monastery 2.2.2 → 3.0.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/.eslintrc.json +10 -1
- package/changelog.md +2 -0
- 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/...rawMethods.md +289 -0
- 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/remove.md +4 -6
- package/docs/model/update.md +4 -6
- package/docs/readme.md +78 -45
- 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 -40
- 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.0",
|
|
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",
|
|
@@ -33,8 +36,7 @@
|
|
|
33
36
|
"@aws-sdk/s3-request-presigner": "3.549.0",
|
|
34
37
|
"debug": "4.3.4",
|
|
35
38
|
"file-type": "^16.5.4",
|
|
36
|
-
"
|
|
37
|
-
"mongodb": "^3.2.3",
|
|
39
|
+
"mongodb": "^5.9.2",
|
|
38
40
|
"nanoid": "3.2.0",
|
|
39
41
|
"validator": "13.7.0"
|
|
40
42
|
},
|
|
@@ -49,8 +51,7 @@
|
|
|
49
51
|
"supertest": "4.0.2"
|
|
50
52
|
},
|
|
51
53
|
"engines": {
|
|
52
|
-
"node": ">=14"
|
|
53
|
-
"npm": ">=6"
|
|
54
|
+
"node": ">=14"
|
|
54
55
|
},
|
|
55
56
|
"standard-version": {
|
|
56
57
|
"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,
|
|
@@ -193,7 +193,7 @@ let plugin = module.exports = {
|
|
|
193
193
|
return model._update(
|
|
194
194
|
idquery,
|
|
195
195
|
{ '$set': prunedData },
|
|
196
|
-
{ 'multi': options.multi || options.create }
|
|
196
|
+
{ 'multi': options.multi || options.create }
|
|
197
197
|
)
|
|
198
198
|
|
|
199
199
|
// If errors, remove inserted documents to prevent double ups when the user resaves.
|
|
@@ -361,7 +361,7 @@ let plugin = module.exports = {
|
|
|
361
361
|
{ Key: pre.image.path },
|
|
362
362
|
{ Key: `small/${key}.jpg` },
|
|
363
363
|
{ Key: `medium/${key}.jpg` },
|
|
364
|
-
{ Key: `large/${key}.jpg` }
|
|
364
|
+
{ Key: `large/${key}.jpg` }
|
|
365
365
|
)
|
|
366
366
|
plugin.manager.info(
|
|
367
367
|
`Removing '${pre.image.filename}' from '${pre.image.bucket}/${pre.image.path}'`
|
|
@@ -374,7 +374,7 @@ let plugin = module.exports = {
|
|
|
374
374
|
await new Promise((resolve, reject) => {
|
|
375
375
|
plugin.getS3Client().deleteObjects({
|
|
376
376
|
Bucket: plugin.awsBucket,
|
|
377
|
-
Delete: { Objects: unused }
|
|
377
|
+
Delete: { Objects: unused },
|
|
378
378
|
}, (err, data) => {
|
|
379
379
|
if (err) reject(err)
|
|
380
380
|
resolve()
|
|
@@ -448,19 +448,19 @@ let plugin = module.exports = {
|
|
|
448
448
|
|
|
449
449
|
if (file.truncated) reject({
|
|
450
450
|
title: filesArr.inputPath + (i? `.${i}` : ''),
|
|
451
|
-
detail: `The file size for '${file.nameClipped}' is too big
|
|
451
|
+
detail: `The file size for '${file.nameClipped}' is too big.`,
|
|
452
452
|
})
|
|
453
453
|
else if (filesize && filesize < file.size) reject({ // file.size == bytes
|
|
454
454
|
title: filesArr.inputPath + (i? `.${i}` : ''),
|
|
455
|
-
detail: `The file size for '${file.nameClipped}' is bigger than ${(filesize/1000/1000).toFixed(1)}MB
|
|
455
|
+
detail: `The file size for '${file.nameClipped}' is bigger than ${(filesize/1000/1000).toFixed(1)}MB.`,
|
|
456
456
|
})
|
|
457
457
|
else if (file.ext == 'unknown') reject({
|
|
458
458
|
title: filesArr.inputPath + (i? `.${i}` : ''),
|
|
459
|
-
detail: `Please add a file extension to your file '${file.nameClipped}'
|
|
459
|
+
detail: `Please add a file extension to your file '${file.nameClipped}'`,
|
|
460
460
|
})
|
|
461
461
|
else if (!allowAny && !util.inArray(formats, file.ext)) reject({
|
|
462
462
|
title: filesArr.inputPath + (i? `.${i}` : ''),
|
|
463
|
-
detail: `The file format '${file.ext}' for '${file.nameClipped}' is not supported
|
|
463
|
+
detail: `The file format '${file.ext}' for '${file.nameClipped}' is not supported`,
|
|
464
464
|
})
|
|
465
465
|
else resolve()
|
|
466
466
|
})
|