@cocreate/crud-server 1.26.0 → 1.27.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/.github/workflows/automated.yml +70 -83
- package/CHANGELOG.md +14 -0
- package/docs/index.html +1 -7
- package/package.json +1 -1
- package/src/index.js +29 -23
|
@@ -1,83 +1,70 @@
|
|
|
1
|
-
name: Automated
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
jobs:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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,17 @@
|
|
|
1
|
+
# [1.27.0](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.26.0...v1.27.0) (2023-08-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* /dist/CoCreate.js updated to https://CoCreate.app/dist/CoCreate.js ([1f82f69](https://github.com/CoCreate-app/CoCreate-crud-server/commit/1f82f6921aa6dc39410263eea7e4ee4b535d7039))
|
|
7
|
+
* replace cdn with /dist ([7ad2004](https://github.com/CoCreate-app/CoCreate-crud-server/commit/7ad20046820f19a12917edd13b379da652ac391b))
|
|
8
|
+
* update file uploader ([f6000d9](https://github.com/CoCreate-app/CoCreate-crud-server/commit/f6000d9e0ed2569d35d8cd7f81b7dece04446c25))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* handling stats from multiple storages. ([5d06d16](https://github.com/CoCreate-app/CoCreate-crud-server/commit/5d06d169ce12ed4000e529f54fc3404380997f57))
|
|
14
|
+
|
|
1
15
|
# [1.26.0](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.25.0...v1.26.0) (2023-08-17)
|
|
2
16
|
|
|
3
17
|
|
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://
|
|
221
|
+
<script src="https://CoCreate.app/dist/CoCreate.js"></script>
|
|
228
222
|
</body>
|
|
229
223
|
</html>
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -27,19 +27,19 @@ class CoCreateCrudServer {
|
|
|
27
27
|
}
|
|
28
28
|
})
|
|
29
29
|
|
|
30
|
-
let
|
|
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
|
-
|
|
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 (!
|
|
40
|
+
if (!storageUrl)
|
|
41
41
|
console.log('Could not find a url in your storage object')
|
|
42
|
-
if (!
|
|
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
|
|
86
|
-
if (
|
|
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 (!
|
|
89
|
+
if (!storages) {
|
|
90
90
|
if (data.organization_id === this.config.organization_id) {
|
|
91
|
-
|
|
92
|
-
if (
|
|
93
|
-
this.storages.set(data.organization_id,
|
|
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
|
-
|
|
106
|
-
this.storages.set(data.organization_id,
|
|
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(
|
|
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 (
|
|
166
|
-
let
|
|
167
|
-
|
|
168
|
-
if (
|
|
169
|
-
if (!Array.isArray(
|
|
170
|
-
|
|
171
|
-
for (let i = 0; i <
|
|
172
|
-
data['
|
|
173
|
-
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.
|
|
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({
|