fix: Corregir imports de Baileys para ESM/CJS
Some checks failed
build-and-deploy / build-and-deploy (push) Has been cancelled

This commit is contained in:
2025-12-02 19:15:08 -06:00
parent a0b1502bb1
commit 767b0800a8
2 changed files with 15 additions and 10 deletions

View File

@@ -3,10 +3,14 @@
* Stores credentials and keys in the database instead of files * Stores credentials and keys in the database instead of files
*/ */
import type { AuthenticationCreds, SignalDataTypeMap } from '@whiskeysockets/baileys' import type { AuthenticationCreds, SignalDataTypeMap } from '@whiskeysockets/baileys'
import pkg from '@whiskeysockets/baileys' import * as baileys from '@whiskeysockets/baileys'
const { initAuthCreds, BufferJSON, proto } = pkg
import { query } from '../../utils/database' import { query } from '../../utils/database'
// Get functions from baileys module
const initAuthCreds = (baileys as any).initAuthCreds || (baileys as any).default?.initAuthCreds
const BufferJSON = (baileys as any).BufferJSON || (baileys as any).default?.BufferJSON
const proto = (baileys as any).proto || (baileys as any).default?.proto
export interface PostgresAuthState { export interface PostgresAuthState {
state: { state: {
creds: AuthenticationCreds creds: AuthenticationCreds

View File

@@ -3,14 +3,15 @@
* Singleton pattern for managing all Baileys connections * Singleton pattern for managing all Baileys connections
*/ */
import type { WASocket, BaileysEventMap } from '@whiskeysockets/baileys' import type { WASocket, BaileysEventMap } from '@whiskeysockets/baileys'
import pkg from '@whiskeysockets/baileys' import * as baileys from '@whiskeysockets/baileys'
const {
default: makeWASocket, // Get functions from baileys module (handle both ESM and CJS)
DisconnectReason, const makeWASocket = (baileys as any).default || (baileys as any).makeWASocket
fetchLatestBaileysVersion, const DisconnectReason = (baileys as any).DisconnectReason || (baileys as any).default?.DisconnectReason
makeCacheableSignalKeyStore, const fetchLatestBaileysVersion = (baileys as any).fetchLatestBaileysVersion || (baileys as any).default?.fetchLatestBaileysVersion
Browsers const makeCacheableSignalKeyStore = (baileys as any).makeCacheableSignalKeyStore || (baileys as any).default?.makeCacheableSignalKeyStore
} = pkg const Browsers = (baileys as any).Browsers || (baileys as any).default?.Browsers
import { Boom } from '@hapi/boom' import { Boom } from '@hapi/boom'
import { EventEmitter } from 'events' import { EventEmitter } from 'events'
import QRCode from 'qrcode' import QRCode from 'qrcode'