@cocreate/users 1.22.26 → 1.23.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,28 @@
1
+ # [1.23.0](https://github.com/CoCreate-app/CoCreate-users/compare/v1.22.27...v1.23.0) (2023-08-16)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Change import statements in client.js to use capitalized class names. ([912011b](https://github.com/CoCreate-app/CoCreate-users/commit/912011be5302265af056d775bb5ddd798cb35221))
7
+ * crud attributes renamed ([4be4f0c](https://github.com/CoCreate-app/CoCreate-users/commit/4be4f0cdee84f12e04ba91d2ecfb168c4329bfb0))
8
+ * replace -target -selector ([9cfb2cb](https://github.com/CoCreate-app/CoCreate-users/commit/9cfb2cb22d1814eb8ebf7cc74bcd8b045a917269))
9
+ * updated actions callback data object ([3dd8ed2](https://github.com/CoCreate-app/CoCreate-users/commit/3dd8ed22c595353153362fd9732249ae6f19c2b7))
10
+ * webpack.config and package.json make use of mode=production instead of process.env ([cdf28d5](https://github.com/CoCreate-app/CoCreate-users/commit/cdf28d573c597b7692b1549d47fc676ffefba6a3))
11
+
12
+
13
+ ### Features
14
+
15
+ * name attribute and variable renamed to key ([efbf453](https://github.com/CoCreate-app/CoCreate-users/commit/efbf45327b4c9654951f8d947bdd8d655ed8074d))
16
+ * Update package.json and replace "@cocreate/form" with "@cocreate/elements". ([ec00092](https://github.com/CoCreate-app/CoCreate-users/commit/ec0009228942a5ab10cc74d8152ac89afc62b9dc))
17
+ * update template_id to render-selector attribute. update filter attributes to filter selector-attributes ([c782cf7](https://github.com/CoCreate-app/CoCreate-users/commit/c782cf7941f951dcebb89f44457e2fdbb10a6c17))
18
+
19
+ ## [1.22.27](https://github.com/CoCreate-app/CoCreate-users/compare/v1.22.26...v1.22.27) (2023-06-14)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * Update dependencies versions for [@cocreate](https://github.com/cocreate) libraries ([4253ced](https://github.com/CoCreate-app/CoCreate-users/commit/4253ced4d3e6849ac335a459c9557570bca4e1d9))
25
+
1
26
  ## [1.22.26](https://github.com/CoCreate-app/CoCreate-users/compare/v1.22.25...v1.22.26) (2023-06-11)
2
27
 
3
28
 
@@ -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": "6012f7af86c0ba24512cca2e",
10
10
  "name": "index.html",
11
11
  "path": "/docs/users/index.html",
package/demo/signin.html CHANGED
@@ -11,9 +11,9 @@
11
11
  <link
12
12
  rel="stylesheet"
13
13
  href="../index.css"
14
- collection="files"
15
- document_id="637bc8fe91249e639db315d9"
16
- name="src"
14
+ array="files"
15
+ object="637bc8fe91249e639db315d9"
16
+ key="src"
17
17
  type="text/css" />
18
18
  <link rel="manifest" href="/manifest.webmanifest" />
19
19
  </head>
@@ -35,7 +35,7 @@
35
35
  class="justify-content:center align-items:center overflow:auto display:flex flex-wrap:wrap position:absolute width:100% height:100%">
36
36
  <div
37
37
  class="flex-grow:1 min-width:300px max-width:400px margin:15px">
38
- <form realtime="false" collection="users" id="signin">
38
+ <form realtime="false" array="users" id="signin">
39
39
  <div
40
40
  class="overflow:hidden padding:0px_25px background:white">
41
41
  <div class="float:left width:75% padding-top:25px">
@@ -53,7 +53,7 @@
53
53
  <floating-label>
54
54
  <input
55
55
  type="email"
56
- name="email"
56
+ key="email"
57
57
  placeholder="Email"
58
58
  class="floating-label" />
59
59
  </floating-label>
@@ -61,7 +61,7 @@
61
61
  <floating-label>
62
62
  <input
63
63
  type="password"
64
- name="password"
64
+ key="password"
65
65
  placeholder="Password"
66
66
  class="floating-label" />
67
67
  </floating-label>
@@ -77,7 +77,7 @@
77
77
  </div>
78
78
  </form>
79
79
 
80
- <form collection="users" hidden id="forgotpass">
80
+ <form array="users" hidden id="forgotpass">
81
81
  <div
82
82
  class="overflow:hidden padding:0px_25px background:white">
83
83
  <div class="float:left width:75% padding-top:25px">
@@ -95,7 +95,7 @@
95
95
  <floating-label>
96
96
  <input
97
97
  type="email"
98
- name="email"
98
+ key="email"
99
99
  id="email"
100
100
  placeholder="Email"
101
101
  class="floating-label" />
@@ -112,15 +112,13 @@
112
112
  </div>
113
113
 
114
114
  <div class="position:fixed!important bottom:15px right:15px">
115
- <div
116
- template="signIn"
117
- class="card margin:5px padding:10px {{status}}">
115
+ <div template class="card margin:5px padding:10px {{status}}">
118
116
  <span class="{{type}}">{{message}}</span
119
117
  ><a actions="removeElement"> X</a>
120
118
  </div>
121
119
 
122
120
  <div
123
- template="notification"
121
+ template
124
122
  class="card position:fixed!important bottom:15px right:15px padding:10px {{status}}">
125
123
  <span class="{{type}}">{{message}}</span
126
124
  ><a actions="removeElement"> X</a>
package/demo/signout.html CHANGED
@@ -11,9 +11,9 @@
11
11
  <link
12
12
  rel="stylesheet"
13
13
  href="../index.css"
14
- collection="files"
15
- document_id="637bc8fe91249e639db315d9"
16
- name="src"
14
+ array="files"
15
+ object="637bc8fe91249e639db315d9"
16
+ key="src"
17
17
  type="text/css" />
18
18
  <link rel="manifest" href="/manifest.webmanifest" />
19
19
  </head>
@@ -49,7 +49,7 @@
49
49
 
50
50
  <div class="position:fixed!important bottom:15px right:15px">
51
51
  <div
52
- template="notification"
52
+ template
53
53
  class="card position:fixed!important bottom:15px right:15px padding:10px {{status}}">
54
54
  <span class="{{type}}">{{message}}</span
55
55
  ><a actions="removeElement"> X</a>
package/demo/signup.html CHANGED
@@ -13,9 +13,9 @@
13
13
  <link
14
14
  rel="stylesheet"
15
15
  href="../index.css"
16
- collection="files"
17
- document_id="637bc8fe91249e639db315d9"
18
- name="src"
16
+ array="files"
17
+ object="637bc8fe91249e639db315d9"
18
+ key="src"
19
19
  type="text/css" />
20
20
  <link rel="manifest" href="/manifest.webmanifest" />
21
21
  </head>
@@ -78,9 +78,9 @@
78
78
  <input
79
79
  type="text"
80
80
  id="name"
81
- collection="users"
82
- document_id=""
83
- name="name"
81
+ array="users"
82
+ object=""
83
+ key="name"
84
84
  placeholder="Full Name"
85
85
  class="floating-label"
86
86
  autocomplete="off"
@@ -90,10 +90,10 @@
90
90
  <input
91
91
  type="email"
92
92
  id="email"
93
- collection="users"
93
+ array="users"
94
94
  unique
95
- document_id=""
96
- name="email"
95
+ object=""
96
+ key="email"
97
97
  placeholder="Email"
98
98
  class="floating-label"
99
99
  required />
@@ -104,9 +104,9 @@
104
104
  <input
105
105
  type="password"
106
106
  id="password"
107
- collection="users"
108
- document_id=""
109
- name="password"
107
+ array="users"
108
+ object=""
109
+ key="password"
110
110
  placeholder="Password"
111
111
  class="floating-label" />
112
112
  </floating-label>
@@ -141,16 +141,12 @@
141
141
  </main>
142
142
 
143
143
  <div class="position:fixed!important bottom:15px right:15px">
144
- <div
145
- template="validate"
146
- class="card margin:5px padding:10px {{status}}">
144
+ <div template class="card margin:5px padding:10px {{status}}">
147
145
  <span class="{{type}}">{{message}}</span
148
146
  ><a actions="removeElement"> X</a>
149
147
  </div>
150
148
 
151
- <div
152
- template="notification"
153
- class="card margin:5px padding:10px {{status}}">
149
+ <div template class="card margin:5px padding:10px {{status}}">
154
150
  <span class="{{type}}">{{message}}</span
155
151
  ><a actions="removeElement"> X</a>
156
152
  </div>
package/docs/index.html CHANGED
@@ -11,10 +11,10 @@
11
11
  sizes="32x32"
12
12
  href="https://cocreate.app/images/favicon.ico" />
13
13
  <meta
14
- name="description"
14
+ key="description"
15
15
  content="A simple HTML5 and pure javascript component. Easy configuration using HTML5 attributes or Javscript api and highly styleable." />
16
16
  <meta
17
- name="keywords"
17
+ key="keywords"
18
18
  content="helper classes, utility classes, css framework, css library, inline style classes" />
19
19
  <meta name="robots" content="index,follow" />
20
20
  <meta
@@ -29,9 +29,9 @@
29
29
  <link
30
30
  rel="stylesheet"
31
31
  href="/docs/index.css"
32
- collection="files"
33
- document_id="60888216117c640e7596303f"
34
- name="src"
32
+ array="files"
33
+ object="60888216117c640e7596303f"
34
+ key="src"
35
35
  type="text/css"
36
36
  save="true" />
37
37
  <link rel="manifest" href="/manifest.webmanifest" />
@@ -44,20 +44,20 @@
44
44
  scroll="sticky-nav,hide-nav"
45
45
  scroll-up="10"
46
46
  scroll-down="10"
47
- collection="files"
48
- document_id="60395ef42b3ac232657040fd"
49
- name="src"></nav>
47
+ array="files"
48
+ object="60395ef42b3ac232657040fd"
49
+ key="src"></nav>
50
50
  <sidenav
51
51
  id="menuL"
52
52
  class="position:fixed top:0px left:0px overflow:hidden background:whitesmoke height:100vh width:0px width:300px@xl"
53
53
  resizable
54
- resize-target="[content_id='content']"
54
+ resize-selector="[content_id='content']"
55
55
  resize-property="margin-left"
56
56
  resize-value="width">
57
57
  <menu
58
- collection="files"
59
- document_id="603717b07de7fb350ae9fec8"
60
- name="src"></menu>
58
+ array="files"
59
+ object="603717b07de7fb350ae9fec8"
60
+ key="src"></menu>
61
61
  <div resize="right"></div>
62
62
  </sidenav>
63
63
  <main
@@ -80,7 +80,7 @@
80
80
  share-width="700"
81
81
  share-media="https://cdn.cocreate.app/docs/users.png"
82
82
  hover="display:block!important"
83
- hover-target=".social-networks">
83
+ hover-selector=".social-networks">
84
84
  <div class="display:none social-networks">
85
85
  <a
86
86
  class="margin-right:15px"
@@ -139,11 +139,11 @@
139
139
  class="border-bottom:1px_solid_lightgrey"
140
140
  scroll
141
141
  scroll-intersect="color:dodgerblue"
142
- scroll-target="#users-install-section">
142
+ scroll-selector="#users-install-section">
143
143
  <span
144
144
  class="display:flex align-items:center width:fit-content"
145
145
  hover="display:block!important"
146
- hover-target="[href='#users-install']">
146
+ hover-selector="[href='#users-install']">
147
147
  <h2 class="padding:5px_0px">Install</h2>
148
148
  <a
149
149
  class="margin-left:10px display:none"
@@ -165,11 +165,11 @@
165
165
  class="margin-top:80px border-bottom:1px_solid_lightgrey"
166
166
  scroll
167
167
  scroll-intersect="color:dodgerblue"
168
- scroll-target="#users-usage-section">
168
+ scroll-selector="#users-usage-section">
169
169
  <span
170
170
  class="display:flex align-items:center width:fit-content"
171
171
  hover="display:block!important"
172
- hover-target="[href='#users-usage']">
172
+ hover-selector="[href='#users-usage']">
173
173
  <h2 class="padding:5px_0px">Usage</h2>
174
174
  <a
175
175
  class="margin-left:10px display:none"
@@ -200,11 +200,11 @@
200
200
  class="margin-top:80px border-bottom:1px_solid_lightgrey"
201
201
  scroll
202
202
  scroll-intersect="color:dodgerblue"
203
- scroll-target="#users-attributes-section">
203
+ scroll-selector="#users-attributes-section">
204
204
  <span
205
205
  class="display:flex align-items:center width:fit-content"
206
206
  hover="display:block!important"
207
- hover-target="[href='#users-attributes']">
207
+ hover-selector="[href='#users-attributes']">
208
208
  <h2 class="padding:5px_0px">Attributes</h2>
209
209
  <a
210
210
  class="margin-left:10px display:none"
@@ -253,11 +253,11 @@
253
253
  class="border-bottom:1px_solid_lightgrey"
254
254
  scroll
255
255
  scroll-intersect="color:dodgerblue"
256
- scroll-target="#users-demo-section">
256
+ scroll-selector="#users-demo-section">
257
257
  <span
258
258
  class="display:flex align-items:center width:fit-content"
259
259
  hover="display:block!important"
260
- hover-target="[href='#users-demo']">
260
+ hover-selector="[href='#users-demo']">
261
261
  <h2 class="padding:5px_0px">Demo</h2>
262
262
  <a
263
263
  class="margin-left:10px display:none"
@@ -281,12 +281,12 @@
281
281
  <textarea
282
282
  type="code"
283
283
  lang="html"
284
- collection="demos"
285
- document_id=""
286
- name="demo"
284
+ array="demos"
285
+ object=""
286
+ key="demo"
287
287
  save="false"
288
288
  id="demo"
289
- input-target=".demopreview"
289
+ input-selector=".demopreview"
290
290
  input-attribute="value"
291
291
  input-events="input, onload"
292
292
  class="height:100% width:100% outline:none border:none resize:none padding:5px"></textarea>
@@ -309,7 +309,7 @@
309
309
  show="#eye-slash"
310
310
  hide="#eye, #demo-preview"
311
311
  toggle="code-height"
312
- toggle-target="#demo-code"
312
+ toggle-selector="#demo-code"
313
313
  ><i
314
314
  class="height:18px fill:#505050"
315
315
  src="/assets/svg/eye.svg"></i
@@ -321,7 +321,7 @@
321
321
  show="#eye, #demo-preview"
322
322
  hide="#eye-slash"
323
323
  toggle="code-height"
324
- toggle-target="#demo-code"
324
+ toggle-selector="#demo-code"
325
325
  ><i
326
326
  class="height:20px fill:#505050"
327
327
  src="/assets/svg/eye-slash.svg"></i
@@ -348,7 +348,7 @@
348
348
  <a
349
349
  class="margin-right:5px"
350
350
  fullscreen
351
- fullscreen-target="#playground"></a>
351
+ fullscreen-selector="#playground"></a>
352
352
  </div>
353
353
  </div>
354
354
  <!-- End SandBox -->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/users",
3
- "version": "1.22.26",
3
+ "version": "1.23.0",
4
4
  "description": "A simple users component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "users",
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "scripts": {
27
27
  "start": "npx webpack --config webpack.config.js",
28
- "build": "NODE_ENV=production npx webpack --config webpack.config.js",
28
+ "build": "npx webpack --mode=production --config webpack.config.js",
29
29
  "dev": "npx webpack --config webpack.config.js --watch",
30
30
  "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); } }\""
31
31
  },
@@ -58,12 +58,11 @@
58
58
  "webpack-log": "^3.0.1"
59
59
  },
60
60
  "dependencies": {
61
- "@cocreate/actions": "^1.8.30",
62
- "@cocreate/cli": "^1.33.8",
63
- "@cocreate/crud-client": "^1.21.22",
64
- "@cocreate/element-prototype": "^1.8.28",
65
- "@cocreate/form": "^1.14.28",
66
- "@cocreate/local-storage": "^1.7.19",
67
- "@cocreate/render": "^1.24.30"
61
+ "@cocreate/actions": "^1.8.32",
62
+ "@cocreate/crud-client": "^1.21.24",
63
+ "@cocreate/element-prototype": "^1.8.30",
64
+ "@cocreate/elements": "^1.17.33",
65
+ "@cocreate/local-storage": "^1.7.21",
66
+ "@cocreate/render": "^1.24.32"
68
67
  }
69
68
  }
package/src/client.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /*globals CustomEvent, btoa*/
2
- import crud from '@cocreate/crud-client';
3
- import action from '@cocreate/actions';
4
- import form from '@cocreate/form';
5
- import render from '@cocreate/render';
2
+ import Crud from '@cocreate/crud-client';
3
+ import Action from '@cocreate/actions';
4
+ import Elements from '@cocreate/elements';
5
+ import Render from '@cocreate/render';
6
6
  import '@cocreate/element-prototype';
7
7
  import './index.css';
8
8
  import localStorage from '@cocreate/local-storage';
@@ -15,53 +15,55 @@ const CoCreateUser = {
15
15
 
16
16
  initSocket: function () {
17
17
  const self = this;
18
- crud.listen('updateUserStatus', (data) => self.updateUserStatus(data));
18
+ Crud.listen('updateUserStatus', (data) => self.updateUserStatus(data));
19
19
  },
20
20
 
21
21
  signUp: async function (btn) {
22
22
  let formEl = btn.closest("form");
23
23
  if (!formEl) return;
24
24
 
25
- let organization_id = crud.socket.config.organization_id;
26
- let collection = form.getAttribute('collection')
27
- if (!collection) {
25
+ let organization_id = Crud.socket.config.organization_id;
26
+ let array = formEl.getAttribute('array')
27
+ if (!array) {
28
28
  for (let el of formEl) {
29
- collection = el.getAttribute('collection');
30
- if (collection)
29
+ array = el.getAttribute('array');
30
+ if (array)
31
31
  break;
32
32
  }
33
33
  }
34
34
 
35
- let data = form.getData(formEl, collection)
36
- data['collection'] = collection
35
+ let data = Elements.getFormData(formEl, array)
36
+ data.method = 'create.object'
37
+ data['array'] = array
37
38
  data.organization_id = organization_id;
38
39
 
39
- if (!data.document[0]._id)
40
- data.document[0]._id = crud.ObjectId();
40
+ if (!data.object[0]._id)
41
+ data.object[0]._id = Crud.ObjectId();
41
42
 
42
- let user = await crud.createDocument(data)
43
- form.setDocumentId(formEl, user)
43
+ let user = await Crud.send(data)
44
+ Elements.setTypeValue(formEl, user)
44
45
 
45
- // const socket = crud.socket.getSockets()
46
+ // const socket = Crud.socket.getSockets()
46
47
  // if (!socket[0] || !socket[0].connected || window && !window.navigator.onLine) {
47
48
  let key = {
48
- collection: 'keys',
49
- document: {
49
+ method: 'create.object',
50
+ array: 'keys',
51
+ object: {
50
52
  type: "user",
51
- key: user.document[0]._id,
53
+ key: user.object[0]._id,
52
54
  roles: ['user'],
53
- email: user.document.email,
54
- password: user.document.password || btoa('0000'),
55
- collection
55
+ email: user.object.email,
56
+ password: user.object.password || btoa('0000'),
57
+ array
56
58
  },
57
59
  organization_id
58
60
  }
59
61
 
60
- let response = await crud.createDocument(key)
61
- if (response && response.document && response.document[0]) {
62
- crud.socket.send('signUp', { user, userKey })
62
+ let response = await Crud.send(key)
63
+ if (response && response.object && response.object[0]) {
64
+ Crud.socket.send({ method: 'signUp', user, userKey })
63
65
 
64
- render.data({
66
+ Render.data({
65
67
  selector: "[template='signUp']",
66
68
  data: {
67
69
  type: 'signUp',
@@ -79,44 +81,46 @@ const CoCreateUser = {
79
81
 
80
82
  signIn: function (btn) {
81
83
  let form = btn.closest('form');
82
- let collection = form.getAttribute('collection');
84
+ let array = form.getAttribute('array');
83
85
  let query = [];
84
86
 
85
- const inputs = form.querySelectorAll('input[name="email"], input[name="password"], input[name="username"]');
87
+ const inputs = form.querySelectorAll('input[key="email"], input[key="password"], input[key="username"]');
86
88
 
87
89
  inputs.forEach((input) => {
88
- const name = input.getAttribute('name');
90
+ const key = input.getAttribute('key');
89
91
  const value = input.getValue();
90
- collection = 'keys';
91
- query.push({ name, value, operator: '$eq' })
92
+ array = 'keys';
93
+ query.push({ key, value, operator: '$eq' })
92
94
  });
93
95
 
94
96
  let request = {
97
+ method: 'read.object',
95
98
  db: 'indexeddb',
96
- collection,
99
+ array,
97
100
  filter: {
98
101
  query
99
102
  }
100
103
  }
101
104
 
102
- const socket = crud.socket.getSockets()
103
- if (!socket[0] || !socket[0].connected || window && !window.navigator.onLine || crud.socket.serverOrganization == false) {
104
- crud.readDocument(request).then((response) => {
105
+ const socket = Crud.socket.getSockets()
106
+ if (!socket[0] || !socket[0].connected || window && !window.navigator.onLine || Crud.socket.serverOrganization == false) {
107
+ Crud.send(request).then((response) => {
105
108
  response['success'] = false
106
109
  response['status'] = "signIn failed"
107
- if (response.document && response.document[0]) {
110
+ if (response.object && response.object[0]) {
108
111
  response['success'] = true
109
112
  response['status'] = "success"
110
- response['user_id'] = response.document[0].key
113
+ response['user_id'] = response.object[0].key
111
114
  this.signInResponse(response)
112
115
  } else {
113
116
  this.signInResponse(response)
114
117
  }
115
118
  })
116
119
  } else {
120
+ request.method = 'signIn'
117
121
  request.broadcastBrowser = false
118
122
  delete request.storage
119
- crud.socket.send('signIn', request).then((response) => {
123
+ Crud.socket.send(request).then((response) => {
120
124
  this.signInResponse(response)
121
125
  })
122
126
  }
@@ -126,9 +130,9 @@ const CoCreateUser = {
126
130
  let { success, status, message, user_id, token } = data;
127
131
 
128
132
  if (success) {
129
- localStorage.setItem('organization_id', crud.socket.config.organization_id);
130
- localStorage.setItem("key", crud.socket.config.key);
131
- localStorage.setItem("host", crud.socket.config.host);
133
+ localStorage.setItem('organization_id', Crud.socket.config.organization_id);
134
+ localStorage.setItem("key", Crud.socket.config.key);
135
+ localStorage.setItem("host", Crud.socket.config.host);
132
136
  localStorage.setItem('user_id', user_id);
133
137
  localStorage.setItem("token", token);
134
138
  // document.cookie = `token=${token};path=/`;
@@ -140,7 +144,7 @@ const CoCreateUser = {
140
144
  else
141
145
  message = "The email or password you entered is incorrect";
142
146
 
143
- render.data({
147
+ Render.data({
144
148
  selector: "[template='signIn']",
145
149
  data: {
146
150
  type: 'signIn',
@@ -162,7 +166,7 @@ const CoCreateUser = {
162
166
  // document.cookie = allCookies[i] + "=;expires=" +
163
167
  // new Date(0).toUTCString();
164
168
 
165
- render.data({
169
+ Render.data({
166
170
  selector: "[template='signOut']",
167
171
  data: {
168
172
  type: 'signOut',
@@ -178,7 +182,7 @@ const CoCreateUser = {
178
182
  updateUserStatus: function (data) {
179
183
  this.redirect(data)
180
184
  if (data.user_id) {
181
- let statusEls = document.querySelectorAll(`[user-status][document_id='${data['user_id']}']`);
185
+ let statusEls = document.querySelectorAll(`[user-status][object='${data['user_id']}']`);
182
186
 
183
187
  statusEls.forEach((el) => {
184
188
  el.setAttribute('user-status', data['userStatus']);
@@ -188,9 +192,9 @@ const CoCreateUser = {
188
192
  },
189
193
 
190
194
  redirect: (data) => {
191
- if (data.user_id && data.user_id !== crud.socket.config.user_id)
195
+ if (data.user_id && data.user_id !== Crud.socket.config.user_id)
192
196
  return
193
- if (!data.user_id && data.clientId !== crud.socket.clientId)
197
+ if (!data.user_id && data.clientId !== Crud.socket.clientId)
194
198
  return
195
199
  if (data.userStatus == 'on' || data.userStatus == 'idle') {
196
200
  let redirectTag = document.querySelector('[session="true"]');
@@ -222,7 +226,8 @@ const CoCreateUser = {
222
226
  let redirectTag = document.querySelector('[session]');
223
227
 
224
228
  if (redirectTag) {
225
- crud.socket.send('sendMessage', {
229
+ Crud.socket.send({
230
+ method: 'sendMessage',
226
231
  message: 'checkSession',
227
232
  broadcast: false,
228
233
  broadcastSender: false,
@@ -239,27 +244,27 @@ const CoCreateUser = {
239
244
  };
240
245
 
241
246
 
242
- action.init({
247
+ Action.init({
243
248
  name: "signUp",
244
249
  endEvent: "signUp",
245
- callback: (btn, data) => {
246
- CoCreateUser.signUp(btn);
250
+ callback: (data) => {
251
+ CoCreateUser.signUp(data.element);
247
252
  },
248
253
  });
249
254
 
250
- action.init({
255
+ Action.init({
251
256
  name: "signIn",
252
257
  endEvent: "signIn",
253
- callback: (btn, data) => {
254
- CoCreateUser.signIn(btn, data);
258
+ callback: (data) => {
259
+ CoCreateUser.signIn(data.element);
255
260
  },
256
261
  });
257
262
 
258
- action.init({
263
+ Action.init({
259
264
  name: "signOut",
260
265
  endEvent: "signOut",
261
- callback: (btn, data) => {
262
- CoCreateUser.signOut(btn, data);
266
+ callback: (data) => {
267
+ CoCreateUser.signOut(data.element);
263
268
  },
264
269
  });
265
270
 
package/src/server.js CHANGED
@@ -18,19 +18,21 @@ class CoCreateUser {
18
18
  try {
19
19
 
20
20
  if (data.user) {
21
- const response = await this.crud.createDocument(data.user)
22
- this.wsManager.broadcast(socket, 'createDocument', response);
21
+ data.user.method = 'create.object'
22
+ const response = await this.crud.send(data.user)
23
+ this.wsManager.broadcast(socket, response);
23
24
  }
24
25
 
25
26
  if (data.userKey) {
26
- const response = await this.crud.createDocument(data.userKey)
27
- this.wsManager.broadcast(socket, 'createDocument', response);
27
+ data.userKey.method = 'create.object'
28
+ const response = await this.crud.send(data.userKey)
29
+ this.wsManager.broadcast(socket, response);
28
30
  }
29
31
 
30
- self.wsManager.send(socket, 'signUp', data);
32
+ self.wsManager.send(socket, data);
31
33
 
32
34
  } catch (error) {
33
- console.log('createDocument error', error);
35
+ console.log('create.object error', error);
34
36
  }
35
37
  }
36
38
 
@@ -38,7 +40,7 @@ class CoCreateUser {
38
40
  /**
39
41
  data = {
40
42
  namespace: string,
41
- collection: string,
43
+ array: string,
42
44
  data: object,
43
45
  eId: string,
44
46
  key: string,
@@ -48,8 +50,10 @@ class CoCreateUser {
48
50
  async signIn(socket, data) {
49
51
  const self = this;
50
52
  try {
51
- this.crud.readDocument(data).then(async (data) => {
53
+ data.method = 'read.object'
54
+ this.crud.send(data).then(async (data) => {
52
55
  let response = {
56
+ method: 'signIn',
53
57
  success: false,
54
58
  message: "signIn failed",
55
59
  status: "failed",
@@ -57,8 +61,8 @@ class CoCreateUser {
57
61
  uid: data.uid
58
62
  }
59
63
 
60
- if (data.document[0] && data.document[0]._id && self.wsManager.authenticate) {
61
- const user_id = data.document[0].key
64
+ if (data.object[0] && data.object[0]._id && self.wsManager.authenticate) {
65
+ const user_id = data.object[0].key
62
66
  const token = await self.wsManager.authenticate.generateToken({ user_id });
63
67
 
64
68
  if (token && token != 'null') {
@@ -74,15 +78,16 @@ class CoCreateUser {
74
78
 
75
79
  // if (data.organization_id != process.env.organization_id) {
76
80
  // let Data = { organization_id: process.env.organization_id }
77
- // Data.document['_id'] = data.document[0]._id
78
- // Data.document['lastsignIn'] = data.document[0].lastsignIn
79
- // Data.document['organization_id'] = process.env.organization_id
80
- // crud.updateDocument(Data)
81
+ // Data.object['_id'] = data.object[0]._id
82
+ // Data.object['lastsignIn'] = data.object[0].lastsignIn
83
+ // Data.object['organization_id'] = process.env.organization_id
84
+ // crud.send(Data)
81
85
  // }
82
86
  }
83
87
  }
84
- self.wsManager.send(socket, 'signIn', response)
85
- self.wsManager.broadcast(socket, 'updateUserStatus', {
88
+ self.wsManager.send(socket, response)
89
+ self.wsManager.broadcast(socket, {
90
+ method: 'updateUserStatus',
86
91
  user_id: response.user_id,
87
92
  userStatus: response.userStatus,
88
93
  organization_id: response.organization_id
@@ -103,15 +108,16 @@ class CoCreateUser {
103
108
  try {
104
109
  if (!data.user_id || !data.userStatus)
105
110
  return
106
- data.collection = 'users'
107
- data['document'] = {
111
+ data.array = 'users'
112
+ data['object'] = {
108
113
  _id: data.user_id,
109
114
  userStatus: data.userStatus
110
115
  }
111
116
 
112
- this.crud.updateDocument(data).then((data) => {
113
- // self.wsManager.broadcast(socket, 'updateUserStatus', data)
114
- self.wsManager.broadcast(socket, 'updateUserStatus', {
117
+ data.method = 'update.object'
118
+ this.crud.send(data).then((data) => {
119
+ self.wsManager.broadcast(socket, {
120
+ method: 'updateUserStatus',
115
121
  user_id: data.user_id,
116
122
  userStatus: data.userStatus,
117
123
  organization_id: data.organization_id || socket.config.organization_id
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-users": "./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", "users"],
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-users": "./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", "users"],
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
+ }