From 170fcaf59d7e623dec8cabb3235b1ff0cead8536 Mon Sep 17 00:00:00 2001 From: Leifer Mendez Date: Mon, 27 Nov 2023 10:38:56 +0100 Subject: [PATCH 01/16] build: :zap: improved --- __test__/0.0.2-goto-flow.test.js | 2 +- ...1.5-case.test.js => 0.1.5-endflow.test.js} | 68 +++++++++++++++++++ __test__/0.2.0-case.test.js | 2 + packages/bot/core/core.class.js | 40 +++++++---- packages/bot/io/flow.class.js | 3 +- packages/bot/package.json | 2 +- starters/apps/base-baileys-json/package.json | 1 + .../apps/base-baileys-memory/package.json | 2 +- 8 files changed, 102 insertions(+), 18 deletions(-) rename __test__/{0.1.5-case.test.js => 0.1.5-endflow.test.js} (66%) diff --git a/__test__/0.0.2-goto-flow.test.js b/__test__/0.0.2-goto-flow.test.js index c1875dd01..872373b48 100644 --- a/__test__/0.0.2-goto-flow.test.js +++ b/__test__/0.0.2-goto-flow.test.js @@ -235,7 +235,7 @@ testSuite(`Debe de continuar el el encadenamiento con procesos async`, async ({ assert.is('datos de json', history[3]) assert.is('Digame su *Nombre y apellidos* para reservar su mesa...', history[4]) assert.is('leifer', history[5]) - assert.is(undefined, history[96]) + assert.is(undefined, history[6]) }) //Issue https://github.com/codigoencasa/bot-whatsapp/issues/877 diff --git a/__test__/0.1.5-case.test.js b/__test__/0.1.5-endflow.test.js similarity index 66% rename from __test__/0.1.5-case.test.js rename to __test__/0.1.5-endflow.test.js index 254cf5ac5..63b46c982 100644 --- a/__test__/0.1.5-case.test.js +++ b/__test__/0.1.5-endflow.test.js @@ -2,6 +2,7 @@ const { suite } = require('uvu') const assert = require('uvu/assert') const { addKeyword, createBot, createFlow } = require('../packages/bot/index') const { setup, clear, delay } = require('../__mocks__/env') +const { EVENTS } = require('../packages/bot/lib/bundle.bot.cjs') const fakeHTTP = async (fakeData = []) => { await delay(50) @@ -164,4 +165,71 @@ suiteCase(`flowDynamic con capture`, async ({ database, provider }) => { assert.is('Puedes pasar', getHistory[11]) }) +suiteCase(`endFlow desde gotoFlow`, async ({ database, provider }) => { + const flow = addKeyword(['hola']) + .addAnswer('Buenas!', null, async (_, { gotoFlow }) => { + return gotoFlow(flowUsuario) + }) + .addAnswer('no debe llegar') + + const flowUsuario = addKeyword(EVENTS.ACTION) + .addAction({ ref: `1111111111111111` }, async (_, { flowDynamic, endFlow }) => { + try { + const confirmar = { + data: { + estado: '3', + }, + } + if (confirmar === 500) { + return gotoFlow(serverError) + } + if (confirmar.data.estado === '3') { + return endFlow(`Final y no mas`) + } + + if (confirmar.data) { + await flowDynamic('ya estas! debe finalizar flow no debe enviar mas mensajes') + return endFlow() + } + } catch (error) { + console.error(error) + } + await flowDynamic('⏳ por favor solo espere a que el asistente responda 🍀🤖...') + }) + .addAction({ ref: `22222222222` }, async (_, { flowDynamic }) => { + await flowDynamic('ping pong') + console.log(`🌟🌟🌟🌟`) + }) + + await createBot({ + database, + provider, + flow: createFlow([flow, flowUsuario]), + }) + + await provider.delaySendMessage(100, 'message', { + from: '000', + body: 'hola', + }) + + await delay(5000) + const getHistory = database.listHistory.map((i) => i.answer) + assert.is('Buenas!', getHistory[0]) + assert.is('__capture_only_intended__', getHistory[1]) + assert.is('__capture_only_intended__', getHistory[2]) + assert.is('Final y no mas', getHistory[3]) + assert.is(undefined, getHistory[4]) + // assert.is('this is not email value', getHistory[1]) + // assert.is(MOCK_VALUES[0], getHistory[2]) + // assert.is('test@test.com', getHistory[3]) + // assert.is('Gracias por tu email se ha validado de manera correcta', getHistory[4]) + // assert.is(MOCK_VALUES[1], getHistory[5]) + // assert.is(MOCK_VALUES[2], getHistory[6]) + // assert.is('20', getHistory[7]) + // assert.is('Ups creo que no eres mayor de edad', getHistory[8]) + // assert.is('18', getHistory[9]) + // assert.is('Bien tu edad es correcta!', getHistory[10]) + // assert.is('Puedes pasar', getHistory[11]) +}) + suiteCase.run() diff --git a/__test__/0.2.0-case.test.js b/__test__/0.2.0-case.test.js index 4b503e9a3..7c78ce4e7 100644 --- a/__test__/0.2.0-case.test.js +++ b/__test__/0.2.0-case.test.js @@ -94,11 +94,13 @@ suiteCase(`Encadenanos addAction con captures and gotoFlow`, async ({ database, const flujoTercero = addKeyword(['ordenar']) .addAction({ ref: `00000000000000000000000` }, async (ctx, { flowDynamic, state }) => { + console.log(`🔴🔴🔴🔴`) await flowDynamic(`Gracias por el interes`) }) .addAction({ ref: `1111111111111111111` }, async (ctx, { flowDynamic }) => { await flowDynamic(`Chao!`) }) + await createBot({ database, flow: createFlow([flujoPrincipal, flujoSegundario, flujoTercero]), diff --git a/packages/bot/core/core.class.js b/packages/bot/core/core.class.js index 8cf266cdc..cabdcdd4b 100644 --- a/packages/bot/core/core.class.js +++ b/packages/bot/core/core.class.js @@ -174,21 +174,33 @@ class CoreClass extends EventEmitter { // 📄 Finalizar flujo const endFlow = (flag) => - async (messages = null) => { + async (messages = null, options = { fromGotoFlow: false, end: false }) => { flag.endFlow = true endFlowFlag = true - if (typeof messages === 'string') { + + if (typeof messages === 'string' || messages === null) { await this.sendProviderAndSave(from, createCtxMessage(messages)) + clearQueue() + return } // Procesos de callback que se deben execute como exepciones if (Array.isArray(messages)) { + // console.log('options.fromGotoFlow', messages) + + // const indexLimit = messages.findIndex((m) => m.ref === inRef) for (const iteratorCtxMessage of messages) { - await resolveCbEveryCtx(iteratorCtxMessage, { - omitEndFlow: true, + // console.log(`Counter ${indexLimit}`) + // if(indexLimit !== -1 && counterFor === indexLimit) break + const scopeCtx = await resolveCbEveryCtx(iteratorCtxMessage, { + omitEndFlow: options.fromGotoFlow, idleCtx: !!iteratorCtxMessage?.options?.idle, triggerKey: iteratorCtxMessage.keyword.startsWith('key_'), }) + + if (scopeCtx?.endFlow) break + + // options.fromGotoFlow = false } } clearQueue() @@ -315,13 +327,10 @@ class CoreClass extends EventEmitter { const msgParse = this.flowClass.findSerializeByRef(msg?.ref) const ctxMessage = { ...msgParse, ...msg } - - // Enviar el mensaje al proveedor y guardarlo await this.sendProviderAndSave(from, ctxMessage).then(() => promises.push(ctxMessage)) } - await endFlow(flag)(promises) - + await endFlow(flag)(promises, { fromGotoFlow: true, ...{ end: endFlowFlag } }) return } @@ -377,13 +386,16 @@ class CoreClass extends EventEmitter { `[ATENCION IDLE]: La función "idle" no tendrá efecto a menos que habilites la opción "capture:true". Por favor, asegúrate de configurar "capture:true" o elimina la función "idle"` ) } + + // if(endFlowFlag) return + if (ctxMessage?.options?.idle) { - await cbEveryCtx(ctxMessage?.ref, { ...options, startIdleMs: ctxMessage?.options?.idle }) - return + const run = await cbEveryCtx(ctxMessage?.ref, { ...options, startIdleMs: ctxMessage?.options?.idle }) + return run } if (!ctxMessage?.options?.capture) { - await cbEveryCtx(ctxMessage?.ref, options) - return + const run = await cbEveryCtx(ctxMessage?.ref, options) + return run } } @@ -414,7 +426,7 @@ class CoreClass extends EventEmitter { inRef, fallBack: fallBack(flags), flowDynamic: flowDynamic(flags, inRef, options), - endFlow: endFlow(flags), + endFlow: endFlow(flags, inRef), gotoFlow: gotoFlow(flags), } @@ -452,7 +464,7 @@ class CoreClass extends EventEmitter { } await runContext() - return + return { ...flags } } const exportFunctionsSend = async (cb = () => Promise.resolve()) => { diff --git a/packages/bot/io/flow.class.js b/packages/bot/io/flow.class.js index 7c06f894a..300335700 100644 --- a/packages/bot/io/flow.class.js +++ b/packages/bot/io/flow.class.js @@ -12,7 +12,8 @@ class FlowClass { constructor(_flow) { if (!Array.isArray(_flow)) throw new Error('Esto debe ser un ARRAY') - this.flowRaw = this.addEndsFlows(_flow) + // this.flowRaw = this.addEndsFlows(_flow) + this.flowRaw = _flow this.allCallbacks = flatObject(_flow) diff --git a/packages/bot/package.json b/packages/bot/package.json index 83aadf683..a42c304a8 100644 --- a/packages/bot/package.json +++ b/packages/bot/package.json @@ -1,6 +1,6 @@ { "name": "@bot-whatsapp/bot", - "version": "0.0.204-alpha.0", + "version": "0.0.216-alpha.0", "description": "", "main": "./lib/bundle.bot.cjs", "scripts": { diff --git a/starters/apps/base-baileys-json/package.json b/starters/apps/base-baileys-json/package.json index 074773848..ad97cbf92 100644 --- a/starters/apps/base-baileys-json/package.json +++ b/starters/apps/base-baileys-json/package.json @@ -4,6 +4,7 @@ "description": "", "main": "app.js", "scripts": { + "prestart": "npx eslint . --no-ignore", "pre-copy": "cd .. && npm run copy.lib base-baileys-json", "start": "node app.js" }, diff --git a/starters/apps/base-baileys-memory/package.json b/starters/apps/base-baileys-memory/package.json index d6294069d..5ba9af094 100644 --- a/starters/apps/base-baileys-memory/package.json +++ b/starters/apps/base-baileys-memory/package.json @@ -4,7 +4,7 @@ "description": "", "main": "app.js", "scripts": { - "prestart": "npx eslint .", + "prestart": "npx eslint . --no-ignore", "pre-copy": "cd .. && npm run copy.lib base-baileys-memory", "start": "node app.js" }, From 9ba11f97475aefc55660f38f4870027b3314172b Mon Sep 17 00:00:00 2001 From: Leifer Mendez Date: Mon, 27 Nov 2023 10:40:37 +0100 Subject: [PATCH 02/16] build: :zap: improved --- __test__/0.2.0-case.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/__test__/0.2.0-case.test.js b/__test__/0.2.0-case.test.js index 7c78ce4e7..de7b061ae 100644 --- a/__test__/0.2.0-case.test.js +++ b/__test__/0.2.0-case.test.js @@ -94,7 +94,6 @@ suiteCase(`Encadenanos addAction con captures and gotoFlow`, async ({ database, const flujoTercero = addKeyword(['ordenar']) .addAction({ ref: `00000000000000000000000` }, async (ctx, { flowDynamic, state }) => { - console.log(`🔴🔴🔴🔴`) await flowDynamic(`Gracias por el interes`) }) .addAction({ ref: `1111111111111111111` }, async (ctx, { flowDynamic }) => { From 99dba8547024158ebaca76bb3d42b99dbbbc9897 Mon Sep 17 00:00:00 2001 From: Leifer Mendez Date: Sat, 30 Dec 2023 13:43:28 +0100 Subject: [PATCH 03/16] fix: release alpha --- packages/bot/core/core.class.js | 34 ++++++++++++++++----------------- packages/bot/package.json | 2 +- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/packages/bot/core/core.class.js b/packages/bot/core/core.class.js index cabdcdd4b..ccbe54fa4 100644 --- a/packages/bot/core/core.class.js +++ b/packages/bot/core/core.class.js @@ -174,33 +174,29 @@ class CoreClass extends EventEmitter { // 📄 Finalizar flujo const endFlow = (flag) => - async (messages = null, options = { fromGotoFlow: false, end: false }) => { + async (message = null) => { flag.endFlow = true endFlowFlag = true + if (message) this.sendProviderAndSave(from, createCtxMessage(message)) + clearQueue() + return + } - if (typeof messages === 'string' || messages === null) { - await this.sendProviderAndSave(from, createCtxMessage(messages)) - clearQueue() - return - } + // 📄 Finalizar flujo (patch) + const endFlowToGotoFlow = + (flag) => + async (messages = null, options = { fromGotoFlow: false, end: false }) => { + flag.endFlow = true + endFlowFlag = true - // Procesos de callback que se deben execute como exepciones if (Array.isArray(messages)) { - // console.log('options.fromGotoFlow', messages) - - // const indexLimit = messages.findIndex((m) => m.ref === inRef) for (const iteratorCtxMessage of messages) { - // console.log(`Counter ${indexLimit}`) - // if(indexLimit !== -1 && counterFor === indexLimit) break const scopeCtx = await resolveCbEveryCtx(iteratorCtxMessage, { omitEndFlow: options.fromGotoFlow, idleCtx: !!iteratorCtxMessage?.options?.idle, triggerKey: iteratorCtxMessage.keyword.startsWith('key_'), }) - if (scopeCtx?.endFlow) break - - // options.fromGotoFlow = false } } clearQueue() @@ -211,7 +207,7 @@ class CoreClass extends EventEmitter { const sendFlow = async (messageToSend, numberOrId, options = {}) => { options = { prev: prevMsg, forceQueue: false, ...options } - if (options.prev?.options?.capture) { + if (options.prev?.options?.capture && !options.prev?.options?.idle) { await cbEveryCtx(options.prev?.ref) } @@ -330,7 +326,7 @@ class CoreClass extends EventEmitter { await this.sendProviderAndSave(from, ctxMessage).then(() => promises.push(ctxMessage)) } - await endFlow(flag)(promises, { fromGotoFlow: true, ...{ end: endFlowFlag } }) + await endFlowToGotoFlow(flag)(promises, { fromGotoFlow: true, ...{ end: endFlowFlag } }) return } @@ -385,9 +381,11 @@ class CoreClass extends EventEmitter { printer( `[ATENCION IDLE]: La función "idle" no tendrá efecto a menos que habilites la opción "capture:true". Por favor, asegúrate de configurar "capture:true" o elimina la función "idle"` ) + return } - // if(endFlowFlag) return + // const endFlowState = state.getMyState() && state.get('__end_flow__') + // if(endFlowState) return if (ctxMessage?.options?.idle) { const run = await cbEveryCtx(ctxMessage?.ref, { ...options, startIdleMs: ctxMessage?.options?.idle }) diff --git a/packages/bot/package.json b/packages/bot/package.json index a42c304a8..9a241685d 100644 --- a/packages/bot/package.json +++ b/packages/bot/package.json @@ -1,6 +1,6 @@ { "name": "@bot-whatsapp/bot", - "version": "0.0.216-alpha.0", + "version": "0.0.223-alpha.0", "description": "", "main": "./lib/bundle.bot.cjs", "scripts": { From be079123587a50f490fd7b8addbd48bb528dfb6d Mon Sep 17 00:00:00 2001 From: Leifer Mendez Date: Sat, 30 Dec 2023 19:33:15 +0100 Subject: [PATCH 04/16] fix: some fix --- __test__/0.2.1-case.test.js | 6 +++--- packages/provider/common/download.js | 6 +++--- packages/provider/package.json | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/__test__/0.2.1-case.test.js b/__test__/0.2.1-case.test.js index ee461ab5e..d805d075f 100644 --- a/__test__/0.2.1-case.test.js +++ b/__test__/0.2.1-case.test.js @@ -8,7 +8,7 @@ const suiteCase = suite('Flujo: idle state') suiteCase.before.each(setup) suiteCase.after.each(clear) -suiteCase(`Prevenir enviar mensaje luego de inactividad (2seg)`, async ({ database, provider }) => { +suiteCase.skip(`Prevenir enviar mensaje luego de inactividad (2seg)`, async ({ database, provider }) => { const flujoFinal = addKeyword(EVENTS.ACTION).addAnswer('Se cancelo por inactividad') const flujoPrincipal = addKeyword(['hola']) @@ -47,7 +47,7 @@ suiteCase(`Prevenir enviar mensaje luego de inactividad (2seg)`, async ({ databa assert.is(undefined, getHistory[3]) }) -suiteCase(`Enviar mensaje luego de inactividad (2seg)`, async ({ database, provider }) => { +suiteCase.skip(`Enviar mensaje luego de inactividad (2seg)`, async ({ database, provider }) => { const flujoFinal = addKeyword(EVENTS.ACTION).addAnswer('Se cancelo por inactividad') const flujoPrincipal = addKeyword(['hola']) @@ -80,7 +80,7 @@ suiteCase(`Enviar mensaje luego de inactividad (2seg)`, async ({ database, provi assert.is(undefined, getHistory[2]) }) -suiteCase(`Enviar mensajes con ambos casos de idle`, async ({ database, provider }) => { +suiteCase.skip(`Enviar mensajes con ambos casos de idle`, async ({ database, provider }) => { const flujoFinal = addKeyword(EVENTS.ACTION) .addAnswer('Se cancelo por inactividad') .addAction(async (_, { flowDynamic }) => { diff --git a/packages/provider/common/download.js b/packages/provider/common/download.js index 4b156c806..339f7c816 100644 --- a/packages/provider/common/download.js +++ b/packages/provider/common/download.js @@ -3,7 +3,7 @@ const { tmpdir } = require('os') const http = require('follow-redirects').http const https = require('follow-redirects').https const { rename, createWriteStream, existsSync } = require('fs') -const { extname } = require('path') +const { extname, basename, parse } = require('path') /** * Extrar el mimetype from buffer @@ -30,8 +30,8 @@ const generalDownload = async (url) => { const handleDownload = () => { const checkProtocol = url.includes('https:') const handleHttp = checkProtocol ? https : http - - const name = `tmp-${Date.now()}-dat` + const fileName = basename(new URL(url).pathname) + const name = parse(fileName).name const fullPath = `${tmpdir()}/${name}` const file = createWriteStream(fullPath) diff --git a/packages/provider/package.json b/packages/provider/package.json index 988374f99..716c40c8e 100644 --- a/packages/provider/package.json +++ b/packages/provider/package.json @@ -1,6 +1,6 @@ { "name": "@bot-whatsapp/provider", - "version": "0.0.142-alpha.0", + "version": "0.0.156-alpha.0", "description": "Esto es el conector a Twilio, Meta, etc...", "main": "./lib/mock/index.cjs", "keywords": [], From f8ff35e401510e1614e6d6753b7ad42f5114fc16 Mon Sep 17 00:00:00 2001 From: Leifer Mendez Date: Thu, 4 Jan 2024 17:55:09 +0100 Subject: [PATCH 05/16] fix: crypto url --- packages/provider/common/hash.js | 36 +++++++++++++++++++++++++- packages/provider/src/twilio/index.js | 4 ++- packages/provider/src/twilio/server.js | 4 ++- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/packages/provider/common/hash.js b/packages/provider/common/hash.js index e9c74b8e1..4bdfc0461 100644 --- a/packages/provider/common/hash.js +++ b/packages/provider/common/hash.js @@ -1,5 +1,14 @@ const crypto = require('crypto') +const SALT_KEY = `sal-key-${Date.now()}` +const SALT_IV = `sal-iv-${Date.now()}` + +const METHOD = 'aes-256-cbc' + +const key = crypto.createHash('sha512').update(SALT_KEY).digest('hex').substring(0, 32) + +const encryptionIV = crypto.createHash('sha512').update(SALT_IV).digest('hex').substring(0, 16) + /** * Generamos un UUID unico con posibilidad de tener un prefijo * @param {*} prefix @@ -10,4 +19,29 @@ const generateRefprovider = (prefix = false) => { return prefix ? `${prefix}_${id}` : id } -module.exports = { generateRefprovider } +/** + * Encriptar data + * @param {*} data + * @returns + */ +const encryptData = (data) => { + const cipher = crypto.createCipheriv(METHOD, key, encryptionIV) + return Buffer.from(cipher.update(data, 'utf8', 'hex') + cipher.final('hex')).toString('base64') +} + +/** + * Desencriptar data + * @param {*} encryptedData + * @returns + */ +const decryptData = (encryptedData) => { + try { + const buff = Buffer.from(encryptedData, 'base64') + const decipher = crypto.createDecipheriv(METHOD, key, encryptionIV) + return decipher.update(buff.toString('utf8'), 'hex', 'utf8') + decipher.final('utf8') + } catch (e) { + return 'FAIL' + } +} + +module.exports = { generateRefprovider, encryptData, decryptData } diff --git a/packages/provider/src/twilio/index.js b/packages/provider/src/twilio/index.js index b7c5940b9..5a3f27437 100644 --- a/packages/provider/src/twilio/index.js +++ b/packages/provider/src/twilio/index.js @@ -3,6 +3,7 @@ const { ProviderClass } = require('@bot-whatsapp/bot') const TwilioWebHookServer = require('./server') const { parseNumber } = require('./utils') +const { encryptData } = require('../../common/hash') /** * ⚙️TwilioProvider: Es un provedor que te ofrece enviar @@ -68,7 +69,8 @@ class TwilioProvider extends ProviderClass { */ sendMedia = async (number, message, mediaInput = null) => { if (!mediaInput) throw new Error(`MEDIA_INPUT_NULL_: ${mediaInput}`) - const urlEncode = `${this.publicUrl}/tmp?path=${encodeURIComponent(mediaInput)}` + const ecrypPath = encryptData(encodeURIComponent(mediaInput)) + const urlEncode = `${this.publicUrl}/tmp?path=${ecrypPath}` const regexUrl = /^(?!https?:\/\/)[^\s]+$/ const urlNotice = [ diff --git a/packages/provider/src/twilio/server.js b/packages/provider/src/twilio/server.js index 5906dafda..2001f303b 100644 --- a/packages/provider/src/twilio/server.js +++ b/packages/provider/src/twilio/server.js @@ -4,6 +4,7 @@ const mime = require('mime-types') const polka = require('polka') const { urlencoded, json } = require('body-parser') const { parseNumber } = require('./utils') +const { decryptData } = require('../../common/hash') /** * Encargado de levantar un servidor HTTP con una hook url @@ -47,7 +48,8 @@ class TwilioWebHookServer extends EventEmitter { const { query } = req const file = query?.path if (!file) return res.end(`path: invalid`) - const decodeFile = decodeURIComponent(file) + const descryptPath = decryptData(file) + const decodeFile = decodeURIComponent(descryptPath) if (!existsSync(decodeFile)) return res.end(`not exits: ${decodeFile}`) const fileStream = createReadStream(decodeFile) const mimeType = mime.lookup(decodeFile) From c3b273843afa0141e78e662fe1534f83287bc6e6 Mon Sep 17 00:00:00 2001 From: yond1994 Date: Thu, 4 Jan 2024 20:32:20 +0100 Subject: [PATCH 06/16] fix: "provider twilio media & document " --- packages/provider/package.json | 2 +- packages/provider/src/meta/server.js | 2 +- packages/provider/src/twilio/server.js | 35 ++++++++++++++++++++++++-- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/packages/provider/package.json b/packages/provider/package.json index 988374f99..336a73926 100644 --- a/packages/provider/package.json +++ b/packages/provider/package.json @@ -1,6 +1,6 @@ { "name": "@bot-whatsapp/provider", - "version": "0.0.142-alpha.0", + "version": "0.0.161-alpha.0", "description": "Esto es el conector a Twilio, Meta, etc...", "main": "./lib/mock/index.cjs", "keywords": [], diff --git a/packages/provider/src/meta/server.js b/packages/provider/src/meta/server.js index 2502da3cf..6e03dfff7 100644 --- a/packages/provider/src/meta/server.js +++ b/packages/provider/src/meta/server.js @@ -141,7 +141,7 @@ class MetaWebHookServer extends EventEmitter { from: message.from, url: audioUrl, to, - body: generateRefprovider('_event_audio_'), + body: generateRefprovider('_event_voice_note_'), pushName, } break diff --git a/packages/provider/src/twilio/server.js b/packages/provider/src/twilio/server.js index 5906dafda..9181f47ea 100644 --- a/packages/provider/src/twilio/server.js +++ b/packages/provider/src/twilio/server.js @@ -4,6 +4,7 @@ const mime = require('mime-types') const polka = require('polka') const { urlencoded, json } = require('body-parser') const { parseNumber } = require('./utils') +const { generateRefprovider } = require('../../common/hash') /** * Encargado de levantar un servidor HTTP con una hook url @@ -26,12 +27,42 @@ class TwilioWebHookServer extends EventEmitter { */ incomingMsg = (req, res) => { const { body } = req - this.emit('message', { + const payload = { ...body, from: parseNumber(body.From), to: parseNumber(body.To), body: body.Body, - }) + } + if (body.NumMedia !== '0' && body.MediaContentType0) { + const type = body.MediaContentType0.split('/')[0] + switch (type) { + case 'audio': { + payload.body = generateRefprovider('_event_voice_note_') + break + } + case 'image': + case 'video': { + payload.body = generateRefprovider('_event_media_') + break + } + case 'application': { + payload.body = generateRefprovider('_event_document_') + break + } + case 'text': { + payload.body = generateRefprovider('_event_contacts_') + break + } + default: + // Lógica para manejar tipos de mensajes no reconocidos + break + } + } else { + if (body.Latitude && body.Longitude) { + payload.body = generateRefprovider('_event_location_') + } + } + this.emit('message', payload) const json = JSON.stringify({ body }) res.end(json) } From d9ff81c539e2786fe1210bbd24f2c1da12d90058 Mon Sep 17 00:00:00 2001 From: Leifer Mendez Date: Thu, 4 Jan 2024 20:43:17 +0100 Subject: [PATCH 07/16] fix: fix twilio --- __test__/0.2.1-case.test.js | 11 ++++++----- package.json | 2 +- packages/bot/context/idleState.class.js | 2 +- packages/bot/core/core.class.js | 7 ++++++- packages/provider/package.json | 2 +- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/__test__/0.2.1-case.test.js b/__test__/0.2.1-case.test.js index d805d075f..04e56d3f8 100644 --- a/__test__/0.2.1-case.test.js +++ b/__test__/0.2.1-case.test.js @@ -8,20 +8,21 @@ const suiteCase = suite('Flujo: idle state') suiteCase.before.each(setup) suiteCase.after.each(clear) -suiteCase.skip(`Prevenir enviar mensaje luego de inactividad (2seg)`, async ({ database, provider }) => { +suiteCase(`Prevenir enviar mensaje luego de inactividad (2seg)`, async ({ database, provider }) => { const flujoFinal = addKeyword(EVENTS.ACTION).addAnswer('Se cancelo por inactividad') const flujoPrincipal = addKeyword(['hola']) .addAnswer( 'debes de responder antes de que transcurran 2 segundos (2000)', - { capture: true, idle: 2000 }, + { capture: true, idle: 2000, ref: '000000000000000000000000' }, async (ctx, { gotoFlow, inRef }) => { if (ctx?.idleFallBack) { + console.log('me executo ????') return gotoFlow(flujoFinal) } } ) - .addAnswer('gracias!') + .addAnswer('gracias!', { ref: '1111111111111' }) await createBot({ database, @@ -47,7 +48,7 @@ suiteCase.skip(`Prevenir enviar mensaje luego de inactividad (2seg)`, async ({ d assert.is(undefined, getHistory[3]) }) -suiteCase.skip(`Enviar mensaje luego de inactividad (2seg)`, async ({ database, provider }) => { +suiteCase(`Enviar mensaje luego de inactividad (2seg)`, async ({ database, provider }) => { const flujoFinal = addKeyword(EVENTS.ACTION).addAnswer('Se cancelo por inactividad') const flujoPrincipal = addKeyword(['hola']) @@ -128,7 +129,7 @@ suiteCase.skip(`Enviar mensajes con ambos casos de idle`, async ({ database, pro await delay(10000) const getHistory = database.listHistory.map((i) => i.answer) - assert.is('Hola tienes 2 segundos para responder si no te pedire de nuevo otro dato', getHistory[0]) + assert.is('Hola tienes 2 segundos para responder si no te pedire de nuevo otro dato', getHistory) assert.is('Se cancelo por inactividad', getHistory[1]) assert.is('__call_action__', getHistory[2]) assert.is('__capture_only_intended__', getHistory[3]) diff --git a/package.json b/package.json index 9dffa403b..11f06d25c 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "build": "pnpm run cli:rollup && pnpm run bot:rollup && pnpm run provider:rollup && pnpm run database:rollup && pnpm run contexts:rollup && pnpm run create-bot-whatsapp:rollup && pnpm run portal:rollup && pnpm run eslint-plugin:rollup", "copy.lib": "node ./scripts/move.js", "test.unit": "node ./node_modules/uvu/bin.js packages test", - "test.e2e": "node ./node_modules/uvu/bin.js __test__ ", + "test.e2e": "node ./node_modules/uvu/bin.js __test__", "test.coverage": "node ./node_modules/c8/bin/c8.js npm run test.unit", "test": "npm run test.coverage", "cli": "node ./packages/cli/bin/cli.js", diff --git a/packages/bot/context/idleState.class.js b/packages/bot/context/idleState.class.js index 5a94f793a..f83574dca 100755 --- a/packages/bot/context/idleState.class.js +++ b/packages/bot/context/idleState.class.js @@ -24,8 +24,8 @@ class IdleState { inRef, cb, stop: (ctxInComming) => { - cb({ ...ctxInComming, next: false, inRef }) clearInterval(interval) + cb({ ...ctxInComming, next: false, inRef }) }, }) } diff --git a/packages/bot/core/core.class.js b/packages/bot/core/core.class.js index ccbe54fa4..937b9ddd5 100644 --- a/packages/bot/core/core.class.js +++ b/packages/bot/core/core.class.js @@ -264,8 +264,10 @@ class CoreClass extends EventEmitter { if (initRef && !initRef?.idleFallBack) { nextFlow = (await this.flowClass.find(initRef?.ref, true)) ?? [] } + const filterNextFlow = nextFlow.filter((msg) => msg.refSerialize !== currentPrev?.refSerialize) const isContinueFlow = filterNextFlow.map((i) => i.keyword).includes(currentPrev?.ref) + console.log('--------------->', isContinueFlow, initRef) if (!isContinueFlow) { const refToContinueChild = this.flowClass.getRefToContinueChild(currentPrev?.keyword) @@ -277,6 +279,10 @@ class CoreClass extends EventEmitter { return exportFunctionsSend(() => sendFlow(filterNextFlow, from, { prev: undefined })) } + + if (initRef) { + return exportFunctionsSend(() => sendFlow(filterNextFlow, from, { prev: undefined })) + } } // 📄 [options: fallBack]: esta funcion se encarga de repetir el ultimo mensaje const fallBack = @@ -454,7 +460,6 @@ class CoreClass extends EventEmitter { inRef, timeInSeconds: options.startIdleMs / 1000, cb: async (opts) => { - endFlowFlag = false await runContext(true, { idleFallBack: opts.next, ref: opts.inRef, body: opts.body }) }, }) diff --git a/packages/provider/package.json b/packages/provider/package.json index 716c40c8e..44a3572ab 100644 --- a/packages/provider/package.json +++ b/packages/provider/package.json @@ -1,6 +1,6 @@ { "name": "@bot-whatsapp/provider", - "version": "0.0.156-alpha.0", + "version": "0.0.157-alpha.0", "description": "Esto es el conector a Twilio, Meta, etc...", "main": "./lib/mock/index.cjs", "keywords": [], From a1eb16a94689f30e0864f0f13f41c057b304d4d5 Mon Sep 17 00:00:00 2001 From: Leifer Mendez Date: Fri, 5 Jan 2024 13:04:24 +0100 Subject: [PATCH 08/16] fix: fix --- __test__/0.2.1-case.test.js | 7 +++--- packages/bot/context/idleState.class.js | 16 +++++++++++++ packages/bot/core/core.class.js | 8 +++++-- packages/bot/io/events/index.js | 6 ++--- .../src/dialogflow-cx/dialogflow-cx.class.js | 24 +++++++++---------- packages/database/src/mysql/index.js | 16 ++++++------- 6 files changed, 48 insertions(+), 29 deletions(-) diff --git a/__test__/0.2.1-case.test.js b/__test__/0.2.1-case.test.js index 04e56d3f8..6c91ba59d 100644 --- a/__test__/0.2.1-case.test.js +++ b/__test__/0.2.1-case.test.js @@ -87,8 +87,9 @@ suiteCase.skip(`Enviar mensajes con ambos casos de idle`, async ({ database, pro .addAction(async (_, { flowDynamic }) => { await flowDynamic(`Empezemos de nuevo.`) await flowDynamic(`Cual es el numero de orden? tienes dos segundos para responder...`) + console.log('--> antes de action capture') }) - .addAction({ capture: true, idle: 2000, ref: '🙉🙉🙉🙉🙉🙉🙉🙉' }, async (ctx, { flowDynamic }) => { + .addAction({ capture: true, idle: 2100, ref: '🙉🙉🙉🙉🙉🙉🙉🙉' }, async (ctx, { flowDynamic }) => { if (ctx?.idleFallBack) { console.log(`[seundo desvio]`) console.log(`[idleFallBack]:`, ctx) @@ -126,10 +127,10 @@ suiteCase.skip(`Enviar mensajes con ambos casos de idle`, async ({ database, pro body: 'el numero es 444', }) - await delay(10000) + await delay(15000) const getHistory = database.listHistory.map((i) => i.answer) - assert.is('Hola tienes 2 segundos para responder si no te pedire de nuevo otro dato', getHistory) + assert.is('Hola tienes 2 segundos para responder si no te pedire de nuevo otro dato', getHistory[0]) assert.is('Se cancelo por inactividad', getHistory[1]) assert.is('__call_action__', getHistory[2]) assert.is('__capture_only_intended__', getHistory[3]) diff --git a/packages/bot/context/idleState.class.js b/packages/bot/context/idleState.class.js index f83574dca..e8fefc13d 100755 --- a/packages/bot/context/idleState.class.js +++ b/packages/bot/context/idleState.class.js @@ -30,6 +30,22 @@ class IdleState { }) } + /** + * + * @param {*} param0 + * @returns + */ + get = ({ from, inRef }) => { + try { + const queueCb = this.indexCb.get(from) ?? [] + const isHas = queueCb.findIndex((i) => i.inRef !== inRef) !== -1 + return isHas + } catch (err) { + console.error(`Error Get ctxInComming: `, err) + return null + } + } + stop = (ctxInComming) => { try { const queueCb = this.indexCb.get(ctxInComming.from) ?? [] diff --git a/packages/bot/core/core.class.js b/packages/bot/core/core.class.js index 937b9ddd5..9f57326e4 100644 --- a/packages/bot/core/core.class.js +++ b/packages/bot/core/core.class.js @@ -207,6 +207,10 @@ class CoreClass extends EventEmitter { const sendFlow = async (messageToSend, numberOrId, options = {}) => { options = { prev: prevMsg, forceQueue: false, ...options } + const idleCtxQueue = idleForCallback.get({ from, inRef: prevMsg?.ref }) + + // console.log(`>>>>>>>>>>`,{prevRef:prevMsg?.ref, ctx:messageCtxInComming?.ref, idle:options.prev?.options?.idle, idleCtxQueue}) + if (options.prev?.options?.capture && !options.prev?.options?.idle) { await cbEveryCtx(options.prev?.ref) } @@ -267,7 +271,6 @@ class CoreClass extends EventEmitter { const filterNextFlow = nextFlow.filter((msg) => msg.refSerialize !== currentPrev?.refSerialize) const isContinueFlow = filterNextFlow.map((i) => i.keyword).includes(currentPrev?.ref) - console.log('--------------->', isContinueFlow, initRef) if (!isContinueFlow) { const refToContinueChild = this.flowClass.getRefToContinueChild(currentPrev?.keyword) @@ -280,7 +283,7 @@ class CoreClass extends EventEmitter { return exportFunctionsSend(() => sendFlow(filterNextFlow, from, { prev: undefined })) } - if (initRef) { + if (initRef && !initRef?.idleFallBack) { return exportFunctionsSend(() => sendFlow(filterNextFlow, from, { prev: undefined })) } } @@ -541,6 +544,7 @@ class CoreClass extends EventEmitter { msgToSend = this.flowClass.find(this.generalArgs.listEvents.TEMPLATE) || [] } } + return exportFunctionsSend(() => sendFlow(msgToSend, from, { forceQueue: true })) } diff --git a/packages/bot/io/events/index.js b/packages/bot/io/events/index.js index 68b123700..d6a0e8219 100644 --- a/packages/bot/io/events/index.js +++ b/packages/bot/io/events/index.js @@ -15,7 +15,7 @@ const LIST_ALL = { VOICE_NOTE: eventVoiceNote(), ACTION: eventAction(), ORDER: eventOrder(), - TEMPLATE: eventTemplate() + TEMPLATE: eventTemplate(), } const LIST_REGEX = { @@ -24,7 +24,7 @@ const LIST_REGEX = { REGEX_EVENT_MEDIA, REGEX_EVENT_VOICE_NOTE, REGEX_EVENT_ORDER, - REGEX_EVENT_TEMPLATE + REGEX_EVENT_TEMPLATE, } -module.exports = { LIST_ALL, LIST_REGEX } \ No newline at end of file +module.exports = { LIST_ALL, LIST_REGEX } diff --git a/packages/contexts/src/dialogflow-cx/dialogflow-cx.class.js b/packages/contexts/src/dialogflow-cx/dialogflow-cx.class.js index 9f42ef462..58b89be22 100644 --- a/packages/contexts/src/dialogflow-cx/dialogflow-cx.class.js +++ b/packages/contexts/src/dialogflow-cx/dialogflow-cx.class.js @@ -23,33 +23,31 @@ class DialogFlowCXContext extends CoreClass { * Verificar conexión con servicio de DialogFlow */ init = () => { - let credentials; - const googleKeyFilePath = join(process.cwd(), 'google-key.json'); + let credentials + const googleKeyFilePath = join(process.cwd(), 'google-key.json') if (existsSync(googleKeyFilePath)) { - const rawJson = readFileSync(googleKeyFilePath, 'utf-8'); - credentials = JSON.parse(rawJson); + const rawJson = readFileSync(googleKeyFilePath, 'utf-8') + credentials = JSON.parse(rawJson) } else if (process.env.GOOGLE_KEY_JSON) { - credentials = JSON.parse(process.env.GOOGLE_KEY_JSON); + credentials = JSON.parse(process.env.GOOGLE_KEY_JSON) } else { - throw new Error('Google key configuration not found'); + throw new Error('Google key configuration not found') } - if (!this.optionsDX.location.length) throw new Error('LOCATION_NO_ENCONTRADO'); - if (!this.optionsDX.agentId.length) throw new Error('AGENTID_NO_ENCONTRADO'); + if (!this.optionsDX.location.length) throw new Error('LOCATION_NO_ENCONTRADO') + if (!this.optionsDX.agentId.length) throw new Error('AGENTID_NO_ENCONTRADO') - const { project_id, private_key, client_email } = credentials; + const { project_id, private_key, client_email } = credentials - this.projectId = project_id; + this.projectId = project_id this.sessionClient = new SessionsClient({ credentials: { private_key, client_email }, apiEndpoint: `${this.optionsDX.location}-dialogflow.googleapis.com`, - }); + }) } - - /** * GLOSSARY.md * @param {*} messageCtxInComming diff --git a/packages/database/src/mysql/index.js b/packages/database/src/mysql/index.js index 09b1d6430..498cdd1fe 100644 --- a/packages/database/src/mysql/index.js +++ b/packages/database/src/mysql/index.js @@ -26,24 +26,24 @@ class MyslAdapter { } getPrevByNumber = async (from) => { - if (this.db._closing) await this.init() + if (this.db._closing) await this.init() return await new Promise((resolve, reject) => { - const sql = `SELECT * FROM history WHERE phone='${from}' ORDER BY id DESC`; + const sql = `SELECT * FROM history WHERE phone='${from}' ORDER BY id DESC` this.db.query(sql, (error, rows) => { if (error) { - reject(error); + reject(error) } if (rows.length) { - const [row] = rows; - row.options = JSON.parse(row.options); - resolve(row); + const [row] = rows + row.options = JSON.parse(row.options) + resolve(row) } if (!rows.length) { - resolve(null); + resolve(null) } - }); + }) }) } From 085761abccac0647a05522d1373ff5c0da96f5f8 Mon Sep 17 00:00:00 2001 From: Leifer Mendez Date: Fri, 5 Jan 2024 13:04:51 +0100 Subject: [PATCH 09/16] fix: fix --- packages/bot/core/core.class.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/bot/core/core.class.js b/packages/bot/core/core.class.js index 9f57326e4..a0f2675c1 100644 --- a/packages/bot/core/core.class.js +++ b/packages/bot/core/core.class.js @@ -207,7 +207,7 @@ class CoreClass extends EventEmitter { const sendFlow = async (messageToSend, numberOrId, options = {}) => { options = { prev: prevMsg, forceQueue: false, ...options } - const idleCtxQueue = idleForCallback.get({ from, inRef: prevMsg?.ref }) + // const idleCtxQueue = idleForCallback.get({ from, inRef: prevMsg?.ref }) // console.log(`>>>>>>>>>>`,{prevRef:prevMsg?.ref, ctx:messageCtxInComming?.ref, idle:options.prev?.options?.idle, idleCtxQueue}) From 1f8f23cbe26b91953d305ccc1bead6e7bf6a9b6f Mon Sep 17 00:00:00 2001 From: Leifer Mendez Date: Fri, 5 Jan 2024 13:51:08 +0100 Subject: [PATCH 10/16] fix: idle second version --- __test__/0.2.1-case.test.js | 3 +- package.json | 2 +- packages/bot/core/core.class.js | 93 ++++++++++++++++++++------------- 3 files changed, 58 insertions(+), 40 deletions(-) diff --git a/__test__/0.2.1-case.test.js b/__test__/0.2.1-case.test.js index 6c91ba59d..fcdaba910 100644 --- a/__test__/0.2.1-case.test.js +++ b/__test__/0.2.1-case.test.js @@ -81,13 +81,12 @@ suiteCase(`Enviar mensaje luego de inactividad (2seg)`, async ({ database, provi assert.is(undefined, getHistory[2]) }) -suiteCase.skip(`Enviar mensajes con ambos casos de idle`, async ({ database, provider }) => { +suiteCase(`Enviar mensajes con ambos casos de idle`, async ({ database, provider }) => { const flujoFinal = addKeyword(EVENTS.ACTION) .addAnswer('Se cancelo por inactividad') .addAction(async (_, { flowDynamic }) => { await flowDynamic(`Empezemos de nuevo.`) await flowDynamic(`Cual es el numero de orden? tienes dos segundos para responder...`) - console.log('--> antes de action capture') }) .addAction({ capture: true, idle: 2100, ref: '🙉🙉🙉🙉🙉🙉🙉🙉' }, async (ctx, { flowDynamic }) => { if (ctx?.idleFallBack) { diff --git a/package.json b/package.json index 11f06d25c..9dffa403b 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "build": "pnpm run cli:rollup && pnpm run bot:rollup && pnpm run provider:rollup && pnpm run database:rollup && pnpm run contexts:rollup && pnpm run create-bot-whatsapp:rollup && pnpm run portal:rollup && pnpm run eslint-plugin:rollup", "copy.lib": "node ./scripts/move.js", "test.unit": "node ./node_modules/uvu/bin.js packages test", - "test.e2e": "node ./node_modules/uvu/bin.js __test__", + "test.e2e": "node ./node_modules/uvu/bin.js __test__ ", "test.coverage": "node ./node_modules/c8/bin/c8.js npm run test.unit", "test": "npm run test.coverage", "cli": "node ./packages/cli/bin/cli.js", diff --git a/packages/bot/core/core.class.js b/packages/bot/core/core.class.js index a0f2675c1..06094a61f 100644 --- a/packages/bot/core/core.class.js +++ b/packages/bot/core/core.class.js @@ -207,61 +207,80 @@ class CoreClass extends EventEmitter { const sendFlow = async (messageToSend, numberOrId, options = {}) => { options = { prev: prevMsg, forceQueue: false, ...options } - // const idleCtxQueue = idleForCallback.get({ from, inRef: prevMsg?.ref }) + const idleCtxQueue = idleForCallback.get({ from, inRef: prevMsg?.ref }) - // console.log(`>>>>>>>>>>`,{prevRef:prevMsg?.ref, ctx:messageCtxInComming?.ref, idle:options.prev?.options?.idle, idleCtxQueue}) + const { ref: prevRef, options: prevOptions } = options.prev || {} + const { capture, idle } = prevOptions || {} - if (options.prev?.options?.capture && !options.prev?.options?.idle) { - await cbEveryCtx(options.prev?.ref) + if (messageCtxInComming?.ref && idleCtxQueue && messageToSend.length) { + return + } + + if (capture && idle && messageToSend.length === 0) { + await cbEveryCtx(prevRef) + return + } + + if (capture && !idle) { + await cbEveryCtx(prevRef) } for (const ctxMessage of messageToSend) { if (endFlowFlag) { - return // Si endFlowFlag es verdadero, detener el flujo + break } const delayMs = ctxMessage?.options?.delay ?? this.generalArgs.delay ?? 0 await delay(delayMs) //TODO el proceso de forzar cola de procsos - if (options?.forceQueue) { - const listIdsRefCallbacks = messageToSend.map((i) => i.ref) - - const listProcessWait = this.queuePrincipal.getIdsCallback(from) - if (!listProcessWait.length) { - this.queuePrincipal.setIdsCallbacks(from, listIdsRefCallbacks) - } else { - const lastMessage = messageToSend[messageToSend.length - 1] - await this.databaseClass.save({ ...lastMessage, from: numberOrId }) - if (listProcessWait.includes(lastMessage.ref)) { - this.queuePrincipal.clearQueue(from) - } - } + if (options.forceQueue) { + await handleForceQueue(ctxMessage, messageToSend, numberOrId, from) } - try { - // this.queuePrincipal.clearQueue(from); - await this.queuePrincipal.enqueue( - from, - async () => { - // Usar async en la función pasada a enqueue - await this.sendProviderAndSave(numberOrId, ctxMessage).then(() => - resolveCbEveryCtx(ctxMessage) - ) - logger.log(`[QUEUE_SE_ENVIO]: `, ctxMessage) - // await resolveCbEveryCtx(ctxMessage) - }, - ctxMessage.ref - ) - } catch (error) { - logger.error(`Error al encolar (ID ${ctxMessage.ref}):`, error) - return Promise.reject() - // Puedes considerar manejar el error aquí o rechazar la promesa - // Pasada a resolveCbEveryCtx con el error correspondiente. + await enqueueMsg(numberOrId, ctxMessage, from) + } + } + + // Se han extraído algunas funcionalidades en nuevas funciones para mejorar la legibilidad + const handleForceQueue = async (_, messageToSend, numberOrId, from) => { + const listIdsRefCallbacks = messageToSend.map((i) => i.ref) + const listProcessWait = this.queuePrincipal.getIdsCallback(from) + + if (!listProcessWait.length) { + this.queuePrincipal.setIdsCallbacks(from, listIdsRefCallbacks) + } else { + const lastMessage = messageToSend[messageToSend.length - 1] + await this.databaseClass.save({ ...lastMessage, from: numberOrId }) + + if (listProcessWait.includes(lastMessage.ref)) { + this.queuePrincipal.clearQueue(from) } } } + const enqueueMsg = async (numberOrId, ctxMessage, from) => { + try { + await this.queuePrincipal.enqueue( + from, + async () => { + await this.sendProviderAndSave(numberOrId, ctxMessage) + .then(() => resolveCbEveryCtx(ctxMessage)) + .catch((error) => { + logger.error(`Error en sendProviderAndSave (ID ${ctxMessage.ref}):`, error) + throw error + }) + + logger.log(`[QUEUE_SE_ENVIO]: `, ctxMessage) + }, + ctxMessage.ref + ) + } catch (error) { + logger.error(`Error al encolar (ID ${ctxMessage.ref}):`, error) + throw error + } + } + const continueFlow = async (initRef = undefined) => { const currentPrev = await this.databaseClass.getPrevByNumber(from) let nextFlow = (await this.flowClass.find(refToContinue?.ref, true)) ?? [] From 924d029e0fcfe8eff5a26d0477343452f0a25204 Mon Sep 17 00:00:00 2001 From: Leifer Mendez Date: Fri, 5 Jan 2024 13:58:32 +0100 Subject: [PATCH 11/16] fix: idle second version --- packages/bot/tests/idleState.test.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 packages/bot/tests/idleState.test.js diff --git a/packages/bot/tests/idleState.test.js b/packages/bot/tests/idleState.test.js new file mode 100644 index 000000000..e2735c504 --- /dev/null +++ b/packages/bot/tests/idleState.test.js @@ -0,0 +1,14 @@ +const { test } = require('uvu') +const assert = require('uvu/assert') +const IdleState = require('../context/idleState.class') + +test(`[IdleState] Probando instanciamiento de clase`, async () => { + const idleState = new IdleState() + + idleState.setIdleTime({ from: '000', inRef: 'ref1', timeInSeconds: 10 }) + const queue = idleState.get({ from: '000' }) + assert.is(idleState instanceof IdleState, true) + assert.is(queue, true) +}) + +test.run() From 79aa5e8fdc1fff1d1e2b1d7590d3530b13bb31df Mon Sep 17 00:00:00 2001 From: Leifer Mendez Date: Fri, 5 Jan 2024 14:01:20 +0100 Subject: [PATCH 12/16] fix: idle second version --- packages/bot/context/idleState.class.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/bot/context/idleState.class.js b/packages/bot/context/idleState.class.js index e8fefc13d..35b5c018e 100755 --- a/packages/bot/context/idleState.class.js +++ b/packages/bot/context/idleState.class.js @@ -2,6 +2,7 @@ class IdleState { indexCb = new Map() setIdleTime = ({ from, inRef, timeInSeconds, cb }) => { + cb = cb ?? (() => {}) const startTime = new Date().getTime() const endTime = startTime + timeInSeconds * 1000 From c9ba66e34b641c436825e0cd97051db7c094038a Mon Sep 17 00:00:00 2001 From: Leifer Mendez Date: Mon, 22 Jan 2024 17:29:19 +0100 Subject: [PATCH 13/16] chore: release js after ts --- package.json | 2 +- packages/bot/context/idleState.class.js | 14 +++++++++++--- packages/bot/core/core.class.js | 17 +++++++++++++---- packages/bot/package.json | 2 +- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 9dffa403b..0157ff90b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bot-whatsapp/root", - "version": "0.1.34", + "version": "0.1.35", "description": "Bot de wahtsapp open source para MVP o pequeños negocios", "main": "app.js", "private": true, diff --git a/packages/bot/context/idleState.class.js b/packages/bot/context/idleState.class.js index 35b5c018e..560fb950d 100755 --- a/packages/bot/context/idleState.class.js +++ b/packages/bot/context/idleState.class.js @@ -1,6 +1,10 @@ class IdleState { indexCb = new Map() + /** + * + * @param param0 + */ setIdleTime = ({ from, inRef, timeInSeconds, cb }) => { cb = cb ?? (() => {}) const startTime = new Date().getTime() @@ -33,7 +37,7 @@ class IdleState { /** * - * @param {*} param0 + * @param param0 * @returns */ get = ({ from, inRef }) => { @@ -47,15 +51,19 @@ class IdleState { } } + /** + * + * @param ctxInComming + */ stop = (ctxInComming) => { try { const queueCb = this.indexCb.get(ctxInComming.from) ?? [] for (const iterator of queueCb) { iterator.stop(ctxInComming) } + this.indexCb.set(ctxInComming.from, []) } catch (err) { - console.log(err) - return null + console.error(err) } } } diff --git a/packages/bot/core/core.class.js b/packages/bot/core/core.class.js index 06094a61f..1d18665d8 100644 --- a/packages/bot/core/core.class.js +++ b/packages/bot/core/core.class.js @@ -283,12 +283,19 @@ class CoreClass extends EventEmitter { const continueFlow = async (initRef = undefined) => { const currentPrev = await this.databaseClass.getPrevByNumber(from) - let nextFlow = (await this.flowClass.find(refToContinue?.ref, true)) ?? [] + + let nextFlow = this.flowClass.find(refToContinue?.ref, true) || [] if (initRef && !initRef?.idleFallBack) { - nextFlow = (await this.flowClass.find(initRef?.ref, true)) ?? [] + nextFlow = this.flowClass.find(initRef?.ref, true) || [] } - const filterNextFlow = nextFlow.filter((msg) => msg.refSerialize !== currentPrev?.refSerialize) + const getContinueIndex = nextFlow.findIndex((msg) => msg.refSerialize === currentPrev?.refSerialize) + const indexToContinue = getContinueIndex !== -1 ? getContinueIndex : 0 + const filterNextFlow = nextFlow + .slice(indexToContinue) + .filter((i) => i.refSerialize !== currentPrev?.refSerialize) + + // const filterNextFlow = nextFlow.filter((msg) => msg.refSerialize !== currentPrev?.refSerialize); const isContinueFlow = filterNextFlow.map((i) => i.keyword).includes(currentPrev?.ref) if (!isContinueFlow) { @@ -482,7 +489,9 @@ class CoreClass extends EventEmitter { inRef, timeInSeconds: options.startIdleMs / 1000, cb: async (opts) => { - await runContext(true, { idleFallBack: opts.next, ref: opts.inRef, body: opts.body }) + if (opts?.next) { + await runContext(true, { idleFallBack: opts.next, ref: opts.inRef, body: opts.body }) + } }, }) return diff --git a/packages/bot/package.json b/packages/bot/package.json index 9a241685d..db9772536 100644 --- a/packages/bot/package.json +++ b/packages/bot/package.json @@ -1,6 +1,6 @@ { "name": "@bot-whatsapp/bot", - "version": "0.0.223-alpha.0", + "version": "0.0.226-alpha.0", "description": "", "main": "./lib/bundle.bot.cjs", "scripts": { From 4cd23f1c2151deedf10bc0baac2addc47798422d Mon Sep 17 00:00:00 2001 From: Leifer Mendez Date: Mon, 22 Jan 2024 17:35:10 +0100 Subject: [PATCH 14/16] chore(release): 0.1.36 --- CHANGELOG.md | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 99 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a50ddea5a..c90b755aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,104 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [0.1.36](https://github.com/leifermendez/bot-whatsapp/compare/v0.1.25...v0.1.36) (2024-01-22) + + +### Features + +* :art: next-version ([70d75ed](https://github.com/leifermendez/bot-whatsapp/commit/70d75edf8265be83a19259091ef98de5bbf56639)) +* :art: update + endflow default ([bdf4206](https://github.com/leifermendez/bot-whatsapp/commit/bdf420602b6dc596383f960df26bdce37a2b109f)) +* :fire: delay -> `flowDynamic` ([cb6d11b](https://github.com/leifermendez/bot-whatsapp/commit/cb6d11b3242d9ed8ea42d25e457123c52992c8b1)) +* :fire: delay -> `flowDynamic` ([8c23eae](https://github.com/leifermendez/bot-whatsapp/commit/8c23eaee69b117e6be276c48b96946cf512b8c33)) +* :zap: beta new features ([c34b207](https://github.com/leifermendez/bot-whatsapp/commit/c34b207e3fbb38130b036ba960d07600e606573f)) +* :zap: idle concat ([2d23d39](https://github.com/leifermendez/bot-whatsapp/commit/2d23d3907283cf2d64e0f004d9177810dcf787d9)) +* :zap: lot improvments ([2a1726b](https://github.com/leifermendez/bot-whatsapp/commit/2a1726bc41862e360e5066ac9ab7ed8dd17cb7c0)) +* :zap: lot improvments ([21a0730](https://github.com/leifermendez/bot-whatsapp/commit/21a0730c12bb8ffdd2d79a9c7cf5cbdfc5d5cb50)) +* :zap: queue by from ([8b43036](https://github.com/leifermendez/bot-whatsapp/commit/8b43036d85ba5bed3803d524ca71fc97886d66b1)) +* **adapter:** :zap: added that it automatically generates the date when the data is added to the db ([889cbfa](https://github.com/leifermendez/bot-whatsapp/commit/889cbfab8abfb76ed8e111e702bdad93483ae611)) +* add eslint-plugin ([2df14e6](https://github.com/leifermendez/bot-whatsapp/commit/2df14e6f8923a4e640cf06ff8a83c50095a40e79)) +* add eslint-plugin ([5ca3313](https://github.com/leifermendez/bot-whatsapp/commit/5ca331334388c6bd59827a4cd3f5f9ecc5f8e22e)) +* add eslint-plugin ([769b7e8](https://github.com/leifermendez/bot-whatsapp/commit/769b7e812b9f47c5375b1e04ad0a35f2441380a3)) +* **bot:** :sparkles: feat ([589f96e](https://github.com/leifermendez/bot-whatsapp/commit/589f96efc26d03d622c85619656757f3dfb8c39e)) +* **bot:** :zap: add dynamic BlackList ([5a05414](https://github.com/leifermendez/bot-whatsapp/commit/5a054146b6a46cbe7e4a36865425eb0f8209eaf6)) +* **bot:** :zap: handler state ctx ([7f3f156](https://github.com/leifermendez/bot-whatsapp/commit/7f3f156c0c05c5f638ed521cb20613aa2243e863)) +* **bot:** :zap: idle feature ([e2a6cbd](https://github.com/leifermendez/bot-whatsapp/commit/e2a6cbd7091544907a4c6e5911ea351c4d1d8a42)) +* **database:** Se agrego sp para guardar y actualizar contactos en postgres ([574b0d3](https://github.com/leifermendez/bot-whatsapp/commit/574b0d35d1306c935ccb6490018e7c8dfbb73bbe)) +* fix gotoFlow addAction ([4ce4dbf](https://github.com/leifermendez/bot-whatsapp/commit/4ce4dbff0e23422cd4c82777b25de0b758b960be)) +* idle state ([a39c9d2](https://github.com/leifermendez/bot-whatsapp/commit/a39c9d2c954f167eb8768e4787d440b33cf4f7d0)) +* Integrate 'capture_only_intended' flag for silent execution in 'addAnswer' function ([e298b54](https://github.com/leifermendez/bot-whatsapp/commit/e298b546f4e91c2142ca09f4281a0faf694bfa7b)) +* meta add fileUrl image ([7b5f8fd](https://github.com/leifermendez/bot-whatsapp/commit/7b5f8fd9577ffb26feeaa670a5bfca84281b20e8)) +* next release ([158849f](https://github.com/leifermendez/bot-whatsapp/commit/158849fe99a80096719e09f348ba66d10c97d183)) +* next-release ([3f50a05](https://github.com/leifermendez/bot-whatsapp/commit/3f50a0577b82c493ae3b6c85af26e9f2f63b34c7)) +* **provider:** :fire: add tmp file twilio ([c99ab6c](https://github.com/leifermendez/bot-whatsapp/commit/c99ab6c6ea5a69790b3229a9700fea1a0d45d222)) +* **provider:** :memo: se actualizó el contexto (ctx) para incluir la url ([043b33c](https://github.com/leifermendez/bot-whatsapp/commit/043b33c860c489fed0b5251d06535cea42b75b01)) +* **provider:** :sparkles: the image, video, document, stickers, location and vcard events are added ([0705aeb](https://github.com/leifermendez/bot-whatsapp/commit/0705aeb6077fd151ccf7a37582f7afe64e089b36)) +* **provider:** :zap: meta fix ([dd849d6](https://github.com/leifermendez/bot-whatsapp/commit/dd849d63571bcd896d9cf9e47eee02dff784558f)) +* **provider:** :zap: meta fix ([f50acf2](https://github.com/leifermendez/bot-whatsapp/commit/f50acf2975fe5adb9bdb090f8bd6c056e171f3cb)) +* **provider:** ✨ WPPConnect added poll ([564d6bb](https://github.com/leifermendez/bot-whatsapp/commit/564d6bb31b972f2fdd559a1379cc54e64468e8fd)) +* **provider:** ✨Baileys added auth with Pairing Code ([a2622cc](https://github.com/leifermendez/bot-whatsapp/commit/a2622cc3a7388138034bd41722f812e552dfbf53)) +* **provider:** ✨Baileys added polls in baileys ([6374503](https://github.com/leifermendez/bot-whatsapp/commit/637450351baf32395c719d7a09d47ed0ef3e1fa1)) +* se adiciona la funcionalidad de enviar reacciones para el proveedor meta sendReaction ([abf89ff](https://github.com/leifermendez/bot-whatsapp/commit/abf89ff9d5f5ca8005fc738fda8d2fb56b044d31)) +* se adiciona la funcionalidad de enviar ubicacion para provedor meta ([73f0c69](https://github.com/leifermendez/bot-whatsapp/commit/73f0c6908405a18d3ae87e564ce00d441c92943a)) +* se adiciona la funcionalidad de enviar una ubicacion para el proveedor meta ([3f9942b](https://github.com/leifermendez/bot-whatsapp/commit/3f9942b53cd614c5a601f102d3f2ed52752e8acc)) + + +### Bug Fixes + +* :art: more ([35d1279](https://github.com/leifermendez/bot-whatsapp/commit/35d12792ec1b692abcc4aeedb0c7d640b776ee6b)) +* :art: pnpm ([122a7e1](https://github.com/leifermendez/bot-whatsapp/commit/122a7e1ab6b0288accba620f410ee7920ed3ff5d)) +* :art: pnpm ([bca9826](https://github.com/leifermendez/bot-whatsapp/commit/bca98268f84f033f8bb64d9146d7ccadea39a50c)) +* :art: working gotoFlow and capture ([baa7429](https://github.com/leifermendez/bot-whatsapp/commit/baa7429c73675c673850666fc58f0036cac8e66d)) +* :zap: bug ([28b3240](https://github.com/leifermendez/bot-whatsapp/commit/28b3240d4f1313356da393832fe616b9f06baa7d)) +* :zap: change quueu ([f43c236](https://github.com/leifermendez/bot-whatsapp/commit/f43c2363d5d6df49b16ba9a1f0c6643e9970c622)) +* :zap: core properties ([cff223b](https://github.com/leifermendez/bot-whatsapp/commit/cff223ba5839b961fea10316269d16a7b4c39a54)) +* :zap: delay after gotoFlow [#877](https://github.com/leifermendez/bot-whatsapp/issues/877) ([1eda39a](https://github.com/leifermendez/bot-whatsapp/commit/1eda39aa7756d7a8f62050775ded20709ad5faad)) +* :zap: issue [#865](https://github.com/leifermendez/bot-whatsapp/issues/865) ([2fe6bd5](https://github.com/leifermendez/bot-whatsapp/commit/2fe6bd569791f3481183bc9000145f9f48b07673)) +* :zap: issue [#910](https://github.com/leifermendez/bot-whatsapp/issues/910) ([6edf373](https://github.com/leifermendez/bot-whatsapp/commit/6edf3730e143c58b3bb36e1d748a6730e6392168)) +* :zap: meta video ([6cef90a](https://github.com/leifermendez/bot-whatsapp/commit/6cef90ad21913634ac3a50e5096eac8242645268)) +* :zap: next version ([fbce48f](https://github.com/leifermendez/bot-whatsapp/commit/fbce48f91c76ef44b87a10f60cd922a35fafb45e)) +* :zap: other queue ([54ad1d6](https://github.com/leifermendez/bot-whatsapp/commit/54ad1d65826ac78bd5da7e863bd56baafbeff362)) +* :zap: prevent queued process ([bbd744b](https://github.com/leifermendez/bot-whatsapp/commit/bbd744b09ee27692ac87888695c54b9ced02a410)) +* :zap: queue ([c380f06](https://github.com/leifermendez/bot-whatsapp/commit/c380f061926983a953b0f297f38003b98f02133a)) +* :zap: some ([d2d1409](https://github.com/leifermendez/bot-whatsapp/commit/d2d140993a2a4a6be6d55e8de7300decaf2613ab)) +* "provider twilio media & document " ([c3b2738](https://github.com/leifermendez/bot-whatsapp/commit/c3b273843afa0141e78e662fe1534f83287bc6e6)) +* **bot:** :fire: fix ([894edde](https://github.com/leifermendez/bot-whatsapp/commit/894eddefe161e7c87f049faa40e91ec1bc649a3f)) +* **bot:** :fire: se incorpora la funcionalidad de blacklist dinámica ([966834e](https://github.com/leifermendez/bot-whatsapp/commit/966834eb54967348fbb0bb88653add8c968ad121)) +* **bot:** :zap: hot fix `fotoFlow` and download ([dced080](https://github.com/leifermendez/bot-whatsapp/commit/dced08017c823791131a29ef4a5e81090800794c)) +* crypto url ([f8ff35e](https://github.com/leifermendez/bot-whatsapp/commit/f8ff35e401510e1614e6d6753b7ad42f5114fc16)) +* **database:** MySQL conection timeout ([8391037](https://github.com/leifermendez/bot-whatsapp/commit/8391037ff120265faeaa7277918b856d94294ff7)) +* default endFlow ([a522eeb](https://github.com/leifermendez/bot-whatsapp/commit/a522eeb2e92ed8c26ee4930e824ef95b7f863d2f)) +* fix ([085761a](https://github.com/leifermendez/bot-whatsapp/commit/085761abccac0647a05522d1373ff5c0da96f5f8)) +* fix ([a1eb16a](https://github.com/leifermendez/bot-whatsapp/commit/a1eb16a94689f30e0864f0f13f41c057b304d4d5)) +* fix twilio ([e122f67](https://github.com/leifermendez/bot-whatsapp/commit/e122f67751f49563dc2d0ea894da1da30dfa03e1)) +* fix twilio ([22112a3](https://github.com/leifermendez/bot-whatsapp/commit/22112a364d325aaa03b9ec27c438796cfb832e46)) +* fix twilio ([d9ff81c](https://github.com/leifermendez/bot-whatsapp/commit/d9ff81c539e2786fe1210bbd24f2c1da12d90058)) +* gloalState ([491e1f7](https://github.com/leifermendez/bot-whatsapp/commit/491e1f72974ce45f8d9a00145f3afb8dbe0e2189)) +* **hook:** :zap: event action ([e922dfc](https://github.com/leifermendez/bot-whatsapp/commit/e922dfce84a84a3c3ad00be6aa4e7758459e32bf)) +* idle ([07dd0fe](https://github.com/leifermendez/bot-whatsapp/commit/07dd0fe6dac2d18664e7b93e886dd7f5897e4e46)) +* idle second version ([79aa5e8](https://github.com/leifermendez/bot-whatsapp/commit/79aa5e8fdc1fff1d1e2b1d7590d3530b13bb31df)) +* idle second version ([924d029](https://github.com/leifermendez/bot-whatsapp/commit/924d029e0fcfe8eff5a26d0477343452f0a25204)) +* idle second version ([1f8f23c](https://github.com/leifermendez/bot-whatsapp/commit/1f8f23cbe26b91953d305ccc1bead6e7bf6a9b6f)) +* **io:** flow.Class some regular expressions don´t works ([a66d219](https://github.com/leifermendez/bot-whatsapp/commit/a66d2197432411634aebd0a1c31c900f731f625f)) +* **provider:** :bug: Fixed Puppeteer configuration ([f01bc76](https://github.com/leifermendez/bot-whatsapp/commit/f01bc76edababe8f57aced85db22f567477caf78)) +* **provider:** :fire: ([82d05aa](https://github.com/leifermendez/bot-whatsapp/commit/82d05aaad93bdba63cde3c7625b3b64274081ffc)) +* **provider:** :zap: change Bailey ([110a4b8](https://github.com/leifermendez/bot-whatsapp/commit/110a4b8d5fc25f2c11ea05c9d33d728830446fcc)) +* **provider:** :zap: change Bailey ([5d000af](https://github.com/leifermendez/bot-whatsapp/commit/5d000af98ff6a70613be7019dcfc9c638ea3d9aa)) +* **provider:** :zap: update GetMediaUrl and add audio url ([29a4f82](https://github.com/leifermendez/bot-whatsapp/commit/29a4f82b4beae705910d9cb1604b041e3169505a)) +* **provider:** :zap: version is added ([d4818f2](https://github.com/leifermendez/bot-whatsapp/commit/d4818f289d7e559fa46076c34c6ddfb1deaf427d)) +* **provider:** 🐛Fixed Baileys body Undefined sometimes ([8f90ee8](https://github.com/leifermendez/bot-whatsapp/commit/8f90ee8f2d8ccb396423af375819431ca772e486)) +* **provider:** 🐛Fixed get data mysql for baileys ([0f792da](https://github.com/leifermendez/bot-whatsapp/commit/0f792da5bdc668e82b31a061204ca1756614196d)) +* **provider:** 🐛Fixed get state message poll ([260c240](https://github.com/leifermendez/bot-whatsapp/commit/260c2406fc31fe8bacaa542dbc959e4618b82273)) +* **provider:** 🐛Fixed update version whatsapp-web.js ([464b34f](https://github.com/leifermendez/bot-whatsapp/commit/464b34f2e35d6cb7cdd0426179aec8f961d44f9c)) +* **provider:** meta improved 🔥 ([2f21dfd](https://github.com/leifermendez/bot-whatsapp/commit/2f21dfd2b9092736a190a0a1ce4a4fa3762999e0)) +* queue new ([e708dd9](https://github.com/leifermendez/bot-whatsapp/commit/e708dd9519b93cc0fd282800a78375224a6261da)) +* queue timer clear ([215ccfe](https://github.com/leifermendez/bot-whatsapp/commit/215ccfee6af38d54ada7636a2de59b13e667672c)) +* queue timer clear ([dab9e51](https://github.com/leifermendez/bot-whatsapp/commit/dab9e51a3b087cb6586f5fbdce0425979cc473f7)) +* release alpha ([99dba85](https://github.com/leifermendez/bot-whatsapp/commit/99dba8547024158ebaca76bb3d42b99dbbbc9897)) +* remove map ([e13f912](https://github.com/leifermendez/bot-whatsapp/commit/e13f9127c5c016192f98ef6d8aa923ea08755e23)) +* se soluciona problemas con sendContacts para el provider meta ([3bcbb97](https://github.com/leifermendez/bot-whatsapp/commit/3bcbb97979ccc144bc52e5edb5f74e3826909987)) +* some fix ([be07912](https://github.com/leifermendez/bot-whatsapp/commit/be079123587a50f490fd7b8addbd48bb528dfb6d)) + ### [0.1.27](https://github.com/leifermendez/bot-whatsapp/compare/v0.1.25...v0.1.27) (2023-05-28) diff --git a/package.json b/package.json index 0157ff90b..b38cab2d7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bot-whatsapp/root", - "version": "0.1.35", + "version": "0.1.36", "description": "Bot de wahtsapp open source para MVP o pequeños negocios", "main": "app.js", "private": true, From 124c328515f0e4a538f1251be9ae4b53f9d6ebaf Mon Sep 17 00:00:00 2001 From: Leifer Mendez Date: Tue, 23 Jan 2024 17:26:27 +0100 Subject: [PATCH 15/16] fix: bug --- packages/bot/package.json | 2 +- packages/cli/package.json | 2 +- packages/contexts/package.json | 2 +- packages/create-bot-whatsapp/package.json | 2 +- packages/database/package.json | 2 +- packages/eslint-plugin-bot-whatsapp/package.json | 2 +- packages/portal/package.json | 2 +- packages/provider/package.json | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/bot/package.json b/packages/bot/package.json index db9772536..3deb201a8 100644 --- a/packages/bot/package.json +++ b/packages/bot/package.json @@ -1,6 +1,6 @@ { "name": "@bot-whatsapp/bot", - "version": "0.0.226-alpha.0", + "version": "0.1.37", "description": "", "main": "./lib/bundle.bot.cjs", "scripts": { diff --git a/packages/cli/package.json b/packages/cli/package.json index eefedf2f5..2b3baabac 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@bot-whatsapp/cli", - "version": "0.0.111-alpha.0", + "version": "0.1.37", "description": "", "main": "index.js", "devDependencies": { diff --git a/packages/contexts/package.json b/packages/contexts/package.json index d16829a29..85439b569 100644 --- a/packages/contexts/package.json +++ b/packages/contexts/package.json @@ -1,6 +1,6 @@ { "name": "@bot-whatsapp/contexts", - "version": "0.0.39-alpha.0", + "version": "0.1.37", "description": "", "main": "./lib/bundle.contexts.cjs", "files": [ diff --git a/packages/create-bot-whatsapp/package.json b/packages/create-bot-whatsapp/package.json index 66a2afc51..9b201e504 100644 --- a/packages/create-bot-whatsapp/package.json +++ b/packages/create-bot-whatsapp/package.json @@ -1,6 +1,6 @@ { "name": "create-bot-whatsapp", - "version": "0.0.141-alpha.0", + "version": "0.1.37", "description": "", "main": "./lib/bundle.create-bot-whatsapp.cjs", "files": [ diff --git a/packages/database/package.json b/packages/database/package.json index 5c2986ba0..0c57dbe93 100644 --- a/packages/database/package.json +++ b/packages/database/package.json @@ -1,6 +1,6 @@ { "name": "@bot-whatsapp/database", - "version": "0.0.86-alpha.0", + "version": "0.1.37", "description": "Esto es el conector a mysql, pg, mongo", "main": "./lib/mock/index.cjs", "keywords": [], diff --git a/packages/eslint-plugin-bot-whatsapp/package.json b/packages/eslint-plugin-bot-whatsapp/package.json index a689f3ce7..4f3be902d 100644 --- a/packages/eslint-plugin-bot-whatsapp/package.json +++ b/packages/eslint-plugin-bot-whatsapp/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-bot-whatsapp", - "version": "0.0.4-alpha.0", + "version": "0.1.37", "description": "", "main": "./lib/eslint-plugin-bot-whatsapp.cjs", "files": [ diff --git a/packages/portal/package.json b/packages/portal/package.json index 7214ee7d4..5b1367de4 100644 --- a/packages/portal/package.json +++ b/packages/portal/package.json @@ -1,6 +1,6 @@ { "name": "@bot-whatsapp/portal", - "version": "0.0.44-alpha.0", + "version": "0.1.37", "description": "Portal WEB para escanear QR", "main": "./lib/portal.http.cjs", "scripts": { diff --git a/packages/provider/package.json b/packages/provider/package.json index 336a73926..6295af7fb 100644 --- a/packages/provider/package.json +++ b/packages/provider/package.json @@ -1,6 +1,6 @@ { "name": "@bot-whatsapp/provider", - "version": "0.0.161-alpha.0", + "version": "0.1.37", "description": "Esto es el conector a Twilio, Meta, etc...", "main": "./lib/mock/index.cjs", "keywords": [], From a30792aef5db7832d0518a5a7a85540bd7f5d94e Mon Sep 17 00:00:00 2001 From: Leifer Mendez Date: Tue, 23 Jan 2024 17:32:19 +0100 Subject: [PATCH 16/16] refactor: fix bug version --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b38cab2d7..d8f12159d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bot-whatsapp/root", - "version": "0.1.36", + "version": "0.1.37", "description": "Bot de wahtsapp open source para MVP o pequeños negocios", "main": "app.js", "private": true, @@ -24,7 +24,7 @@ "build:full": "pnpm run build:portal-web && pnpm run cli:rollup && pnpm run bot:rollup && pnpm run provider:rollup && pnpm run database:rollup && pnpm run contexts:rollup && pnpm run create-bot-whatsapp:rollup && pnpm run eslint-plugin:rollup && pnpm run portal:rollup", "build": "pnpm run cli:rollup && pnpm run bot:rollup && pnpm run provider:rollup && pnpm run database:rollup && pnpm run contexts:rollup && pnpm run create-bot-whatsapp:rollup && pnpm run portal:rollup && pnpm run eslint-plugin:rollup", "copy.lib": "node ./scripts/move.js", - "test.unit": "node ./node_modules/uvu/bin.js packages test", + "test.unit": "node ./node_modules/uvu/bin.js packages test -i database-json", "test.e2e": "node ./node_modules/uvu/bin.js __test__ ", "test.coverage": "node ./node_modules/c8/bin/c8.js npm run test.unit", "test": "npm run test.coverage",