@indra.ai/deva 1.3.5 โ 1.3.7
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/config.json +76 -71
- package/index.js +79 -146
- package/package.json +1 -1
- package/tests/index.js +8 -7
package/config.json
CHANGED
|
@@ -32,70 +32,70 @@
|
|
|
32
32
|
"zones": {
|
|
33
33
|
"load": "๐ Load",
|
|
34
34
|
"unload": "๐ป Unload",
|
|
35
|
-
"init": "๐
|
|
35
|
+
"init": "๐ Init",
|
|
36
36
|
"start": "๐๏ธ Start",
|
|
37
37
|
"stop": "๐ Stop",
|
|
38
38
|
"enter": "๐ก Enter",
|
|
39
39
|
"exit": "๐ช Exit",
|
|
40
40
|
"finish": "๐ Finish",
|
|
41
41
|
"deva": "โก๏ธ Deva",
|
|
42
|
-
"client": "
|
|
42
|
+
"client": "๐จ Client",
|
|
43
43
|
"agent": "๐ค Agent",
|
|
44
44
|
"security": "๐ Security",
|
|
45
|
-
"support": "
|
|
46
|
-
"services": "
|
|
47
|
-
"systems": "
|
|
45
|
+
"support": "๐ Support",
|
|
46
|
+
"services": "๐ Services",
|
|
47
|
+
"systems": "๐ Systems",
|
|
48
48
|
"legal": "๐๏ธ Legal",
|
|
49
|
-
"authority": "
|
|
50
|
-
"justice": "โ๏ธ
|
|
49
|
+
"authority": "๐ Authority",
|
|
50
|
+
"justice": "โ๏ธ Justice",
|
|
51
51
|
"help": "๐ Help",
|
|
52
52
|
"error": "โ Error!"
|
|
53
53
|
},
|
|
54
54
|
"state": "offline",
|
|
55
55
|
"states": {
|
|
56
|
-
"online": "๐คฉ
|
|
57
|
-
"offline": "๐ด
|
|
58
|
-
"active": "๐
|
|
59
|
-
"inactive": "๐ซฅ
|
|
60
|
-
"idle": "๐
|
|
61
|
-
"talk": "๐ข
|
|
62
|
-
"listen": "๐
|
|
63
|
-
"ask": "๐ฃ๏ธ
|
|
64
|
-
"question": "๐ฌ
|
|
65
|
-
"cmd": "๐ช
|
|
66
|
-
"answer": "๐ก
|
|
67
|
-
"ready": "๐
|
|
68
|
-
"wait": "โณ
|
|
69
|
-
"pause": "โธ๏ธ
|
|
70
|
-
"resume": "๐
|
|
71
|
-
"connect": "๐ณ
|
|
72
|
-
"disconnect": "๐ด
|
|
73
|
-
"send": "๐ฌ
|
|
74
|
-
"receive": "๐ช
|
|
75
|
-
"init": "๐
|
|
76
|
-
"forward": "โญ๏ธ
|
|
77
|
-
"backward": "โฎ๏ธ
|
|
78
|
-
"start": "๐
|
|
79
|
-
"stop": "โน๏ธ
|
|
80
|
-
"open": "๐ฅซ
|
|
81
|
-
"close": "๐ฆ
|
|
82
|
-
"enter": "๐ก
|
|
83
|
-
"exit": "๐ช
|
|
84
|
-
"begin": "๐บ๏ธ
|
|
85
|
-
"end": "๐ฌ
|
|
86
|
-
"load": "๐
|
|
87
|
-
"unload": "๐ป
|
|
88
|
-
"resolve": "
|
|
89
|
-
"reject": "๐งฑ
|
|
90
|
-
"done": "๐
|
|
91
|
-
"data": "๐ก
|
|
92
|
-
"finish": "๐
|
|
93
|
-
"complete": "
|
|
94
|
-
"create": "๐จ
|
|
95
|
-
"destroy": "๐ฃ
|
|
96
|
-
"write": "๐
|
|
97
|
-
"save": "๐พ
|
|
98
|
-
"delete": "๐งจ
|
|
56
|
+
"online": "๐คฉ Online",
|
|
57
|
+
"offline": "๐ด Offline",
|
|
58
|
+
"active": "๐ Active",
|
|
59
|
+
"inactive": "๐ซฅ Inactive",
|
|
60
|
+
"idle": "๐ Idle",
|
|
61
|
+
"talk": "๐ข Talk",
|
|
62
|
+
"listen": "๐ Listen",
|
|
63
|
+
"ask": "๐ฃ๏ธ Ask",
|
|
64
|
+
"question": "๐ฌ Question",
|
|
65
|
+
"cmd": "๐ช Command",
|
|
66
|
+
"answer": "๐ก Answer",
|
|
67
|
+
"ready": "๐ Ready",
|
|
68
|
+
"wait": "โณ Waiting",
|
|
69
|
+
"pause": "โธ๏ธ Pause",
|
|
70
|
+
"resume": "๐ Resume",
|
|
71
|
+
"connect": "๐ณ Connect",
|
|
72
|
+
"disconnect": "๐ด Disconnect",
|
|
73
|
+
"send": "๐ฌ Send",
|
|
74
|
+
"receive": "๐ช Receive",
|
|
75
|
+
"init": "๐ Init",
|
|
76
|
+
"forward": "โญ๏ธ Forward",
|
|
77
|
+
"backward": "โฎ๏ธ Backward",
|
|
78
|
+
"start": "๐ Start",
|
|
79
|
+
"stop": "โน๏ธ Stop",
|
|
80
|
+
"open": "๐ฅซ Open",
|
|
81
|
+
"close": "๐ฆ Close",
|
|
82
|
+
"enter": "๐ก Enter",
|
|
83
|
+
"exit": "๐ช Exit",
|
|
84
|
+
"begin": "๐บ๏ธ Begin",
|
|
85
|
+
"end": "๐ฌ End",
|
|
86
|
+
"load": "๐ Load",
|
|
87
|
+
"unload": "๐ป Unload",
|
|
88
|
+
"resolve": "๐ค Resolve",
|
|
89
|
+
"reject": "๐งฑ Reject",
|
|
90
|
+
"done": "๐ Done",
|
|
91
|
+
"data": "๐ก Data",
|
|
92
|
+
"finish": "๐ Finish",
|
|
93
|
+
"complete": "โ
Complete",
|
|
94
|
+
"create": "๐จ Create",
|
|
95
|
+
"destroy": "๐ฃ Destroy",
|
|
96
|
+
"write": "๐ Write",
|
|
97
|
+
"save": "๐พ Save",
|
|
98
|
+
"delete": "๐งจ Delete",
|
|
99
99
|
"set": "๐ Set",
|
|
100
100
|
"get": "๐ซด Get",
|
|
101
101
|
"put": "๐ค Put",
|
|
@@ -109,8 +109,8 @@
|
|
|
109
109
|
"abort": "๐ ABORT!",
|
|
110
110
|
"error": "โ ERROR!",
|
|
111
111
|
"help": "๐ Help",
|
|
112
|
-
"authorized": "
|
|
113
|
-
"unauthorized": "๐ดโโ ๏ธ
|
|
112
|
+
"authorized": "๐ Authorized",
|
|
113
|
+
"unauthorized": "๐ดโโ ๏ธ Unauthorized",
|
|
114
114
|
"Done": "โ๏ธ Done",
|
|
115
115
|
"glitch": "๐ก Glitch",
|
|
116
116
|
"intruder": "๐ฆนโโ๏ธ Intruder",
|
|
@@ -125,20 +125,19 @@
|
|
|
125
125
|
},
|
|
126
126
|
"action": false,
|
|
127
127
|
"actions": {
|
|
128
|
-
"
|
|
129
|
-
"
|
|
130
|
-
"
|
|
131
|
-
"
|
|
132
|
-
"
|
|
133
|
-
"
|
|
134
|
-
"
|
|
135
|
-
"
|
|
136
|
-
"
|
|
137
|
-
"
|
|
138
|
-
"
|
|
139
|
-
"
|
|
140
|
-
"
|
|
141
|
-
"question": "๐ question",
|
|
128
|
+
"init": "๐ Init",
|
|
129
|
+
"wait": "โณ Waiting",
|
|
130
|
+
"start": "๐ฌ Start",
|
|
131
|
+
"enter": "๐ก Enter",
|
|
132
|
+
"exit": "๐ช Exit",
|
|
133
|
+
"stop": "๐ Stop",
|
|
134
|
+
"load": "๐ฆ Load",
|
|
135
|
+
"unload": "๐ฅก Unload",
|
|
136
|
+
"finish": "๐ Finish",
|
|
137
|
+
"complete": "โ
Complete",
|
|
138
|
+
"done": "โ๏ธ Done",
|
|
139
|
+
"ready": "๐ข Ready",
|
|
140
|
+
"question": "๐ Question",
|
|
142
141
|
"talk": "๐ข talk",
|
|
143
142
|
"context": "๐ context",
|
|
144
143
|
"prompt": "๐ prompt",
|
|
@@ -173,13 +172,14 @@
|
|
|
173
172
|
"ask": "๐ฃ Ask",
|
|
174
173
|
|
|
175
174
|
"client": "๐จ Client",
|
|
176
|
-
"
|
|
177
|
-
"
|
|
178
|
-
"
|
|
179
|
-
"
|
|
175
|
+
"agent": "๐ต๏ธโโ๏ธ Agent",
|
|
176
|
+
"security": "๐ Security",
|
|
177
|
+
"support": "๐ฉน Support",
|
|
178
|
+
"services": "๐ ๏ธ Services",
|
|
179
|
+
"systems": "๐ก Systems",
|
|
180
180
|
"legal": "๐๏ธ Legal",
|
|
181
181
|
"justice": "๐๏ธ Justice",
|
|
182
|
-
"authority": "
|
|
182
|
+
"authority": "๐ฎ Authority",
|
|
183
183
|
|
|
184
184
|
"invalid": "โ Invalid",
|
|
185
185
|
"states": "๐ป States",
|
|
@@ -203,10 +203,15 @@
|
|
|
203
203
|
},
|
|
204
204
|
"feature": false,
|
|
205
205
|
"features": {
|
|
206
|
+
"client": "๐จ Client",
|
|
207
|
+
"init": "๐ Init",
|
|
206
208
|
"security": "๐ Security",
|
|
207
209
|
"support": "๐ผ Support",
|
|
208
210
|
"services": "๐ ๏ธ Services",
|
|
209
211
|
"systems": "๐ฅ๏ธ๏ธ Systems",
|
|
212
|
+
"legal": "๐๏ธ๏ธ๏ธ Legal",
|
|
213
|
+
"justice": "๐๏ธ๏ธ Justice",
|
|
214
|
+
"authority": "๐๏ธ๏ธ Authority",
|
|
210
215
|
"cipher": "๐ Cipher",
|
|
211
216
|
"decipher": "๐ Decipher",
|
|
212
217
|
"promp": "๐ชต Prompt",
|
package/index.js
CHANGED
|
@@ -23,6 +23,7 @@ class Deva {
|
|
|
23
23
|
this._systems = false; // inherited Systems features.
|
|
24
24
|
this._legal = false; // inherited Legal features.
|
|
25
25
|
this._justice = false; // inherited Justice features.
|
|
26
|
+
this._authority = false; // inherited Justice features.
|
|
26
27
|
this.events = opts.events || new EventEmitter({}); // Event Bus
|
|
27
28
|
this.lib = new lib({}); // used for loading library functions
|
|
28
29
|
this.utils = opts.utils || {}; // parse function
|
|
@@ -191,6 +192,8 @@ class Deva {
|
|
|
191
192
|
this.Client = {data}
|
|
192
193
|
***************/
|
|
193
194
|
Client(client, resolve, reject) {
|
|
195
|
+
this.feature('client');
|
|
196
|
+
this.zone('client');
|
|
194
197
|
this.action('client');
|
|
195
198
|
// setup any custom methods for the features
|
|
196
199
|
try {
|
|
@@ -204,7 +207,9 @@ class Deva {
|
|
|
204
207
|
}
|
|
205
208
|
}
|
|
206
209
|
const _client = this.lib.copy(client); // copy the client parameter
|
|
210
|
+
this.state('set', 'client');
|
|
207
211
|
this._client = _client; // set local _client to this scope
|
|
212
|
+
this.state('resolve', 'client');
|
|
208
213
|
return resolve();
|
|
209
214
|
} catch (e) {
|
|
210
215
|
return this.error(e, false, reject);
|
|
@@ -212,41 +217,53 @@ class Deva {
|
|
|
212
217
|
}
|
|
213
218
|
|
|
214
219
|
/**************
|
|
215
|
-
func:
|
|
220
|
+
func: Feature
|
|
216
221
|
params: client: false
|
|
217
222
|
describe:
|
|
218
223
|
The Security feature sets the correct variables and necessary rules for the
|
|
219
224
|
client presented data.
|
|
220
225
|
***************/
|
|
221
|
-
|
|
222
|
-
this.
|
|
223
|
-
this.
|
|
226
|
+
Feature(feature, resolve, reject) {
|
|
227
|
+
this.feature(feature);
|
|
228
|
+
this.zone(feature);
|
|
224
229
|
const _cl = this.client(); // set local copy of client data
|
|
225
230
|
try {
|
|
226
|
-
if (!_cl.features
|
|
231
|
+
if (!_cl.features[feature]) return resolve(); // if no security feature goto Support
|
|
227
232
|
else {
|
|
228
|
-
this.
|
|
233
|
+
this.action(feature); // set action to feature
|
|
234
|
+
const _fe = `_${feature}`;
|
|
229
235
|
const {id, profile, features} = _cl; // make a copy the clinet data.
|
|
230
|
-
const
|
|
231
|
-
this.
|
|
236
|
+
const data = features[feature]; // make a copy the clinet data.
|
|
237
|
+
this.state('set', feature);
|
|
238
|
+
this[_fe] = { // set this_security with data
|
|
232
239
|
id: this.lib.uid(true), // uuid of the security feature
|
|
233
240
|
client_id: id, // client id for reference
|
|
234
241
|
client_name: profile.name, // client name for personalization
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
global: security.global, // the global policies for client
|
|
239
|
-
personal: security.devas[this._agent.key], // Client personal features and rules.
|
|
242
|
+
concerns: data.concerns, // any concerns for client
|
|
243
|
+
global: data.global, // the global policies for client
|
|
244
|
+
personal: data.devas[this._agent.key], // Client personal features and rules.
|
|
240
245
|
};
|
|
241
|
-
delete this._client.features
|
|
242
|
-
|
|
246
|
+
delete this._client.features[feature]; // make a copy the clinet data.
|
|
247
|
+
this.state('resolve', feature);
|
|
248
|
+
return resolve(feature); // resolve when done
|
|
243
249
|
}
|
|
244
250
|
} catch (e) {
|
|
245
|
-
this.state('reject',
|
|
246
|
-
return this.error(e); // run error handling if an error is caught
|
|
251
|
+
this.state('reject', feature);
|
|
252
|
+
return this.error(e, feature, reject); // run error handling if an error is caught
|
|
247
253
|
}
|
|
248
254
|
}
|
|
249
255
|
|
|
256
|
+
/**************
|
|
257
|
+
func: Security
|
|
258
|
+
params: client: false
|
|
259
|
+
describe:
|
|
260
|
+
The Security feature sets the correct variables and necessary rules for the
|
|
261
|
+
client presented data.
|
|
262
|
+
***************/
|
|
263
|
+
Security(resolve, reject) {
|
|
264
|
+
return this.Feature('security', resolve, reject);
|
|
265
|
+
}
|
|
266
|
+
|
|
250
267
|
/**************
|
|
251
268
|
func: Support
|
|
252
269
|
params: client: false
|
|
@@ -255,30 +272,7 @@ class Deva {
|
|
|
255
272
|
client presented data.
|
|
256
273
|
***************/
|
|
257
274
|
Support(resolve, reject) {
|
|
258
|
-
this.
|
|
259
|
-
this.action('support');
|
|
260
|
-
const _cl = this.client(); // set the local client variable
|
|
261
|
-
try {
|
|
262
|
-
if (!_cl.features.support) return resolve() // move to Services if no support feature
|
|
263
|
-
else {
|
|
264
|
-
this.state('set', 'Support');
|
|
265
|
-
const {id, features, profile} = _cl; // set the local consts from client copy
|
|
266
|
-
const {support} = features; // set support from features const
|
|
267
|
-
this._support = { // set this_support with data
|
|
268
|
-
id: this.lib.uid(true), // uuid of the support feature
|
|
269
|
-
client_id: id, // client id for reference
|
|
270
|
-
client_name: profile.name, // client name for personalization
|
|
271
|
-
concerns: support.concerns, // any concerns for client
|
|
272
|
-
global: support.global, // the global policies for client
|
|
273
|
-
personal: support.devas[this._agent.key], // Client personalSecurity features and rules.
|
|
274
|
-
};
|
|
275
|
-
delete this._client.features.support; // delete the support key from the client
|
|
276
|
-
return resolve(); // when done move to Services
|
|
277
|
-
}
|
|
278
|
-
} catch (e) {
|
|
279
|
-
this.state('reject', 'Services');
|
|
280
|
-
return this.error(e, false, reject); // run error handling if an error is caught
|
|
281
|
-
}
|
|
275
|
+
return this.Feature('support', resolve, reject);
|
|
282
276
|
}
|
|
283
277
|
|
|
284
278
|
/**************
|
|
@@ -289,30 +283,7 @@ class Deva {
|
|
|
289
283
|
client presented data.
|
|
290
284
|
***************/
|
|
291
285
|
Services(resolve, reject) {
|
|
292
|
-
this.
|
|
293
|
-
this.action('services');
|
|
294
|
-
const _cl = this.client(); // set local client
|
|
295
|
-
try {
|
|
296
|
-
if (!_cl.features.services) return resolve(); // move to Done if no Services feature
|
|
297
|
-
else {
|
|
298
|
-
this.state('set', 'Services');
|
|
299
|
-
const {id, features, profile} = _cl; // set the local consts from client copy
|
|
300
|
-
const {services} = features; // set services from features const
|
|
301
|
-
this._services = { // set this_services with data
|
|
302
|
-
id: this.lib.uid(true), // uuid of the services feature
|
|
303
|
-
client_id: id, // client id for reference
|
|
304
|
-
client_name: profile.name, // client name for personalization
|
|
305
|
-
concerns: services.concerns, // any concerns for client
|
|
306
|
-
global: services.global, // the global policies for client
|
|
307
|
-
personal: services.devas[this._agent.key], // Client personal features and rules.
|
|
308
|
-
};
|
|
309
|
-
delete this._client.features.services; // delete the services key for isolation
|
|
310
|
-
return resolve(); // go to Done
|
|
311
|
-
}
|
|
312
|
-
} catch (e) {
|
|
313
|
-
this.state('reject', 'Services');
|
|
314
|
-
return this.error(e, false, reject); // run error handling if an error is caught
|
|
315
|
-
}
|
|
286
|
+
return this.Feature('services', resolve, reject);
|
|
316
287
|
}
|
|
317
288
|
|
|
318
289
|
/**************
|
|
@@ -323,30 +294,7 @@ class Deva {
|
|
|
323
294
|
client presented data.
|
|
324
295
|
***************/
|
|
325
296
|
Systems(resolve, reject) {
|
|
326
|
-
this.
|
|
327
|
-
this.action('systems');
|
|
328
|
-
const _cl = this.client(); // set local client
|
|
329
|
-
try {
|
|
330
|
-
if (!_cl.features.systems) return resolve(); // move to Done if no Systems feature
|
|
331
|
-
else {
|
|
332
|
-
this.state('set', 'Systems');
|
|
333
|
-
const {id, features, profile} = _cl; // set the local consts from client copy
|
|
334
|
-
const {systems} = features; // set systems from features const
|
|
335
|
-
this._systems = { // set this_systems with data
|
|
336
|
-
id: this.lib.uid(true), // uuid of the systems feature
|
|
337
|
-
client_id: id, // client id for reference
|
|
338
|
-
client_name: profile.name, // client name for personalization
|
|
339
|
-
concerns: systems.concerns, // any concerns for client
|
|
340
|
-
global: systems.global, // the global policies for client
|
|
341
|
-
personal: systems.devas[this._agent.key], // Client personal features and rules.
|
|
342
|
-
};
|
|
343
|
-
delete this._client.features.systems; // delete the services key for isolation
|
|
344
|
-
return resolve(); // go to Done
|
|
345
|
-
}
|
|
346
|
-
} catch (e) {
|
|
347
|
-
this.state('reject', 'Systems');
|
|
348
|
-
return this.error(e, false, reject); // run error handling if an error is caught
|
|
349
|
-
}
|
|
297
|
+
return this.Feature('systems', resolve, reject);
|
|
350
298
|
}
|
|
351
299
|
|
|
352
300
|
/**************
|
|
@@ -357,30 +305,7 @@ class Deva {
|
|
|
357
305
|
client presented data.
|
|
358
306
|
***************/
|
|
359
307
|
Legal(resolve, reject) {
|
|
360
|
-
this.
|
|
361
|
-
this.action('legal');
|
|
362
|
-
const _cl = this.client(); // set local client
|
|
363
|
-
try {
|
|
364
|
-
if (!_cl.features.legal) return resolve(); // move to Done if no Systems feature
|
|
365
|
-
else {
|
|
366
|
-
this.state('set', 'Legal');
|
|
367
|
-
const {id, features, profile} = _cl; // set the local consts from client copy
|
|
368
|
-
const {legal} = features; // set services from features const
|
|
369
|
-
this._legal = { // set this_services with data
|
|
370
|
-
id: this.lib.uid(true), // uuid of the services feature
|
|
371
|
-
client_id: id, // client id for reference
|
|
372
|
-
client_name: profile.name, // client name for personalization
|
|
373
|
-
concerns: legal.concerns, // any concerns for client
|
|
374
|
-
global: legal.global, // the global policies for client
|
|
375
|
-
personal: legal.devas[this._agent.key], // Client personal features and rules.
|
|
376
|
-
};
|
|
377
|
-
delete this._client.features.legal; // delete the services key for isolation
|
|
378
|
-
return resolve(); // go to Done
|
|
379
|
-
}
|
|
380
|
-
} catch (e) {
|
|
381
|
-
this.state('reject', 'Legal');
|
|
382
|
-
return this.error(e, false, reject); // run error handling if an error is caught
|
|
383
|
-
}
|
|
308
|
+
return this.Feature('legal', resolve, reject);
|
|
384
309
|
}
|
|
385
310
|
|
|
386
311
|
/**************
|
|
@@ -391,30 +316,18 @@ class Deva {
|
|
|
391
316
|
client presented data.
|
|
392
317
|
***************/
|
|
393
318
|
Justice(resolve, reject) {
|
|
394
|
-
this.
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
client_name: profile.name, // client name for personalization
|
|
407
|
-
concerns: justice.concerns, // any concerns for client
|
|
408
|
-
global: justice.global, // the global policies for client
|
|
409
|
-
personal: justice.devas[this._agent.key], // Client personal features and rules.
|
|
410
|
-
};
|
|
411
|
-
delete this._client.features.justice; // delete the services key for isolation
|
|
412
|
-
return resolve(); // go to Done
|
|
413
|
-
}
|
|
414
|
-
} catch (e) {
|
|
415
|
-
this.state('reject', 'Justice');
|
|
416
|
-
return this.error(e, false, reject); // run error handling if an error is caught
|
|
417
|
-
}
|
|
319
|
+
return this.Feature('justice', resolve, reject);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**************
|
|
323
|
+
func: Authority
|
|
324
|
+
params: client: false
|
|
325
|
+
describe:
|
|
326
|
+
The Authority feature sets the correct variables and necessary rules for the
|
|
327
|
+
client presented data.
|
|
328
|
+
***************/
|
|
329
|
+
Authority(resolve, reject) {
|
|
330
|
+
return this.Feature('authority', resolve, reject);
|
|
418
331
|
}
|
|
419
332
|
|
|
420
333
|
/**************
|
|
@@ -756,23 +669,28 @@ class Deva {
|
|
|
756
669
|
}).then(() => {
|
|
757
670
|
return this._assignListeners();
|
|
758
671
|
}).then(() => {
|
|
672
|
+
this.feature('init');
|
|
673
|
+
this.zone('init');
|
|
674
|
+
this.action('init');
|
|
675
|
+
this.state('init');
|
|
759
676
|
return this.Client(client, resolve, reject);
|
|
760
677
|
}).then(() => {
|
|
761
678
|
return this.Security(resolve, reject);
|
|
762
|
-
}).then(() => {
|
|
763
|
-
return this.Services(resolve, reject);
|
|
764
679
|
}).then(() => {
|
|
765
680
|
return this.Support(resolve, reject);
|
|
681
|
+
}).then(() => {
|
|
682
|
+
return this.Services(resolve, reject);
|
|
766
683
|
}).then(() => {
|
|
767
684
|
return this.Systems(resolve, reject);
|
|
768
685
|
}).then(() => {
|
|
769
686
|
return this.Legal(resolve, reject);
|
|
770
687
|
}).then(() => {
|
|
771
688
|
return this.Justice(resolve, reject);
|
|
689
|
+
}).then(() => {
|
|
690
|
+
return this.Authority(resolve, reject);
|
|
772
691
|
}).then(() => {
|
|
773
692
|
return this.Done(resolve, reject);
|
|
774
693
|
}).then(() => {
|
|
775
|
-
this.zone('init');
|
|
776
694
|
const hasOnInit = this.onInit && typeof this.onInit === 'function';
|
|
777
695
|
return hasOnInit ? this.onInit(_data, resolve) : this.start(_data, resolve);
|
|
778
696
|
}).catch(err => {
|
|
@@ -1154,7 +1072,6 @@ class Deva {
|
|
|
1154
1072
|
feature(value=false, extra=false) {
|
|
1155
1073
|
try {
|
|
1156
1074
|
if (!value || !this._features[value]) return; // check feature value
|
|
1157
|
-
this._feature = value; // set local feature variable
|
|
1158
1075
|
|
|
1159
1076
|
const lookup = this._features[value]; // set the lookup value
|
|
1160
1077
|
const text = extra ? `${lookup} ${extra}` : lookup; // set the text value
|
|
@@ -1275,7 +1192,9 @@ class Deva {
|
|
|
1275
1192
|
try {
|
|
1276
1193
|
this.state('return', 'security'); // set the security state
|
|
1277
1194
|
return this.lib.copy(this._security); // return the security feature
|
|
1278
|
-
} catch (e) {
|
|
1195
|
+
} catch (e) {
|
|
1196
|
+
return this.error(e);
|
|
1197
|
+
}
|
|
1279
1198
|
}
|
|
1280
1199
|
|
|
1281
1200
|
/**************
|
|
@@ -1368,6 +1287,24 @@ class Deva {
|
|
|
1368
1287
|
}
|
|
1369
1288
|
}
|
|
1370
1289
|
|
|
1290
|
+
/**************
|
|
1291
|
+
func: authority
|
|
1292
|
+
params: none
|
|
1293
|
+
describe: basic authority features available in a Deva.
|
|
1294
|
+
usage: this.systems()
|
|
1295
|
+
***************/
|
|
1296
|
+
authority() {
|
|
1297
|
+
if (!this._active) return this._messages.offline; // check the active status
|
|
1298
|
+
this.zone('authority');
|
|
1299
|
+
this.feature('authority'); // set the support state
|
|
1300
|
+
try {
|
|
1301
|
+
this.state('return', 'authority'); // set the systems state
|
|
1302
|
+
return this.lib.copy(this._authority); // return the systems feature
|
|
1303
|
+
} catch (e) {
|
|
1304
|
+
return this.error(e); // return this.error when error catch
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1371
1308
|
/**************
|
|
1372
1309
|
func: load
|
|
1373
1310
|
params:
|
|
@@ -1415,7 +1352,6 @@ class Deva {
|
|
|
1415
1352
|
usage: this.prompt('text')
|
|
1416
1353
|
***************/
|
|
1417
1354
|
prompt(text) {
|
|
1418
|
-
this.feature('prompt');
|
|
1419
1355
|
// Talk a global prompt event for the client
|
|
1420
1356
|
const agent = this.agent();
|
|
1421
1357
|
const client = this.client();
|
|
@@ -1444,7 +1380,6 @@ class Deva {
|
|
|
1444
1380
|
info() {
|
|
1445
1381
|
// check the active status
|
|
1446
1382
|
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
1447
|
-
this.feature('info');
|
|
1448
1383
|
return this._info;
|
|
1449
1384
|
}
|
|
1450
1385
|
|
|
@@ -1462,7 +1397,6 @@ class Deva {
|
|
|
1462
1397
|
status() {
|
|
1463
1398
|
// check the active status
|
|
1464
1399
|
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
1465
|
-
this.feature('status');
|
|
1466
1400
|
|
|
1467
1401
|
// format the date since active for output.
|
|
1468
1402
|
const dateFormat = this.lib.formatDate(this._active, 'long', true);
|
|
@@ -1485,7 +1419,6 @@ class Deva {
|
|
|
1485
1419
|
this.zone('help');
|
|
1486
1420
|
|
|
1487
1421
|
if (!this._active) return resolve(this._messages.offline);
|
|
1488
|
-
this.feature('help');
|
|
1489
1422
|
|
|
1490
1423
|
const params = msg.split(' ');
|
|
1491
1424
|
let helpFile = 'main';
|
package/package.json
CHANGED
package/tests/index.js
CHANGED
|
@@ -31,27 +31,28 @@ const HelloWorld = new Deva({
|
|
|
31
31
|
vars: agent.vars,
|
|
32
32
|
listeners: {
|
|
33
33
|
'devacore:prompt'(packet) {
|
|
34
|
-
console.log(`๐
|
|
34
|
+
console.log(`๐ prompt: ${packet.text}`);
|
|
35
35
|
},
|
|
36
36
|
'devacore:question'(packet) {
|
|
37
|
-
console.log(`๐โโ๏ธ๏ธ
|
|
37
|
+
console.log(`๐โโ๏ธ๏ธ question: ${packet.text}`);
|
|
38
38
|
},
|
|
39
39
|
'devacore:answer'(packet) {
|
|
40
|
-
console.log(`๐จโ๐ฌ
|
|
40
|
+
console.log(`๐จโ๐ฌ answer: ${packet.text}`);
|
|
41
41
|
},
|
|
42
42
|
'devacore:ask'(packet) {
|
|
43
|
-
console.log(`๐ค
|
|
43
|
+
console.log(`๐ค ask: ${packet.text}`);
|
|
44
44
|
},
|
|
45
45
|
'devacore:state'(packet) {
|
|
46
|
-
console.log(`๐ช
|
|
46
|
+
console.log(`๐ช state: ${packet.text}`);
|
|
47
47
|
},
|
|
48
48
|
'devacore:zone'(packet) {
|
|
49
|
-
console.log(`๐บ๏ธ
|
|
49
|
+
console.log(`๐บ๏ธ zone: ${packet.text}`);
|
|
50
50
|
},
|
|
51
51
|
'devacore:action'(packet) {
|
|
52
|
-
console.log(`๐ฅ
|
|
52
|
+
console.log(`๐ฅ action: ${packet.text}`);
|
|
53
53
|
},
|
|
54
54
|
'devacore:feature'(packet) {
|
|
55
|
+
console.log(`---`);
|
|
55
56
|
console.log(`๐ฟ feature: ${packet.text}`);
|
|
56
57
|
},
|
|
57
58
|
'devacore:error'(packet) {
|