mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-18 03:29:14 +00:00
fix: add missing type definitions (#278)
* fix: @todo docs improvements * fix: add ClientInfo to Client typings * add ClientInfoPhone * fix: set getBatteryStatus as async * add ClientInfo comment Co-authored-by: Pedro S. Lopez <pedroslopez@me.com>
This commit is contained in:
50
index.d.ts
vendored
50
index.d.ts
vendored
@@ -6,6 +6,12 @@ declare namespace WAWebJS {
|
||||
|
||||
export class Client extends EventEmitter {
|
||||
constructor(options: ClientOptions)
|
||||
|
||||
/**
|
||||
* Current connection information
|
||||
* @todo add this in the official docs
|
||||
*/
|
||||
public info: ClientInfo
|
||||
|
||||
/**Accepts an invitation to join a group */
|
||||
acceptInvite(inviteCode: string): Promise<void>
|
||||
@@ -49,19 +55,13 @@ declare namespace WAWebJS {
|
||||
/** Gets the current connection state for the client */
|
||||
getState(): Promise<WAState>
|
||||
|
||||
/**
|
||||
* Returns the version of WhatsApp Web currently being run
|
||||
* @todo fix the return value in the official docs
|
||||
*/
|
||||
/** Returns the version of WhatsApp Web currently being run */
|
||||
getWWebVersion(): Promise<string>
|
||||
|
||||
/** Sets up events and requirements, kicks off authentication request */
|
||||
initialize(): Promise<void>
|
||||
|
||||
/**
|
||||
* Check if a given ID is registered in whatsapp
|
||||
* @todo add contactId param in the official docs
|
||||
*/
|
||||
/** Check if a given ID is registered in whatsapp */
|
||||
isRegisteredUser(contactId: string): Promise<boolean>
|
||||
|
||||
/**
|
||||
@@ -92,10 +92,7 @@ declare namespace WAWebJS {
|
||||
/** Changes and returns the archive state of the Chat */
|
||||
unarchiveChat(chatId: string): Promise<boolean>
|
||||
|
||||
/**
|
||||
* Unmutes the Chat
|
||||
* @todo add chatId param in the official docs
|
||||
*/
|
||||
/** Unmutes the Chat */
|
||||
unmuteChat(chatId: string): Promise<void>
|
||||
|
||||
/** Generic event */
|
||||
@@ -197,6 +194,35 @@ declare namespace WAWebJS {
|
||||
on(event: 'ready', listener: () => void): this
|
||||
}
|
||||
|
||||
/** Current connection information */
|
||||
export interface ClientInfo {
|
||||
/** Current user ID */
|
||||
me: ContactId
|
||||
/** Information about the phone this client is connected to */
|
||||
phone: ClientInfoPhone
|
||||
/** Platform the phone is running on */
|
||||
platform: string
|
||||
/** Name configured to be shown in push notifications */
|
||||
pushname: string
|
||||
|
||||
/** Get current battery percentage and charging status for the attached device */
|
||||
getBatteryStatus: () => Promise<BatteryInfo>
|
||||
}
|
||||
|
||||
/** Information about the phone this client is connected to */
|
||||
export interface ClientInfoPhone {
|
||||
/** WhatsApp Version running on the phone */
|
||||
wa_version: string
|
||||
/** OS Version running on the phone (iOS or Android version) */
|
||||
os_version: string
|
||||
/** Device manufacturer */
|
||||
device_manufacturer: string
|
||||
/** Device model */
|
||||
device_model: string
|
||||
/** OS build number */
|
||||
os_build_number: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for initializing the whatsapp client
|
||||
* @todo add these in the official docs
|
||||
|
||||
@@ -15,6 +15,7 @@ const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification
|
||||
/**
|
||||
* Starting point for interacting with the WhatsApp Web API
|
||||
* @extends {EventEmitter}
|
||||
* @param {object} options
|
||||
* @fires Client#qr
|
||||
* @fires Client#authenticated
|
||||
* @fires Client#auth_failure
|
||||
@@ -370,7 +371,7 @@ class Client extends EventEmitter {
|
||||
|
||||
/**
|
||||
* Returns the version of WhatsApp Web currently being run
|
||||
* @returns Promise<string>
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
async getWWebVersion() {
|
||||
return await this.pupPage.evaluate(() => {
|
||||
@@ -610,6 +611,7 @@ class Client extends EventEmitter {
|
||||
|
||||
/**
|
||||
* Check if a given ID is registered in whatsapp
|
||||
* @param {string} id the whatsapp user's ID
|
||||
* @returns {Promise<Boolean>}
|
||||
*/
|
||||
async isRegisteredUser(id) {
|
||||
|
||||
Reference in New Issue
Block a user