@gudhub/core 1.1.58 → 1.1.59
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/GUDHUB/FieldProcessor/FieldProcessor.js +11 -0
- package/GUDHUB/FieldProcessor/FieldProcessor.test.js +5 -0
- package/GUDHUB/PipeService/PipeService.test.js +1 -2
- package/GUDHUB/Utils/json_constructor/json_constructor.js +4 -1
- package/GUDHUB/Utils/json_constructor/json_constructor.test.js +25 -1
- package/GUDHUB/config.js +1 -1
- package/GUDHUB/gudhub.js +4 -0
- package/package.json +1 -1
- package/umd/library.min.js +4 -4
- package/umd/library.min.js.map +1 -1
|
@@ -98,6 +98,17 @@ export class FieldProcessor {
|
|
|
98
98
|
return null;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
async getFieldIdByNameSpace(app_id, name_space) {
|
|
102
|
+
const app = await this.appProcessor.getApp(app_id);
|
|
103
|
+
if(!app) return null;
|
|
104
|
+
for(let i = 0; i < app.field_list.length; i++) {
|
|
105
|
+
if(app.field_list[i].name_space == name_space) {
|
|
106
|
+
return app.field_list[i].field_id;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
|
|
101
112
|
//!!!!! Shou Be Renamed to getFields() !!!!!!!
|
|
102
113
|
async getFieldModels(app_id) {
|
|
103
114
|
const app = await this.appProcessor.getApp(app_id);
|
|
@@ -12,6 +12,11 @@ describe("FIELD PROCESSOR", async function() {
|
|
|
12
12
|
(typeof fieldModel).should.equal('object');
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
+
it("GET FIELD ID BY NAMESPACE / should return a field id", async function() {
|
|
16
|
+
const fieldId = await gudhub.getFieldIdByNameSpace(16259, 'name');
|
|
17
|
+
fieldId.should.equal(254056);
|
|
18
|
+
});
|
|
19
|
+
|
|
15
20
|
it('GET FIELD VALUE / should return a field value', async () => {
|
|
16
21
|
let value = await gudhub.getFieldValue(16259, 1064673, 254055);
|
|
17
22
|
value.should.equal('Hall up');
|
|
@@ -68,9 +68,8 @@ describe("PipeService", () => {
|
|
|
68
68
|
gudhub
|
|
69
69
|
.emit("test", { app_id: 4, item_id: 3, field_id: 2 }, {"message" : "this is the data"})
|
|
70
70
|
.on("test", { app_id: 4, item_id: 3, field_id: 2 }, (event, data) => {
|
|
71
|
-
|
|
71
|
+
data.message.should.equal("this is the data");
|
|
72
72
|
});
|
|
73
|
-
incomeData.should.equal("this is the data");
|
|
74
73
|
});
|
|
75
74
|
|
|
76
75
|
|
|
@@ -117,13 +117,16 @@ export function compiler(scheme, item, util, variables, appId) {
|
|
|
117
117
|
let result = scheme.function(item, appId, util.gudhub, ...scheme.args);
|
|
118
118
|
return result;
|
|
119
119
|
} else {
|
|
120
|
-
const func = new Function('item, appId, gudhub', 'return (async ' + scheme.function + ')(item, appId,
|
|
120
|
+
const func = new Function('item, appId, gudhub', 'return (async ' + scheme.function + ')(item, appId, gudhub)');
|
|
121
121
|
let result = await func(item, appId, util.gudhub);
|
|
122
122
|
return result;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
case "field_value":
|
|
126
126
|
default:
|
|
127
|
+
if(!scheme.field_id && scheme.name_space) {
|
|
128
|
+
scheme.field_id = await util.gudhub.getFieldIdByNameSpace(appId, scheme.name_space);
|
|
129
|
+
}
|
|
127
130
|
if (Boolean(Number(scheme.interpretation))) {
|
|
128
131
|
let interpretatedValue = await util.gudhub.getInterpretationById(Number(appId), Number(item.item_id), Number(scheme.field_id), 'value');
|
|
129
132
|
return interpretatedValue;
|
|
@@ -20,13 +20,14 @@ describe("JSON CONSTRUCTOR", function () {
|
|
|
20
20
|
gudhub.ghconstructor.initJsdomWindow(window);
|
|
21
21
|
|
|
22
22
|
it("JSON FROM ONE APP : Here we construct simple json from one App", async function () {
|
|
23
|
-
this.timeout(
|
|
23
|
+
this.timeout(5000);
|
|
24
24
|
//-- checking if json was generated properly
|
|
25
25
|
let json = await gudhub.jsonConstructor(fishtank_scheme);
|
|
26
26
|
json.fishtank[0].should.have.property("name", "Big Fish Tank");
|
|
27
27
|
json.fishtank[0].should.have.property("state", "Normal ");
|
|
28
28
|
});
|
|
29
29
|
it("CHECK INTERPRETATION VALUE FOR FILES: output: we should get url's", async function () {
|
|
30
|
+
this.timeout(5000);
|
|
30
31
|
//-- checking interpretation mode
|
|
31
32
|
let json = await gudhub.jsonConstructor(fishtank_scheme);
|
|
32
33
|
json.fishtank[0].should.have.property("image","https://gudhub.com/userdata/16259/809199.jpg,https://gudhub.com/userdata/16259/811768.png");
|
|
@@ -34,6 +35,7 @@ describe("JSON CONSTRUCTOR", function () {
|
|
|
34
35
|
json.fishtank[0].should.have.property("notes","https://gudhub.com/userdata/16259/811770.html?timestamp=0");
|
|
35
36
|
});
|
|
36
37
|
it("GET FILTERED ITEMS LENGTH WITH CURRENT ITEM FILTER", async function () {
|
|
38
|
+
this.timeout(5000);
|
|
37
39
|
let json = await gudhub.jsonConstructor(currentItemScheme);
|
|
38
40
|
let firstLength = json.scheme[0].array.length;
|
|
39
41
|
let secondLength = json.scheme[1].array.length;
|
|
@@ -42,6 +44,11 @@ describe("JSON CONSTRUCTOR", function () {
|
|
|
42
44
|
secondLength.should.equal(4);
|
|
43
45
|
|
|
44
46
|
});
|
|
47
|
+
it("WORK WITH NAMESPACE INSTEAD OF FIELD ID", async function () {
|
|
48
|
+
this.timeout(5000);
|
|
49
|
+
let json = await gudhub.jsonConstructor(schemeWithNamespace);
|
|
50
|
+
json.scheme[0].name.should.equal("Big Fish Tank");
|
|
51
|
+
});
|
|
45
52
|
});
|
|
46
53
|
|
|
47
54
|
var fishtank_scheme = {
|
|
@@ -146,3 +153,20 @@ let currentItemScheme = {
|
|
|
146
153
|
app_id: "16259",
|
|
147
154
|
filter: [],
|
|
148
155
|
};
|
|
156
|
+
|
|
157
|
+
let schemeWithNamespace = {
|
|
158
|
+
type: "array",
|
|
159
|
+
id: 1,
|
|
160
|
+
childs: [
|
|
161
|
+
{
|
|
162
|
+
type: "property",
|
|
163
|
+
id: 2,
|
|
164
|
+
property_name: "name",
|
|
165
|
+
property_type: "field_value",
|
|
166
|
+
name_space: "name"
|
|
167
|
+
}
|
|
168
|
+
],
|
|
169
|
+
property_name: "scheme",
|
|
170
|
+
app_id: "16259",
|
|
171
|
+
filter: []
|
|
172
|
+
}
|
package/GUDHUB/config.js
CHANGED
|
@@ -3,7 +3,7 @@ export const server_url = "https://gudhub.com/GudHub_Test";
|
|
|
3
3
|
//export const server_url = "https://integration.gudhub.com/GudHub_Test";
|
|
4
4
|
//export const server_url = "http://localhost:9000";
|
|
5
5
|
export const wss_url = "wss://gudhub.com/GudHub/ws/app/";
|
|
6
|
-
export const async_modules_path = 'build/latest/
|
|
6
|
+
export const async_modules_path = 'build/latest/async_modules_node/';
|
|
7
7
|
export const automation_modules_path = 'build/latest/automation_modules/'
|
|
8
8
|
export const file_server_url = 'https://gudhub.com'
|
|
9
9
|
|
package/GUDHUB/gudhub.js
CHANGED
|
@@ -314,6 +314,10 @@ export class GudHub {
|
|
|
314
314
|
return this.fieldProcessor.getField(app_id, field_id);
|
|
315
315
|
}
|
|
316
316
|
|
|
317
|
+
getFieldIdByNameSpace(app_id, name_space) {
|
|
318
|
+
return this.fieldProcessor.getFieldIdByNameSpace(app_id, name_space);
|
|
319
|
+
}
|
|
320
|
+
|
|
317
321
|
getFieldModels(app_id) {
|
|
318
322
|
return this.fieldProcessor.getFieldModels(app_id);
|
|
319
323
|
}
|