@cocreate/api 1.2.30 → 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,10 @@
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
+
1
8
  ## [1.2.30](https://github.com/CoCreate-app/CoCreate-api/compare/v1.2.29...v1.2.30) (2022-02-24)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/api",
3
- "version": "1.2.30",
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",
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
  }
@@ -47,8 +47,8 @@ const CoCreateApi = {
47
47
 
48
48
  __response: function(id, data) {
49
49
  const {action, response} = data;
50
- const m_instance = this.modules[id];
51
- const functions = m_instance.actions[action]
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
  }
@@ -138,10 +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
143
  data = {...request_data, action, data};
144
- socketApi.send(module, data);
144
+ socketApi.send(component, data);
145
145
  },
146
146
 
147
147
  render: function(action, data) {
package/src/server.js CHANGED
@@ -10,15 +10,15 @@ var api = ( ()=> {
10
10
  wsManager.send(socket, send_response, obj)
11
11
  },
12
12
 
13
- handleError: (wsManager, socket, action, error, module_id) => {
13
+ handleError: (wsManager, socket, action, error, component) => {
14
14
  const response = {
15
15
  'object': 'error',
16
16
  'data':error || error.response || error.response.data || error.response.body || error.message || error,
17
17
  };
18
- wsManager.send(socket, module_id, { action, response })
18
+ wsManager.send(socket, component, { action, response })
19
19
  },
20
20
 
21
- getOrg: async (config, module) => {
21
+ getOrg: async (config, component) => {
22
22
 
23
23
  socket.create({
24
24
  namespace: config["organization_id"],
@@ -36,7 +36,7 @@ var api = ( ()=> {
36
36
  try{
37
37
  org = org["data"];
38
38
  }catch(e){
39
- console.log(module," Error GET ORG in : ",e);
39
+ console.log(component," Error GET ORG in : ",e);
40
40
  return false;
41
41
  }
42
42
  return org;