zaileys 4.7.0 → 4.7.2

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 (130) 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 +130 -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 +104 -0
  54. package/dist/command/dispatcher.d.ts +23 -0
  55. package/dist/command/errors.d.ts +8 -0
  56. package/dist/command/index.d.ts +7 -0
  57. package/dist/command/middleware.d.ts +2 -0
  58. package/dist/command/parser.d.ts +2 -0
  59. package/dist/command/registry.d.ts +13 -0
  60. package/dist/command/types.d.ts +30 -0
  61. package/dist/connection/auth-adapter.d.ts +4 -0
  62. package/dist/connection/auth-guard.d.ts +37 -0
  63. package/dist/connection/disconnect-reason.d.ts +6 -0
  64. package/dist/connection/index.d.ts +7 -0
  65. package/dist/connection/pairing-flow.d.ts +16 -0
  66. package/dist/connection/qr-terminal.d.ts +2 -0
  67. package/dist/connection/reconnect.d.ts +15 -0
  68. package/dist/connection/state-machine.d.ts +9 -0
  69. package/dist/connection/status-log.d.ts +25 -0
  70. package/dist/domain/business.d.ts +19 -0
  71. package/dist/domain/chat.d.ts +27 -0
  72. package/dist/domain/community.d.ts +28 -0
  73. package/dist/domain/contact.d.ts +21 -0
  74. package/dist/domain/errors.d.ts +8 -0
  75. package/dist/domain/group.d.ts +35 -0
  76. package/dist/domain/index.d.ts +11 -0
  77. package/dist/domain/newsletter.d.ts +35 -0
  78. package/dist/domain/privacy.d.ts +15 -0
  79. package/dist/domain/profile.d.ts +14 -0
  80. package/dist/domain/socket-like.d.ts +117 -0
  81. package/dist/domain/types.d.ts +24 -0
  82. package/dist/events/context.d.ts +238 -0
  83. package/dist/events/decoders/_media-download.d.ts +8 -0
  84. package/dist/events/decoders/_shared.d.ts +26 -0
  85. package/dist/events/decoders/calls.d.ts +11 -0
  86. package/dist/events/decoders/groups.d.ts +36 -0
  87. package/dist/events/decoders/interactive.d.ts +9 -0
  88. package/dist/events/decoders/lifecycle.d.ts +69 -0
  89. package/dist/events/decoders/messages.d.ts +30 -0
  90. package/dist/events/decoders/mutations.d.ts +24 -0
  91. package/dist/events/guards.d.ts +9 -0
  92. package/dist/events/index.d.ts +4 -0
  93. package/dist/events/pipeline.d.ts +37 -0
  94. package/dist/events/types.d.ts +187 -0
  95. package/dist/index.cjs +8 -8
  96. package/dist/index.d.ts +14 -2264
  97. package/dist/index.mjs +8 -8
  98. package/dist/media/ffmpeg/audio.d.ts +12 -0
  99. package/dist/media/ffmpeg/core.d.ts +67 -0
  100. package/dist/media/ffmpeg/document.d.ts +10 -0
  101. package/dist/media/ffmpeg/image.d.ts +7 -0
  102. package/dist/media/ffmpeg/index.d.ts +7 -0
  103. package/dist/media/ffmpeg/sticker.d.ts +14 -0
  104. package/dist/media/ffmpeg/transform.d.ts +2 -0
  105. package/dist/media/ffmpeg/video.d.ts +6 -0
  106. package/dist/media/index.d.ts +2 -0
  107. package/dist/media/media.d.ts +39 -0
  108. package/dist/plugin/index.d.ts +5 -0
  109. package/dist/plugin/loader.d.ts +30 -0
  110. package/dist/plugin/registry.d.ts +24 -0
  111. package/dist/plugin/types.d.ts +25 -0
  112. package/dist/store/adapters/convex.d.ts +33 -0
  113. package/dist/store/adapters/index.d.ts +5 -0
  114. package/dist/store/adapters/memory.d.ts +31 -0
  115. package/dist/store/adapters/postgres.d.ts +40 -0
  116. package/dist/store/adapters/redis.d.ts +49 -0
  117. package/dist/store/adapters/sqlite.d.ts +36 -0
  118. package/dist/store/index.d.ts +2 -0
  119. package/dist/store/types.d.ts +48 -0
  120. package/dist/types/convex.d.ts +35 -0
  121. package/dist/types/index.d.ts +4 -0
  122. package/dist/types/lid-mapping.d.ts +5 -0
  123. package/dist/types/optional-clients.d.ts +69 -0
  124. package/dist/types/store-error.d.ts +8 -0
  125. package/dist/utils/array.d.ts +1 -0
  126. package/dist/utils/index.d.ts +5 -0
  127. package/dist/utils/jid.d.ts +6 -0
  128. package/dist/utils/logger.d.ts +10 -0
  129. package/package.json +5 -7
  130. package/dist/index.d.cts +0 -2264
