@gudhub/core 1.0.39 → 1.0.43
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/Auth/Auth.js +2 -0
- package/GUDHUB/Auth/Auth.test.js +49 -2
- package/GUDHUB/Utils/Utils.js +2 -2
- package/GUDHUB/Utils/interpretation/interpretation.js +1 -1
- package/GUDHUB/Utils/interpretation/interpretation.test.js +11 -0
- package/GUDHUB/Utils/nested_list/nested_list.js +19 -1
- package/GUDHUB/Utils/nested_list/nested_list.test.js +79 -1
- package/GUDHUB/gudhub.js +3 -3
- package/Readme.md +537 -537
- package/fake_server/fake_java_server.js +8 -0
- package/fake_server/fake_server_data/app_16259.js +1152 -1152
- package/index.js +2 -2
- package/indexUMD.js +4 -4
- package/package.json +45 -46
- package/umd/library.min.js +13 -15
- package/umd/library.min.js.map +1 -1
package/GUDHUB/Auth/Auth.js
CHANGED
|
@@ -128,10 +128,12 @@ export class Auth {
|
|
|
128
128
|
async updateUser(userData) {
|
|
129
129
|
const user = await this.updateUserApi(userData);
|
|
130
130
|
this.storage.updateUser(user);
|
|
131
|
+
return user;
|
|
131
132
|
}
|
|
132
133
|
|
|
133
134
|
async updateAvatar(imageData) {
|
|
134
135
|
const user = await this.avatarUploadApi(imageData);
|
|
135
136
|
this.storage.updateUser(user);
|
|
137
|
+
return user;
|
|
136
138
|
}
|
|
137
139
|
}
|
package/GUDHUB/Auth/Auth.test.js
CHANGED
|
@@ -3,13 +3,60 @@ import {GudHub} from './../gudhub.js';
|
|
|
3
3
|
|
|
4
4
|
describe("AUTHORIZATION", async function() {
|
|
5
5
|
const auth_key = 'Z/lxMHLenEaQTvPjW5U6c3jBDwWFYZrh2F9Kxa3fbt8drvabS2u2lXQ2zI+SRmic';
|
|
6
|
-
const gudhub = new GudHub(auth_key);
|
|
7
6
|
|
|
8
7
|
it("GET USER BY ID / It Should return user with 'Vasya Pupkin' fullname", async function () {
|
|
9
|
-
|
|
8
|
+
const gudhub = new GudHub(auth_key);
|
|
10
9
|
var user = await gudhub.auth.getUserById("58");
|
|
11
10
|
|
|
12
11
|
user.fullname.should.equal('Vasya Pupkin');
|
|
13
12
|
})
|
|
14
13
|
|
|
14
|
+
it("Authentication with login and password", async function () {
|
|
15
|
+
const gudhub = new GudHub();
|
|
16
|
+
let credentials = {
|
|
17
|
+
username: 'test@gudhub.com',
|
|
18
|
+
password: 'gudhub'
|
|
19
|
+
}
|
|
20
|
+
var user = await gudhub.login(credentials);
|
|
21
|
+
|
|
22
|
+
user.fullname.should.equal('Vasya Pupkin');
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it("Signing up user", async function () {
|
|
26
|
+
const gudhub = new GudHub();
|
|
27
|
+
let credentials = {
|
|
28
|
+
fullname: "Vasya Pupkin",
|
|
29
|
+
password: "gudhub",
|
|
30
|
+
username: "test@gudhub.com"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
var user = await gudhub.signup(credentials);
|
|
34
|
+
|
|
35
|
+
user.fullname.should.equal('Vasya Pupkin');
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it("Update user", async function() {
|
|
39
|
+
const gudhub = new GudHub(auth_key);
|
|
40
|
+
|
|
41
|
+
const dataToUpdate = {
|
|
42
|
+
fullname: 'Vasya Pupkin'
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const user = await gudhub.updateUser(dataToUpdate);
|
|
46
|
+
|
|
47
|
+
user.fullname.should.equal('Vasya Pupkin');
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it("Update user avatar", async function() {
|
|
51
|
+
const gudhub = new GudHub(auth_key);
|
|
52
|
+
|
|
53
|
+
const dataToUpdate = {
|
|
54
|
+
avatar: '/9j/4AAQSkZJRgABAQAAAQA'
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const user = await gudhub.updateUser(dataToUpdate);
|
|
58
|
+
|
|
59
|
+
user.fullname.should.equal('Vasya Pupkin');
|
|
60
|
+
})
|
|
61
|
+
|
|
15
62
|
});
|
package/GUDHUB/Utils/Utils.js
CHANGED
|
@@ -127,8 +127,8 @@ export class Utils {
|
|
|
127
127
|
return mergeObjects(target, source, optionsArgument);
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
makeNestedList(arr, id, parent_id, children_property) {
|
|
131
|
-
return makeNestedList(arr, id, parent_id, children_property);
|
|
130
|
+
makeNestedList(arr, id, parent_id, children_property, priority_property) {
|
|
131
|
+
return makeNestedList(arr, id, parent_id, children_property, priority_property);
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
mergeChunks(chunks) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import should from "should";
|
|
2
|
+
import {GudHub} from '../../gudhub.js';
|
|
3
|
+
|
|
4
|
+
describe("CHECK INTERPRETATION", function () {
|
|
5
|
+
const gudhub = new GudHub();
|
|
6
|
+
|
|
7
|
+
it("Check radio_button interpretation", async function () {
|
|
8
|
+
let interpretationValue = await gudhub.getInterpretedValue(16259,1064673,270607);
|
|
9
|
+
interpretationValue.should.equal("Normal");
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export function makeNestedList(arr, id, parent_id, children_property) {
|
|
1
|
+
export function makeNestedList(arr, id, parent_id, children_property, priority_property) {
|
|
2
2
|
let array = JSON.parse(JSON.stringify(arr));
|
|
3
3
|
let children = Boolean(children_property) ? children_property : 'children';
|
|
4
|
+
let priority = Boolean(priority_property) ? priority_property : false;
|
|
4
5
|
let i;
|
|
5
6
|
for (i = 0; i < array.length; i++) {
|
|
6
7
|
if (array[i][parent_id] && array[i][parent_id] !== 0) {
|
|
@@ -34,5 +35,22 @@ export function makeNestedList(arr, id, parent_id, children_property) {
|
|
|
34
35
|
});
|
|
35
36
|
}
|
|
36
37
|
|
|
38
|
+
function sortChildrensByPriority(unsorted_array) {
|
|
39
|
+
unsorted_array.forEach(item => {
|
|
40
|
+
if(item[children]) {
|
|
41
|
+
item[children].sort((a, b) => a[priority] - b[priority]);
|
|
42
|
+
item[children].forEach(child => {
|
|
43
|
+
if(child[children]) {
|
|
44
|
+
sortChildrensByPriority(child[children]);
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if(priority) {
|
|
52
|
+
sortChildrensByPriority(array);
|
|
53
|
+
}
|
|
54
|
+
|
|
37
55
|
return array;
|
|
38
56
|
}
|
|
@@ -19,6 +19,11 @@ describe("NESTED LIST", function () {
|
|
|
19
19
|
nestedList[0].custom_children[0].should.have.property('custom_children');
|
|
20
20
|
})
|
|
21
21
|
|
|
22
|
+
it('Should sort nested list childrens by priority', function () {
|
|
23
|
+
let nestedList = gudhub.makeNestedList(complicatedInput, 'id', 'parent_id', 'custom_children_array_name', 'priority');
|
|
24
|
+
nestedList[0].custom_children_array_name[1].title.should.equal('Child 1');
|
|
25
|
+
})
|
|
26
|
+
|
|
22
27
|
});
|
|
23
28
|
|
|
24
29
|
let input = [
|
|
@@ -67,4 +72,77 @@ let input = [
|
|
|
67
72
|
id: 9,
|
|
68
73
|
parent_id: 8
|
|
69
74
|
},
|
|
70
|
-
];
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
let complicatedInput = [
|
|
78
|
+
{
|
|
79
|
+
id: "26553.2884361",
|
|
80
|
+
parent_id: "26553.2904452",
|
|
81
|
+
title: "Second parent",
|
|
82
|
+
priority: 3
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: "26553.2904452",
|
|
86
|
+
parent_id: "",
|
|
87
|
+
title: "Parent"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: "26553.2904533",
|
|
91
|
+
parent_id: "26553.2904452",
|
|
92
|
+
title: "Child 2",
|
|
93
|
+
priority: 5
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
id: "26553.2904534",
|
|
97
|
+
parent_id: "26553.2904452",
|
|
98
|
+
title: "Child 3",
|
|
99
|
+
priority: 4
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
id: "26553.2904535",
|
|
103
|
+
parent_id: "26553.2884361",
|
|
104
|
+
title: "Child of child 1"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id: "26553.2904536",
|
|
108
|
+
parent_id: "26553.2884361",
|
|
109
|
+
title: "Child of child 2"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
id: "26553.2904538",
|
|
113
|
+
parent_id: "26553.2884361",
|
|
114
|
+
title: "Third parent"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
id: "26553.2904539",
|
|
118
|
+
parent_id: "26553.2904538",
|
|
119
|
+
title: "Child of child of child"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
id: "26553.2904540",
|
|
123
|
+
parent_id: "",
|
|
124
|
+
title: "Another parent"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
id: "26553.2906081",
|
|
128
|
+
parent_id: "26553.2904452",
|
|
129
|
+
title: "Child 1",
|
|
130
|
+
priority: 2
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
id: "26553.2914316",
|
|
134
|
+
parent_id: "26553.2904540",
|
|
135
|
+
title: "Child of another parent"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
id: "26553.2914491",
|
|
139
|
+
parent_id: "26553.2904452",
|
|
140
|
+
title: "Child of first parent",
|
|
141
|
+
priority: 1
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
id: "26553.2914500",
|
|
145
|
+
parent_id: "26553.2884361",
|
|
146
|
+
title: "Child of second parent"
|
|
147
|
+
}
|
|
148
|
+
]
|
package/GUDHUB/gudhub.js
CHANGED
|
@@ -65,7 +65,7 @@ export class GudHub {
|
|
|
65
65
|
this.appProcessor,
|
|
66
66
|
this.itemProcessor
|
|
67
67
|
);
|
|
68
|
-
this.fileManager = new FileManager(this.storage, this.
|
|
68
|
+
this.fileManager = new FileManager(this.storage, this.pipeService, this.req, this.appProcessor);
|
|
69
69
|
this.documentManager = new DocumentManager(this.req);
|
|
70
70
|
|
|
71
71
|
if (options.initWebsocket) {
|
|
@@ -216,8 +216,8 @@ export class GudHub {
|
|
|
216
216
|
return this.util.mergeObjects(sourceObject, destinationObject);
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
makeNestedList(arr, id, parent_id, children_property) {
|
|
220
|
-
return this.util.makeNestedList(arr, id, parent_id, children_property);
|
|
219
|
+
makeNestedList(arr, id, parent_id, children_property, priority_property) {
|
|
220
|
+
return this.util.makeNestedList(arr, id, parent_id, children_property, priority_property);
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
jsonConstructor(scheme, items, variables){
|