@gudhub/core 1.1.119 → 1.1.120
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/Storage/ModulesList.js +7 -0
- package/GUDHUB/Utils/sharing/GroupInvitation.js +64 -0
- package/GUDHUB/config.js +1 -1
- package/GUDHUB/gudhub.js +2 -0
- package/GUDHUB/invitation.test.js +69 -56
- package/fake_server/fake_java_server.js +7 -7
- package/package.json +1 -1
- package/umd/library.min.js +6 -4
- package/umd/library.min.js.map +1 -1
- package/GUDHUB/Utils/sharing/GroupInventation.js +0 -46
|
@@ -1203,6 +1203,13 @@ export default function generateModulesList(async_modules_path, file_server_url,
|
|
|
1203
1203
|
type: 'automation',
|
|
1204
1204
|
icon: 'automation_item_constructor'
|
|
1205
1205
|
},
|
|
1206
|
+
{
|
|
1207
|
+
data_type: 'InvitationsGenerator',
|
|
1208
|
+
name: 'Invitations Generator',
|
|
1209
|
+
url: file_server_url + '/' + automation_modules_path + 'invitations_generator_node.js',
|
|
1210
|
+
type: 'automation',
|
|
1211
|
+
icon: 'automation_api'
|
|
1212
|
+
},
|
|
1206
1213
|
{
|
|
1207
1214
|
data_type: 'ItemDestructor',
|
|
1208
1215
|
name: 'Item Destructor',
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export class GroupInvitation {
|
|
2
|
+
constructor(gudhub, req) {
|
|
3
|
+
this.req = req;
|
|
4
|
+
this.gudhub = gudhub;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
async groupInvitationCreate(sharingGroups, actions) {
|
|
8
|
+
try {
|
|
9
|
+
const form = {
|
|
10
|
+
sharing_groups: sharingGroups,
|
|
11
|
+
actions,
|
|
12
|
+
token: await this.gudhub.auth.getToken(),
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const groupInventation = await this.req.post({
|
|
16
|
+
url: "/api/invitation/create",
|
|
17
|
+
form,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
return groupInventation;
|
|
21
|
+
} catch (err) {
|
|
22
|
+
console.log(err);
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async groupInvitationGet(invitationId) {
|
|
28
|
+
try {
|
|
29
|
+
const form = {
|
|
30
|
+
invitation_id: invitationId
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const groupInventation = await this.req.post({
|
|
34
|
+
url: "/api/invitation/get",
|
|
35
|
+
form,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
return groupInventation;
|
|
39
|
+
} catch (err) {
|
|
40
|
+
console.log(err);
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async groupInvitationAccept(invitationId) {
|
|
46
|
+
try {
|
|
47
|
+
const form = {
|
|
48
|
+
invitation_id: invitationId
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const groupInventation = await this.req.post({
|
|
52
|
+
url: "/api/invitation/accept",
|
|
53
|
+
form,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return groupInventation;
|
|
57
|
+
} catch (err) {
|
|
58
|
+
console.log(err);
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
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
|
-
//
|
|
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/';
|
package/GUDHUB/gudhub.js
CHANGED
|
@@ -16,6 +16,7 @@ import { Interpritate } from './GHConstructor/interpritate.js'
|
|
|
16
16
|
import { IS_WEB } from "./consts.js";
|
|
17
17
|
import { WebsocketHandler } from './WebSocket/WebsocketHandler.js';
|
|
18
18
|
import { GroupSharing } from './Utils/sharing/GroupSharing.js';
|
|
19
|
+
import { GroupInvitation } from './Utils/sharing/GroupInvitation.js';
|
|
19
20
|
import { Sharing } from './Utils/sharing/Sharing.js';
|
|
20
21
|
import { WebSocketEmitter } from './WebSocket/WebSocketEmitter.js';
|
|
21
22
|
|
|
@@ -46,6 +47,7 @@ export class GudHub {
|
|
|
46
47
|
this.auth = new Auth(this.req, this.storage);
|
|
47
48
|
this.sharing = new Sharing(this, this.req);
|
|
48
49
|
this.groupSharing = new GroupSharing(this, this.req, this.pipeService);
|
|
50
|
+
this.groupInventation = new GroupInvitation(this, this.req);
|
|
49
51
|
|
|
50
52
|
// Login with access token - pass to setUser access token and after it user can make requests with access token
|
|
51
53
|
// This method created for optimize GudHub initialization without auth key
|
|
@@ -1,21 +1,34 @@
|
|
|
1
|
-
import should from "should";
|
|
1
|
+
// import should from "should";
|
|
2
2
|
import sinon from "sinon";
|
|
3
|
-
import
|
|
4
|
-
import GroupInvitation from "../GUDHUB/Utils/sharing/GroupInventation.js";
|
|
3
|
+
import { GroupInvitation } from "../GUDHUB/Utils/sharing/GroupInvitation.js";
|
|
5
4
|
|
|
6
5
|
describe("Invitation API", function () {
|
|
7
|
-
|
|
8
6
|
const token = "fgdr5rfd4e5hsjkdrkdemdxm6re5erl";
|
|
9
7
|
|
|
8
|
+
let gudhub;
|
|
9
|
+
let req;
|
|
10
|
+
let api;
|
|
11
|
+
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
gudhub = {
|
|
14
|
+
auth: {
|
|
15
|
+
getToken: sinon.stub().resolves(token)
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
req = {
|
|
20
|
+
post: sinon.stub()
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
api = new GroupInvitation(gudhub, req);
|
|
24
|
+
});
|
|
25
|
+
|
|
10
26
|
afterEach(() => {
|
|
11
27
|
sinon.restore();
|
|
12
28
|
});
|
|
13
29
|
|
|
14
30
|
it("groupInvitationCreate should call correct endpoint and return data", async function () {
|
|
15
|
-
|
|
16
|
-
const api = new GroupInvitation(token);
|
|
17
|
-
|
|
18
|
-
const sharing_groups = [
|
|
31
|
+
const sharingGroups = [
|
|
19
32
|
{ group_id: 7853, permission: 1 },
|
|
20
33
|
{ group_id: 7862, permission: 1 }
|
|
21
34
|
];
|
|
@@ -25,79 +38,79 @@ describe("Invitation API", function () {
|
|
|
25
38
|
{ app_id: 54122, field_id: 748122, item_id: 5415122 }
|
|
26
39
|
];
|
|
27
40
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
invitation_status: 0
|
|
32
|
-
}
|
|
41
|
+
req.post.resolves({
|
|
42
|
+
invitation_id: "r5fh587guj7r",
|
|
43
|
+
invitation_status: 0
|
|
33
44
|
});
|
|
34
45
|
|
|
35
|
-
const result = await api.groupInvitationCreate(
|
|
46
|
+
const result = await api.groupInvitationCreate(sharingGroups, actions);
|
|
36
47
|
|
|
37
48
|
result.should.have.property("invitation_id", "r5fh587guj7r");
|
|
38
49
|
result.should.have.property("invitation_status", 0);
|
|
39
50
|
|
|
40
|
-
|
|
41
|
-
|
|
51
|
+
gudhub.auth.getToken.calledOnce.should.be.true();
|
|
52
|
+
req.post.calledOnce.should.be.true();
|
|
42
53
|
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
54
|
+
const arg = req.post.firstCall.args[0];
|
|
55
|
+
arg.should.have.property("url", "/api/invitation/create");
|
|
56
|
+
arg.should.have.property("form");
|
|
57
|
+
arg.form.token.should.equal(token);
|
|
58
|
+
arg.form.sharing_groups.should.eql(sharingGroups);
|
|
59
|
+
arg.form.actions.should.eql(actions);
|
|
47
60
|
});
|
|
48
61
|
|
|
49
|
-
|
|
50
62
|
it("groupInvitationGet should return full invitation structure", async function () {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
sharing_groups: [
|
|
65
|
-
{ group_name: "3D Rendering Team", group_permission: 1 }
|
|
66
|
-
]
|
|
67
|
-
}
|
|
63
|
+
const invitationId = "lknvzl3266bkjbkb";
|
|
64
|
+
|
|
65
|
+
req.post.resolves({
|
|
66
|
+
invitation_id: invitationId,
|
|
67
|
+
invitation_status: 0,
|
|
68
|
+
Inviter_user: {
|
|
69
|
+
fullname: "Andrii Atlas",
|
|
70
|
+
avatar_128: "url128",
|
|
71
|
+
avatar_512: "url512"
|
|
72
|
+
},
|
|
73
|
+
sharing_groups: [
|
|
74
|
+
{ group_name: "3D Rendering Team", group_permission: 1 }
|
|
75
|
+
]
|
|
68
76
|
});
|
|
69
77
|
|
|
70
|
-
const result = await api.groupInvitationGet(
|
|
78
|
+
const result = await api.groupInvitationGet(invitationId);
|
|
71
79
|
|
|
72
|
-
result.should.have.property("invitation_id",
|
|
80
|
+
result.should.have.property("invitation_id", invitationId);
|
|
73
81
|
result.should.have.property("invitation_status", 0);
|
|
74
82
|
result.should.have.property("Inviter_user");
|
|
75
83
|
result.should.have.property("sharing_groups");
|
|
76
84
|
|
|
77
|
-
result.Inviter_user.should.have.property("fullname");
|
|
85
|
+
result.Inviter_user.should.have.property("fullname", "Andrii Atlas");
|
|
78
86
|
result.sharing_groups.should.be.Array();
|
|
79
|
-
});
|
|
80
87
|
|
|
88
|
+
req.post.calledOnce.should.be.true();
|
|
81
89
|
|
|
82
|
-
|
|
90
|
+
const arg = req.post.firstCall.args[0];
|
|
91
|
+
arg.should.have.property("url", "/api/invitation/get");
|
|
92
|
+
arg.should.have.property("form");
|
|
93
|
+
arg.form.invitation_id.should.equal(invitationId);
|
|
94
|
+
});
|
|
83
95
|
|
|
84
|
-
|
|
85
|
-
const
|
|
96
|
+
it("groupInvitationAccept should send invitation id and return accepted status", async function () {
|
|
97
|
+
const invitationId = "lknvzl3266bkjbkb";
|
|
86
98
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
invitation_status: 1
|
|
91
|
-
}
|
|
99
|
+
req.post.resolves({
|
|
100
|
+
invitation_id: invitationId,
|
|
101
|
+
invitation_status: 1
|
|
92
102
|
});
|
|
93
103
|
|
|
94
|
-
const result = await api.groupInvitationAccept(
|
|
104
|
+
const result = await api.groupInvitationAccept(invitationId);
|
|
95
105
|
|
|
96
|
-
result.
|
|
106
|
+
result.should.have.property("invitation_id", invitationId);
|
|
107
|
+
result.should.have.property("invitation_status", 1);
|
|
97
108
|
|
|
98
|
-
|
|
99
|
-
body.invitation_id.should.equal(invitation_id);
|
|
100
|
-
body.token.should.equal(token);
|
|
101
|
-
});
|
|
109
|
+
req.post.calledOnce.should.be.true();
|
|
102
110
|
|
|
111
|
+
const arg = req.post.firstCall.args[0];
|
|
112
|
+
arg.should.have.property("url", "/api/invitation/accept");
|
|
113
|
+
arg.should.have.property("form");
|
|
114
|
+
arg.form.invitation_id.should.equal(invitationId);
|
|
115
|
+
});
|
|
103
116
|
});
|
|
@@ -193,7 +193,7 @@ export default function (app) {
|
|
|
193
193
|
]);
|
|
194
194
|
})
|
|
195
195
|
|
|
196
|
-
app.post('/invitation/create', (req, res) => {
|
|
196
|
+
app.post('/api/invitation/create', (req, res) => {
|
|
197
197
|
const { sharing_groups, actions, token } = req.body;
|
|
198
198
|
|
|
199
199
|
if (!sharing_groups || !actions || !token) {
|
|
@@ -206,8 +206,8 @@ export default function (app) {
|
|
|
206
206
|
});
|
|
207
207
|
});
|
|
208
208
|
|
|
209
|
-
app.
|
|
210
|
-
const { invitation_id } = req.
|
|
209
|
+
app.post('/api/invitation/get', (req, res) => {
|
|
210
|
+
const { invitation_id } = req.body;
|
|
211
211
|
|
|
212
212
|
if (!invitation_id) {
|
|
213
213
|
return res.status(400).json({ error: "Missing invitation_id" });
|
|
@@ -234,11 +234,11 @@ export default function (app) {
|
|
|
234
234
|
});
|
|
235
235
|
});
|
|
236
236
|
|
|
237
|
-
app.post('/invitation/accept', (req, res) => {
|
|
238
|
-
const { invitation_id
|
|
237
|
+
app.post('/api/invitation/accept', (req, res) => {
|
|
238
|
+
const { invitation_id } = req.body;
|
|
239
239
|
|
|
240
|
-
if (!invitation_id
|
|
241
|
-
return res.status(400).json({ error: "Missing
|
|
240
|
+
if (!invitation_id) {
|
|
241
|
+
return res.status(400).json({ error: "Missing invitation_id" });
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
res.status(200).json({
|