@cocreate/mongodb 1.6.2 → 1.6.3
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 +11 -0
- package/demo/index.html +15 -17
- package/docs/index.html +1 -7
- package/package.json +1 -1
- package/src/index.js +27 -22
|
@@ -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,14 @@
|
|
|
1
|
+
## [1.6.3](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.6.2...v1.6.3) (2023-08-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* /dist/CoCreate.js updated to https://CoCreate.app/dist/CoCreate.js ([553bfe6](https://github.com/CoCreate-app/CoCreate-mongodb/commit/553bfe6036c0f7705e7f993f7e65b9adb625f66f))
|
|
7
|
+
* document to object ([1780f64](https://github.com/CoCreate-app/CoCreate-mongodb/commit/1780f6452ae3ba9f4eb3e4876b77695269cb1428))
|
|
8
|
+
* renamed dbUrl to storageUrl and add storage name to responses ([ace186f](https://github.com/CoCreate-app/CoCreate-mongodb/commit/ace186f252d624ab4535d81817a0262f112c699b))
|
|
9
|
+
* replace cdn with /dist ([a4d3773](https://github.com/CoCreate-app/CoCreate-mongodb/commit/a4d377343b646154902ce07799a890d7e31857e1))
|
|
10
|
+
* update file uploader ([e6e1dbe](https://github.com/CoCreate-app/CoCreate-mongodb/commit/e6e1dbe31990e7e6cbfa94d4faf62cacbdf289c3))
|
|
11
|
+
|
|
1
12
|
## [1.6.2](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.6.1...v1.6.2) (2023-08-18)
|
|
2
13
|
|
|
3
14
|
|
package/demo/index.html
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
+
<link
|
|
8
|
+
rel="icon"
|
|
9
|
+
href="https://cdn.cocreate.app/favicon.ico"
|
|
10
|
+
type="image/ico"
|
|
11
|
+
sizes="16x16" />
|
|
12
|
+
<title>mongodb | CoCreateJS</title>
|
|
13
|
+
</head>
|
|
3
14
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
<link rel="icon" href="https://cdn.cocreate.app/favicon.ico" type="image/ico" sizes="16x16">
|
|
9
|
-
<title>mongodb | CoCreateJS</title>
|
|
10
|
-
</head>
|
|
11
|
-
|
|
12
|
-
<body>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<!--<script src="https://cdn.cocreate.app/mongodb/latest/CoCreate-mongodb.min.js"></script>-->
|
|
17
|
-
<script src="https://cdn.cocreate.app/latest/CoCreate.min.js"></script>
|
|
18
|
-
|
|
19
|
-
</body>
|
|
20
|
-
|
|
15
|
+
<body>
|
|
16
|
+
<!--<script src="https://cdn.cocreate.app/mongodb/latest/CoCreate-mongodb.min.js"></script>-->
|
|
17
|
+
<script src="https://CoCreate.app/dist/CoCreate.js"></script>
|
|
18
|
+
</body>
|
|
21
19
|
</html>
|
package/docs/index.html
CHANGED
|
@@ -225,14 +225,8 @@
|
|
|
225
225
|
</div>
|
|
226
226
|
</div>
|
|
227
227
|
</div>
|
|
228
|
-
<script>
|
|
229
|
-
var CoCreateConfig = {
|
|
230
|
-
key: "2061acef-0451-4545-f754-60cf8160",
|
|
231
|
-
organization_id: "5ff747727005da1c272740ab",
|
|
232
|
-
};
|
|
233
|
-
</script>
|
|
234
228
|
|
|
235
229
|
<!--CoCreateJS-->
|
|
236
|
-
<script src="https://
|
|
230
|
+
<script src="https://CoCreate.app/dist/CoCreate.js"></script>
|
|
237
231
|
</body>
|
|
238
232
|
</html>
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -4,12 +4,12 @@ const clients = new Map()
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
async function dbClient(data) {
|
|
7
|
-
if (data.
|
|
8
|
-
let client = clients.get(data.
|
|
7
|
+
if (data.storageUrl) {
|
|
8
|
+
let client = clients.get(data.storageUrl)
|
|
9
9
|
if (!client) {
|
|
10
10
|
try {
|
|
11
|
-
client = MongoClient.connect(data.
|
|
12
|
-
clients.set(data.
|
|
11
|
+
client = MongoClient.connect(data.storageUrl, { useNewUrlParser: true, useUnifiedTopology: true });
|
|
12
|
+
clients.set(data.storageUrl, client)
|
|
13
13
|
} catch (error) {
|
|
14
14
|
console.error(error)
|
|
15
15
|
return { status: false }
|
|
@@ -23,9 +23,14 @@ async function dbClient(data) {
|
|
|
23
23
|
async function databaseStats(data) {
|
|
24
24
|
const client = await dbClient(data)
|
|
25
25
|
if (!client) return
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
const db = client.db(data.organization_id)
|
|
27
|
+
const stats = await db.stats()
|
|
28
|
+
stats.storage = data.storageName
|
|
29
|
+
if (!data.stats)
|
|
30
|
+
data.stats = [stats]
|
|
31
|
+
else
|
|
32
|
+
data.stats.push(stats)
|
|
33
|
+
return data
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
function createDatabase(data) {
|
|
@@ -62,9 +67,9 @@ function database(action, data) {
|
|
|
62
67
|
if (data.filter && data.filter.query) {
|
|
63
68
|
let isFilter = queryData(database, data.filter.query)
|
|
64
69
|
if (isFilter)
|
|
65
|
-
databaseArray.push({ database,
|
|
70
|
+
databaseArray.push({ database, storage: data.storageName })
|
|
66
71
|
} else
|
|
67
|
-
databaseArray.push({ database,
|
|
72
|
+
databaseArray.push({ database, storage: data.storageName })
|
|
68
73
|
}
|
|
69
74
|
|
|
70
75
|
resolve(createData(data, databaseArray, type))
|
|
@@ -137,9 +142,9 @@ function array(action, data) {
|
|
|
137
142
|
if (data.filter && data.filter.query) {
|
|
138
143
|
let isFilter = queryData(res, data.filter.query)
|
|
139
144
|
if (isFilter)
|
|
140
|
-
arrayArray.push({ name: res.name, database,
|
|
145
|
+
arrayArray.push({ name: res.name, database, storage: data.storageName })
|
|
141
146
|
} else
|
|
142
|
-
arrayArray.push({ name: res.name, database,
|
|
147
|
+
arrayArray.push({ name: res.name, database, storage: data.storageName })
|
|
143
148
|
}
|
|
144
149
|
}
|
|
145
150
|
|
|
@@ -169,7 +174,7 @@ function array(action, data) {
|
|
|
169
174
|
errorHandler(data, error, database, array)
|
|
170
175
|
|
|
171
176
|
if (result)
|
|
172
|
-
arrayArray.push({ name: array, database,
|
|
177
|
+
arrayArray.push({ name: array, database, storage: data.storageName })
|
|
173
178
|
|
|
174
179
|
arraysLength -= 1
|
|
175
180
|
if (!arraysLength)
|
|
@@ -193,7 +198,7 @@ function array(action, data) {
|
|
|
193
198
|
errorHandler(data, error, database, array)
|
|
194
199
|
|
|
195
200
|
if (result)
|
|
196
|
-
arrayArray.push({ name: value, oldName: array, database,
|
|
201
|
+
arrayArray.push({ name: value, oldName: array, database, storage: data.storageName })
|
|
197
202
|
|
|
198
203
|
arraysLength -= 1
|
|
199
204
|
if (!arraysLength)
|
|
@@ -213,7 +218,7 @@ function array(action, data) {
|
|
|
213
218
|
errorHandler(data, error, database, array)
|
|
214
219
|
|
|
215
220
|
if (result)
|
|
216
|
-
arrayArray.push({ name: array, database,
|
|
221
|
+
arrayArray.push({ name: array, database, storage: data.storageName })
|
|
217
222
|
|
|
218
223
|
arraysLength -= 1
|
|
219
224
|
if (!arraysLength)
|
|
@@ -330,7 +335,7 @@ function object(action, data) {
|
|
|
330
335
|
update_ids.push({ _id: data[type][i]._id, updateDoc: data[type][i], updateType: '_id' })
|
|
331
336
|
|
|
332
337
|
if (!data[type][i]._id)
|
|
333
|
-
updateData = createUpdate({
|
|
338
|
+
updateData = createUpdate({ object: [data[type][i]] }, type)
|
|
334
339
|
|
|
335
340
|
data[type][i]['modified'] = { on: data.timeStamp, by: data.user_id || data.clientId }
|
|
336
341
|
|
|
@@ -338,7 +343,7 @@ function object(action, data) {
|
|
|
338
343
|
if (action == 'deleteObject') {
|
|
339
344
|
if (data[type][i]._id) {
|
|
340
345
|
_ids.push(ObjectId(data[type][i]._id))
|
|
341
|
-
documents.push({ _id: data[type][i]._id,
|
|
346
|
+
documents.push({ _id: data[type][i]._id, storage: data.storageName, database, array })
|
|
342
347
|
}
|
|
343
348
|
}
|
|
344
349
|
}
|
|
@@ -355,7 +360,7 @@ function object(action, data) {
|
|
|
355
360
|
errorHandler(data, error, database, array)
|
|
356
361
|
|
|
357
362
|
for (let i = 0; i < data[type].length; i++)
|
|
358
|
-
documents.push({
|
|
363
|
+
documents.push({ storage: data.storageName, database, array, ...data[type][i] })
|
|
359
364
|
|
|
360
365
|
arraysLength -= 1
|
|
361
366
|
if (!arraysLength)
|
|
@@ -465,7 +470,7 @@ function object(action, data) {
|
|
|
465
470
|
if (Result) {
|
|
466
471
|
for (let doc of Result) {
|
|
467
472
|
if (action == 'deleteObject')
|
|
468
|
-
documents.push({ _id: doc._id,
|
|
473
|
+
documents.push({ _id: doc._id, storage: data.storageName, database, array })
|
|
469
474
|
else
|
|
470
475
|
doc['modified'] = { on: data.timeStamp, by: data.user_id || data.clientId }
|
|
471
476
|
|
|
@@ -481,10 +486,10 @@ function object(action, data) {
|
|
|
481
486
|
if (updateType == '_id') {
|
|
482
487
|
let update_id = updateDoc._id
|
|
483
488
|
query['_id'] = ObjectId(update_id)
|
|
484
|
-
$update = createUpdate({
|
|
489
|
+
$update = createUpdate({ object: [updateDoc] }, type)
|
|
485
490
|
update = $update.update
|
|
486
491
|
projection = $update.projection
|
|
487
|
-
documents.push({ _id: update_id,
|
|
492
|
+
documents.push({ _id: update_id, storage: data.storageName, database, array, ...update['$set'] })
|
|
488
493
|
}
|
|
489
494
|
|
|
490
495
|
if (updateType == 'filter') {
|
|
@@ -493,7 +498,7 @@ function object(action, data) {
|
|
|
493
498
|
update = $update.update
|
|
494
499
|
projection = $update.projection
|
|
495
500
|
for (let _id of _ids)
|
|
496
|
-
documents.push({ _id,
|
|
501
|
+
documents.push({ _id, storage: data.storageName, database, array, ...update['$set'] })
|
|
497
502
|
|
|
498
503
|
}
|
|
499
504
|
|
|
@@ -754,7 +759,7 @@ function errorHandler(data, error, database, array) {
|
|
|
754
759
|
if (typeof error == 'object')
|
|
755
760
|
error['storage'] = 'mongodb'
|
|
756
761
|
else
|
|
757
|
-
error = {
|
|
762
|
+
error = { storage: data.storageName, message: error }
|
|
758
763
|
|
|
759
764
|
if (database)
|
|
760
765
|
error['database'] = database
|