2016-09-24 08:05:26 +03:00
|
|
|
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
|
2016-10-19 15:22:50 +03:00
|
|
|
import createGraph from '../query/lib/createGraph.js';
|
2016-09-24 08:05:26 +03:00
|
|
|
|
2016-10-19 15:22:50 +03:00
|
|
|
let Schema = new SimpleSchema({
|
2016-09-24 08:05:26 +03:00
|
|
|
firewall: {
|
|
|
|
type: Function,
|
|
|
|
optional: true
|
|
|
|
},
|
|
|
|
|
|
|
|
maxLimit: {
|
|
|
|
type: Number,
|
|
|
|
optional: true,
|
|
|
|
min: 1
|
|
|
|
},
|
|
|
|
|
|
|
|
maxDepth: {
|
|
|
|
type: Number,
|
|
|
|
optional: true,
|
|
|
|
min: 1
|
|
|
|
},
|
|
|
|
|
|
|
|
restrictedFields: {
|
|
|
|
type: [String],
|
|
|
|
optional: true
|
2016-09-28 18:30:12 +03:00
|
|
|
},
|
|
|
|
|
2016-10-07 10:31:58 +03:00
|
|
|
restrictLinks: {
|
|
|
|
type: null, // Can be function that accepts userId and returns array or array
|
2016-09-28 18:30:12 +03:00
|
|
|
optional: true
|
|
|
|
},
|
|
|
|
|
|
|
|
publication: {
|
|
|
|
type: Boolean,
|
|
|
|
defaultValue: true
|
|
|
|
},
|
|
|
|
|
|
|
|
method: {
|
|
|
|
type: Boolean,
|
|
|
|
defaultValue: true
|
2016-10-19 15:22:50 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
body: {
|
|
|
|
type: null,
|
|
|
|
blackbox: true,
|
|
|
|
optional: true
|
2016-11-17 13:11:55 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
blocking: {
|
|
|
|
type: Boolean,
|
|
|
|
defaultValue: false
|
2016-10-19 15:22:50 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default Schema;
|
|
|
|
|
|
|
|
_.extend(Schema, {
|
|
|
|
validateBody(collection, body) {
|
|
|
|
try {
|
|
|
|
createGraph(collection, body);
|
|
|
|
} catch (e) {
|
|
|
|
throw new Meteor.Error('invalid-body', 'We could not build a valid graph when trying to create your exposure: ' + e.toString())
|
|
|
|
}
|
2016-09-24 08:05:26 +03:00
|
|
|
}
|
|
|
|
})
|