@cocreate/api 1.21.2 → 1.21.3
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 +9 -0
- package/docs/index.html +13 -6
- package/package.json +1 -1
- package/src/index.js +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## [1.21.3](https://github.com/CoCreate-app/CoCreate-api/compare/v1.21.2...v1.21.3) (2024-08-24)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* dynaically fire endEvent provided by action ([ad8084e](https://github.com/CoCreate-app/CoCreate-api/commit/ad8084e5e5822c9f1f49e0acd00676b57c1e4f2b))
|
|
7
|
+
* removed listener and use await with request to get response ([db14d2c](https://github.com/CoCreate-app/CoCreate-api/commit/db14d2cdcc17d0edd967f660ec5206ab0172fd4d))
|
|
8
|
+
* update doc ([d68a2e2](https://github.com/CoCreate-app/CoCreate-api/commit/d68a2e207c8f3e3d497ccff4f6cece3eb5639488))
|
|
9
|
+
|
|
1
10
|
## [1.21.2](https://github.com/CoCreate-app/CoCreate-api/compare/v1.21.1...v1.21.2) (2024-06-23)
|
|
2
11
|
|
|
3
12
|
|
package/docs/index.html
CHANGED
|
@@ -17,8 +17,15 @@
|
|
|
17
17
|
</head>
|
|
18
18
|
|
|
19
19
|
<body>
|
|
20
|
-
<nav
|
|
21
|
-
|
|
20
|
+
<nav
|
|
21
|
+
class="nav display:flex align-items:center left:0px background:whitesmoke padding-top:10px padding-bottom:10px"
|
|
22
|
+
content_id="content"
|
|
23
|
+
scroll="sticky-nav,hide-nav"
|
|
24
|
+
scroll-up="10"
|
|
25
|
+
scroll-down="10"
|
|
26
|
+
array="files"
|
|
27
|
+
object="60395ef42b3ac232657040fd"
|
|
28
|
+
key="src">
|
|
22
29
|
</nav>
|
|
23
30
|
<sidenav id="menuL" class="position:fixed top:0px left:0px overflow:hidden background:whitesmoke height:100vh width:0px width:300px@xl" resizable resize-selector="[content_id='content']" resize-property="margin-left" resize-value="width">
|
|
24
31
|
<menu array="files" object="603717b07de7fb350ae9fec8" key="src"></menu>
|
|
@@ -42,8 +49,9 @@
|
|
|
42
49
|
<a href="https://github.com/CoCreate-app/CoCreate-dnd" target="_blank" class=""><i src="/assets/svg/github.svg"></i></a>
|
|
43
50
|
</div>
|
|
44
51
|
</div>
|
|
45
|
-
|
|
46
|
-
|
|
52
|
+
|
|
53
|
+
<!-- <h1 class="max-width:500px margin:20px_10px line-height:1.5 font-size:16px font-weight:100">CoCreate-api is a simple api helper component in vanilla javascript used by JavaScript developers to create thirdparty api intergrations. Thirdparty apis can be accessible using HTML5 attributes and/or JavaScript API. CoCreate-api includes the
|
|
54
|
+
client component and server side for api processing.</h1> -->
|
|
47
55
|
<div id="api-section" class="display:flex flex-wrap:wrap">
|
|
48
56
|
<div class="flex-grow:1 width:400px width:300px@xs padding:0px_10px margin-top:60px">
|
|
49
57
|
|
|
@@ -74,7 +82,7 @@
|
|
|
74
82
|
<span class="display:flex align-items:center width:fit-content" hover="display:block!important" hover-selector="[href='#api-usage']">
|
|
75
83
|
<h2 class="padding:5px_0px">Usage</h2>
|
|
76
84
|
<a class="margin-left:10px display:none" href="#api-usage"><i src="/assets/svg/link.svg"></i></a>
|
|
77
|
-
|
|
85
|
+
</span>
|
|
78
86
|
</div>
|
|
79
87
|
|
|
80
88
|
<h4 class="margin-top:20px padding:5px_0px">Install package</h4>
|
|
@@ -218,7 +226,6 @@
|
|
|
218
226
|
|
|
219
227
|
</div>
|
|
220
228
|
<!-- End SandBox -->
|
|
221
|
-
</div>
|
|
222
229
|
</div>
|
|
223
230
|
</div>
|
|
224
231
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/api",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.3",
|
|
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/index.js
CHANGED
|
@@ -29,10 +29,6 @@ const CoCreateApi = {
|
|
|
29
29
|
if (typeof this.modules[name] === 'undefined') {
|
|
30
30
|
this.modules[name] = { name, endPoints, options };
|
|
31
31
|
|
|
32
|
-
Socket.listen(name, (data) => {
|
|
33
|
-
self.response(name, data);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
32
|
Actions.init({
|
|
37
33
|
name,
|
|
38
34
|
callback: (action) => {
|
|
@@ -91,12 +87,13 @@ const CoCreateApi = {
|
|
|
91
87
|
this.modules[object.name][object.method].request(object)
|
|
92
88
|
else if (!object.event && object.type === 'action' || object.event && object.event.includes(object.type)) {
|
|
93
89
|
let data = await CoCreateApi.getData(object);
|
|
94
|
-
CoCreateApi.send(object
|
|
90
|
+
CoCreateApi.send(object, data);
|
|
95
91
|
}
|
|
96
92
|
},
|
|
97
93
|
|
|
98
|
-
response: function (
|
|
99
|
-
const
|
|
94
|
+
response: function (object, data) {
|
|
95
|
+
const name = object.name
|
|
96
|
+
const method = object.method;
|
|
100
97
|
if (this.modules[name][method] && this.modules[name][method].response)
|
|
101
98
|
this.modules[name][method].response(data[name])
|
|
102
99
|
else if (data.error) {
|
|
@@ -110,9 +107,9 @@ const CoCreateApi = {
|
|
|
110
107
|
}]
|
|
111
108
|
});
|
|
112
109
|
} else {
|
|
113
|
-
CoCreateApi.setData(
|
|
110
|
+
CoCreateApi.setData(object, data)
|
|
114
111
|
|
|
115
|
-
document.dispatchEvent(new CustomEvent(
|
|
112
|
+
document.dispatchEvent(new CustomEvent(object.endEvent, {
|
|
116
113
|
detail: {
|
|
117
114
|
data: data[name]
|
|
118
115
|
}
|
|
@@ -120,8 +117,9 @@ const CoCreateApi = {
|
|
|
120
117
|
}
|
|
121
118
|
},
|
|
122
119
|
|
|
123
|
-
send: function (
|
|
124
|
-
Socket.send({ method: name + '.' + method, [name]: data, broadcast: false, broadcastBrowser: false, status: 'await' });
|
|
120
|
+
send: async function (object, data) {
|
|
121
|
+
data = await Socket.send({ method: object.name + '.' + object.method, [object.name]: data, broadcast: false, broadcastBrowser: false, status: 'await' });
|
|
122
|
+
this.response(object, data);
|
|
125
123
|
},
|
|
126
124
|
|
|
127
125
|
getData: async function ({ name, method, element, form }) {
|
|
@@ -171,11 +169,13 @@ const CoCreateApi = {
|
|
|
171
169
|
return data
|
|
172
170
|
},
|
|
173
171
|
|
|
174
|
-
setData: function (
|
|
172
|
+
setData: function (object, data) {
|
|
173
|
+
const name = object.name
|
|
174
|
+
let form = object.form
|
|
175
175
|
if (!form)
|
|
176
176
|
form = document;
|
|
177
177
|
|
|
178
|
-
let elements = form.querySelectorAll(`[${name}="${method}"]`);
|
|
178
|
+
let elements = form.querySelectorAll(`[${name}="${object.method}"]`);
|
|
179
179
|
if (!elements || elements.length == 0)
|
|
180
180
|
return
|
|
181
181
|
|