@teamplay/backend 0.2.4 → 0.2.5

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.
@@ -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, { customCheck, models = {} } = {}) {
5
- _serverAggregate(backend, { customCheck })
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
- const schemaPerCollection = { schemas: {}, formats: {}, validators: {} }
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
- schemaPerCollection.schemas[collectionName] = schema
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
- schemaPerCollection.schemas.service = transformSchema({
30
+ options.schemas.service = transformSchema({
26
31
  type: 'object', properties: {}, additionalProperties: true
27
32
  })
28
33
  }
29
34
 
30
- sharedbSchema(backend, schemaPerCollection)
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, { customCheck: serverAggregate?.customCheck, models })
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.4",
3
+ "version": "0.2.5",
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.4",
16
- "@teamplay/server-aggregate": "^0.2.4",
17
- "@teamplay/sharedb-access": "^0.2.4",
18
- "@teamplay/sharedb-schema": "^0.2.4",
19
- "@teamplay/utils": "^0.2.4",
15
+ "@teamplay/schema": "^0.2.5",
16
+ "@teamplay/server-aggregate": "^0.2.5",
17
+ "@teamplay/sharedb-access": "^0.2.5",
18
+ "@teamplay/sharedb-schema": "^0.2.5",
19
+ "@teamplay/utils": "^0.2.5",
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": "9d78732c718f86a12cfa74d0a2b23b31d8ba8daa"
32
+ "gitHead": "e4ea7de3c12214a24928af14b882651b3aeb5599"
33
33
  }