@indra.ai/deva 1.3.12 → 1.3.13

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.
Files changed (2) hide show
  1. package/index.js +34 -55
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -348,11 +348,10 @@ class Deva {
348
348
  describe: The end of the workflow Client Feature Workflow
349
349
  ***************/
350
350
  Done(resolve, reject) {
351
- this.action('done', 'init');
351
+ this.action('done');
352
352
  try {
353
- this.state('secure', 'data');
353
+ this.state('Done');
354
354
  delete this._client.features; // delete the features key when done.
355
- this.state('resolve', 'init');
356
355
  return resolve(this.client()); // resolve an empty pr
357
356
  } catch (e) {
358
357
  this.state('reject', 'Done');
@@ -687,45 +686,23 @@ class Deva {
687
686
  this.action('init');
688
687
  this.state('init');
689
688
  return this.Client(client, resolve, reject);
690
- }).then(part => {
691
- this.state('done', 'client');
692
- this.action('done', 'client');
689
+ }).then(() => {
693
690
  return this.Security(resolve, reject);
694
- }).then(part => {
695
- this.state('done', 'security');
696
- this.action('done', 'security');
691
+ }).then(() => {
697
692
  return this.Support(resolve, reject);
698
693
  }).then(() => {
699
- this.state('done', 'support');
700
- this.action('done', 'support');
701
694
  return this.Services(resolve, reject);
702
695
  }).then(() => {
703
- this.state('done', 'services');
704
- this.action('done', 'services');
705
696
  return this.Systems(resolve, reject);
706
697
  }).then(() => {
707
- this.state('done', 'systems');
708
- this.action('done', 'systems');
709
698
  return this.Networks(resolve, reject);
710
699
  }).then(() => {
711
- this.state('done', 'networks');
712
- this.action('done', 'networks');
713
700
  return this.Legal(resolve, reject);
714
701
  }).then(() => {
715
- this.state('done', 'legal');
716
- this.action('done', 'legal');
717
- return this.Authority(resolve, reject);
718
- }).then(() => {
719
- this.state('done', 'authority');
720
- this.action('done', 'authority');
721
702
  return this.Justice(resolve, reject);
722
703
  }).then(() => {
723
- this.state('done', 'justice');
724
- this.action('done', 'justice');
725
- return this.Defense(resolve, reject);
704
+ return this.Authority(resolve, reject);
726
705
  }).then(() => {
727
- this.state('done', 'defense');
728
- this.action('done', 'defense');
729
706
  return this.Done(resolve, reject);
730
707
  }).then(() => {
731
708
  const hasOnInit = this.onInit && typeof this.onInit === 'function';
@@ -770,7 +747,7 @@ class Deva {
770
747
  usage: this.enter('msg')
771
748
  ***************/
772
749
  enter(data, resolve) {
773
- this.zone('enter');
750
+ this.zone('deva');
774
751
  if (!this._active) return Promise.resolve(this._messages.offline);
775
752
  this.action('enter');
776
753
  data.value = 'enter';
@@ -800,8 +777,34 @@ class Deva {
800
777
  data.hash = this.lib.hash(data);
801
778
  const hasOnDone = this.onDone && typeof this.onDone === 'function' ? true : false;
802
779
  this.state('done');
803
- return hasOnDone ? this.onDone(data, resolve) : this.finish(data, resolve);
780
+ return hasOnDone ? this.onDone(data, resolve) : this.ready(data, resolve);
781
+ }
782
+
783
+ /**************
784
+ func: ready
785
+ params:
786
+ - packet: the data to pass to the resolve
787
+ - resolve: the complete resolve to pass back
788
+ describe: This function is use to relay the Agent ito a complete state when
789
+ resolving a question or data.
790
+ usage: this.complete(data, resolve)
791
+ ***************/
792
+ ready(packet, resolve) {
793
+ if (!this._active) return Promise.resolve(this._messages.offline);
794
+ this.action('ready'); // set the complete action
795
+
796
+ packet.hash = this.lib.hash(packet);// hash the entire packet before completeing.
797
+ // check for agent on complete function in agent
798
+ const hasOnReady = this.onReady && typeof this.onReady === 'function';
799
+
800
+ // if: agent has on complete then return on complete
801
+ this.state('ready'); // set the finish state
802
+
803
+ // return the provided resolve function or a promise resolve.
804
+ return hasOnReady ? this.onReady(packet, resolve) : resolve(packet);
804
805
  }
806
+
807
+
805
808
 
806
809
  /**************
807
810
  func: finish
@@ -846,33 +849,9 @@ class Deva {
846
849
  // if: agent has on complete then return on complete
847
850
  this.state('complete'); // set the finish state
848
851
  // return the provided resolve function or a promise resolve.
849
- return hasOnComplete ? this.onComplete(packet) : this.ready(packet, resolve);
852
+ return hasOnComplete ? this.onComplete(packet) : resolve(packet);
850
853
  }
851
854
 
852
- /**************
853
- func: ready
854
- params:
855
- - packet: the data to pass to the resolve
856
- - resolve: the complete resolve to pass back
857
- describe: This function is use to relay the Agent ito a complete state when
858
- resolving a question or data.
859
- usage: this.complete(data, resolve)
860
- ***************/
861
- ready(packet, resolve) {
862
- if (!this._active) return Promise.resolve(this._messages.offline);
863
- this.action('ready'); // set the complete action
864
-
865
- packet.hash = this.lib.hash(packet);// hash the entire packet before completeing.
866
- // check for agent on complete function in agent
867
- const hasOnReady = this.onReady && typeof this.onReady === 'function';
868
-
869
- // if: agent has on complete then return on complete
870
- this.state('ready'); // set the finish state
871
-
872
- // return the provided resolve function or a promise resolve.
873
- return hasOnReady ? this.onReady(packet, resolve) : resolve(packet);
874
- }
875
-
876
855
  /**************
877
856
  func: stop
878
857
  params:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indra.ai/deva",
3
- "version": "1.3.12",
3
+ "version": "1.3.13",
4
4
  "description": "The Deva Core",
5
5
  "main": "index.js",
6
6
  "type": "module",