@cocreate/api 1.2.18 → 1.2.22
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 +29 -0
- package/demo/index.html +19 -19
- package/docs/form.html +1 -1
- package/docs/index.html +14 -14
- package/docs/module.html +1 -1
- package/docs/server.html +1 -1
- package/package.json +8 -7
- package/src/client.js +20 -40
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
## [1.2.22](https://github.com/CoCreate-app/CoCreate-api/compare/v1.2.21...v1.2.22) (2022-01-01)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* get-value attribute value now supports a selector added # to all values currently in get-value attributes ([e36f596](https://github.com/CoCreate-app/CoCreate-api/commit/e36f5961be023c7dbb1eb7643ac2e995f1c6d0c0))
|
|
7
|
+
|
|
8
|
+
## [1.2.21](https://github.com/CoCreate-app/CoCreate-api/compare/v1.2.20...v1.2.21) (2022-01-01)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* removed data- from attributes ([ed63cfd](https://github.com/CoCreate-app/CoCreate-api/commit/ed63cfd6375cba25960fc0a3349ee39ddb98eebc))
|
|
14
|
+
|
|
15
|
+
## [1.2.20](https://github.com/CoCreate-app/CoCreate-api/compare/v1.2.19...v1.2.20) (2021-12-31)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* clean code ([a44ef95](https://github.com/CoCreate-app/CoCreate-api/commit/a44ef95a5fb2e0686d811fdd11144d093c2e0455))
|
|
21
|
+
* removed data- and added elements.getValue ([d339cbd](https://github.com/CoCreate-app/CoCreate-api/commit/d339cbd783f9fe5f244337907dc3ec3cd2d2cf54))
|
|
22
|
+
|
|
23
|
+
## [1.2.19](https://github.com/CoCreate-app/CoCreate-api/compare/v1.2.18...v1.2.19) (2021-12-15)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Bug Fixes
|
|
27
|
+
|
|
28
|
+
* update dependencies ([c50ad0d](https://github.com/CoCreate-app/CoCreate-api/commit/c50ad0d654955591a26a7eb2ccb903584d302227))
|
|
29
|
+
|
|
1
30
|
## [1.2.18](https://github.com/CoCreate-app/CoCreate-api/compare/v1.2.17...v1.2.18) (2021-12-14)
|
|
2
31
|
|
|
3
32
|
|
package/demo/index.html
CHANGED
|
@@ -10,31 +10,31 @@
|
|
|
10
10
|
<h1>Form Demo</h1>
|
|
11
11
|
|
|
12
12
|
<form>
|
|
13
|
-
<input
|
|
13
|
+
<input xxx="xxxCreateRequest.name">
|
|
14
14
|
|
|
15
|
-
<div
|
|
16
|
-
<input
|
|
17
|
-
<input
|
|
15
|
+
<div xxx="xxxCreateRequest.address" xxx_array="address">
|
|
16
|
+
<input xxx="address.home.city">
|
|
17
|
+
<input xxx="address.work">
|
|
18
18
|
</div>
|
|
19
19
|
|
|
20
|
-
<div
|
|
21
|
-
<input
|
|
22
|
-
<input
|
|
23
|
-
<input
|
|
24
|
-
|
|
25
|
-
<div
|
|
26
|
-
<input
|
|
27
|
-
<input
|
|
28
|
-
<input
|
|
29
|
-
<input
|
|
20
|
+
<div xxx="xxxCreateRequest.address" xxx_array="address">
|
|
21
|
+
<input xxx="address.home.city">
|
|
22
|
+
<input xxx="address.name">
|
|
23
|
+
<input xxx="address.line1">
|
|
24
|
+
|
|
25
|
+
<div xxx="address.billing" xxx_array="b">
|
|
26
|
+
<input xxx="b.address1">
|
|
27
|
+
<input xxx="b.city">
|
|
28
|
+
<input xxx="b.code.zip">
|
|
29
|
+
<input xxx="b.code.postal">
|
|
30
30
|
</div>
|
|
31
31
|
</div>
|
|
32
|
-
<input
|
|
32
|
+
<input xxx="xxxCreateRequest.email">
|
|
33
33
|
|
|
34
|
-
<div template_id="xxxCreateCard" render-array="data.card" render-key="c"
|
|
35
|
-
<input
|
|
36
|
-
<input
|
|
37
|
-
<input
|
|
34
|
+
<div template_id="xxxCreateCard" render-array="data.card" render-key="c" xxx="xxxCreateCard.card" xxx_array="card">
|
|
35
|
+
<input xxx="card.number" value="c.number">
|
|
36
|
+
<input xxx="card.cvv" value="c.cvv">
|
|
37
|
+
<input xxx="card.expiry" value="c.expiry">
|
|
38
38
|
</div>
|
|
39
39
|
|
|
40
40
|
|
package/docs/form.html
CHANGED
|
@@ -194,7 +194,7 @@
|
|
|
194
194
|
<div class="svSplitter svHorizontal"> </div>
|
|
195
195
|
|
|
196
196
|
<div class="svPanel">
|
|
197
|
-
<iframe get-value="demo" frameBorder="0" height="100%" width="100%" class="min-width:300px"></iframe>
|
|
197
|
+
<iframe get-value="#demo" frameBorder="0" height="100%" width="100%" class="min-width:300px"></iframe>
|
|
198
198
|
</div>
|
|
199
199
|
|
|
200
200
|
</div>
|
package/docs/index.html
CHANGED
|
@@ -156,22 +156,22 @@
|
|
|
156
156
|
<p class="padding:10px_0px line-height:1.5">
|
|
157
157
|
<pre><code class="language-html">
|
|
158
158
|
<form>
|
|
159
|
-
<input
|
|
160
|
-
<div
|
|
161
|
-
<input
|
|
162
|
-
<input
|
|
159
|
+
<input stripe="createCustomer.name">
|
|
160
|
+
<div stripe="createCustomer.address" stripe_array="address">
|
|
161
|
+
<input stripe="address.home.city">
|
|
162
|
+
<input stripe="address.work">
|
|
163
163
|
</div>
|
|
164
164
|
|
|
165
|
-
<div
|
|
166
|
-
<input
|
|
167
|
-
<input
|
|
168
|
-
<input
|
|
165
|
+
<div stripe="createCustomer.address" xxx_array="address">
|
|
166
|
+
<input stripe="address.home.city">
|
|
167
|
+
<input stripe="address.name">
|
|
168
|
+
<input stripe="address.line1">
|
|
169
169
|
|
|
170
|
-
<div
|
|
171
|
-
<input
|
|
172
|
-
<input
|
|
173
|
-
<input
|
|
174
|
-
<input
|
|
170
|
+
<div stripe="address.billing" xxx_array="b">
|
|
171
|
+
<input stripe="b.address1">
|
|
172
|
+
<input stripe="b.city">
|
|
173
|
+
<input stripe="b.code.zip">
|
|
174
|
+
<input stripe="b.code.postal">
|
|
175
175
|
</div>
|
|
176
176
|
</div>
|
|
177
177
|
<button actions='createCustomer'>Create Form</button>
|
|
@@ -220,7 +220,7 @@
|
|
|
220
220
|
<div class="svSplitter svHorizontal"> </div>
|
|
221
221
|
|
|
222
222
|
<div class="svPanel">
|
|
223
|
-
<iframe get-value="demo" frameBorder="0" height="100%" width="100%" class="min-width:300px"></iframe>
|
|
223
|
+
<iframe get-value="#demo" frameBorder="0" height="100%" width="100%" class="min-width:300px"></iframe>
|
|
224
224
|
</div>
|
|
225
225
|
|
|
226
226
|
</div>
|
package/docs/module.html
CHANGED
|
@@ -184,7 +184,7 @@
|
|
|
184
184
|
<div class="svSplitter svHorizontal"> </div>
|
|
185
185
|
|
|
186
186
|
<div class="svPanel">
|
|
187
|
-
<iframe get-value="demo" frameBorder="0" height="100%" width="100%" class="min-width:300px"></iframe>
|
|
187
|
+
<iframe get-value="#demo" frameBorder="0" height="100%" width="100%" class="min-width:300px"></iframe>
|
|
188
188
|
</div>
|
|
189
189
|
|
|
190
190
|
</div>
|
package/docs/server.html
CHANGED
|
@@ -195,7 +195,7 @@
|
|
|
195
195
|
<div class="svSplitter svHorizontal"> </div>
|
|
196
196
|
|
|
197
197
|
<div class="svPanel">
|
|
198
|
-
<iframe get-value="demo" frameBorder="0" height="100%" width="100%" class="min-width:300px"></iframe>
|
|
198
|
+
<iframe get-value="#demo" frameBorder="0" height="100%" width="100%" class="min-width:300px"></iframe>
|
|
199
199
|
</div>
|
|
200
200
|
|
|
201
201
|
</div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/api",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.22",
|
|
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",
|
|
@@ -62,11 +62,12 @@
|
|
|
62
62
|
"webpack-log": "^3.0.1"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@cocreate/actions": "^1.3.
|
|
66
|
-
"@cocreate/crud-client": "^1.4.
|
|
67
|
-
"@cocreate/docs": "^1.2.
|
|
68
|
-
"@cocreate/
|
|
69
|
-
"@cocreate/
|
|
70
|
-
"@cocreate/
|
|
65
|
+
"@cocreate/actions": "^1.3.25",
|
|
66
|
+
"@cocreate/crud-client": "^1.4.40",
|
|
67
|
+
"@cocreate/docs": "^1.2.62",
|
|
68
|
+
"@cocreate/elements": "^1.5.0",
|
|
69
|
+
"@cocreate/hosting": "^1.2.58",
|
|
70
|
+
"@cocreate/render": "^1.3.24",
|
|
71
|
+
"@cocreate/socket-client": "^1.4.16"
|
|
71
72
|
}
|
|
72
73
|
}
|
package/src/client.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import CoCreateSocket from "@cocreate/socket-client";
|
|
3
3
|
import CoCreateAction from '@cocreate/actions';
|
|
4
4
|
import CoCreateRender from '@cocreate/render';
|
|
5
|
+
import CoCreateElements from '@cocreate/elements';
|
|
5
6
|
|
|
6
7
|
let socketApi = new CoCreateSocket('api');
|
|
7
8
|
|
|
@@ -44,9 +45,9 @@ const CoCreateApi = {
|
|
|
44
45
|
}
|
|
45
46
|
},
|
|
46
47
|
|
|
47
|
-
__responseProcess: function(
|
|
48
|
+
__responseProcess: function(id, data) {
|
|
48
49
|
const {type, response} = data;
|
|
49
|
-
const m_instance = this.modules[
|
|
50
|
+
const m_instance = this.modules[id];
|
|
50
51
|
|
|
51
52
|
if (type && response && m_instance) {
|
|
52
53
|
|
|
@@ -65,24 +66,29 @@ const CoCreateApi = {
|
|
|
65
66
|
},
|
|
66
67
|
|
|
67
68
|
__commonAction: function(id, action, element) {
|
|
68
|
-
const
|
|
69
|
-
let data = CoCreateApi.getFormData(id, action,
|
|
69
|
+
const form = element.closest("form") || document;
|
|
70
|
+
let data = CoCreateApi.getFormData(id, action, form);
|
|
70
71
|
CoCreateApi.send(id, action, data);
|
|
71
72
|
},
|
|
72
73
|
|
|
73
74
|
|
|
74
|
-
getFormData
|
|
75
|
-
const mainAttr =
|
|
75
|
+
getFormData: function(id, action, form){
|
|
76
|
+
const mainAttr = id;
|
|
76
77
|
const self = this;
|
|
77
|
-
const elements =
|
|
78
|
+
const elements = form.querySelectorAll(`[${mainAttr}^="${action}."]`);
|
|
78
79
|
|
|
79
80
|
let data = {};
|
|
80
81
|
elements.forEach(element => {
|
|
81
82
|
let name = element.getAttribute(mainAttr);
|
|
82
|
-
let array_name = element.getAttribute(mainAttr + "_array");
|
|
83
|
-
let value = self.__getElValue(element);
|
|
84
|
-
|
|
85
83
|
if (!name) return;
|
|
84
|
+
|
|
85
|
+
let array_name = element.getAttribute(mainAttr + "_array");
|
|
86
|
+
|
|
87
|
+
let value;
|
|
88
|
+
if(element.getValue)
|
|
89
|
+
value = element.getValue(element);
|
|
90
|
+
else
|
|
91
|
+
value = CoCreateElements.getValue(element);
|
|
86
92
|
|
|
87
93
|
if (action) {
|
|
88
94
|
let re = new RegExp(`^${action}.`, 'i');
|
|
@@ -97,7 +103,7 @@ const CoCreateApi = {
|
|
|
97
103
|
if (!data[name]) {
|
|
98
104
|
data[name] = [];
|
|
99
105
|
}
|
|
100
|
-
data[name].push(self.getFormData(
|
|
106
|
+
data[name].push(self.getFormData(id, array_name, element));
|
|
101
107
|
} else if (value != null) {
|
|
102
108
|
data[name] = value;
|
|
103
109
|
}
|
|
@@ -118,31 +124,6 @@ const CoCreateApi = {
|
|
|
118
124
|
return objectData;
|
|
119
125
|
},
|
|
120
126
|
|
|
121
|
-
__getElValue: function(element) {
|
|
122
|
-
let value = null;
|
|
123
|
-
if(element.getValue)
|
|
124
|
-
value = element.getValue(element);
|
|
125
|
-
else if (typeof element.value !== "undefined") {
|
|
126
|
-
switch (element.type.toLocaleLowerCase()) {
|
|
127
|
-
case 'checkbox':
|
|
128
|
-
if (element.checked) {
|
|
129
|
-
value = element.value;
|
|
130
|
-
}
|
|
131
|
-
break;
|
|
132
|
-
default:
|
|
133
|
-
value = element.value;
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
} else {
|
|
137
|
-
value = element.getAttribute('value');
|
|
138
|
-
if (!value) {
|
|
139
|
-
value = element.innerHTML;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return value;
|
|
144
|
-
},
|
|
145
|
-
|
|
146
127
|
__mergeObject: function(target, source) {
|
|
147
128
|
target = target || {};
|
|
148
129
|
for (let key of Object.keys(source)) {
|
|
@@ -180,13 +161,12 @@ const CoCreateApi = {
|
|
|
180
161
|
});
|
|
181
162
|
},
|
|
182
163
|
|
|
183
|
-
getCommonParams: function(info)
|
|
184
|
-
{
|
|
164
|
+
getCommonParams: function(info) {
|
|
185
165
|
return {
|
|
186
166
|
"apiKey": info.apiKey || config.apiKey,
|
|
187
167
|
"organization_id": info.organization_id || config.organization_Id,
|
|
188
|
-
}
|
|
168
|
+
};
|
|
189
169
|
}
|
|
190
|
-
}
|
|
170
|
+
};
|
|
191
171
|
|
|
192
172
|
export default CoCreateApi;
|