@indra.ai/deva 1.4.10 → 1.4.12

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 +28 -81
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1192,6 +1192,8 @@ class Deva {
1192
1192
  client() {
1193
1193
  if (!this._active) return this._messages.offline; // check the active status
1194
1194
  const client_copy = this.lib.copy(this._client); // create a copy of the client data
1195
+ client_copy.hash = this.lib.hash(client_copy);
1196
+ client_copy.created = Date.now();
1195
1197
  return client_copy; // return the copy of the client data.
1196
1198
  }
1197
1199
 
@@ -1204,9 +1206,26 @@ class Deva {
1204
1206
  agent() {
1205
1207
  if (!this._active) return this._messages.offline; // check the active status
1206
1208
  const agent_copy = this.lib.copy(this._agent); // create a copy of the agent data.
1209
+ agent_copy.hash = this.lib.hash(agent_copy);
1210
+ agent_copy.created = Date.now();
1207
1211
  return agent_copy; // return the copy of the agent data.
1208
1212
  }
1209
1213
 
1214
+ _feature(key, value) {
1215
+ if (!this._active) return this._messages.offline; // check the active status
1216
+ this.zone(key);
1217
+ this.feature(key); // set the security state
1218
+ try {
1219
+ const data = this.lib.copy(value);
1220
+ data.id = this.lib.uid();
1221
+ data.hash = this.lib.hash(value);
1222
+ data.created = Date.now();
1223
+ this.state('return', key); // set the security state
1224
+ return data; // return the security feature
1225
+ } catch (e) {
1226
+ return this.error(e);
1227
+ }
1228
+ }
1210
1229
  // FEATURE FUNCTIONS
1211
1230
  /**************
1212
1231
  func: security
@@ -1215,15 +1234,7 @@ class Deva {
1215
1234
  usage: this.security()
1216
1235
  ***************/
1217
1236
  security() {
1218
- if (!this._active) return this._messages.offline; // check the active status
1219
- this.zone('security');
1220
- this.feature('security'); // set the security state
1221
- try {
1222
- this.state('return', 'security'); // set the security state
1223
- return this.lib.copy(this._security); // return the security feature
1224
- } catch (e) {
1225
- return this.error(e);
1226
- }
1237
+ return this._feature('security', this._security);
1227
1238
  }
1228
1239
 
1229
1240
  /**************
@@ -1233,15 +1244,7 @@ class Deva {
1233
1244
  usage: this.defense()
1234
1245
  ***************/
1235
1246
  defense() {
1236
- if (!this._active) return this._messages.offline; // check the active status
1237
- this.zone('defense');
1238
- this.feature('defense'); // set the defense state
1239
- try {
1240
- this.state('return', 'defense'); // set the defense state
1241
- return this.lib.copy(this._defense); // return the defense feature
1242
- } catch (e) {
1243
- return this.error(e);
1244
- }
1247
+ return this._feature('defense', this._defense);
1245
1248
  }
1246
1249
 
1247
1250
  /**************
@@ -1251,15 +1254,7 @@ class Deva {
1251
1254
  usage: this.support()
1252
1255
  ***************/
1253
1256
  support() {
1254
- if (!this._active) return this._messages.offline; // check the active status
1255
- this.zone('support');
1256
- this.feature('support'); // set the support state
1257
- try {
1258
- this.state('return', 'support'); // set the action to support.
1259
- return this.lib.copy(this._support); // return the support feature
1260
- } catch (e) {
1261
- return this.error(e); // return this.error when error catch
1262
- }
1257
+ return this._feature('support', this._support);
1263
1258
  }
1264
1259
 
1265
1260
  /**************
@@ -1269,15 +1264,7 @@ class Deva {
1269
1264
  usage: this.services()
1270
1265
  ***************/
1271
1266
  services() {
1272
- if (!this._active) return this._messages.offline; // check the active status
1273
- this.zone('services');
1274
- this.feature('services'); // set the support state
1275
- try {
1276
- this.state('return', 'services'); // set the services state
1277
- return this.lib.copy(this._services); // return the services feature
1278
- } catch (e) {
1279
- return this.error(e); // return this.error when error catch
1280
- }
1267
+ return this._feature('services', this._services);
1281
1268
  }
1282
1269
 
1283
1270
  /**************
@@ -1287,15 +1274,7 @@ class Deva {
1287
1274
  usage: this.systems()
1288
1275
  ***************/
1289
1276
  systems() {
1290
- if (!this._active) return this._messages.offline; // check the active status
1291
- this.zone('systems');
1292
- this.feature('systems'); // set the support state
1293
- try {
1294
- this.state('return', 'systems'); // set the systems state
1295
- return this.lib.copy(this._systems); // return the systems feature
1296
- } catch (e) {
1297
- return this.error(e); // return this.error when error catch
1298
- }
1277
+ return this._feature('systems', this._systems);
1299
1278
  }
1300
1279
 
1301
1280
  /**************
@@ -1305,15 +1284,7 @@ class Deva {
1305
1284
  usage: this.networks()
1306
1285
  ***************/
1307
1286
  networks() {
1308
- if (!this._active) return this._messages.offline; // check the active status
1309
- this.zone('networks');
1310
- this.feature('networks'); // set the support state
1311
- try {
1312
- this.state('return', 'networks'); // set the networks state
1313
- return this.lib.copy(this._networks); // return the networks feature
1314
- } catch (e) {
1315
- return this.error(e); // return this.error when error catch
1316
- }
1287
+ return this._feature('networks', this._networks);
1317
1288
  }
1318
1289
 
1319
1290
  /**************
@@ -1323,15 +1294,7 @@ class Deva {
1323
1294
  usage: this.systems()
1324
1295
  ***************/
1325
1296
  legal() {
1326
- if (!this._active) return this._messages.offline; // check the active status
1327
- this.zone('legal');
1328
- this.feature('legal'); // set the support state
1329
- try {
1330
- this.state('return', 'legal'); // set the systems state
1331
- return this.lib.copy(this._legal); // return the systems feature
1332
- } catch (e) {
1333
- return this.error(e); // return this.error when error catch
1334
- }
1297
+ return this._feature('legal', this._legal);
1335
1298
  }
1336
1299
 
1337
1300
  /**************
@@ -1341,15 +1304,7 @@ class Deva {
1341
1304
  usage: this.systems()
1342
1305
  ***************/
1343
1306
  justice() {
1344
- if (!this._active) return this._messages.offline; // check the active status
1345
- this.zone('justice');
1346
- this.feature('justice'); // set the support state
1347
- try {
1348
- this.state('return', 'justice'); // set the systems state
1349
- return this.lib.copy(this._justice); // return the systems feature
1350
- } catch (e) {
1351
- return this.error(e); // return this.error when error catch
1352
- }
1307
+ return this._feature('legal', this._legal);
1353
1308
  }
1354
1309
 
1355
1310
  /**************
@@ -1359,15 +1314,7 @@ class Deva {
1359
1314
  usage: this.systems()
1360
1315
  ***************/
1361
1316
  authority() {
1362
- if (!this._active) return this._messages.offline; // check the active status
1363
- this.zone('authority');
1364
- this.feature('authority'); // set the support state
1365
- try {
1366
- this.state('return', 'authority'); // set the systems state
1367
- return this.lib.copy(this._authority); // return the systems feature
1368
- } catch (e) {
1369
- return this.error(e); // return this.error when error catch
1370
- }
1317
+ return this._feature('authority', this._authority);
1371
1318
  }
1372
1319
 
1373
1320
  /**************
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indra.ai/deva",
3
- "version": "1.4.10",
3
+ "version": "1.4.12",
4
4
  "description": "The Deva Core",
5
5
  "main": "index.js",
6
6
  "type": "module",