@indra.ai/deva 1.3.14 → 1.4.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/index.js +44 -14
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -18,6 +18,7 @@ class Deva {
|
|
|
18
18
|
this._client = {}; // this will be set on init.
|
|
19
19
|
this._active = false; // the active/birth date.
|
|
20
20
|
this._security = false; // inherited Security features.
|
|
21
|
+
this._defense = false; // inherited Security features.
|
|
21
22
|
this._support = false; // inherited Support features.
|
|
22
23
|
this._services = false; // inherited Service features.
|
|
23
24
|
this._systems = false; // inherited Systems features.
|
|
@@ -265,6 +266,17 @@ class Deva {
|
|
|
265
266
|
return this.Feature('security', resolve, reject);
|
|
266
267
|
}
|
|
267
268
|
|
|
269
|
+
/**************
|
|
270
|
+
func: Defense
|
|
271
|
+
params: client: false
|
|
272
|
+
describe:
|
|
273
|
+
The Defense feature sets the correct variables and necessary rules for the
|
|
274
|
+
client presented data.
|
|
275
|
+
***************/
|
|
276
|
+
Defense(resolve, reject) {
|
|
277
|
+
return this.Feature('defense', resolve, reject);
|
|
278
|
+
}
|
|
279
|
+
|
|
268
280
|
/**************
|
|
269
281
|
func: Support
|
|
270
282
|
params: client: false
|
|
@@ -688,6 +700,14 @@ class Deva {
|
|
|
688
700
|
return this.Client(client, resolve, reject);
|
|
689
701
|
}).then(() => {
|
|
690
702
|
return this.Security(resolve, reject);
|
|
703
|
+
}).then(() => {
|
|
704
|
+
return this.Defense(resolve, reject);
|
|
705
|
+
}).then(() => {
|
|
706
|
+
return this.Legal(resolve, reject);
|
|
707
|
+
}).then(() => {
|
|
708
|
+
return this.Authority(resolve, reject);
|
|
709
|
+
}).then(() => {
|
|
710
|
+
return this.Justice(resolve, reject);
|
|
691
711
|
}).then(() => {
|
|
692
712
|
return this.Support(resolve, reject);
|
|
693
713
|
}).then(() => {
|
|
@@ -696,12 +716,6 @@ class Deva {
|
|
|
696
716
|
return this.Systems(resolve, reject);
|
|
697
717
|
}).then(() => {
|
|
698
718
|
return this.Networks(resolve, reject);
|
|
699
|
-
}).then(() => {
|
|
700
|
-
return this.Legal(resolve, reject);
|
|
701
|
-
}).then(() => {
|
|
702
|
-
return this.Justice(resolve, reject);
|
|
703
|
-
}).then(() => {
|
|
704
|
-
return this.Authority(resolve, reject);
|
|
705
719
|
}).then(() => {
|
|
706
720
|
return this.Done(resolve, reject);
|
|
707
721
|
}).then(() => {
|
|
@@ -785,9 +799,8 @@ class Deva {
|
|
|
785
799
|
params:
|
|
786
800
|
- packet: the data to pass to the resolve
|
|
787
801
|
- resolve: the complete resolve to pass back
|
|
788
|
-
describe: This function is use to relay the
|
|
789
|
-
|
|
790
|
-
usage: this.complete(data, resolve)
|
|
802
|
+
describe: This function is use to relay the to the ready state.
|
|
803
|
+
usage: this.ready(data, resolve)
|
|
791
804
|
***************/
|
|
792
805
|
ready(packet, resolve) {
|
|
793
806
|
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
@@ -811,8 +824,7 @@ class Deva {
|
|
|
811
824
|
params:
|
|
812
825
|
- packet: the data to pass to the resolve
|
|
813
826
|
- resolve: the finish resolve to pass back
|
|
814
|
-
describe: This function is
|
|
815
|
-
resolving a question or data.
|
|
827
|
+
describe: This function is used to relay into the finish state when resolving a question or data.
|
|
816
828
|
usage: this.finish(data, resolve)
|
|
817
829
|
***************/
|
|
818
830
|
finish(packet, resolve) {
|
|
@@ -826,7 +838,7 @@ class Deva {
|
|
|
826
838
|
this.state('finish'); // set the finish state
|
|
827
839
|
|
|
828
840
|
// return the provided resolve function or a promise resolve.
|
|
829
|
-
return hasOnFinish ? this.onFinish(packet) : this.complete(packet, resolve);
|
|
841
|
+
return hasOnFinish ? this.onFinish(packet, resolve) : this.complete(packet, resolve);
|
|
830
842
|
}
|
|
831
843
|
|
|
832
844
|
/**************
|
|
@@ -834,7 +846,7 @@ class Deva {
|
|
|
834
846
|
params:
|
|
835
847
|
- packet: the data to pass to the resolve
|
|
836
848
|
- resolve: the complete resolve to pass back
|
|
837
|
-
describe: This function is use to relay
|
|
849
|
+
describe: This function is use to relay into a complete state when
|
|
838
850
|
resolving a question or data.
|
|
839
851
|
usage: this.complete(data, resolve)
|
|
840
852
|
***************/
|
|
@@ -849,7 +861,7 @@ class Deva {
|
|
|
849
861
|
// if: agent has on complete then return on complete
|
|
850
862
|
this.state('complete'); // set the finish state
|
|
851
863
|
// return the provided resolve function or a promise resolve.
|
|
852
|
-
return hasOnComplete ? this.onComplete(packet) : resolve(packet);
|
|
864
|
+
return hasOnComplete ? this.onComplete(packet, resolve) : resolve(packet);
|
|
853
865
|
}
|
|
854
866
|
|
|
855
867
|
/**************
|
|
@@ -1211,6 +1223,24 @@ class Deva {
|
|
|
1211
1223
|
}
|
|
1212
1224
|
}
|
|
1213
1225
|
|
|
1226
|
+
/**************
|
|
1227
|
+
func: defense
|
|
1228
|
+
params: none
|
|
1229
|
+
describe: basic defense features available in a Deva.
|
|
1230
|
+
usage: this.defense()
|
|
1231
|
+
***************/
|
|
1232
|
+
defense() {
|
|
1233
|
+
if (!this._active) return this._messages.offline; // check the active status
|
|
1234
|
+
this.zone('defense');
|
|
1235
|
+
this.feature('defense'); // set the defense state
|
|
1236
|
+
try {
|
|
1237
|
+
this.state('return', 'defense'); // set the defense state
|
|
1238
|
+
return this.lib.copy(this._defense); // return the defense feature
|
|
1239
|
+
} catch (e) {
|
|
1240
|
+
return this.error(e);
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1214
1244
|
/**************
|
|
1215
1245
|
func: support
|
|
1216
1246
|
params: none
|