@cocreate/crud-server 1.26.0 → 1.28.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.
@@ -1,83 +1,70 @@
1
- name: Automated Deployment
2
- "on":
3
- push:
4
- branches:
5
- - master
6
- jobs:
7
- about:
8
- runs-on: ubuntu-latest
9
- steps:
10
- - name: Checkout
11
- uses: actions/checkout@v3
12
- - name: setup nodejs
13
- uses: actions/setup-node@v3
14
- with:
15
- node-version: 16
16
- - name: Jaid/action-sync-node-meta
17
- uses: jaid/action-sync-node-meta@v1.4.0
18
- with:
19
- direction: overwrite-github
20
- githubToken: "${{ secrets.GITHUB }}"
21
- release:
22
- runs-on: ubuntu-latest
23
- steps:
24
- - name: Checkout
25
- uses: actions/checkout@v3
26
- - name: setup nodejs
27
- uses: actions/setup-node@v3
28
- with:
29
- node-version: 14
30
- - name: Semantic Release
31
- uses: cycjimmy/semantic-release-action@v3
32
- id: semantic
33
- with:
34
- extra_plugins: |
35
- @semantic-release/changelog
36
- @semantic-release/git
37
- @semantic-release/github
38
- env:
39
- GITHUB_TOKEN: "${{ secrets.GITHUB }}"
40
- NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
41
- outputs:
42
- new_release_published: "${{ steps.semantic.outputs.new_release_published }}"
43
- new_release_version: "${{ steps.semantic.outputs.new_release_version }}"
44
-
45
- upload:
46
- runs-on: ubuntu-latest
47
-
48
- steps:
49
- - name: Checkout
50
- uses: actions/checkout@v3
51
-
52
- - name: Setup Node.js
53
- uses: actions/setup-node@v3
54
- with:
55
- node-version: 16
56
-
57
- - name: Get Environment Variables
58
- run: |
59
- echo "organization_id=${{ secrets.COCREATE_ORGANIZATION_ID }}" >> $GITHUB_ENV
60
- echo "key=${{ secrets.COCREATE_KEY }}" >> $GITHUB_ENV
61
- echo "host=${{ secrets.COCREATE_HOST }}" >> $GITHUB_ENV
62
-
63
- - name: Install @cocreate/cli
64
- run: npm install -g @cocreate/cli
65
-
66
- - name: CoCreate CLI Upload
67
- run: coc upload
68
-
69
- # docs:
70
- # runs-on: ubuntu-latest
71
- # steps:
72
- # - name: Checkout
73
- # uses: actions/checkout@v3
74
- # - name: setup nodejs
75
- # uses: actions/setup-node@v3
76
- # with:
77
- # node-version: 16
78
- # - name: update documentation
79
- # uses: CoCreate-app/CoCreate-docs@master
80
- # env:
81
- # organization_id: ${{ secrets.COCREATE_ORGANIZATION_ID }}
82
- # key: ${{ secrets.COCREATE_KEY }}
83
- # host: ${{ secrets.COCREATE_HOST }}
1
+ name: Automated Workflow
2
+ on:
3
+ push:
4
+ branches:
5
+ - master
6
+ jobs:
7
+ about:
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - name: Checkout
11
+ uses: actions/checkout@v3
12
+ - name: Setup Node.js
13
+ uses: actions/setup-node@v3
14
+ with:
15
+ node-version: 16
16
+ - name: Jaid/action-sync-node-meta
17
+ uses: jaid/action-sync-node-meta@v1.4.0
18
+ with:
19
+ direction: overwrite-github
20
+ githubToken: "${{ secrets.GITHUB }}"
21
+ release:
22
+ runs-on: ubuntu-latest
23
+ steps:
24
+ - name: Checkout
25
+ uses: actions/checkout@v3
26
+ - name: Setup Node.js
27
+ uses: actions/setup-node@v3
28
+ with:
29
+ node-version: 14
30
+ - name: Semantic Release
31
+ uses: cycjimmy/semantic-release-action@v3
32
+ id: semantic
33
+ with:
34
+ extra_plugins: |
35
+ @semantic-release/changelog
36
+ @semantic-release/git
37
+ @semantic-release/github
38
+ env:
39
+ GITHUB_TOKEN: "${{ secrets.GITHUB }}"
40
+ NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
41
+ outputs:
42
+ new_release_published: "${{ steps.semantic.outputs.new_release_published }}"
43
+ new_release_version: "${{ steps.semantic.outputs.new_release_version }}"
44
+ upload:
45
+ runs-on: ubuntu-latest
46
+ needs: release
47
+ if: needs.release.outputs.new_release_published == 'true'
48
+ env:
49
+ VERSION: "${{ needs.release.outputs.new_release_version }}"
50
+ steps:
51
+ - name: Checkout
52
+ uses: actions/checkout@v3
53
+ - name: Setup Node.js
54
+ uses: actions/setup-node@v3
55
+ with:
56
+ node-version: 16
57
+ - name: Set npm registry auth
58
+ run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
59
+ - name: Install dependencies
60
+ run: yarn install
61
+ - name: Build
62
+ run: yarn build
63
+ - name: Set Environment Variables
64
+ run: |
65
+ echo "organization_id=${{ secrets.COCREATE_ORGANIZATION_ID }}" >> $GITHUB_ENV
66
+ echo "key=${{ secrets.COCREATE_KEY }}" >> $GITHUB_ENV
67
+ echo "host=${{ secrets.COCREATE_HOST }}" >> $GITHUB_ENV
68
+ - name: CoCreate Upload
69
+ run: coc upload
70
+
package/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ # [1.28.0](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.27.0...v1.28.0) (2023-08-21)
2
+
3
+
4
+ ### Features
5
+
6
+ * Update cocreate dependencies for the latest features and bug fixes ([2bd1716](https://github.com/CoCreate-app/CoCreate-crud-server/commit/2bd171618046d5e31f74442b45cc381278228096))
7
+
8
+ # [1.27.0](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.26.0...v1.27.0) (2023-08-21)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * /dist/CoCreate.js updated to https://CoCreate.app/dist/CoCreate.js ([1f82f69](https://github.com/CoCreate-app/CoCreate-crud-server/commit/1f82f6921aa6dc39410263eea7e4ee4b535d7039))
14
+ * replace cdn with /dist ([7ad2004](https://github.com/CoCreate-app/CoCreate-crud-server/commit/7ad20046820f19a12917edd13b379da652ac391b))
15
+ * update file uploader ([f6000d9](https://github.com/CoCreate-app/CoCreate-crud-server/commit/f6000d9e0ed2569d35d8cd7f81b7dece04446c25))
16
+
17
+
18
+ ### Features
19
+
20
+ * handling stats from multiple storages. ([5d06d16](https://github.com/CoCreate-app/CoCreate-crud-server/commit/5d06d169ce12ed4000e529f54fc3404380997f57))
21
+
1
22
  # [1.26.0](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.25.0...v1.26.0) (2023-08-17)
2
23
 
3
24
 
package/docs/index.html CHANGED
@@ -216,14 +216,8 @@
216
216
  </div>
217
217
  </div>
218
218
  </div>
219
- <script>
220
- var CoCreateConfig = {
221
- key: "2061acef-0451-4545-f754-60cf8160",
222
- organization_id: "5ff747727005da1c272740ab",
223
- };
224
- </script>
225
219
 
226
220
  <!--CoCreateJS-->
227
- <script src="https://cdn.cocreate.app/latest/CoCreate.min.js"></script>
221
+ <script src="https://CoCreate.app/dist/CoCreate.js"></script>
228
222
  </body>
229
223
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/crud-server",
3
- "version": "1.26.0",
3
+ "version": "1.28.0",
4
4
  "description": "CoCreate-crud-server",
5
5
  "keywords": [
6
6
  "cocreate-crud",
@@ -40,8 +40,8 @@
40
40
  },
41
41
  "homepage": "https://cocreate.app/docs/CoCreate-crud-server",
42
42
  "dependencies": {
43
- "@cocreate/config": "^1.2.0",
44
- "@cocreate/utils": "^1.22.0",
43
+ "@cocreate/config": "^1.4.0",
44
+ "@cocreate/utils": "^1.23.1",
45
45
  "csvtojson": "^2.0.10",
46
46
  "json-2-csv": "^3.10.3"
47
47
  }
package/src/index.js CHANGED
@@ -27,19 +27,19 @@ class CoCreateCrudServer {
27
27
  }
28
28
  })
29
29
 
30
- let dbUrl
30
+ let storageUrl
31
31
  if (this.config.storage) {
32
32
  if (typeof this.config.storage === 'string')
33
33
  this.config.storage = JSON.parse(this.config.storage)
34
34
  let defaultStorage = Object.keys(this.config.storage)
35
- dbUrl = this.config.storage[defaultStorage[0]].url
35
+ storageUrl = this.config.storage[defaultStorage[0]].url
36
36
  }
37
37
 
38
38
  if (!this.config.organization_id)
39
39
  console.log('Could not find the organization_id')
40
- if (!dbUrl)
40
+ if (!storageUrl)
41
41
  console.log('Could not find a url in your storage object')
42
- if (!dbUrl && !this.config.organization_id)
42
+ if (!storageUrl && !this.config.organization_id)
43
43
  process.exit()
44
44
 
45
45
  if (this.wsManager) {
@@ -82,15 +82,15 @@ class CoCreateCrudServer {
82
82
 
83
83
 
84
84
 
85
- let storage = this.storages.get(data.organization_id)
86
- if (storage === false)
85
+ let storages = this.storages.get(data.organization_id)
86
+ if (storages === false)
87
87
  return resolve({ storage: false, error: 'A storage or database could not be found' })
88
88
 
89
- if (!storage) {
89
+ if (!storages) {
90
90
  if (data.organization_id === this.config.organization_id) {
91
- storage = this.config.storage
92
- if (storage)
93
- this.storages.set(data.organization_id, storage)
91
+ storages = this.config.storage
92
+ if (storages)
93
+ this.storages.set(data.organization_id, storages)
94
94
  } else {
95
95
  let organization = await this.send({
96
96
  method: 'read.object',
@@ -102,8 +102,8 @@ class CoCreateCrudServer {
102
102
  if (organization && organization.object && organization.object[0])
103
103
  organization = organization.object[0]
104
104
  if (organization && organization.storage) {
105
- storage = organization.storage
106
- this.storages.set(data.organization_id, storage)
105
+ storages = organization.storage
106
+ this.storages.set(data.organization_id, storages)
107
107
  } else {
108
108
  this.storages.set(data.organization_id, false)
109
109
  if (organization)
@@ -117,6 +117,7 @@ class CoCreateCrudServer {
117
117
  if (!data['timeStamp'])
118
118
  data['timeStamp'] = new Date().toISOString()
119
119
 
120
+ // TODO: manage error handling if if no method defined
120
121
  if (data.method.startsWith('update') && data.upsert != false)
121
122
  data.upsert = true
122
123
 
@@ -157,23 +158,26 @@ class CoCreateCrudServer {
157
158
  }
158
159
 
159
160
  if (!data.storage || !data.storage.length) {
160
- data.storage = [Object.keys(storage)[0]]
161
+ data.storage = [Object.keys(storages)[0]]
161
162
  } else if (!Array.isArray(data.storage))
162
163
  data.storage = [data.storage]
163
164
 
164
165
  for (let i = 0; i < data.storage.length; i++) {
165
- if (storage && storage[data.storage[i]]) {
166
- let db = storage[data.storage[i]]
167
-
168
- if (db.provider && this.databases[db.provider]) {
169
- if (!Array.isArray(db.url))
170
- db.url = [db.url]
171
- for (let i = 0; i < db.url.length; i++) {
172
- data['dbUrl'] = db.url[i]
173
- data = await this.databases[db.provider][action](data)
166
+ if (storages && storages[data.storage[i]]) {
167
+ let storage = storages[data.storage[i]]
168
+
169
+ if (storage.provider && this.databases[storage.provider]) {
170
+ if (!Array.isArray(storage.url))
171
+ storage.url = [storage.url]
172
+ for (let i = 0; i < storage.url.length; i++) {
173
+ data['storageName'] = data.storage[i]
174
+ data['storageUrl'] = storage.url[i]
175
+ data = await this.databases[storage.provider][action](data)
174
176
  }
175
177
 
176
178
  if (data.filter) {
179
+ if (!data.type)
180
+ data.type = data.method.split('.').pop()
177
181
  if (data.filter.sort && data.filter.sort.length)
178
182
  data[data.type] = sortData(array, data.filter.sort)
179
183
  if (data.filter.index && data.filter.limit) {
@@ -186,7 +190,9 @@ class CoCreateCrudServer {
186
190
  }
187
191
  }
188
192
 
189
- delete data.dbUrl
193
+ delete data.storageUrl
194
+ delete data.storageName
195
+
190
196
  if (socket) {
191
197
  if (data.organization_id === this.config.organization_id && socket.config.organization_id !== data.organization_id) {
192
198
  this.wsManager.broadcast({