zaileys 4.7.1 → 4.8.0

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.
Files changed (143) hide show
  1. package/README.md +5 -0
  2. package/dist/auth/adapters/convex.d.ts +9 -0
  3. package/dist/auth/adapters/file.d.ts +16 -0
  4. package/dist/auth/adapters/index.d.ts +6 -0
  5. package/dist/auth/adapters/memory.d.ts +9 -0
  6. package/dist/auth/adapters/postgres.d.ts +20 -0
  7. package/dist/auth/adapters/redis.d.ts +27 -0
  8. package/dist/auth/adapters/sqlite.d.ts +19 -0
  9. package/dist/auth/cache.d.ts +11 -0
  10. package/dist/auth/index.d.ts +3 -0
  11. package/dist/auth/types.d.ts +21 -0
  12. package/dist/automation/auto-delete.d.ts +30 -0
  13. package/dist/automation/broadcast.d.ts +10 -0
  14. package/dist/automation/errors.d.ts +8 -0
  15. package/dist/automation/index.d.ts +11 -0
  16. package/dist/automation/operation-guard.d.ts +20 -0
  17. package/dist/automation/presence.d.ts +28 -0
  18. package/dist/automation/queue.d.ts +18 -0
  19. package/dist/automation/rate-limiter.d.ts +18 -0
  20. package/dist/automation/schedule.d.ts +45 -0
  21. package/dist/automation/types.d.ts +31 -0
  22. package/dist/builder/album.d.ts +4 -0
  23. package/dist/builder/builder.d.ts +59 -0
  24. package/dist/builder/content/airich.d.ts +80 -0
  25. package/dist/builder/content/audio.d.ts +9 -0
  26. package/dist/builder/content/buttons.d.ts +30 -0
  27. package/dist/builder/content/carousel.d.ts +19 -0
  28. package/dist/builder/content/contact.d.ts +13 -0
  29. package/dist/builder/content/document.d.ts +9 -0
  30. package/dist/builder/content/event.d.ts +3 -0
  31. package/dist/builder/content/group-invite.d.ts +3 -0
  32. package/dist/builder/content/image.d.ts +8 -0
  33. package/dist/builder/content/list.d.ts +14 -0
  34. package/dist/builder/content/location.d.ts +11 -0
  35. package/dist/builder/content/markdown.d.ts +2 -0
  36. package/dist/builder/content/poll.d.ts +10 -0
  37. package/dist/builder/content/product.d.ts +3 -0
  38. package/dist/builder/content/sticker.d.ts +7 -0
  39. package/dist/builder/content/template.d.ts +3 -0
  40. package/dist/builder/content/text.d.ts +4 -0
  41. package/dist/builder/content/video.d.ts +10 -0
  42. package/dist/builder/edit-builder.d.ts +15 -0
  43. package/dist/builder/errors.d.ts +8 -0
  44. package/dist/builder/index.d.ts +6 -0
  45. package/dist/builder/media-loader.d.ts +11 -0
  46. package/dist/builder/mutations.d.ts +14 -0
  47. package/dist/builder/state.d.ts +15 -0
  48. package/dist/builder/types.d.ts +164 -0
  49. package/dist/builder/username-resolve.d.ts +8 -0
  50. package/dist/client/client.d.ts +160 -0
  51. package/dist/client/event-emitter.d.ts +19 -0
  52. package/dist/client/index.d.ts +3 -0
  53. package/dist/client/types.d.ts +119 -0
  54. package/dist/cloud/errors.d.ts +14 -0
  55. package/dist/cloud/graph-client.d.ts +15 -0
  56. package/dist/cloud/index.d.ts +6 -0
  57. package/dist/cloud/media.d.ts +15 -0
  58. package/dist/cloud/module.d.ts +147 -0
  59. package/dist/cloud/translate/inbound.d.ts +119 -0
  60. package/dist/cloud/translate/interactive.d.ts +2 -0
  61. package/dist/cloud/translate/outbound.d.ts +21 -0
  62. package/dist/cloud/transport.d.ts +51 -0
  63. package/dist/cloud/types.d.ts +17 -0
  64. package/dist/cloud/webhook.d.ts +11 -0
  65. package/dist/command/dispatcher.d.ts +23 -0
  66. package/dist/command/errors.d.ts +8 -0
  67. package/dist/command/index.d.ts +7 -0
  68. package/dist/command/middleware.d.ts +2 -0
  69. package/dist/command/parser.d.ts +2 -0
  70. package/dist/command/registry.d.ts +13 -0
  71. package/dist/command/types.d.ts +30 -0
  72. package/dist/connection/auth-adapter.d.ts +4 -0
  73. package/dist/connection/auth-guard.d.ts +37 -0
  74. package/dist/connection/disconnect-reason.d.ts +6 -0
  75. package/dist/connection/index.d.ts +7 -0
  76. package/dist/connection/pairing-flow.d.ts +16 -0
  77. package/dist/connection/qr-terminal.d.ts +2 -0
  78. package/dist/connection/reconnect.d.ts +15 -0
  79. package/dist/connection/state-machine.d.ts +9 -0
  80. package/dist/connection/status-log.d.ts +25 -0
  81. package/dist/domain/business.d.ts +19 -0
  82. package/dist/domain/chat.d.ts +27 -0
  83. package/dist/domain/community.d.ts +28 -0
  84. package/dist/domain/contact.d.ts +21 -0
  85. package/dist/domain/errors.d.ts +8 -0
  86. package/dist/domain/group.d.ts +35 -0
  87. package/dist/domain/index.d.ts +11 -0
  88. package/dist/domain/newsletter.d.ts +35 -0
  89. package/dist/domain/privacy.d.ts +15 -0
  90. package/dist/domain/profile.d.ts +14 -0
  91. package/dist/domain/socket-like.d.ts +117 -0
  92. package/dist/domain/types.d.ts +24 -0
  93. package/dist/events/context.d.ts +238 -0
  94. package/dist/events/decoders/_media-download.d.ts +8 -0
  95. package/dist/events/decoders/_shared.d.ts +26 -0
  96. package/dist/events/decoders/calls.d.ts +11 -0
  97. package/dist/events/decoders/groups.d.ts +36 -0
  98. package/dist/events/decoders/interactive.d.ts +9 -0
  99. package/dist/events/decoders/lifecycle.d.ts +69 -0
  100. package/dist/events/decoders/messages.d.ts +30 -0
  101. package/dist/events/decoders/mutations.d.ts +24 -0
  102. package/dist/events/guards.d.ts +9 -0
  103. package/dist/events/index.d.ts +4 -0
  104. package/dist/events/pipeline.d.ts +37 -0
  105. package/dist/events/types.d.ts +187 -0
  106. package/dist/index.cjs +20 -15
  107. package/dist/index.d.ts +15 -2264
  108. package/dist/index.mjs +20 -15
  109. package/dist/media/ffmpeg/audio.d.ts +12 -0
  110. package/dist/media/ffmpeg/core.d.ts +67 -0
  111. package/dist/media/ffmpeg/document.d.ts +10 -0
  112. package/dist/media/ffmpeg/image.d.ts +7 -0
  113. package/dist/media/ffmpeg/index.d.ts +7 -0
  114. package/dist/media/ffmpeg/sticker.d.ts +14 -0
  115. package/dist/media/ffmpeg/transform.d.ts +2 -0
  116. package/dist/media/ffmpeg/video.d.ts +6 -0
  117. package/dist/media/index.d.ts +2 -0
  118. package/dist/media/media.d.ts +39 -0
  119. package/dist/plugin/index.d.ts +5 -0
  120. package/dist/plugin/loader.d.ts +30 -0
  121. package/dist/plugin/registry.d.ts +24 -0
  122. package/dist/plugin/types.d.ts +25 -0
  123. package/dist/store/adapters/convex.d.ts +33 -0
  124. package/dist/store/adapters/index.d.ts +5 -0
  125. package/dist/store/adapters/memory.d.ts +31 -0
  126. package/dist/store/adapters/postgres.d.ts +40 -0
  127. package/dist/store/adapters/redis.d.ts +49 -0
  128. package/dist/store/adapters/sqlite.d.ts +36 -0
  129. package/dist/store/index.d.ts +2 -0
  130. package/dist/store/types.d.ts +48 -0
  131. package/dist/transport/index.d.ts +1 -0
  132. package/dist/transport/types.d.ts +18 -0
  133. package/dist/types/convex.d.ts +35 -0
  134. package/dist/types/index.d.ts +4 -0
  135. package/dist/types/lid-mapping.d.ts +5 -0
  136. package/dist/types/optional-clients.d.ts +69 -0
  137. package/dist/types/store-error.d.ts +8 -0
  138. package/dist/utils/array.d.ts +1 -0
  139. package/dist/utils/index.d.ts +5 -0
  140. package/dist/utils/jid.d.ts +6 -0
  141. package/dist/utils/logger.d.ts +10 -0
  142. package/package.json +7 -7
  143. package/dist/index.d.cts +0 -2264
