@cocreate/api 1.10.30 → 1.11.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,27 @@
1
+ # [1.11.0](https://github.com/CoCreate-app/CoCreate-api/compare/v1.10.31...v1.11.0) (2023-08-16)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * crud attributes renamed ([739fd2e](https://github.com/CoCreate-app/CoCreate-api/commit/739fd2ec4db058f064561373395adeaf5da2265e))
7
+ * render-array and render-object attributes renamed to render ([558b8cd](https://github.com/CoCreate-app/CoCreate-api/commit/558b8cd0b3ca4c648ea39dbea9de4bf37ea5adeb))
8
+ * replace -target -selector ([8daf241](https://github.com/CoCreate-app/CoCreate-api/commit/8daf24163608a51eb0daad64fc4f430a56e14be9))
9
+ * updated actions callback data object ([8034616](https://github.com/CoCreate-app/CoCreate-api/commit/803461695887e239074761ecf52a5240313699fa))
10
+ * webpack.config and package.json make use of mode=production instead of process.env ([af618e8](https://github.com/CoCreate-app/CoCreate-api/commit/af618e8b4c9f2369f91f7486d94ab7f974ede83f))
11
+
12
+
13
+ ### Features
14
+
15
+ * name attribute and variable renamed to key ([9e8016d](https://github.com/CoCreate-app/CoCreate-api/commit/9e8016d583d02fb9a0e0dfa0b8c1e153e56b0981))
16
+ * update template_id to render-selector attribute. update filter attributes to filter selector-attributes ([d22a5be](https://github.com/CoCreate-app/CoCreate-api/commit/d22a5beb7e6afe50c41f4dccde6a92000366d219))
17
+
18
+ ## [1.10.31](https://github.com/CoCreate-app/CoCreate-api/compare/v1.10.30...v1.10.31) (2023-06-14)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * Update dependencies versions for [@cocreate](https://github.com/cocreate) libraries ([86f65e8](https://github.com/CoCreate-app/CoCreate-api/commit/86f65e88053938126be1c277b39664eaa727cc78))
24
+
1
25
  ## [1.10.30](https://github.com/CoCreate-app/CoCreate-api/compare/v1.10.29...v1.10.30) (2023-06-11)
2
26
 
3
27
 
@@ -4,8 +4,8 @@ module.exports = {
4
4
  "host": "",
5
5
  "sources": [
6
6
  {
7
- "collection": "files",
8
- "document": {
7
+ "array": "files",
8
+ "object": {
9
9
  "_id": "601f02625803e43d00589077",
10
10
  "name": "index.html",
11
11
  "path": "/docs/api/index.html",
package/demo/index.html CHANGED
@@ -37,7 +37,7 @@
37
37
 
38
38
  <div
39
39
  template_id="xxxCreateCard"
40
- render-array="data.card"
40
+ render="data.card"
41
41
  render-key="c"
42
42
  xxx="xxxCreateCard.card"
43
43
  xxx_array="card">
package/docs/form.html CHANGED
@@ -14,15 +14,15 @@
14
14
  <!-- CoCreate CSS -->
15
15
  <!-- CoCreate CSS -->
16
16
  <link rel="stylesheet" href="https://cdn.cocreate.app/latest/CoCreate.min.css" type="text/css" />
17
- <link rel="stylesheet" href="/docs/index.css" collection="files" document_id="60888216117c640e7596303f" name="src" type="text/css" save="true" />
17
+ <link rel="stylesheet" href="/docs/index.css" array="files" object="60888216117c640e7596303f" key="src" type="text/css" save="true" />
18
18
  <link rel="manifest" href="/manifest.webmanifest" />
19
19
  </head>
20
20
 
21
21
  <body>
22
- <nav class="nav display:flex align-items:center left:0px background:whitesmoke padding-top:10px padding-bottom:10px" content_id="content" scroll="sticky-nav,hide-nav" scroll-up="10" scroll-down="10" collection="files" document_id="60395ef42b3ac232657040fd" name="src">
22
+ <nav class="nav display:flex align-items:center left:0px background:whitesmoke padding-top:10px padding-bottom:10px" content_id="content" scroll="sticky-nav,hide-nav" scroll-up="10" scroll-down="10" array="files" object="60395ef42b3ac232657040fd" key="src">
23
23
  </nav>
24
- <sidenav id="menuL" class="position:fixed top:0px left:0px overflow:hidden background:whitesmoke height:100vh width:0px width:300px@xl" resizable resize-target="[content_id='content']" resize-property="margin-left" resize-value="width">
25
- <menu collection="files" document_id="603717b07de7fb350ae9fec8" name="src"></menu>
24
+ <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">
25
+ <menu array="files" object="603717b07de7fb350ae9fec8" key="src"></menu>
26
26
  <div resize="right"></div>
27
27
  </sidenav>
28
28
  <main class="padding-top:15px padding:15px@lg@xl" content_id="content" id="CoCreate-api-form">
@@ -32,7 +32,7 @@
32
32
  </div>
33
33
  <div class="display:flex align-items:center font-size:20px position:absolute right:0 padding:5px background:white">
34
34
  <div class="display:flex align-items:center transition:0.3s padding-left:10px" share-network="true" share-text="An api helper component in vanilla javascript to setup thirdparty api intergrations. Apis can be accessible using HTML5 attributes and/or JavaScript API"
35
- share-title="CoCreate API form" share-height="600" share-width="700" share-media="https://cdn.cocreate.app/docs/api.png" hover="display:block!important" hover-target=".social-networks">
35
+ share-title="CoCreate API form" share-height="600" share-width="700" share-media="https://cdn.cocreate.app/docs/api.png" hover="display:block!important" hover-selector=".social-networks">
36
36
  <div class="display:none social-networks">
37
37
  <a class="margin-right:15px" share-network="twitter" title="Share on twitter"><i class="height:20px fill:#505050" src="/assets/svg/twitter.svg"></i></a>
38
38
  <a class="margin-right:15px" share-network="facebook" title="Share on Facebook"><i class="height:20px fill:#505050" src="/assets/svg/facebook.svg"></i></a>
@@ -49,8 +49,8 @@
49
49
  <div class="flex-grow:1 width:400px width:300px@xs padding:0px_10px margin-top:60px">
50
50
 
51
51
 
52
- <div id="api-install" class="border-bottom:1px_solid_lightgrey" scroll scroll-intersect="color:dodgerblue" scroll-target="#api-install-section">
53
- <span class="display:flex align-items:center width:fit-content" hover="display:block!important" hover-target="[href='#api-install']">
52
+ <div id="api-install" class="border-bottom:1px_solid_lightgrey" scroll scroll-intersect="color:dodgerblue" scroll-selector="#api-install-section">
53
+ <span class="display:flex align-items:center width:fit-content" hover="display:block!important" hover-selector="[href='#api-install']">
54
54
  <h2 class="padding:5px_0px">Install</h2>
55
55
  <a class="margin-left:10px display:none" href="#api-install"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
56
56
  </span>
@@ -63,13 +63,13 @@
63
63
  <pre><code class="language-html">&lt;script&gt;https://cdn.cocreate.app/api/latest/CoCreate-api.min.js&lt;/script&gt;</code></pre>
64
64
 
65
65
  <div>
66
- <h2 id="api-server-run" hover="display:block" hover-target="" class="border-bottom:1px_solid_lightgrey padding:5px_0px">Server run</h2>
66
+ <h2 id="api-server-run" hover="display:block" hover-selector="" class="border-bottom:1px_solid_lightgrey padding:5px_0px">Server run</h2>
67
67
  <a class="display:none" href="#api-server-run"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
68
68
  </div>
69
69
  <pre><code class="language-javascript">npm run start</code></pre>
70
70
 
71
71
  <div>
72
- <h2 id="api-dependencies" hover="display:block" hover-target="" class="border-bottom:1px_solid_lightgrey margin-top:80px padding:5px_0px">Dependencies components</h2>
72
+ <h2 id="api-dependencies" hover="display:block" hover-selector="" class="border-bottom:1px_solid_lightgrey margin-top:80px padding:5px_0px">Dependencies components</h2>
73
73
  <a class="display:none" href="#api-dependencies"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
74
74
  </div>
75
75
  <p class="padding:10px_0px line-height:1.5">
@@ -79,7 +79,7 @@
79
79
 
80
80
 
81
81
  <div>
82
- <h2 id="api-development" hover="display:block" hover-target="" class="border-bottom:1px_solid_lightgrey margin-top:80px padding:5px_0px">Development Guide</h2>
82
+ <h2 id="api-development" hover="display:block" hover-selector="" class="border-bottom:1px_solid_lightgrey margin-top:80px padding:5px_0px">Development Guide</h2>
83
83
  <a class="display:none" href="#api-development"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
84
84
  </div>
85
85
 
@@ -170,8 +170,8 @@
170
170
  <div class="flex-grow:1 width:300px padding:0px_10px margin-top:60px border-bottom:1px_solid_lightgrey">
171
171
 
172
172
  <!-- SandBox -->
173
- <div id="api-demo" class="border-bottom:1px_solid_lightgrey" scroll scroll-intersect="color:dodgerblue" scroll-target="#api-demo-section">
174
- <span class="display:flex align-items:center width:fit-content" hover="display:block!important" hover-target="[href='#api-demo']">
173
+ <div id="api-demo" class="border-bottom:1px_solid_lightgrey" scroll scroll-intersect="color:dodgerblue" scroll-selector="#api-demo-section">
174
+ <span class="display:flex align-items:center width:fit-content" hover="display:block!important" hover-selector="[href='#api-demo']">
175
175
  <h2 class="padding:5px_0px">Demo</h2>
176
176
  <a class="margin-left:10px display:none" href="#api-demo"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
177
177
  </span>
@@ -182,7 +182,7 @@
182
182
  <div class="display:flex flex-direction:column position:relative overflow:hidden card border-radius:2px width:auto height:600px margin-top:20px" id="playground">
183
183
 
184
184
  <div id="demo-code" resizable class="position:relative height:50%">
185
- <textarea type="code" lang="html" collection="demos" document_id="" name="demo" save="false" id="demo" class="height:100% width:100% outline:none border:none resize:none padding:5px"></textarea>
185
+ <textarea type="code" lang="html" array="demos" object="" key="demo" save="false" id="demo" class="height:100% width:100% outline:none border:none resize:none padding:5px"></textarea>
186
186
  <div resize="bottom" class="background:lightgrey"></div>
187
187
  </div>
188
188
 
@@ -191,11 +191,11 @@
191
191
  </div>
192
192
 
193
193
  <div class="font-size:20px position:absolute top:10px right:10px opacity:0.6">
194
- <a class="margin-right:10px" id="eye" show="#eye-slash" hide="#eye, #demo-preview" toggle="code-height" toggle-target="#demo-code"><i class="height:18px fill:#505050" src="/assets/svg/eye.svg"></i></a>
195
- <a class="margin-right:10px" hidden id="eye-slash" show="#eye, #demo-preview" hide="#eye-slash" toggle="code-height" toggle-target="#demo-code"><i class="height:20px fill:#505050" src="/assets/svg/eye-slash.svg"></i></a>
194
+ <a class="margin-right:10px" id="eye" show="#eye-slash" hide="#eye, #demo-preview" toggle="code-height" toggle-selector="#demo-code"><i class="height:18px fill:#505050" src="/assets/svg/eye.svg"></i></a>
195
+ <a class="margin-right:10px" hidden id="eye-slash" show="#eye, #demo-preview" hide="#eye-slash" toggle="code-height" toggle-selector="#demo-code"><i class="height:20px fill:#505050" src="/assets/svg/eye-slash.svg"></i></a>
196
196
  <a class="margin-right:10px" id="code" show="#code-slash" hide="#code, #demo-code"><i class="height:20px fill:#505050" src="/assets/svg/code.svg"></i></a>
197
197
  <a class="margin-right:10px" hidden id="code-slash" show="#code, #demo-code" hide="#code-slash"><i class="display:flex height:18px fill:#505050" src="/assets/svg/code.svg"></i></a>
198
- <a class="margin-right:5px" fullscreen fullscreen-target="#playground"></a>
198
+ <a class="margin-right:5px" fullscreen fullscreen-selector="#playground"></a>
199
199
  </div>
200
200
 
201
201
  </div>
package/docs/index.html CHANGED
@@ -14,17 +14,17 @@
14
14
 
15
15
  <!-- CoCreate CSS -->
16
16
  <link rel="stylesheet" href="https://cdn.cocreate.app/latest/CoCreate.min.css" type="text/css" />
17
- <link rel="stylesheet" href="/docs/index.css" collection="files" document_id="60888216117c640e7596303f" name="src" type="text/css" save="true" />
17
+ <link rel="stylesheet" href="/docs/index.css" array="files" object="60888216117c640e7596303f" key="src" type="text/css" save="true" />
18
18
 
19
19
  <link rel="manifest" href="/manifest.webmanifest" />
20
20
  </head>
21
21
 
22
22
  <body>
23
- <nav class="nav display:flex align-items:center left:0px background:whitesmoke padding-top:10px padding-bottom:10px" content_id="content" scroll="sticky-nav,hide-nav" scroll-up="10" scroll-down="10" collection="files" document_id="60395ef42b3ac232657040fd"
24
- name="src">
23
+ <nav class="nav display:flex align-items:center left:0px background:whitesmoke padding-top:10px padding-bottom:10px" content_id="content" scroll="sticky-nav,hide-nav" scroll-up="10" scroll-down="10" array="files" object="60395ef42b3ac232657040fd"
24
+ key="src">
25
25
  </nav>
26
- <sidenav id="menuL" class="position:fixed top:0px left:0px overflow:hidden background:whitesmoke height:100vh width:0px width:300px@xl" resizable resize-target="[content_id='content']" resize-property="margin-left" resize-value="width">
27
- <menu collection="files" document_id="603717b07de7fb350ae9fec8" name="src"></menu>
26
+ <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">
27
+ <menu array="files" object="603717b07de7fb350ae9fec8" key="src"></menu>
28
28
  <div resize="right"></div>
29
29
  </sidenav>
30
30
  <main class="padding-top:15px padding:15px@lg@xl" content_id="content" id="CoCreate-api">
@@ -34,7 +34,7 @@
34
34
  </div>
35
35
  <div class="display:flex align-items:center font-size:20px position:absolute right:0 padding:5px background:white">
36
36
  <div class="display:flex align-items:center transition:0.3s padding-left:10px" share-network="true" share-text="Enter decription here" share-title="testing im a title" share-height="600" share-width="700" share-media="https://cdn.cocreate.app/docs/api.png"
37
- hover="display:block!important" hover-target=".social-networks">
37
+ hover="display:block!important" hover-selector=".social-networks">
38
38
  <div class="display:none social-networks">
39
39
  <a class="margin-right:15px" share-network="twitter" title="Share on twitter"><i class="height:20px fill:#505050" src="/assets/svg/twitter.svg"></i></a>
40
40
  <a class="margin-right:15px" share-network="facebook" title="Share on Facebook"><i class="height:20px fill:#505050" src="/assets/svg/facebook.svg"></i></a>
@@ -50,8 +50,8 @@
50
50
  <div id="api-section" class="display:flex flex-wrap:wrap">
51
51
  <div class="flex-grow:1 width:400px width:300px@xs padding:0px_10px margin-top:60px">
52
52
 
53
- <div id="api-install" class="border-bottom:1px_solid_lightgrey" scroll scroll-intersect="color:dodgerblue" scroll-target="#api-install-section">
54
- <span class="display:flex align-items:center width:fit-content" hover="display:block!important" hover-target="[href='#api-install']">
53
+ <div id="api-install" class="border-bottom:1px_solid_lightgrey" scroll scroll-intersect="color:dodgerblue" scroll-selector="#api-install-section">
54
+ <span class="display:flex align-items:center width:fit-content" hover="display:block!important" hover-selector="[href='#api-install']">
55
55
  <h2 class="padding:5px_0px">Install</h2>
56
56
  <a class="margin-left:10px display:none" href="#api-install"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
57
57
  </span>
@@ -62,7 +62,7 @@
62
62
  <pre><code class="language-html">&lt;script&gt;https://cdn.cocreate.app/api/latest/CoCreate-api.min.js&lt;/script&gt;</code></pre>
63
63
 
64
64
  <div>
65
- <h2 id="api-dependencies" hover="display:block" hover-target="" class="border-bottom:1px_solid_lightgrey margin-top:80px padding:5px_0px">Dependencies components</h2>
65
+ <h2 id="api-dependencies" hover="display:block" hover-selector="" class="border-bottom:1px_solid_lightgrey margin-top:80px padding:5px_0px">Dependencies components</h2>
66
66
  <a class="display:none" href="#api-dependencies"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
67
67
  </div>
68
68
 
@@ -73,8 +73,8 @@
73
73
  </p>
74
74
 
75
75
 
76
- <div id="api-usage" class="margin-top:80px border-bottom:1px_solid_lightgrey" scroll scroll-intersect="color:dodgerblue" scroll-target="#api-usage-section">
77
- <span class="display:flex align-items:center width:fit-content" hover="display:block!important" hover-target="[href='#api-usage']">
76
+ <div id="api-usage" class="margin-top:80px border-bottom:1px_solid_lightgrey" scroll scroll-intersect="color:dodgerblue" scroll-selector="#api-usage-section">
77
+ <span class="display:flex align-items:center width:fit-content" hover="display:block!important" hover-selector="[href='#api-usage']">
78
78
  <h2 class="padding:5px_0px">Usage</h2>
79
79
  <a class="margin-left:10px display:none" href="#api-usage"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
80
80
  </span>
@@ -88,7 +88,7 @@
88
88
  <pre><code class="language-html">&lt;script&gt;https://cdn.cocreate.app/api/latest/CoCreate-api.min.js&lt;/script&gt;</code></pre>
89
89
 
90
90
  <div>
91
- <h2 id="api-server-run" hover="display:block" hover-target="" class="border-bottom:1px_solid_lightgrey padding:5px_0px">Server run</h2>
91
+ <h2 id="api-server-run" hover="display:block" hover-selector="" class="border-bottom:1px_solid_lightgrey padding:5px_0px">Server run</h2>
92
92
  <a class="display:none" href="#api-server-run"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
93
93
  </div>
94
94
 
@@ -110,7 +110,7 @@
110
110
  </p>
111
111
 
112
112
  <div>
113
- <h2 id="api-functions" hover="display:block" hover-target="" class="border-bottom:1px_solid_lightgrey padding:5px_0px">CoCreate-api functions</h2>
113
+ <h2 id="api-functions" hover="display:block" hover-selector="" class="border-bottom:1px_solid_lightgrey padding:5px_0px">CoCreate-api functions</h2>
114
114
  <a class="display:none" href="#api-functions"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
115
115
  </div>
116
116
 
@@ -185,7 +185,7 @@
185
185
  <h2 class="border-bottom:1px_solid_lightgrey margin-top:20px padding:5px_0px">How Does It Works</h2>
186
186
  <p>CoCreate-fetch works based on cocreate.js and template. </p>
187
187
 
188
- <p>To fetch the array data, the template wrapper should define <code class="language-js">fetch-document</code>. <code class="language-js">template_id</code></p>
188
+ <p>To fetch the array data, the template wrapper should define <code class="language-js">document</code>. <code class="language-js">template_id</code></p>
189
189
 
190
190
  <h2 class="border-bottom:1px_solid_lightgrey margin-top:20px padding:5px_0px">Effects and Styles</h2>
191
191
 
@@ -197,8 +197,8 @@
197
197
  <div class="flex-grow:1 width:300px padding:0px_10px margin-top:60px border-bottom:1px_solid_lightgrey">
198
198
 
199
199
  <!-- SandBox -->
200
- <div id="api-demo" class="border-bottom:1px_solid_lightgrey" scroll scroll-intersect="color:dodgerblue" scroll-target="#api-demo-section">
201
- <span class="display:flex align-items:center width:fit-content" hover="display:block!important" hover-target="[href='#api-demo']">
200
+ <div id="api-demo" class="border-bottom:1px_solid_lightgrey" scroll scroll-intersect="color:dodgerblue" scroll-selector="#api-demo-section">
201
+ <span class="display:flex align-items:center width:fit-content" hover="display:block!important" hover-selector="[href='#api-demo']">
202
202
  <h2 class="padding:5px_0px">Demo</h2>
203
203
  <a class="margin-left:10px display:none" href="#api-demo"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
204
204
  </span>
@@ -208,7 +208,7 @@
208
208
  <div class="display:flex flex-direction:column position:relative overflow:hidden card border-radius:2px width:auto height:600px margin-top:20px" id="playground">
209
209
 
210
210
  <div id="demo-code" resizable class="position:relative height:50%">
211
- <textarea type="code" lang="html" collection="demos" document_id="" name="demo" save="false" id="demo" class="height:100% width:100% outline:none border:none resize:none padding:5px"></textarea>
211
+ <textarea type="code" lang="html" array="demos" object="" key="demo" save="false" id="demo" class="height:100% width:100% outline:none border:none resize:none padding:5px"></textarea>
212
212
  <div resize="bottom" class="background:lightgrey"></div>
213
213
  </div>
214
214
 
@@ -217,11 +217,11 @@
217
217
  </div>
218
218
 
219
219
  <div class="font-size:20px position:absolute top:10px right:10px opacity:0.6">
220
- <a class="margin-right:10px" id="eye" show="#eye-slash" hide="#eye, #demo-preview" toggle="code-height" toggle-target="#demo-code"><i class="height:18px fill:#505050" src="/assets/svg/eye.svg"></i></a>
221
- <a class="margin-right:10px" hidden id="eye-slash" show="#eye, #demo-preview" hide="#eye-slash" toggle="code-height" toggle-target="#demo-code"><i class="height:20px fill:#505050" src="/assets/svg/eye-slash.svg"></i></a>
220
+ <a class="margin-right:10px" id="eye" show="#eye-slash" hide="#eye, #demo-preview" toggle="code-height" toggle-selector="#demo-code"><i class="height:18px fill:#505050" src="/assets/svg/eye.svg"></i></a>
221
+ <a class="margin-right:10px" hidden id="eye-slash" show="#eye, #demo-preview" hide="#eye-slash" toggle="code-height" toggle-selector="#demo-code"><i class="height:20px fill:#505050" src="/assets/svg/eye-slash.svg"></i></a>
222
222
  <a class="margin-right:10px" id="code" show="#code-slash" hide="#code, #demo-code"><i class="height:20px fill:#505050" src="/assets/svg/code.svg"></i></a>
223
223
  <a class="margin-right:10px" hidden id="code-slash" show="#code, #demo-code" hide="#code-slash"><i class="display:flex height:18px fill:#505050" src="/assets/svg/code.svg"></i></a>
224
- <a class="margin-right:5px" fullscreen fullscreen-target="#playground"></a>
224
+ <a class="margin-right:5px" fullscreen fullscreen-selector="#playground"></a>
225
225
  </div>
226
226
 
227
227
  </div>
package/docs/module.html CHANGED
@@ -14,15 +14,15 @@
14
14
 
15
15
  <!-- CoCreate CSS -->
16
16
  <link rel="stylesheet" href="https://cdn.cocreate.app/latest/CoCreate.min.css" type="text/css" />
17
- <link rel="stylesheet" href="/docs/index.css" collection="files" document_id="60888216117c640e7596303f" name="src" type="text/css" save="true" />
17
+ <link rel="stylesheet" href="/docs/index.css" array="files" object="60888216117c640e7596303f" key="src" type="text/css" save="true" />
18
18
  <link rel="manifest" href="/manifest.webmanifest">
19
19
  </head>
20
20
 
21
21
  <body>
22
- <nav class="nav display:flex align-items:center left:0px background:whitesmoke padding-top:10px padding-bottom:10px" content_id="content" scroll="sticky-nav,hide-nav" scroll-up="10" scroll-down="10" collection="files" document_id="60395ef42b3ac232657040fd" name="src">
22
+ <nav class="nav display:flex align-items:center left:0px background:whitesmoke padding-top:10px padding-bottom:10px" content_id="content" scroll="sticky-nav,hide-nav" scroll-up="10" scroll-down="10" array="files" object="60395ef42b3ac232657040fd" key="src">
23
23
  </nav>
24
- <sidenav id="menuL" class="position:fixed top:0px left:0px overflow:hidden background:whitesmoke height:100vh width:0px width:300px@xl" resizable resize-target="[content_id='content']" resize-property="margin-left" resize-value="width">
25
- <menu collection="files" document_id="603717b07de7fb350ae9fec8" name="src"></menu>
24
+ <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">
25
+ <menu array="files" object="603717b07de7fb350ae9fec8" key="src"></menu>
26
26
  <div resize="right"></div>
27
27
  </sidenav>
28
28
  <main class="padding-top:15px padding:15px@lg@xl" content_id="content" id="CoCreate-api-module">
@@ -38,8 +38,8 @@
38
38
  <div id="api-section" class="display:flex flex-wrap:wrap">
39
39
  <div class="flex-grow:1 width:400px width:300px@xs padding:0px_10px margin-top:60px">
40
40
 
41
- <div id="api-install" class="border-bottom:1px_solid_lightgrey" scroll scroll-intersect="color:dodgerblue" scroll-target="#api-install-section">
42
- <span class="display:flex align-items:center width:fit-content" hover="display:block!important" hover-target="[href='#api-install']">
41
+ <div id="api-install" class="border-bottom:1px_solid_lightgrey" scroll scroll-intersect="color:dodgerblue" scroll-selector="#api-install-section">
42
+ <span class="display:flex align-items:center width:fit-content" hover="display:block!important" hover-selector="[href='#api-install']">
43
43
  <h2 class="padding:5px_0px">Install</h2>
44
44
  <a class="margin-left:10px display:none" href="#api-install"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
45
45
  </span>
@@ -52,7 +52,7 @@
52
52
  <pre><code class="language-html">&lt;script&gt;https://cdn.cocreate.app/api/latest/CoCreate-api.min.js&lt;/script&gt;</code></pre>
53
53
 
54
54
  <div>
55
- <h2 id="api-dependencies" hover="display:block" hover-target="" class="border-bottom:1px_solid_lightgrey margin-top:80px padding:5px_0px">Dependencies components</h2>
55
+ <h2 id="api-dependencies" hover="display:block" hover-selector="" class="border-bottom:1px_solid_lightgrey margin-top:80px padding:5px_0px">Dependencies components</h2>
56
56
  <a class="display:none" href="#api-dependencies"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
57
57
  </div>
58
58
  <p class="padding:10px_0px line-height:1.5">
@@ -62,7 +62,7 @@
62
62
 
63
63
 
64
64
  <div>
65
- <h2 id="api-development" hover="display:block" hover-target="" class="border-bottom:1px_solid_lightgrey margin-top:80px padding:5px_0px">Development Guide</h2>
65
+ <h2 id="api-development" hover="display:block" hover-selector="" class="border-bottom:1px_solid_lightgrey margin-top:80px padding:5px_0px">Development Guide</h2>
66
66
  <a class="display:none" href="#api-development"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
67
67
  </div>
68
68
 
@@ -159,8 +159,8 @@
159
159
  <div class="flex-grow:1 width:300px padding:0px_10px margin-top:60px border-bottom:1px_solid_lightgrey">
160
160
 
161
161
  <!-- SandBox -->
162
- <div id="api-demo" class="border-bottom:1px_solid_lightgrey" scroll scroll-intersect="color:dodgerblue" scroll-target="#api-demo-section">
163
- <span class="display:flex align-items:center width:fit-content" hover="display:block!important" hover-target="[href='#api-demo']">
162
+ <div id="api-demo" class="border-bottom:1px_solid_lightgrey" scroll scroll-intersect="color:dodgerblue" scroll-selector="#api-demo-section">
163
+ <span class="display:flex align-items:center width:fit-content" hover="display:block!important" hover-selector="[href='#api-demo']">
164
164
  <h2 class="padding:5px_0px">Demo</h2>
165
165
  <a class="margin-left:10px display:none" href="#api-demo"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
166
166
  </span>
@@ -172,7 +172,7 @@
172
172
  <div class="display:flex flex-direction:column position:relative overflow:hidden card border-radius:2px width:auto height:600px margin-top:20px" id="playground">
173
173
 
174
174
  <div id="demo-code" resizable class="position:relative height:50%">
175
- <textarea type="code" lang="html" collection="demos" document_id="" name="demo" save="false" id="demo" class="height:100% width:100% outline:none border:none resize:none padding:5px"></textarea>
175
+ <textarea type="code" lang="html" array="demos" object="" key="demo" save="false" id="demo" class="height:100% width:100% outline:none border:none resize:none padding:5px"></textarea>
176
176
  <div resize="bottom" class="background:lightgrey"></div>
177
177
  </div>
178
178
 
@@ -181,11 +181,11 @@
181
181
  </div>
182
182
 
183
183
  <div class="font-size:20px position:absolute top:10px right:10px opacity:0.6">
184
- <a class="margin-right:10px" id="eye" show="#eye-slash" hide="#eye, #demo-preview" toggle="code-height" toggle-target="#demo-code"><i class="height:18px fill:#505050" src="/assets/svg/eye.svg"></i></a>
185
- <a class="margin-right:10px" hidden id="eye-slash" show="#eye, #demo-preview" hide="#eye-slash" toggle="code-height" toggle-target="#demo-code"><i class="height:20px fill:#505050" src="/assets/svg/eye-slash.svg"></i></a>
184
+ <a class="margin-right:10px" id="eye" show="#eye-slash" hide="#eye, #demo-preview" toggle="code-height" toggle-selector="#demo-code"><i class="height:18px fill:#505050" src="/assets/svg/eye.svg"></i></a>
185
+ <a class="margin-right:10px" hidden id="eye-slash" show="#eye, #demo-preview" hide="#eye-slash" toggle="code-height" toggle-selector="#demo-code"><i class="height:20px fill:#505050" src="/assets/svg/eye-slash.svg"></i></a>
186
186
  <a class="margin-right:10px" id="code" show="#code-slash" hide="#code, #demo-code"><i class="height:20px fill:#505050" src="/assets/svg/code.svg"></i></a>
187
187
  <a class="margin-right:10px" hidden id="code-slash" show="#code, #demo-code" hide="#code-slash"><i class="display:flex height:18px fill:#505050" src="/assets/svg/code.svg"></i></a>
188
- <a class="margin-right:5px" fullscreen fullscreen-target="#playground"></a>
188
+ <a class="margin-right:5px" fullscreen fullscreen-selector="#playground"></a>
189
189
  </div>
190
190
 
191
191
  </div>
package/docs/server.html CHANGED
@@ -14,15 +14,15 @@
14
14
 
15
15
  <!-- CoCreate CSS -->
16
16
  <link rel="stylesheet" href="https://cdn.cocreate.app/latest/CoCreate.min.css" type="text/css" />
17
- <link rel="stylesheet" href="/docs/index.css" collection="files" document_id="60888216117c640e7596303f" name="src" type="text/css" save="true" />
17
+ <link rel="stylesheet" href="/docs/index.css" array="files" object="60888216117c640e7596303f" key="src" type="text/css" save="true" />
18
18
  <link rel="manifest" href="/manifest.webmanifest">
19
19
  </head>
20
20
 
21
21
  <body>
22
- <nav class="nav display:flex align-items:center left:0px background:whitesmoke padding-top:10px padding-bottom:10px" content_id="content" scroll="sticky-nav,hide-nav" scroll-up="10" scroll-down="10" collection="files" document_id="60395ef42b3ac232657040fd" name="src">
22
+ <nav class="nav display:flex align-items:center left:0px background:whitesmoke padding-top:10px padding-bottom:10px" content_id="content" scroll="sticky-nav,hide-nav" scroll-up="10" scroll-down="10" array="files" object="60395ef42b3ac232657040fd" key="src">
23
23
  </nav>
24
- <sidenav id="menuL" class="position:fixed top:0px left:0px overflow:hidden background:whitesmoke height:100vh width:0px width:300px@xl" resizable resize-target="[content_id='content']" resize-property="margin-left" resize-value="width">
25
- <menu collection="files" document_id="603717b07de7fb350ae9fec8" name="src"></menu>
24
+ <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">
25
+ <menu array="files" object="603717b07de7fb350ae9fec8" key="src"></menu>
26
26
  <div resize="right"></div>
27
27
  </sidenav>
28
28
  <main class="padding-top:15px padding:15px@lg@xl" content_id="content" id="CoCreate-api-server">
@@ -32,7 +32,7 @@
32
32
  </div>
33
33
  <div class="display:flex align-items:center font-size:20px position:absolute right:0 padding:5px background:white">
34
34
  <div class="display:flex align-items:center transition:0.3s padding-left:10px" share-network="true" share-text="An api helper component in vanilla javascript to setup thirdparty api intergrations. Apis can be accessible using HTML5 attributes and/or JavaScript API"
35
- share-title="CoCreate API server" share-height="600" share-width="700" share-media="https://cdn.cocreate.app/docs/api.png" hover="display:block!important" hover-target=".social-networks">
35
+ share-title="CoCreate API server" share-height="600" share-width="700" share-media="https://cdn.cocreate.app/docs/api.png" hover="display:block!important" hover-selector=".social-networks">
36
36
  <div class="display:none social-networks">
37
37
  <a class="margin-right:15px" share-network="twitter" title="Share on twitter"><i class="height:20px fill:#505050" src="/assets/svg/twitter.svg"></i></a>
38
38
  <a class="margin-right:15px" share-network="facebook" title="Share on Facebook"><i class="height:20px fill:#505050" src="/assets/svg/facebook.svg"></i></a>
@@ -47,8 +47,8 @@
47
47
  client component and server side for api processing.</h1>
48
48
  <div id="api-section" class="display:flex flex-wrap:wrap">
49
49
  <div class="flex-grow:1 width:400px width:300px@xs padding:0px_10px margin-top:60px">
50
- <div id="api-install" class="border-bottom:1px_solid_lightgrey" scroll scroll-intersect="color:dodgerblue" scroll-target="#api-install-section">
51
- <span class="display:flex align-items:center width:fit-content" hover="display:block!important" hover-target="[href='#api-install']">
50
+ <div id="api-install" class="border-bottom:1px_solid_lightgrey" scroll scroll-intersect="color:dodgerblue" scroll-selector="#api-install-section">
51
+ <span class="display:flex align-items:center width:fit-content" hover="display:block!important" hover-selector="[href='#api-install']">
52
52
  <h2 class="padding:5px_0px">Install</h2>
53
53
  <a class="margin-left:10px display:none" href="#api-install"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
54
54
  </span>
@@ -60,13 +60,13 @@
60
60
  <pre><code class="language-html">&lt;script&gt;https://cdn.cocreate.app/api/latest/CoCreate-api.min.js&lt;/script&gt;</code></pre>
61
61
 
62
62
  <div>
63
- <h2 id="api-server-run" hover="display:block" hover-target="" class="border-bottom:1px_solid_lightgrey padding:5px_0px">Server run</h2>
63
+ <h2 id="api-server-run" hover="display:block" hover-selector="" class="border-bottom:1px_solid_lightgrey padding:5px_0px">Server run</h2>
64
64
  <a class="display:none" href="#api-server-run"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
65
65
  </div>
66
66
  <pre><code class="language-javascript">npm run start</code></pre>
67
67
 
68
68
  <div>
69
- <h2 id="api-dependencies" hover="display:block" hover-target="" class="border-bottom:1px_solid_lightgrey margin-top:80px padding:5px_0px">Dependencies components</h2>
69
+ <h2 id="api-dependencies" hover="display:block" hover-selector="" class="border-bottom:1px_solid_lightgrey margin-top:80px padding:5px_0px">Dependencies components</h2>
70
70
  <a class="display:none" href="#api-dependencies"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
71
71
  </div>
72
72
  <p class="padding:10px_0px line-height:1.5">
@@ -76,7 +76,7 @@
76
76
 
77
77
 
78
78
  <div>
79
- <h2 id="api-development" hover="display:block" hover-target="" class="border-bottom:1px_solid_lightgrey margin-top:80px padding:5px_0px">Development Guide</h2>
79
+ <h2 id="api-development" hover="display:block" hover-selector="" class="border-bottom:1px_solid_lightgrey margin-top:80px padding:5px_0px">Development Guide</h2>
80
80
  <a class="display:none" href="#api-development"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
81
81
  </div>
82
82
 
@@ -171,8 +171,8 @@
171
171
  <div class="flex-grow:1 width:300px padding:0px_10px margin-top:60px border-bottom:1px_solid_lightgrey">
172
172
 
173
173
  <!-- SandBox -->
174
- <div id="api-demo" class="border-bottom:1px_solid_lightgrey" scroll scroll-intersect="color:dodgerblue" scroll-target="#api-demo-section">
175
- <span class="display:flex align-items:center width:fit-content" hover="display:block!important" hover-target="[href='#api-demo']">
174
+ <div id="api-demo" class="border-bottom:1px_solid_lightgrey" scroll scroll-intersect="color:dodgerblue" scroll-selector="#api-demo-section">
175
+ <span class="display:flex align-items:center width:fit-content" hover="display:block!important" hover-selector="[href='#api-demo']">
176
176
  <h2 class="padding:5px_0px">Demo</h2>
177
177
  <a class="margin-left:10px display:none" href="#api-demo"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
178
178
  </span>
@@ -183,7 +183,7 @@
183
183
  <div class="display:flex flex-direction:column position:relative overflow:hidden card border-radius:2px width:auto height:600px margin-top:20px" id="playground">
184
184
 
185
185
  <div id="demo-code" resizable class="position:relative height:50%">
186
- <textarea type="code" lang="html" collection="demos" document_id="" name="demo" save="false" id="demo" class="height:100% width:100% outline:none border:none resize:none padding:5px"></textarea>
186
+ <textarea type="code" lang="html" array="demos" object="" key="demo" save="false" id="demo" class="height:100% width:100% outline:none border:none resize:none padding:5px"></textarea>
187
187
  <div resize="bottom" class="background:lightgrey"></div>
188
188
  </div>
189
189
 
@@ -192,11 +192,11 @@
192
192
  </div>
193
193
 
194
194
  <div class="font-size:20px position:absolute top:10px right:10px opacity:0.6">
195
- <a class="margin-right:10px" id="eye" show="#eye-slash" hide="#eye, #demo-preview" toggle="code-height" toggle-target="#demo-code"><i class="height:18px fill:#505050" src="/assets/svg/eye.svg"></i></a>
196
- <a class="margin-right:10px" hidden id="eye-slash" show="#eye, #demo-preview" hide="#eye-slash" toggle="code-height" toggle-target="#demo-code"><i class="height:20px fill:#505050" src="/assets/svg/eye-slash.svg"></i></a>
195
+ <a class="margin-right:10px" id="eye" show="#eye-slash" hide="#eye, #demo-preview" toggle="code-height" toggle-selector="#demo-code"><i class="height:18px fill:#505050" src="/assets/svg/eye.svg"></i></a>
196
+ <a class="margin-right:10px" hidden id="eye-slash" show="#eye, #demo-preview" hide="#eye-slash" toggle="code-height" toggle-selector="#demo-code"><i class="height:20px fill:#505050" src="/assets/svg/eye-slash.svg"></i></a>
197
197
  <a class="margin-right:10px" id="code" show="#code-slash" hide="#code, #demo-code"><i class="height:20px fill:#505050" src="/assets/svg/code.svg"></i></a>
198
198
  <a class="margin-right:10px" hidden id="code-slash" show="#code, #demo-code" hide="#code-slash"><i class="display:flex height:18px fill:#505050" src="/assets/svg/code.svg"></i></a>
199
- <a class="margin-right:5px" fullscreen fullscreen-target="#playground"></a>
199
+ <a class="margin-right:5px" fullscreen fullscreen-selector="#playground"></a>
200
200
  </div>
201
201
 
202
202
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/api",
3
- "version": "1.10.30",
3
+ "version": "1.11.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",
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "scripts": {
28
28
  "start": "npx webpack --config webpack.config.js",
29
- "build": "NODE_ENV=production npx webpack --config webpack.config.js",
29
+ "build": "npx webpack --mode=production --config webpack.config.js",
30
30
  "dev": "npx webpack --config webpack.config.js --watch",
31
31
  "postinstall": "node -e \"const { execSync } = require('child_process'); try { execSync('coc --version', { stdio: 'ignore' }); } catch (error) { try { execSync('npm install -g @cocreate/cli', { stdio: 'inherit' }); console.log('Installed \"@cocreate/cli\" globally.'); } catch (error) { console.error('Failed to install \"@cocreate/cli\" globally:', error); } }\""
32
32
  },
@@ -59,12 +59,11 @@
59
59
  "webpack-log": "^3.0.1"
60
60
  },
61
61
  "dependencies": {
62
- "@cocreate/actions": "^1.8.30",
63
- "@cocreate/cli": "^1.33.8",
64
- "@cocreate/crud-client": "^1.21.22",
65
- "@cocreate/element-prototype": "^1.8.28",
66
- "@cocreate/render": "^1.24.30",
67
- "@cocreate/socket-client": "^1.23.24",
68
- "@cocreate/utils": "^1.21.14"
62
+ "@cocreate/actions": "^1.8.32",
63
+ "@cocreate/crud-client": "^1.21.24",
64
+ "@cocreate/element-prototype": "^1.8.30",
65
+ "@cocreate/render": "^1.24.32",
66
+ "@cocreate/socket-client": "^1.23.26",
67
+ "@cocreate/utils": "^1.21.16"
69
68
  }
70
69
  }
package/src/client.js CHANGED
@@ -1,190 +1,192 @@
1
1
  /*globals CustomEvent, config*/
2
- import {getAttributes, getValueFromObject, dotNotationToObject} from "@cocreate/utils";
2
+ import { getAttributes, getValueFromObject, dotNotationToObject } from "@cocreate/utils";
3
3
  import observer from "@cocreate/observer";
4
4
  import socket from "@cocreate/socket-client";
5
5
  import action from '@cocreate/actions';
6
6
  import render from '@cocreate/render';
7
7
  import '@cocreate/element-prototype';
8
8
 
9
- const CoCreateApi = {
10
- components: {},
11
-
12
- init: function({name, endPoints, options}) {
13
- this.register({name, endPoints, options});
14
- if (options.socket !== false && !socket.sockets.size)
15
- socket.create({prefix: 'api'});
16
- },
17
-
18
- register: function({name, endPoints, options}) {
19
- const self = this;
20
- if (typeof this.components[name] === 'undefined') {
21
- this.components[name] = {name, endPoints, options};
22
-
23
- socket.listen(name, (data) => {
24
- self.__response(name, data);
25
- });
26
-
27
- for (const endPoint of Object.keys(endPoints)) {
28
- let functions = endPoints[endPoint]
29
- if (typeof functions.request !== 'function') {
30
- functions.request = self.__request;
31
- }
32
- action.init({
33
- name: endPoint,
34
- endEvent: endPoint,
35
- callback: (element) => {
36
- let params
37
- let form = element.closest('form') || document
38
- const selector = `[${name}^="${endPoint}."]`
39
- let el = form.querySelector(selector)
40
- if (!el) return
41
- params = self.parseParams({name, element: el})
42
- if (params) {
43
- functions.request({name, ...params, element, form, type: 'action'})
44
- }
45
- },
46
- });
47
- }
48
-
49
- const inputEvent = (element) => {
50
- const self = this
51
- element.addEventListener('input', (e) => {
52
- if (element.hasAttribute(name)) {
53
- let params = self.parseParams({name, element})
54
- if (params) {
55
- if (!e.detail || e.detail && e.detail.skip != true) {
56
- endPoints[params.endPoint].request({name, ...params, element, type: 'input'})
57
- }
58
- }
59
- }
60
- });
61
- }
62
-
63
- let elements = document.querySelectorAll(`[${name}]`)
64
- for (let element of elements) {
65
- let params = this.parseParams({name, element})
66
- if (params) {
67
- endPoints[params.endPoint].request({name, ...params, element, type:'onload'})
68
- inputEvent(element)
69
- }
70
- }
71
-
72
- observer.init({
73
- name: `${name}NodeObserver`,
74
- observe: ['addedNodes'],
75
- target: `[${name}]`,
76
- callback: function(mutation) {
77
- let params = self.parseParams({name, element: mutation.target})
78
- if (params) {
79
- endPoints[params.endPoint].request({name, ...params, element: mutation.target, type: 'nodeObserver'});
80
- inputEvent(mutation.target)
81
- }
82
- }
83
- });
84
-
85
- observer.init({
86
- name: `${name}AttributeObserver`,
87
- observe: ['attributes'],
88
- attributeName: [name],
89
- callback: function(mutation) {
90
- let params = self.parseParams({name, element: mutation.target})
91
- if (params) {
92
- endPoints[params.endPoint].request({name, ...params, element: mutation.target, type: 'attributeObserver'});
93
- }
94
- }
95
- });
96
- }
97
- },
98
-
99
- __request: function({name, endPoint, element}) {
100
- let form = element.closest('form');
101
- let data = this.getData({name, endPoint, form});
102
- this.send(name, endPoint, data[endPoint]);
103
- },
104
-
105
- __response: function(name, data) {
106
- const {endPoint, response} = data;
107
- const component = this.components[name];
108
- const functions = component.endPoints[endPoint]
109
- if (functions.listen !== false) {
110
- if (typeof functions.response === 'function') {
111
- functions.response(response);
112
- } else
113
- this.setData({name, endPoint, data})
114
-
115
- document.dispatchEvent(new CustomEvent(endPoint, {
116
- detail: {
117
- data: response
118
- }
119
- }));
120
- }
121
- },
122
-
123
- send: function(name, endPoint, data) {
124
- socket.send(name, {endPoint, data, broadcastBrowser: false});
125
- },
126
-
127
- parseParams: function({name, endPoint, element}) {
128
- let attribute = element.getAttribute(name)
129
- if (!attribute)
130
- return false
131
-
132
- let dotNotation = attribute
133
- let params = attribute.split('.')
134
- endPoint = params[0]
135
- let key = params[1]
136
- return {endPoint, key, dotNotation, params}
137
-
138
- },
139
-
140
-
141
- getData: function({name, endPoint, element, form}) {
142
- const data = {}
143
- const selector = `[${name}^="${endPoint}."]`
144
- let elements
145
- if (form)
146
- elements = form.querySelectorAll(selector);
147
- if (!elements || elements.length == 0)
148
- elements = [element]
149
- for (let el of elements) {
150
- if (!el || el.closest('[template]')) continue
151
- let attribute = el.getAttribute(name)
152
- if (attribute)
153
- data[attribute] = el.getValue()
154
- }
155
-
156
- return dotNotationToObject(data);
157
- },
158
-
159
- setData: function({name, endPoint, data, form}) {
160
- const selector = `[${name}^="${endPoint}."]`
161
- if (!form)
162
- form = document;
163
- let elements = form.querySelectorAll(selector);
164
- if (!elements || elements.length == 0) return
165
-
166
- for (let el of elements) {
167
- let attribute = el.getAttribute(name)
168
- if (attribute) {
169
- if (el.hasAttribute('actions')) continue;
170
- let templateid = el.getAttribute('template_id')
171
- if (templateid) {
172
- let items = document.querySelectorAll(`[templateid="${templateid}"]`)
173
- for (let item of items)
174
- item.remove()
175
- render.data({
176
- selector: `[template="${templateid}"]`,
177
- data
178
- });
179
- } else {
180
- let value = getValueFromObject(data, attribute);
181
- el.setValue(value);
182
- }
183
- }
184
- }
185
-
186
- }
187
-
9
+ const CoCreateApi = {
10
+ components: {},
11
+
12
+ init: function ({ name, endPoints, options }) {
13
+ this.register({ name, endPoints, options });
14
+ if (options.socket !== false && !socket.sockets.size)
15
+ socket.create({ prefix: 'api' });
16
+ },
17
+
18
+ register: function ({ name, endPoints, options }) {
19
+ const self = this;
20
+ if (typeof this.components[name] === 'undefined') {
21
+ this.components[name] = { name, endPoints, options };
22
+
23
+ socket.listen(name, (data) => {
24
+ self.__response(name, data);
25
+ });
26
+
27
+ for (const endPoint of Object.keys(endPoints)) {
28
+ let functions = endPoints[endPoint]
29
+ if (typeof functions.request !== 'function') {
30
+ functions.request = self.__request;
31
+ }
32
+ action.init({
33
+ name: endPoint,
34
+ endEvent: endPoint,
35
+ callback: (data) => {
36
+ let params
37
+ const element = data.element
38
+ let form = element.closest('form') || document
39
+ const selector = `[${name}^="${endPoint}."]`
40
+ let el = form.querySelector(selector)
41
+ if (!el) return
42
+ params = self.parseParams({ name, element: el })
43
+ if (params) {
44
+ functions.request({ name, ...params, element, form, type: 'action' })
45
+ }
46
+ },
47
+ });
48
+ }
49
+
50
+ const inputEvent = (element) => {
51
+ const self = this
52
+ element.addEventListener('input', (e) => {
53
+ if (element.hasAttribute(name)) {
54
+ let params = self.parseParams({ name, element })
55
+ if (params) {
56
+ if (!e.detail || e.detail && e.detail.skip != true) {
57
+ endPoints[params.endPoint].request({ name, ...params, element, type: 'input' })
58
+ }
59
+ }
60
+ }
61
+ });
62
+ }
63
+
64
+ let elements = document.querySelectorAll(`[${name}]`)
65
+ for (let element of elements) {
66
+ let params = this.parseParams({ name, element })
67
+ if (params) {
68
+ endPoints[params.endPoint].request({ name, ...params, element, type: 'onload' })
69
+ inputEvent(element)
70
+ }
71
+ }
72
+
73
+ observer.init({
74
+ name: `${name}NodeObserver`,
75
+ observe: ['addedNodes'],
76
+ target: `[${name}]`,
77
+ callback: function (mutation) {
78
+ let params = self.parseParams({ name, element: mutation.target })
79
+ if (params) {
80
+ endPoints[params.endPoint].request({ name, ...params, element: mutation.target, type: 'nodeObserver' });
81
+ inputEvent(mutation.target)
82
+ }
83
+ }
84
+ });
85
+
86
+ observer.init({
87
+ name: `${name}AttributeObserver`,
88
+ observe: ['attributes'],
89
+ attributeName: [name],
90
+ callback: function (mutation) {
91
+ let params = self.parseParams({ name, element: mutation.target })
92
+ if (params) {
93
+ endPoints[params.endPoint].request({ name, ...params, element: mutation.target, type: 'attributeObserver' });
94
+ }
95
+ }
96
+ });
97
+ }
98
+ },
99
+
100
+ __request: function ({ name, endPoint, element }) {
101
+ let form = element.closest('form');
102
+ let data = this.getData({ name, endPoint, form });
103
+ this.send(name, endPoint, data[endPoint]);
104
+ },
105
+
106
+ __response: function (name, data) {
107
+ const { endPoint, response } = data;
108
+ const component = this.components[name];
109
+ const functions = component.endPoints[endPoint]
110
+ if (functions.listen !== false) {
111
+ if (typeof functions.response === 'function') {
112
+ functions.response(response);
113
+ } else
114
+ this.setData({ name, endPoint, data })
115
+
116
+ document.dispatchEvent(new CustomEvent(endPoint, {
117
+ detail: {
118
+ data: response
119
+ }
120
+ }));
121
+ }
122
+ },
123
+
124
+ send: function (name, endPoint, data) {
125
+ let method = name + '.' + endPoint
126
+ socket.send({ method, endPoint, data, broadcastBrowser: false });
127
+ },
128
+
129
+ parseParams: function ({ name, endPoint, element }) {
130
+ let attribute = element.getAttribute(name)
131
+ if (!attribute)
132
+ return false
133
+
134
+ let dotNotation = attribute
135
+ let params = attribute.split('.')
136
+ endPoint = params[0]
137
+ let key = params[1]
138
+ return { endPoint, key, dotNotation, params }
139
+
140
+ },
141
+
142
+
143
+ getData: function ({ name, endPoint, element, form }) {
144
+ const data = {}
145
+ const selector = `[${name}^="${endPoint}."]`
146
+ let elements
147
+ if (form)
148
+ elements = form.querySelectorAll(selector);
149
+ if (!elements || elements.length == 0)
150
+ elements = [element]
151
+ for (let el of elements) {
152
+ if (!el || el.closest('[template]')) continue
153
+ let attribute = el.getAttribute(name)
154
+ if (attribute)
155
+ data[attribute] = el.getValue()
156
+ }
157
+
158
+ return dotNotationToObject(data);
159
+ },
160
+
161
+ setData: function ({ name, endPoint, data, form }) {
162
+ const selector = `[${name}^="${endPoint}."]`
163
+ if (!form)
164
+ form = document;
165
+ let elements = form.querySelectorAll(selector);
166
+ if (!elements || elements.length == 0) return
167
+
168
+ for (let el of elements) {
169
+ let attribute = el.getAttribute(name)
170
+ if (attribute) {
171
+ if (el.hasAttribute('actions')) continue;
172
+ let templateid = el.getAttribute('template_id')
173
+ if (templateid) {
174
+ let items = document.querySelectorAll(`[templateid="${templateid}"]`)
175
+ for (let item of items)
176
+ item.remove()
177
+ render.data({
178
+ selector: `[template="${templateid}"]`,
179
+ data
180
+ });
181
+ } else {
182
+ let value = getValueFromObject(data, attribute);
183
+ el.setValue(value);
184
+ }
185
+ }
186
+ }
187
+
188
+ }
189
+
188
190
  };
189
-
191
+
190
192
  export default CoCreateApi;
package/src/server.js CHANGED
@@ -26,22 +26,23 @@ var api = (() => {
26
26
  host: config["host"]
27
27
  })
28
28
 
29
- let org = await crud.readDocument({
30
- collection: "organizations",
29
+ let org = await crud.send({
30
+ method: 'read.object',
31
+ array: "organizations",
31
32
  key: config["key"],
32
33
  organization_id: config["organization_id"],
33
- document: {
34
+ object: {
34
35
  _id: config["organization_id"]
35
36
  }
36
37
 
37
38
  });
38
39
 
39
- if (!org || !org.document && !org.document[0]) {
40
+ if (!org || !org.object && !org.object[0]) {
40
41
  console.log(component, " Error GET ORG in : ", e);
41
42
  return false;
42
43
  }
43
44
 
44
- return org.document[0];
45
+ return org.object[0];
45
46
  },
46
47
 
47
48
  getOrgInRoutesbyHostname: async (config, hostname) => {
@@ -60,11 +61,12 @@ var api = (() => {
60
61
  host: socket_config.host
61
62
  })
62
63
 
63
- let data2 = await crud.readDocument({
64
- collection: "organizations",
64
+ let data2 = await crud.send({
65
+ method: 'read.object',
66
+ array: "organizations",
65
67
  filter: {
66
68
  query: [{
67
- name: 'host',
69
+ key: 'host',
68
70
  operator: "$in",
69
71
  value: [hostname]
70
72
  }],
@@ -73,7 +75,7 @@ var api = (() => {
73
75
  organization_id: config["config"]["organization_id"]
74
76
  });
75
77
 
76
- var org = data2.document[0]
78
+ var org = data2.object[0]
77
79
 
78
80
  var socket_config = {
79
81
  "config": {
@@ -91,11 +93,12 @@ var api = (() => {
91
93
  host: socket_config.host
92
94
  })
93
95
 
94
- let myOrg = await crud.readDocument({
95
- collection: "organizations",
96
+ let myOrg = await crud.send({
97
+ method: 'read.object',
98
+ array: "organizations",
96
99
  key: org["key"],
97
100
  organization_id: org["_id"],
98
- document: {
101
+ object: {
99
102
  _id: org["_id"]
100
103
  }
101
104
  });
package/webpack.config.js CHANGED
@@ -1,84 +1,90 @@
1
1
  const path = require("path")
2
2
  const TerserPlugin = require("terser-webpack-plugin")
3
3
  const MiniCssExtractPlugin = require("mini-css-extract-plugin")
4
- let isProduction = process.env.NODE_ENV === "production"
5
4
  const { CleanWebpackPlugin } = require("clean-webpack-plugin")
6
5
 
7
- module.exports = {
8
- entry: {
9
- "CoCreate-api": "./src/index.js",
10
- },
11
- output: {
12
- path: path.resolve(__dirname, "dist"),
13
- filename: isProduction ? "[name].min.js" : "[name].js",
14
- libraryTarget: "umd",
15
- libraryExport: "default",
16
- library: ["CoCreate", "api"],
17
- globalObject: "this",
18
- },
6
+ module.exports = (env, argv) => {
7
+ let isProduction = false
8
+ if (argv.mode === 'production')
9
+ isProduction = true
19
10
 
20
- plugins: [
21
- new CleanWebpackPlugin(),
22
- new MiniCssExtractPlugin({
23
- filename: "[name].css",
24
- }),
25
- ],
26
- // Default mode for Webpack is production.
27
- // Depending on mode Webpack will apply different things
28
- // on final bundle. For now we don't need production's JavaScript
29
- // minifying and other thing so let's set mode to development
30
- mode: isProduction ? "production" : "development",
31
- module: {
32
- rules: [
33
- {
34
- test: /.js$/,
35
- exclude: /(node_modules)/,
36
- use: {
37
- loader: "babel-loader",
38
- options: {
39
- plugins: ["@babel/plugin-transform-modules-commonjs"],
40
- },
11
+ const config = {
12
+ entry: {
13
+ "CoCreate-api": "./src/index.js",
41
14
  },
42
- },
43
- {
44
- test: /.css$/i,
45
- use: [
46
- { loader: "style-loader", options: { injectType: "linkTag" } },
47
- "file-loader",
15
+ output: {
16
+ path: path.resolve(__dirname, "dist"),
17
+ filename: isProduction ? "[name].min.js" : "[name].js",
18
+ libraryTarget: "umd",
19
+ libraryExport: "default",
20
+ library: ["CoCreate", "api"],
21
+ globalObject: "this",
22
+ },
23
+
24
+ plugins: [
25
+ new CleanWebpackPlugin(),
26
+ new MiniCssExtractPlugin({
27
+ filename: "[name].css",
28
+ }),
48
29
  ],
49
- },
50
- ],
51
- },
30
+ // Default mode for Webpack is production.
31
+ // Depending on mode Webpack will apply different things
32
+ // on final bundle. For now we don't need production's JavaScript
33
+ // minifying and other thing so let's set mode to development
34
+ mode: isProduction ? "production" : "development",
35
+ module: {
36
+ rules: [
37
+ {
38
+ test: /.js$/,
39
+ exclude: /(node_modules)/,
40
+ use: {
41
+ loader: "babel-loader",
42
+ options: {
43
+ plugins: ["@babel/plugin-transform-modules-commonjs"],
44
+ },
45
+ },
46
+ },
47
+ {
48
+ test: /.css$/i,
49
+ use: [
50
+ { loader: "style-loader", options: { injectType: "linkTag" } },
51
+ "file-loader",
52
+ ],
53
+ },
54
+ ],
55
+ },
52
56
 
53
- // add source map
54
- ...(isProduction ? {} : { devtool: "eval-source-map" }),
57
+ // add source map
58
+ ...(isProduction ? {} : { devtool: "eval-source-map" }),
55
59
 
56
- optimization: {
57
- minimize: true,
58
- minimizer: [
59
- new TerserPlugin({
60
- extractComments: true,
61
- // cache: true,
62
- parallel: true,
63
- // sourceMap: true, // Must be set to true if using source-maps in production
64
- terserOptions: {
65
- // https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
66
- // extractComments: 'all',
67
- compress: {
68
- drop_console: true,
69
- },
70
- },
71
- }),
72
- ],
73
- splitChunks: {
74
- chunks: "all",
75
- minSize: 200,
76
- // maxSize: 99999,
77
- //minChunks: 1,
60
+ optimization: {
61
+ minimize: true,
62
+ minimizer: [
63
+ new TerserPlugin({
64
+ extractComments: true,
65
+ // cache: true,
66
+ parallel: true,
67
+ // sourceMap: true, // Must be set to true if using source-maps in production
68
+ terserOptions: {
69
+ // https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
70
+ // extractComments: 'all',
71
+ compress: {
72
+ drop_console: true,
73
+ },
74
+ },
75
+ }),
76
+ ],
77
+ splitChunks: {
78
+ chunks: "all",
79
+ minSize: 200,
80
+ // maxSize: 99999,
81
+ //minChunks: 1,
78
82
 
79
- cacheGroups: {
80
- defaultVendors: false,
81
- },
82
- },
83
- },
84
- }
83
+ cacheGroups: {
84
+ defaultVendors: false,
85
+ },
86
+ },
87
+ },
88
+ }
89
+ return config
90
+ }