@cocreate/api 1.3.7 → 1.4.0

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,16 @@
1
+ # [1.4.0](https://github.com/CoCreate-app/CoCreate-api/compare/v1.3.7...v1.4.0) (2022-09-28)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * removed getCommonParams as socket applies defaults ([17f0a5d](https://github.com/CoCreate-app/CoCreate-api/commit/17f0a5daaad506ebe00200e31cea22aa9b0c1ae0))
7
+ * socket connection refactor ([3fa9e60](https://github.com/CoCreate-app/CoCreate-api/commit/3fa9e60c6843d0bb0a2b52ee52b38aa0f49150d8))
8
+
9
+
10
+ ### Features
11
+
12
+ * config is accessible from socket.config ([803a08a](https://github.com/CoCreate-app/CoCreate-api/commit/803a08a5e865f3e62ef79b1702391e4bb044be7c))
13
+
1
14
  ## [1.3.7](https://github.com/CoCreate-app/CoCreate-api/compare/v1.3.6...v1.3.7) (2022-09-22)
2
15
 
3
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/api",
3
- "version": "1.3.7",
3
+ "version": "1.4.0",
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
@@ -1,18 +1,16 @@
1
1
  /*globals CustomEvent, config*/
2
- import CoCreateSocket from "@cocreate/socket-client";
2
+ import socket from "@cocreate/socket-client";
3
3
  import CoCreateAction from '@cocreate/actions';
4
4
  import CoCreateRender from '@cocreate/render';
5
5
  import CoCreateElements from '@cocreate/elements';
6
6
 
7
- let socketApi = new CoCreateSocket('api');
8
-
9
7
  const CoCreateApi = {
10
8
  components: { },
11
-
9
+
12
10
  init: function({name, component}) {
13
11
  this.register(name || component.name, component);
14
- if (!socketApi.sockets.size)
15
- socketApi.create(window.config);
12
+ if (!socket.sockets.size)
13
+ socket.create({prefix: 'api'});
16
14
  },
17
15
 
18
16
  register: function(name, component) {
@@ -20,7 +18,7 @@ const CoCreateApi = {
20
18
  if (typeof this.components[name] === 'undefined') {
21
19
  this.components[name] = component;
22
20
 
23
- socketApi.listen(name, (data) => {
21
+ socket.listen(name, (data) => {
24
22
  self.__response(name, data);
25
23
  });
26
24
 
@@ -136,10 +134,8 @@ const CoCreateApi = {
136
134
  return newObject;
137
135
  },
138
136
 
139
- send : function(component, action, data){
140
- let request_data = this.getCommonParams(data || {});
141
- data = {...request_data, action, data};
142
- socketApi.send(component, data);
137
+ send: function(component, action, data) {
138
+ socket.send(component, {action, data});
143
139
  },
144
140
 
145
141
  render: function(action, data) {
@@ -149,13 +145,6 @@ const CoCreateApi = {
149
145
  });
150
146
  },
151
147
 
152
- getCommonParams: function(info) {
153
- return {
154
- "apiKey": info.apiKey || config.apiKey,
155
- "organization_id": info.organization_id || config.organization_id,
156
- "host": info.host || config.host
157
- };
158
- }
159
148
  };
160
149
 
161
150
  export default CoCreateApi;