@indra.ai/deva 1.3.11 → 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.
- package/index.js +42 -87
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -24,8 +24,7 @@ class Deva {
|
|
|
24
24
|
this._networks = false; // inherited Systems features.
|
|
25
25
|
this._legal = false; // inherited Legal features.
|
|
26
26
|
this._justice = false; // inherited Justice features.
|
|
27
|
-
this._authority = false; // inherited
|
|
28
|
-
this._defense = false; // inherited Defense features.
|
|
27
|
+
this._authority = false; // inherited Justice features.
|
|
29
28
|
this.events = opts.events || new EventEmitter({}); // Event Bus
|
|
30
29
|
this.lib = new lib({}); // used for loading library functions
|
|
31
30
|
this.utils = opts.utils || {}; // parse function
|
|
@@ -343,28 +342,16 @@ class Deva {
|
|
|
343
342
|
return this.Feature('authority', resolve, reject);
|
|
344
343
|
}
|
|
345
344
|
|
|
346
|
-
/**************
|
|
347
|
-
func: Defense
|
|
348
|
-
params: client: false
|
|
349
|
-
describe:
|
|
350
|
-
The Defense feature sets the correct variables and necessary rules for the
|
|
351
|
-
client presented data.
|
|
352
|
-
***************/
|
|
353
|
-
Defense(resolve, reject) {
|
|
354
|
-
return this.Feature('defense', resolve, reject);
|
|
355
|
-
}
|
|
356
|
-
|
|
357
345
|
/**************
|
|
358
346
|
func: Done
|
|
359
347
|
params: none
|
|
360
348
|
describe: The end of the workflow Client Feature Workflow
|
|
361
349
|
***************/
|
|
362
350
|
Done(resolve, reject) {
|
|
363
|
-
this.action('done'
|
|
351
|
+
this.action('done');
|
|
364
352
|
try {
|
|
365
|
-
this.state('
|
|
353
|
+
this.state('Done');
|
|
366
354
|
delete this._client.features; // delete the features key when done.
|
|
367
|
-
this.state('resolve', 'init');
|
|
368
355
|
return resolve(this.client()); // resolve an empty pr
|
|
369
356
|
} catch (e) {
|
|
370
357
|
this.state('reject', 'Done');
|
|
@@ -694,10 +681,14 @@ class Deva {
|
|
|
694
681
|
}).then(() => {
|
|
695
682
|
return this._assignListeners();
|
|
696
683
|
}).then(() => {
|
|
684
|
+
this.feature('init');
|
|
685
|
+
this.zone('init');
|
|
686
|
+
this.action('init');
|
|
687
|
+
this.state('init');
|
|
697
688
|
return this.Client(client, resolve, reject);
|
|
698
|
-
}).then(
|
|
689
|
+
}).then(() => {
|
|
699
690
|
return this.Security(resolve, reject);
|
|
700
|
-
}).then(
|
|
691
|
+
}).then(() => {
|
|
701
692
|
return this.Support(resolve, reject);
|
|
702
693
|
}).then(() => {
|
|
703
694
|
return this.Services(resolve, reject);
|
|
@@ -707,12 +698,10 @@ class Deva {
|
|
|
707
698
|
return this.Networks(resolve, reject);
|
|
708
699
|
}).then(() => {
|
|
709
700
|
return this.Legal(resolve, reject);
|
|
710
|
-
}).then(() => {
|
|
711
|
-
return this.Authority(resolve, reject);
|
|
712
701
|
}).then(() => {
|
|
713
702
|
return this.Justice(resolve, reject);
|
|
714
703
|
}).then(() => {
|
|
715
|
-
return this.
|
|
704
|
+
return this.Authority(resolve, reject);
|
|
716
705
|
}).then(() => {
|
|
717
706
|
return this.Done(resolve, reject);
|
|
718
707
|
}).then(() => {
|
|
@@ -758,7 +747,7 @@ class Deva {
|
|
|
758
747
|
usage: this.enter('msg')
|
|
759
748
|
***************/
|
|
760
749
|
enter(data, resolve) {
|
|
761
|
-
this.zone('
|
|
750
|
+
this.zone('deva');
|
|
762
751
|
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
763
752
|
this.action('enter');
|
|
764
753
|
data.value = 'enter';
|
|
@@ -788,9 +777,35 @@ class Deva {
|
|
|
788
777
|
data.hash = this.lib.hash(data);
|
|
789
778
|
const hasOnDone = this.onDone && typeof this.onDone === 'function' ? true : false;
|
|
790
779
|
this.state('done');
|
|
791
|
-
return hasOnDone ? this.onDone(data, resolve) : this.
|
|
780
|
+
return hasOnDone ? this.onDone(data, resolve) : this.ready(data, resolve);
|
|
792
781
|
}
|
|
793
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);
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
|
|
794
809
|
/**************
|
|
795
810
|
func: finish
|
|
796
811
|
params:
|
|
@@ -834,33 +849,9 @@ class Deva {
|
|
|
834
849
|
// if: agent has on complete then return on complete
|
|
835
850
|
this.state('complete'); // set the finish state
|
|
836
851
|
// return the provided resolve function or a promise resolve.
|
|
837
|
-
return hasOnComplete ? this.onComplete(packet) :
|
|
852
|
+
return hasOnComplete ? this.onComplete(packet) : resolve(packet);
|
|
838
853
|
}
|
|
839
854
|
|
|
840
|
-
/**************
|
|
841
|
-
func: ready
|
|
842
|
-
params:
|
|
843
|
-
- packet: the data to pass to the resolve
|
|
844
|
-
- resolve: the complete resolve to pass back
|
|
845
|
-
describe: This function is use to relay the Agent ito a complete state when
|
|
846
|
-
resolving a question or data.
|
|
847
|
-
usage: this.complete(data, resolve)
|
|
848
|
-
***************/
|
|
849
|
-
ready(packet, resolve) {
|
|
850
|
-
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
851
|
-
this.action('ready'); // set the complete action
|
|
852
|
-
|
|
853
|
-
packet.hash = this.lib.hash(packet);// hash the entire packet before completeing.
|
|
854
|
-
// check for agent on complete function in agent
|
|
855
|
-
const hasOnReady = this.onReady && typeof this.onReady === 'function';
|
|
856
|
-
|
|
857
|
-
// if: agent has on complete then return on complete
|
|
858
|
-
this.state('ready'); // set the finish state
|
|
859
|
-
|
|
860
|
-
// return the provided resolve function or a promise resolve.
|
|
861
|
-
return hasOnReady ? this.onReady(packet, resolve) : resolve(packet);
|
|
862
|
-
}
|
|
863
|
-
|
|
864
855
|
/**************
|
|
865
856
|
func: stop
|
|
866
857
|
params:
|
|
@@ -1274,29 +1265,11 @@ class Deva {
|
|
|
1274
1265
|
}
|
|
1275
1266
|
}
|
|
1276
1267
|
|
|
1277
|
-
/**************
|
|
1278
|
-
func: networks
|
|
1279
|
-
params: none
|
|
1280
|
-
describe: basic networks features available in a Deva.
|
|
1281
|
-
usage: this.networks()
|
|
1282
|
-
***************/
|
|
1283
|
-
networks() {
|
|
1284
|
-
if (!this._active) return this._messages.offline; // check the active status
|
|
1285
|
-
this.zone('networks');
|
|
1286
|
-
this.feature('networks'); // set the support state
|
|
1287
|
-
try {
|
|
1288
|
-
this.state('return', 'networks'); // set the networks state
|
|
1289
|
-
return this.lib.copy(this._networks); // return the systems feature
|
|
1290
|
-
} catch (e) {
|
|
1291
|
-
return this.error(e); // return this.error when error catch
|
|
1292
|
-
}
|
|
1293
|
-
}
|
|
1294
|
-
|
|
1295
1268
|
/**************
|
|
1296
1269
|
func: legal
|
|
1297
1270
|
params: none
|
|
1298
1271
|
describe: basic legal features available in a Deva.
|
|
1299
|
-
usage: this.
|
|
1272
|
+
usage: this.systems()
|
|
1300
1273
|
***************/
|
|
1301
1274
|
legal() {
|
|
1302
1275
|
if (!this._active) return this._messages.offline; // check the active status
|
|
@@ -1314,7 +1287,7 @@ class Deva {
|
|
|
1314
1287
|
func: justice
|
|
1315
1288
|
params: none
|
|
1316
1289
|
describe: basic justice features available in a Deva.
|
|
1317
|
-
usage: this.
|
|
1290
|
+
usage: this.systems()
|
|
1318
1291
|
***************/
|
|
1319
1292
|
justice() {
|
|
1320
1293
|
if (!this._active) return this._messages.offline; // check the active status
|
|
@@ -1332,7 +1305,7 @@ class Deva {
|
|
|
1332
1305
|
func: authority
|
|
1333
1306
|
params: none
|
|
1334
1307
|
describe: basic authority features available in a Deva.
|
|
1335
|
-
usage: this.
|
|
1308
|
+
usage: this.systems()
|
|
1336
1309
|
***************/
|
|
1337
1310
|
authority() {
|
|
1338
1311
|
if (!this._active) return this._messages.offline; // check the active status
|
|
@@ -1346,24 +1319,6 @@ class Deva {
|
|
|
1346
1319
|
}
|
|
1347
1320
|
}
|
|
1348
1321
|
|
|
1349
|
-
/**************
|
|
1350
|
-
func: defense
|
|
1351
|
-
params: none
|
|
1352
|
-
describe: basic defense features available in a Deva.
|
|
1353
|
-
usage: this.defense()
|
|
1354
|
-
***************/
|
|
1355
|
-
defense() {
|
|
1356
|
-
if (!this._active) return this._messages.offline; // check the active status
|
|
1357
|
-
this.zone('defense');
|
|
1358
|
-
this.feature('defense'); // set the support state
|
|
1359
|
-
try {
|
|
1360
|
-
this.state('return', 'defense'); // set the systems state
|
|
1361
|
-
return this.lib.copy(this._defense); // return the systems feature
|
|
1362
|
-
} catch (e) {
|
|
1363
|
-
return this.error(e); // return this.error when error catch
|
|
1364
|
-
}
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
1322
|
/**************
|
|
1368
1323
|
func: load
|
|
1369
1324
|
params:
|