/** * Type guards and coercion helpers shared by all bridge adapters. * * Adapters treat the bridge payload as `unknown` and validate field-by-field * here so a bridge schema drift (renamed field, lost serde rename_all, * timestamp serializer change) surfaces as `null` from one adapter instead * of a silent type lie that propagates downstream. */ /** * Plain-object guard. `typeof null === "object"` so we exclude it * explicitly; arrays return `true` here so callers must check * `Array.isArray` first if they need to distinguish. */ export declare const isObject: (x: unknown) => x is Record; /** Treat any non-string as missing rather than coercing (no `String(x)`). */ export declare const asString: (x: unknown) => string | undefined; /** Treat any non-number (including booleans, NaN) as missing. */ export declare const asNumber: (x: unknown) => number | undefined; /** Strict bool — does not coerce truthy values like `1` or `'true'`. */ export declare const asBool: (x: unknown) => boolean | undefined; /** Same as `asBool` but defaults to `false` for missing/invalid input. */ export declare const asBoolOr: (x: unknown, fallback: boolean) => boolean; /** * Bridge JID struct — `user@server`, plus optional `agent`/`device`/ * `integrator` for multi-device addressing. We always drop the latter when * stringifying so canonical JIDs are device-stripped (matching how Baileys * consumers index and compare). */ export interface BridgeJid { user: string; server: string; agent?: number; device?: number; integrator?: number; } /** Type guard for the bridge's `Jid` shape. Required fields only. */ export declare const isBridgeJid: (x: unknown) => x is BridgeJid; /** `null`-tolerant `BridgeJid` extractor — bridge payloads sometimes carry `null`. */ export declare const asBridgeJid: (x: unknown) => BridgeJid | undefined; /** Stringify a bridge JID into the canonical `user@server` form. Drops device/agent. */ export declare const bridgeJidToString: (j: BridgeJid) => string; /** Combined: validate & stringify in one step. Returns `undefined` on invalid input. */ export declare const asJidString: (x: unknown) => string | undefined; /** * Coerce a timestamp value into unix seconds. Accepts both numbers and ISO * strings — the bridge serializes `DateTime` as ISO unless explicitly * typed with `ts_seconds`, so being lenient here insulates us from drift. */ export declare const toUnixSeconds: (raw: unknown) => number; /** * Lowercase a discriminator string defensively — handles both the current * lowercase wire-tag form and any legacy PascalCase form an older bridge * might still emit. */ export declare const normalizeDiscriminator: (x: unknown) => string | undefined; //# sourceMappingURL=primitives.d.ts.map