@cocreate/api 1.4.13 → 1.5.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 +13 -0
- package/demo/index.html +3 -10
- package/package.json +2 -2
- package/src/client.js +1 -1
- package/src/server.js +21 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
# [1.5.0](https://github.com/CoCreate-app/CoCreate-api/compare/v1.4.13...v1.5.0) (2022-11-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* renamed data.data to data.document ([ba27705](https://github.com/CoCreate-app/CoCreate-api/commit/ba27705c60773631448b04b61adbad2bea0eaa0f))
|
|
7
|
+
* update crud functions to receive an array of objects as the response ([4e2b817](https://github.com/CoCreate-app/CoCreate-api/commit/4e2b817c05a0843208b6e57adf055fd37926d875))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* Add @cocreate/element-prototype ([ca92d48](https://github.com/CoCreate-app/CoCreate-api/commit/ca92d48985897b6eecdac6ef60c4e74462d5fe19))
|
|
13
|
+
|
|
1
14
|
## [1.4.13](https://github.com/CoCreate-app/CoCreate-api/compare/v1.4.12...v1.4.13) (2022-10-02)
|
|
2
15
|
|
|
3
16
|
|
package/demo/index.html
CHANGED
|
@@ -42,17 +42,10 @@
|
|
|
42
42
|
</form>
|
|
43
43
|
|
|
44
44
|
<h1>Result</h1>
|
|
45
|
-
|
|
46
|
-
<script>
|
|
47
|
-
var CoCreateConfig = {
|
|
48
|
-
apiKey: 'c2b08663-06e3-440c-ef6f-13978b42883a',
|
|
49
|
-
organization_id: '5de0387b12e200ea63204d6c'
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
</script>
|
|
53
|
-
|
|
45
|
+
|
|
54
46
|
<!--CoCreateJS CDN-->
|
|
55
|
-
<script src="https://cdn.cocreate.app/api/latest/CoCreate-api.min.js"></script>
|
|
47
|
+
<!-- <script src="https://cdn.cocreate.app/api/latest/CoCreate-api.min.js"></script> -->
|
|
48
|
+
<script src="../dist/CoCreate-api.js"></script>
|
|
56
49
|
|
|
57
50
|
</body>
|
|
58
51
|
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.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",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@cocreate/actions": "^1.5.12",
|
|
66
66
|
"@cocreate/crud-client": "^1.12.12",
|
|
67
67
|
"@cocreate/docs": "^1.3.18",
|
|
68
|
-
"@cocreate/
|
|
68
|
+
"@cocreate/element-prototype": "^1.0.0",
|
|
69
69
|
"@cocreate/hosting": "^1.4.1",
|
|
70
70
|
"@cocreate/render": "^1.15.10",
|
|
71
71
|
"@cocreate/socket-client": "^1.9.12"
|
package/src/client.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import socket from "@cocreate/socket-client";
|
|
3
3
|
import CoCreateAction from '@cocreate/actions';
|
|
4
4
|
import CoCreateRender from '@cocreate/render';
|
|
5
|
-
import
|
|
5
|
+
import '@cocreate/element-prototype';
|
|
6
6
|
|
|
7
7
|
const CoCreateApi = {
|
|
8
8
|
components: { },
|
package/src/server.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
const
|
|
1
|
+
const CRUD = require('@cocreate/crud-client')
|
|
2
2
|
const socketClient = require('@cocreate/socket-client')
|
|
3
3
|
let socket = new socketClient("ws");
|
|
4
4
|
|
|
5
|
+
let crud
|
|
6
|
+
if(CRUD && CRUD.default)
|
|
7
|
+
crud = CRUD.default
|
|
8
|
+
else
|
|
9
|
+
crud = CRUD
|
|
10
|
+
|
|
5
11
|
crud.setSocket(socket);
|
|
6
12
|
|
|
7
13
|
var api = ( ()=> {
|
|
@@ -28,18 +34,20 @@ var api = ( ()=> {
|
|
|
28
34
|
|
|
29
35
|
let org = await crud.readDocument({
|
|
30
36
|
collection: "organizations",
|
|
31
|
-
document_id: config["organization_id"],
|
|
32
37
|
apiKey: config["apiKey"],
|
|
33
|
-
organization_id: config["organization_id"]
|
|
38
|
+
organization_id: config["organization_id"],
|
|
39
|
+
document: {
|
|
40
|
+
_id: config["organization_id"]
|
|
41
|
+
}
|
|
42
|
+
|
|
34
43
|
});
|
|
35
44
|
|
|
36
|
-
|
|
37
|
-
org = org["data"];
|
|
38
|
-
}catch(e){
|
|
45
|
+
if (!org || !org.document && !org.document[0]) {
|
|
39
46
|
console.log(component," Error GET ORG in : ",e);
|
|
40
47
|
return false;
|
|
41
48
|
}
|
|
42
|
-
|
|
49
|
+
|
|
50
|
+
return org.document[0];
|
|
43
51
|
},
|
|
44
52
|
|
|
45
53
|
getOrgInRoutesbyHostname : async (config, hostname) => {
|
|
@@ -58,7 +66,7 @@ var api = ( ()=> {
|
|
|
58
66
|
host: socket_config.host
|
|
59
67
|
})
|
|
60
68
|
|
|
61
|
-
let data2 = await crud.
|
|
69
|
+
let data2 = await crud.readDocument({
|
|
62
70
|
collection: "organizations",
|
|
63
71
|
filter: {
|
|
64
72
|
query: [{
|
|
@@ -67,15 +75,11 @@ var api = ( ()=> {
|
|
|
67
75
|
value: [hostname]
|
|
68
76
|
}],
|
|
69
77
|
},
|
|
70
|
-
is_collection: false,
|
|
71
78
|
apiKey: config["config"]["apiKey"],
|
|
72
79
|
organization_id: config["config"]["organization_id"]
|
|
73
80
|
});
|
|
74
|
-
|
|
75
|
-
//let data2 = await crud.listenAsync(eventGetOrg);
|
|
76
|
-
// console.log("data2 ===", data2)
|
|
77
81
|
|
|
78
|
-
var org = data2[
|
|
82
|
+
var org = data2.document[0]
|
|
79
83
|
|
|
80
84
|
var socket_config = {
|
|
81
85
|
"config": {
|
|
@@ -95,9 +99,11 @@ var api = ( ()=> {
|
|
|
95
99
|
|
|
96
100
|
let myOrg = await crud.readDocument({
|
|
97
101
|
collection: "organizations",
|
|
98
|
-
document_id: org["_id"],
|
|
99
102
|
apiKey: org["apiKey"],
|
|
100
|
-
organization_id: org["_id"]
|
|
103
|
+
organization_id: org["_id"],
|
|
104
|
+
document: {
|
|
105
|
+
_id: org["_id"]
|
|
106
|
+
}
|
|
101
107
|
});
|
|
102
108
|
let result = {'row':myOrg,'socket_config':socket_config};
|
|
103
109
|
return result;
|