@gudhub/core 1.1.117 → 1.1.119
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 +14 -3
- package/GUDHUB/Utils/AppsTemplateService/AppsTemplateService.js +1 -1
- package/GUDHUB/Utils/sharing/GroupInventation.js +46 -0
- package/GUDHUB/config.js +1 -1
- package/GUDHUB/invitation.test.js +103 -0
- package/fake_server/fake_java_server.js +54 -0
- package/package.json +1 -1
- package/umd/library.min.js +30 -30
- package/umd/library.min.js.map +1 -1
package/GUDHUB/Auth/Auth.js
CHANGED
|
@@ -5,9 +5,15 @@ export class Auth {
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
async login({ username, password } = {}) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
try {
|
|
9
|
+
const user = await this.loginApi(username, password);
|
|
10
|
+
this.storage.updateUser(user);
|
|
11
|
+
return user;
|
|
12
|
+
} catch (error) {
|
|
13
|
+
return {
|
|
14
|
+
error: error.response?.data || error.message,
|
|
15
|
+
}
|
|
16
|
+
}
|
|
11
17
|
}
|
|
12
18
|
|
|
13
19
|
async loginWithToken(token) {
|
|
@@ -61,6 +67,11 @@ export class Auth {
|
|
|
61
67
|
return user;
|
|
62
68
|
} catch (error) {
|
|
63
69
|
console.log(error);
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
status: error.response?.status,
|
|
73
|
+
message: error.response?.data,
|
|
74
|
+
};
|
|
64
75
|
}
|
|
65
76
|
}
|
|
66
77
|
|
|
@@ -333,7 +333,7 @@ export default class AppsTemplateService {
|
|
|
333
333
|
progress.apps.push(source_app.icon);
|
|
334
334
|
|
|
335
335
|
let appTemplate = self.prepareAppTemplate(source_app);
|
|
336
|
-
appTemplate.app_name = appTemplate.app_name
|
|
336
|
+
appTemplate.app_name = appTemplate.app_name;
|
|
337
337
|
appTemplate.privacy = 1;
|
|
338
338
|
if(pack.data_to_change) {
|
|
339
339
|
if(pack.data_to_change.name) {
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
|
|
3
|
+
class GroupInvitation {
|
|
4
|
+
constructor(token, baseURL = "http://localhost") {
|
|
5
|
+
this.token = token;
|
|
6
|
+
|
|
7
|
+
this.api = axios.create({
|
|
8
|
+
baseURL
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
groupInvitationCreate(sharing_groups, actions) {
|
|
13
|
+
return this.api.post("invitation/create", {
|
|
14
|
+
sharing_groups,
|
|
15
|
+
actions,
|
|
16
|
+
token: this.token
|
|
17
|
+
})
|
|
18
|
+
.then(res => res.data)
|
|
19
|
+
.catch(error => {
|
|
20
|
+
throw error.response?.data || error;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
groupInvitationGet(invitation_id) {
|
|
25
|
+
return this.api.get("invitation/get", {
|
|
26
|
+
params: { invitation_id }
|
|
27
|
+
})
|
|
28
|
+
.then(res => res.data)
|
|
29
|
+
.catch(error => {
|
|
30
|
+
throw error.response?.data || error;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
groupInvitationAccept(invitation_id) {
|
|
35
|
+
return this.api.post("invitation/accept", {
|
|
36
|
+
invitation_id,
|
|
37
|
+
token: this.token
|
|
38
|
+
})
|
|
39
|
+
.then(res => res.data)
|
|
40
|
+
.catch(error => {
|
|
41
|
+
throw error.response?.data || error;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default GroupInvitation;
|
package/GUDHUB/config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const server_url = "https://app.gudhub.com/GudHub";
|
|
2
2
|
//export const server_url = "https://app.gudhub.com/GudHub_Temp";
|
|
3
3
|
//export const server_url = "https://integration.gudhub.com/GudHub";
|
|
4
|
-
//export const server_url = "http://localhost:9000";
|
|
4
|
+
// export const server_url = "http://localhost:9000";
|
|
5
5
|
export const wss_url = "wss://app.gudhub.com/GudHub/ws/app/";
|
|
6
6
|
export const node_server_url = "https://app.gudhub.com/api/services/prod"
|
|
7
7
|
export const async_modules_path = 'build/latest/async_modules_node/';
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import should from "should";
|
|
2
|
+
import sinon from "sinon";
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
import GroupInvitation from "../GUDHUB/Utils/sharing/GroupInventation.js";
|
|
5
|
+
|
|
6
|
+
describe("Invitation API", function () {
|
|
7
|
+
|
|
8
|
+
const token = "fgdr5rfd4e5hsjkdrkdemdxm6re5erl";
|
|
9
|
+
|
|
10
|
+
afterEach(() => {
|
|
11
|
+
sinon.restore();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("groupInvitationCreate should call correct endpoint and return data", async function () {
|
|
15
|
+
|
|
16
|
+
const api = new GroupInvitation(token);
|
|
17
|
+
|
|
18
|
+
const sharing_groups = [
|
|
19
|
+
{ group_id: 7853, permission: 1 },
|
|
20
|
+
{ group_id: 7862, permission: 1 }
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
const actions = [
|
|
24
|
+
{ app_id: 36354, field_id: 651748, item_id: 4555415 },
|
|
25
|
+
{ app_id: 54122, field_id: 748122, item_id: 5415122 }
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
const postStub = sinon.stub(api.api, "post").resolves({
|
|
29
|
+
data: {
|
|
30
|
+
invitation_id: "r5fh587guj7r",
|
|
31
|
+
invitation_status: 0
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const result = await api.groupInvitationCreate(sharing_groups, actions);
|
|
36
|
+
|
|
37
|
+
result.should.have.property("invitation_id", "r5fh587guj7r");
|
|
38
|
+
result.should.have.property("invitation_status", 0);
|
|
39
|
+
|
|
40
|
+
postStub.calledOnce.should.be.true();
|
|
41
|
+
postStub.firstCall.args[0].should.equal("invitation/create");
|
|
42
|
+
|
|
43
|
+
const body = postStub.firstCall.args[1];
|
|
44
|
+
body.token.should.equal(token);
|
|
45
|
+
body.sharing_groups.should.eql(sharing_groups);
|
|
46
|
+
body.actions.should.eql(actions);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
it("groupInvitationGet should return full invitation structure", async function () {
|
|
51
|
+
|
|
52
|
+
const api = new GroupInvitation(token);
|
|
53
|
+
const invitation_id = "lknvzl3266bkjbkb";
|
|
54
|
+
|
|
55
|
+
sinon.stub(api.api, "get").resolves({
|
|
56
|
+
data: {
|
|
57
|
+
invitation_id,
|
|
58
|
+
invitation_status: 0,
|
|
59
|
+
Inviter_user: {
|
|
60
|
+
fullname: "Andrii Atlas",
|
|
61
|
+
avatar_128: "url128",
|
|
62
|
+
avatar_512: "url512"
|
|
63
|
+
},
|
|
64
|
+
sharing_groups: [
|
|
65
|
+
{ group_name: "3D Rendering Team", group_permission: 1 }
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const result = await api.groupInvitationGet(invitation_id);
|
|
71
|
+
|
|
72
|
+
result.should.have.property("invitation_id", invitation_id);
|
|
73
|
+
result.should.have.property("invitation_status", 0);
|
|
74
|
+
result.should.have.property("Inviter_user");
|
|
75
|
+
result.should.have.property("sharing_groups");
|
|
76
|
+
|
|
77
|
+
result.Inviter_user.should.have.property("fullname");
|
|
78
|
+
result.sharing_groups.should.be.Array();
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
it("groupInvitationAccept should send token and return accepted status", async function () {
|
|
83
|
+
|
|
84
|
+
const api = new GroupInvitation(token);
|
|
85
|
+
const invitation_id = "lknvzl3266bkjbkb";
|
|
86
|
+
|
|
87
|
+
const postStub = sinon.stub(api.api, "post").resolves({
|
|
88
|
+
data: {
|
|
89
|
+
invitation_id,
|
|
90
|
+
invitation_status: 1
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const result = await api.groupInvitationAccept(invitation_id);
|
|
95
|
+
|
|
96
|
+
result.invitation_status.should.equal(1);
|
|
97
|
+
|
|
98
|
+
const body = postStub.firstCall.args[1];
|
|
99
|
+
body.invitation_id.should.equal(invitation_id);
|
|
100
|
+
body.token.should.equal(token);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
});
|
|
@@ -193,6 +193,60 @@ export default function (app) {
|
|
|
193
193
|
]);
|
|
194
194
|
})
|
|
195
195
|
|
|
196
|
+
app.post('/invitation/create', (req, res) => {
|
|
197
|
+
const { sharing_groups, actions, token } = req.body;
|
|
198
|
+
|
|
199
|
+
if (!sharing_groups || !actions || !token) {
|
|
200
|
+
return res.status(400).json({ error: "Missing required fields" });
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
res.status(200).json({
|
|
204
|
+
invitation_id: "r5fh587guj7r",
|
|
205
|
+
invitation_status: 0
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
app.get('/invitation/get', (req, res) => {
|
|
210
|
+
const { invitation_id } = req.query;
|
|
211
|
+
|
|
212
|
+
if (!invitation_id) {
|
|
213
|
+
return res.status(400).json({ error: "Missing invitation_id" });
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
res.status(200).json({
|
|
217
|
+
invitation_id,
|
|
218
|
+
invitation_status: 0,
|
|
219
|
+
Inviter_user: {
|
|
220
|
+
fullname: "Andrii Atlas",
|
|
221
|
+
avatar_128: "https://gudhub.com/avatars/22_2289_128.jpg",
|
|
222
|
+
avatar_512: "https://gudhub.com/avatars/22_2289_512.jpg"
|
|
223
|
+
},
|
|
224
|
+
sharing_groups: [
|
|
225
|
+
{
|
|
226
|
+
group_name: "3D Rendering Team",
|
|
227
|
+
group_permission: 1
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
group_name: "Design Team",
|
|
231
|
+
group_permission: 2
|
|
232
|
+
}
|
|
233
|
+
]
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
app.post('/invitation/accept', (req, res) => {
|
|
238
|
+
const { invitation_id, token } = req.body;
|
|
239
|
+
|
|
240
|
+
if (!invitation_id || !token) {
|
|
241
|
+
return res.status(400).json({ error: "Missing required fields" });
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
res.status(200).json({
|
|
245
|
+
invitation_id,
|
|
246
|
+
invitation_status: 1
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
|
|
196
250
|
app.post('/api/sharing-group/create-group', (req, res) => {
|
|
197
251
|
res.status(200).send({ group_id: 1, group_name: req.body.group_name });
|
|
198
252
|
})
|