@builderbot/bot 1.1.7 → 1.1.8-alpha.1
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 +59 -54
- package/dist/utils/queueClass.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -794,65 +794,70 @@ class Queue {
|
|
|
794
794
|
}
|
|
795
795
|
}
|
|
796
796
|
async enqueue(from, promiseInFunc, fingerIdRef) {
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
this.timers.
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
this.queue.
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
const
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
797
|
+
try {
|
|
798
|
+
this.logger.log(`${from}: QUEUE: ${fingerIdRef}`);
|
|
799
|
+
if (!this.timers.has(fingerIdRef)) {
|
|
800
|
+
this.timers.set(fingerIdRef, false);
|
|
801
|
+
}
|
|
802
|
+
if (!this.queue.has(from)) {
|
|
803
|
+
this.queue.set(from, []);
|
|
804
|
+
this.workingOnPromise.set(from, false);
|
|
805
|
+
}
|
|
806
|
+
const queueByFrom = this.queue.get(from);
|
|
807
|
+
const workingByFrom = this.workingOnPromise.get(from);
|
|
808
|
+
/**
|
|
809
|
+
*
|
|
810
|
+
* @param item
|
|
811
|
+
* @returns
|
|
812
|
+
*/
|
|
813
|
+
const promiseFunc = (item) => {
|
|
814
|
+
const timer = ({ resolve }) => setTimeout(() => {
|
|
815
|
+
console.log('no debe aparecer si la otra funcion del race se ejecuta primero 🙉🙉🙉🙉', fingerIdRef);
|
|
816
|
+
resolve('timeout');
|
|
817
|
+
}, this.timeout);
|
|
818
|
+
const timerPromise = new Promise((resolve, reject) => {
|
|
819
|
+
if (item.cancelled) {
|
|
820
|
+
reject('cancelled');
|
|
821
|
+
}
|
|
822
|
+
if (!this.timers.has(fingerIdRef)) {
|
|
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 = () => {
|
|
823
833
|
clearTimeout(this.timers.get(fingerIdRef));
|
|
824
|
-
this.timers.
|
|
834
|
+
this.timers.delete(fingerIdRef);
|
|
825
835
|
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) {
|
|
826
842
|
this.clearQueue(from);
|
|
827
|
-
return refIdTimeOut;
|
|
828
843
|
}
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
this.clearQueue(from);
|
|
842
|
-
}
|
|
843
|
-
queueByFrom.push({
|
|
844
|
-
promiseFunc,
|
|
845
|
-
fingerIdRef,
|
|
846
|
-
cancelled: false,
|
|
847
|
-
resolve,
|
|
848
|
-
reject,
|
|
844
|
+
queueByFrom.push({
|
|
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
|
+
}
|
|
849
856
|
});
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
}
|
|
855
|
-
});
|
|
857
|
+
}
|
|
858
|
+
catch (e) {
|
|
859
|
+
this.logger.log(`${from}: CLEAN QUEUE: ${fingerIdRef}`);
|
|
860
|
+
}
|
|
856
861
|
}
|
|
857
862
|
async processQueue(from) {
|
|
858
863
|
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,EAAE,MAAM,CAAA;KAAE;YAKjD,WAAW;IAkBnB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"queueClass.d.ts","sourceRoot":"","sources":["../../src/utils/queueClass.ts"],"names":[],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
|
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": "a4d2042e860cf6e982f1b7ffb652f41ea68183b1"
|
|
66
66
|
}
|