@open-wa/wa-automate-types-only 4.48.1 → 4.49.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -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 {};
|