@doist/twist-sdk 0.1.0-alpha.3 → 0.1.0-alpha.5
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 +21 -8
- package/dist/batch-builder.js +99 -13
- package/dist/clients/base-client.d.ts +27 -0
- package/dist/clients/base-client.js +34 -0
- package/dist/clients/channels-client.d.ts +2 -5
- package/dist/clients/channels-client.js +21 -8
- package/dist/clients/comments-client.d.ts +2 -5
- package/dist/clients/comments-client.js +21 -8
- 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 +2 -5
- package/dist/clients/conversations-client.js +21 -8
- package/dist/clients/groups-client.d.ts +2 -5
- package/dist/clients/groups-client.js +21 -8
- 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 +2 -5
- package/dist/clients/threads-client.js +21 -8
- 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 +2 -5
- package/dist/clients/workspace-users-client.js +31 -18
- 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/package.json +5 -5
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,17 +11,29 @@ import type { BatchRequestDescriptor, BatchResponseArray } from './types/batch';
|
|
|
10
11
|
* )
|
|
11
12
|
* ```
|
|
12
13
|
*/
|
|
13
|
-
export declare class BatchBuilder {
|
|
14
|
-
private
|
|
15
|
-
private baseUrl?;
|
|
16
|
-
constructor(apiToken: string, baseUrl?: string | undefined);
|
|
17
|
-
private getBaseUri;
|
|
14
|
+
export declare class BatchBuilder extends BaseClient {
|
|
15
|
+
private static readonly CHUNK_SIZE;
|
|
18
16
|
/**
|
|
19
|
-
*
|
|
17
|
+
* Splits an array of requests into chunks of the specified size.
|
|
18
|
+
*/
|
|
19
|
+
private chunkRequests;
|
|
20
|
+
/**
|
|
21
|
+
* Flattens chunked results back into a single array while preserving the original order.
|
|
22
|
+
*/
|
|
23
|
+
private flattenChunkedResults;
|
|
24
|
+
/**
|
|
25
|
+
* Executes a single chunk of batch requests (up to CHUNK_SIZE).
|
|
26
|
+
* This is the core batch execution logic extracted from the original execute method.
|
|
27
|
+
*/
|
|
28
|
+
private executeSingleBatch;
|
|
29
|
+
/**
|
|
30
|
+
* Executes multiple API requests with automatic chunking and parallel execution.
|
|
31
|
+
* Transparently handles the 10-request API limitation by splitting large batches
|
|
32
|
+
* into smaller chunks and executing them concurrently.
|
|
20
33
|
*
|
|
21
34
|
* @param requests - Array of batch request descriptors
|
|
22
|
-
* @returns Array of BatchResponse objects with processed data
|
|
23
|
-
* @throws {TwistRequestError} If
|
|
35
|
+
* @returns Array of BatchResponse objects with processed data in original order
|
|
36
|
+
* @throws {TwistRequestError} If any batch chunk fails completely
|
|
24
37
|
*/
|
|
25
38
|
execute<T extends readonly BatchRequestDescriptor<unknown>[]>(requests: T): Promise<BatchResponseArray<T>>;
|
|
26
39
|
}
|
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) {
|
|
@@ -35,8 +50,18 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
50
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
51
|
}
|
|
37
52
|
};
|
|
53
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
54
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
55
|
+
if (ar || !(i in from)) {
|
|
56
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
57
|
+
ar[i] = from[i];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
61
|
+
};
|
|
38
62
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
63
|
exports.BatchBuilder = void 0;
|
|
64
|
+
var base_client_1 = require("./clients/base-client");
|
|
40
65
|
var errors_1 = require("./types/errors");
|
|
41
66
|
var case_conversion_1 = require("./utils/case-conversion");
|
|
42
67
|
var timestamp_conversion_1 = require("./utils/timestamp-conversion");
|
|
@@ -51,22 +76,35 @@ var timestamp_conversion_1 = require("./utils/timestamp-conversion");
|
|
|
51
76
|
* )
|
|
52
77
|
* ```
|
|
53
78
|
*/
|
|
54
|
-
var BatchBuilder = /** @class */ (function () {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
this
|
|
79
|
+
var BatchBuilder = /** @class */ (function (_super) {
|
|
80
|
+
__extends(BatchBuilder, _super);
|
|
81
|
+
function BatchBuilder() {
|
|
82
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
58
83
|
}
|
|
59
|
-
|
|
60
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Splits an array of requests into chunks of the specified size.
|
|
86
|
+
*/
|
|
87
|
+
BatchBuilder.prototype.chunkRequests = function (requests, chunkSize) {
|
|
88
|
+
if (requests.length === 0) {
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
var chunks = [];
|
|
92
|
+
for (var i = 0; i < requests.length; i += chunkSize) {
|
|
93
|
+
chunks.push(requests.slice(i, i + chunkSize));
|
|
94
|
+
}
|
|
95
|
+
return chunks;
|
|
61
96
|
};
|
|
62
97
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* @param requests - Array of batch request descriptors
|
|
66
|
-
* @returns Array of BatchResponse objects with processed data
|
|
67
|
-
* @throws {TwistRequestError} If the batch request fails
|
|
98
|
+
* Flattens chunked results back into a single array while preserving the original order.
|
|
68
99
|
*/
|
|
69
|
-
BatchBuilder.prototype.
|
|
100
|
+
BatchBuilder.prototype.flattenChunkedResults = function (chunkedResults) {
|
|
101
|
+
return chunkedResults.flat();
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Executes a single chunk of batch requests (up to CHUNK_SIZE).
|
|
105
|
+
* This is the core batch execution logic extracted from the original execute method.
|
|
106
|
+
*/
|
|
107
|
+
BatchBuilder.prototype.executeSingleBatch = function (requests) {
|
|
70
108
|
return __awaiter(this, void 0, void 0, function () {
|
|
71
109
|
var batchRequests, allGets, formData, response, errorText, batchApiResponses;
|
|
72
110
|
var _this = this;
|
|
@@ -186,6 +224,54 @@ var BatchBuilder = /** @class */ (function () {
|
|
|
186
224
|
});
|
|
187
225
|
});
|
|
188
226
|
};
|
|
227
|
+
/**
|
|
228
|
+
* Executes multiple API requests with automatic chunking and parallel execution.
|
|
229
|
+
* Transparently handles the 10-request API limitation by splitting large batches
|
|
230
|
+
* into smaller chunks and executing them concurrently.
|
|
231
|
+
*
|
|
232
|
+
* @param requests - Array of batch request descriptors
|
|
233
|
+
* @returns Array of BatchResponse objects with processed data in original order
|
|
234
|
+
* @throws {TwistRequestError} If any batch chunk fails completely
|
|
235
|
+
*/
|
|
236
|
+
BatchBuilder.prototype.execute = function (requests) {
|
|
237
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
238
|
+
var chunks, chunkPromises, chunkedResults;
|
|
239
|
+
var _this = this;
|
|
240
|
+
return __generator(this, function (_a) {
|
|
241
|
+
switch (_a.label) {
|
|
242
|
+
case 0:
|
|
243
|
+
if (requests.length === 0) {
|
|
244
|
+
return [2 /*return*/, []];
|
|
245
|
+
}
|
|
246
|
+
// If requests fit within a single chunk, use the original single-batch execution
|
|
247
|
+
if (requests.length <= BatchBuilder.CHUNK_SIZE) {
|
|
248
|
+
return [2 /*return*/, this.executeSingleBatch(requests)];
|
|
249
|
+
}
|
|
250
|
+
chunks = this.chunkRequests(__spreadArray([], requests, true), BatchBuilder.CHUNK_SIZE);
|
|
251
|
+
chunkPromises = chunks.map(function (chunk) {
|
|
252
|
+
return _this.executeSingleBatch(chunk).catch(function (error) {
|
|
253
|
+
// Collect errors but don't fail fast - allow other chunks to complete
|
|
254
|
+
console.error('Batch chunk failed:', error);
|
|
255
|
+
// Return error responses for all requests in this chunk
|
|
256
|
+
return chunk.map(function () { return ({
|
|
257
|
+
code: 500,
|
|
258
|
+
headers: {},
|
|
259
|
+
data: null,
|
|
260
|
+
}); });
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
return [4 /*yield*/, Promise.all(chunkPromises)
|
|
264
|
+
// Flatten results back to original order
|
|
265
|
+
];
|
|
266
|
+
case 1:
|
|
267
|
+
chunkedResults = _a.sent();
|
|
268
|
+
// Flatten results back to original order
|
|
269
|
+
return [2 /*return*/, this.flattenChunkedResults(chunkedResults)];
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
};
|
|
274
|
+
BatchBuilder.CHUNK_SIZE = 10;
|
|
189
275
|
return BatchBuilder;
|
|
190
|
-
}());
|
|
276
|
+
}(base_client_1.BaseClient));
|
|
191
277
|
exports.BatchBuilder = BatchBuilder;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ApiVersion } from '../types/api-version';
|
|
2
|
+
export type 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,6 +1,7 @@
|
|
|
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';
|
|
4
5
|
export type AddChannelUserArgs = {
|
|
5
6
|
id: number;
|
|
6
7
|
userId: number;
|
|
@@ -20,11 +21,7 @@ export type RemoveChannelUsersArgs = {
|
|
|
20
21
|
/**
|
|
21
22
|
* Client for interacting with Twist channel endpoints.
|
|
22
23
|
*/
|
|
23
|
-
export declare class ChannelsClient {
|
|
24
|
-
private apiToken;
|
|
25
|
-
private baseUrl?;
|
|
26
|
-
constructor(apiToken: string, baseUrl?: string | undefined);
|
|
27
|
-
private getBaseUri;
|
|
24
|
+
export declare class ChannelsClient extends BaseClient {
|
|
28
25
|
/**
|
|
29
26
|
* Gets all channels for a given workspace.
|
|
30
27
|
*
|
|
@@ -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");
|
|
@@ -136,5 +149,5 @@ var ChannelsClient = /** @class */ (function () {
|
|
|
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,6 +1,7 @@
|
|
|
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';
|
|
4
5
|
export type MarkCommentPositionArgs = {
|
|
5
6
|
threadId: number;
|
|
6
7
|
commentId: number;
|
|
@@ -8,11 +9,7 @@ export type MarkCommentPositionArgs = {
|
|
|
8
9
|
/**
|
|
9
10
|
* Client for interacting with Twist comment endpoints.
|
|
10
11
|
*/
|
|
11
|
-
export declare class CommentsClient {
|
|
12
|
-
private apiToken;
|
|
13
|
-
private baseUrl?;
|
|
14
|
-
constructor(apiToken: string, baseUrl?: string | undefined);
|
|
15
|
-
private getBaseUri;
|
|
12
|
+
export declare class CommentsClient extends BaseClient {
|
|
16
13
|
/**
|
|
17
14
|
* Gets all comments for a thread.
|
|
18
15
|
*
|
|
@@ -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,
|
|
@@ -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;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { BatchRequestDescriptor } from '../types/batch';
|
|
2
2
|
import { Conversation, UnreadConversation } from '../types/entities';
|
|
3
3
|
import { GetConversationsArgs, GetOrCreateConversationArgs } from '../types/requests';
|
|
4
|
+
import { BaseClient } from './base-client';
|
|
4
5
|
export type UpdateConversationArgs = {
|
|
5
6
|
id: number;
|
|
6
7
|
title: string;
|
|
@@ -29,11 +30,7 @@ export type MuteConversationArgs = {
|
|
|
29
30
|
/**
|
|
30
31
|
* Client for interacting with Twist conversation endpoints.
|
|
31
32
|
*/
|
|
32
|
-
export declare class ConversationsClient {
|
|
33
|
-
private apiToken;
|
|
34
|
-
private baseUrl?;
|
|
35
|
-
constructor(apiToken: string, baseUrl?: string | undefined);
|
|
36
|
-
private getBaseUri;
|
|
33
|
+
export declare class ConversationsClient extends BaseClient {
|
|
37
34
|
/**
|
|
38
35
|
* Gets all conversations for a workspace.
|
|
39
36
|
*
|
|
@@ -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.ConversationsClient = 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 endpoints.
|
|
9
25
|
*/
|
|
10
|
-
var ConversationsClient = /** @class */ (function () {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this
|
|
26
|
+
var ConversationsClient = /** @class */ (function (_super) {
|
|
27
|
+
__extends(ConversationsClient, _super);
|
|
28
|
+
function ConversationsClient() {
|
|
29
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
14
30
|
}
|
|
15
|
-
ConversationsClient.prototype.getBaseUri = function () {
|
|
16
|
-
return this.baseUrl ? "".concat(this.baseUrl, "/api/v3") : (0, endpoints_1.getTwistBaseUri)();
|
|
17
|
-
};
|
|
18
31
|
ConversationsClient.prototype.getConversations = function (args, options) {
|
|
19
32
|
var method = 'GET';
|
|
20
33
|
var url = "".concat(endpoints_1.ENDPOINT_CONVERSATIONS, "/get");
|
|
@@ -170,5 +183,5 @@ var ConversationsClient = /** @class */ (function () {
|
|
|
170
183
|
return (0, rest_client_1.request)(method, this.getBaseUri(), url, this.apiToken, params).then(function (response) { return schema.parse(response.data); });
|
|
171
184
|
};
|
|
172
185
|
return ConversationsClient;
|
|
173
|
-
}());
|
|
186
|
+
}(base_client_1.BaseClient));
|
|
174
187
|
exports.ConversationsClient = ConversationsClient;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BatchRequestDescriptor } from '../types/batch';
|
|
2
2
|
import { Group } from '../types/entities';
|
|
3
|
+
import { BaseClient } from './base-client';
|
|
3
4
|
export type AddGroupUserArgs = {
|
|
4
5
|
id: number;
|
|
5
6
|
userId: number;
|
|
@@ -19,11 +20,7 @@ export type RemoveGroupUsersArgs = {
|
|
|
19
20
|
/**
|
|
20
21
|
* Client for interacting with Twist group endpoints.
|
|
21
22
|
*/
|
|
22
|
-
export declare class GroupsClient {
|
|
23
|
-
private apiToken;
|
|
24
|
-
private baseUrl?;
|
|
25
|
-
constructor(apiToken: string, baseUrl?: string | undefined);
|
|
26
|
-
private getBaseUri;
|
|
23
|
+
export declare class GroupsClient extends BaseClient {
|
|
27
24
|
/**
|
|
28
25
|
* Gets all groups for a given workspace.
|
|
29
26
|
*
|
|
@@ -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.GroupsClient = 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 group endpoints.
|
|
9
25
|
*/
|
|
10
|
-
var GroupsClient = /** @class */ (function () {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this
|
|
26
|
+
var GroupsClient = /** @class */ (function (_super) {
|
|
27
|
+
__extends(GroupsClient, _super);
|
|
28
|
+
function GroupsClient() {
|
|
29
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
14
30
|
}
|
|
15
|
-
GroupsClient.prototype.getBaseUri = function () {
|
|
16
|
-
return this.baseUrl ? "".concat(this.baseUrl, "/api/v3") : (0, endpoints_1.getTwistBaseUri)();
|
|
17
|
-
};
|
|
18
31
|
GroupsClient.prototype.getGroups = function (workspaceId, options) {
|
|
19
32
|
var method = 'GET';
|
|
20
33
|
var url = "".concat(endpoints_1.ENDPOINT_GROUPS, "/get");
|
|
@@ -100,5 +113,5 @@ var GroupsClient = /** @class */ (function () {
|
|
|
100
113
|
return (0, rest_client_1.request)(method, this.getBaseUri(), url, this.apiToken, params).then(function () { return undefined; });
|
|
101
114
|
};
|
|
102
115
|
return GroupsClient;
|
|
103
|
-
}());
|
|
116
|
+
}(base_client_1.BaseClient));
|
|
104
117
|
exports.GroupsClient = GroupsClient;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BatchRequestDescriptor } from '../types/batch';
|
|
2
2
|
import { InboxThread } from '../types/entities';
|
|
3
|
+
import { BaseClient } from './base-client';
|
|
3
4
|
type GetInboxArgs = {
|
|
4
5
|
workspaceId: number;
|
|
5
6
|
since?: Date;
|
|
@@ -16,11 +17,7 @@ type ArchiveAllArgs = {
|
|
|
16
17
|
/**
|
|
17
18
|
* Client for interacting with Twist inbox endpoints.
|
|
18
19
|
*/
|
|
19
|
-
export declare class InboxClient {
|
|
20
|
-
private apiToken;
|
|
21
|
-
private baseUrl?;
|
|
22
|
-
constructor(apiToken: string, baseUrl?: string | undefined);
|
|
23
|
-
private getBaseUri;
|
|
20
|
+
export declare class InboxClient extends BaseClient {
|
|
24
21
|
/**
|
|
25
22
|
* Gets inbox items (threads).
|
|
26
23
|
*
|