@builderbot/bot 1.1.8-alpha.1 → 1.1.9-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/index.cjs +54 -59
- package/dist/utils/queueClass.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -794,70 +794,65 @@ class Queue {
|
|
|
794
794
|
}
|
|
795
795
|
}
|
|
796
796
|
async enqueue(from, promiseInFunc, fingerIdRef) {
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
const
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
const refIdTimeOut = timer({ reject, resolve });
|
|
824
|
-
clearTimeout(this.timers.get(fingerIdRef));
|
|
825
|
-
this.timers.set(fingerIdRef, refIdTimeOut);
|
|
826
|
-
this.clearAndDone(from, item);
|
|
827
|
-
this.clearQueue(from);
|
|
828
|
-
return refIdTimeOut;
|
|
829
|
-
}
|
|
830
|
-
return this.timers.get(fingerIdRef);
|
|
831
|
-
});
|
|
832
|
-
const cancel = () => {
|
|
797
|
+
this.logger.log(`${from}: QUEUE: ${fingerIdRef}`);
|
|
798
|
+
if (!this.timers.has(fingerIdRef)) {
|
|
799
|
+
this.timers.set(fingerIdRef, false);
|
|
800
|
+
}
|
|
801
|
+
if (!this.queue.has(from)) {
|
|
802
|
+
this.queue.set(from, []);
|
|
803
|
+
this.workingOnPromise.set(from, false);
|
|
804
|
+
}
|
|
805
|
+
const queueByFrom = this.queue.get(from);
|
|
806
|
+
const workingByFrom = this.workingOnPromise.get(from);
|
|
807
|
+
/**
|
|
808
|
+
*
|
|
809
|
+
* @param item
|
|
810
|
+
* @returns
|
|
811
|
+
*/
|
|
812
|
+
const promiseFunc = (item) => {
|
|
813
|
+
const timer = ({ resolve }) => setTimeout(() => {
|
|
814
|
+
console.log('no debe aparecer si la otra funcion del race se ejecuta primero 🙉🙉🙉🙉', fingerIdRef);
|
|
815
|
+
resolve('timeout');
|
|
816
|
+
}, this.timeout);
|
|
817
|
+
const timerPromise = new Promise((resolve, reject) => {
|
|
818
|
+
if (item.cancelled) {
|
|
819
|
+
reject('cancelled');
|
|
820
|
+
}
|
|
821
|
+
if (!this.timers.has(fingerIdRef)) {
|
|
822
|
+
const refIdTimeOut = timer({ reject, resolve });
|
|
833
823
|
clearTimeout(this.timers.get(fingerIdRef));
|
|
834
|
-
this.timers.
|
|
824
|
+
this.timers.set(fingerIdRef, refIdTimeOut);
|
|
835
825
|
this.clearAndDone(from, item);
|
|
836
|
-
};
|
|
837
|
-
return { promiseInFunc, timer, timerPromise, cancel };
|
|
838
|
-
};
|
|
839
|
-
return new Promise((resolve, reject) => {
|
|
840
|
-
const pid = queueByFrom.findIndex((i) => i.fingerIdRef === fingerIdRef);
|
|
841
|
-
if (pid !== -1) {
|
|
842
826
|
this.clearQueue(from);
|
|
827
|
+
return refIdTimeOut;
|
|
843
828
|
}
|
|
844
|
-
|
|
845
|
-
promiseFunc,
|
|
846
|
-
fingerIdRef,
|
|
847
|
-
cancelled: false,
|
|
848
|
-
resolve,
|
|
849
|
-
reject,
|
|
850
|
-
});
|
|
851
|
-
if (!workingByFrom) {
|
|
852
|
-
this.logger.log(`${from}: EXECUTING: ${fingerIdRef}`);
|
|
853
|
-
this.processQueue(from);
|
|
854
|
-
this.workingOnPromise.set(from, true);
|
|
855
|
-
}
|
|
829
|
+
return this.timers.get(fingerIdRef);
|
|
856
830
|
});
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
831
|
+
const cancel = () => {
|
|
832
|
+
clearTimeout(this.timers.get(fingerIdRef));
|
|
833
|
+
this.timers.delete(fingerIdRef);
|
|
834
|
+
this.clearAndDone(from, item);
|
|
835
|
+
};
|
|
836
|
+
return { promiseInFunc, timer, timerPromise, cancel };
|
|
837
|
+
};
|
|
838
|
+
return new Promise((resolve, reject) => {
|
|
839
|
+
const pid = queueByFrom.findIndex((i) => i.fingerIdRef === fingerIdRef);
|
|
840
|
+
if (pid !== -1) {
|
|
841
|
+
this.clearQueue(from);
|
|
842
|
+
}
|
|
843
|
+
queueByFrom.push({
|
|
844
|
+
promiseFunc,
|
|
845
|
+
fingerIdRef,
|
|
846
|
+
cancelled: false,
|
|
847
|
+
resolve,
|
|
848
|
+
reject,
|
|
849
|
+
});
|
|
850
|
+
if (!workingByFrom) {
|
|
851
|
+
this.logger.log(`${from}: EXECUTING: ${fingerIdRef}`);
|
|
852
|
+
this.processQueue(from);
|
|
853
|
+
this.workingOnPromise.set(from, true);
|
|
854
|
+
}
|
|
855
|
+
});
|
|
861
856
|
}
|
|
862
857
|
async processQueue(from) {
|
|
863
858
|
const queueByFrom = this.queue.get(from);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queueClass.d.ts","sourceRoot":"","sources":["../../src/utils/queueClass.ts"],"names":[],"mappings":"AAAA,KAAK,MAAM,GAAG,OAAO,CAAA;AAiBrB,cAAM,KAAK,CAAC,CAAC;IACT,OAAO,CAAC,KAAK,CAA6B;IAC1C,OAAO,CAAC,MAAM,CAAuC;IACrD,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,gBAAgB,CAAsB;IAC9C,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,gBAAgB,CAAQ;gBAEpB,MAAM,EAAE,MAAM,EAAE,gBAAgB,SAAK,EAAE,OAAO,SAAQ;IAUlE;;;;OAIG;IACI,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;QAAE,WAAW,EAA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BAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI;CAUtD;AAED,OAAO,EAAE,KAAK,EAAE,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builderbot/bot",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9-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",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"optionalDependencies": {
|
|
63
63
|
"sharp": "0.33.3"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "ff18d72bd95d0f5aa946c3a493a6fe6182afe649"
|
|
66
66
|
}
|