@@ -0,0 +1,27 @@
1
+ import type { WAMessageKey } from 'baileys';
2
+ import type { DomainSocketLike } from './socket-like.js';
3
+ export type LastMessage = {
4
+ key: WAMessageKey;
5
+ messageTimestamp: number;
6
+ };
7
+ export type LastMessageResolver = (jid: string) => Promise<LastMessage[]>;
8
+ export declare class ChatModule {
9
+ private readonly getSocket;
10
+ private readonly resolveLast?;
11
+ constructor(getSocket: () => DomainSocketLike | undefined, resolveLast?: LastMessageResolver | undefined);
12
+ protected requireSocket(): DomainSocketLike;
13
+ private last;
14
+ archive(jid: string): Promise<void>;
15
+ unarchive(jid: string): Promise<void>;
16
+ pin(jid: string): Promise<void>;
17
+ unpin(jid: string): Promise<void>;
18
+ /** Mute for `durationMs` (e.g. 8h = 28_800_000). Omit to mute indefinitely. */
19
+ mute(jid: string, durationMs?: number): Promise<void>;
20
+ unmute(jid: string): Promise<void>;
21
+ markRead(jid: string): Promise<void>;
22
+ markUnread(jid: string): Promise<void>;
23
+ star(key: WAMessageKey, starred?: boolean): Promise<void>;
24
+ unstar(key: WAMessageKey): Promise<void>;
25
+ delete(jid: string): Promise<void>;
26
+ clear(jid: string): Promise<void>;
27
+ }
@@ -0,0 +1,28 @@
1
+ import type { OperationGuard } from '../automation/operation-guard.js';
2
+ import type { DomainSocketLike } from './socket-like.js';
3
+ import type { GroupMetadata, LinkedGroup } from './types.js';
4
+ export declare class CommunityModule {
5
+ private readonly getSocket;
6
+ private readonly guard?;
7
+ constructor(getSocket: () => DomainSocketLike | undefined, guard?: OperationGuard | undefined);
8
+ protected requireSocket(): DomainSocketLike;
9
+ private run;
10
+ create(subject: string, body: string): Promise<GroupMetadata>;
11
+ createGroup(subject: string, participants: string[], communityId: string): Promise<GroupMetadata>;
12
+ linkGroup(communityId: string, groupId: string): Promise<void>;
13
+ unlinkGroup(communityId: string, groupId: string): Promise<void>;
14
+ subGroups(communityId: string): Promise<LinkedGroup[]>;
15
+ leave(communityId: string): Promise<void>;
16
+ updateSubject(communityId: string, subject: string): Promise<void>;
17
+ updateDescription(communityId: string, description?: string): Promise<void>;
18
+ inviteCode(communityId: string): Promise<string | undefined>;
19
+ revokeInvite(communityId: string): Promise<string | undefined>;
20
+ acceptInvite(code: string): Promise<string | undefined>;
21
+ metadata(communityId: string): Promise<GroupMetadata>;
22
+ list(): Promise<GroupMetadata[]>;
23
+ inviteInfo(code: string): Promise<GroupMetadata>;
24
+ toggleEphemeral(communityId: string, seconds: number): Promise<void>;
25
+ setting(communityId: string, setting: 'announcement' | 'not_announcement'): Promise<void>;
26
+ memberAddMode(communityId: string, adminsOnly: boolean): Promise<void>;
27
+ joinApproval(communityId: string, enabled: boolean): Promise<void>;
28
+ }
@@ -0,0 +1,21 @@
1
+ import type { DomainSocketLike } from './socket-like.js';
2
+ export type ContactCheckResult = {
3
+ jid: string;
4
+ exists: boolean;
5
+ lid?: string;
6
+ };
7
+ export declare class ContactModule {
8
+ private readonly getSocket;
9
+ private readonly normalize;
10
+ constructor(getSocket: () => DomainSocketLike | undefined, normalize: (input: string) => string);
11
+ protected requireSocket(): DomainSocketLike;
12
+ /** Check whether phone numbers are on WhatsApp; returns the resolved jid + existence per input. */
13
+ check(...numbers: string[]): Promise<ContactCheckResult[]>;
14
+ exists(number: string): Promise<boolean>;
15
+ save(jid: string, name: {
16
+ firstName?: string;
17
+ lastName?: string;
18
+ fullName?: string;
19
+ }): Promise<void>;
20
+ remove(jid: string): Promise<void>;
21
+ }
@@ -0,0 +1,8 @@
1
+ export type DomainErrorCode = 'NOT_CONNECTED' | 'GROUP_NOT_FOUND' | 'NEWSLETTER_NOT_FOUND' | 'INVALID_PARTICIPANT' | 'OPERATION_FAILED';
2
+ export declare class ZaileysDomainError extends Error {
3
+ readonly code: DomainErrorCode;
4
+ readonly cause?: unknown;
5
+ constructor(code: DomainErrorCode, message: string, options?: {
6
+ cause?: unknown;
7
+ });
8
+ }
@@ -0,0 +1,35 @@
1
+ import type { OperationGuard } from '../automation/operation-guard.js';
2
+ import type { DomainSocketLike } from './socket-like.js';
3
+ import type { GroupMetadata, ParticipantUpdateResult } from './types.js';
4
+ export declare class GroupModule {
5
+ private readonly getSocket;
6
+ private readonly guard?;
7
+ constructor(getSocket: () => DomainSocketLike | undefined, guard?: OperationGuard | undefined);
8
+ protected requireSocket(): DomainSocketLike;
9
+ private mapParticipants;
10
+ private run;
11
+ create(subject: string, participants: string[]): Promise<GroupMetadata>;
12
+ addMember(groupId: string, jids: string[]): Promise<ParticipantUpdateResult[]>;
13
+ removeMember(groupId: string, jids: string[]): Promise<ParticipantUpdateResult[]>;
14
+ promote(groupId: string, jids: string[]): Promise<ParticipantUpdateResult[]>;
15
+ demote(groupId: string, jids: string[]): Promise<ParticipantUpdateResult[]>;
16
+ updateSubject(groupId: string, subject: string): Promise<void>;
17
+ updateDescription(groupId: string, description?: string): Promise<void>;
18
+ leave(groupId: string): Promise<void>;
19
+ metadata(groupId: string): Promise<GroupMetadata>;
20
+ tagMember(groupId: string, jid: string, label: string): Promise<void>;
21
+ inviteCode(groupId: string): Promise<string>;
22
+ revokeInvite(groupId: string): Promise<string>;
23
+ acceptInvite(code: string): Promise<string>;
24
+ toggleEphemeral(groupId: string, seconds: number): Promise<void>;
25
+ setting(groupId: string, setting: 'announcement' | 'not_announcement' | 'locked' | 'unlocked'): Promise<void>;
26
+ list(): Promise<GroupMetadata[]>;
27
+ inviteInfo(code: string): Promise<GroupMetadata>;
28
+ joinRequests(groupId: string): Promise<Array<{
29
+ [k: string]: string;
30
+ }>>;
31
+ approveJoin(groupId: string, jids: string[]): Promise<ParticipantUpdateResult[]>;
32
+ rejectJoin(groupId: string, jids: string[]): Promise<ParticipantUpdateResult[]>;
33
+ joinApproval(groupId: string, enabled: boolean): Promise<void>;
34
+ memberAddMode(groupId: string, adminsOnly: boolean): Promise<void>;
35
+ }
@@ -0,0 +1,11 @@
1
+ export * from './types.js';
2
+ export * from './errors.js';
3
+ export { GroupModule } from './group.js';
4
+ export { PrivacyModule } from './privacy.js';
5
+ export { NewsletterModule } from './newsletter.js';
6
+ export { CommunityModule } from './community.js';
7
+ export { ProfileModule } from './profile.js';
8
+ export { ChatModule } from './chat.js';
9
+ export { ContactModule } from './contact.js';
10
+ export { BusinessModule } from './business.js';
11
+ export type { DomainSocketLike } from './socket-like.js';
@@ -0,0 +1,35 @@
1
+ import type { OperationGuard } from '../automation/operation-guard.js';
2
+ import type { DomainSocketLike } from './socket-like.js';
3
+ import type { NewsletterMetadata } from './types.js';
4
+ export declare class NewsletterModule {
5
+ private readonly getSocket;
6
+ private readonly guard?;
7
+ constructor(getSocket: () => DomainSocketLike | undefined, guard?: OperationGuard | undefined);
8
+ protected requireSocket(): DomainSocketLike;
9
+ private run;
10
+ create(name: string, opts?: {
11
+ description?: string;
12
+ picture?: Buffer;
13
+ }): Promise<NewsletterMetadata>;
14
+ follow(jid: string): Promise<void>;
15
+ unfollow(jid: string): Promise<void>;
16
+ metadata(jid: string): Promise<NewsletterMetadata>;
17
+ updateName(jid: string, name: string): Promise<void>;
18
+ updateDescription(jid: string, description: string): Promise<void>;
19
+ updatePicture(jid: string, picture: Buffer): Promise<void>;
20
+ mute(jid: string): Promise<void>;
21
+ unmute(jid: string): Promise<void>;
22
+ delete(jid: string): Promise<void>;
23
+ removePicture(jid: string): Promise<void>;
24
+ react(jid: string, serverId: string, emoji: string): Promise<void>;
25
+ /** Remove a reaction from a newsletter message. */
26
+ unreact(jid: string, serverId: string): Promise<void>;
27
+ subscribers(jid: string): Promise<unknown>;
28
+ messages(jid: string, count?: number, opts?: {
29
+ since?: number;
30
+ after?: number;
31
+ }): Promise<unknown>;
32
+ adminCount(jid: string): Promise<number>;
33
+ changeOwner(jid: string, newOwnerJid: string): Promise<void>;
34
+ demote(jid: string, userJid: string): Promise<void>;
35
+ }
@@ -0,0 +1,15 @@
1
+ import type { DomainSocketLike } from './socket-like.js';
2
+ import type { PrivacyConfig, PrivacySettings, WAReadReceiptsValue } from './types.js';
3
+ export declare class PrivacyModule {
4
+ private readonly getSocket;
5
+ constructor(getSocket: () => DomainSocketLike | undefined);
6
+ protected requireSocket(): DomainSocketLike;
7
+ set(config: PrivacyConfig & {
8
+ readReceipts?: WAReadReceiptsValue | boolean;
9
+ }): Promise<void>;
10
+ get(): Promise<PrivacySettings>;
11
+ block(jid: string): Promise<void>;
12
+ unblock(jid: string): Promise<void>;
13
+ blocklist(): Promise<string[]>;
14
+ disappearingMode(seconds: number): Promise<void>;
15
+ }
@@ -0,0 +1,14 @@
1
+ import type { WAMediaUpload } from 'baileys';
2
+ import type { DomainSocketLike } from './socket-like.js';
3
+ export declare class ProfileModule {
4
+ private readonly getSocket;
5
+ constructor(getSocket: () => DomainSocketLike | undefined);
6
+ protected requireSocket(): DomainSocketLike;
7
+ setName(name: string): Promise<void>;
8
+ setStatus(status: string): Promise<void>;
9
+ /** Set the profile/group picture. `jid` defaults to self; pass a group jid to set a group avatar. */
10
+ setPicture(jid: string, image: WAMediaUpload): Promise<void>;
11
+ removePicture(jid: string): Promise<void>;
12
+ getPicture(jid: string, hd?: boolean): Promise<string | null>;
13
+ getStatus(jid: string): Promise<unknown>;
14
+ }
@@ -0,0 +1,117 @@
1
+ import type { ChatModification, GroupMetadata, NewsletterMetadata, ParticipantAction, WAMediaUpload, WAPrivacyGroupAddValue, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from 'baileys';
2
+ import type { LinkedGroup } from './types.js';
3
+ export interface DomainSocketLike {
4
+ groupCreate(subject: string, participants: string[]): Promise<GroupMetadata>;
5
+ groupParticipantsUpdate(jid: string, participants: string[], action: ParticipantAction): Promise<{
6
+ status: string;
7
+ jid: string;
8
+ content?: unknown;
9
+ }[]>;
10
+ groupUpdateSubject(jid: string, subject: string): Promise<void>;
11
+ groupUpdateDescription(jid: string, description?: string): Promise<void>;
12
+ groupLeave(id: string): Promise<void>;
13
+ groupMetadata(jid: string): Promise<GroupMetadata>;
14
+ groupInviteCode(jid: string): Promise<string | undefined>;
15
+ groupRevokeInvite(jid: string): Promise<string | undefined>;
16
+ groupAcceptInvite(code: string): Promise<string | undefined>;
17
+ groupToggleEphemeral(jid: string, ephemeralExpiration: number): Promise<void>;
18
+ groupSettingUpdate(jid: string, setting: 'announcement' | 'not_announcement' | 'locked' | 'unlocked'): Promise<void>;
19
+ updateMemberLabel(jid: string, memberLabel: string): Promise<unknown>;
20
+ groupFetchAllParticipating(): Promise<{
21
+ [jid: string]: GroupMetadata;
22
+ }>;
23
+ groupGetInviteInfo(code: string): Promise<GroupMetadata>;
24
+ groupRequestParticipantsList(jid: string): Promise<Array<{
25
+ [k: string]: string;
26
+ }>>;
27
+ groupRequestParticipantsUpdate(jid: string, participants: string[], action: 'approve' | 'reject'): Promise<{
28
+ status: string;
29
+ jid: string;
30
+ }[]>;
31
+ groupJoinApprovalMode(jid: string, mode: 'on' | 'off'): Promise<void>;
32
+ groupMemberAddMode(jid: string, mode: 'admin_add' | 'all_member_add'): Promise<void>;
33
+ onWhatsApp(...jids: string[]): Promise<Array<{
34
+ jid: string;
35
+ exists: boolean;
36
+ lid?: string;
37
+ }> | undefined>;
38
+ addOrEditContact(jid: string, contact: {
39
+ firstName?: string;
40
+ lastName?: string;
41
+ fullName?: string;
42
+ }): Promise<unknown>;
43
+ removeContact(jid: string): Promise<unknown>;
44
+ getBusinessProfile(jid: string): Promise<unknown>;
45
+ getCatalog(opts: {
46
+ jid?: string;
47
+ limit?: number;
48
+ cursor?: string;
49
+ }): Promise<unknown>;
50
+ getCollections(jid?: string, limit?: number): Promise<unknown>;
51
+ getOrderDetails(orderId: string, tokenBase64: string): Promise<unknown>;
52
+ productCreate(create: Record<string, unknown>): Promise<unknown>;
53
+ productUpdate(productId: string, update: Record<string, unknown>): Promise<unknown>;
54
+ productDelete(productIds: string[]): Promise<{
55
+ deleted: number;
56
+ }>;
57
+ updateLastSeenPrivacy(value: WAPrivacyValue): Promise<void>;
58
+ updateOnlinePrivacy(value: WAPrivacyOnlineValue): Promise<void>;
59
+ updateProfilePicturePrivacy(value: WAPrivacyValue): Promise<void>;
60
+ updateStatusPrivacy(value: WAPrivacyValue): Promise<void>;
61
+ updateReadReceiptsPrivacy(value: WAReadReceiptsValue): Promise<void>;
62
+ updateGroupsAddPrivacy(value: WAPrivacyGroupAddValue): Promise<void>;
63
+ updateDefaultDisappearingMode(duration: number): Promise<void>;
64
+ fetchPrivacySettings(force?: boolean): Promise<{
65
+ [_: string]: string;
66
+ }>;
67
+ updateBlockStatus(jid: string, action: 'block' | 'unblock'): Promise<void>;
68
+ fetchBlocklist(): Promise<string[]>;
69
+ updateProfileName(name: string): Promise<void>;
70
+ updateProfileStatus(status: string): Promise<void>;
71
+ updateProfilePicture(jid: string, content: WAMediaUpload): Promise<void>;
72
+ removeProfilePicture(jid: string): Promise<void>;
73
+ profilePictureUrl(jid: string, type?: 'image' | 'preview', timeoutMs?: number): Promise<string | undefined>;
74
+ fetchStatus(jid: string): Promise<unknown>;
75
+ chatModify(mod: ChatModification, jid: string): Promise<void>;
76
+ newsletterCreate(name: string, description?: string): Promise<NewsletterMetadata>;
77
+ newsletterFollow(jid: string): Promise<unknown>;
78
+ newsletterUnfollow(jid: string): Promise<unknown>;
79
+ newsletterMetadata(type: 'invite' | 'jid', key: string): Promise<NewsletterMetadata | null>;
80
+ newsletterUpdateName(jid: string, name: string): Promise<unknown>;
81
+ newsletterUpdateDescription(jid: string, description: string): Promise<unknown>;
82
+ newsletterUpdatePicture(jid: string, content: WAMediaUpload): Promise<unknown>;
83
+ newsletterMute(jid: string): Promise<unknown>;
84
+ newsletterUnmute(jid: string): Promise<unknown>;
85
+ newsletterDelete(jid: string): Promise<void>;
86
+ newsletterSubscribers(jid: string): Promise<unknown>;
87
+ newsletterRemovePicture(jid: string): Promise<unknown>;
88
+ newsletterReactMessage(jid: string, serverId: string, reaction?: string): Promise<void>;
89
+ newsletterFetchMessages(jid: string, count: number, since?: number, after?: number): Promise<unknown>;
90
+ newsletterAdminCount(jid: string): Promise<number>;
91
+ newsletterChangeOwner(jid: string, newOwnerJid: string): Promise<void>;
92
+ newsletterDemote(jid: string, userJid: string): Promise<void>;
93
+ communityCreate(subject: string, body: string): Promise<GroupMetadata>;
94
+ communityCreateGroup(subject: string, participants: string[], parentCommunityJid: string): Promise<GroupMetadata>;
95
+ communityLinkGroup(groupJid: string, parentCommunityJid: string): Promise<void>;
96
+ communityUnlinkGroup(groupJid: string, parentCommunityJid: string): Promise<void>;
97
+ communityFetchLinkedGroups(jid: string): Promise<{
98
+ communityJid: string;
99
+ isCommunity: boolean;
100
+ linkedGroups: LinkedGroup[];
101
+ }>;
102
+ communityLeave(id: string): Promise<void>;
103
+ communityUpdateSubject(jid: string, subject: string): Promise<void>;
104
+ communityUpdateDescription(jid: string, description?: string): Promise<void>;
105
+ communityInviteCode(jid: string): Promise<string | undefined>;
106
+ communityRevokeInvite(jid: string): Promise<string | undefined>;
107
+ communityAcceptInvite(code: string): Promise<string | undefined>;
108
+ communityMetadata(jid: string): Promise<GroupMetadata>;
109
+ communityFetchAllParticipating(): Promise<{
110
+ [jid: string]: GroupMetadata;
111
+ }>;
112
+ communityGetInviteInfo(code: string): Promise<GroupMetadata>;
113
+ communityToggleEphemeral(jid: string, ephemeralExpiration: number): Promise<void>;
114
+ communitySettingUpdate(jid: string, setting: 'announcement' | 'not_announcement'): Promise<void>;
115
+ communityMemberAddMode(jid: string, mode: 'admin_add' | 'all_member_add'): Promise<void>;
116
+ communityJoinApprovalMode(jid: string, mode: 'on' | 'off'): Promise<void>;
117
+ }
@@ -0,0 +1,24 @@
1
+ export type { GroupMetadata, GroupParticipant, ParticipantAction, WAPrivacyValue, WAPrivacyOnlineValue, WAReadReceiptsValue, WAPrivacyGroupAddValue, NewsletterMetadata, WAMediaUpload, } from 'baileys';
2
+ import type { WAPrivacyValue, WAPrivacyOnlineValue, WAReadReceiptsValue, WAPrivacyGroupAddValue } from 'baileys';
3
+ export interface ParticipantUpdateResult {
4
+ jid: string;
5
+ status: string;
6
+ }
7
+ export interface PrivacyConfig {
8
+ lastSeen?: WAPrivacyValue;
9
+ online?: WAPrivacyOnlineValue;
10
+ profile?: WAPrivacyValue;
11
+ status?: WAPrivacyValue;
12
+ readReceipts?: WAReadReceiptsValue;
13
+ groupAdd?: WAPrivacyGroupAddValue;
14
+ }
15
+ export type PrivacySettings = {
16
+ [key: string]: string;
17
+ };
18
+ export interface LinkedGroup {
19
+ id?: string;
20
+ subject: string;
21
+ creation?: number;
22
+ owner?: string;
23
+ size?: number;
24
+ }
@@ -0,0 +1,238 @@
1
+ import { type WAMessage, type WAMessageKey } from 'baileys';
2
+ import { Readable } from 'node:stream';
3
+ import type { SenderInfo } from './types.js';
4
+ import type { TextOptions } from '../builder/builder.js';
5
+ export type ChatType = 'text' | 'image' | 'video' | 'audio' | 'document' | 'sticker' | 'poll' | 'contact' | 'location' | 'live-location' | 'event' | 'album' | 'group-invite' | 'product' | 'order' | 'payment' | 'buttons' | 'list' | 'interactive' | 'template' | 'unknown';
6
+ export type SenderDevice = 'unknown' | 'android' | 'ios' | 'web' | 'desktop' | string;
7
+ export interface CitationConfig {
8
+ authors?: string[] | ((jid: string) => boolean | Promise<boolean>);
9
+ banned?: string[] | ((jid: string) => boolean | Promise<boolean>);
10
+ }
11
+ export interface CitationPredicates {
12
+ authors(): Promise<boolean>;
13
+ banned(): Promise<boolean>;
14
+ }
15
+ export interface MediaAttachment {
16
+ type: 'image' | 'video' | 'audio' | 'document' | 'sticker';
17
+ mimetype: string | null;
18
+ caption: string | null;
19
+ fileName: string | null;
20
+ fileSize: number | null;
21
+ ptt: boolean;
22
+ buffer(): Promise<Buffer>;
23
+ stream(): Promise<Readable>;
24
+ }
25
+ export interface PollMedia {
26
+ type: 'poll';
27
+ name: string | null;
28
+ options: string[];
29
+ selectableCount: number;
30
+ }
31
+ export interface ContactCard {
32
+ displayName: string | null;
33
+ vcard: string | null;
34
+ }
35
+ export interface ContactMedia {
36
+ type: 'contact';
37
+ displayName: string | null;
38
+ vcard: string | null;
39
+ contacts: ContactCard[];
40
+ }
41
+ export interface LocationMedia {
42
+ type: 'location' | 'live-location';
43
+ latitude: number | null;
44
+ longitude: number | null;
45
+ name: string | null;
46
+ address: string | null;
47
+ accuracy: number | null;
48
+ speed: number | null;
49
+ caption: string | null;
50
+ }
51
+ export interface AlbumMedia {
52
+ type: 'album';
53
+ expectedImageCount: number | null;
54
+ expectedVideoCount: number | null;
55
+ }
56
+ export interface GroupInviteMedia {
57
+ type: 'group-invite';
58
+ groupId: string | null;
59
+ groupName: string | null;
60
+ inviteCode: string | null;
61
+ caption: string | null;
62
+ expiresAt: number | null;
63
+ }
64
+ export interface ProductMedia {
65
+ type: 'product';
66
+ productId: string | null;
67
+ title: string | null;
68
+ description: string | null;
69
+ price: number | null;
70
+ currency: string | null;
71
+ retailerId: string | null;
72
+ url: string | null;
73
+ businessOwnerId: string | null;
74
+ }
75
+ export interface OrderMedia {
76
+ type: 'order';
77
+ orderId: string | null;
78
+ title: string | null;
79
+ itemCount: number | null;
80
+ total: number | null;
81
+ currency: string | null;
82
+ status: string | null;
83
+ message: string | null;
84
+ }
85
+ export interface PaymentMedia {
86
+ type: 'payment';
87
+ kind: 'request' | 'send' | 'invite';
88
+ amount: number | null;
89
+ currency: string | null;
90
+ note: string | null;
91
+ expiresAt: number | null;
92
+ }
93
+ export interface LinkPreviewMedia {
94
+ type: 'link';
95
+ url: string | null;
96
+ title: string | null;
97
+ description: string | null;
98
+ }
99
+ export interface EventMedia {
100
+ type: 'event';
101
+ name: string | null;
102
+ description: string | null;
103
+ location: string | null;
104
+ startTime: number | null;
105
+ endTime: number | null;
106
+ isCanceled: boolean;
107
+ }
108
+ export interface MessageButton {
109
+ id: string | null;
110
+ text: string | null;
111
+ }
112
+ export interface ButtonsMedia {
113
+ type: 'buttons';
114
+ contentText: string | null;
115
+ footerText: string | null;
116
+ buttons: MessageButton[];
117
+ }
118
+ export interface ListRow {
119
+ id: string | null;
120
+ title: string | null;
121
+ description: string | null;
122
+ }
123
+ export interface ListSection {
124
+ title: string | null;
125
+ rows: ListRow[];
126
+ }
127
+ export interface ListMedia {
128
+ type: 'list';
129
+ title: string | null;
130
+ description: string | null;
131
+ buttonText: string | null;
132
+ sections: ListSection[];
133
+ }
134
+ export interface InteractiveMedia {
135
+ type: 'interactive';
136
+ title: string | null;
137
+ body: string | null;
138
+ footer: string | null;
139
+ buttons: Array<{
140
+ name: string | null;
141
+ params: string | null;
142
+ }>;
143
+ }
144
+ export interface TemplateMedia {
145
+ type: 'template';
146
+ text: string | null;
147
+ buttons: MessageButton[];
148
+ }
149
+ export type ContextMedia = MediaAttachment | PollMedia | ContactMedia | LocationMedia | EventMedia | AlbumMedia | GroupInviteMedia | ProductMedia | OrderMedia | PaymentMedia | LinkPreviewMedia | ButtonsMedia | ListMedia | InteractiveMedia | TemplateMedia;
150
+ export interface MessageContext {
151
+ uniqueId: string;
152
+ staticId: string;
153
+ channelId: string;
154
+ chatId: string;
155
+ chatType: ChatType;
156
+ receiverId: string;
157
+ roomId: string | null;
158
+ senderId: string;
159
+ senderLid: string | null;
160
+ senderName: string | null;
161
+ senderDevice: SenderDevice;
162
+ timestamp: number;
163
+ text: string;
164
+ mentions: string[];
165
+ links: string[];
166
+ isFromMe: boolean;
167
+ isGroup: boolean;
168
+ isNewsletter: boolean;
169
+ isBroadcast: boolean;
170
+ isViewOnce: boolean;
171
+ isEphemeral: boolean;
172
+ isForwarded: boolean;
173
+ isQuestion: boolean;
174
+ isPrefix: boolean;
175
+ isTagMe: boolean;
176
+ isEdited: boolean;
177
+ isDeleted: boolean;
178
+ isPinned: boolean;
179
+ isUnPinned: boolean;
180
+ isBot: boolean;
181
+ isSpam: boolean;
182
+ isHideTags: boolean;
183
+ isStatusMention: boolean;
184
+ isGroupStatusMention: boolean;
185
+ isStory: boolean;
186
+ roomName(): Promise<string | null>;
187
+ receiverName(): Promise<string | null>;
188
+ media?: ContextMedia;
189
+ replied(): Promise<MessageContext | null>;
190
+ message(): WAMessage;
191
+ citation: CitationPredicates;
192
+ reply(content: string, opts?: TextOptions): Promise<WAMessageKey>;
193
+ react(emoji: string): Promise<WAMessageKey>;
194
+ }
195
+ export interface MentionContext extends MessageContext {
196
+ mentionedJids: string[];
197
+ selfJid: string;
198
+ }
199
+ export interface MentionAllContext extends MessageContext {
200
+ isMentionAll: true;
201
+ selfJid: string;
202
+ members?: string[];
203
+ }
204
+ export interface BuildContextInput {
205
+ message: WAMessage;
206
+ key: WAMessageKey;
207
+ channelId: string;
208
+ receiverId: string;
209
+ selfJid: string;
210
+ text: string;
211
+ chatType: ChatType;
212
+ sender: SenderInfo;
213
+ mentions: string[];
214
+ isViewOnce: boolean;
215
+ isEphemeral: boolean;
216
+ isForwarded: boolean;
217
+ isBroadcast: boolean;
218
+ isNewsletter: boolean;
219
+ prefixes: string[];
220
+ citationConfig?: CitationConfig;
221
+ lidMap?: Map<string, string>;
222
+ resolveRoomName: () => Promise<string | null>;
223
+ resolveReceiverName: () => Promise<string | null>;
224
+ resolveReplied: () => Promise<MessageContext | null>;
225
+ reply: (content: string, opts?: TextOptions) => Promise<WAMessageKey>;
226
+ react: (emoji: string) => Promise<WAMessageKey>;
227
+ media?: ContextMedia;
228
+ }
229
+ export declare const extractLinks: (text: string) => string[];
230
+ export declare const computeUniqueId: (key: WAMessageKey) => string;
231
+ export declare const computeStaticId: (roomId: string | null, senderId: string) => string;
232
+ export declare const epochSecondsToMs: (value: unknown) => number;
233
+ export declare const senderDeviceOf: (jid: string) => SenderDevice;
234
+ export declare const isQuestionOf: (text: string) => boolean;
235
+ export declare const isPrefixOf: (text: string, prefixes: string[]) => boolean;
236
+ export declare const isTagMeOf: (selfJid: string, mentions: string[]) => boolean;
237
+ export declare const makeCitation: (config: CitationConfig | undefined, senderJid: string) => CitationPredicates;
238
+ export declare const buildMessageContext: (input: BuildContextInput) => MessageContext;
@@ -0,0 +1,8 @@
1
+ import { Readable } from 'node:stream';
2
+ import type { WAMessage } from 'baileys';
3
+ import type { MediaDownloadResult, MediaKind } from '../types.js';
4
+ export interface DownloadLogger {
5
+ warn(obj: unknown, msg?: string): void;
6
+ }
7
+ export declare const createDownloadFn: (msg: WAMessage, kind: MediaKind, logger?: DownloadLogger) => (() => Promise<MediaDownloadResult>);
8
+ export declare const createStreamFn: (msg: WAMessage, kind: MediaKind, logger?: DownloadLogger) => (() => Promise<Readable>);
@@ -0,0 +1,26 @@
1
+ import { type WAContextInfo, type WAMessageKey } from 'baileys';
2
+ import type { QuotedRef, SenderInfo } from '../types.js';
3
+ export interface LongLike {
4
+ toNumber(): number;
5
+ low: number;
6
+ high: number;
7
+ }
8
+ export interface AddressingAliases {
9
+ remoteJidAlt?: string;
10
+ remoteJidUsername?: string;
11
+ participantAlt?: string;
12
+ participantUsername?: string;
13
+ }
14
+ export interface ExtractedMentions {
15
+ mentionedJids: string[];
16
+ mentionAll: boolean;
17
+ }
18
+ export declare const extractJid: (remoteJid: string | undefined | null) => string | null;
19
+ export declare const isLidJid: (jid: string) => boolean;
20
+ export declare const isPnJid: (jid: string) => boolean;
21
+ export declare const extractSender: (key: WAMessageKey | undefined, pushName?: string) => SenderInfo | null;
22
+ export declare const extractQuoted: (contextInfo: WAContextInfo | null | undefined) => QuotedRef | null;
23
+ export declare const extractMentions: (contextInfo: WAContextInfo | null | undefined) => ExtractedMentions;
24
+ export declare const mapAddressing: (key: WAMessageKey) => AddressingAliases;
25
+ export declare const isGroupJid: (jid: string) => boolean;
26
+ export declare const safeNumber: (n: number | LongLike | null | undefined) => number | null;
@@ -0,0 +1,11 @@
1
+ import type { WACallEvent } from 'baileys';
2
+ import type { CallPayload } from '../types.js';
3
+ type IncomingCall = Extract<CallPayload, {
4
+ kind: 'incoming';
5
+ }>;
6
+ type EndedCall = Extract<CallPayload, {
7
+ kind: 'ended';
8
+ }>;
9
+ export declare const decodeCallIncoming: (item: WACallEvent) => IncomingCall | null;
10
+ export declare const decodeCallEnded: (item: WACallEvent) => EndedCall | null;
11
+ export {};