@cocreate/api 1.2.26 → 1.2.27
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/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/client.js +1 -0
- package/src/server.js +55 -64
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.2.27](https://github.com/CoCreate-app/CoCreate-api/compare/v1.2.26...v1.2.27) (2022-02-11)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* define host will be used when creating socket ([e7c4a88](https://github.com/CoCreate-app/CoCreate-api/commit/e7c4a8846b1131c98150f923e76ab42ec8bfe821))
|
|
7
|
+
|
|
1
8
|
## [1.2.26](https://github.com/CoCreate-app/CoCreate-api/compare/v1.2.25...v1.2.26) (2022-02-10)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/api",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.27",
|
|
4
4
|
"description": "A simple api helper component in vanilla javascript used by JavaScript developers to create thirdparty api intergrations. CoCreate-api includes the client component and server side for api processing. Thirdparty apis can be accessible using HTML5 attributes and/or JavaScript API. ",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"thirdparty-api-intergration",
|
package/src/client.js
CHANGED
package/src/server.js
CHANGED
|
@@ -1,54 +1,49 @@
|
|
|
1
1
|
const crud = require('@cocreate/crud-client')
|
|
2
|
-
const
|
|
3
|
-
let socket = new
|
|
2
|
+
const socketClient = require('@cocreate/socket-client')
|
|
3
|
+
let socket = new socketClient("ws");
|
|
4
4
|
|
|
5
5
|
crud.setSocket(socket);
|
|
6
6
|
|
|
7
7
|
var api = ( ()=> {
|
|
8
8
|
return {
|
|
9
|
-
send_response
|
|
10
|
-
console.log("Response
|
|
9
|
+
send_response: (wsManager, socket, obj, send_response) => {
|
|
10
|
+
console.log(send_response, " Response Sent")
|
|
11
11
|
wsManager.send(socket, send_response, obj)
|
|
12
12
|
},
|
|
13
13
|
|
|
14
|
-
handleError
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
//send_response(wsManager, socket, { type, response }, module_id);
|
|
14
|
+
handleError: (wsManager,socket, type, error,module_id)=>{
|
|
15
|
+
const response = {
|
|
16
|
+
'object': 'error',
|
|
17
|
+
'data':error || error.response || error.response.data || error.response.body || error.message || error,
|
|
18
|
+
};
|
|
19
|
+
wsManager.send(socket, module_id, { type, response })
|
|
21
20
|
},
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
|
|
22
|
+
getOrg: async (config, module) =>{
|
|
24
23
|
|
|
25
24
|
socket.create({
|
|
26
25
|
namespace: config["organization_id"],
|
|
27
26
|
room: null,
|
|
28
|
-
host: "
|
|
27
|
+
host: config["host"]
|
|
29
28
|
})
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
console.log("Org_id => ",config["organization_id"])
|
|
34
|
-
|
|
35
|
-
let org_row = await crud.readDocument({
|
|
29
|
+
|
|
30
|
+
let org = await crud.readDocument({
|
|
36
31
|
collection: "organizations",
|
|
37
32
|
name:"name",
|
|
38
33
|
document_id: config["organization_id"],
|
|
39
|
-
event,
|
|
40
34
|
apiKey: config["apiKey"],
|
|
41
|
-
organization_id:
|
|
35
|
+
organization_id: config["organization_id"]
|
|
42
36
|
});
|
|
43
37
|
|
|
44
38
|
try{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
org = org["data"];
|
|
40
|
+
}catch(e){
|
|
41
|
+
console.log(module," Error GET ORG in : ",e);
|
|
48
42
|
return false;
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
}
|
|
44
|
+
return org;
|
|
51
45
|
},
|
|
46
|
+
|
|
52
47
|
getOrgInRoutesbyHostname : async (config, hostname) =>{
|
|
53
48
|
var socket_config = {
|
|
54
49
|
"config": {
|
|
@@ -59,29 +54,25 @@ var api = ( ()=> {
|
|
|
59
54
|
"host": "server.cocreate.app:8088"
|
|
60
55
|
};
|
|
61
56
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
57
|
+
socket.create({
|
|
58
|
+
namespace: socket_config.config.organization_Id,
|
|
59
|
+
room: null,
|
|
60
|
+
host: socket_config.host
|
|
61
|
+
})
|
|
67
62
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
is_collection: false,
|
|
82
|
-
apiKey: config["config"]["apiKey"],
|
|
83
|
-
organization_id: config["config"]["organization_id"]
|
|
84
|
-
});
|
|
63
|
+
let data2 = await crud.readDocumentList({
|
|
64
|
+
collection: "organizations",
|
|
65
|
+
operator: {
|
|
66
|
+
filters: [{
|
|
67
|
+
name: 'domains',
|
|
68
|
+
operator: "$in",
|
|
69
|
+
value: [hostname]
|
|
70
|
+
}],
|
|
71
|
+
},
|
|
72
|
+
is_collection: false,
|
|
73
|
+
apiKey: config["config"]["apiKey"],
|
|
74
|
+
organization_id: config["config"]["organization_id"]
|
|
75
|
+
});
|
|
85
76
|
|
|
86
77
|
//let data2 = await crud.listenAsync(eventGetOrg);
|
|
87
78
|
console.log("data2 ===",data2)
|
|
@@ -91,7 +82,6 @@ var api = ( ()=> {
|
|
|
91
82
|
var socket_config = {
|
|
92
83
|
"config": {
|
|
93
84
|
"apiKey": org["apiKey"],
|
|
94
|
-
// "securityKey": org["securityKey"],
|
|
95
85
|
"organization_Id": org["_id"].toString(),
|
|
96
86
|
},
|
|
97
87
|
"prefix": "ws",
|
|
@@ -99,23 +89,24 @@ var api = ( ()=> {
|
|
|
99
89
|
}
|
|
100
90
|
//other connection
|
|
101
91
|
socket.create({
|
|
102
|
-
|
|
92
|
+
namespace: socket_config.config.organization_Id,
|
|
103
93
|
room: null,
|
|
104
94
|
host: socket_config.host
|
|
105
95
|
})
|
|
96
|
+
|
|
106
97
|
// socket.setGlobalScope(socket_config.config.organization_id)
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
98
|
+
let myOrg = await crud.readDocumentList({
|
|
99
|
+
collection: "organizations",
|
|
100
|
+
operator: {
|
|
101
|
+
filters: [{
|
|
102
|
+
name: '_id',
|
|
103
|
+
operator: "$eq",
|
|
104
|
+
value: [org["_id"].toString()]
|
|
105
|
+
}],
|
|
106
|
+
orders: [],
|
|
107
|
+
startIndex: 0,
|
|
108
|
+
search: { type: 'or', value: []}
|
|
109
|
+
},
|
|
119
110
|
is_collection: false,
|
|
120
111
|
apiKey: org["apiKey"],
|
|
121
112
|
organization_id: org["_id"]
|
|
@@ -124,7 +115,7 @@ var api = ( ()=> {
|
|
|
124
115
|
return result;
|
|
125
116
|
}
|
|
126
117
|
|
|
127
|
-
}
|
|
118
|
+
}
|
|
128
119
|
})();
|
|
129
120
|
|
|
130
121
|
module.exports = api;
|