@indra.ai/deva.data 0.1.6 → 0.1.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.
Files changed (2) hide show
  1. package/feature/methods.js +41 -12
  2. package/package.json +2 -2
@@ -12,28 +12,57 @@ export default {
12
12
  async data(packet) {
13
13
  const info = this.info();
14
14
  const agent = this.agent();
15
+ const client = this.client();
15
16
  const {id, q} = packet;
16
17
  const {meta, text, data} = q;
17
18
  const {params} = meta;
18
19
  const method = params[1] ? params[1] : 'insert';
19
20
  const collection = params[2] ? params[2] : 'PersonalVault';
20
21
  const database = params[3] ? params[3] : `${agent.id}-${agent.profile.name.replace(/\s/g, '')}`;
21
- const answer = await this.question(`${this.askChr}data ${method}:${collection}:${database} ${text}`, {id:q.id, content:q.text});
22
-
23
- console.log('ANSWER', JSON.stringify(answer, null, 2));
24
-
25
- this.prompt(`database: ${database}`);
26
- this.prompt(`collection: ${collection}`);
27
- this.prompt(`method: ${method}`);
28
- this.prompt(`text: ${text}`);
29
-
22
+
23
+ this.state('data', `data_packet:${id.uid}`); // set state data
24
+ const data_packet = {
25
+ id,
26
+ content: q.text,
27
+ client: client.id,
28
+ agent: agent.id,
29
+ method,
30
+ collection,
31
+ database,
32
+ created: Date.now(),
33
+ };
34
+
35
+ this.action('hash', `data:${method}:md5:${id.uid}`); // set action hash
36
+ data_packet.md5 = this.hash(data_packet, 'md5');
37
+ this.action('hash', `data:${method}:sha256:${id.uid}`); // set action hash
38
+ data_packet.sha256 = this.hash(data_packet, 'sha256');
39
+ this.action('hash', `data:${method}:sha512:${id.uid}`); // set action hash
40
+ data_packet.sha512 = this.hash(data_packet, 'sha512');
41
+
42
+ const answer = await this.question(`${this.askChr}data ${method}:${collection}:${database} ${text}`, data_packet);
43
+ data_packet.insertedId = answer.a.data.insertedId;
44
+
45
+ const data_prompt = [
46
+ `::begin:data:${method}:${id.uid}`,
47
+ `content: ${data_packet.content}`,
48
+ `uid: ${id.uid}`,
49
+ `insertedId: ${data_packet.insertedId}`,
50
+ `collection: ${data_packet.collection}`,
51
+ `database: ${data_packet.database}`,
52
+ `md5: ${data_packet.md5}`,
53
+ `sha256: ${data_packet.sha256}`,
54
+ `sha512: ${data_packet.sha512}`,
55
+ `created: ${this.lib.formatDate(data_packet.created, 'long', true)}`,
56
+ `::end:data:${method}:${id.uid}`,
57
+ ].join('\n');
58
+
30
59
  this.action('resolve', `data:${packet.id.uid}`); // set action reject
31
60
  this.state('valid', `data:${packet.id.uid}`); // set action reject
32
61
  this.intent('good', `data:${packet.id.uid}`);
33
62
  return {
34
- text: answer.a.text,
35
- html: answer.a.html,
36
- data: answer.a.data,
63
+ text: data_prompt,
64
+ html: false,
65
+ data: data_packet,
37
66
  }
38
67
  },
39
68
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "65859204002504361305",
3
3
  "name": "@indra.ai/deva.data",
4
- "version": "0.1.6",
4
+ "version": "0.1.7",
5
5
  "license": "VLA:65859204002504361305 LICENSE.md",
6
6
  "VLA": {
7
7
  "uid": "65859204002504361305",
@@ -59,7 +59,7 @@
59
59
  },
60
60
  "homepage": "https://indra.ai",
61
61
  "dependencies": {
62
- "@indra.ai/deva": "^1.20.2",
62
+ "@indra.ai/deva": "^1.20.3",
63
63
  "mongodb": "^6.13.0"
64
64
  },
65
65
  "data": {