monastery 2.2.3 → 3.0.1
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/.eslintrc.json +10 -1
- package/changelog.md +3 -1
- package/docs/_config.yml +2 -2
- package/docs/assets/imgs/monastery.jpg +0 -0
- package/docs/definition/index.md +1 -2
- package/docs/manager/index.md +19 -11
- package/docs/manager/model.md +1 -1
- package/docs/manager/models.md +2 -3
- package/docs/model/count.md +25 -0
- package/docs/model/find.md +5 -9
- package/docs/model/findOne.md +1 -1
- package/docs/model/findOneAndUpdate.md +1 -1
- package/docs/model/index.md +5 -30
- package/docs/model/insert.md +4 -6
- package/docs/model/rawMethods.md +290 -0
- package/docs/model/remove.md +4 -6
- package/docs/model/update.md +4 -6
- package/docs/readme.md +69 -48
- package/lib/collection.js +324 -0
- package/lib/index.js +207 -67
- package/lib/model-crud.js +605 -619
- package/lib/model-validate.js +227 -245
- package/lib/model.js +70 -91
- package/lib/rules.js +36 -35
- package/lib/util.js +69 -15
- package/package.json +12 -11
- package/plugins/images/index.js +11 -11
- package/test/blacklisting.js +506 -537
- package/test/collection.js +445 -0
- package/test/crud.js +810 -730
- package/test/index.test.js +26 -0
- package/test/manager.js +77 -0
- package/test/mock/blacklisting.js +23 -23
- package/test/model.js +611 -572
- package/test/plugin-images.js +880 -965
- package/test/populate.js +249 -262
- package/test/util.js +126 -45
- package/test/validate.js +1074 -1121
- package/test/virtuals.js +222 -227
- package/lib/monk-monkey-patches.js +0 -90
- package/test/monk.js +0 -53
- package/test/test.js +0 -38
package/package.json
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "monastery",
|
|
3
|
-
"description": "⛪ A
|
|
3
|
+
"description": "⛪ A simple, straightforward MongoDB ODM",
|
|
4
4
|
"author": "Ricky Boyce",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "3.0.1",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "github:boycce/monastery",
|
|
8
8
|
"homepage": "https://boycce.github.io/monastery/",
|
|
9
9
|
"main": "lib/index.js",
|
|
10
10
|
"keywords": [
|
|
11
|
+
"database",
|
|
12
|
+
"javascript",
|
|
11
13
|
"monastery",
|
|
12
|
-
"
|
|
13
|
-
"mongodb",
|
|
14
|
+
"mongo driver",
|
|
14
15
|
"mongo",
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
16
|
+
"mongodb",
|
|
17
|
+
"nodejs",
|
|
18
|
+
"odm",
|
|
19
|
+
"orm"
|
|
18
20
|
],
|
|
19
21
|
"scripts": {
|
|
20
22
|
"dev": "npm run lint & jest --watchAll --runInBand --verbose=false",
|
|
21
23
|
"docs": "cd docs && bundle exec jekyll serve --livereload --livereload-port 4001",
|
|
22
24
|
"lint": "eslint ./lib ./plugins ./test",
|
|
25
|
+
"mona": "nodemon resources/mona.js",
|
|
23
26
|
"mong": "nodemon resources/mong.js",
|
|
24
27
|
"major": "standard-version --release-as major && npm publish",
|
|
25
28
|
"minor": "standard-version --release-as minor && npm publish",
|
|
@@ -34,8 +37,7 @@
|
|
|
34
37
|
"@aws-sdk/s3-request-presigner": "3.549.0",
|
|
35
38
|
"debug": "4.3.4",
|
|
36
39
|
"file-type": "^16.5.4",
|
|
37
|
-
"mongodb": "^
|
|
38
|
-
"monk": "7.3.4",
|
|
40
|
+
"mongodb": "^5.9.2",
|
|
39
41
|
"nanoid": "3.2.0",
|
|
40
42
|
"validator": "13.7.0"
|
|
41
43
|
},
|
|
@@ -50,8 +52,7 @@
|
|
|
50
52
|
"supertest": "4.0.2"
|
|
51
53
|
},
|
|
52
54
|
"engines": {
|
|
53
|
-
"node": ">=14"
|
|
54
|
-
"npm": ">=6"
|
|
55
|
+
"node": ">=14"
|
|
55
56
|
},
|
|
56
57
|
"standard-version": {
|
|
57
58
|
"infile": "changelog.md",
|
package/plugins/images/index.js
CHANGED
|
@@ -39,7 +39,7 @@ let plugin = module.exports = {
|
|
|
39
39
|
|
|
40
40
|
if (!options.awsBucket || !options.awsAccessKeyId || !options.awsSecretAccessKey) {
|
|
41
41
|
manager.error('Monastery imagePlugin: awsBucket, awsAccessKeyId, or awsSecretAccessKey is not defined')
|
|
42
|
-
delete manager.imagePlugin
|
|
42
|
+
delete manager.opts.imagePlugin
|
|
43
43
|
return
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -54,8 +54,8 @@ let plugin = module.exports = {
|
|
|
54
54
|
region: this.awsRegion,
|
|
55
55
|
credentials: {
|
|
56
56
|
accessKeyId: this.awsAccessKeyId,
|
|
57
|
-
secretAccessKey: this.awsSecretAccessKey
|
|
58
|
-
}
|
|
57
|
+
secretAccessKey: this.awsSecretAccessKey,
|
|
58
|
+
},
|
|
59
59
|
}))
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -150,7 +150,7 @@ let plugin = module.exports = {
|
|
|
150
150
|
let path = filesArr.imageField.path || plugin.path
|
|
151
151
|
let image = {
|
|
152
152
|
bucket: filesArr.imageField.awsBucket || plugin.awsBucket,
|
|
153
|
-
date: plugin.manager.useMilliseconds? Date.now() : Math.floor(Date.now() / 1000),
|
|
153
|
+
date: plugin.manager.opts.useMilliseconds? Date.now() : Math.floor(Date.now() / 1000),
|
|
154
154
|
filename: file.name,
|
|
155
155
|
filesize: file.size,
|
|
156
156
|
metadata: filesArr.imageField.metadata || plugin.metadata,
|
|
@@ -204,7 +204,7 @@ let plugin = module.exports = {
|
|
|
204
204
|
return model._update(
|
|
205
205
|
idquery,
|
|
206
206
|
{ '$set': prunedData },
|
|
207
|
-
{ 'multi': options.multi || options.create }
|
|
207
|
+
{ 'multi': options.multi || options.create }
|
|
208
208
|
)
|
|
209
209
|
|
|
210
210
|
// If errors, remove inserted documents to prevent double ups when the user resaves.
|
|
@@ -372,7 +372,7 @@ let plugin = module.exports = {
|
|
|
372
372
|
{ Key: pre.image.path },
|
|
373
373
|
{ Key: `small/${key}.jpg` },
|
|
374
374
|
{ Key: `medium/${key}.jpg` },
|
|
375
|
-
{ Key: `large/${key}.jpg` }
|
|
375
|
+
{ Key: `large/${key}.jpg` }
|
|
376
376
|
)
|
|
377
377
|
plugin.manager.info(
|
|
378
378
|
`Removing '${pre.image.filename}' from '${pre.image.bucket}/${pre.image.path}'`
|
|
@@ -385,7 +385,7 @@ let plugin = module.exports = {
|
|
|
385
385
|
await new Promise((resolve, reject) => {
|
|
386
386
|
plugin.getS3Client().deleteObjects({
|
|
387
387
|
Bucket: plugin.awsBucket,
|
|
388
|
-
Delete: { Objects: unused }
|
|
388
|
+
Delete: { Objects: unused },
|
|
389
389
|
}, (err, data) => {
|
|
390
390
|
if (err) reject(err)
|
|
391
391
|
resolve()
|
|
@@ -459,19 +459,19 @@ let plugin = module.exports = {
|
|
|
459
459
|
|
|
460
460
|
if (file.truncated) reject({
|
|
461
461
|
title: filesArr.inputPath + (i? `.${i}` : ''),
|
|
462
|
-
detail: `The file size for '${file.nameClipped}' is too big
|
|
462
|
+
detail: `The file size for '${file.nameClipped}' is too big.`,
|
|
463
463
|
})
|
|
464
464
|
else if (filesize && filesize < file.size) reject({ // file.size == bytes
|
|
465
465
|
title: filesArr.inputPath + (i? `.${i}` : ''),
|
|
466
|
-
detail: `The file size for '${file.nameClipped}' is bigger than ${(filesize/1000/1000).toFixed(1)}MB
|
|
466
|
+
detail: `The file size for '${file.nameClipped}' is bigger than ${(filesize/1000/1000).toFixed(1)}MB.`,
|
|
467
467
|
})
|
|
468
468
|
else if (file.ext == 'unknown') reject({
|
|
469
469
|
title: filesArr.inputPath + (i? `.${i}` : ''),
|
|
470
|
-
detail: `Please add a file extension to your file '${file.nameClipped}'
|
|
470
|
+
detail: `Please add a file extension to your file '${file.nameClipped}'`,
|
|
471
471
|
})
|
|
472
472
|
else if (!allowAny && !util.inArray(formats, file.ext)) reject({
|
|
473
473
|
title: filesArr.inputPath + (i? `.${i}` : ''),
|
|
474
|
-
detail: `The file format '${file.ext}' for '${file.nameClipped}' is not supported
|
|
474
|
+
detail: `The file format '${file.ext}' for '${file.nameClipped}' is not supported`,
|
|
475
475
|
})
|
|
476
476
|
else resolve()
|
|
477
477
|
})
|