monastery 1.28.2 → 1.29.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 +30 -4
- package/docs/Gemfile +8 -18
- package/docs/_config.yml +1 -4
- package/docs/errors.md +0 -0
- package/docs/image-plugin.md +0 -0
- package/docs/manager/model.md +0 -0
- package/docs/manager/models.md +0 -0
- package/docs/model/findOne.md +0 -0
- package/docs/model/index.md +0 -0
- package/docs/model/remove.md +0 -0
- package/docs/readme.md +1 -1
- package/docs/rules.md +0 -0
- package/lib/index.js +0 -1
- package/lib/model-crud.js +32 -16
- package/lib/model-validate.js +20 -24
- package/lib/model.js +13 -4
- package/lib/rules.js +38 -16
- package/lib/util.js +13 -7
- package/package.json +17 -16
- package/plugins/images/index.js +4 -4
- package/test/assets/bad.svg +0 -0
- package/test/assets/image.ico +0 -0
- package/test/assets/image.webp +0 -0
- package/test/assets/lion1.png +0 -0
- package/test/assets/lion2.jpg +0 -0
- package/test/assets/logo.png +0 -0
- package/test/assets/logo2.png +0 -0
- package/test/blacklisting.js +4 -8
- package/test/crud.js +28 -31
- package/test/model.js +22 -25
- package/test/monk.js +4 -4
- package/test/plugin-images.js +400 -390
- package/test/populate.js +15 -18
- package/test/util.js +8 -8
- package/test/validate.js +126 -50
- package/test/virtuals.js +2 -4
package/test/model.js
CHANGED
|
@@ -19,13 +19,13 @@ module.exports = function(monastery, opendb) {
|
|
|
19
19
|
insertOnly: true,
|
|
20
20
|
isInteger: true,
|
|
21
21
|
timestampField: true,
|
|
22
|
-
type:
|
|
22
|
+
type: 'integer',
|
|
23
23
|
},
|
|
24
24
|
updatedAt: {
|
|
25
25
|
default: expect.any(Function),
|
|
26
26
|
isInteger: true,
|
|
27
27
|
timestampField: true,
|
|
28
|
-
type:
|
|
28
|
+
type: 'integer',
|
|
29
29
|
},
|
|
30
30
|
})
|
|
31
31
|
|
|
@@ -79,13 +79,13 @@ module.exports = function(monastery, opendb) {
|
|
|
79
79
|
insertOnly: true,
|
|
80
80
|
isInteger: true,
|
|
81
81
|
timestampField: true,
|
|
82
|
-
type:
|
|
82
|
+
type: 'integer'
|
|
83
83
|
},
|
|
84
84
|
updatedAt: {
|
|
85
85
|
default: expect.any(Function),
|
|
86
86
|
isInteger: true,
|
|
87
87
|
timestampField: true,
|
|
88
|
-
type:
|
|
88
|
+
type: 'integer'
|
|
89
89
|
}
|
|
90
90
|
})
|
|
91
91
|
})
|
|
@@ -115,7 +115,7 @@ module.exports = function(monastery, opendb) {
|
|
|
115
115
|
})
|
|
116
116
|
})
|
|
117
117
|
|
|
118
|
-
test('Model indexes', async (
|
|
118
|
+
test('Model indexes', async () => {
|
|
119
119
|
// Need to test different types of indexes
|
|
120
120
|
let db = (await opendb(null)).db
|
|
121
121
|
|
|
@@ -129,10 +129,10 @@ module.exports = function(monastery, opendb) {
|
|
|
129
129
|
|
|
130
130
|
// Unique & text index (after model initialisation, in serial)
|
|
131
131
|
let userIndexRawModel = db.model('userIndexRaw', {})
|
|
132
|
-
|
|
132
|
+
await userIndexRawModel._setupIndexes({
|
|
133
133
|
email: { type: 'string', index: 'unique' },
|
|
134
134
|
})
|
|
135
|
-
|
|
135
|
+
await userIndexRawModel._setupIndexes({
|
|
136
136
|
name: { type: 'string', index: 'text' },
|
|
137
137
|
})
|
|
138
138
|
let indexes = await db._db.collection('userIndexRaw').indexes()
|
|
@@ -170,28 +170,27 @@ module.exports = function(monastery, opendb) {
|
|
|
170
170
|
textIndexVersion: 3
|
|
171
171
|
})
|
|
172
172
|
|
|
173
|
-
// No text index change error, i.e. new Error(
|
|
173
|
+
// No text index change error, i.e. new Error('Index with name: text already exists with different options')
|
|
174
174
|
await expect(userIndexModel._setupIndexes({
|
|
175
175
|
name: { type: 'string', index: 'text' },
|
|
176
176
|
name2: { type: 'string', index: 'text' }
|
|
177
177
|
})).resolves.toEqual([{
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
'key': { 'name': 'text', 'name2': 'text' },
|
|
179
|
+
'name': 'text',
|
|
180
180
|
}])
|
|
181
181
|
|
|
182
182
|
// Text index on a different model
|
|
183
183
|
await expect(userIndexRawModel._setupIndexes({
|
|
184
184
|
name2: { type: 'string', index: 'text' }
|
|
185
185
|
})).resolves.toEqual([{
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
'key': {'name2': 'text'},
|
|
187
|
+
'name': 'text',
|
|
188
188
|
}])
|
|
189
189
|
|
|
190
190
|
db.close()
|
|
191
|
-
done()
|
|
192
191
|
})
|
|
193
192
|
|
|
194
|
-
test('Model 2dsphere indexes', async (
|
|
193
|
+
test('Model 2dsphere indexes', async () => {
|
|
195
194
|
// Setup. The tested model needs to be unique as race condition issue arises when the same model
|
|
196
195
|
// with text indexes are setup at the same time
|
|
197
196
|
let db = (await opendb(null)).db
|
|
@@ -217,10 +216,10 @@ module.exports = function(monastery, opendb) {
|
|
|
217
216
|
coordinates: expect.any(Array),
|
|
218
217
|
schema: {
|
|
219
218
|
default: undefined,
|
|
220
|
-
index:
|
|
219
|
+
index: '2dsphere',
|
|
221
220
|
isObject: true,
|
|
222
221
|
nullObject: undefined,
|
|
223
|
-
type:
|
|
222
|
+
type: 'object'
|
|
224
223
|
}
|
|
225
224
|
})
|
|
226
225
|
expect(db.user3.fields.location2).toEqual({
|
|
@@ -228,10 +227,10 @@ module.exports = function(monastery, opendb) {
|
|
|
228
227
|
coordinates: expect.any(Array),
|
|
229
228
|
schema: {
|
|
230
229
|
default: undefined,
|
|
231
|
-
index: { type:
|
|
230
|
+
index: { type: '2dsphere' },
|
|
232
231
|
isObject: true,
|
|
233
232
|
nullObject: undefined,
|
|
234
|
-
type:
|
|
233
|
+
type: 'object'
|
|
235
234
|
}
|
|
236
235
|
})
|
|
237
236
|
|
|
@@ -244,17 +243,16 @@ module.exports = function(monastery, opendb) {
|
|
|
244
243
|
_id: expect.any(Object),
|
|
245
244
|
location: {
|
|
246
245
|
coordinates: [172.5880385, -43.3311608],
|
|
247
|
-
type:
|
|
246
|
+
type: 'Point'
|
|
248
247
|
},
|
|
249
248
|
})
|
|
250
249
|
|
|
251
250
|
db.close()
|
|
252
|
-
done()
|
|
253
251
|
})
|
|
254
252
|
|
|
255
|
-
test('Model findBL, findBLProject', async (
|
|
253
|
+
test('Model findBL, findBLProject', async () => {
|
|
256
254
|
let db = (await opendb(null)).db
|
|
257
|
-
|
|
255
|
+
db.model('bird', { fields: {
|
|
258
256
|
name: { type: 'string' }
|
|
259
257
|
}})
|
|
260
258
|
let user = db.model('user', {
|
|
@@ -355,8 +353,8 @@ module.exports = function(monastery, opendb) {
|
|
|
355
353
|
'hiddenDeepModel': 0,
|
|
356
354
|
'hiddenDeepModels': 0,
|
|
357
355
|
// Deep model blacklists
|
|
358
|
-
|
|
359
|
-
|
|
356
|
+
'deepModel.myBird.password': 0,
|
|
357
|
+
'deepModel2.myBird.password': 0
|
|
360
358
|
})
|
|
361
359
|
|
|
362
360
|
// Test whitelisting
|
|
@@ -415,7 +413,6 @@ module.exports = function(monastery, opendb) {
|
|
|
415
413
|
})
|
|
416
414
|
|
|
417
415
|
db.close()
|
|
418
|
-
done()
|
|
419
416
|
})
|
|
420
417
|
|
|
421
418
|
}
|
package/test/monk.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
module.exports = function(monastery, opendb) {
|
|
2
2
|
|
|
3
|
-
test('Monk confilicts', async (
|
|
3
|
+
test('Monk confilicts', async () => {
|
|
4
4
|
// Setup
|
|
5
5
|
let db = (await opendb(false)).db
|
|
6
6
|
let monkdb = require('monk')(':badconnection', () => {})
|
|
7
|
-
|
|
7
|
+
db.model('user', {})
|
|
8
8
|
let modelNamedConnected = db.model('connected', {})
|
|
9
9
|
|
|
10
10
|
// Any of our monastery properties already exist on the manager?
|
|
@@ -19,8 +19,8 @@ module.exports = function(monastery, opendb) {
|
|
|
19
19
|
expect(db.connected).toEqual(db.connected)
|
|
20
20
|
expect(db.model.connected).toEqual(modelNamedConnected)
|
|
21
21
|
|
|
22
|
-
// Close test since monk(uri) awaits upoin a connection
|
|
23
|
-
done()
|
|
22
|
+
// Close test since monk(uri) awaits upoin a connection (Update, done not needed in latest jest)
|
|
23
|
+
// done()
|
|
24
24
|
})
|
|
25
25
|
|
|
26
26
|
test('Monastery connect with promise', (done) => {
|