@builderbot/bot 1.0.5-alpha.0 → 1.0.6-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core/coreClass.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { EventEmitter } from 'node:events';
|
|
3
|
-
import { DispatchFn, DynamicBlacklist } from './../types';
|
|
3
|
+
import { DispatchFn, DynamicBlacklist, TContext } from './../types';
|
|
4
4
|
import { GlobalState, SingleState } from '../context';
|
|
5
5
|
import { MemoryDB } from '../db';
|
|
6
6
|
import FlowClass from '../io/flowClass';
|
|
@@ -40,14 +40,14 @@ declare class CoreClass<P extends ProviderClass = any, D extends MemoryDB = any>
|
|
|
40
40
|
capture: boolean;
|
|
41
41
|
delay: number;
|
|
42
42
|
keyword: null;
|
|
43
|
-
}, index?: number) =>
|
|
43
|
+
}, index?: number) => TContext;
|
|
44
44
|
clearQueue: () => void;
|
|
45
45
|
endFlow: (flag: {
|
|
46
46
|
endFlow: any;
|
|
47
47
|
fallBack?: boolean;
|
|
48
48
|
flowDynamic?: boolean;
|
|
49
49
|
gotoFlow?: boolean;
|
|
50
|
-
}) => (message?: any) => Promise<void>;
|
|
50
|
+
}, inRef: string | number) => (message?: any) => Promise<void>;
|
|
51
51
|
sendFlow: (messageToSend: any[], numberOrId: string, options?: {
|
|
52
52
|
[key: string]: any;
|
|
53
53
|
}) => Promise<void>;
|
|
@@ -108,7 +108,7 @@ declare class CoreClass<P extends ProviderClass = any, D extends MemoryDB = any>
|
|
|
108
108
|
* @param {*} ctxMessage ver más en GLOSSARY.md
|
|
109
109
|
* @returns
|
|
110
110
|
*/
|
|
111
|
-
sendProviderAndSave: (numberOrId: string, ctxMessage:
|
|
111
|
+
sendProviderAndSave: (numberOrId: string, ctxMessage: TContext) => Promise<void>;
|
|
112
112
|
/**
|
|
113
113
|
* Funcion dedicada a enviar el mensaje sin pasar por el flow
|
|
114
114
|
* (dialogflow)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreClass.d.ts","sourceRoot":"","sources":["../../src/core/coreClass.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"coreClass.d.ts","sourceRoot":"","sources":["../../src/core/coreClass.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACnE,OAAO,EAAE,WAAW,EAAa,WAAW,EAAE,MAAM,YAAY,CAAA;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,SAAS,MAAM,iBAAiB,CAAA;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAClF,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAUtC,KAAK,aAAa,GAAG,CAAC,GAAG,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAA;AAI5E,cAAM,SAAS,CAAC,CAAC,SAAS,aAAa,GAAG,GAAG,EAAE,CAAC,SAAS,QAAQ,GAAG,GAAG,CAAE,SAAQ,YAAY;IACzF,SAAS,EAAE,SAAS,CAAA;IACpB,QAAQ,EAAE,CAAC,CAAA;IACX,QAAQ,EAAE,CAAC,CAAA;IACX,cAAc,EAAE,KAAK,CAAC,OAAO,CAAC,C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kBAAyB,GAAG,cAAc,GAAG;;;;OAY1D;IAED;;OAEG;IACH,UAAU,SAAU,MAAM,UAIzB;IAED;;;;OAIG;IACH,SAAS,mBAGK,CAAC,KAAK,OAAO,IAAI,CAAC,QAAQ,EAAE,aAAa,GAAG,QAAQ,CAAC,GAAG;QACtD,QAAQ,EAAE,OAAO,IAAI,CAAC,QAAQ,CAAA;QAC9B,SAAS,EAAE,gBAAgB,CAAA;QAC3B,QAAQ,EAAE,UAAU,CAAA;KACvB,CAAC,GACA,SAAS,OACV,GAAG,OACH,GAAG,KACP,QAAQ,IAAI,CAAC,iCACkB;CAC3C;AACD,OAAO,EAAE,SAAS,EAAE,CAAA"}
|
package/dist/index.cjs
CHANGED
|
@@ -13907,11 +13907,16 @@ class CoreClass extends node_events.EventEmitter {
|
|
|
13907
13907
|
return;
|
|
13908
13908
|
};
|
|
13909
13909
|
// 📄 Finalizar flujo
|
|
13910
|
-
const endFlow = (flag) => async (message = null) => {
|
|
13910
|
+
const endFlow = (flag, inRef) => async (message = null) => {
|
|
13911
13911
|
flag.endFlow = true;
|
|
13912
13912
|
endFlowFlag = true;
|
|
13913
|
-
if (message)
|
|
13914
|
-
this.sendProviderAndSave(from, createCtxMessage(message))
|
|
13913
|
+
if (message) {
|
|
13914
|
+
this.sendProviderAndSave(from, createCtxMessage(message))
|
|
13915
|
+
.then(() => this.sendProviderAndSave(from, createCtxMessage({ ...message, keyword: `${inRef}`, answer: '__end_flow__' })));
|
|
13916
|
+
}
|
|
13917
|
+
else {
|
|
13918
|
+
this.sendProviderAndSave(from, createCtxMessage({ ...message, keyword: `${inRef}`, answer: '__end_flow__' }));
|
|
13919
|
+
}
|
|
13915
13920
|
clearQueue();
|
|
13916
13921
|
return;
|
|
13917
13922
|
};
|
|
@@ -14144,7 +14149,7 @@ class CoreClass extends node_events.EventEmitter {
|
|
|
14144
14149
|
inRef,
|
|
14145
14150
|
fallBack: fallBack(flags),
|
|
14146
14151
|
flowDynamic: flowDynamic(flags, inRef, options),
|
|
14147
|
-
endFlow: endFlow(flags),
|
|
14152
|
+
endFlow: endFlow(flags, inRef),
|
|
14148
14153
|
gotoFlow: gotoFlow(flags),
|
|
14149
14154
|
};
|
|
14150
14155
|
const runContext = async (continueAfterIdle = false, overCtx = {}) => {
|
|
@@ -14255,7 +14260,7 @@ class CoreClass extends node_events.EventEmitter {
|
|
|
14255
14260
|
this.sendProviderAndSave = async (numberOrId, ctxMessage) => {
|
|
14256
14261
|
try {
|
|
14257
14262
|
const { answer } = ctxMessage;
|
|
14258
|
-
if (answer && answer.length && answer !== '__call_action__' && answer !== '__goto_flow__') {
|
|
14263
|
+
if (answer && answer.length && answer !== '__call_action__' && answer !== '__goto_flow__' && answer !== '__end_flow__') {
|
|
14259
14264
|
if (answer !== '__capture_only_intended__') {
|
|
14260
14265
|
await this.provider.sendMessage(numberOrId, answer, ctxMessage);
|
|
14261
14266
|
this.emit('send_message', { numberOrId, answer, ctxMessage });
|
|
@@ -14392,8 +14397,9 @@ class FlowClass {
|
|
|
14392
14397
|
findIn(keyOrWord, symbol, overFlow);
|
|
14393
14398
|
return messages;
|
|
14394
14399
|
}
|
|
14395
|
-
findBySerialize(refSerialize) {
|
|
14396
|
-
|
|
14400
|
+
findBySerialize(refSerialize, k = 0) {
|
|
14401
|
+
const index = this.flowSerialize.findIndex((r) => r.refSerialize === refSerialize);
|
|
14402
|
+
return this.flowSerialize[index - k];
|
|
14397
14403
|
}
|
|
14398
14404
|
findIndexByRef(ref) {
|
|
14399
14405
|
return this.flowSerialize.findIndex((r) => r.ref === ref);
|
package/dist/io/flowClass.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ declare class FlowClass {
|
|
|
9
9
|
flowRaw: TFlow[];
|
|
10
10
|
constructor(_flow: TFlow[]);
|
|
11
11
|
find(keyOrWord: string, symbol?: boolean, overFlow?: TContext[] | null): TContext[];
|
|
12
|
-
findBySerialize(refSerialize: string): TContext | undefined;
|
|
12
|
+
findBySerialize(refSerialize: string, k?: number): TContext | undefined;
|
|
13
13
|
findIndexByRef(ref: string): number;
|
|
14
14
|
findSerializeByRef(ref: string): TContext | undefined;
|
|
15
15
|
findSerializeByKeyword(keyword: string): TContext | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowClass.d.ts","sourceRoot":"","sources":["../../src/io/flowClass.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAG1C;;;GAGG;AACH,cAAM,SAAS;IACX,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IACtC,aAAa,EAAE,QAAQ,EAAE,CAAA;IACzB,OAAO,EAAE,KAAK,EAAE,CAAA;gBAEJ,KAAK,EAAE,KAAK,EAAE;IAW1B,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,GAAE,OAAe,EAAE,QAAQ,GAAE,QAAQ,EAAE,GAAG,IAAW,GAAG,QAAQ,EAAE;IAuChG,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS;
|
|
1
|
+
{"version":3,"file":"flowClass.d.ts","sourceRoot":"","sources":["../../src/io/flowClass.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAG1C;;;GAGG;AACH,cAAM,SAAS;IACX,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IACtC,aAAa,EAAE,QAAQ,EAAE,CAAA;IACzB,OAAO,EAAE,KAAK,EAAE,CAAA;gBAEJ,KAAK,EAAE,KAAK,EAAE;IAW1B,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,GAAE,OAAe,EAAE,QAAQ,GAAE,QAAQ,EAAE,GAAG,IAAW,GAAG,QAAQ,EAAE;IAuChG,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC,GAAE,MAAU,GAAG,QAAQ,GAAG,SAAS;IAK1E,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAInC,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS;IAIrD,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS;IAI7D,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS;IAa5D,aAAa,IAAI,QAAQ,EAAE;CAc9B;AAED,eAAe,SAAS,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builderbot/bot",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6-alpha.0",
|
|
4
4
|
"description": "core typescript",
|
|
5
5
|
"author": "Leifer Mendez <leifer33@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/codigoencasa/bot-whatsapp#readme",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"type": "module",
|
|
11
11
|
"scripts": {
|
|
12
12
|
"build": "rimraf dist && rollup --config",
|
|
13
|
-
"test": " npx uvu -r tsm ./__tests__",
|
|
14
|
-
"test:coverage": "npx c8 npm run test",
|
|
13
|
+
"test": " npx uvu -r tsm ./__tests__ ",
|
|
14
|
+
"test:coverage": "npx c8 npm run test ",
|
|
15
15
|
"test:debug": " npx uvu -r tsm ./__tests__ 0.2.2-case.test.ts"
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"picocolors": "^1.0.0",
|
|
57
57
|
"sharp": "^0.33.2"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "9cd1ff8449da3b51524262012fcf8376b29f0747"
|
|
60
60
|
}
|