@indra.ai/deva 1.3.3 → 1.3.4

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 (3) hide show
  1. package/config.json +11 -16
  2. package/index.js +101 -44
  3. package/package.json +1 -1
package/config.json CHANGED
@@ -45,7 +45,7 @@
45
45
  "support": "💼 Support",
46
46
  "services": "🛠️ Services",
47
47
  "systems": "📡 Systems",
48
- "legal": "👨‍⚖️️ Legal",
48
+ "legal": "🏛️ Legal",
49
49
  "authority": "👮‍♂️ Authority",
50
50
  "help": "💚 Help",
51
51
  "error": "❌ Error!"
@@ -86,7 +86,7 @@
86
86
  "unload": "🛻 unload",
87
87
  "resolve": "🔬 resolve",
88
88
  "reject": "🧱 reject",
89
- "done": " done",
89
+ "done": "👍 done",
90
90
  "data": "📡 data",
91
91
  "finish": "🏁 finish",
92
92
  "complete": "⌛️ complete",
@@ -133,10 +133,10 @@
133
133
  "stop": "🛑 stop",
134
134
  "load": "📦 load",
135
135
  "unload": "🥡 unload",
136
- "done": "📝 done",
137
136
  "finish": "🏁 finish",
138
- "complete": "👍 complete",
139
- "ready": "✅ ready",
137
+ "complete": " complete",
138
+ "done": "☑️ done",
139
+ "ready": "🟢 ready",
140
140
  "question": "🙋 question",
141
141
  "talk": "📢 talk",
142
142
  "context": "📇 context",
@@ -171,17 +171,12 @@
171
171
  "answer": "💡 Answer",
172
172
  "ask": "📣 Ask",
173
173
 
174
- "security": "🚨 Security",
175
- "support": "❤️ Support",
176
- "services": "🛠️ Services",
177
- "systems": "💻️ Systems",
178
-
179
- "Client": " Client",
180
- "Security": "🚓 Security",
181
- "Support": "🚑 Support",
182
- "Services": "🚚 Services",
183
- "Systems": "🚛 Systems",
184
- "Done": "☑️ Done",
174
+ "client": "👨 Client",
175
+ "security": "🚓 Security",
176
+ "support": "🚑 Support",
177
+ "services": "🚚 Services",
178
+ "systems": "🚛 Systems",
179
+ "legal": "⚖️ Legal",
185
180
 
186
181
  "invalid": "❌ Invalid",
187
182
  "states": "🛻 States",
