@indra.ai/deva 1.5.25 → 1.5.27
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/index.js +50 -48
- package/package.json +5 -4
package/index.js
CHANGED
|
@@ -781,17 +781,17 @@ class Deva {
|
|
|
781
781
|
function or running the enter function.
|
|
782
782
|
usage: this.start('msg')
|
|
783
783
|
***************/
|
|
784
|
-
start(
|
|
785
|
-
|
|
784
|
+
start(data, resolve) {
|
|
785
|
+
this.zone('start', data.id);
|
|
786
|
+
if (!this._active) return resolve(this._messages.offline);
|
|
787
|
+
this.action('start', data.id);
|
|
786
788
|
const id = this.lib.uid();
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
delete packet.hash;
|
|
791
|
-
packet.hash = this.lib.hash(packet);
|
|
789
|
+
delete data.hash;
|
|
790
|
+
data.value = 'start';
|
|
791
|
+
data.hash = this.lib.hash(data);
|
|
792
792
|
const hasOnStart = this.onStart && typeof this.onStart === 'function' ? true : false;
|
|
793
|
-
this.state('start');
|
|
794
|
-
return hasOnStart ? this.onStart(
|
|
793
|
+
this.state('start', data.id);
|
|
794
|
+
return hasOnStart ? this.onStart(data, resolve) : this.enter(data, resolve)
|
|
795
795
|
}
|
|
796
796
|
|
|
797
797
|
/**************
|
|
@@ -805,16 +805,16 @@ class Deva {
|
|
|
805
805
|
If the Deva is offline it will return the offline message.
|
|
806
806
|
usage: this.enter('msg')
|
|
807
807
|
***************/
|
|
808
|
-
enter(
|
|
809
|
-
|
|
808
|
+
enter(data, resolve) {
|
|
809
|
+
this.zone('enter', data.id);
|
|
810
|
+
if (!this._active) return resolve(this._messages.offline);
|
|
811
|
+
this.action('enter', data.id);
|
|
810
812
|
const hasOnEnter = this.onEnter && typeof this.onEnter === 'function' ? true : false;
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
this.
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
packet.hash = this.lib.hash(packet);
|
|
817
|
-
return hasOnEnter ? this.onEnter(packet, resolve) : this.done(packet, resolve)
|
|
813
|
+
delete data.hash;
|
|
814
|
+
data.value = 'enter';
|
|
815
|
+
data.hash = this.lib.hash(data);
|
|
816
|
+
this.state('enter', data.id);
|
|
817
|
+
return hasOnEnter ? this.onEnter(data, resolve) : this.done(data, resolve)
|
|
818
818
|
}
|
|
819
819
|
|
|
820
820
|
/**************
|
|
@@ -828,16 +828,16 @@ class Deva {
|
|
|
828
828
|
If the deva is offline it will return the offline message.
|
|
829
829
|
usage: this.done('msg')
|
|
830
830
|
***************/
|
|
831
|
-
done(
|
|
832
|
-
|
|
831
|
+
done(data, resolve) {
|
|
832
|
+
this.zone('done', data.id);
|
|
833
|
+
if (!this._active) return resolve(this._messages.offline);
|
|
834
|
+
this.action('done', data.id);
|
|
833
835
|
const hasOnDone = this.onDone && typeof this.onDone === 'function' ? true : false;
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
this.
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
packet.hash = this.lib.hash(packet);
|
|
840
|
-
return hasOnDone ? this.onDone(packet, resolve) : this.ready(packet, resolve);
|
|
836
|
+
delete data.hash;
|
|
837
|
+
data.value = 'done';
|
|
838
|
+
data.hash = this.lib.hash(data);
|
|
839
|
+
this.state('done', data.id);
|
|
840
|
+
return hasOnDone ? this.onDone(data, resolve) : this.ready(data, resolve);
|
|
841
841
|
}
|
|
842
842
|
|
|
843
843
|
/**************
|
|
@@ -848,16 +848,16 @@ class Deva {
|
|
|
848
848
|
describe: This function is use to relay the to the ready state.
|
|
849
849
|
usage: this.ready(data, resolve)
|
|
850
850
|
***************/
|
|
851
|
-
ready(
|
|
852
|
-
|
|
851
|
+
ready(data, resolve) {
|
|
852
|
+
this.zone('ready', data.id);
|
|
853
|
+
if (!this._active) return resolve(this._messages.offline);
|
|
854
|
+
this.action('ready', data.id);
|
|
853
855
|
const hasOnReady = this.onReady && typeof this.onReady === 'function';
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
this.
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
packet.hash = this.lib.hash(packet);// hash the entire packet before completeing.
|
|
860
|
-
return hasOnReady ? this.onReady(packet, resolve) : resolve(packet);
|
|
856
|
+
delete data.hash;
|
|
857
|
+
data.value = 'ready';
|
|
858
|
+
data.hash = this.lib.hash(data);// hash the entire data before completeing.
|
|
859
|
+
this.state('ready', data.id);
|
|
860
|
+
return hasOnReady ? this.onReady(data, resolve) : resolve(data);
|
|
861
861
|
}
|
|
862
862
|
|
|
863
863
|
|
|
@@ -871,11 +871,14 @@ class Deva {
|
|
|
871
871
|
usage: this.finish(data, resolve)
|
|
872
872
|
***************/
|
|
873
873
|
finish(packet, resolve) {
|
|
874
|
-
|
|
874
|
+
this.zone('finish', packet.id); // enter finish zone
|
|
875
|
+
if (!this._active) return resolve(this._messages.offline); //
|
|
876
|
+
this.action('finish', packet.id); // start finish action
|
|
875
877
|
const hasOnFinish = this.onFinish && typeof this.onFinish === 'function';
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
this.
|
|
878
|
+
delete packet.hash; // delete packet hash to update for finish time
|
|
879
|
+
packet.finish = Date.now(); // set the finish timestamp
|
|
880
|
+
packet.hash = this.lib.hash(packet); // rehash the packet;
|
|
881
|
+
this.state('finish', packet.id); // set finish state
|
|
879
882
|
return hasOnFinish ? this.onFinish(packet, resolve) : this.complete(packet, resolve);
|
|
880
883
|
}
|
|
881
884
|
|
|
@@ -889,14 +892,14 @@ class Deva {
|
|
|
889
892
|
usage: this.complete(data, resolve)
|
|
890
893
|
***************/
|
|
891
894
|
complete(packet, resolve) {
|
|
892
|
-
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
893
|
-
const hasOnComplete = this.onComplete && typeof this.onComplete === 'function';
|
|
894
895
|
this.zone('complete', packet.id);
|
|
896
|
+
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
895
897
|
this.action('complete', packet.id);
|
|
896
|
-
this.
|
|
897
|
-
packet.created = Date.now();// set the complete date on the whole packet.
|
|
898
|
+
const hasOnComplete = this.onComplete && typeof this.onComplete === 'function';
|
|
898
899
|
delete packet.hash;
|
|
900
|
+
packet.complete = Date.now();// set the complete date on the whole packet.
|
|
899
901
|
packet.hash = this.lib.hash(packet);// hash the entire packet before complete.
|
|
902
|
+
this.state('complete', packet.id);
|
|
900
903
|
return hasOnComplete ? this.onComplete(packet, resolve) : resolve(packet);
|
|
901
904
|
}
|
|
902
905
|
|
|
@@ -952,7 +955,6 @@ class Deva {
|
|
|
952
955
|
const hasOnExit = this.onExit && typeof this.onExit === 'function';
|
|
953
956
|
this.zone('exit', id);
|
|
954
957
|
this.action('exit', id);
|
|
955
|
-
this.state('exit', id); // set the state to stop
|
|
956
958
|
|
|
957
959
|
const data = {
|
|
958
960
|
id,
|
|
@@ -964,6 +966,7 @@ class Deva {
|
|
|
964
966
|
}
|
|
965
967
|
data.hash = this.lib.hash(data);
|
|
966
968
|
|
|
969
|
+
this.state('exit', id); // set the state to stop
|
|
967
970
|
// clear memory
|
|
968
971
|
this._active = false;
|
|
969
972
|
this._client = false;
|
|
@@ -975,7 +978,6 @@ class Deva {
|
|
|
975
978
|
this._legal = false;
|
|
976
979
|
this._authority = false;
|
|
977
980
|
this._justice = false;
|
|
978
|
-
|
|
979
981
|
return hasOnExit ? this.onExit(data) : Promise.resolve(data)
|
|
980
982
|
}
|
|
981
983
|
|
|
@@ -1391,7 +1393,7 @@ class Deva {
|
|
|
1391
1393
|
describe: Unload a currently loaded Deva.
|
|
1392
1394
|
***************/
|
|
1393
1395
|
unload(key) {
|
|
1394
|
-
this.zone('
|
|
1396
|
+
this.zone('unload', key);
|
|
1395
1397
|
return new Promise((resolve, reject) => {
|
|
1396
1398
|
try {
|
|
1397
1399
|
this.action('uload', key);
|
|
@@ -1400,7 +1402,7 @@ class Deva {
|
|
|
1400
1402
|
this.talk(config.events.unload, key);
|
|
1401
1403
|
});
|
|
1402
1404
|
this.state('unload', key)
|
|
1403
|
-
return resolve(this._states.unload);
|
|
1405
|
+
return resolve(`${this._states.unload}:${key}`);
|
|
1404
1406
|
} catch (e) {
|
|
1405
1407
|
return this.error(e, this.devas[key], reject)
|
|
1406
1408
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@indra.ai/deva",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.27",
|
|
4
4
|
"description": "The Deva Core",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"copyright": "(c)2025 Quinn Michaels; All rights reserved.",
|
|
@@ -251,11 +251,12 @@
|
|
|
251
251
|
"message": "offline",
|
|
252
252
|
"messages": {
|
|
253
253
|
"init": "🟠 INIT",
|
|
254
|
-
"start": "🟢
|
|
254
|
+
"start": "🟢 START",
|
|
255
255
|
"enter": "🔵 ENTER",
|
|
256
|
+
"done": "🟣 DONE",
|
|
257
|
+
"ready": "⭐️ READY",
|
|
256
258
|
"stop": "🔴 STOP",
|
|
257
|
-
"exit": "
|
|
258
|
-
"done": "🟣 DONE",
|
|
259
|
+
"exit": "🚪 EXIT",
|
|
259
260
|
"offline": "⭕️ OFFLINE",
|
|
260
261
|
"noid": "⛔️ NO ID PROVIDED",
|
|
261
262
|
"notext": "⛔️ NO TEXT PROVIDED",
|