@indra.ai/deva 1.5.16 → 1.5.17
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 +9 -16
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1042,7 +1042,6 @@ class Deva {
|
|
|
1042
1042
|
|
|
1043
1043
|
if (!value || !this._zones[value] || value === this._zone) return;
|
|
1044
1044
|
|
|
1045
|
-
this.state('try', `zone:${value}:${id}`)
|
|
1046
1045
|
try {
|
|
1047
1046
|
this._zone = value;
|
|
1048
1047
|
const lookup = this._zones[value]; // set the lookup value
|
|
@@ -1059,7 +1058,6 @@ class Deva {
|
|
|
1059
1058
|
};
|
|
1060
1059
|
data.hash = this.lib.hash(data);
|
|
1061
1060
|
this.talk(config.events.zone, data);
|
|
1062
|
-
this.state('return', `zone:${value}:${id}`);
|
|
1063
1061
|
return data;
|
|
1064
1062
|
} catch (e) {
|
|
1065
1063
|
this.state('catch', `zone:${value}:${id}`);
|
|
@@ -1095,7 +1093,6 @@ class Deva {
|
|
|
1095
1093
|
***************/
|
|
1096
1094
|
action(value=false, extra=false) {
|
|
1097
1095
|
const id = this.lib.uid();
|
|
1098
|
-
this.state('try', `action:${value}:${id}`);
|
|
1099
1096
|
try {
|
|
1100
1097
|
if (!value || !this._actions[value] || value === this._action) return;
|
|
1101
1098
|
this._action = value; // set the local action variable
|
|
@@ -1116,7 +1113,6 @@ class Deva {
|
|
|
1116
1113
|
};
|
|
1117
1114
|
data.hash = this.lib.hash(data); // generate a hash of the action packet.
|
|
1118
1115
|
this.talk(config.events.action, data); // talk the core action event
|
|
1119
|
-
this.state('return', `action:${value}:${id}`);
|
|
1120
1116
|
return data;
|
|
1121
1117
|
} catch (e) { // catch any errors that occur
|
|
1122
1118
|
this.state('catch', `action:${value}:${id}`);
|
|
@@ -1154,8 +1150,6 @@ class Deva {
|
|
|
1154
1150
|
***************/
|
|
1155
1151
|
feature(value=false, extra=false) {
|
|
1156
1152
|
const id = this.lib.uid();
|
|
1157
|
-
this.action('feature', value);
|
|
1158
|
-
this.state('try', `feature:${value}:${id}`);
|
|
1159
1153
|
try {
|
|
1160
1154
|
if (!value || !this._features[value]) return; // check feature value
|
|
1161
1155
|
|
|
@@ -1172,7 +1166,6 @@ class Deva {
|
|
|
1172
1166
|
};
|
|
1173
1167
|
data.hash = this.lib.hash(data); // generate the hash value of the data packet
|
|
1174
1168
|
this.talk(config.events.feature, data); // talk the feature event with data
|
|
1175
|
-
this.state('return', `feature:${value}:${id}`);
|
|
1176
1169
|
return data;
|
|
1177
1170
|
} catch (e) { // catch any errors
|
|
1178
1171
|
this.state('catch', `feature:${value}:${id}`);
|
|
@@ -1210,11 +1203,8 @@ class Deva {
|
|
|
1210
1203
|
***************/
|
|
1211
1204
|
context(value=false, extra=false) {
|
|
1212
1205
|
const id = this.lib.uid();
|
|
1213
|
-
this.action('context', `${value}:${id}`);
|
|
1214
|
-
this.state('try', `context:${value}:${id}`);
|
|
1215
1206
|
try {
|
|
1216
1207
|
if (!value) return;
|
|
1217
|
-
this.state('set', `context:${value}:${id}`);
|
|
1218
1208
|
this._context = value;
|
|
1219
1209
|
const lookup = this.vars.context[value] || value;
|
|
1220
1210
|
const text = extra ? `${lookup} ${extra}` : lookup;
|
|
@@ -1230,7 +1220,6 @@ class Deva {
|
|
|
1230
1220
|
};
|
|
1231
1221
|
data.hash = this.lib.hash(data);
|
|
1232
1222
|
this.talk(config.events.context, data);
|
|
1233
|
-
this.state('return', `context:${value}:${id}`);
|
|
1234
1223
|
return data;
|
|
1235
1224
|
} catch (e) {
|
|
1236
1225
|
this.state('catch', `context:${value}:${id}`);
|
|
@@ -1239,16 +1228,20 @@ class Deva {
|
|
|
1239
1228
|
}
|
|
1240
1229
|
|
|
1241
1230
|
contexts() {
|
|
1231
|
+
const id = this.lib.uid();
|
|
1232
|
+
this.action('contexts', id);
|
|
1242
1233
|
if (!this._active) return this._messages.offline; // check the active status
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
id: this.lib.uid(),
|
|
1234
|
+
const data = {
|
|
1235
|
+
id,
|
|
1246
1236
|
agent: this.agent(),
|
|
1247
1237
|
client: this.client(),
|
|
1248
1238
|
key: 'contexts',
|
|
1249
1239
|
value: this.vars.context || false,
|
|
1250
|
-
created: Date.now(),
|
|
1251
|
-
}
|
|
1240
|
+
created: Date.now(),
|
|
1241
|
+
};
|
|
1242
|
+
data.hash = this.lib.hash(data);
|
|
1243
|
+
this.state('return', `contexts:${id}`);
|
|
1244
|
+
return data;
|
|
1252
1245
|
}
|
|
1253
1246
|
|
|
1254
1247
|
/**************
|