@xcrop/sdk 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +361 -2
- package/dist/cjs/client.d.ts +65 -0
- package/dist/cjs/client.d.ts.map +1 -0
- package/dist/cjs/client.js +84 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/cjs/errors.d.ts +38 -0
- package/dist/cjs/errors.d.ts.map +1 -0
- package/dist/cjs/errors.js +70 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/http.d.ts +28 -0
- package/dist/cjs/http.d.ts.map +1 -0
- package/dist/cjs/http.js +250 -0
- package/dist/cjs/http.js.map +1 -0
- package/dist/cjs/index.d.ts +13 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +36 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/resources/account.d.ts +24 -0
- package/dist/cjs/resources/account.d.ts.map +1 -0
- package/dist/cjs/resources/account.js +54 -0
- package/dist/cjs/resources/account.js.map +1 -0
- package/dist/cjs/resources/communities.d.ts +26 -0
- package/dist/cjs/resources/communities.d.ts.map +1 -0
- package/dist/cjs/resources/communities.js +47 -0
- package/dist/cjs/resources/communities.js.map +1 -0
- package/dist/cjs/resources/lists.d.ts +24 -0
- package/dist/cjs/resources/lists.d.ts.map +1 -0
- package/dist/cjs/resources/lists.js +61 -0
- package/dist/cjs/resources/lists.js.map +1 -0
- package/dist/cjs/resources/search.d.ts +60 -0
- package/dist/cjs/resources/search.d.ts.map +1 -0
- package/dist/cjs/resources/search.js +198 -0
- package/dist/cjs/resources/search.js.map +1 -0
- package/dist/cjs/resources/stream.d.ts +45 -0
- package/dist/cjs/resources/stream.d.ts.map +1 -0
- package/dist/cjs/resources/stream.js +129 -0
- package/dist/cjs/resources/stream.js.map +1 -0
- package/dist/cjs/resources/trending.d.ts +11 -0
- package/dist/cjs/resources/trending.d.ts.map +1 -0
- package/dist/cjs/resources/trending.js +21 -0
- package/dist/cjs/resources/trending.js.map +1 -0
- package/dist/cjs/resources/tweets.d.ts +84 -0
- package/dist/cjs/resources/tweets.d.ts.map +1 -0
- package/dist/cjs/resources/tweets.js +179 -0
- package/dist/cjs/resources/tweets.js.map +1 -0
- package/dist/cjs/resources/users.d.ts +81 -0
- package/dist/cjs/resources/users.d.ts.map +1 -0
- package/dist/cjs/resources/users.js +182 -0
- package/dist/cjs/resources/users.js.map +1 -0
- package/dist/cjs/types.d.ts +256 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +4 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/client.d.ts +65 -0
- package/dist/esm/client.d.ts.map +1 -0
- package/dist/esm/client.js +80 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/errors.d.ts +38 -0
- package/dist/esm/errors.d.ts.map +1 -0
- package/dist/esm/errors.js +62 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/http.d.ts +28 -0
- package/dist/esm/http.d.ts.map +1 -0
- package/dist/esm/http.js +246 -0
- package/dist/esm/http.js.map +1 -0
- package/dist/esm/index.d.ts +13 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/resources/account.d.ts +24 -0
- package/dist/esm/resources/account.d.ts.map +1 -0
- package/dist/esm/resources/account.js +50 -0
- package/dist/esm/resources/account.js.map +1 -0
- package/dist/esm/resources/communities.d.ts +26 -0
- package/dist/esm/resources/communities.d.ts.map +1 -0
- package/dist/esm/resources/communities.js +43 -0
- package/dist/esm/resources/communities.js.map +1 -0
- package/dist/esm/resources/lists.d.ts +24 -0
- package/dist/esm/resources/lists.d.ts.map +1 -0
- package/dist/esm/resources/lists.js +56 -0
- package/dist/esm/resources/lists.js.map +1 -0
- package/dist/esm/resources/search.d.ts +60 -0
- package/dist/esm/resources/search.d.ts.map +1 -0
- package/dist/esm/resources/search.js +193 -0
- package/dist/esm/resources/search.js.map +1 -0
- package/dist/esm/resources/stream.d.ts +45 -0
- package/dist/esm/resources/stream.d.ts.map +1 -0
- package/dist/esm/resources/stream.js +124 -0
- package/dist/esm/resources/stream.js.map +1 -0
- package/dist/esm/resources/trending.d.ts +11 -0
- package/dist/esm/resources/trending.d.ts.map +1 -0
- package/dist/esm/resources/trending.js +17 -0
- package/dist/esm/resources/trending.js.map +1 -0
- package/dist/esm/resources/tweets.d.ts +84 -0
- package/dist/esm/resources/tweets.d.ts.map +1 -0
- package/dist/esm/resources/tweets.js +174 -0
- package/dist/esm/resources/tweets.js.map +1 -0
- package/dist/esm/resources/users.d.ts +81 -0
- package/dist/esm/resources/users.d.ts.map +1 -0
- package/dist/esm/resources/users.js +177 -0
- package/dist/esm/resources/users.js.map +1 -0
- package/dist/esm/types.d.ts +256 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +3 -0
- package/dist/esm/types.js.map +1 -0
- package/package.json +43 -4
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ApiResponse, PaginatedResponse, RequestOptions, XCropOptions } from './types.js';
|
|
2
|
+
/** SDK version — single source of truth */
|
|
3
|
+
export declare const SDK_VERSION = "1.0.1";
|
|
4
|
+
/**
|
|
5
|
+
* Low-level HTTP client with automatic retry, backoff, and error mapping.
|
|
6
|
+
*/
|
|
7
|
+
export declare class HttpClient {
|
|
8
|
+
private readonly apiKey;
|
|
9
|
+
private readonly baseUrl;
|
|
10
|
+
private readonly timeout;
|
|
11
|
+
private readonly maxRetries;
|
|
12
|
+
constructor(options: XCropOptions);
|
|
13
|
+
/**
|
|
14
|
+
* Execute a request with automatic retry on 429 and 5xx errors.
|
|
15
|
+
* Returns the parsed JSON response with proper typing for both
|
|
16
|
+
* single-item and paginated responses.
|
|
17
|
+
*/
|
|
18
|
+
request<T>(options: RequestOptions): Promise<ApiResponse<T>>;
|
|
19
|
+
request<T>(options: RequestOptions): Promise<PaginatedResponse<T>>;
|
|
20
|
+
/**
|
|
21
|
+
* Execute a request and return a raw Response for streaming.
|
|
22
|
+
* Includes retry logic for 429/5xx (same as request()).
|
|
23
|
+
* Timeout only applies to the initial connection, not to the stream body.
|
|
24
|
+
*/
|
|
25
|
+
requestRaw(options: RequestOptions): Promise<Response>;
|
|
26
|
+
private buildUrl;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/http.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAM/F,2CAA2C;AAC3C,eAAO,MAAM,WAAW,UAAU,CAAC;AAGnC;;GAEG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;gBAExB,OAAO,EAAE,YAAY;IAOjC;;;;OAIG;IACG,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAC5D,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;IA2HxE;;;;OAIG;IACG,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC;IAgH5D,OAAO,CAAC,QAAQ;CAcjB"}
|
package/dist/cjs/http.js
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpClient = exports.SDK_VERSION = void 0;
|
|
4
|
+
const errors_js_1 = require("./errors.js");
|
|
5
|
+
const DEFAULT_BASE_URL = 'https://xcrop.io/api/v2';
|
|
6
|
+
const DEFAULT_TIMEOUT = 30_000;
|
|
7
|
+
const DEFAULT_MAX_RETRIES = 3;
|
|
8
|
+
/** SDK version — single source of truth */
|
|
9
|
+
exports.SDK_VERSION = '1.0.1';
|
|
10
|
+
const USER_AGENT = `@xcrop/sdk/${exports.SDK_VERSION}`;
|
|
11
|
+
/**
|
|
12
|
+
* Low-level HTTP client with automatic retry, backoff, and error mapping.
|
|
13
|
+
*/
|
|
14
|
+
class HttpClient {
|
|
15
|
+
apiKey;
|
|
16
|
+
baseUrl;
|
|
17
|
+
timeout;
|
|
18
|
+
maxRetries;
|
|
19
|
+
constructor(options) {
|
|
20
|
+
this.apiKey = options.apiKey;
|
|
21
|
+
this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, '');
|
|
22
|
+
this.timeout = options.timeout ?? DEFAULT_TIMEOUT;
|
|
23
|
+
this.maxRetries = options.maxRetries ?? DEFAULT_MAX_RETRIES;
|
|
24
|
+
}
|
|
25
|
+
async request(options) {
|
|
26
|
+
const { method, path, query, body, noRetry, signal } = options;
|
|
27
|
+
const url = this.buildUrl(path, query);
|
|
28
|
+
const headers = {
|
|
29
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
30
|
+
'Content-Type': 'application/json',
|
|
31
|
+
'User-Agent': USER_AGENT,
|
|
32
|
+
};
|
|
33
|
+
const maxAttempts = noRetry ? 1 : this.maxRetries + 1;
|
|
34
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
35
|
+
try {
|
|
36
|
+
const controller = new AbortController();
|
|
37
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
38
|
+
// If an external signal is provided, link it
|
|
39
|
+
if (signal) {
|
|
40
|
+
if (signal.aborted) {
|
|
41
|
+
clearTimeout(timeoutId);
|
|
42
|
+
throw new errors_js_1.XCropError('Request aborted', 0, 'ABORTED');
|
|
43
|
+
}
|
|
44
|
+
signal.addEventListener('abort', () => controller.abort(), { once: true });
|
|
45
|
+
}
|
|
46
|
+
const response = await fetch(url, {
|
|
47
|
+
method,
|
|
48
|
+
headers,
|
|
49
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
50
|
+
signal: controller.signal,
|
|
51
|
+
});
|
|
52
|
+
clearTimeout(timeoutId);
|
|
53
|
+
const responseHeaders = extractHeaders(response.headers);
|
|
54
|
+
if (response.ok) {
|
|
55
|
+
const json = await response.json();
|
|
56
|
+
return json;
|
|
57
|
+
}
|
|
58
|
+
// Parse error body
|
|
59
|
+
let errorBody = {};
|
|
60
|
+
try {
|
|
61
|
+
errorBody = await response.json();
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// ignore parse errors
|
|
65
|
+
}
|
|
66
|
+
const errorMessage = errorBody.error ?? `HTTP ${response.status}`;
|
|
67
|
+
const errorCode = errorBody.code ?? `HTTP_${response.status}`;
|
|
68
|
+
// Non-retryable errors
|
|
69
|
+
if (response.status === 401) {
|
|
70
|
+
throw new errors_js_1.AuthError(errorMessage, responseHeaders);
|
|
71
|
+
}
|
|
72
|
+
if (response.status === 403) {
|
|
73
|
+
throw new errors_js_1.ForbiddenError(errorMessage, responseHeaders);
|
|
74
|
+
}
|
|
75
|
+
if (response.status === 404) {
|
|
76
|
+
throw new errors_js_1.NotFoundError(errorMessage, responseHeaders);
|
|
77
|
+
}
|
|
78
|
+
// Retryable: 429 rate limit
|
|
79
|
+
if (response.status === 429) {
|
|
80
|
+
if (attempt < maxAttempts - 1) {
|
|
81
|
+
const retryAfter = parseInt(responseHeaders['retry-after'] || '', 10);
|
|
82
|
+
const delay = retryAfter > 0
|
|
83
|
+
? retryAfter * 1000
|
|
84
|
+
: backoffDelay(attempt);
|
|
85
|
+
await sleep(delay);
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
throw new errors_js_1.RateLimitError(errorMessage, responseHeaders);
|
|
89
|
+
}
|
|
90
|
+
// Retryable: 5xx server errors
|
|
91
|
+
if (response.status >= 500) {
|
|
92
|
+
if (attempt < maxAttempts - 1) {
|
|
93
|
+
await sleep(backoffDelay(attempt));
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
throw new errors_js_1.XCropError(errorMessage, response.status, errorCode, responseHeaders);
|
|
97
|
+
}
|
|
98
|
+
// Other 4xx — not retryable
|
|
99
|
+
throw new errors_js_1.XCropError(errorMessage, response.status, errorCode, responseHeaders);
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
if (err instanceof errors_js_1.XCropError)
|
|
103
|
+
throw err;
|
|
104
|
+
// Abort / timeout
|
|
105
|
+
if (err instanceof DOMException && err.name === 'AbortError') {
|
|
106
|
+
if (attempt < maxAttempts - 1) {
|
|
107
|
+
await sleep(backoffDelay(attempt));
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
throw new errors_js_1.XCropError(`Request timed out after ${this.timeout}ms`, 0, 'TIMEOUT');
|
|
111
|
+
}
|
|
112
|
+
// Network errors — retry
|
|
113
|
+
if (attempt < maxAttempts - 1) {
|
|
114
|
+
await sleep(backoffDelay(attempt));
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
throw new errors_js_1.XCropError(err.message ?? 'Network error', 0, 'NETWORK_ERROR');
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// Should never reach here
|
|
121
|
+
throw new errors_js_1.XCropError('Max retries exceeded', 0, 'MAX_RETRIES');
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Execute a request and return a raw Response for streaming.
|
|
125
|
+
* Includes retry logic for 429/5xx (same as request()).
|
|
126
|
+
* Timeout only applies to the initial connection, not to the stream body.
|
|
127
|
+
*/
|
|
128
|
+
async requestRaw(options) {
|
|
129
|
+
const { method, path, query, body, signal: externalSignal } = options;
|
|
130
|
+
const url = this.buildUrl(path, query);
|
|
131
|
+
const headers = {
|
|
132
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
133
|
+
'Content-Type': 'application/json',
|
|
134
|
+
'User-Agent': USER_AGENT,
|
|
135
|
+
'Accept': 'text/event-stream',
|
|
136
|
+
};
|
|
137
|
+
const maxAttempts = this.maxRetries + 1;
|
|
138
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
139
|
+
try {
|
|
140
|
+
// For streaming: only timeout the initial connection, not the full stream
|
|
141
|
+
const connectController = new AbortController();
|
|
142
|
+
const connectTimeout = setTimeout(() => connectController.abort(), this.timeout);
|
|
143
|
+
// Link external signal (for .close() cancellation)
|
|
144
|
+
if (externalSignal) {
|
|
145
|
+
if (externalSignal.aborted) {
|
|
146
|
+
clearTimeout(connectTimeout);
|
|
147
|
+
throw new errors_js_1.XCropError('Request aborted', 0, 'ABORTED');
|
|
148
|
+
}
|
|
149
|
+
externalSignal.addEventListener('abort', () => connectController.abort(), { once: true });
|
|
150
|
+
}
|
|
151
|
+
const response = await fetch(url, {
|
|
152
|
+
method,
|
|
153
|
+
headers,
|
|
154
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
155
|
+
signal: connectController.signal,
|
|
156
|
+
});
|
|
157
|
+
// Connection established — clear the connect timeout
|
|
158
|
+
// The stream can now read for as long as needed
|
|
159
|
+
clearTimeout(connectTimeout);
|
|
160
|
+
if (response.ok) {
|
|
161
|
+
return response;
|
|
162
|
+
}
|
|
163
|
+
const responseHeaders = extractHeaders(response.headers);
|
|
164
|
+
let errorBody = {};
|
|
165
|
+
try {
|
|
166
|
+
errorBody = await response.json();
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
// ignore
|
|
170
|
+
}
|
|
171
|
+
const msg = errorBody.error ?? `HTTP ${response.status}`;
|
|
172
|
+
// Non-retryable
|
|
173
|
+
if (response.status === 401)
|
|
174
|
+
throw new errors_js_1.AuthError(msg, responseHeaders);
|
|
175
|
+
if (response.status === 403)
|
|
176
|
+
throw new errors_js_1.ForbiddenError(msg, responseHeaders);
|
|
177
|
+
if (response.status === 404)
|
|
178
|
+
throw new errors_js_1.NotFoundError(msg, responseHeaders);
|
|
179
|
+
// Retryable: 429
|
|
180
|
+
if (response.status === 429) {
|
|
181
|
+
if (attempt < maxAttempts - 1) {
|
|
182
|
+
const retryAfter = parseInt(responseHeaders['retry-after'] || '', 10);
|
|
183
|
+
const delay = retryAfter > 0 ? retryAfter * 1000 : backoffDelay(attempt);
|
|
184
|
+
await sleep(delay);
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
throw new errors_js_1.RateLimitError(msg, responseHeaders);
|
|
188
|
+
}
|
|
189
|
+
// Retryable: 5xx
|
|
190
|
+
if (response.status >= 500) {
|
|
191
|
+
if (attempt < maxAttempts - 1) {
|
|
192
|
+
await sleep(backoffDelay(attempt));
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
throw new errors_js_1.XCropError(msg, response.status, errorBody.code ?? 'ERROR', responseHeaders);
|
|
197
|
+
}
|
|
198
|
+
catch (err) {
|
|
199
|
+
if (err instanceof errors_js_1.XCropError)
|
|
200
|
+
throw err;
|
|
201
|
+
if (err instanceof DOMException && err.name === 'AbortError') {
|
|
202
|
+
// Check if it was an external abort (user called .close())
|
|
203
|
+
if (externalSignal?.aborted) {
|
|
204
|
+
throw new errors_js_1.XCropError('Request aborted', 0, 'ABORTED');
|
|
205
|
+
}
|
|
206
|
+
if (attempt < maxAttempts - 1) {
|
|
207
|
+
await sleep(backoffDelay(attempt));
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
throw new errors_js_1.XCropError(`Request timed out after ${this.timeout}ms`, 0, 'TIMEOUT');
|
|
211
|
+
}
|
|
212
|
+
if (attempt < maxAttempts - 1) {
|
|
213
|
+
await sleep(backoffDelay(attempt));
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
throw new errors_js_1.XCropError(err.message ?? 'Network error', 0, 'NETWORK_ERROR');
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
throw new errors_js_1.XCropError('Max retries exceeded', 0, 'MAX_RETRIES');
|
|
220
|
+
}
|
|
221
|
+
buildUrl(path, query) {
|
|
222
|
+
const url = new URL(`${this.baseUrl}${path}`);
|
|
223
|
+
if (query) {
|
|
224
|
+
for (const [key, value] of Object.entries(query)) {
|
|
225
|
+
if (value !== undefined && value !== null) {
|
|
226
|
+
url.searchParams.set(key, String(value));
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return url.toString();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
exports.HttpClient = HttpClient;
|
|
234
|
+
function extractHeaders(headers) {
|
|
235
|
+
const result = {};
|
|
236
|
+
headers.forEach((value, key) => {
|
|
237
|
+
result[key.toLowerCase()] = value;
|
|
238
|
+
});
|
|
239
|
+
return result;
|
|
240
|
+
}
|
|
241
|
+
function backoffDelay(attempt) {
|
|
242
|
+
// Exponential backoff: 1s, 2s, 4s + jitter
|
|
243
|
+
const base = Math.min(1000 * Math.pow(2, attempt), 10_000);
|
|
244
|
+
const jitter = Math.random() * 500;
|
|
245
|
+
return base + jitter;
|
|
246
|
+
}
|
|
247
|
+
function sleep(ms) {
|
|
248
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
249
|
+
}
|
|
250
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/http.ts"],"names":[],"mappings":";;;AAAA,2CAMqB;AAGrB,MAAM,gBAAgB,GAAG,yBAAyB,CAAC;AACnD,MAAM,eAAe,GAAG,MAAM,CAAC;AAC/B,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAE9B,2CAA2C;AAC9B,QAAA,WAAW,GAAG,OAAO,CAAC;AACnC,MAAM,UAAU,GAAG,cAAc,mBAAW,EAAE,CAAC;AAE/C;;GAEG;AACH,MAAa,UAAU;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|
|
2
|
+
export { SDK_VERSION } from './http.js';
|
|
3
|
+
export { XCropError, AuthError, RateLimitError, NotFoundError, ForbiddenError, } from './errors.js';
|
|
4
|
+
export { UsersResource } from './resources/users.js';
|
|
5
|
+
export { TweetsResource } from './resources/tweets.js';
|
|
6
|
+
export { SearchResource, SearchStream } from './resources/search.js';
|
|
7
|
+
export { ListsResource } from './resources/lists.js';
|
|
8
|
+
export { TrendingResource } from './resources/trending.js';
|
|
9
|
+
export { CommunitiesResource } from './resources/communities.js';
|
|
10
|
+
export { AccountResource } from './resources/account.js';
|
|
11
|
+
export { StreamResource, RealtimeStream } from './resources/stream.js';
|
|
12
|
+
export type { XCropOptions, ApiMeta, ApiResponse, ApiErrorResponse, PaginationParams, PaginatedResponse, User, CheckFollowResult, Tweet, Media, UrlEntity, List, TrendingTopic, TrendingParams, Community, SearchTweetsParams, SearchUsersParams, ConnectAccountParams, AccountStatus, CreateTweetParams, ReplyTweetParams, QuoteTweetParams, WriteResult, InteractionCheckResult, QualifiedAccountParams, QualifiedAccountResult, QualifiedNameParams, QualifiedNameResult, FollowersIdsParams, FollowersIdsMeta, FollowersIdsResponse, CommunityTweetsParams, CommunityMembersParams, StreamOptions, StreamEvent, RequestOptions, } from './types.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGpC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGxC,OAAO,EACL,UAAU,EACV,SAAS,EACT,cAAc,EACd,aAAa,EACb,cAAc,GACf,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvE,YAAY,EAEV,YAAY,EAGZ,OAAO,EACP,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EAGjB,IAAI,EACJ,iBAAiB,EACjB,KAAK,EACL,KAAK,EACL,SAAS,EACT,IAAI,EACJ,aAAa,EACb,cAAc,EACd,SAAS,EAGT,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,aAAa,EACb,WAAW,EACX,cAAc,GACf,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RealtimeStream = exports.StreamResource = exports.AccountResource = exports.CommunitiesResource = exports.TrendingResource = exports.ListsResource = exports.SearchStream = exports.SearchResource = exports.TweetsResource = exports.UsersResource = exports.ForbiddenError = exports.NotFoundError = exports.RateLimitError = exports.AuthError = exports.XCropError = exports.SDK_VERSION = exports.XCrop = void 0;
|
|
4
|
+
// Main client
|
|
5
|
+
var client_js_1 = require("./client.js");
|
|
6
|
+
Object.defineProperty(exports, "XCrop", { enumerable: true, get: function () { return client_js_1.XCrop; } });
|
|
7
|
+
// SDK version
|
|
8
|
+
var http_js_1 = require("./http.js");
|
|
9
|
+
Object.defineProperty(exports, "SDK_VERSION", { enumerable: true, get: function () { return http_js_1.SDK_VERSION; } });
|
|
10
|
+
// Error classes
|
|
11
|
+
var errors_js_1 = require("./errors.js");
|
|
12
|
+
Object.defineProperty(exports, "XCropError", { enumerable: true, get: function () { return errors_js_1.XCropError; } });
|
|
13
|
+
Object.defineProperty(exports, "AuthError", { enumerable: true, get: function () { return errors_js_1.AuthError; } });
|
|
14
|
+
Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return errors_js_1.RateLimitError; } });
|
|
15
|
+
Object.defineProperty(exports, "NotFoundError", { enumerable: true, get: function () { return errors_js_1.NotFoundError; } });
|
|
16
|
+
Object.defineProperty(exports, "ForbiddenError", { enumerable: true, get: function () { return errors_js_1.ForbiddenError; } });
|
|
17
|
+
// Resource classes (for advanced usage / type narrowing)
|
|
18
|
+
var users_js_1 = require("./resources/users.js");
|
|
19
|
+
Object.defineProperty(exports, "UsersResource", { enumerable: true, get: function () { return users_js_1.UsersResource; } });
|
|
20
|
+
var tweets_js_1 = require("./resources/tweets.js");
|
|
21
|
+
Object.defineProperty(exports, "TweetsResource", { enumerable: true, get: function () { return tweets_js_1.TweetsResource; } });
|
|
22
|
+
var search_js_1 = require("./resources/search.js");
|
|
23
|
+
Object.defineProperty(exports, "SearchResource", { enumerable: true, get: function () { return search_js_1.SearchResource; } });
|
|
24
|
+
Object.defineProperty(exports, "SearchStream", { enumerable: true, get: function () { return search_js_1.SearchStream; } });
|
|
25
|
+
var lists_js_1 = require("./resources/lists.js");
|
|
26
|
+
Object.defineProperty(exports, "ListsResource", { enumerable: true, get: function () { return lists_js_1.ListsResource; } });
|
|
27
|
+
var trending_js_1 = require("./resources/trending.js");
|
|
28
|
+
Object.defineProperty(exports, "TrendingResource", { enumerable: true, get: function () { return trending_js_1.TrendingResource; } });
|
|
29
|
+
var communities_js_1 = require("./resources/communities.js");
|
|
30
|
+
Object.defineProperty(exports, "CommunitiesResource", { enumerable: true, get: function () { return communities_js_1.CommunitiesResource; } });
|
|
31
|
+
var account_js_1 = require("./resources/account.js");
|
|
32
|
+
Object.defineProperty(exports, "AccountResource", { enumerable: true, get: function () { return account_js_1.AccountResource; } });
|
|
33
|
+
var stream_js_1 = require("./resources/stream.js");
|
|
34
|
+
Object.defineProperty(exports, "StreamResource", { enumerable: true, get: function () { return stream_js_1.StreamResource; } });
|
|
35
|
+
Object.defineProperty(exports, "RealtimeStream", { enumerable: true, get: function () { return stream_js_1.RealtimeStream; } });
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,cAAc;AACd,yCAAoC;AAA3B,kGAAA,KAAK,OAAA;AAEd,cAAc;AACd,qCAAwC;AAA/B,sGAAA,WAAW,OAAA;AAEpB,gBAAgB;AAChB,yCAMqB;AALnB,uGAAA,UAAU,OAAA;AACV,sGAAA,SAAS,OAAA;AACT,2GAAA,cAAc,OAAA;AACd,0GAAA,aAAa,OAAA;AACb,2GAAA,cAAc,OAAA;AAGhB,yDAAyD;AACzD,iDAAqD;AAA5C,yGAAA,aAAa,OAAA;AACtB,mDAAuD;AAA9C,2GAAA,cAAc,OAAA;AACvB,mDAAqE;AAA5D,2GAAA,cAAc,OAAA;AAAE,yGAAA,YAAY,OAAA;AACrC,iDAAqD;AAA5C,yGAAA,aAAa,OAAA;AACtB,uDAA2D;AAAlD,+GAAA,gBAAgB,OAAA;AACzB,6DAAiE;AAAxD,qHAAA,mBAAmB,OAAA;AAC5B,qDAAyD;AAAhD,6GAAA,eAAe,OAAA;AACxB,mDAAuE;AAA9D,2GAAA,cAAc,OAAA;AAAE,2GAAA,cAAc,OAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { HttpClient } from '../http.js';
|
|
2
|
+
import type { ConnectAccountParams, AccountStatus, ApiResponse } from '../types.js';
|
|
3
|
+
export declare class AccountResource {
|
|
4
|
+
private readonly http;
|
|
5
|
+
constructor(http: HttpClient);
|
|
6
|
+
/**
|
|
7
|
+
* Connect an X account using credentials or cookies.
|
|
8
|
+
* Required for write operations (tweet, like, retweet, follow).
|
|
9
|
+
*/
|
|
10
|
+
connect(params: ConnectAccountParams): Promise<ApiResponse<{
|
|
11
|
+
success: boolean;
|
|
12
|
+
}>>;
|
|
13
|
+
/**
|
|
14
|
+
* Check the current X account connection status.
|
|
15
|
+
*/
|
|
16
|
+
status(): Promise<ApiResponse<AccountStatus>>;
|
|
17
|
+
/**
|
|
18
|
+
* Disconnect the X account and remove stored credentials.
|
|
19
|
+
*/
|
|
20
|
+
disconnect(): Promise<ApiResponse<{
|
|
21
|
+
success: boolean;
|
|
22
|
+
}>>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=account.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../../src/resources/account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACb,WAAW,EACZ,MAAM,aAAa,CAAC;AAErB,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;OAGG;IACG,OAAO,CACX,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,WAAW,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAuB7C;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IAOnD;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,WAAW,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CAM/D"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AccountResource = void 0;
|
|
4
|
+
class AccountResource {
|
|
5
|
+
http;
|
|
6
|
+
constructor(http) {
|
|
7
|
+
this.http = http;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Connect an X account using credentials or cookies.
|
|
11
|
+
* Required for write operations (tweet, like, retweet, follow).
|
|
12
|
+
*/
|
|
13
|
+
async connect(params) {
|
|
14
|
+
const hasCredentials = params.username && params.password;
|
|
15
|
+
const hasCookies = params.cookies?.auth_token && params.cookies?.ct0;
|
|
16
|
+
if (!hasCredentials && !hasCookies) {
|
|
17
|
+
throw new Error('Either credentials (username + password) or cookies (auth_token + ct0) must be provided');
|
|
18
|
+
}
|
|
19
|
+
const body = {};
|
|
20
|
+
if (params.username)
|
|
21
|
+
body.username = params.username;
|
|
22
|
+
if (params.password)
|
|
23
|
+
body.password = params.password;
|
|
24
|
+
if (params.totp_secret)
|
|
25
|
+
body.totp_secret = params.totp_secret;
|
|
26
|
+
if (params.cookies)
|
|
27
|
+
body.cookies = params.cookies;
|
|
28
|
+
return this.http.request({
|
|
29
|
+
method: 'POST',
|
|
30
|
+
path: '/account/connect',
|
|
31
|
+
body,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Check the current X account connection status.
|
|
36
|
+
*/
|
|
37
|
+
async status() {
|
|
38
|
+
return this.http.request({
|
|
39
|
+
method: 'GET',
|
|
40
|
+
path: '/account/status',
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Disconnect the X account and remove stored credentials.
|
|
45
|
+
*/
|
|
46
|
+
async disconnect() {
|
|
47
|
+
return this.http.request({
|
|
48
|
+
method: 'DELETE',
|
|
49
|
+
path: '/account/disconnect',
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.AccountResource = AccountResource;
|
|
54
|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AAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU;QACd,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAuB;YAC7C,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,qBAAqB;SAC5B,CAAC,CAAC;IACL,CAAC;CACF;AAnDD,0CAmDC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { HttpClient } from '../http.js';
|
|
2
|
+
import type { Community, Tweet, User, PaginatedResponse, ApiResponse, CommunityTweetsParams, CommunityMembersParams } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* X Communities data.
|
|
5
|
+
*
|
|
6
|
+
* ⚠️ Beta: these endpoints are newly added to the platform and may
|
|
7
|
+
* return a 503 (`ENDPOINT_IN_DEVELOPMENT`) while the backend is being
|
|
8
|
+
* finished. Treat a 503 here as "not ready yet", not a hard failure.
|
|
9
|
+
*/
|
|
10
|
+
export declare class CommunitiesResource {
|
|
11
|
+
private readonly http;
|
|
12
|
+
constructor(http: HttpClient);
|
|
13
|
+
/**
|
|
14
|
+
* Get a community's profile.
|
|
15
|
+
*/
|
|
16
|
+
get(communityId: string): Promise<ApiResponse<Community>>;
|
|
17
|
+
/**
|
|
18
|
+
* Get tweets from a community's timeline.
|
|
19
|
+
*/
|
|
20
|
+
tweets(communityId: string, params?: CommunityTweetsParams): Promise<PaginatedResponse<Tweet>>;
|
|
21
|
+
/**
|
|
22
|
+
* Get members of a community.
|
|
23
|
+
*/
|
|
24
|
+
members(communityId: string, params?: CommunityMembersParams): Promise<PaginatedResponse<User>>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=communities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"communities.d.ts","sourceRoot":"","sources":["../../../src/resources/communities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,SAAS,EACT,KAAK,EACL,IAAI,EACJ,iBAAiB,EACjB,WAAW,EACX,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAErB;;;;;;GAMG;AACH,qBAAa,mBAAmB;IAClB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;OAEG;IACG,GAAG,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAO/D;;OAEG;IACG,MAAM,CACV,WAAW,EAAE,MAAM,EACnB,MAAM,GAAE,qBAA0B,GACjC,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAQpC;;OAEG;IACG,OAAO,CACX,WAAW,EAAE,MAAM,EACnB,MAAM,GAAE,sBAA2B,GAClC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;CAOpC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommunitiesResource = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* X Communities data.
|
|
6
|
+
*
|
|
7
|
+
* ⚠️ Beta: these endpoints are newly added to the platform and may
|
|
8
|
+
* return a 503 (`ENDPOINT_IN_DEVELOPMENT`) while the backend is being
|
|
9
|
+
* finished. Treat a 503 here as "not ready yet", not a hard failure.
|
|
10
|
+
*/
|
|
11
|
+
class CommunitiesResource {
|
|
12
|
+
http;
|
|
13
|
+
constructor(http) {
|
|
14
|
+
this.http = http;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Get a community's profile.
|
|
18
|
+
*/
|
|
19
|
+
async get(communityId) {
|
|
20
|
+
return this.http.request({
|
|
21
|
+
method: 'GET',
|
|
22
|
+
path: `/communities/${encodeURIComponent(communityId)}`,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get tweets from a community's timeline.
|
|
27
|
+
*/
|
|
28
|
+
async tweets(communityId, params = {}) {
|
|
29
|
+
return this.http.request({
|
|
30
|
+
method: 'GET',
|
|
31
|
+
path: `/communities/${encodeURIComponent(communityId)}/tweets`,
|
|
32
|
+
query: { count: params.count, sort: params.sort, cursor: params.cursor },
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get members of a community.
|
|
37
|
+
*/
|
|
38
|
+
async members(communityId, params = {}) {
|
|
39
|
+
return this.http.request({
|
|
40
|
+
method: 'GET',
|
|
41
|
+
path: `/communities/${encodeURIComponent(communityId)}/members`,
|
|
42
|
+
query: { count: params.count, sort: params.sort, cursor: params.cursor },
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.CommunitiesResource = CommunitiesResource;
|
|
47
|
+
//# sourceMappingURL=communities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"communities.js","sourceRoot":"","sources":["../../../src/resources/communities.ts"],"names":[],"mappings":";;;AAWA;;;;;;GAMG;AACH,MAAa,mBAAmB;IACD;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;OAEG;IACH,KAAK,CAAC,GAAG,CAAC,WAAmB;QAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAY;YAClC,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,gBAAgB,kBAAkB,CAAC,WAAW,CAAC,EAAE;SACxD,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CACV,WAAmB,EACnB,SAAgC,EAAE;QAElC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;YACvB,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,gBAAgB,kBAAkB,CAAC,WAAW,CAAC,SAAS;YAC9D,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;SACzE,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO,CACX,WAAmB,EACnB,SAAiC,EAAE;QAEnC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;YACvB,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,gBAAgB,kBAAkB,CAAC,WAAW,CAAC,UAAU;YAC/D,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;SACzE,CAAC,CAAC;IACL,CAAC;CACF;AAxCD,kDAwCC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { HttpClient } from '../http.js';
|
|
2
|
+
import type { Tweet, User, PaginationParams, PaginatedResponse } from '../types.js';
|
|
3
|
+
export declare class ListsResource {
|
|
4
|
+
private readonly http;
|
|
5
|
+
constructor(http: HttpClient);
|
|
6
|
+
/**
|
|
7
|
+
* Get tweets from a list.
|
|
8
|
+
*/
|
|
9
|
+
tweets(listId: string, params?: PaginationParams): Promise<PaginatedResponse<Tweet>>;
|
|
10
|
+
/**
|
|
11
|
+
* Get members of a list.
|
|
12
|
+
*/
|
|
13
|
+
members(listId: string, params?: PaginationParams): Promise<PaginatedResponse<User>>;
|
|
14
|
+
/**
|
|
15
|
+
* Get subscribers of a list.
|
|
16
|
+
*/
|
|
17
|
+
subscribers(listId: string, params?: PaginationParams): Promise<PaginatedResponse<User>>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Async generator that auto-paginates a list-based paginated endpoint.
|
|
21
|
+
* @param maxPages Safety limit to prevent infinite loops (default 100).
|
|
22
|
+
*/
|
|
23
|
+
export declare function paginateList<T>(method: (listId: string, params: PaginationParams) => Promise<PaginatedResponse<T>>, listId: string, params?: PaginationParams, maxPages?: number): AsyncGenerator<T, void, undefined>;
|
|
24
|
+
//# sourceMappingURL=lists.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lists.d.ts","sourceRoot":"","sources":["../../../src/resources/lists.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,KAAK,EACL,IAAI,EACJ,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAIrB,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;OAEG;IACG,MAAM,CACV,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,gBAAqB,GAC5B,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAQpC;;OAEG;IACG,OAAO,CACX,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,gBAAqB,GAC5B,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAQnC;;OAEG;IACG,WAAW,CACf,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,gBAAqB,GAC5B,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;CAOpC;AAED;;;GAGG;AACH,wBAAuB,YAAY,CAAC,CAAC,EACnC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,EACnF,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,gBAAqB,EAC7B,QAAQ,GAAE,MAA0B,GACnC,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,CAgBpC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ListsResource = void 0;
|
|
4
|
+
exports.paginateList = paginateList;
|
|
5
|
+
const DEFAULT_MAX_PAGES = 100;
|
|
6
|
+
class ListsResource {
|
|
7
|
+
http;
|
|
8
|
+
constructor(http) {
|
|
9
|
+
this.http = http;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Get tweets from a list.
|
|
13
|
+
*/
|
|
14
|
+
async tweets(listId, params = {}) {
|
|
15
|
+
return this.http.request({
|
|
16
|
+
method: 'GET',
|
|
17
|
+
path: `/lists/${encodeURIComponent(listId)}/tweets`,
|
|
18
|
+
query: { count: params.count, cursor: params.cursor },
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get members of a list.
|
|
23
|
+
*/
|
|
24
|
+
async members(listId, params = {}) {
|
|
25
|
+
return this.http.request({
|
|
26
|
+
method: 'GET',
|
|
27
|
+
path: `/lists/${encodeURIComponent(listId)}/members`,
|
|
28
|
+
query: { count: params.count, cursor: params.cursor },
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get subscribers of a list.
|
|
33
|
+
*/
|
|
34
|
+
async subscribers(listId, params = {}) {
|
|
35
|
+
return this.http.request({
|
|
36
|
+
method: 'GET',
|
|
37
|
+
path: `/lists/${encodeURIComponent(listId)}/subscribers`,
|
|
38
|
+
query: { count: params.count, cursor: params.cursor },
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.ListsResource = ListsResource;
|
|
43
|
+
/**
|
|
44
|
+
* Async generator that auto-paginates a list-based paginated endpoint.
|
|
45
|
+
* @param maxPages Safety limit to prevent infinite loops (default 100).
|
|
46
|
+
*/
|
|
47
|
+
async function* paginateList(method, listId, params = {}, maxPages = DEFAULT_MAX_PAGES) {
|
|
48
|
+
let cursor = params.cursor;
|
|
49
|
+
let hasNext = true;
|
|
50
|
+
let page = 0;
|
|
51
|
+
while (hasNext && page < maxPages) {
|
|
52
|
+
const response = await method(listId, { ...params, cursor });
|
|
53
|
+
for (const item of response.data) {
|
|
54
|
+
yield item;
|
|
55
|
+
}
|
|
56
|
+
cursor = response.meta.cursor;
|
|
57
|
+
hasNext = !!response.meta.has_next && !!cursor;
|
|
58
|
+
page++;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=lists.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lists.js","sourceRoot":"","sources":["../../../src/resources/lists.ts"],"names":[],"mappings":";;;AA4DA,oCAqBC;AAzED,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAE9B,MAAa,aAAa;IACK;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;OAEG;IACH,KAAK,CAAC,MAAM,CACV,MAAc,EACd,SAA2B,EAAE;QAE7B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;YACvB,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,UAAU,kBAAkB,CAAC,MAAM,CAAC,SAAS;YACnD,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;SACtD,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO,CACX,MAAc,EACd,SAA2B,EAAE;QAE7B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;YACvB,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,UAAU,kBAAkB,CAAC,MAAM,CAAC,UAAU;YACpD,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;SACtD,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CACf,MAAc,EACd,SAA2B,EAAE;QAE7B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;YACvB,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,UAAU,kBAAkB,CAAC,MAAM,CAAC,cAAc;YACxD,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