@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 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.26",
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
@@ -165,6 +165,7 @@ const CoCreateApi = {
165
165
  return {
166
166
  "apiKey": info.apiKey || config.apiKey,
167
167
  "organization_id": info.organization_id || config.organization_Id,
168
+ "host": info.host || config.host
168
169
  };
169
170
  }
170
171
  };
package/src/server.js CHANGED
@@ -1,54 +1,49 @@
1
1
  const crud = require('@cocreate/crud-client')
2
- const CoCreateSocketClient = require('@cocreate/socket-client')
3
- let socket = new CoCreateSocketClient("ws");
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 : (wsManager,socket,obj,send_response) => {
10
- console.log("Response TO-> "+send_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 : (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 })
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
- getOrg : async (config, module) =>{
23
- console.log("config WS utils==== ",config)
21
+
22
+ getOrg: async (config, module) =>{
24
23
 
25
24
  socket.create({
26
25
  namespace: config["organization_id"],
27
26
  room: null,
28
- host: "server.cocreate.app:8088"
27
+ host: config["host"]
29
28
  })
30
- const event = "getOrg";
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: '5de0387b12e200ea63204d6c'
35
+ organization_id: config["organization_id"]
42
36
  });
43
37
 
44
38
  try{
45
- org_row = org_row["data"];
46
- }catch(e){
47
- console.log(module," Error GET ORG in : ",e);
39
+ org = org["data"];
40
+ }catch(e){
41
+ console.log(module," Error GET ORG in : ",e);
48
42
  return false;
49
- }
50
- return org_row;
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
- socket.create({
63
- namespace: socket_config.config.organization_Id,
64
- room: null,
65
- host: socket_config.host
66
- })
57
+ socket.create({
58
+ namespace: socket_config.config.organization_Id,
59
+ room: null,
60
+ host: socket_config.host
61
+ })
67
62
 
68
-
69
- let data2 = await crud.readDocumentList({
70
- collection: "organizations",
71
- operator: {
72
- filters: [{
73
- name: 'domains',
74
- operator: "$in",
75
- value: [hostname]
76
- }],
77
- // orders: [],
78
- // startIndex: 0,
79
- // search: { type: 'or', value: []}
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
- namespace: socket_config.config.organization_Id,
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
- let myOrg = await crud.readDocumentList({
108
- collection: "organizations",
109
- operator: {
110
- filters: [{
111
- name: '_id',
112
- operator: "$eq",
113
- value: [org["_id"].toString()]
114
- }],
115
- orders: [],
116
- startIndex: 0,
117
- search: { type: 'or', value: []}
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;