@cocreate/api 1.17.0 → 1.18.1

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,22 @@
1
+ ## [1.18.1](https://github.com/CoCreate-app/CoCreate-api/compare/v1.18.0...v1.18.1) (2023-12-01)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * added constructor ([cfd4f49](https://github.com/CoCreate-app/CoCreate-api/commit/cfd4f4960b48f48a4ef3b4bc75272cb192800480))
7
+
8
+ # [1.18.0](https://github.com/CoCreate-app/CoCreate-api/compare/v1.17.0...v1.18.0) (2023-11-25)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * update licensing details ([7ba9214](https://github.com/CoCreate-app/CoCreate-api/commit/7ba9214f494a5ae71e056853edb6bb730e6d666d))
14
+
15
+
16
+ ### Features
17
+
18
+ * upgrade dependencies for latest features and fixes ([22a8e3a](https://github.com/CoCreate-app/CoCreate-api/commit/22a8e3ae85d8f73d203978ca9a3529e6d7babc94))
19
+
1
20
  # [1.17.0](https://github.com/CoCreate-app/CoCreate-api/compare/v1.16.0...v1.17.0) (2023-11-25)
2
21
 
3
22
 
package/README.md CHANGED
@@ -39,12 +39,12 @@ $ yarn install @cocreate/api
39
39
 
40
40
  # Table of Contents
41
41
 
42
- - [Table of Contents](#table-of-contents)
43
- - [Announcements](#announcements)
44
- - [Roadmap](#roadmap)
45
- - [How to Contribute](#how-to-contribute)
46
- - [About](#about)
47
- - [License](#license)
42
+ - [Table of Contents](#table-of-contents)
43
+ - [Announcements](#announcements)
44
+ - [Roadmap](#roadmap)
45
+ - [How to Contribute](#how-to-contribute)
46
+ - [About](#about)
47
+ - [License](#license)
48
48
 
49
49
  <a name="announcements"></a>
50
50
 
@@ -78,8 +78,14 @@ We want this library to be community-driven, and CoCreate led. We need your help
78
78
 
79
79
  We appreciate your continued support, thank you!
80
80
 
81
-
82
81
  <a name="license"></a>
82
+
83
83
  # License
84
84
 
85
- [The MIT License (MIT)](https://github.com/CoCreate-app/CoCreate-api/blob/master/LICENSE)
85
+ This software is dual-licensed under the GNU Affero General Public License version 3 (AGPLv3) and a commercial license.
86
+
87
+ - **Open Source Use**: For open-source projects and non-commercial use, this software is available under the AGPLv3. The AGPLv3 allows you to freely use, modify, and distribute this software, provided that all modifications and derivative works are also licensed under the AGPLv3. For the full license text, see the [LICENSE file](https://github.com/CoCreate-app/CoCreate-api/blob/master/LICENSE).
88
+
89
+ - **Commercial Use**: For-profit companies and individuals intending to use this software for commercial purposes must obtain a commercial license. The commercial license is available when you sign up for an API key on our [website](https://cocreate.app). This license permits proprietary use and modification of the software without the copyleft requirements of the AGPLv3. It is ideal for integrating this software into proprietary commercial products and applications.
90
+
91
+ If you have not purchased a commercial license and intend to use this software for commercial purposes, you are required to sign up for an API key on our website.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/api",
3
- "version": "1.17.0",
3
+ "version": "1.18.1",
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",
@@ -59,11 +59,11 @@
59
59
  "webpack-log": "^3.0.1"
60
60
  },
61
61
  "dependencies": {
62
- "@cocreate/actions": "^1.13.0",
63
- "@cocreate/crud-client": "^1.30.0",
64
- "@cocreate/element-prototype": "^1.14.1",
65
- "@cocreate/render": "^1.34.0",
66
- "@cocreate/socket-client": "^1.34.0",
67
- "@cocreate/utils": "^1.28.0"
62
+ "@cocreate/actions": "^1.14.0",
63
+ "@cocreate/crud-client": "^1.31.0",
64
+ "@cocreate/element-prototype": "^1.15.0",
65
+ "@cocreate/render": "^1.35.0",
66
+ "@cocreate/socket-client": "^1.35.0",
67
+ "@cocreate/utils": "^1.29.0"
68
68
  }
69
69
  }
package/src/server.js CHANGED
@@ -1,102 +1,60 @@
1
- const CRUD = require('@cocreate/crud-client')
2
- const socketClient = require('@cocreate/socket-client')
3
- let socket = new socketClient("ws");
4
-
5
- CRUD.setSocket(socket);
6
-
7
- var api = (() => {
8
- return {
9
- getOrg: async (config, component) => {
10
-
11
- socket.create({
12
- namespace: config["organization_id"],
13
- room: null,
14
- host: config["host"]
15
- })
16
-
17
- let org = await CRUD.send({
18
- method: 'object.read',
19
- array: "organizations",
20
- key: config["key"],
21
- organization_id: config["organization_id"],
22
- object: {
23
- _id: config["organization_id"]
24
- }
1
+ class CoCreateApi {
2
+ constructor(crud) {
3
+ this.wsManager = crud.wsManager
4
+ this.crud = crud
5
+ this.init()
6
+ }
25
7
 
26
- });
8
+ async getOrganization(config, component) {
27
9
 
28
- if (!org || !org.object && !org.object[0]) {
29
- console.log(component, " Error GET ORG in : ", e);
30
- return false;
10
+ let org = await CRUD.send({
11
+ method: 'object.read',
12
+ array: "organizations",
13
+ key: config["key"],
14
+ organization_id: config["organization_id"],
15
+ object: {
16
+ _id: config["organization_id"]
31
17
  }
32
18
 
33
- return org.object[0];
34
- },
35
-
36
- getOrgInRoutesbyHostname: async (config, hostname) => {
37
- var socket_config = {
38
- "config": {
39
- "key": config["config"]["key"],
40
- "organization_id": config["config"]["organization_id"],
41
- },
42
- "prefix": "ws",
43
- "host": "server.cocreate.app:8088"
44
- };
45
-
46
- socket.create({
47
- namespace: socket_config.config.organization_id,
48
- room: null,
49
- host: socket_config.host
50
- })
19
+ });
51
20
 
52
- let data2 = await CRUD.send({
53
- method: 'object.read',
54
- array: "organizations",
55
- object: {
56
- $filter: {
57
- query: [{
58
- key: 'host',
59
- operator: "$in",
60
- value: [hostname]
61
- }],
62
- },
63
- },
64
- key: config["config"]["key"],
65
- organization_id: config["config"]["organization_id"]
66
- });
67
-
68
- var org = data2.object[0]
21
+ if (!org || !org.object && !org.object[0]) {
22
+ console.log(component, " Error GET ORG in : ", e);
23
+ return false;
24
+ }
69
25
 
70
- var socket_config = {
71
- "config": {
72
- "key": org["key"],
73
- "organization_id": org["_id"].toString(),
74
- },
75
- "prefix": "ws",
76
- "host": "server.cocreate.app:8088"
77
- }
26
+ return org.object[0];
27
+ }
78
28
 
79
- //other connection
80
- socket.create({
81
- namespace: socket_config.config.organization_id,
82
- room: null,
83
- host: socket_config.host
84
- })
29
+ async getApiKey(organization_id, name) {
30
+ this.organizations[organization_id] = this.getOrganization(organization_id, name)
31
+ this.organizations[organization_id] = await this.organizations[organization_id]
32
+ return this.organizations[organization_id]
33
+ }
85
34
 
86
- let myOrg = await CRUD.send({
87
- method: 'object.read',
88
- array: "organizations",
89
- key: org["key"],
90
- organization_id: org["_id"],
91
- object: {
92
- _id: org["_id"]
93
- }
94
- });
95
- let result = { 'row': myOrg, 'socket_config': socket_config };
96
- return result;
35
+ async getOrganizationNew(organization_id, name) {
36
+ let organization = await this.crud.send({
37
+ method: 'object.read',
38
+ database: organization_id,
39
+ array: 'organizations',
40
+ object: [{ _id: organization_id }],
41
+ organization_id
42
+ })
43
+
44
+ if (organization
45
+ && organization.object
46
+ && organization.object[0]) {
47
+ if (organization.object[0].apis && organization.object[0].apis[name]) {
48
+ return organization.object[0].apis && organization.object[0].apis[name]
49
+ } else
50
+ return { [this.name]: false, error: 'An apikey could not be found' }
51
+ } else {
52
+ return { serverOrganization: false, error: 'An organization could not be found' }
97
53
  }
98
54
 
99
55
  }
100
- })();
101
56
 
102
- module.exports = api;
57
+ }
58
+
59
+
60
+ module.exports = CoCreateApi;