twitter-api-browser-js 0.0.13 → 0.1.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/README.md CHANGED
@@ -4,4 +4,4 @@ Look [example.ts](./example.ts);
4
4
 
5
5
  notice: It doesn't work well with Bun or Deno due to compatibility issues.
6
6
 
7
- <img width="890" height="234" alt="image" src="https://github.com/user-attachments/assets/768a3524-5b2a-463d-b06c-cd39cdbb4f72" />
7
+ <img alt="example" src="./.github/assets/example.png" />
package/dist/main.d.ts CHANGED
@@ -18,7 +18,7 @@ export declare class TwitterAPIBrowser {
18
18
  * @param waitForReady - The number of seconds to wait for the browser to be ready.
19
19
  * @param headless - Whether to run the browser in headless mode. (Recommended: false)
20
20
  */
21
- setup(waitForReady?: number, headless?: boolean, proxy?: string | undefined): Promise<void>;
21
+ setup(waitForReady?: number, headless?: boolean, proxy?: string | undefined, args?: string[]): Promise<void>;
22
22
  /**
23
23
  * @description Closes the browser context and page.
24
24
  */
@@ -39,7 +39,7 @@ export declare class TwitterAPIBrowser {
39
39
  * @param body - The body of the request
40
40
  * @returns Response of the request
41
41
  */
42
- graphql<T extends string = string>(method: string, path: string, body: LooseType): Promise<SuccessResponse<T> | LooseErrorResponse>;
42
+ graphql<T extends string = string>(method: string, path: string, body: LooseType): Promise<LooseType>;
43
43
  /**
44
44
  * Sends a request to the Twitter API
45
45
  * @param operationName - The name of the operation to request
@@ -47,5 +47,8 @@ export declare class TwitterAPIBrowser {
47
47
  * @param fieldToggles - The fields to toggle on or off in the operation
48
48
  * @returns Response of the request
49
49
  */
50
- request<T extends keyof TwitterOpenAPIModelsMapping = string>(operationName: T, variables: LooseType, fieldToggles?: Record<string, boolean>, features?: Record<string, LooseType> | null): Promise<SuccessResponse<T> | LooseErrorResponse>;
50
+ request<T extends keyof TwitterOpenAPIModelsMapping = string>(operationName: T, variables: LooseType, fieldToggles?: Record<string, boolean>, features?: Record<string, LooseType> | null): Promise<{
51
+ success: boolean;
52
+ response: SuccessResponse<T> | LooseErrorResponse;
53
+ }>;
51
54
  }
package/dist/main.js CHANGED
@@ -32,7 +32,7 @@ export class TwitterAPIBrowser {
32
32
  * @param waitForReady - The number of seconds to wait for the browser to be ready.
33
33
  * @param headless - Whether to run the browser in headless mode. (Recommended: false)
34
34
  */
35
- async setup(waitForReady = 5, headless = false, proxy = void 0) {
35
+ async setup(waitForReady = 5, headless = false, proxy = void 0, args = []) {
36
36
  if (this.browser && this.page) {
37
37
  await this.close();
38
38
  }
@@ -47,6 +47,7 @@ export class TwitterAPIBrowser {
47
47
  "--disable-dev-shm-usage",
48
48
  "--disable-gpu",
49
49
  proxy ? `--proxy-server=${proxy}` : "",
50
+ ...args,
50
51
  ],
51
52
  })
52
53
  .then(resolve)
@@ -218,6 +219,16 @@ export class TwitterAPIBrowser {
218
219
  delete body[key];
219
220
  }
220
221
  });
221
- return await this.graphql(method, `/graphql/${queryId}/${operationName}`, body);
222
+ const response = await this.graphql(method, `/graphql/${queryId}/${operationName}`, body);
223
+ if (response.errors) {
224
+ return {
225
+ success: false,
226
+ response: response,
227
+ };
228
+ }
229
+ return {
230
+ success: true,
231
+ response: response,
232
+ };
222
233
  }
223
234
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "twitter-api-browser-js",
3
- "version": "0.0.13",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {