Skip to content

Commit d647ba1

Browse files
committed
refactor: trim whatsapp helper exports
1 parent d573671 commit d647ba1

10 files changed

Lines changed: 22 additions & 22 deletions

File tree

extensions/whatsapp/src/auto-reply/monitor/inbound-context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export type GroupHistoryEntry = {
2121

2222
type ContextVisibilityMode = "all" | "allowlist" | "allowlist_quote";
2323

24-
export function isWhatsAppSupplementalSenderAllowed(params: {
24+
function isWhatsAppSupplementalSenderAllowed(params: {
2525
allowFrom: string[];
2626
sender?: WhatsAppIdentity | null;
2727
}): boolean {

extensions/whatsapp/src/connection-controller-registry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { ActiveWebListener } from "./inbound/types.js";
22

3-
export type WhatsAppConnectionControllerHandle = {
3+
type WhatsAppConnectionControllerHandle = {
44
getActiveListener(): ActiveWebListener | null;
55
};
66

extensions/whatsapp/src/connection-controller.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import type { WhatsAppSocketTimingOptions } from "./socket-timing.js";
1919
const LOGGED_OUT_STATUS = DisconnectReason?.loggedOut ?? 401;
2020
const WHATSAPP_LOGIN_RESTART_MESSAGE =
2121
"WhatsApp asked for a restart after pairing (code 515); waiting for creds to save…";
22-
export const WHATSAPP_LOGGED_OUT_RELINK_MESSAGE =
22+
const WHATSAPP_LOGGED_OUT_RELINK_MESSAGE =
2323
"WhatsApp reported the session is logged out. Cleared cached web session; please rerun openclaw channels login and scan the QR again.";
2424
export const WHATSAPP_LOGGED_OUT_QR_MESSAGE =
2525
"WhatsApp reported the session is logged out. Cleared cached web session; please scan a new QR.";
@@ -33,7 +33,7 @@ export type ManagedWhatsAppListener = ActiveWebListener & {
3333
signalClose?: (reason?: WebListenerCloseReason) => void;
3434
};
3535

36-
export type WhatsAppLiveConnection = {
36+
type WhatsAppLiveConnection = {
3737
connectionId: string;
3838
startedAt: number;
3939
sock: WASocket;
@@ -51,7 +51,7 @@ export type WhatsAppLiveConnection = {
5151
resolveClose: (reason: WebListenerCloseReason) => void;
5252
};
5353

54-
export type WhatsAppConnectionSnapshot = {
54+
type WhatsAppConnectionSnapshot = {
5555
connectionId: string;
5656
startedAt: number;
5757
lastInboundAt: number | null;
@@ -61,23 +61,23 @@ export type WhatsAppConnectionSnapshot = {
6161
uptimeMs: number;
6262
};
6363

64-
export type NormalizedConnectionCloseReason = {
64+
type NormalizedConnectionCloseReason = {
6565
statusCode?: number;
6666
statusLabel: number | "unknown";
6767
isLoggedOut: boolean;
6868
error?: unknown;
6969
errorText: string;
7070
};
7171

72-
export type WhatsAppConnectionCloseDecision = {
72+
type WhatsAppConnectionCloseDecision = {
7373
action: "stop" | "retry";
7474
delayMs?: number;
7575
reconnectAttempts: number;
7676
healthState: "logged-out" | "conflict" | "stopped" | "reconnecting";
7777
normalized: NormalizedConnectionCloseReason;
7878
};
7979

80-
export type WhatsAppReconnectAttemptDecision = {
80+
type WhatsAppReconnectAttemptDecision = {
8181
action: "stop" | "retry";
8282
delayMs?: number;
8383
reconnectAttempts: number;
@@ -148,7 +148,7 @@ export function closeWaSocketSoon(
148148
}, delayMs);
149149
}
150150

151-
export type WhatsAppLoginWaitResult =
151+
type WhatsAppLoginWaitResult =
152152
| {
153153
outcome: "connected";
154154
restarted: boolean;

extensions/whatsapp/src/group-intro.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const WHATSAPP_GROUP_INTRO_HINT =
1+
const WHATSAPP_GROUP_INTRO_HINT =
22
"WhatsApp IDs: SenderId is the participant JID (group participant id).";
33

44
export function resolveWhatsAppGroupIntroHint(): string {

extensions/whatsapp/src/identity.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ type LegacyMentionsLike = {
5050
mentionedJids?: string[];
5151
};
5252

53-
export function normalizeDeviceScopedJid(jid: string | null | undefined): string | null {
53+
function normalizeDeviceScopedJid(jid: string | null | undefined): string | null {
5454
return jid ? jid.replace(/:\d+/, "") : null;
5555
}
5656

@@ -148,7 +148,7 @@ export function getReplyContext(
148148
};
149149
}
150150

151-
export function getMentionJids(msg: LegacyMentionsLike): string[] {
151+
function getMentionJids(msg: LegacyMentionsLike): string[] {
152152
return msg.mentions ?? msg.mentionedJids ?? [];
153153
}
154154

extensions/whatsapp/src/inbound/monitor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const RECONNECT_IN_PROGRESS_ERROR = "no active socket - reconnection in progress
5050
const GROUP_META_TTL_MS = 5 * 60 * 1000; // 5 minutes
5151
export const WHATSAPP_GROUP_METADATA_CACHE_MAX_ENTRIES = 500;
5252

53-
export type WhatsAppGroupMetadataCacheEntry = {
53+
type WhatsAppGroupMetadataCacheEntry = {
5454
subject?: string;
5555
expires: number;
5656
};
@@ -118,7 +118,7 @@ function isNonEmptyString(value: string | undefined): value is string {
118118
return Boolean(value);
119119
}
120120

121-
export type MonitorWebInboxOptions = {
121+
type MonitorWebInboxOptions = {
122122
cfg: OpenClawConfig;
123123
verbose: boolean;
124124
accountId: string;

extensions/whatsapp/src/inbound/send-result.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { WAMessage, WAMessageKey } from "@whiskeysockets/baileys";
22

33
export type WhatsAppSendKind = "media" | "poll" | "reaction" | "text";
44

5-
export type WhatsAppSendKey = Omit<
5+
type WhatsAppSendKey = Omit<
66
Pick<WAMessageKey, "fromMe" | "id" | "participant" | "remoteJid">,
77
"id"
88
> & {

extensions/whatsapp/src/outbound-media-contract.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type WhatsAppLoadedMediaLike = {
2424
fileName?: string;
2525
};
2626

27-
export type NormalizedWhatsAppOutboundPayload<T extends WhatsAppOutboundPayloadLike> = Omit<
27+
type NormalizedWhatsAppOutboundPayload<T extends WhatsAppOutboundPayloadLike> = Omit<
2828
T,
2929
"text" | "mediaUrl" | "mediaUrls"
3030
> & {
@@ -40,7 +40,7 @@ export type DeliverableWhatsAppOutboundPayload<T extends WhatsAppOutboundPayload
4040
text?: string;
4141
};
4242

43-
export type CanonicalWhatsAppLoadedMedia = {
43+
type CanonicalWhatsAppLoadedMedia = {
4444
buffer: Buffer;
4545
kind: "image" | "audio" | "video" | "document";
4646
mimetype: string;
@@ -109,7 +109,7 @@ export function normalizeWhatsAppOutboundPayload<T extends WhatsAppOutboundPaylo
109109
};
110110
}
111111

112-
export function normalizeWhatsAppLoadedMedia(
112+
function normalizeWhatsAppLoadedMedia(
113113
media: WhatsAppLoadedMediaLike,
114114
mediaUrl?: string,
115115
): CanonicalWhatsAppLoadedMedia {
@@ -236,7 +236,7 @@ function deriveWhatsAppDocumentFileName(mediaUrl: string | undefined): string |
236236
}
237237
}
238238

239-
export function isRetryableWhatsAppOutboundError(error: unknown): boolean {
239+
function isRetryableWhatsAppOutboundError(error: unknown): boolean {
240240
return /closed|reset|timed\s*out|disconnect/i.test(formatError(error));
241241
}
242242

extensions/whatsapp/src/reaction-level.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
22
import { resolveReactionLevel, type ResolvedReactionLevel } from "openclaw/plugin-sdk/text-runtime";
33
import { resolveMergedWhatsAppAccountConfig } from "./account-config.js";
44

5-
export type ResolvedWhatsAppReactionLevel = ResolvedReactionLevel;
5+
type ResolvedWhatsAppReactionLevel = ResolvedReactionLevel;
66

77
/** Resolve the effective reaction level and its implications for WhatsApp. */
88
export function resolveWhatsAppReactionLevel(params: {

extensions/whatsapp/src/shared.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import {
3838
isLegacyGroupSessionKey,
3939
} from "./session-contract.js";
4040

41-
export const WHATSAPP_CHANNEL = "whatsapp" as const;
41+
const WHATSAPP_CHANNEL = "whatsapp" as const;
4242

4343
const WHATSAPP_GROUP_SCOPE_FIELDS = ["groupPolicy", "groupAllowFrom", "groups"] as const;
4444

@@ -123,7 +123,7 @@ const whatsappResolveDmPolicy = createScopedDmSecurityResolver<ResolvedWhatsAppA
123123
inheritSharedDefaultsFromDefaultAccount: true,
124124
});
125125

126-
export function createWhatsAppSetupWizardProxy(
126+
function createWhatsAppSetupWizardProxy(
127127
loadWizard: () => Promise<ChannelSetupWizard>,
128128
): ChannelSetupWizard {
129129
return createDelegatedSetupWizardProxy({

0 commit comments

Comments
 (0)