package/index.js CHANGED
@@ -21,6 +21,7 @@ class Deva {
21
21
  this._support = false; // inherited Support features.
22
22
  this._services = false; // inherited Service features.
23
23
  this._systems = false; // inherited Service features.
24
+ this._legal = false; // inherited Service features.
24
25
  this.events = opts.events || new EventEmitter({}); // Event Bus
25
26
  this.lib = new lib({}); // used for loading library functions
26
27
  this.utils = opts.utils || {}; // parse function
@@ -188,21 +189,25 @@ class Deva {
188
189
  usage:
189
190
  this.Client = {data}
190
191
  ***************/
191
- Client(client) {
192
- this.action('Client');
192
+ Client(client, resolve, reject) {
193
+ this.action('client');
193
194
  // setup any custom methods for the features
194
- for (const x in client.features) {
195
- const methods = client.features[x].methods || false;
196
- if (methods) for (const y in methods) {
197
- const isFunc = typeof methods[y] === 'function';
198
- if (isFunc) {
199
- this.methods[y] = methods[y].bind(this);
195
+ try {
196
+ for (const x in client.features) {
197
+ const methods = client.features[x].methods || false;
198
+ if (methods) for (const y in methods) {
199
+ const isFunc = typeof methods[y] === 'function';
200
+ if (isFunc) {
201
+ this.methods[y] = methods[y].bind(this);
202
+ }
200
203
  }
201
204
  }
205
+ const _client = this.lib.copy(client); // copy the client parameter
206
+ this._client = _client; // set local _client to this scope
207
+ return resolve();
208
+ } catch (e) {
209
+ return this.error(e, false, reject);
202
210
  }
203
- const _client = this.lib.copy(client); // copy the client parameter
204
- this._client = _client; // set local _client to this scope
205
- return Promise.resolve();
206
211
  }
207
212
 
208
213
  /**************
@@ -212,9 +217,9 @@ class Deva {
212
217
  The Security feature sets the correct variables and necessary rules for the
213
218
  client presented data.
214
219
  ***************/
215
- Security() {
220
+ Security(resolve, reject) {
216
221
  this.zone('security');
217
- this.action('Security'); // set action to Security
222
+ this.action('security'); // set action to Security
218
223
  const _cl = this.client(); // set local copy of client data
219
224
  try {
220
225
  if (!_cl.features.security) return this.Support(); // if no security feature goto Support
@@ -233,7 +238,7 @@ class Deva {
233
238
  personal: security.devas[this._agent.key], // Client personal features and rules.
234
239
  };
235
240
  delete this._client.features.security; // make a copy the clinet data.
236
- return Promise.resolve(); // goto Support when done with Security
241
+ return resolve(); // goto Support when done with Security
237
242
  }
238
243
  } catch (e) {
239
244
  this.state('reject', 'Security');
@@ -248,9 +253,9 @@ class Deva {
248
253
  The Support feature sets the correct variables and necessary rules for the
249
254
  client presented data.
250
255
  ***************/
251
- Support() {
256
+ Support(resolve, reject) {
252
257
  this.zone('support');
253
- this.action('Support');
258
+ this.action('support');
254
259
  const _cl = this.client(); // set the local client variable
255
260
  try {
256
261
  if (!_cl.features.support) return Promise.resolve() // move to Services if no support feature
@@ -267,11 +272,11 @@ class Deva {
267
272
  personal: support.devas[this._agent.key], // Client personalSecurity features and rules.
268
273
  };
269
274
  delete this._client.features.support; // delete the support key from the client
270
- return Promise.resolve(); // when done move to Services
275
+ return resolve(); // when done move to Services
271
276
  }
272
277
  } catch (e) {
273
278
  this.state('reject', 'Services');
274
- return this.error(e); // run error handling if an error is caught
279
+ return this.error(e, false, reject); // run error handling if an error is caught
275
280
  }
276
281
  }
277
282
 
@@ -282,9 +287,9 @@ class Deva {
282
287
  The Services feature sets the correct variables and necessary rules for the
283
288
  client presented data.
284
289
  ***************/
285
- Services() {
290
+ Services(resolve, reject) {
286
291
  this.zone('services')
287
- this.action('Services');
292
+ this.action('services');
288
293
  const _cl = this.client(); // set local client
289
294
  try {
290
295
  if (!_cl.features.services) return Promise.resolve(); // move to Done if no Services feature
@@ -301,11 +306,11 @@ class Deva {
301
306
  personal: services.devas[this._agent.key], // Client personal features and rules.
302
307
  };
303
308
  delete this._client.features.services; // delete the services key for isolation
304
- return Promise.resolve(); // go to Done
309
+ return resolve(); // go to Done
305
310
  }
306
311
  } catch (e) {
307
312
  this.state('reject', 'Services');
308
- return this.error(e); // run error handling if an error is caught
313
+ return this.error(e, false, reject); // run error handling if an error is caught
309
314
  }
310
315
  }
311
316
 
@@ -316,9 +321,9 @@ class Deva {
316
321
  The Systems feature sets the correct variables and necessary rules for the
317
322
  client presented data.
318
323
  ***************/
319
- Systems() {
324
+ Systems(resolve, reject) {
320
325
  this.zone('systems')
321
- this.action('Systems');
326
+ this.action('systems');
322
327
  const _cl = this.client(); // set local client
323
328
  try {
324
329
  if (!_cl.features.services) return Promise.resolve(); // move to Done if no Systems feature
@@ -335,11 +340,45 @@ class Deva {
335
340
  personal: services.devas[this._agent.key], // Client personal features and rules.
336
341
  };
337
342
  delete this._client.features.services; // delete the services key for isolation
338
- return Promise.resolve(); // go to Done
343
+ return resolve(); // go to Done
339
344
  }
340
345
  } catch (e) {
341
346
  this.state('reject', 'Systems');
342
- return this.error(e); // run error handling if an error is caught
347
+ return this.error(e, false, reject); // run error handling if an error is caught
348
+ }
349
+ }
350
+
351
+ /**************
352
+ func: Legal
353
+ params: client: false
354
+ describe:
355
+ The Legal feature sets the correct variables and necessary rules for the
356
+ client presented data.
357
+ ***************/
358
+ Legal(resolve, reject) {
359
+ this.zone('legal')
360
+ this.action('legal');
361
+ const _cl = this.client(); // set local client
362
+ try {
363
+ if (!_cl.features.legal) return Promise.resolve(); // move to Done if no Systems feature
364
+ else {
365
+ this.state('set', 'Legal');
366
+ const {id, features, profile} = _cl; // set the local consts from client copy
367
+ const {legal} = features; // set services from features const
368
+ this._legal = { // set this_services with data
369
+ id: this.lib.uid(true), // uuid of the services feature
370
+ client_id: id, // client id for reference
371
+ client_name: profile.name, // client name for personalization
372
+ concerns: legal.concerns, // any concerns for client
373
+ global: legal.global, // the global policies for client
374
+ personal: legal.devas[this._agent.key], // Client personal features and rules.
375
+ };
376
+ delete this._client.features.legal; // delete the services key for isolation
377
+ return resolve(); // go to Done
378
+ }
379
+ } catch (e) {
380
+ this.state('reject', 'Legal');
381
+ return this.error(e, false, reject); // run error handling if an error is caught
343
382
  }
344
383
  }
345
384
 
@@ -348,18 +387,16 @@ class Deva {
348
387
  params: none
349
388
  describe: The end of the workflow Client Feature Workflow
350
389
  ***************/
351
- Done() {
352
- this.action('Done');
353
- return new Promise((resolve, reject) => {
354
- try {
355
- this.state('Done');
356
- delete this._client.features; // delete the features key when done.
357
- return resolve(this.client()); // resolve an empty pr
358
- } catch (e) {
359
- this.state('reject', 'Done');
360
- return this.error(e, false, reject);
361
- }
362
- });
390
+ Done(resolve, reject) {
391
+ this.action('done');
392
+ try {
393
+ this.state('Done');
394
+ delete this._client.features; // delete the features key when done.
395
+ return resolve(this.client()); // resolve an empty pr
396
+ } catch (e) {
397
+ this.state('reject', 'Done');
398
+ return this.error(e, false, reject);
399
+ }
363
400
  }
364
401
 
365
402
  /**************
@@ -684,17 +721,19 @@ class Deva {
684
721
  }).then(() => {
685
722
  return this._assignListeners();
686
723
  }).then(() => {
687
- return this.Client(client);
724
+ return this.Client(client, resolve, reject);
725
+ }).then(() => {
726
+ return this.Security(resolve, reject);
688
727
  }).then(() => {
689
- return this.Security();
728
+ return this.Services(resolve, reject);
690
729
  }).then(() => {
691
- return this.Services();
730
+ return this.Support(resolve, reject);
692
731
  }).then(() => {
693
- return this.Support();
732
+ return this.Systems(resolve, reject);
694
733
  }).then(() => {
695
- return this.Systems();
734
+ return this.Legal(resolve, reject);
696
735
  }).then(() => {
697
- return this.Done();
736
+ return this.Done(resolve, reject);
698
737
  }).then(() => {
699
738
  this.zone('init');
700
739
  const hasOnInit = this.onInit && typeof this.onInit === 'function';
@@ -1256,6 +1295,24 @@ class Deva {
1256
1295
  }
1257
1296
  }
1258
1297
 
1298
+ /**************
1299
+ func: legal
1300
+ params: none
1301
+ describe: basic legal features available in a Deva.
1302
+ usage: this.systems()
1303
+ ***************/
1304
+ systems() {
1305
+ if (!this._active) return this._messages.offline; // check the active status
1306
+ this.zone('legal');
1307
+ this.feature('legal'); // set the support state
1308
+ try {
1309
+ this.state('return', 'legal'); // set the systems state
1310
+ return this.lib.copy(this._legal); // return the systems feature
1311
+ } catch (e) {
1312
+ return this.error(e); // return this.error when error catch
1313
+ }
1314
+ }
1315
+
1259
1316
  /**************
1260
1317
  func: load
1261
1318
  params:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indra.ai/deva",
3
- "version": "1.3.3",
3
+ "version": "1.3.4",
4
4
  "description": "The Deva Core",
5
5
  "main": "index.js",
6
6
  "type": "module",