@bot-whatsapp/bot
Advanced tools
Comparing version 0.0.204-alpha.0 to 0.0.205-alpha.0
@@ -236,4 +236,5 @@ const { EventEmitter } = require('node:events') | ||
// Usar async en la función pasada a enqueue | ||
await this.sendProviderAndSave(numberOrId, ctxMessage) | ||
.then(() => resolveCbEveryCtx(ctxMessage)) | ||
await this.sendProviderAndSave(numberOrId, ctxMessage).then(() => | ||
resolveCbEveryCtx(ctxMessage) | ||
) | ||
logger.log(`[QUEUE_SE_ENVIO]: `, ctxMessage) | ||
@@ -246,3 +247,3 @@ // await resolveCbEveryCtx(ctxMessage) | ||
logger.error(`Error al encolar (ID ${ctxMessage.ref}):`, error) | ||
return Promise.reject | ||
return Promise.reject() | ||
// Puedes considerar manejar el error aquí o rechazar la promesa | ||
@@ -297,11 +298,9 @@ // Pasada a resolveCbEveryCtx con el error correspondiente. | ||
if(!flowInstance?.toJson){ | ||
printer( | ||
[ | ||
`[CIRCULAR_DEPENDENCY]: Se ha detectado una dependencia circular.`, | ||
`Para evitar problemas, te recomendamos utilizar 'require'('./ruta_del_flow')`, | ||
`Ejemplo: gotoFlow(helloFlow) --> gotoFlow(require('./flows/helloFlow.js'))`, | ||
`[INFO]: https://bot-whatsapp.netlify.app/docs/goto-flow/` | ||
] | ||
); | ||
if (!flowInstance?.toJson) { | ||
printer([ | ||
`[CIRCULAR_DEPENDENCY]: Se ha detectado una dependencia circular.`, | ||
`Para evitar problemas, te recomendamos utilizar 'require'('./ruta_del_flow')`, | ||
`Ejemplo: gotoFlow(helloFlow) --> gotoFlow(require('./flows/helloFlow.js'))`, | ||
`[INFO]: https://bot-whatsapp.netlify.app/docs/goto-flow/`, | ||
]) | ||
return | ||
@@ -308,0 +307,0 @@ } |
@@ -0,0 +0,0 @@ const { generateRef } = require('../../utils/hash') |
@@ -0,0 +0,0 @@ const { generateRef } = require('../../utils/hash') |
@@ -0,0 +0,0 @@ const { generateRef } = require('../../utils/hash') |
@@ -0,0 +0,0 @@ const { generateRef } = require('../../utils/hash') |
@@ -0,0 +0,0 @@ const { generateRef } = require('../../utils/hash') |
@@ -0,0 +0,0 @@ const { generateRef } = require('../../utils/hash') |
@@ -0,0 +0,0 @@ const { generateRef } = require('../../utils/hash') |
@@ -0,0 +0,0 @@ const { generateRef } = require('../../utils/hash') |
@@ -0,0 +0,0 @@ const { eventDocument, REGEX_EVENT_DOCUMENT } = require('./eventDocument') |
const { toSerialize } = require('./methods/toSerialize') | ||
const { flatObject } = require('../utils/flattener') | ||
/** | ||
* Esta clas se encarga de manera la manipulacion de los flows | ||
* y la creaciones de indices donde almacenar los callbacks | ||
*/ | ||
class FlowClass { | ||
@@ -8,5 +12,6 @@ allCallbacks = [] | ||
flowRaw = [] | ||
constructor(_flow) { | ||
if (!Array.isArray(_flow)) throw new Error('Esto debe ser un ARRAY') | ||
this.flowRaw = _flow | ||
this.flowRaw = this.addEndsFlows(_flow) | ||
@@ -22,2 +27,24 @@ this.allCallbacks = flatObject(_flow) | ||
/** | ||
* Agregamos un addAcion con un endFlow | ||
* al finalizar el flow para limpiar rendimiento, colas, etc | ||
* @param {*} _flows | ||
* @returns | ||
*/ | ||
addEndsFlows = (_flows) => { | ||
return _flows.map((flow) => | ||
flow.addAction(async (_, { endFlow }) => { | ||
return endFlow() | ||
}) | ||
) | ||
} | ||
/** | ||
* Funcion principal encargada de devolver un array de mensajes a continuar | ||
* la idea es basado en un ref o id devolver la lista de mensaes a enviar | ||
* @param {*} keyOrWord | ||
* @param {*} symbol | ||
* @param {*} overFlow | ||
* @returns | ||
*/ | ||
find = (keyOrWord, symbol = false, overFlow = null) => { | ||
@@ -88,2 +115,7 @@ keyOrWord = `${keyOrWord}` | ||
/** | ||
* El proposito es cargar los flows y la serializacion de los callbacks | ||
* a los flows qu son hijos | ||
* @returns | ||
*/ | ||
getFlowsChild = () => { | ||
@@ -90,0 +122,0 @@ try { |
const addAction = () => async () => {} | ||
module.exports = { addAction } |
@@ -0,0 +0,0 @@ MIT License |
{ | ||
"name": "@bot-whatsapp/bot", | ||
"version": "0.0.204-alpha.0", | ||
"version": "0.0.205-alpha.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./lib/bundle.bot.cjs", |
@@ -0,0 +0,0 @@ const { EventEmitter } = require('node:events') |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
152507
3950