@cocreate/api 1.2.28 → 1.2.31

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,26 @@
1
+ ## [1.2.31](https://github.com/CoCreate-app/CoCreate-api/compare/v1.2.30...v1.2.31) (2022-02-27)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * update param module to component ([45edeb7](https://github.com/CoCreate-app/CoCreate-api/commit/45edeb7e4701d0510b1875f8a63dd7156338618c))
7
+
8
+ ## [1.2.30](https://github.com/CoCreate-app/CoCreate-api/compare/v1.2.29...v1.2.30) (2022-02-24)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * CoCreate.config replace CoCreate.app with * ([62ecf98](https://github.com/CoCreate-app/CoCreate-api/commit/62ecf980e1e0efdc237d0015fd041ebaceb954eb))
14
+ * removed name param from getOrg crud function ([4d868b5](https://github.com/CoCreate-app/CoCreate-api/commit/4d868b58982d4fb635f6d040073fad23dc225533))
15
+ * update param type to action ([3ee6cd7](https://github.com/CoCreate-app/CoCreate-api/commit/3ee6cd7c6f2f67b0d26c49c0b202554e828633b4))
16
+
17
+ ## [1.2.29](https://github.com/CoCreate-app/CoCreate-api/compare/v1.2.28...v1.2.29) (2022-02-16)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * update dependencies ([aea132d](https://github.com/CoCreate-app/CoCreate-api/commit/aea132d9e4102ee866f951de88a63c4d3e6cce14))
23
+
1
24
  ## [1.2.28](https://github.com/CoCreate-app/CoCreate-api/compare/v1.2.27...v1.2.28) (2022-02-16)
2
25
 
3
26
 
@@ -14,7 +14,7 @@ module.exports = {
14
14
  "name": "index.html",
15
15
  "path": "/docs/api/index.html",
16
16
  "domains": [
17
- "cocreate.app",
17
+ "*",
18
18
  "general.cocreate.app"
19
19
  ],
20
20
  "directory": "/docs/api",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/api",
3
- "version": "1.2.28",
3
+ "version": "1.2.31",
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",
@@ -62,12 +62,12 @@
62
62
  "webpack-log": "^3.0.1"
63
63
  },
64
64
  "dependencies": {
65
- "@cocreate/actions": "^1.3.31",
66
- "@cocreate/crud-client": "^1.4.46",
67
- "@cocreate/docs": "^1.2.68",
68
- "@cocreate/elements": "^1.6.9",
69
- "@cocreate/hosting": "^1.2.63",
70
- "@cocreate/render": "^1.5.5",
71
- "@cocreate/socket-client": "^1.4.21"
65
+ "@cocreate/actions": "^1.3.33",
66
+ "@cocreate/crud-client": "^1.4.47",
67
+ "@cocreate/docs": "^1.2.69",
68
+ "@cocreate/elements": "^1.6.11",
69
+ "@cocreate/hosting": "^1.2.64",
70
+ "@cocreate/render": "^1.5.7",
71
+ "@cocreate/socket-client": "^1.4.22"
72
72
  }
73
73
  }
package/src/client.js CHANGED
@@ -7,24 +7,24 @@ import CoCreateElements from '@cocreate/elements';
7
7
  let socketApi = new CoCreateSocket('api');
8
8
 
9
9
  const CoCreateApi = {
10
- modules: { },
10
+ components: { },
11
11
 
12
- init: function({name, module}) {
13
- this.register(name, module);
12
+ init: function({name, component}) {
13
+ this.register(name || component.name, component);
14
14
  if (!socketApi.sockets.size)
15
15
  socketApi.create(window.config);
16
16
  },
17
17
 
18
- register: function(name, m_instance) {
18
+ register: function(name, component) {
19
19
  const self = this;
20
- if (typeof this.modules[name] === 'undefined') {
21
- this.modules[name] = m_instance;
22
-
20
+ if (typeof this.components[name] === 'undefined') {
21
+ this.components[name] = component;
22
+
23
23
  socketApi.listen(name, (data) => {
24
24
  self.__response(name, data);
25
25
  });
26
26
 
27
- for (const [action, functions] of Object.entries(m_instance['actions'])){
27
+ for (const [action, functions] of Object.entries(component['actions'])){
28
28
  if (typeof functions.request !== 'function') {
29
29
  functions.request = self.__request;
30
30
  }
@@ -32,7 +32,7 @@ const CoCreateApi = {
32
32
  name: action,
33
33
  endEvent: action,
34
34
  callback: (element) => {
35
- functions.request(m_instance.name, action, element);
35
+ functions.request(component.name, action, element);
36
36
  },
37
37
  });
38
38
  }
@@ -46,16 +46,16 @@ const CoCreateApi = {
46
46
  },
47
47
 
48
48
  __response: function(id, data) {
49
- const {type, response} = data;
50
- const m_instance = this.modules[id];
51
- const functions = m_instance.actions[type]
49
+ const {action, response} = data;
50
+ const component = this.components[id];
51
+ const functions = component.actions[action]
52
52
  if (typeof functions.response === 'function') {
53
53
  functions.response(response);
54
54
  }
55
55
  else
56
- this.render(type, response);
56
+ this.render(action, response);
57
57
 
58
- document.dispatchEvent(new CustomEvent(type, {
58
+ document.dispatchEvent(new CustomEvent(action, {
59
59
  detail: {
60
60
  data: response
61
61
  }
@@ -138,11 +138,10 @@ const CoCreateApi = {
138
138
  return newObject;
139
139
  },
140
140
 
141
- send : function(module, action, data){
141
+ send : function(component, action, data){
142
142
  let request_data = this.getCommonParams(data || {});
143
- data = {...request_data, type: action, data};
144
- socketApi.send(module, data);
145
- console.log('data', data)
143
+ data = {...request_data, action, data};
144
+ socketApi.send(component, data);
146
145
  },
147
146
 
148
147
  render: function(action, data) {
package/src/server.js CHANGED
@@ -7,19 +7,18 @@ crud.setSocket(socket);
7
7
  var api = ( ()=> {
8
8
  return {
9
9
  send_response: (wsManager, socket, obj, send_response) => {
10
- console.log(send_response, " Response Sent")
11
10
  wsManager.send(socket, send_response, obj)
12
11
  },
13
12
 
14
- handleError: (wsManager, socket, type, error, module_id)=>{
13
+ handleError: (wsManager, socket, action, error, component) => {
15
14
  const response = {
16
15
  'object': 'error',
17
16
  'data':error || error.response || error.response.data || error.response.body || error.message || error,
18
17
  };
19
- wsManager.send(socket, module_id, { type, response })
18
+ wsManager.send(socket, component, { action, response })
20
19
  },
21
20
 
22
- getOrg: async (config, module) =>{
21
+ getOrg: async (config, component) => {
23
22
 
24
23
  socket.create({
25
24
  namespace: config["organization_id"],
@@ -29,7 +28,6 @@ var api = ( ()=> {
29
28
 
30
29
  let org = await crud.readDocument({
31
30
  collection: "organizations",
32
- name:"name",
33
31
  document_id: config["organization_id"],
34
32
  apiKey: config["apiKey"],
35
33
  organization_id: config["organization_id"]
@@ -38,13 +36,13 @@ var api = ( ()=> {
38
36
  try{
39
37
  org = org["data"];
40
38
  }catch(e){
41
- console.log(module," Error GET ORG in : ",e);
39
+ console.log(component," Error GET ORG in : ",e);
42
40
  return false;
43
41
  }
44
42
  return org;
45
43
  },
46
44
 
47
- getOrgInRoutesbyHostname : async (config, hostname) =>{
45
+ getOrgInRoutesbyHostname : async (config, hostname) => {
48
46
  var socket_config = {
49
47
  "config": {
50
48
  "apiKey": config["config"]["apiKey"],
@@ -75,7 +73,7 @@ var api = ( ()=> {
75
73
  });
76
74
 
77
75
  //let data2 = await crud.listenAsync(eventGetOrg);
78
- console.log("data2 ===",data2)
76
+ // console.log("data2 ===", data2)
79
77
 
80
78
  var org = data2["data"][0]
81
79