refactor: trim whatsapp helper exports

This commit is contained in:
Peter Steinberger
2026-05-01 17:15:24 +01:00
parent d5736710a9
commit d647ba1c6f
10 changed files with 22 additions and 22 deletions

View File

@@ -21,7 +21,7 @@ export type GroupHistoryEntry = {
type ContextVisibilityMode = "all" | "allowlist" | "allowlist_quote";
export function isWhatsAppSupplementalSenderAllowed(params: {
function isWhatsAppSupplementalSenderAllowed(params: {
allowFrom: string[];
sender?: WhatsAppIdentity | null;
}): boolean {

View File

@@ -1,6 +1,6 @@
import type { ActiveWebListener } from "./inbound/types.js";
export type WhatsAppConnectionControllerHandle = {
type WhatsAppConnectionControllerHandle = {
getActiveListener(): ActiveWebListener | null;
};

View File

@@ -19,7 +19,7 @@ import type { WhatsAppSocketTimingOptions } from "./socket-timing.js";
const LOGGED_OUT_STATUS = DisconnectReason?.loggedOut ?? 401;
const WHATSAPP_LOGIN_RESTART_MESSAGE =
"WhatsApp asked for a restart after pairing (code 515); waiting for creds to save…";
export const WHATSAPP_LOGGED_OUT_RELINK_MESSAGE =
const WHATSAPP_LOGGED_OUT_RELINK_MESSAGE =
"WhatsApp reported the session is logged out. Cleared cached web session; please rerun openclaw channels login and scan the QR again.";
export const WHATSAPP_LOGGED_OUT_QR_MESSAGE =
"WhatsApp reported the session is logged out. Cleared cached web session; please scan a new QR.";
@@ -33,7 +33,7 @@ export type ManagedWhatsAppListener = ActiveWebListener & {
signalClose?: (reason?: WebListenerCloseReason) => void;
};
export type WhatsAppLiveConnection = {
type WhatsAppLiveConnection = {
connectionId: string;
startedAt: number;
sock: WASocket;
@@ -51,7 +51,7 @@ export type WhatsAppLiveConnection = {
resolveClose: (reason: WebListenerCloseReason) => void;
};
export type WhatsAppConnectionSnapshot = {
type WhatsAppConnectionSnapshot = {
connectionId: string;
startedAt: number;
lastInboundAt: number | null;
@@ -61,7 +61,7 @@ export type WhatsAppConnectionSnapshot = {
uptimeMs: number;
};
export type NormalizedConnectionCloseReason = {
type NormalizedConnectionCloseReason = {
statusCode?: number;
statusLabel: number | "unknown";
isLoggedOut: boolean;
@@ -69,7 +69,7 @@ export type NormalizedConnectionCloseReason = {
errorText: string;
};
export type WhatsAppConnectionCloseDecision = {
type WhatsAppConnectionCloseDecision = {
action: "stop" | "retry";
delayMs?: number;
reconnectAttempts: number;
@@ -77,7 +77,7 @@ export type WhatsAppConnectionCloseDecision = {
normalized: NormalizedConnectionCloseReason;
};
export type WhatsAppReconnectAttemptDecision = {
type WhatsAppReconnectAttemptDecision = {
action: "stop" | "retry";
delayMs?: number;
reconnectAttempts: number;
@@ -148,7 +148,7 @@ export function closeWaSocketSoon(
}, delayMs);
}
export type WhatsAppLoginWaitResult =
type WhatsAppLoginWaitResult =
| {
outcome: "connected";
restarted: boolean;

View File

@@ -1,4 +1,4 @@
export const WHATSAPP_GROUP_INTRO_HINT =
const WHATSAPP_GROUP_INTRO_HINT =
"WhatsApp IDs: SenderId is the participant JID (group participant id).";
export function resolveWhatsAppGroupIntroHint(): string {

View File

@@ -50,7 +50,7 @@ type LegacyMentionsLike = {
mentionedJids?: string[];
};
export function normalizeDeviceScopedJid(jid: string | null | undefined): string | null {
function normalizeDeviceScopedJid(jid: string | null | undefined): string | null {
return jid ? jid.replace(/:\d+/, "") : null;
}
@@ -148,7 +148,7 @@ export function getReplyContext(
};
}
export function getMentionJids(msg: LegacyMentionsLike): string[] {
function getMentionJids(msg: LegacyMentionsLike): string[] {
return msg.mentions ?? msg.mentionedJids ?? [];
}

View File

@@ -50,7 +50,7 @@ const RECONNECT_IN_PROGRESS_ERROR = "no active socket - reconnection in progress
const GROUP_META_TTL_MS = 5 * 60 * 1000; // 5 minutes
export const WHATSAPP_GROUP_METADATA_CACHE_MAX_ENTRIES = 500;
export type WhatsAppGroupMetadataCacheEntry = {
type WhatsAppGroupMetadataCacheEntry = {
subject?: string;
expires: number;
};
@@ -118,7 +118,7 @@ function isNonEmptyString(value: string | undefined): value is string {
return Boolean(value);
}
export type MonitorWebInboxOptions = {
type MonitorWebInboxOptions = {
cfg: OpenClawConfig;
verbose: boolean;
accountId: string;

View File

@@ -2,7 +2,7 @@ import type { WAMessage, WAMessageKey } from "@whiskeysockets/baileys";
export type WhatsAppSendKind = "media" | "poll" | "reaction" | "text";
export type WhatsAppSendKey = Omit<
type WhatsAppSendKey = Omit<
Pick<WAMessageKey, "fromMe" | "id" | "participant" | "remoteJid">,
"id"
> & {

View File

@@ -24,7 +24,7 @@ type WhatsAppLoadedMediaLike = {
fileName?: string;
};
export type NormalizedWhatsAppOutboundPayload<T extends WhatsAppOutboundPayloadLike> = Omit<
type NormalizedWhatsAppOutboundPayload<T extends WhatsAppOutboundPayloadLike> = Omit<
T,
"text" | "mediaUrl" | "mediaUrls"
> & {
@@ -40,7 +40,7 @@ export type DeliverableWhatsAppOutboundPayload<T extends WhatsAppOutboundPayload
text?: string;
};
export type CanonicalWhatsAppLoadedMedia = {
type CanonicalWhatsAppLoadedMedia = {
buffer: Buffer;
kind: "image" | "audio" | "video" | "document";
mimetype: string;
@@ -109,7 +109,7 @@ export function normalizeWhatsAppOutboundPayload<T extends WhatsAppOutboundPaylo
};
}
export function normalizeWhatsAppLoadedMedia(
function normalizeWhatsAppLoadedMedia(
media: WhatsAppLoadedMediaLike,
mediaUrl?: string,
): CanonicalWhatsAppLoadedMedia {
@@ -236,7 +236,7 @@ function deriveWhatsAppDocumentFileName(mediaUrl: string | undefined): string |
}
}
export function isRetryableWhatsAppOutboundError(error: unknown): boolean {
function isRetryableWhatsAppOutboundError(error: unknown): boolean {
return /closed|reset|timed\s*out|disconnect/i.test(formatError(error));
}

View File

@@ -2,7 +2,7 @@ import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
import { resolveReactionLevel, type ResolvedReactionLevel } from "openclaw/plugin-sdk/text-runtime";
import { resolveMergedWhatsAppAccountConfig } from "./account-config.js";
export type ResolvedWhatsAppReactionLevel = ResolvedReactionLevel;
type ResolvedWhatsAppReactionLevel = ResolvedReactionLevel;
/** Resolve the effective reaction level and its implications for WhatsApp. */
export function resolveWhatsAppReactionLevel(params: {

View File

@@ -38,7 +38,7 @@ import {
isLegacyGroupSessionKey,
} from "./session-contract.js";
export const WHATSAPP_CHANNEL = "whatsapp" as const;
const WHATSAPP_CHANNEL = "whatsapp" as const;
const WHATSAPP_GROUP_SCOPE_FIELDS = ["groupPolicy", "groupAllowFrom", "groups"] as const;
@@ -123,7 +123,7 @@ const whatsappResolveDmPolicy = createScopedDmSecurityResolver<ResolvedWhatsAppA
inheritSharedDefaultsFromDefaultAccount: true,
});
export function createWhatsAppSetupWizardProxy(
function createWhatsAppSetupWizardProxy(
loadWizard: () => Promise<ChannelSetupWizard>,
): ChannelSetupWizard {
return createDelegatedSetupWizardProxy({