@@ -0,0 +1,30 @@
1
+ import type { WAMessageKey } from 'baileys';
2
+ import type { MessageContext } from '../events/context.js';
3
+ import type { TextOptions } from '../builder/builder.js';
4
+ export type CommandPrefix = string | string[];
5
+ export interface ParsedArgs {
6
+ matched: boolean;
7
+ name?: string;
8
+ args: string[];
9
+ flags: Record<string, string | boolean>;
10
+ json: unknown;
11
+ raw: string;
12
+ }
13
+ export interface CommandContext extends MessageContext {
14
+ raw: string;
15
+ command: string;
16
+ args: string[];
17
+ flags: Record<string, string | boolean>;
18
+ json: unknown;
19
+ reply(content: string, opts?: TextOptions): Promise<WAMessageKey>;
20
+ react(emoji: string): Promise<WAMessageKey>;
21
+ edit(content: string): Promise<void>;
22
+ }
23
+ export type CommandHandler = (ctx: CommandContext) => Promise<void> | void;
24
+ export type Middleware = (ctx: CommandContext, next: () => Promise<void>) => Promise<void> | void;
25
+ export interface CommandDefinition {
26
+ name: string;
27
+ aliases: string[];
28
+ parts: string[];
29
+ handler: CommandHandler;
30
+ }
@@ -0,0 +1,4 @@
1
+ import type { SignalKeyStore } from 'baileys';
2
+ import type { AuthStore } from '../auth/types.js';
3
+ import type { Logger } from '../client/types.js';
4
+ export declare function signalKeyStoreFromAuthStore(store: AuthStore, _logger?: Logger): SignalKeyStore;
@@ -0,0 +1,37 @@
1
+ import type { ConnectionAuthType } from '../client/types.js';
2
+ /**
3
+ * Bounds QR and pairing-code regeneration across a client's lifetime to avoid
4
+ * tripping WhatsApp's spam/automation restriction. Each reconnect creates a fresh
5
+ * socket which re-emits a QR or requests a new pairing code; without a budget and
6
+ * cooldown this loops unbounded and gets the account restricted.
7
+ */
8
+ export interface AuthGuardOptions {
9
+ /** Master switch. When `false` the guard never blocks (legacy behaviour). Default `true`. */
10
+ enabled?: boolean;
11
+ /** Total QR codes emitted before the guard stops and signals exhaustion. Default `5`. */
12
+ maxQrAttempts?: number;
13
+ /** Total pairing-code requests before the guard stops and signals exhaustion. Default `3`. */
14
+ maxPairingAttempts?: number;
15
+ /** Base cooldown between pairing-code requests; escalates per attempt. Default `60000`. */
16
+ pairingCooldownMs?: number;
17
+ }
18
+ export type AuthAttemptBlockReason = 'budget-exhausted' | 'cooldown';
19
+ export interface AuthAttemptDecision {
20
+ allowed: boolean;
21
+ reason?: AuthAttemptBlockReason;
22
+ waitMs: number;
23
+ attempts: number;
24
+ max: number;
25
+ }
26
+ export interface AuthGuard {
27
+ /** Decide whether a new auth attempt of `kind` is permitted at time `now` (does not mutate). */
28
+ evaluate(kind: ConnectionAuthType, now: number): AuthAttemptDecision;
29
+ /** Record that an attempt of `kind` was actually issued at time `now`. */
30
+ record(kind: ConnectionAuthType, now: number): void;
31
+ /** Clear all counters and cooldowns (call on a successful connection or manual restart). */
32
+ reset(): void;
33
+ readonly enabled: boolean;
34
+ readonly qrAttempts: number;
35
+ readonly pairingAttempts: number;
36
+ }
37
+ export declare function createAuthGuard(options?: AuthGuardOptions): AuthGuard;
@@ -0,0 +1,6 @@
1
+ export type DisconnectReasonDomain = 'logged-out' | 'connection-replaced' | 'forbidden' | 'restart-required' | 'bad-session' | 'connection-closed' | 'connection-lost' | 'multi-device-mismatch' | 'unavailable-service' | 'rate-limited' | 'unknown';
2
+ export declare function mapDisconnectReason(code: number | undefined): DisconnectReasonDomain;
3
+ export declare function isFatalDisconnect(reason: DisconnectReasonDomain): boolean;
4
+ export declare function isRateLimited(reason: DisconnectReasonDomain): boolean;
5
+ export declare function shouldClearAuth(reason: DisconnectReasonDomain): boolean;
6
+ export declare function shouldReconnect(reason: DisconnectReasonDomain): boolean;
@@ -0,0 +1,7 @@
1
+ export * from './auth-adapter.js';
2
+ export * from './auth-guard.js';
3
+ export * from './disconnect-reason.js';
4
+ export * from './pairing-flow.js';
5
+ export * from './qr-terminal.js';
6
+ export * from './reconnect.js';
7
+ export * from './state-machine.js';
@@ -0,0 +1,16 @@
1
+ import type { BaileysSocket } from '../client/types.js';
2
+ export interface PairingFlowOptions {
3
+ phoneNumber: string;
4
+ ttlMs?: number;
5
+ }
6
+ export interface PairingFlowResult {
7
+ code: string;
8
+ expiresAt: number;
9
+ }
10
+ export interface PairingFlow {
11
+ readonly phoneNumber: string;
12
+ requestCode(socket: Pick<BaileysSocket, 'requestPairingCode'>): Promise<PairingFlowResult>;
13
+ }
14
+ export declare function normalizePhoneNumber(raw: string): string;
15
+ export declare function validateE164(raw: string): string;
16
+ export declare function createPairingFlow(options: PairingFlowOptions): PairingFlow;
@@ -0,0 +1,2 @@
1
+ export declare function renderQrInTerminal(qrString: string): Promise<string>;
2
+ export declare function printQrToTerminal(qrString: string, write?: (s: string) => void): Promise<void>;
@@ -0,0 +1,15 @@
1
+ import type { ReconnectOptions } from '../client/types.js';
2
+ import { type DisconnectReasonDomain } from './disconnect-reason.js';
3
+ export interface ReconnectDecision {
4
+ attempt: number;
5
+ delayMs: number;
6
+ }
7
+ export interface ReconnectStrategy {
8
+ next(reason: DisconnectReasonDomain): ReconnectDecision | null;
9
+ reset(): void;
10
+ readonly attempts: number;
11
+ }
12
+ export interface ReconnectStrategyDeps {
13
+ random?: () => number;
14
+ }
15
+ export declare function createReconnectStrategy(options?: ReconnectOptions, deps?: ReconnectStrategyDeps): ReconnectStrategy;
@@ -0,0 +1,9 @@
1
+ import type { ConnectionState } from '../client/types.js';
2
+ export type StateTransitionListener = (prev: ConnectionState, next: ConnectionState) => void;
3
+ export interface ConnectionStateMachine {
4
+ readonly state: ConnectionState;
5
+ canTransition(next: ConnectionState): boolean;
6
+ transition(next: ConnectionState): void;
7
+ onChange(listener: StateTransitionListener): () => void;
8
+ }
9
+ export declare function createConnectionStateMachine(initial?: ConnectionState): ConnectionStateMachine;
@@ -0,0 +1,25 @@
1
+ import type { DisconnectReasonDomain } from './disconnect-reason.js';
2
+ export type StatusEvent = {
3
+ kind: 'connecting';
4
+ sessionId: string;
5
+ } | {
6
+ kind: 'qr';
7
+ } | {
8
+ kind: 'pairing-code';
9
+ code: string;
10
+ } | {
11
+ kind: 'connected';
12
+ id: string;
13
+ } | {
14
+ kind: 'reconnecting';
15
+ attempt: number;
16
+ delayMs: number;
17
+ reason: DisconnectReasonDomain;
18
+ invalidCredsSuspected: boolean;
19
+ } | {
20
+ kind: 'disconnect';
21
+ reason: DisconnectReasonDomain;
22
+ willReconnect: boolean;
23
+ };
24
+ export declare function formatConnectionStatus(event: StatusEvent): string | null;
25
+ export declare function suppressLibsignalNoise(): void;
@@ -0,0 +1,19 @@
1
+ import type { DomainSocketLike } from './socket-like.js';
2
+ export declare class BusinessModule {
3
+ private readonly getSocket;
4
+ constructor(getSocket: () => DomainSocketLike | undefined);
5
+ protected requireSocket(): DomainSocketLike;
6
+ profile(jid: string): Promise<unknown>;
7
+ catalog(opts?: {
8
+ jid?: string;
9
+ limit?: number;
10
+ cursor?: string;
11
+ }): Promise<unknown>;
12
+ collections(jid?: string, limit?: number): Promise<unknown>;
13
+ orderDetails(orderId: string, tokenBase64: string): Promise<unknown>;
14
+ createProduct(create: Record<string, unknown>): Promise<unknown>;
15
+ updateProduct(productId: string, update: Record<string, unknown>): Promise<unknown>;
16
+ deleteProduct(...productIds: string[]): Promise<{
17
+ deleted: number;
18
+ }>;
19
+ }
@@ -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
+ }