@open-wa/wa-automate-types-only 4.30.11 → 4.31.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.
@@ -74,7 +74,7 @@ export declare class Client {
74
74
  * A convinience method to download the [[DataURL]] of a file
75
75
  * @param url The url
76
76
  * @param optionsOverride You can use this to override the [axios request config](https://github.com/axios/axios#request-config)
77
- * @returns Promise<DataURL>
77
+ * @returns `Promise<DataURL>`
78
78
  */
79
79
  download(url: string, optionsOverride?: any): Promise<DataURL>;
80
80
  /**
@@ -239,7 +239,8 @@ export declare class Client {
239
239
  *
240
240
  * Here is an example of the fired object:
241
241
  *
242
- * @fires ```javascript
242
+ * @fires
243
+ * ```javascript
243
244
  * {
244
245
  * "chat": "00000000000-1111111111@g.us", //the chat in which this state is occuring
245
246
  * "user": "22222222222@c.us", //the user that is causing this state
@@ -315,7 +316,7 @@ export declare class Client {
315
316
  * @param chatId the chat from which you want to subscribes to live location updates
316
317
  * @param fn callback that takes in a LiveLocationChangedEvent
317
318
  * @returns boolean, if returns false then there were no valid live locations in the chat of chatId
318
- * @emits <LiveLocationChangedEvent> LiveLocationChangedEvent
319
+ * @emits `<LiveLocationChangedEvent>` LiveLocationChangedEvent
319
320
  */
320
321
  onLiveLocation(chatId: ChatId, fn: (liveLocationChangedEvent: LiveLocationChangedEvent) => void): Promise<boolean>;
321
322
  /**
@@ -428,7 +429,7 @@ export declare class Client {
428
429
  * A list of participants in the chat who have their live location on. If the chat does not exist, or the chat does not have any contacts actively sharing their live locations, it will return false. If it's a chat with a single contact, there will be only 1 value in the array if the contact has their livelocation on.
429
430
  * Please note. This should only be called once every 30 or so seconds. This forces the phone to grab the latest live location data for the number. This can be used in conjunction with onLiveLocation (this will trigger onLiveLocation).
430
431
  * @param chatId string Id of the chat you want to force the phone to get the livelocation data for.
431
- * @returns Promise<LiveLocationChangedEvent []> | boolean
432
+ * @returns `Promise<LiveLocationChangedEvent []>` | boolean
432
433
  */
433
434
  forceUpdateLiveLocation(chatId: ChatId): Promise<LiveLocationChangedEvent[] | boolean>;
434
435
  private link;
@@ -482,6 +483,8 @@ export declare class Client {
482
483
  */
483
484
  sendBanner(to: ChatId, base64: Base64): Promise<boolean | MessageId>;
484
485
  /**
486
+ * {@license:insiders@}
487
+ * <span theme="badge contrast license">Insiders</span>
485
488
  * [REQUIRES AN INSIDERS LICENSE-KEY](https://gum.co/open-wa?tier=Insiders%20Program)
486
489
  *
487
490
  * Send a list message. This will not work when being sent from business accounts!
@@ -511,7 +514,7 @@ export declare class Client {
511
514
  * @param groupId group chat id: `xxxxx@g.us`
512
515
  * @param content text message to add under all of the tags
513
516
  * @param hideTags Removes all tags within the message
514
- * @returns Promise<MessageId>
517
+ * @returns `Promise<MessageId>`
515
518
  */
516
519
  tagEveryone(groupId: GroupChatId, content: Content, hideTags?: boolean): Promise<boolean | MessageId>;
517
520
  /**
@@ -542,7 +545,7 @@ export declare class Client {
542
545
  /**
543
546
  * Decrypts a media message.
544
547
  * @param message This can be the serialized [[MessageId]] or the whole [[Message]] object. It is advised to just use the serialized message ID.
545
- * @returns Promise<[[DataURL]]>
548
+ * @returns `Promise<[[DataURL]]>`
546
549
  */
547
550
  decryptMedia(message: Message | MessageId): Promise<DataURL>;
548
551
  /**
@@ -553,7 +556,7 @@ export declare class Client {
553
556
  * @param caption string xxxxx
554
557
  * @param waitForKey boolean default: false set this to true if you want to wait for the id of the message. By default this is set to false as it will take a few seconds to retrieve to the key of the message and this waiting may not be desirable for the majority of users.
555
558
  * @param hideTags boolean default: false [INSIDERS] set this to try silent tag someone in the caption
556
- * @returns Promise <boolean | string> This will either return true or the id of the message. It will return true after 10 seconds even if waitForId is true
559
+ * @returns `Promise <boolean | string>` This will either return true or the id of the message. It will return true after 10 seconds even if waitForId is true
557
560
  */
558
561
  sendImage(to: ChatId, file: DataURL | FilePath, filename: string, caption: Content, quotedMsgId?: MessageId, waitForId?: boolean, ptt?: boolean, withoutPreview?: boolean, hideTags?: boolean, viewOnce?: boolean): Promise<MessageId | boolean>;
559
562
  /**
@@ -580,7 +583,7 @@ export declare class Client {
580
583
  * @param content string reply text
581
584
  * @param quotedMsgId string the msg id to reply to.
582
585
  * @param sendSeen boolean If set to true, the chat will 'blue tick' all messages before sending the reply
583
- * @returns Promise<MessageId | false> false if didn't work, otherwise returns message id.
586
+ * @returns `Promise<MessageId | false>` false if didn't work, otherwise returns message id.
584
587
  */
585
588
  reply(to: ChatId, content: Content, quotedMsgId: MessageId, sendSeen?: boolean): Promise<boolean | MessageId>;
586
589
  /**
@@ -591,7 +594,7 @@ export declare class Client {
591
594
  * This will only work if you have chats sent back and forth between you and the contact 1-1.
592
595
  *
593
596
  * @param contactId The Id of the contact with which you have an existing conversation with messages already.
594
- * @returns Promise<string | boolean> true or false or a string with an explaintaion of why it wasn't able to determine the read receipts.
597
+ * @returns `Promise<string | boolean>` true or false or a string with an explaintaion of why it wasn't able to determine the read receipts.
595
598
  *
596
599
  */
597
600
  checkReadReceipts(contactId: ContactId): Promise<string | boolean>;
@@ -612,7 +615,7 @@ export declare class Client {
612
615
  * @param ptt boolean default: false set this to true if you want to send the file as a push to talk file.
613
616
  * @param withoutPreview boolean default: false set this to true if you want to send the file without a preview (i.e as a file). This is useful for preventing auto downloads on recipient devices.
614
617
  * @param hideTags boolean default: false [INSIDERS] set this to try silent tag someone in the caption
615
- * @returns Promise <boolean | MessageId> This will either return true or the id of the message. It will return true after 10 seconds even if waitForId is true
618
+ * @returns `Promise <boolean | MessageId>` This will either return true or the id of the message. It will return true after 10 seconds even if waitForId is true
616
619
  */
617
620
  sendFile(to: ChatId, file: DataURL | FilePath, filename: string, caption: Content, quotedMsgId?: MessageId, waitForId?: boolean, ptt?: boolean, withoutPreview?: boolean, hideTags?: boolean, viewOnce?: boolean): Promise<MessageId | boolean>;
618
621
  /**
@@ -620,7 +623,7 @@ export declare class Client {
620
623
  *
621
624
  * Checks whether or not the group id provided is known to be unsafe by the contributors of the library.
622
625
  * @param groupChatId The group chat you want to deteremine is unsafe
623
- * @returns Promise <boolean | string> This will either return a boolean indiciating whether this group chat id is considered unsafe or an error message as a string
626
+ * @returns `Promise <boolean | string>` This will either return a boolean indiciating whether this group chat id is considered unsafe or an error message as a string
624
627
  */
625
628
  isGroupIdUnsafe(groupChatId: GroupChatId): Promise<string | boolean>;
626
629
  /**
@@ -628,7 +631,7 @@ export declare class Client {
628
631
  * @param to chat id `xxxxx@c.us`
629
632
  * @param file base64 data:image/xxx;base64,xxx or the path of the file you want to send.
630
633
  * @param quotedMsgId string true_0000000000@c.us_JHB2HB23HJ4B234HJB to send as a reply to a message
631
- * @returns Promise <boolean | string> This will either return true or the id of the message. It will return true after 10 seconds even if waitForId is true
634
+ * @returns `Promise <boolean | string>` This will either return true or the id of the message. It will return true after 10 seconds even if waitForId is true
632
635
  */
633
636
  sendPtt(to: ChatId, file: DataURL | FilePath, quotedMsgId: MessageId): Promise<MessageId>;
634
637
  /**
@@ -674,7 +677,7 @@ export declare class Client {
674
677
  getMe(): Promise<any>;
675
678
  /**
676
679
  * Returns a PNG DataURL screenshot of the session
677
- * @returns Promise<DataURL>
680
+ * @returns `Promise<DataURL>`
678
681
  */
679
682
  getSnapshot(): Promise<DataURL>;
680
683
  /**
@@ -793,7 +796,7 @@ export declare class Client {
793
796
  * Any potential abuse of this method will see it become paywalled.
794
797
  * @param to: Chat id to forward the message to
795
798
  * @param messageId: message id of the message to forward. Please note that if it is not loaded, this will return false - even if it exists.
796
- * @returns Promise<MessageId | boolean>
799
+ * @returns `Promise<MessageId | boolean>`
797
800
  */
798
801
  ghostForward(to: ChatId, messageId: MessageId): Promise<MessageId | boolean>;
799
802
  /**
@@ -861,7 +864,7 @@ export declare class Client {
861
864
  getAllChatIds(): Promise<ChatId[]>;
862
865
  /**
863
866
  * retrieves an array of IDs of accounts blocked by the host account.
864
- * @returns Promise<ChatId[]>
867
+ * @returns `Promise<ChatId[]>`
865
868
  */
866
869
  getBlockedIds(): Promise<ChatId[]>;
867
870
  /**
@@ -900,7 +903,7 @@ export declare class Client {
900
903
  * @param returnChatObj boolean When this is set to true and if the group was joined successfully, it will return a serialzed Chat object which includes group information and metadata. This is useful when you want to immediately do something with group metadata.
901
904
  *
902
905
  *
903
- * @returns Promise<string | boolean | number> Either false if it didn't work, or the group id.
906
+ * @returns `Promise<string | boolean | number>` Either false if it didn't work, or the group id.
904
907
  */
905
908
  joinGroupViaLink(link: string, returnChatObj?: boolean): Promise<string | boolean | number | Chat>;
906
909
  /**
@@ -1165,7 +1168,7 @@ export declare class Client {
1165
1168
  /**
1166
1169
  * Retrieves an invite link for a group chat. returns false if chat is not a group.
1167
1170
  * @param chatId
1168
- * @returns Promise<string>
1171
+ * @returns `Promise<string>`
1169
1172
  */
1170
1173
  getGroupInviteLink(chatId: ChatId): Promise<string>;
1171
1174
  /**
@@ -1177,7 +1180,7 @@ export declare class Client {
1177
1180
  /**
1178
1181
  * Revokes the current invite link for a group chat. Any previous links will stop working
1179
1182
  * @param chatId
1180
- * @returns Promise<boolean>
1183
+ * @returns `Promise<boolean>`
1181
1184
  */
1182
1185
  revokeGroupInviteLink(chatId: ChatId): Promise<boolean | string>;
1183
1186
  /**
@@ -1200,7 +1203,9 @@ export declare class Client {
1200
1203
  * @param use_unread_count
1201
1204
  * @returns any
1202
1205
  */
1203
- getUnreadMessages(includeMe: boolean, includeNotifications: boolean, use_unread_count: boolean): Promise<Message[]>;
1206
+ getUnreadMessages(includeMe: boolean, includeNotifications: boolean, use_unread_count: boolean): Promise<Chat & {
1207
+ messages: Message[];
1208
+ }>;
1204
1209
  /**
1205
1210
  * Retrieves all new Messages. where isNewMsg==true
1206
1211
  * @returns list of messages
@@ -1252,21 +1257,6 @@ export declare class Client {
1252
1257
  *
1253
1258
  * @param groupName group name: 'New group'
1254
1259
  * @param contacts: A single contact id or an array of contact ids.
1255
- * @returns Promise<GroupCreationResponse> :
1256
- * ```javascript
1257
- * {
1258
- * status: 200,
1259
- * gid: {
1260
- * server: 'g.us',
1261
- * user: '447777777777-1583678870',
1262
- * _serialized: '447777777777-1583678870@g.us'
1263
- * },
1264
- * participants: [
1265
- * { '447777777777@c.us': [Object] },
1266
- * { '447444444444@c.us': [Object] }
1267
- * ]
1268
- * }
1269
- * ```
1270
1260
  */
1271
1261
  createGroup(groupName: string, contacts: ContactId | ContactId[]): Promise<GroupChatCreationResponse>;
1272
1262
  /**
@@ -1416,7 +1406,7 @@ export declare class Client {
1416
1406
  * @param url: The url of the image
1417
1407
  * @param requestConfig {} By default the request is a get request, however you can override that and many other options by sending this parameter. You can read more about this parameter here: https://github.com/axios/axios#request-config
1418
1408
  *
1419
- * @returns Promise<MessageId | boolean>
1409
+ * @returns `Promise<MessageId | boolean>`
1420
1410
  */
1421
1411
  sendStickerfromUrl(to: ChatId, url: string, requestConfig?: AxiosRequestConfig, stickerMetadata?: StickerMetadata): Promise<string | MessageId | boolean>;
1422
1412
  /**
@@ -1428,7 +1418,7 @@ export declare class Client {
1428
1418
  * @param messageId The id of the message to reply to
1429
1419
  * @param requestConfig {} By default the request is a get request, however you can override that and many other options by sending this parameter. You can read more about this parameter here: https://github.com/axios/axios#request-config
1430
1420
  *
1431
- * @returns Promise<MessageId | boolean>
1421
+ * @returns `Promise<MessageId | boolean>`
1432
1422
  */
1433
1423
  sendStickerfromUrlAsReply(to: ChatId, url: string, messageId: MessageId, requestConfig?: AxiosRequestConfig, stickerMetadata?: StickerMetadata): Promise<MessageId | boolean>;
1434
1424
  /**
@@ -1505,7 +1495,7 @@ export declare class Client {
1505
1495
  * Turn the ephemeral setting in a chat to on or off
1506
1496
  * @param chatId The ID of the chat
1507
1497
  * @param ephemeral `true` to turn on the ephemeral setting, `false` to turn off the ephemeral setting. Please note, if the setting is already on the requested setting, this method will return `true`.
1508
- * @returns Promise<boolean> true if the setting was set, `false` if the chat does not exist
1498
+ * @returns `Promise<boolean>` true if the setting was set, `false` if the chat does not exist
1509
1499
  */
1510
1500
  setChatEphemeral(chatId: ChatId, ephemeral: boolean): Promise<boolean>;
1511
1501
  /**
@@ -1528,7 +1518,7 @@ export declare class Client {
1528
1518
  * 3: [Bryndan Write](https://www.dafontfree.net/freefonts-bryndan-write-f160189.htm)
1529
1519
  * 4: [Bebasneue Regular](https://www.dafont.com/bebas-neue.font)
1530
1520
  * 5: [Oswald Heavy](https://www.fontsquirrel.com/fonts/oswald)
1531
- * @returns Promise<string | boolean> returns status id if it worked, false if it didn't
1521
+ * @returns `Promise<string | boolean>` returns status id if it worked, false if it didn't
1532
1522
  */
1533
1523
  postTextStatus(text: Content, textRgba: string, backgroundRgba: string, font: number): Promise<MessageId | string | boolean>;
1534
1524
  /**
@@ -1537,7 +1527,7 @@ export declare class Client {
1537
1527
  * Posts an image story.
1538
1528
  * @param data data url string `data:[<MIME-type>][;charset=<encoding>][;base64],<data>`
1539
1529
  * @param caption The caption for the story
1540
- * @returns Promise<string | boolean> returns status id if it worked, false if it didn't
1530
+ * @returns `Promise<string | boolean>` returns status id if it worked, false if it didn't
1541
1531
  */
1542
1532
  postImageStatus(data: DataURL, caption: Content): Promise<MessageId | string | boolean>;
1543
1533
  /**
@@ -1546,7 +1536,7 @@ export declare class Client {
1546
1536
  * Posts a video story.
1547
1537
  * @param data data url string `data:[<MIME-type>][;charset=<encoding>][;base64],<data>`
1548
1538
  * @param caption The caption for the story
1549
- * @returns Promise<string | boolean> returns status id if it worked, false if it didn't
1539
+ * @returns `Promise<string | boolean>` returns status id if it worked, false if it didn't
1550
1540
  */
1551
1541
  postVideoStatus(data: DataURL, caption: Content): Promise<MessageId | string | boolean>;
1552
1542
  /**
@@ -1632,7 +1622,7 @@ export declare class Client {
1632
1622
  *
1633
1623
  * Sets the profile pic of the host number.
1634
1624
  * @param data string data url image string.
1635
- * @returns Promise<boolean> success if true
1625
+ * @returns `Promise<boolean>` success if true
1636
1626
  */
1637
1627
  setProfilePic(data: DataURL): Promise<boolean>;
1638
1628
  /**
@@ -1,3 +1,6 @@
1
+ declare type Brand<K, T> = K & {
2
+ __brand?: T;
3
+ };
1
4
  /**
2
5
  * The suffix used to identify a non-group chat id
3
6
  */
@@ -33,7 +36,7 @@ export declare type GroupChatId = `${AccountNumber}-${number}@${GroupChatServer}
33
36
  *
34
37
  * `"447123456789@c.us"`
35
38
  */
36
- export declare type ContactId = `${AccountNumber}@${ChatServer}`;
39
+ export declare type ContactId = Brand<`${AccountNumber}@${ChatServer}`, "ContactId">;
37
40
  /**
38
41
  * A chat id ends with `@c.us` or `@g.us` for group chats.
39
42
  *
@@ -51,7 +54,7 @@ export declare type ChatId = ContactId | GroupChatId;
51
54
  *
52
55
  * `"false_447123456789@c.us_9C4D0965EA5C09D591334AB6BDB07FEB"`
53
56
  */
54
- export declare type MessageId = `${boolean}_${ChatId}_${string}`;
57
+ export declare type MessageId = Brand<`${boolean}_${ChatId}_${string}`, "MessageId">;
55
58
  /**
56
59
  * This is a generic type alias for the content of a message
57
60
  *
@@ -59,7 +62,7 @@ export declare type MessageId = `${boolean}_${ChatId}_${string}`;
59
62
  *
60
63
  * `"hello!"`
61
64
  */
62
- export declare type Content = string;
65
+ export declare type Content = Brand<string, "Content">;
63
66
  export declare type NonSerializedId = {
64
67
  server: WaServers;
65
68
  user: AccountNumber;
@@ -77,7 +80,7 @@ export declare type NonSerializedId = {
77
80
  *
78
81
  * Learn more here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
79
82
  */
80
- export declare type DataURL = string;
83
+ export declare type DataURL = Brand<`data:${string};base64,${Base64}`, "DataURL">;
81
84
  /**
82
85
  * Base64 is basically a file encoded as a string.
83
86
  *
@@ -85,10 +88,11 @@ export declare type DataURL = string;
85
88
  *
86
89
  * Learn more here: https://developer.mozilla.org/en-US/docs/Glossary/Base64
87
90
  */
88
- export declare type Base64 = string;
91
+ export declare type Base64 = Brand<string, "Base64">;
89
92
  /**
90
93
  * The relative or absolute path of a file
91
94
  *
92
95
  * Learn more here: https://www.w3schools.com/html/html_filepaths.asp
93
96
  */
94
- export declare type FilePath = string;
97
+ export declare type FilePath = Brand<string, "FilePath">;
98
+ export {};
@@ -687,7 +687,7 @@ export interface ConfigObject {
687
687
  /**
688
688
  * What to do when an error is detected on a client method.
689
689
  *
690
- * @default `NOTHING`
690
+ * @default `OnError.NOTHING`
691
691
  */
692
692
  onError?: OnError;
693
693
  /**
@@ -697,6 +697,9 @@ export interface ConfigObject {
697
697
  * Set this to true if you're using the multidevice beta.
698
698
  *
699
699
  * @default `false`
700
+ * :::danger
701
+ * Some features (e.g [[sendLinkWithAutoPreview]]) **do not** work with multi-device beta. Check [this `api`](#).
702
+ * :::
700
703
  */
701
704
  multiDevice?: boolean;
702
705
  /**
@@ -3,6 +3,7 @@ export * from './contact';
3
3
  export * from './message';
4
4
  export * from './errors';
5
5
  export * from './events';
6
+ export * from './product';
6
7
  /**
7
8
  * Client status
8
9
  * @readonly
@@ -75,7 +75,7 @@ export interface Product {
75
75
  description?: string;
76
76
  /**
77
77
  * The availiable quantity of this product.
78
- * @default `"unknown"``
78
+ * @default "unknown"`
79
79
  */
80
80
  availability?: number | "unknown";
81
81
  /**
@@ -0,0 +1,9 @@
1
+ import { AnyFlag } from "meow";
2
+ import { Merge } from "type-fest";
3
+ export declare const optionList: Merge<Merge<{
4
+ name?: string;
5
+ description?: string;
6
+ typeLabel?: string;
7
+ }, AnyFlag>, {
8
+ type?: typeof Boolean | typeof Number | typeof String;
9
+ }>[];
@@ -14,7 +14,7 @@ export declare const cliOptionNames: import("type-fest").Simplify<import("type-f
14
14
  description?: string;
15
15
  typeLabel?: string;
16
16
  }, meow.AnyFlag>>, {
17
- type?: typeof Boolean | typeof Number | typeof String;
17
+ type?: StringConstructor | BooleanConstructor | NumberConstructor;
18
18
  }>>;
19
19
  export declare const meowFlags: () => AnyFlags;
20
20
  export declare const helptext: string;
@@ -3,13 +3,13 @@ import { Spin } from './events';
3
3
  import { ConfigObject } from '../api/model';
4
4
  import { Page } from 'puppeteer';
5
5
  /**
6
+ * isAuthenticated
6
7
  * Validates if client is authenticated
7
8
  * @returns true if is authenticated, false otherwise
8
9
  * @param waPage
9
10
  */
10
11
  export declare const isAuthenticated: (waPage: Page) => Promise<unknown>;
11
12
  export declare const needsToScan: (waPage: Page) => Observable<unknown>;
12
- export declare const isInsideChat: (waPage: Page) => Observable<boolean>;
13
13
  export declare const waitForRipeSession: (waPage: Page) => Promise<boolean>;
14
14
  export declare const sessionDataInvalid: (waPage: Page) => Promise<string>;
15
15
  export declare const phoneIsOutOfReach: (waPage: Page) => Promise<boolean>;
@@ -27,6 +27,10 @@ export declare class QRManager {
27
27
  grabAndEmit(qrData: any, waPage: Page, config: ConfigObject, spinner: Spin): Promise<void>;
28
28
  smartQr(waPage: Page, config?: ConfigObject, spinner?: Spin): Promise<boolean | void | string>;
29
29
  emitFirst(waPage: Page, config?: ConfigObject, spinner?: Spin): Promise<void>;
30
+ /**
31
+ * Wait 10 seconds for the qr element to show.
32
+ * If it doesn't show up within 10 seconds then assume the session is authed already or blocked therefore ignore and return promise
33
+ */
30
34
  waitFirstQr(waPage: Page, config?: ConfigObject, spinner?: Spin): Promise<void>;
31
35
  }
32
36
  export declare const qrManager: QRManager;
@@ -0,0 +1,17 @@
1
+ export declare class ScriptLoader {
2
+ scripts: string[];
3
+ contentRegistry: {
4
+ [key: string]: string;
5
+ };
6
+ constructor();
7
+ loadScripts(): Promise<{
8
+ [key: string]: string;
9
+ }>;
10
+ getScript(scriptName: string): Promise<string>;
11
+ flush(): void;
12
+ getScripts(): {
13
+ [key: string]: string;
14
+ };
15
+ }
16
+ declare const scriptLoader: ScriptLoader;
17
+ export { scriptLoader };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-wa/wa-automate-types-only",
3
- "version": "4.30.11",
3
+ "version": "4.31.1",
4
4
  "description": "Types generated from the @open-wa/wa-automate package",
5
5
  "scripts": {
6
6
  "build": "tsc",