@open-wa/wa-automate-types-only 4.48.0 → 4.49.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/api/Client.d.ts +41 -15
- package/dist/connect/index.d.ts +1 -0
- package/dist/connect/socket.d.ts +96 -0
- package/dist/controllers/browser.ignore.d.ts +13 -0
- package/dist/controllers/data_dir_watcher.d.ts +2 -0
- package/dist/utils/configSchema.d.ts +5 -0
- package/dist/utils/elastic.d.ts +50 -0
- package/package.json +1 -1
package/dist/api/Client.d.ts
CHANGED
@@ -208,7 +208,8 @@ export declare class Client {
|
|
208
208
|
*/
|
209
209
|
onPlugged(fn: (plugged: boolean) => void): Promise<Listener | boolean>;
|
210
210
|
/**
|
211
|
-
*
|
211
|
+
* {@license:restricted@}
|
212
|
+
*
|
212
213
|
* Listens to when a contact posts a new story.
|
213
214
|
* @event
|
214
215
|
*
|
@@ -1693,30 +1694,55 @@ export declare class Client {
|
|
1693
1694
|
*/
|
1694
1695
|
postVideoStatus(data: DataURL, caption: Content): Promise<MessageId | string | boolean>;
|
1695
1696
|
/**
|
1696
|
-
*
|
1697
|
-
*
|
1697
|
+
* {@license:restricted@}
|
1698
|
+
*
|
1699
|
+
* Consumes a list of id strings of stories to delete.
|
1700
|
+
*
|
1701
|
+
* @param statusesToDelete string [] | string an array of ids of stories to delete.
|
1698
1702
|
* @returns boolean. True if it worked.
|
1699
1703
|
*/
|
1700
|
-
|
1704
|
+
deleteStory(statusesToDelete: string | string[]): Promise<boolean>;
|
1705
|
+
/**
|
1706
|
+
* @deprecated
|
1707
|
+
* Alias for deleteStory
|
1708
|
+
*/
|
1709
|
+
deleteStatus: (statusesToDelete: string | string[]) => Promise<boolean>;
|
1701
1710
|
/**
|
1702
|
-
*
|
1711
|
+
* {@license:restricted@}
|
1712
|
+
*
|
1713
|
+
* Deletes all your existing stories.
|
1703
1714
|
* @returns boolean. True if it worked.
|
1704
1715
|
*/
|
1705
|
-
|
1716
|
+
deleteAllStories(): Promise<boolean>;
|
1717
|
+
/**
|
1718
|
+
* @deprecated
|
1719
|
+
* Alias for deleteStory
|
1720
|
+
*/
|
1721
|
+
deleteAllStatus: () => Promise<boolean>;
|
1706
1722
|
/**
|
1707
|
-
*
|
1723
|
+
* {@license:restricted@}
|
1724
|
+
*
|
1725
|
+
* Retrieves all existing stories.
|
1708
1726
|
*
|
1709
1727
|
* Only works with a Story License Key
|
1710
1728
|
*/
|
1711
|
-
|
1729
|
+
getMyStoryArray(): Promise<Message[]>;
|
1730
|
+
/**
|
1731
|
+
* @deprecated
|
1732
|
+
* Alias for deleteStory
|
1733
|
+
*/
|
1734
|
+
getMyStatusArray: () => Promise<Message[]>;
|
1712
1735
|
/**
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1736
|
+
* {@license:restricted@}
|
1737
|
+
*
|
1738
|
+
* Retrieves an array of user ids that have 'read' your story.
|
1739
|
+
*
|
1740
|
+
* @param id string The id of the story
|
1741
|
+
*
|
1742
|
+
*/
|
1743
|
+
getStoryViewers(id?: string): Promise<ContactId[] | {
|
1744
|
+
[k: MessageId]: ContactId[];
|
1745
|
+
}>;
|
1720
1746
|
/**
|
1721
1747
|
* Clears all chats of all messages. This does not delete chats. Please be careful with this as it will remove all messages from whatsapp web and the host device. This feature is great for privacy focussed bots.
|
1722
1748
|
*
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './socket';
|
@@ -0,0 +1,96 @@
|
|
1
|
+
import { EventEmitter2 } from 'eventemitter2';
|
2
|
+
import { Socket } from "socket.io-client";
|
3
|
+
import { Client } from "../api/Client";
|
4
|
+
import { SimpleListener } from "../api/model/events";
|
5
|
+
import { Chat, ChatId, Message } from '..';
|
6
|
+
import { MessageCollector } from '../structures/MessageCollector';
|
7
|
+
import { CollectorFilter, CollectorOptions } from '../structures/Collector';
|
8
|
+
/**
|
9
|
+
* A convenience type that includes all keys from the `Client`.
|
10
|
+
*/
|
11
|
+
export declare type ClientMethods = keyof Client;
|
12
|
+
/**
|
13
|
+
* [ALPHA - API will 100% change in the near future. Don't say I didn't warn you.]
|
14
|
+
*
|
15
|
+
*
|
16
|
+
* An easy to use socket implementation that allows users to connect into remote instances of the EASY API.
|
17
|
+
*
|
18
|
+
* How to use it:
|
19
|
+
*
|
20
|
+
* 1. Make sure you're running an instance of the EASY API and make sure to start it with the `--socket` flag
|
21
|
+
* ```bash
|
22
|
+
* > docker run -e PORT=8080 -p 8080:8080 openwa/wa-automate:latest --socket
|
23
|
+
* ```
|
24
|
+
* 2. Use this in your code:
|
25
|
+
*
|
26
|
+
* ```javascript
|
27
|
+
* import { SocketClient } from "@open-wa/wa-automate";
|
28
|
+
*
|
29
|
+
* SocketClient.connect("http://localhost:8080").then(async client => {
|
30
|
+
* //now you can use the client similar to how you would use the http express middleware.
|
31
|
+
*
|
32
|
+
* //There are two main commands from this client
|
33
|
+
*
|
34
|
+
* // 1. client.listen - use this for your listeners
|
35
|
+
*
|
36
|
+
* await client.listen("onMessage", message => {
|
37
|
+
* ...
|
38
|
+
* })
|
39
|
+
*
|
40
|
+
* // 2. client.asj - ask the main host client to get things done
|
41
|
+
*
|
42
|
+
* await client.ask("sendText", {
|
43
|
+
* "to" : "44771234567@c.us",
|
44
|
+
* "content": "hellow socket"
|
45
|
+
* })
|
46
|
+
*
|
47
|
+
* // or you can send the arguments in order as an array (or tuple, as the cool kids would say)
|
48
|
+
* await client.ask("sendText", [
|
49
|
+
* "44771234567@c.us",
|
50
|
+
* "hellow socket"
|
51
|
+
* ])
|
52
|
+
*
|
53
|
+
* })
|
54
|
+
* ```
|
55
|
+
*/
|
56
|
+
export declare class SocketClient {
|
57
|
+
url: string;
|
58
|
+
apiKey: string;
|
59
|
+
socket: Socket;
|
60
|
+
/**
|
61
|
+
* A local version of the `ev` EventEmitter2
|
62
|
+
*/
|
63
|
+
ev: EventEmitter2;
|
64
|
+
listeners: {
|
65
|
+
[listener in SimpleListener]?: {
|
66
|
+
[id: string]: (data: any) => any;
|
67
|
+
};
|
68
|
+
};
|
69
|
+
/**
|
70
|
+
* The main way to create the socket baed client.
|
71
|
+
* @param url URL of the socket server (i.e the EASY API instance address)
|
72
|
+
* @param apiKey optional api key if set
|
73
|
+
* @returns SocketClient
|
74
|
+
*/
|
75
|
+
static connect(url: string, apiKey?: string, ev?: boolean): Promise<SocketClient & Client>;
|
76
|
+
createMessageCollector(c: Message | ChatId | Chat, filter: CollectorFilter<[Message]>, options: CollectorOptions): Promise<MessageCollector>;
|
77
|
+
constructor(url: string, apiKey?: string, ev?: boolean);
|
78
|
+
ask<M extends ClientMethods, P extends Parameters<Pick<Client, M>[M]>>(method: M, args?: any[] | P | {
|
79
|
+
[k: string]: unknown;
|
80
|
+
}): Promise<unknown>;
|
81
|
+
/**
|
82
|
+
* Set a callback on a simple listener
|
83
|
+
* @param listener The listener name (e.g onMessage, onAnyMessage, etc.)
|
84
|
+
* @param callback The callback you need to run on the selected listener
|
85
|
+
* @returns The id of the callback
|
86
|
+
*/
|
87
|
+
listen(listener: SimpleListener, callback: (data: unknown) => void): Promise<string>;
|
88
|
+
/**
|
89
|
+
* Discard a callback
|
90
|
+
*
|
91
|
+
* @param listener The listener name (e.g onMessage, onAnyMessage, etc.)
|
92
|
+
* @param callbackId The ID from `listen`
|
93
|
+
* @returns boolean - true if the callback was found and discarded, false if the callback is not found
|
94
|
+
*/
|
95
|
+
stopListener(listener: SimpleListener, callbackId: string): boolean;
|
96
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { Browser, Page } from 'puppeteer';
|
2
|
+
import { Spin } from './events';
|
3
|
+
import { ConfigObject } from '../api/model';
|
4
|
+
export declare let BROWSER_START_TS: number;
|
5
|
+
export declare function initPage(sessionId?: string, config?: ConfigObject, customUserAgent?: string, spinner?: Spin, _page?: Page, skipAuth?: boolean): Promise<Page>;
|
6
|
+
export declare const deleteSessionData: (config: ConfigObject) => boolean;
|
7
|
+
export declare const getSessionDataFilePath: (sessionId: string, config: ConfigObject) => string | boolean;
|
8
|
+
export declare const addScript: (page: Page, js: string) => Promise<unknown>;
|
9
|
+
export declare function injectApi(page: Page): Promise<Page>;
|
10
|
+
/**
|
11
|
+
* @internal
|
12
|
+
*/
|
13
|
+
export declare const kill: (p: Page, b?: Browser, exit?: boolean, pid?: number, reason?: string) => Promise<void>;
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import { Request, Response } from "express";
|
2
|
+
declare type CustomResponse = Response & {
|
3
|
+
_swsReq: any;
|
4
|
+
};
|
5
|
+
export declare class ElasticEmitter {
|
6
|
+
queue: any;
|
7
|
+
pipeline: any;
|
8
|
+
username: any;
|
9
|
+
password: any;
|
10
|
+
elasticURL: any;
|
11
|
+
enabled: boolean;
|
12
|
+
lastFlush: any;
|
13
|
+
hostname: any;
|
14
|
+
sanitize: any;
|
15
|
+
version: string;
|
16
|
+
es7: boolean;
|
17
|
+
ES_MAX_BUFF: number;
|
18
|
+
indexBuffer: string;
|
19
|
+
bufferCount: number;
|
20
|
+
indexPrefix: string;
|
21
|
+
ip: any;
|
22
|
+
/**
|
23
|
+
*
|
24
|
+
* @param elasticUrl Elastic search endpoint URL
|
25
|
+
* @param username Elastic username
|
26
|
+
* @param password Elastic passowrd
|
27
|
+
* @param pipeline Pipeline to send the RRR
|
28
|
+
*/
|
29
|
+
constructor(elasticURL: string, username: string, password: string, max?: number, pipeline?: string, indexPrefix?: string);
|
30
|
+
private get elasticURLBulk();
|
31
|
+
private initTemplate;
|
32
|
+
processRecord(rrr: any): Promise<void>;
|
33
|
+
flush(): Promise<void>;
|
34
|
+
elasticMiddleware(config: {
|
35
|
+
sanitize: Function;
|
36
|
+
}): (req: Request, res: CustomResponse, next: any) => unknown;
|
37
|
+
private collectRequestResponseData;
|
38
|
+
private handleRequest;
|
39
|
+
private processRequest;
|
40
|
+
private processResponse;
|
41
|
+
}
|
42
|
+
export declare const getStatusCodeClass: (code: number) => string;
|
43
|
+
export declare const swsStringRecursive: (output: any, val: any) => any;
|
44
|
+
export declare const swsStringValue: (val: any) => string;
|
45
|
+
export declare const getPort: (req: any) => number;
|
46
|
+
export declare const getResponseContentLength: (req: any, res: any) => any;
|
47
|
+
export declare const getRemoteIP: (req: any) => string;
|
48
|
+
export declare const getRemoteRealIP: (req: any) => any;
|
49
|
+
export declare const getApiOpParameterValues: (path: any, method: any, req: any) => {};
|
50
|
+
export {};
|