@doist/twist-sdk 0.1.0-alpha.2 → 0.1.0-alpha.4
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/batch-builder.d.ts +2 -5
- package/dist/batch-builder.js +21 -8
- package/dist/clients/base-client.d.ts +27 -0
- package/dist/clients/base-client.js +34 -0
- package/dist/clients/channels-client.d.ts +40 -23
- package/dist/clients/channels-client.js +29 -16
- package/dist/clients/comments-client.d.ts +12 -10
- package/dist/clients/comments-client.js +24 -11
- package/dist/clients/conversation-messages-client.d.ts +2 -5
- package/dist/clients/conversation-messages-client.js +21 -8
- package/dist/clients/conversations-client.d.ts +61 -33
- package/dist/clients/conversations-client.js +35 -22
- package/dist/clients/groups-client.d.ts +39 -22
- package/dist/clients/groups-client.js +29 -16
- package/dist/clients/inbox-client.d.ts +2 -5
- package/dist/clients/inbox-client.js +21 -8
- package/dist/clients/reactions-client.d.ts +2 -5
- package/dist/clients/reactions-client.js +21 -8
- package/dist/clients/search-client.d.ts +3 -5
- package/dist/clients/search-client.js +21 -8
- package/dist/clients/threads-client.d.ts +48 -26
- package/dist/clients/threads-client.js +31 -18
- package/dist/clients/users-client.d.ts +2 -5
- package/dist/clients/users-client.js +21 -8
- package/dist/clients/workspace-users-client.d.ts +52 -30
- package/dist/clients/workspace-users-client.js +41 -28
- package/dist/clients/workspaces-client.d.ts +2 -5
- package/dist/clients/workspaces-client.js +21 -8
- package/dist/consts/endpoints.d.ts +12 -1
- package/dist/consts/endpoints.js +13 -2
- package/dist/twist-api.js +15 -13
- package/dist/types/api-version.d.ts +4 -0
- package/dist/types/api-version.js +2 -0
- package/dist/types/entities.d.ts +20 -20
- package/dist/types/entities.js +13 -39
- package/package.json +13 -10
package/dist/batch-builder.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BaseClient } from './clients/base-client';
|
|
1
2
|
import type { BatchRequestDescriptor, BatchResponseArray } from './types/batch';
|
|
2
3
|
/**
|
|
3
4
|
* Executes multiple API requests in a single HTTP call.
|
|
@@ -10,11 +11,7 @@ import type { BatchRequestDescriptor, BatchResponseArray } from './types/batch';
|
|
|
10
11
|
* )
|
|
11
12
|
* ```
|
|
12
13
|
*/
|
|
13
|
-
export declare class BatchBuilder {
|
|
14
|
-
private apiToken;
|
|
15
|
-
private baseUrl?;
|
|
16
|
-
constructor(apiToken: string, baseUrl?: string | undefined);
|
|
17
|
-
private getBaseUri;
|
|
14
|
+
export declare class BatchBuilder extends BaseClient {
|
|
18
15
|
/**
|
|
19
16
|
* Executes an array of batch request descriptors in a single API call.
|
|
20
17
|
*
|
package/dist/batch-builder.js
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
2
17
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
18
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
19
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -37,6 +52,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
52
|
};
|
|
38
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
54
|
exports.BatchBuilder = void 0;
|
|
55
|
+
var base_client_1 = require("./clients/base-client");
|
|
40
56
|
var errors_1 = require("./types/errors");
|
|
41
57
|
var case_conversion_1 = require("./utils/case-conversion");
|
|
42
58
|
var timestamp_conversion_1 = require("./utils/timestamp-conversion");
|
|
@@ -51,14 +67,11 @@ var timestamp_conversion_1 = require("./utils/timestamp-conversion");
|
|
|
51
67
|
* )
|
|
52
68
|
* ```
|
|
53
69
|
*/
|
|
54
|
-
var BatchBuilder = /** @class */ (function () {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
this
|
|
70
|
+
var BatchBuilder = /** @class */ (function (_super) {
|
|
71
|
+
__extends(BatchBuilder, _super);
|
|
72
|
+
function BatchBuilder() {
|
|
73
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
58
74
|
}
|
|
59
|
-
BatchBuilder.prototype.getBaseUri = function () {
|
|
60
|
-
return this.baseUrl ? "".concat(this.baseUrl, "/api/v3") : 'https://api.twist.com/api/v3/';
|
|
61
|
-
};
|
|
62
75
|
/**
|
|
63
76
|
* Executes an array of batch request descriptors in a single API call.
|
|
64
77
|
*
|
|
@@ -187,5 +200,5 @@ var BatchBuilder = /** @class */ (function () {
|
|
|
187
200
|
});
|
|
188
201
|
};
|
|
189
202
|
return BatchBuilder;
|
|
190
|
-
}());
|
|
203
|
+
}(base_client_1.BaseClient));
|
|
191
204
|
exports.BatchBuilder = BatchBuilder;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ApiVersion } from '../types/api-version';
|
|
2
|
+
export interface ClientConfig {
|
|
3
|
+
/** API token for authentication */
|
|
4
|
+
apiToken: string;
|
|
5
|
+
/** Optional custom base URL. If not provided, uses the default Twist API URL */
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
/** Optional API version. Defaults to 'v3' */
|
|
8
|
+
version?: ApiVersion;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Base client class that provides centralized URL management and configuration
|
|
12
|
+
* for all Twist API clients. Fixes the trailing slash bug and eliminates code duplication.
|
|
13
|
+
*/
|
|
14
|
+
export declare class BaseClient {
|
|
15
|
+
protected readonly apiToken: string;
|
|
16
|
+
protected readonly baseUrl?: string;
|
|
17
|
+
protected readonly defaultVersion: ApiVersion;
|
|
18
|
+
constructor(config: ClientConfig);
|
|
19
|
+
/**
|
|
20
|
+
* Gets the base URI for API requests with proper trailing slash handling.
|
|
21
|
+
* This method fixes the trailing slash bug that occurred when using custom baseUrl.
|
|
22
|
+
*
|
|
23
|
+
* @param version - Optional API version override. Defaults to the configured version or 'v3'
|
|
24
|
+
* @returns Base URI with guaranteed trailing slash for proper URL resolution
|
|
25
|
+
*/
|
|
26
|
+
protected getBaseUri(version?: ApiVersion): string;
|
|
27
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseClient = void 0;
|
|
4
|
+
var endpoints_1 = require("../consts/endpoints");
|
|
5
|
+
/**
|
|
6
|
+
* Base client class that provides centralized URL management and configuration
|
|
7
|
+
* for all Twist API clients. Fixes the trailing slash bug and eliminates code duplication.
|
|
8
|
+
*/
|
|
9
|
+
var BaseClient = /** @class */ (function () {
|
|
10
|
+
function BaseClient(config) {
|
|
11
|
+
this.apiToken = config.apiToken;
|
|
12
|
+
this.baseUrl = config.baseUrl;
|
|
13
|
+
this.defaultVersion = config.version || 'v3';
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Gets the base URI for API requests with proper trailing slash handling.
|
|
17
|
+
* This method fixes the trailing slash bug that occurred when using custom baseUrl.
|
|
18
|
+
*
|
|
19
|
+
* @param version - Optional API version override. Defaults to the configured version or 'v3'
|
|
20
|
+
* @returns Base URI with guaranteed trailing slash for proper URL resolution
|
|
21
|
+
*/
|
|
22
|
+
BaseClient.prototype.getBaseUri = function (version) {
|
|
23
|
+
var apiVersion = version || this.defaultVersion;
|
|
24
|
+
if (this.baseUrl) {
|
|
25
|
+
// Ensure trailing slash to fix URL resolution bug
|
|
26
|
+
var normalizedBaseUrl = this.baseUrl.endsWith('/') ? this.baseUrl : "".concat(this.baseUrl, "/");
|
|
27
|
+
return "".concat(normalizedBaseUrl, "api/").concat(apiVersion, "/");
|
|
28
|
+
}
|
|
29
|
+
// Use centralized helper function for default Twist API URL
|
|
30
|
+
return (0, endpoints_1.getTwistBaseUri)(apiVersion);
|
|
31
|
+
};
|
|
32
|
+
return BaseClient;
|
|
33
|
+
}());
|
|
34
|
+
exports.BaseClient = BaseClient;
|
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
import type { BatchRequestDescriptor } from '../types/batch';
|
|
2
2
|
import { Channel } from '../types/entities';
|
|
3
3
|
import { CreateChannelArgs, GetChannelsArgs, UpdateChannelArgs } from '../types/requests';
|
|
4
|
+
import { BaseClient } from './base-client';
|
|
5
|
+
export type AddChannelUserArgs = {
|
|
6
|
+
id: number;
|
|
7
|
+
userId: number;
|
|
8
|
+
};
|
|
9
|
+
export type AddChannelUsersArgs = {
|
|
10
|
+
id: number;
|
|
11
|
+
userIds: number[];
|
|
12
|
+
};
|
|
13
|
+
export type RemoveChannelUserArgs = {
|
|
14
|
+
id: number;
|
|
15
|
+
userId: number;
|
|
16
|
+
};
|
|
17
|
+
export type RemoveChannelUsersArgs = {
|
|
18
|
+
id: number;
|
|
19
|
+
userIds: number[];
|
|
20
|
+
};
|
|
4
21
|
/**
|
|
5
22
|
* Client for interacting with Twist channel endpoints.
|
|
6
23
|
*/
|
|
7
|
-
export declare class ChannelsClient {
|
|
8
|
-
private apiToken;
|
|
9
|
-
private baseUrl?;
|
|
10
|
-
constructor(apiToken: string, baseUrl?: string | undefined);
|
|
11
|
-
private getBaseUri;
|
|
24
|
+
export declare class ChannelsClient extends BaseClient {
|
|
12
25
|
/**
|
|
13
26
|
* Gets all channels for a given workspace.
|
|
14
27
|
*
|
|
@@ -152,63 +165,67 @@ export declare class ChannelsClient {
|
|
|
152
165
|
/**
|
|
153
166
|
* Adds a user to a channel.
|
|
154
167
|
*
|
|
155
|
-
* @param
|
|
156
|
-
* @param
|
|
168
|
+
* @param args - The arguments for adding a user.
|
|
169
|
+
* @param args.id - The channel ID.
|
|
170
|
+
* @param args.userId - The user ID to add.
|
|
157
171
|
* @param options - Optional configuration. Set `batch: true` to return a descriptor for batch requests.
|
|
158
172
|
*
|
|
159
173
|
* @example
|
|
160
174
|
* ```typescript
|
|
161
|
-
* await api.channels.addUser(456, 789)
|
|
175
|
+
* await api.channels.addUser({ id: 456, userId: 789 })
|
|
162
176
|
* ```
|
|
163
177
|
*/
|
|
164
|
-
addUser(
|
|
178
|
+
addUser(args: AddChannelUserArgs, options: {
|
|
165
179
|
batch: true;
|
|
166
180
|
}): BatchRequestDescriptor<void>;
|
|
167
|
-
addUser(
|
|
181
|
+
addUser(args: AddChannelUserArgs, options?: {
|
|
168
182
|
batch?: false;
|
|
169
183
|
}): Promise<void>;
|
|
170
184
|
/**
|
|
171
185
|
* Adds multiple users to a channel.
|
|
172
186
|
*
|
|
173
|
-
* @param
|
|
174
|
-
* @param
|
|
187
|
+
* @param args - The arguments for adding users.
|
|
188
|
+
* @param args.id - The channel ID.
|
|
189
|
+
* @param args.userIds - Array of user IDs to add.
|
|
175
190
|
* @param options - Optional configuration. Set `batch: true` to return a descriptor for batch requests.
|
|
176
191
|
*
|
|
177
192
|
* @example
|
|
178
193
|
* ```typescript
|
|
179
|
-
* await api.channels.addUsers(456, [789, 790, 791])
|
|
194
|
+
* await api.channels.addUsers({ id: 456, userIds: [789, 790, 791] })
|
|
180
195
|
* ```
|
|
181
196
|
*/
|
|
182
|
-
addUsers(
|
|
197
|
+
addUsers(args: AddChannelUsersArgs, options: {
|
|
183
198
|
batch: true;
|
|
184
199
|
}): BatchRequestDescriptor<void>;
|
|
185
|
-
addUsers(
|
|
200
|
+
addUsers(args: AddChannelUsersArgs, options?: {
|
|
186
201
|
batch?: false;
|
|
187
202
|
}): Promise<void>;
|
|
188
203
|
/**
|
|
189
204
|
* Removes a user from a channel.
|
|
190
205
|
*
|
|
191
|
-
* @param
|
|
192
|
-
* @param
|
|
206
|
+
* @param args - The arguments for removing a user.
|
|
207
|
+
* @param args.id - The channel ID.
|
|
208
|
+
* @param args.userId - The user ID to remove.
|
|
193
209
|
* @param options - Optional configuration. Set `batch: true` to return a descriptor for batch requests.
|
|
194
210
|
*/
|
|
195
|
-
removeUser(
|
|
211
|
+
removeUser(args: RemoveChannelUserArgs, options: {
|
|
196
212
|
batch: true;
|
|
197
213
|
}): BatchRequestDescriptor<void>;
|
|
198
|
-
removeUser(
|
|
214
|
+
removeUser(args: RemoveChannelUserArgs, options?: {
|
|
199
215
|
batch?: false;
|
|
200
216
|
}): Promise<void>;
|
|
201
217
|
/**
|
|
202
218
|
* Removes multiple users from a channel.
|
|
203
219
|
*
|
|
204
|
-
* @param
|
|
205
|
-
* @param
|
|
220
|
+
* @param args - The arguments for removing users.
|
|
221
|
+
* @param args.id - The channel ID.
|
|
222
|
+
* @param args.userIds - Array of user IDs to remove.
|
|
206
223
|
* @param options - Optional configuration. Set `batch: true` to return a descriptor for batch requests.
|
|
207
224
|
*/
|
|
208
|
-
removeUsers(
|
|
225
|
+
removeUsers(args: RemoveChannelUsersArgs, options: {
|
|
209
226
|
batch: true;
|
|
210
227
|
}): BatchRequestDescriptor<void>;
|
|
211
|
-
removeUsers(
|
|
228
|
+
removeUsers(args: RemoveChannelUsersArgs, options?: {
|
|
212
229
|
batch?: false;
|
|
213
230
|
}): Promise<void>;
|
|
214
231
|
}
|
|
@@ -1,20 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
2
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
18
|
exports.ChannelsClient = void 0;
|
|
4
19
|
var endpoints_1 = require("../consts/endpoints");
|
|
5
20
|
var rest_client_1 = require("../rest-client");
|
|
6
21
|
var entities_1 = require("../types/entities");
|
|
22
|
+
var base_client_1 = require("./base-client");
|
|
7
23
|
/**
|
|
8
24
|
* Client for interacting with Twist channel endpoints.
|
|
9
25
|
*/
|
|
10
|
-
var ChannelsClient = /** @class */ (function () {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this
|
|
26
|
+
var ChannelsClient = /** @class */ (function (_super) {
|
|
27
|
+
__extends(ChannelsClient, _super);
|
|
28
|
+
function ChannelsClient() {
|
|
29
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
14
30
|
}
|
|
15
|
-
ChannelsClient.prototype.getBaseUri = function () {
|
|
16
|
-
return this.baseUrl ? "".concat(this.baseUrl, "/api/v3") : (0, endpoints_1.getTwistBaseUri)();
|
|
17
|
-
};
|
|
18
31
|
ChannelsClient.prototype.getChannels = function (args, options) {
|
|
19
32
|
var method = 'GET';
|
|
20
33
|
var url = "".concat(endpoints_1.ENDPOINT_CHANNELS, "/get");
|
|
@@ -99,42 +112,42 @@ var ChannelsClient = /** @class */ (function () {
|
|
|
99
112
|
}
|
|
100
113
|
return (0, rest_client_1.request)(method, this.getBaseUri(), url, this.apiToken, params).then(function () { return undefined; });
|
|
101
114
|
};
|
|
102
|
-
ChannelsClient.prototype.addUser = function (
|
|
115
|
+
ChannelsClient.prototype.addUser = function (args, options) {
|
|
103
116
|
var method = 'POST';
|
|
104
117
|
var url = "".concat(endpoints_1.ENDPOINT_CHANNELS, "/add_user");
|
|
105
|
-
var params = { id: id, userId: userId };
|
|
118
|
+
var params = { id: args.id, userId: args.userId };
|
|
106
119
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
107
120
|
return { method: method, url: url, params: params };
|
|
108
121
|
}
|
|
109
122
|
return (0, rest_client_1.request)(method, this.getBaseUri(), url, this.apiToken, params).then(function () { return undefined; });
|
|
110
123
|
};
|
|
111
|
-
ChannelsClient.prototype.addUsers = function (
|
|
124
|
+
ChannelsClient.prototype.addUsers = function (args, options) {
|
|
112
125
|
var method = 'POST';
|
|
113
126
|
var url = "".concat(endpoints_1.ENDPOINT_CHANNELS, "/add_users");
|
|
114
|
-
var params = { id: id, userIds: userIds };
|
|
127
|
+
var params = { id: args.id, userIds: args.userIds };
|
|
115
128
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
116
129
|
return { method: method, url: url, params: params };
|
|
117
130
|
}
|
|
118
131
|
return (0, rest_client_1.request)(method, this.getBaseUri(), url, this.apiToken, params).then(function () { return undefined; });
|
|
119
132
|
};
|
|
120
|
-
ChannelsClient.prototype.removeUser = function (
|
|
133
|
+
ChannelsClient.prototype.removeUser = function (args, options) {
|
|
121
134
|
var method = 'POST';
|
|
122
135
|
var url = "".concat(endpoints_1.ENDPOINT_CHANNELS, "/remove_user");
|
|
123
|
-
var params = { id: id, userId: userId };
|
|
136
|
+
var params = { id: args.id, userId: args.userId };
|
|
124
137
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
125
138
|
return { method: method, url: url, params: params };
|
|
126
139
|
}
|
|
127
140
|
return (0, rest_client_1.request)(method, this.getBaseUri(), url, this.apiToken, params).then(function () { return undefined; });
|
|
128
141
|
};
|
|
129
|
-
ChannelsClient.prototype.removeUsers = function (
|
|
142
|
+
ChannelsClient.prototype.removeUsers = function (args, options) {
|
|
130
143
|
var method = 'POST';
|
|
131
144
|
var url = "".concat(endpoints_1.ENDPOINT_CHANNELS, "/remove_users");
|
|
132
|
-
var params = { id: id, userIds: userIds };
|
|
145
|
+
var params = { id: args.id, userIds: args.userIds };
|
|
133
146
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
134
147
|
return { method: method, url: url, params: params };
|
|
135
148
|
}
|
|
136
149
|
return (0, rest_client_1.request)(method, this.getBaseUri(), url, this.apiToken, params).then(function () { return undefined; });
|
|
137
150
|
};
|
|
138
151
|
return ChannelsClient;
|
|
139
|
-
}());
|
|
152
|
+
}(base_client_1.BaseClient));
|
|
140
153
|
exports.ChannelsClient = ChannelsClient;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { BatchRequestDescriptor } from '../types/batch';
|
|
2
2
|
import { Comment } from '../types/entities';
|
|
3
3
|
import { CreateCommentArgs, GetCommentsArgs, UpdateCommentArgs } from '../types/requests';
|
|
4
|
+
import { BaseClient } from './base-client';
|
|
5
|
+
export type MarkCommentPositionArgs = {
|
|
6
|
+
threadId: number;
|
|
7
|
+
commentId: number;
|
|
8
|
+
};
|
|
4
9
|
/**
|
|
5
10
|
* Client for interacting with Twist comment endpoints.
|
|
6
11
|
*/
|
|
7
|
-
export declare class CommentsClient {
|
|
8
|
-
private apiToken;
|
|
9
|
-
private baseUrl?;
|
|
10
|
-
constructor(apiToken: string, baseUrl?: string | undefined);
|
|
11
|
-
private getBaseUri;
|
|
12
|
+
export declare class CommentsClient extends BaseClient {
|
|
12
13
|
/**
|
|
13
14
|
* Gets all comments for a thread.
|
|
14
15
|
*
|
|
@@ -106,19 +107,20 @@ export declare class CommentsClient {
|
|
|
106
107
|
* Marks the user's read position in a thread. Used to track where the user has read up to,
|
|
107
108
|
* so clients can scroll to this position and show a visual indicator (blue line).
|
|
108
109
|
*
|
|
109
|
-
* @param
|
|
110
|
-
* @param
|
|
110
|
+
* @param args - The arguments for marking read position.
|
|
111
|
+
* @param args.threadId - The thread ID.
|
|
112
|
+
* @param args.commentId - The comment ID to mark as the last read position.
|
|
111
113
|
* @param options - Optional configuration. Set `batch: true` to return a descriptor for batch requests.
|
|
112
114
|
*
|
|
113
115
|
* @example
|
|
114
116
|
* ```typescript
|
|
115
|
-
* await api.comments.markPosition(789, 206113)
|
|
117
|
+
* await api.comments.markPosition({ threadId: 789, commentId: 206113 })
|
|
116
118
|
* ```
|
|
117
119
|
*/
|
|
118
|
-
markPosition(
|
|
120
|
+
markPosition(args: MarkCommentPositionArgs, options: {
|
|
119
121
|
batch: true;
|
|
120
122
|
}): BatchRequestDescriptor<void>;
|
|
121
|
-
markPosition(
|
|
123
|
+
markPosition(args: MarkCommentPositionArgs, options?: {
|
|
122
124
|
batch?: false;
|
|
123
125
|
}): Promise<void>;
|
|
124
126
|
}
|
|
@@ -1,20 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
2
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
18
|
exports.CommentsClient = void 0;
|
|
4
19
|
var endpoints_1 = require("../consts/endpoints");
|
|
5
20
|
var rest_client_1 = require("../rest-client");
|
|
6
21
|
var entities_1 = require("../types/entities");
|
|
22
|
+
var base_client_1 = require("./base-client");
|
|
7
23
|
/**
|
|
8
24
|
* Client for interacting with Twist comment endpoints.
|
|
9
25
|
*/
|
|
10
|
-
var CommentsClient = /** @class */ (function () {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this
|
|
26
|
+
var CommentsClient = /** @class */ (function (_super) {
|
|
27
|
+
__extends(CommentsClient, _super);
|
|
28
|
+
function CommentsClient() {
|
|
29
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
14
30
|
}
|
|
15
|
-
CommentsClient.prototype.getBaseUri = function () {
|
|
16
|
-
return this.baseUrl ? "".concat(this.baseUrl, "/api/v3") : (0, endpoints_1.getTwistBaseUri)();
|
|
17
|
-
};
|
|
18
31
|
CommentsClient.prototype.getComments = function (args, options) {
|
|
19
32
|
var params = {
|
|
20
33
|
thread_id: args.threadId,
|
|
@@ -69,12 +82,12 @@ var CommentsClient = /** @class */ (function () {
|
|
|
69
82
|
}
|
|
70
83
|
return (0, rest_client_1.request)(method, this.getBaseUri(), url, this.apiToken, params).then(function () { return undefined; });
|
|
71
84
|
};
|
|
72
|
-
CommentsClient.prototype.markPosition = function (
|
|
85
|
+
CommentsClient.prototype.markPosition = function (args, options) {
|
|
73
86
|
var method = 'POST';
|
|
74
87
|
var url = "".concat(endpoints_1.ENDPOINT_COMMENTS, "/mark_position");
|
|
75
88
|
var params = {
|
|
76
|
-
thread_id: threadId,
|
|
77
|
-
comment_id: commentId,
|
|
89
|
+
thread_id: args.threadId,
|
|
90
|
+
comment_id: args.commentId,
|
|
78
91
|
};
|
|
79
92
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
80
93
|
return { method: method, url: url, params: params };
|
|
@@ -82,5 +95,5 @@ var CommentsClient = /** @class */ (function () {
|
|
|
82
95
|
return (0, rest_client_1.request)(method, this.getBaseUri(), url, this.apiToken, params).then(function () { return undefined; });
|
|
83
96
|
};
|
|
84
97
|
return CommentsClient;
|
|
85
|
-
}());
|
|
98
|
+
}(base_client_1.BaseClient));
|
|
86
99
|
exports.CommentsClient = CommentsClient;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BatchRequestDescriptor } from '../types/batch';
|
|
2
2
|
import { ConversationMessage } from '../types/entities';
|
|
3
|
+
import { BaseClient } from './base-client';
|
|
3
4
|
type GetConversationMessagesArgs = {
|
|
4
5
|
conversationId: number;
|
|
5
6
|
newerThan?: Date;
|
|
@@ -21,11 +22,7 @@ type UpdateConversationMessageArgs = {
|
|
|
21
22
|
/**
|
|
22
23
|
* Client for interacting with Twist conversation message endpoints.
|
|
23
24
|
*/
|
|
24
|
-
export declare class ConversationMessagesClient {
|
|
25
|
-
private apiToken;
|
|
26
|
-
private baseUrl?;
|
|
27
|
-
constructor(apiToken: string, baseUrl?: string | undefined);
|
|
28
|
-
private getBaseUri;
|
|
25
|
+
export declare class ConversationMessagesClient extends BaseClient {
|
|
29
26
|
/**
|
|
30
27
|
* Gets all messages in a conversation.
|
|
31
28
|
*
|
|
@@ -1,20 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
2
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
18
|
exports.ConversationMessagesClient = void 0;
|
|
4
19
|
var endpoints_1 = require("../consts/endpoints");
|
|
5
20
|
var rest_client_1 = require("../rest-client");
|
|
6
21
|
var entities_1 = require("../types/entities");
|
|
22
|
+
var base_client_1 = require("./base-client");
|
|
7
23
|
/**
|
|
8
24
|
* Client for interacting with Twist conversation message endpoints.
|
|
9
25
|
*/
|
|
10
|
-
var ConversationMessagesClient = /** @class */ (function () {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this
|
|
26
|
+
var ConversationMessagesClient = /** @class */ (function (_super) {
|
|
27
|
+
__extends(ConversationMessagesClient, _super);
|
|
28
|
+
function ConversationMessagesClient() {
|
|
29
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
14
30
|
}
|
|
15
|
-
ConversationMessagesClient.prototype.getBaseUri = function () {
|
|
16
|
-
return this.baseUrl ? "".concat(this.baseUrl, "/api/v3") : (0, endpoints_1.getTwistBaseUri)();
|
|
17
|
-
};
|
|
18
31
|
ConversationMessagesClient.prototype.getMessages = function (args, options) {
|
|
19
32
|
var params = {
|
|
20
33
|
conversation_id: args.conversationId,
|
|
@@ -88,5 +101,5 @@ var ConversationMessagesClient = /** @class */ (function () {
|
|
|
88
101
|
return (0, rest_client_1.request)(method, this.getBaseUri(), url, this.apiToken, params).then(function () { return undefined; });
|
|
89
102
|
};
|
|
90
103
|
return ConversationMessagesClient;
|
|
91
|
-
}());
|
|
104
|
+
}(base_client_1.BaseClient));
|
|
92
105
|
exports.ConversationMessagesClient = ConversationMessagesClient;
|