@teamplay/backend 0.2.4 → 0.2.6
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/features/serverAggregate.js +2 -2
- package/features/validateSchema.js +10 -5
- package/index.js +3 -3
- package/package.json +7 -7
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _serverAggregate from '@teamplay/server-aggregate'
|
|
2
2
|
import { isAggregationFunction } from '@teamplay/utils/aggregation'
|
|
3
3
|
|
|
4
|
-
export default function serverAggregate (backend, {
|
|
5
|
-
_serverAggregate(backend,
|
|
4
|
+
export default function serverAggregate (backend, { models = {}, ...options } = {}) {
|
|
5
|
+
_serverAggregate(backend, options)
|
|
6
6
|
|
|
7
7
|
for (const modelPattern in models) {
|
|
8
8
|
for (const aggregationName in models[modelPattern]) {
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import sharedbSchema from '@teamplay/sharedb-schema'
|
|
2
2
|
import { transformSchema } from '@teamplay/schema'
|
|
3
3
|
|
|
4
|
-
export default function validateSchema (backend, { models = {} } = {}) {
|
|
5
|
-
|
|
4
|
+
export default function validateSchema (backend, { models = {}, ...options } = {}) {
|
|
5
|
+
options = {
|
|
6
|
+
schemas: {},
|
|
7
|
+
formats: {},
|
|
8
|
+
validators: {},
|
|
9
|
+
...options
|
|
10
|
+
}
|
|
6
11
|
|
|
7
12
|
for (const modelPattern in models) {
|
|
8
13
|
let { schema, factory } = models[modelPattern]
|
|
@@ -16,18 +21,18 @@ export default function validateSchema (backend, { models = {} } = {}) {
|
|
|
16
21
|
if (/\./.test(collectionName)) throw Error(ERRORS.onlyTopLevelCollections(modelPattern))
|
|
17
22
|
// transform schema from simplified format to full format
|
|
18
23
|
schema = transformSchema(schema, { collectionName })
|
|
19
|
-
|
|
24
|
+
options.schemas[collectionName] = schema
|
|
20
25
|
}
|
|
21
26
|
|
|
22
27
|
// allow any 'service' collection structure
|
|
23
28
|
// since 'service' collection is used in our startupjs libraries
|
|
24
29
|
// and we don't have a tool to collect scheme from all packages right now
|
|
25
|
-
|
|
30
|
+
options.schemas.service = transformSchema({
|
|
26
31
|
type: 'object', properties: {}, additionalProperties: true
|
|
27
32
|
})
|
|
28
33
|
}
|
|
29
34
|
|
|
30
|
-
sharedbSchema(backend,
|
|
35
|
+
sharedbSchema(backend, options)
|
|
31
36
|
console.log('✓ Security: JSON-schema validation of DB collections on backend is enabled')
|
|
32
37
|
}
|
|
33
38
|
|
package/index.js
CHANGED
|
@@ -44,15 +44,15 @@ export default function createBackend ({
|
|
|
44
44
|
if (hooks) hooks(backend)
|
|
45
45
|
|
|
46
46
|
if (accessControl) {
|
|
47
|
-
initAccessControl(backend, { models })
|
|
47
|
+
initAccessControl(backend, { models, ...(typeof accessControl === 'object' ? accessControl : {}) })
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
if (serverAggregate) {
|
|
51
|
-
initServerAggregate(backend, {
|
|
51
|
+
initServerAggregate(backend, { models, ...(typeof serverAggregate === 'object' ? serverAggregate : {}) })
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
if (validateSchema && process.env.NODE_ENV !== 'production') {
|
|
55
|
-
initValidateSchema(backend, { models })
|
|
55
|
+
initValidateSchema(backend, { models, ...(typeof validateSchema === 'object' ? validateSchema : {}) })
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
backend.on('client', (client, reject) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamplay/backend",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "Create new ShareDB backend instance",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
".": "./index.js"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@teamplay/schema": "^0.2.
|
|
16
|
-
"@teamplay/server-aggregate": "^0.2.
|
|
17
|
-
"@teamplay/sharedb-access": "^0.2.
|
|
18
|
-
"@teamplay/sharedb-schema": "^0.2.
|
|
19
|
-
"@teamplay/utils": "^0.2.
|
|
15
|
+
"@teamplay/schema": "^0.2.6",
|
|
16
|
+
"@teamplay/server-aggregate": "^0.2.6",
|
|
17
|
+
"@teamplay/sharedb-access": "^0.2.6",
|
|
18
|
+
"@teamplay/sharedb-schema": "^0.2.6",
|
|
19
|
+
"@teamplay/utils": "^0.2.6",
|
|
20
20
|
"@types/ioredis-mock": "^8.2.5",
|
|
21
21
|
"ioredis": "^5.3.2",
|
|
22
22
|
"ioredis-mock": "^8.9.0",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"sharedb-redis-pubsub": "^2.0.1",
|
|
30
30
|
"sqlite3": "^5.1.6"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "c9a3df89a3c7b9175d35ab21b9261cf8bef6aa3b"
|
|
33
33
|
}
|