2016-10-19 15:22:50 +03:00
|
|
|
import createGraph from '../query/lib/createGraph.js';
|
2017-11-26 23:42:27 +02:00
|
|
|
import {Match} from 'meteor/check';
|
|
|
|
|
|
|
|
export const ExposureDefaults = {
|
|
|
|
blocking: false,
|
|
|
|
method: true,
|
|
|
|
publication: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
export const ExposureSchema = {
|
2017-11-28 17:38:51 +02:00
|
|
|
firewall: Match.Maybe(
|
|
|
|
Match.OneOf(Function, [Function])
|
|
|
|
),
|
2017-11-26 23:42:27 +02:00
|
|
|
maxLimit: Match.Maybe(Match.Integer),
|
|
|
|
maxDepth: Match.Maybe(Match.Integer),
|
|
|
|
publication: Match.Maybe(Boolean),
|
|
|
|
method: Match.Maybe(Boolean),
|
|
|
|
blocking: Match.Maybe(Boolean),
|
|
|
|
body: Match.Maybe(Object),
|
|
|
|
restrictedFields: Match.Maybe([String]),
|
|
|
|
restrictLinks: Match.Maybe(
|
|
|
|
Match.OneOf(Function, [String])
|
|
|
|
),
|
|
|
|
};
|
|
|
|
|
|
|
|
export function 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
|
|
|
}
|
2017-11-26 23:42:27 +02:00
|
|
|
}
|