@indra.ai/deva 1.6.94 → 1.6.96
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 +122 -76
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -255,13 +255,13 @@ class Deva {
|
|
|
255
255
|
|
|
256
256
|
_getFeature(key, value) {
|
|
257
257
|
if (!this._active) return this._messages.offline; // check the active status
|
|
258
|
-
this.zone(key);
|
|
259
258
|
this.feature(key); // set the security state
|
|
259
|
+
this.zone(key);
|
|
260
260
|
this.action(key);
|
|
261
261
|
this.state(key);
|
|
262
262
|
try {
|
|
263
263
|
const data = this.lib.copy(value);
|
|
264
|
-
this.
|
|
264
|
+
this.action('return', key); // set the security state
|
|
265
265
|
return data; // return the security feature
|
|
266
266
|
} catch (e) {
|
|
267
267
|
this.state('catch', key);
|
|
@@ -983,7 +983,7 @@ class Deva {
|
|
|
983
983
|
}
|
|
984
984
|
|
|
985
985
|
this.action('hash', `start:md5:${data.id.uid}`);
|
|
986
|
-
data.md5 = this.hash(data);
|
|
986
|
+
data.md5 = this.hash(data, 'md5');
|
|
987
987
|
|
|
988
988
|
this.action('hash', `start:sha256:${data.id.uid}`)
|
|
989
989
|
data.sha256 = this.hash(data, 'sha256');
|
|
@@ -1093,7 +1093,7 @@ class Deva {
|
|
|
1093
1093
|
data.value = 'start';
|
|
1094
1094
|
|
|
1095
1095
|
this.action('hash', `start:md5:${data.id.uid}`);
|
|
1096
|
-
data.md5 = this.hash(data);
|
|
1096
|
+
data.md5 = this.hash(data, 'md5');
|
|
1097
1097
|
this.action('hash', `start:sha256:${data.id.uid}`)
|
|
1098
1098
|
data.sha256 = this.hash(data, 'sha256');
|
|
1099
1099
|
this.action('hash', `start:sha512:${data.id.uid}`)
|
|
@@ -1139,7 +1139,7 @@ class Deva {
|
|
|
1139
1139
|
data.value = 'enter';
|
|
1140
1140
|
|
|
1141
1141
|
this.action('hash', `enter:md5:${data.id.uid}`);
|
|
1142
|
-
data.md5 = this.hash(data);
|
|
1142
|
+
data.md5 = this.hash(data, 'md5');
|
|
1143
1143
|
this.action('hash', `enter:sha256:${data.id.uid}`)
|
|
1144
1144
|
data.sha256 = this.hash(data, 'sha256');
|
|
1145
1145
|
this.action('hash', `enter:sha512:${data.id.uid}`)
|
|
@@ -1184,7 +1184,7 @@ class Deva {
|
|
|
1184
1184
|
data.value = 'done';
|
|
1185
1185
|
|
|
1186
1186
|
this.action('hash', `done:md5:${data.id.uid}`);
|
|
1187
|
-
data.md5 = this.hash(data);
|
|
1187
|
+
data.md5 = this.hash(data, 'md5');
|
|
1188
1188
|
this.action('hash', `done:sha256:${data.id.uid}`)
|
|
1189
1189
|
data.sha256 = this.hash(data, 'sha256');
|
|
1190
1190
|
this.action('hash', `done:sha512:${data.id.uid}`)
|
|
@@ -1227,7 +1227,7 @@ class Deva {
|
|
|
1227
1227
|
data.value = 'ready';
|
|
1228
1228
|
|
|
1229
1229
|
this.action('hash', `ready:md5:${data.id.uid}`);
|
|
1230
|
-
data.md5 = this.hash(data);
|
|
1230
|
+
data.md5 = this.hash(data, 'md5');
|
|
1231
1231
|
this.action('hash', `ready:sha256:${data.id.uid}`)
|
|
1232
1232
|
data.sha256 = this.hash(data, 'sha256');
|
|
1233
1233
|
this.action('hash', `ready:sha512:${data.id.uid}`)
|
|
@@ -1269,7 +1269,7 @@ class Deva {
|
|
|
1269
1269
|
this.state('set', `data:finish:${data.finish}:${data.id.uid}`)
|
|
1270
1270
|
|
|
1271
1271
|
this.action('hash', `finish:md5:${data.id.uid}`);
|
|
1272
|
-
data.md5 = this.hash(data);
|
|
1272
|
+
data.md5 = this.hash(data, 'md5');
|
|
1273
1273
|
this.action('hash', `finish:sha256:${data.id.uid}`)
|
|
1274
1274
|
data.sha256 = this.hash(data, 'sha256');
|
|
1275
1275
|
this.action('hash', `finish:sha512:${data.id.uid}`)
|
|
@@ -1296,7 +1296,7 @@ class Deva {
|
|
|
1296
1296
|
usage: this.complete(data, resolve)
|
|
1297
1297
|
***************/
|
|
1298
1298
|
complete(data, resolve) {
|
|
1299
|
-
if (!this._active) return
|
|
1299
|
+
if (!this._active) return resolve(this._messages.offline);
|
|
1300
1300
|
this.context('complete', data.id.uid);
|
|
1301
1301
|
this.zone('complete', data.id.uid);
|
|
1302
1302
|
this.action('complete', data.id.uid);
|
|
@@ -1313,7 +1313,7 @@ class Deva {
|
|
|
1313
1313
|
this.state('set', `data:complete:${data.complete}:${data.id.uid}`)
|
|
1314
1314
|
|
|
1315
1315
|
this.action('hash', `complete:md5:${data.id.uid}`);
|
|
1316
|
-
data.md5 = this.hash(data);
|
|
1316
|
+
data.md5 = this.hash(data, 'md5');
|
|
1317
1317
|
this.action('hash', `complete:sha256:${data.id.uid}`)
|
|
1318
1318
|
data.sha256 = this.hash(data, 'sha256');
|
|
1319
1319
|
|
|
@@ -1346,7 +1346,7 @@ class Deva {
|
|
|
1346
1346
|
this.stop()
|
|
1347
1347
|
***************/
|
|
1348
1348
|
stop() {
|
|
1349
|
-
if (!this._active) return
|
|
1349
|
+
if (!this._active) return this._messages.offline;
|
|
1350
1350
|
const id = this.uid();
|
|
1351
1351
|
this.context('stop', id.uid);
|
|
1352
1352
|
this.zone('stop', id.uid);
|
|
@@ -1370,7 +1370,7 @@ class Deva {
|
|
|
1370
1370
|
}
|
|
1371
1371
|
|
|
1372
1372
|
this.action('hash', `stop:md5:${data.id.uid}`);
|
|
1373
|
-
data.md5 = this.hash(data);
|
|
1373
|
+
data.md5 = this.hash(data, 'md5');
|
|
1374
1374
|
this.action('hash', `stop:sha256:${data.id.uid}`)
|
|
1375
1375
|
data.sha256 = this.hash(data, 'sha256');
|
|
1376
1376
|
this.action('hash', `stop:sha512:${data.id.uid}`)
|
|
@@ -1398,7 +1398,7 @@ class Deva {
|
|
|
1398
1398
|
function.
|
|
1399
1399
|
***************/
|
|
1400
1400
|
exit(data) {
|
|
1401
|
-
if (!this._active) return
|
|
1401
|
+
if (!this._active) return this._messages.offline;
|
|
1402
1402
|
|
|
1403
1403
|
this.context('exit', data.id.uid);
|
|
1404
1404
|
this.zone('exit', data.id.uid);
|
|
@@ -1416,7 +1416,7 @@ class Deva {
|
|
|
1416
1416
|
data.exit = Date.now();
|
|
1417
1417
|
|
|
1418
1418
|
this.action('hash', `stop:md5:${data.id.uid}`);
|
|
1419
|
-
data.md5 = this.hash(data);
|
|
1419
|
+
data.md5 = this.hash(data, 'md5');
|
|
1420
1420
|
this.action('hash', `stop:sha256:${data.id.uid}`)
|
|
1421
1421
|
data.sha256 = this.hash(data, 'sha256');
|
|
1422
1422
|
this.action('hash', `stop:sha512:${data.id.uid}`)
|
|
@@ -1453,7 +1453,7 @@ class Deva {
|
|
|
1453
1453
|
const hasOnExit = this.onExit && typeof this.onExit === 'function';
|
|
1454
1454
|
if (hasOnExit) this.state('set', `hasOnExit:${data.id.uid}`); // state set to watch OnFinish
|
|
1455
1455
|
|
|
1456
|
-
this.action('
|
|
1456
|
+
this.action('resolve', `exit:${data.uid}`);
|
|
1457
1457
|
return hasOnExit ? this.onExit(data) : Promise.resolve(data)
|
|
1458
1458
|
}
|
|
1459
1459
|
|
|
@@ -1464,29 +1464,32 @@ class Deva {
|
|
|
1464
1464
|
func: state
|
|
1465
1465
|
params:
|
|
1466
1466
|
- value: The state value to set for the Deva that matches to this._states
|
|
1467
|
-
- extra: any extra text to add
|
|
1467
|
+
- extra: any extra text to add to the state change.
|
|
1468
1468
|
***************/
|
|
1469
1469
|
state(value=false, extra=false) {
|
|
1470
|
+
if (!this._active) return this._messages.offline;
|
|
1471
|
+
const id = this.uid();
|
|
1472
|
+
const key = 'state';
|
|
1470
1473
|
try {
|
|
1471
1474
|
if (!value || !this._states[value]) return; // return if no matching value
|
|
1472
1475
|
this._state = value; // set the local state variable.
|
|
1473
1476
|
const lookup = this._states[value]; // set the local states lookup
|
|
1474
1477
|
const text = extra ? `${lookup} ${extra}` : lookup; // set text from lookup with extra
|
|
1475
1478
|
const data = { // build the data object
|
|
1476
|
-
id
|
|
1477
|
-
|
|
1478
|
-
client: this.client(), // set the client
|
|
1479
|
-
key: 'state', // set the key to state
|
|
1479
|
+
id, // set the data id
|
|
1480
|
+
key, // set the key to state
|
|
1480
1481
|
value, // set the value to the passed in value
|
|
1481
1482
|
text, // set the text value of the data
|
|
1483
|
+
agent: this.agent(), // set the agent
|
|
1484
|
+
client: this.client(), // set the client
|
|
1482
1485
|
created: Date.now(), // set the data created date.
|
|
1483
1486
|
};
|
|
1484
1487
|
|
|
1485
|
-
data.md5 = this.hash(data);
|
|
1488
|
+
data.md5 = this.hash(data, 'md5');
|
|
1486
1489
|
data.sha256 = this.hash(data, 'sha256');
|
|
1487
1490
|
data.sha512 = this.hash(data, 'sha512');
|
|
1488
1491
|
|
|
1489
|
-
this.talk(this._events.state, data); //
|
|
1492
|
+
this.talk(this._events.state, data); // broadcast the state event
|
|
1490
1493
|
return data;
|
|
1491
1494
|
} catch (e) { // catch any errors
|
|
1492
1495
|
return this.err(e); // return if an error happens
|
|
@@ -1496,23 +1499,33 @@ class Deva {
|
|
|
1496
1499
|
/**************
|
|
1497
1500
|
func: states
|
|
1498
1501
|
params: none
|
|
1499
|
-
describe: returns the
|
|
1502
|
+
describe: returns the available states values.
|
|
1500
1503
|
***************/
|
|
1501
1504
|
states() {
|
|
1505
|
+
if (!this._active) return this._messages.offline;
|
|
1502
1506
|
const id = this.uid();
|
|
1503
|
-
|
|
1507
|
+
const key = 'states';
|
|
1508
|
+
this.action(key, id.uid);
|
|
1509
|
+
|
|
1510
|
+
// set the data packet for the states
|
|
1511
|
+
this.state('data', `${key}:${id.uid}`);
|
|
1504
1512
|
const data = {
|
|
1505
1513
|
id,
|
|
1506
|
-
key
|
|
1514
|
+
key,
|
|
1507
1515
|
value: this._states,
|
|
1516
|
+
agent: this.agent(),
|
|
1517
|
+
client: this.client(),
|
|
1508
1518
|
created: Date.now(),
|
|
1509
1519
|
}
|
|
1510
1520
|
|
|
1511
|
-
data.md5
|
|
1512
|
-
data.
|
|
1521
|
+
this.action('hash', `${data.key}:md5:${data.id.uid}`);
|
|
1522
|
+
data.md5 = this.hash(data, 'md5');
|
|
1523
|
+
this.action('hash', `${data.key}:sha256:${data.id.uid}`);
|
|
1524
|
+
data.sha256 = this.hash(data, 'sha256');
|
|
1525
|
+
this.action('hash', `${data.key}:sha512:${data.id.uid}`);
|
|
1513
1526
|
data.sha512 = this.hash(data, 'sha512');
|
|
1514
1527
|
|
|
1515
|
-
this.
|
|
1528
|
+
this.action('return', `${data.key}:${id.uid}`);
|
|
1516
1529
|
return data;
|
|
1517
1530
|
}
|
|
1518
1531
|
|
|
@@ -1523,7 +1536,9 @@ class Deva {
|
|
|
1523
1536
|
describe
|
|
1524
1537
|
***************/
|
|
1525
1538
|
zone(value=false, extra=false) {
|
|
1539
|
+
if (!this._active) return this._messages.offline;
|
|
1526
1540
|
const id = this.uid();
|
|
1541
|
+
const key = 'zone';
|
|
1527
1542
|
if (!value || !this._zones[value]) return;
|
|
1528
1543
|
|
|
1529
1544
|
try {
|
|
@@ -1533,22 +1548,21 @@ class Deva {
|
|
|
1533
1548
|
|
|
1534
1549
|
const data = { // build the zone data
|
|
1535
1550
|
id, // set the packetid
|
|
1536
|
-
|
|
1537
|
-
client: this.client(),
|
|
1538
|
-
key: 'zone',
|
|
1551
|
+
key,
|
|
1539
1552
|
value,
|
|
1540
1553
|
text,
|
|
1554
|
+
agent: this.agent(),
|
|
1555
|
+
client: this.client(),
|
|
1541
1556
|
created: Date.now(),
|
|
1542
1557
|
};
|
|
1543
1558
|
|
|
1544
|
-
data.md5 = this.hash(data);
|
|
1559
|
+
data.md5 = this.hash(data, 'md5');
|
|
1545
1560
|
data.sha256 = this.hash(data, 'sha256');
|
|
1546
1561
|
data.sha512 = this.hash(data, 'sha512');
|
|
1547
1562
|
|
|
1548
1563
|
this.talk(this._events.zone, data);
|
|
1549
1564
|
return data;
|
|
1550
1565
|
} catch (e) {
|
|
1551
|
-
this.state('catch', `zone:${value}:${id.uid}`);
|
|
1552
1566
|
return this.err(e, value);
|
|
1553
1567
|
}
|
|
1554
1568
|
}
|
|
@@ -1559,23 +1573,29 @@ class Deva {
|
|
|
1559
1573
|
describe: returns a listing of zones currently in the system.
|
|
1560
1574
|
***************/
|
|
1561
1575
|
zones() {
|
|
1576
|
+
if (!this._active) return this._messages.offline;
|
|
1562
1577
|
const id = this.uid();
|
|
1563
|
-
|
|
1564
|
-
this.
|
|
1565
|
-
|
|
1578
|
+
const key = 'zones';
|
|
1579
|
+
this.action(key, id.uid);
|
|
1580
|
+
|
|
1581
|
+
this.state('data', `${key}:${id.uid}`);
|
|
1566
1582
|
const data = {
|
|
1567
1583
|
id, // set the uuid of the data
|
|
1568
|
-
|
|
1569
|
-
cleint: this.client(), // set the client value
|
|
1570
|
-
key: 'zones', // set the key return value
|
|
1584
|
+
key, // set the key return value
|
|
1571
1585
|
value: this._zones, // set the list of zones
|
|
1586
|
+
agent: this.agent(), // set the agent value
|
|
1587
|
+
client: this.client(), // set the client value
|
|
1572
1588
|
created: Date.now(), // set the created date of the object.
|
|
1573
1589
|
}
|
|
1574
1590
|
|
|
1575
|
-
data.md5
|
|
1576
|
-
data.
|
|
1591
|
+
this.action('hash', `${data.key}:md5:${data.id.uid}`);
|
|
1592
|
+
data.md5 = this.hash(data, 'md5');
|
|
1593
|
+
this.action('hash', `${data.key}:sha256:${data.id.uid}`);
|
|
1594
|
+
data.sha256 = this.hash(data, 'sha256');
|
|
1595
|
+
this.action('hash', `${data.key}:sha512:${data.id.uid}`);
|
|
1577
1596
|
data.sha512 = this.hash(data, 'sha512');
|
|
1578
1597
|
|
|
1598
|
+
this.action('return', `${data.key}:${id.uid}`);
|
|
1579
1599
|
return data
|
|
1580
1600
|
}
|
|
1581
1601
|
|
|
@@ -1587,7 +1607,9 @@ class Deva {
|
|
|
1587
1607
|
describe
|
|
1588
1608
|
***************/
|
|
1589
1609
|
action(value=false, extra=false) {
|
|
1610
|
+
if (!this._active) return this._messages.offline;
|
|
1590
1611
|
const id = this.uid();
|
|
1612
|
+
const key = 'action'
|
|
1591
1613
|
try {
|
|
1592
1614
|
if (!value || !this._actions[value]) return;
|
|
1593
1615
|
this._action = value; // set the local action variable
|
|
@@ -1600,22 +1622,22 @@ class Deva {
|
|
|
1600
1622
|
|
|
1601
1623
|
const data = { // build the data object for the action.
|
|
1602
1624
|
id, // generate a guid for the action transmitssion.
|
|
1603
|
-
|
|
1604
|
-
client: this.client(), // the client data to send with the action
|
|
1605
|
-
key: 'action', // the key for event to transmit action type
|
|
1625
|
+
key, // the key for event to transmit action type
|
|
1606
1626
|
value, // the value key which is the action passed
|
|
1607
1627
|
text, // text of the action to send
|
|
1628
|
+
agent: this.agent(), // the agent data to send with the action
|
|
1629
|
+
client: this.client(), // the client data to send with the action
|
|
1608
1630
|
created: Date.now(), // action time stamp
|
|
1609
1631
|
};
|
|
1610
1632
|
|
|
1611
|
-
data.md5 = this.hash(data);
|
|
1633
|
+
data.md5 = this.hash(data, 'md5');
|
|
1612
1634
|
data.sha256 = this.hash(data, 'sha256');
|
|
1613
1635
|
data.sha512 = this.hash(data, 'sha512');
|
|
1614
1636
|
|
|
1615
1637
|
this.talk(this._events.action, data); // talk the core action event
|
|
1616
1638
|
return data;
|
|
1617
1639
|
} catch (e) { // catch any errors that occur
|
|
1618
|
-
this.state('catch',
|
|
1640
|
+
this.state('catch', `${key}:${id.uid}`);
|
|
1619
1641
|
return this.err(e); // return error on error catch
|
|
1620
1642
|
}
|
|
1621
1643
|
}
|
|
@@ -1626,22 +1648,29 @@ class Deva {
|
|
|
1626
1648
|
describe: Returns a list of available actions in the system.
|
|
1627
1649
|
***************/
|
|
1628
1650
|
actions() {
|
|
1651
|
+
if (!this._active) return this._messages.offline;
|
|
1629
1652
|
const id = this.uid();
|
|
1630
|
-
|
|
1653
|
+
const key = 'actions';
|
|
1654
|
+
this.action(key, id.uid);
|
|
1655
|
+
|
|
1656
|
+
this.state('data', `${key}:${id.uid}`);
|
|
1631
1657
|
const data = {
|
|
1632
1658
|
id, // set the id with a uuid
|
|
1659
|
+
key, // set the data key
|
|
1660
|
+
value: this._actions, // set the value to the actions list
|
|
1633
1661
|
agent: this.agent(), // set the agent value
|
|
1634
1662
|
client: this.client(), // set the client value
|
|
1635
|
-
key: 'actions', // set the data key
|
|
1636
|
-
value: this._actions, // set the value to the actions list
|
|
1637
1663
|
created: Date.now(), // set the data created date
|
|
1638
1664
|
};
|
|
1639
1665
|
|
|
1640
|
-
data.md5
|
|
1641
|
-
data.
|
|
1666
|
+
this.action('hash', `${data.key}:md5:${data.id.uid}`);
|
|
1667
|
+
data.md5 = this.hash(data, 'md5');
|
|
1668
|
+
this.action('hash', `${data.key}:sha256:${data.id.uid}`);
|
|
1669
|
+
data.sha256 = this.hash(data, 'sha256');
|
|
1670
|
+
this.action('hash', `${data.key}:sha512:${data.id.uid}`);
|
|
1642
1671
|
data.sha512 = this.hash(data, 'sha512');
|
|
1643
1672
|
|
|
1644
|
-
this.state('return',
|
|
1673
|
+
this.state('return', `${key}:${id.uid}`);
|
|
1645
1674
|
return data;
|
|
1646
1675
|
}
|
|
1647
1676
|
|
|
@@ -1669,7 +1698,7 @@ class Deva {
|
|
|
1669
1698
|
created: Date.now(), // set the creation date
|
|
1670
1699
|
};
|
|
1671
1700
|
|
|
1672
|
-
data.md5 = this.hash(data);
|
|
1701
|
+
data.md5 = this.hash(data, 'md5');
|
|
1673
1702
|
data.sha256 = this.hash(data, 'sha256');
|
|
1674
1703
|
data.sha512 = this.hash(data, 'sha512');
|
|
1675
1704
|
|
|
@@ -1689,21 +1718,27 @@ class Deva {
|
|
|
1689
1718
|
features() {
|
|
1690
1719
|
if (!this._active) return this._messages.offline; // check the active status
|
|
1691
1720
|
const id = this.uid();
|
|
1692
|
-
|
|
1721
|
+
const key = 'features';
|
|
1722
|
+
this.action(key, id.uid);
|
|
1723
|
+
|
|
1724
|
+
this.state('data', `${key}:${id.uid}`);
|
|
1693
1725
|
const data = {
|
|
1694
1726
|
id, // set the object id
|
|
1727
|
+
key, // set the key
|
|
1728
|
+
value: this._features, // set the value to the features list
|
|
1695
1729
|
agent: this.agent(), // set the agent value.
|
|
1696
1730
|
client: this.client(), // set the client value.
|
|
1697
|
-
key: 'features', // set the key
|
|
1698
|
-
value: this._features, // set the value to the features list
|
|
1699
1731
|
created: Date.now(), // set the created date.
|
|
1700
1732
|
};
|
|
1701
1733
|
|
|
1702
|
-
data.md5
|
|
1703
|
-
data.
|
|
1734
|
+
this.action('hash', `${data.key}:md5:${data.id.uid}`);
|
|
1735
|
+
data.md5 = this.hash(data, 'md5');
|
|
1736
|
+
this.action('hash', `${data.key}:sha256:${data.id.uid}`);
|
|
1737
|
+
data.sha256 = this.hash(data, 'sha256');
|
|
1738
|
+
this.action('hash', `${data.key}:sha512:${data.id.uid}`);
|
|
1704
1739
|
data.sha512 = this.hash(data, 'sha512');
|
|
1705
|
-
|
|
1706
|
-
this.state('return',
|
|
1740
|
+
|
|
1741
|
+
this.state('return', `${data.key}:${data.id.uid}`);
|
|
1707
1742
|
return data;
|
|
1708
1743
|
}
|
|
1709
1744
|
|
|
@@ -1733,7 +1768,7 @@ class Deva {
|
|
|
1733
1768
|
created: Date.now(),
|
|
1734
1769
|
};
|
|
1735
1770
|
|
|
1736
|
-
data.md5 = this.hash(data);
|
|
1771
|
+
data.md5 = this.hash(data, 'md5');
|
|
1737
1772
|
data.sha256 = this.hash(data, 'sha256');
|
|
1738
1773
|
data.sha512 = this.hash(data, 'sha512');
|
|
1739
1774
|
|
|
@@ -1748,22 +1783,27 @@ class Deva {
|
|
|
1748
1783
|
contexts() {
|
|
1749
1784
|
if (!this._active) return this._messages.offline; // check the active status
|
|
1750
1785
|
const id = this.uid();
|
|
1751
|
-
|
|
1752
|
-
|
|
1786
|
+
const key = 'contexts';
|
|
1787
|
+
this.action(key, id.uid);
|
|
1788
|
+
|
|
1789
|
+
this.state('data', `${key}:${id.uid}`);
|
|
1753
1790
|
const data = {
|
|
1754
1791
|
id,
|
|
1792
|
+
key,
|
|
1793
|
+
value: this.vars.context || false,
|
|
1755
1794
|
agent: this.agent(),
|
|
1756
1795
|
client: this.client(),
|
|
1757
|
-
key: 'contexts',
|
|
1758
|
-
value: this.vars.context || false,
|
|
1759
1796
|
created: Date.now(),
|
|
1760
1797
|
};
|
|
1761
1798
|
|
|
1762
|
-
data.md5
|
|
1763
|
-
data.
|
|
1799
|
+
this.action('hash', `${data.key}:md5:${data.id.uid}`);
|
|
1800
|
+
data.md5 = this.hash(data, 'md5');
|
|
1801
|
+
this.action('hash', `${data.key}:sha256:${data.id.uid}`);
|
|
1802
|
+
data.sha256 = this.hash(data, 'sha256');
|
|
1803
|
+
this.action('hash', `${data.key}:sha512:${data.id.uid}`);
|
|
1764
1804
|
data.sha512 = this.hash(data, 'sha512');
|
|
1765
1805
|
|
|
1766
|
-
this.state('return',
|
|
1806
|
+
this.state('return', `${data.key}:${id.uid}`);
|
|
1767
1807
|
return data;
|
|
1768
1808
|
}
|
|
1769
1809
|
|
|
@@ -2062,17 +2102,23 @@ class Deva {
|
|
|
2062
2102
|
describe: Unload a currently loaded Deva.
|
|
2063
2103
|
***************/
|
|
2064
2104
|
unload(key) {
|
|
2065
|
-
this.zone('unload', key);
|
|
2066
2105
|
return new Promise((resolve, reject) => {
|
|
2106
|
+
if (!this._active) return resolve(this._messages.offline); // check the active status
|
|
2107
|
+
this.zone('unload', key);
|
|
2108
|
+
this.action('unload', key);
|
|
2109
|
+
this.state('unload', key);
|
|
2110
|
+
|
|
2111
|
+
this.state('try', `unload:${key}`);
|
|
2067
2112
|
try {
|
|
2068
|
-
this.action('unload', key);
|
|
2069
2113
|
this.devas[key].stop().then(exit => {
|
|
2070
2114
|
delete this.devas[key];
|
|
2115
|
+
this.action('talk', `${this._events.unload}:${key}`);
|
|
2071
2116
|
this.talk(this._events.unload, key);
|
|
2072
2117
|
});
|
|
2073
|
-
this.
|
|
2074
|
-
return resolve(
|
|
2118
|
+
this.action('resolve', `unload:${key}`);
|
|
2119
|
+
return resolve(exit);
|
|
2075
2120
|
} catch (e) {
|
|
2121
|
+
this.state('catch', `unload:${key}`);
|
|
2076
2122
|
return this.err(e, this.devas[key], reject)
|
|
2077
2123
|
}
|
|
2078
2124
|
});
|
|
@@ -2108,7 +2154,7 @@ class Deva {
|
|
|
2108
2154
|
}
|
|
2109
2155
|
|
|
2110
2156
|
this.action('hash', `${key}:${value}:md5:${data.id.uid}`);
|
|
2111
|
-
data.md5 = this.hash(data); // md5 the data packet
|
|
2157
|
+
data.md5 = this.hash(data, 'md5'); // md5 the data packet
|
|
2112
2158
|
|
|
2113
2159
|
this.action('hash', `${key}:${value}:sha256:${data.id.uid}`);
|
|
2114
2160
|
data.sha256 = this.hash(data, 'sha256'); // sha256 the data packet
|
|
@@ -2182,7 +2228,7 @@ class Deva {
|
|
|
2182
2228
|
data.id = id;
|
|
2183
2229
|
data.created = Date.now();
|
|
2184
2230
|
|
|
2185
|
-
data.md5 = this.hash(data);
|
|
2231
|
+
data.md5 = this.hash(data, 'md5');
|
|
2186
2232
|
data.sha256 = this.hash(data, 'sha256');
|
|
2187
2233
|
data.sha512 = this.hash(data, 'sha512');
|
|
2188
2234
|
|
|
@@ -2226,10 +2272,10 @@ class Deva {
|
|
|
2226
2272
|
***************/
|
|
2227
2273
|
help(msg, help_dir) {
|
|
2228
2274
|
return new Promise((resolve, reject) => {
|
|
2275
|
+
if (!this._active) return resolve(this._messages.offline);
|
|
2229
2276
|
let helpDoc = false;
|
|
2230
2277
|
const id = this.uid();
|
|
2231
2278
|
this.zone('help', id);
|
|
2232
|
-
if (!this._active) return resolve(this._messages.offline);
|
|
2233
2279
|
|
|
2234
2280
|
this.feature('help', id.uid);
|
|
2235
2281
|
this.action('help', id.uid);
|
|
@@ -2310,7 +2356,7 @@ class Deva {
|
|
|
2310
2356
|
packet,
|
|
2311
2357
|
created: Date.now(),
|
|
2312
2358
|
}
|
|
2313
|
-
data.md5 = this.hash(data);
|
|
2359
|
+
data.md5 = this.hash(data, 'md5');
|
|
2314
2360
|
data.sha256 = this.hash(data, 'sha256');
|
|
2315
2361
|
data.sha512 = this.hash(data, 'sha512');
|
|
2316
2362
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "44091450722329207445",
|
|
3
3
|
"name": "@indra.ai/deva",
|
|
4
|
-
"version": "1.6.
|
|
4
|
+
"version": "1.6.96",
|
|
5
5
|
"description": "Deva Core a Vedic-inspired Event Based Context Aware Feature, Zone, Action, and State Machine integrated Artificial Intelligence Framework",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"license": "VLA:44091450722329207445 LICENSE.md",
|