mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 01:51:40 -05:00
devel - revert commits related to simpl-schema (#1537)
* Revert "add note link to issue in collection2 on mutation insert, remove debug console logs on mutation edit" This reverts commit7a15103de7
. * Revert "node simpl-schema + collection2-core: fix vote by specifying the right type of the array (dont use blackbox in the end!)" This reverts commite894c3224c
. * Revert "add graphql date type (fix problem with node simple schema), fix an update bug on date picker, add edit check on custom post item, add `blackbox: true` for arrays field (validation problem with simple-schema)" This reverts commit9d84fbec98
. * Revert "use node `simpl-schema` by aldeed to replace `meteor/aldeed:simple-schema` ; use the meteor collection2 core package as recommended" This reverts commit016935f4fa
. * revert before node-simple-schema, fix obj.hasOwnProperty undefined error thrown by simple-schema & collection2 * CustomPostsItem: check on renderActions; withDocument/List: pollInterval 20seconds by default; DateTime form component enhancement + GraphQLDate type
This commit is contained in:
parent
ad007ac003
commit
7f99b48953
22 changed files with 94 additions and 149 deletions
|
@ -42,5 +42,5 @@ accounts-password@1.3.3
|
||||||
# accounts-twitter
|
# accounts-twitter
|
||||||
# accounts-facebook
|
# accounts-facebook
|
||||||
|
|
||||||
# customization-demo
|
customization-demo
|
||||||
# framework-demo
|
framework-demo
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
accounts-base@1.2.14
|
accounts-base@1.2.14
|
||||||
accounts-password@1.3.3
|
accounts-password@1.3.3
|
||||||
aldeed:collection2-core@2.0.0
|
aldeed:collection2@2.10.0
|
||||||
|
aldeed:collection2-core@1.2.0
|
||||||
|
aldeed:schema-deny@1.1.0
|
||||||
|
aldeed:schema-index@1.1.1
|
||||||
|
aldeed:simple-schema@1.5.3
|
||||||
allow-deny@1.0.5
|
allow-deny@1.0.5
|
||||||
autoupdate@1.3.12
|
autoupdate@1.3.12
|
||||||
babel-compiler@6.13.0
|
babel-compiler@6.13.0
|
||||||
|
@ -15,6 +19,8 @@ callback-hook@1.0.10
|
||||||
check@1.2.4
|
check@1.2.4
|
||||||
chuangbo:cookie@1.1.0
|
chuangbo:cookie@1.1.0
|
||||||
coffeescript@1.11.1_4
|
coffeescript@1.11.1_4
|
||||||
|
customization-demo@0.0.0
|
||||||
|
dburles:collection-helpers@1.1.0
|
||||||
ddp@1.2.5
|
ddp@1.2.5
|
||||||
ddp-client@1.3.2
|
ddp-client@1.3.2
|
||||||
ddp-common@1.2.8
|
ddp-common@1.2.8
|
||||||
|
@ -28,6 +34,7 @@ ejson@1.0.13
|
||||||
email@1.1.18
|
email@1.1.18
|
||||||
fortawesome:fontawesome@4.5.0
|
fortawesome:fontawesome@4.5.0
|
||||||
fourseven:scss@3.10.1
|
fourseven:scss@3.10.1
|
||||||
|
framework-demo@0.0.0
|
||||||
geojson-utils@1.0.10
|
geojson-utils@1.0.10
|
||||||
hot-code-push@1.0.4
|
hot-code-push@1.0.4
|
||||||
html-tools@1.0.11
|
html-tools@1.0.11
|
||||||
|
@ -41,6 +48,7 @@ jquery@1.11.10
|
||||||
livedata@1.0.18
|
livedata@1.0.18
|
||||||
localstorage@1.0.12
|
localstorage@1.0.12
|
||||||
logging@1.1.16
|
logging@1.1.16
|
||||||
|
mdg:validation-error@0.5.1
|
||||||
meteor@1.6.0
|
meteor@1.6.0
|
||||||
meteor-base@1.0.4
|
meteor-base@1.0.4
|
||||||
meteorhacks:fast-render@2.16.0
|
meteorhacks:fast-render@2.16.0
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
"formsy-react": "^0.18.1",
|
"formsy-react": "^0.18.1",
|
||||||
"formsy-react-components": "^0.8.1",
|
"formsy-react-components": "^0.8.1",
|
||||||
"graphql": "^0.8.2",
|
"graphql": "^0.8.2",
|
||||||
"graphql-date": "^1.0.2",
|
|
||||||
"graphql-server-express": "^0.4.4",
|
"graphql-server-express": "^0.4.4",
|
||||||
"graphql-subscriptions": "^0.2.1",
|
"graphql-subscriptions": "^0.2.1",
|
||||||
"graphql-tag": "^1.2.1",
|
"graphql-tag": "^1.2.1",
|
||||||
|
@ -58,7 +57,6 @@
|
||||||
"redux": "^3.6.0",
|
"redux": "^3.6.0",
|
||||||
"rss": "^1.2.1",
|
"rss": "^1.2.1",
|
||||||
"sanitize-html": "^1.11.4",
|
"sanitize-html": "^1.11.4",
|
||||||
"simpl-schema": "^0.1.0",
|
|
||||||
"speakingurl": "^9.0.0",
|
"speakingurl": "^9.0.0",
|
||||||
"tracker-component": "^1.3.14",
|
"tracker-component": "^1.3.14",
|
||||||
"url": "^0.11.0"
|
"url": "^0.11.0"
|
||||||
|
|
|
@ -4,10 +4,9 @@ Posts.addField(
|
||||||
{
|
{
|
||||||
fieldName: 'categories',
|
fieldName: 'categories',
|
||||||
fieldSchema: {
|
fieldSchema: {
|
||||||
type: Array,
|
type: [String],
|
||||||
control: "checkboxgroup",
|
control: "checkboxgroup",
|
||||||
optional: true,
|
optional: true,
|
||||||
blackbox: true,
|
|
||||||
insertableBy: ['members'],
|
insertableBy: ['members'],
|
||||||
editableBy: ['members'],
|
editableBy: ['members'],
|
||||||
viewableBy: ['guests'],
|
viewableBy: ['guests'],
|
||||||
|
@ -39,7 +38,12 @@ Posts.addField(
|
||||||
return categoriesOptions;
|
return categoriesOptions;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// publish: true,
|
||||||
|
// join: {
|
||||||
|
// joinAs: "categoriesArray",
|
||||||
|
// collection: () => Categories
|
||||||
|
// },
|
||||||
resolveAs: 'categories: [Category]'
|
resolveAs: 'categories: [Category]'
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -37,12 +37,16 @@ Posts.addField([
|
||||||
{
|
{
|
||||||
fieldName: "commenters",
|
fieldName: "commenters",
|
||||||
fieldSchema: {
|
fieldSchema: {
|
||||||
type: Array,
|
type: [String],
|
||||||
blackbox: true,
|
|
||||||
optional: true,
|
optional: true,
|
||||||
publish: true,
|
publish: true,
|
||||||
|
// join: {
|
||||||
|
// joinAs: "commentersArray",
|
||||||
|
// collection: () => Users,
|
||||||
|
// limit: 4
|
||||||
|
// },
|
||||||
resolveAs: 'commenters: [User]',
|
resolveAs: 'commenters: [User]',
|
||||||
viewableBy: ['guests'],
|
viewableBy: ['guests'],
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import SimpleSchema from 'simpl-schema';
|
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
|
||||||
|
|
||||||
const Events = new Mongo.Collection('events');
|
const Events = new Mongo.Collection('events');
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ You also need to load Bootstrap's CSS separately.
|
||||||
Example schema:
|
Example schema:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import SimpleSchema from 'simpl-schema';
|
|
||||||
import BodyFormControl from './components/BodyFormControl.jsx';
|
import BodyFormControl from './components/BodyFormControl.jsx';
|
||||||
|
|
||||||
const isLoggedIn = (user) => !!user;
|
const isLoggedIn = (user) => !!user;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import SimpleSchema from 'simpl-schema';
|
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
|
||||||
|
|
||||||
if (typeof SimpleSchema !== "undefined") {
|
if (typeof SimpleSchema !== "undefined") {
|
||||||
SimpleSchema.extendOptions({
|
SimpleSchema.extendOptions({
|
||||||
|
|
|
@ -15,7 +15,8 @@ Package.onUse(function(api) {
|
||||||
|
|
||||||
'ecmascript',
|
'ecmascript',
|
||||||
'check',
|
'check',
|
||||||
'aldeed:collection2-core@2.0.0',
|
'aldeed:simple-schema@1.5.3',
|
||||||
|
'aldeed:collection2@2.8.0',
|
||||||
'fourseven:scss@3.8.0'
|
'fourseven:scss@3.8.0'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import SimpleSchema from 'simpl-schema';
|
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
|
||||||
import { GraphQLSchema } from './graphql.js';
|
import { GraphQLSchema } from './graphql.js';
|
||||||
import { Utils } from './utils.js';
|
import { Utils } from './utils.js';
|
||||||
import { runCallbacks } from './callbacks.js';
|
import { runCallbacks } from './callbacks.js';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import SimpleSchema from 'simpl-schema';
|
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Kick off the global namespace for Telescope.
|
* @summary Kick off the global namespace for Telescope.
|
||||||
|
|
|
@ -7,25 +7,24 @@ Utilities to generate the app's GraphQL schema
|
||||||
import deepmerge from 'deepmerge';
|
import deepmerge from 'deepmerge';
|
||||||
import GraphQLJSON from 'graphql-type-json';
|
import GraphQLJSON from 'graphql-type-json';
|
||||||
import GraphQLDate from 'graphql-date';
|
import GraphQLDate from 'graphql-date';
|
||||||
|
|
||||||
import { Utils } from './utils.js';
|
import { Utils } from './utils.js';
|
||||||
|
|
||||||
// convert a JSON schema to a GraphQL schema
|
// convert a JSON schema to a GraphQL schema
|
||||||
const jsTypeToGraphQLType = type => {
|
const jsTypeToGraphQLType = typeName => {
|
||||||
switch (type) {
|
switch (typeName) {
|
||||||
case String:
|
case "Number":
|
||||||
return "String";
|
|
||||||
case Date:
|
|
||||||
return "Date";
|
|
||||||
case Number:
|
|
||||||
return "Float";
|
return "Float";
|
||||||
case Boolean:
|
|
||||||
return "Boolean";
|
|
||||||
// assume all arrays contains strings for now
|
// assume all arrays contains strings for now
|
||||||
case Array:
|
case "Array":
|
||||||
return "[String]";
|
return "[String]";
|
||||||
case Object:
|
|
||||||
default:
|
case "Object":
|
||||||
return "???";
|
return "???";
|
||||||
|
|
||||||
|
default:
|
||||||
|
return typeName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +94,8 @@ export const GraphQLSchema = {
|
||||||
|
|
||||||
_.forEach(schema, (field, key) => {
|
_.forEach(schema, (field, key) => {
|
||||||
// console.log(field, key)
|
// console.log(field, key)
|
||||||
const fieldType = jsTypeToGraphQLType(field.type.definitions[0].type);
|
const fieldType = jsTypeToGraphQLType(field.type.name);
|
||||||
|
|
||||||
if (key.indexOf('$') === -1 && fieldType !== "???") { // skip fields with "$" and unknown fields
|
if (key.indexOf('$') === -1 && fieldType !== "???") { // skip fields with "$" and unknown fields
|
||||||
|
|
||||||
// 1. main schema
|
// 1. main schema
|
||||||
|
|
|
@ -1,25 +1,14 @@
|
||||||
import { getSetting } from './settings.js';
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Babel polyfill for SimpleSchema. See https://github.com/aldeed/node-simple-schema/issues/33
|
|
||||||
|
|
||||||
*/
|
|
||||||
Array.includes = function() {
|
|
||||||
let [first, ...rest] = arguments;
|
|
||||||
return Array.prototype.includes.apply(first, rest);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
intl polyfill. See https://github.com/andyearnshaw/Intl.js/
|
intl polyfill. See https://github.com/andyearnshaw/Intl.js/
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const areIntlLocalesSupported = require('intl-locales-supported');
|
import { getSetting } from './settings.js';
|
||||||
|
|
||||||
const localesMyAppSupports = [
|
var areIntlLocalesSupported = require('intl-locales-supported');
|
||||||
|
|
||||||
|
var localesMyAppSupports = [
|
||||||
getSetting("locale", "en")
|
getSetting("locale", "en")
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -28,7 +17,7 @@ if (global.Intl) {
|
||||||
if (!areIntlLocalesSupported(localesMyAppSupports)) {
|
if (!areIntlLocalesSupported(localesMyAppSupports)) {
|
||||||
// `Intl` exists, but it doesn't have the data we need, so load the
|
// `Intl` exists, but it doesn't have the data we need, so load the
|
||||||
// polyfill and replace the constructors with need with the polyfill's.
|
// polyfill and replace the constructors with need with the polyfill's.
|
||||||
const IntlPolyfill = require('intl');
|
var IntlPolyfill = require('intl');
|
||||||
Intl.NumberFormat = IntlPolyfill.NumberFormat;
|
Intl.NumberFormat = IntlPolyfill.NumberFormat;
|
||||||
Intl.DateTimeFormat = IntlPolyfill.DateTimeFormat;
|
Intl.DateTimeFormat = IntlPolyfill.DateTimeFormat;
|
||||||
}
|
}
|
|
@ -6,7 +6,7 @@ import './settings.js';
|
||||||
import './collections.js';
|
import './collections.js';
|
||||||
import './deep.js';
|
import './deep.js';
|
||||||
import './deep_extend.js';
|
import './deep_extend.js';
|
||||||
import './polyfills.js';
|
import './intl-polyfill.js';
|
||||||
import './graphql.js';
|
import './graphql.js';
|
||||||
import './icons.js';
|
import './icons.js';
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ If the mutation call is not trusted (i.e. it comes from a GraphQL mutation),
|
||||||
we'll run all validate steps:
|
we'll run all validate steps:
|
||||||
|
|
||||||
- Check that the current user has permission to insert/edit each field.
|
- Check that the current user has permission to insert/edit each field.
|
||||||
- Validate document against collection schema.
|
|
||||||
- Add userId to document (insert only).
|
- Add userId to document (insert only).
|
||||||
- Run validation callbacks.
|
- Run validation callbacks.
|
||||||
|
|
||||||
|
@ -36,6 +35,9 @@ export const newMutation = ({ collection, document, currentUser, validate, conte
|
||||||
console.log(collection._name)
|
console.log(collection._name)
|
||||||
console.log(document)
|
console.log(document)
|
||||||
|
|
||||||
|
// we don't want to modify the original document
|
||||||
|
let newDocument = Object.assign({}, document);
|
||||||
|
|
||||||
const collectionName = collection._name;
|
const collectionName = collection._name;
|
||||||
const schema = collection.simpleSchema()._schema;
|
const schema = collection.simpleSchema()._schema;
|
||||||
|
|
||||||
|
@ -43,23 +45,20 @@ export const newMutation = ({ collection, document, currentUser, validate, conte
|
||||||
if (validate) {
|
if (validate) {
|
||||||
|
|
||||||
// check that the current user has permission to insert each field
|
// check that the current user has permission to insert each field
|
||||||
_.keys(document).forEach(function (fieldName) {
|
_.keys(newDocument).forEach(function (fieldName) {
|
||||||
var field = schema[fieldName];
|
var field = schema[fieldName];
|
||||||
if (!context.Users.canInsertField (currentUser, field)) {
|
if (!context.Users.canInsertField (currentUser, field)) {
|
||||||
throw new Meteor.Error('disallowed_property', `disallowed_property_detected: ${fieldName}`);
|
throw new Meteor.Error('disallowed_property', `disallowed_property_detected: ${fieldName}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// validate document against schema
|
|
||||||
collection.simpleSchema().namedContext(`${collectionName}.new`).validate(document);
|
|
||||||
|
|
||||||
// run validation callbacks
|
// run validation callbacks
|
||||||
document = runCallbacks(`${collectionName}.new.validate`, document, currentUser);
|
newDocument = runCallbacks(`${collectionName}.new.validate`, newDocument, currentUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if userId field is in the schema and add it to document if needed
|
// check if userId field is in the schema and add it to document if needed
|
||||||
const userIdInSchema = Object.keys(schema).find(key => key === 'userId');
|
const userIdInSchema = Object.keys(schema).find(key => key === 'userId');
|
||||||
if (!!userIdInSchema && !document.userId) document.userId = currentUser._id;
|
if (!!userIdInSchema && !newDocument.userId) newDocument.userId = currentUser._id;
|
||||||
|
|
||||||
// TODO: find that info in GraphQL mutations
|
// TODO: find that info in GraphQL mutations
|
||||||
// if (Meteor.isServer && this.connection) {
|
// if (Meteor.isServer && this.connection) {
|
||||||
|
@ -68,23 +67,22 @@ export const newMutation = ({ collection, document, currentUser, validate, conte
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// run sync callbacks
|
// run sync callbacks
|
||||||
document = runCallbacks(`${collectionName}.new.sync`, document, currentUser);
|
newDocument = runCallbacks(`${collectionName}.new.sync`, newDocument, currentUser);
|
||||||
|
|
||||||
// add _id to document
|
// add _id to document
|
||||||
// note: use {...document} to "enable" Object.prototype (see https://cl.ly/1N1m2d0y3u1A)
|
newDocument._id = collection.insert(newDocument);
|
||||||
// see https://github.com/aldeed/meteor-collection2-core/issues/8
|
|
||||||
document._id = collection.insert({...document});
|
|
||||||
|
|
||||||
// get fresh copy of document from db
|
// get fresh copy of document from db
|
||||||
const newDocument = collection.findOne(document._id);
|
const insertedDocument = collection.findOne(newDocument._id);
|
||||||
|
|
||||||
// run async callbacks
|
// run async callbacks
|
||||||
// note: query for document to get fresh document with collection-hooks effects applied
|
// note: query for document to get fresh document with collection-hooks effects applied
|
||||||
runCallbacksAsync(`${collectionName}.new.async`, newDocument, currentUser);
|
runCallbacksAsync(`${collectionName}.new.async`, insertedDocument, currentUser);
|
||||||
|
|
||||||
console.log("// new mutation finished:")
|
console.log("// new mutation finished:")
|
||||||
console.log(newDocument)
|
console.log(newDocument)
|
||||||
return document;
|
|
||||||
|
return newDocument;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const editMutation = ({ collection, documentId, set, unset, currentUser, validate, context }) => {
|
export const editMutation = ({ collection, documentId, set, unset, currentUser, validate, context }) => {
|
||||||
|
@ -110,15 +108,12 @@ export const editMutation = ({ collection, documentId, set, unset, currentUser,
|
||||||
// check that the current user has permission to edit each field
|
// check that the current user has permission to edit each field
|
||||||
const modifiedProperties = _.keys(set).concat(_.keys(unset));
|
const modifiedProperties = _.keys(set).concat(_.keys(unset));
|
||||||
modifiedProperties.forEach(function (fieldName) {
|
modifiedProperties.forEach(function (fieldName) {
|
||||||
const field = schema[fieldName];
|
var field = schema[fieldName];
|
||||||
if (!context.Users.canEditField(currentUser, field, document)) {
|
if (!context.Users.canEditField(currentUser, field, document)) {
|
||||||
throw new Meteor.Error('disallowed_property', `disallowed_property_detected: ${fieldName}`);
|
throw new Meteor.Error('disallowed_property', `disallowed_property_detected: ${fieldName}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// validate modifier against schema
|
|
||||||
collection.simpleSchema().namedContext(`${collectionName}.edit`).validate(modifier, {modifier: true});
|
|
||||||
|
|
||||||
// run validation callbacks
|
// run validation callbacks
|
||||||
modifier = runCallbacks(`${collectionName}.edit.validate`, modifier, document, currentUser);
|
modifier = runCallbacks(`${collectionName}.edit.validate`, modifier, document, currentUser);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,10 @@ Package.onUse(function (api) {
|
||||||
|
|
||||||
// Third-party packages
|
// Third-party packages
|
||||||
|
|
||||||
'aldeed:collection2-core@2.0.0',
|
'aldeed:simple-schema@1.5.3',
|
||||||
|
'aldeed:collection2@2.10.0',
|
||||||
'meteorhacks:picker@1.0.3',
|
'meteorhacks:picker@1.0.3',
|
||||||
// 'dburles:collection-helpers@1.0.4',
|
'dburles:collection-helpers@1.0.4',
|
||||||
'percolatestudio:synced-cron@1.1.0',
|
'percolatestudio:synced-cron@1.1.0',
|
||||||
'jparker:gravatar@0.4.1',
|
'jparker:gravatar@0.4.1',
|
||||||
// 'kadira:flow-router-ssr@3.13.0',
|
// 'kadira:flow-router-ssr@3.13.0',
|
||||||
|
|
|
@ -19,7 +19,7 @@ const Meteor = typeof Meteor !== "undefined" ? Meteor : {
|
||||||
methods: returnEmptyObject
|
methods: returnEmptyObject
|
||||||
};
|
};
|
||||||
|
|
||||||
// const SimpleSchema = typeof SimpleSchema !== "undefined" ? SimpleSchema : returnEmptyObject;
|
const SimpleSchema = typeof SimpleSchema !== "undefined" ? SimpleSchema : returnEmptyObject;
|
||||||
|
|
||||||
const Foo = "bar"
|
const Foo = "bar"
|
||||||
export { Mongo, Foo }
|
export { Mongo, Foo }
|
||||||
|
|
|
@ -13,8 +13,7 @@ Users.addField([
|
||||||
{
|
{
|
||||||
fieldName: '__subscribers',
|
fieldName: '__subscribers',
|
||||||
fieldSchema: {
|
fieldSchema: {
|
||||||
type: Array,
|
type: [String],
|
||||||
blackbox: true,
|
|
||||||
optional: true,
|
optional: true,
|
||||||
hidden: true, // never show this,
|
hidden: true, // never show this,
|
||||||
// publish: true,
|
// publish: true,
|
||||||
|
@ -41,8 +40,7 @@ if (typeof Package['nova:posts'] !== "undefined") {
|
||||||
{
|
{
|
||||||
fieldName: 'subscribers',
|
fieldName: 'subscribers',
|
||||||
fieldSchema: {
|
fieldSchema: {
|
||||||
type: Array,
|
type: [String],
|
||||||
blackbox: true,
|
|
||||||
optional: true,
|
optional: true,
|
||||||
hidden: true, // never show this
|
hidden: true, // never show this
|
||||||
// publish: true,
|
// publish: true,
|
||||||
|
@ -71,8 +69,7 @@ if (typeof Package['nova:categories'] !== "undefined") {
|
||||||
{
|
{
|
||||||
fieldName: 'subscribers',
|
fieldName: 'subscribers',
|
||||||
fieldSchema: {
|
fieldSchema: {
|
||||||
type: Array,
|
type: [String],
|
||||||
blackbox: true,
|
|
||||||
optional: true,
|
optional: true,
|
||||||
hidden: true, // never show this
|
hidden: true, // never show this
|
||||||
// publish: true,
|
// publish: true,
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import SimpleSchema from 'simpl-schema';
|
|
||||||
import Users from './collection.js';
|
import Users from './collection.js';
|
||||||
|
|
||||||
const adminGroup = {
|
const adminGroup = {
|
||||||
|
@ -27,12 +26,7 @@ const schema = {
|
||||||
preload: true,
|
preload: true,
|
||||||
},
|
},
|
||||||
emails: {
|
emails: {
|
||||||
type: Array,
|
type: [Object],
|
||||||
blackbox: true,
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
"emails.$": {
|
|
||||||
type: Object,
|
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
"emails.$.address": {
|
"emails.$.address": {
|
||||||
|
@ -144,6 +138,7 @@ const schema = {
|
||||||
*/
|
*/
|
||||||
__karma: {
|
__karma: {
|
||||||
type: Number,
|
type: Number,
|
||||||
|
decimal: true,
|
||||||
publish: true,
|
publish: true,
|
||||||
optional: true,
|
optional: true,
|
||||||
viewableBy: ['guests'],
|
viewableBy: ['guests'],
|
||||||
|
@ -189,8 +184,7 @@ const schema = {
|
||||||
Groups
|
Groups
|
||||||
*/
|
*/
|
||||||
__groups: {
|
__groups: {
|
||||||
type: Array,
|
type: [String],
|
||||||
blackbox: true,
|
|
||||||
optional: true,
|
optional: true,
|
||||||
control: "checkboxgroup",
|
control: "checkboxgroup",
|
||||||
insertableBy: ['admins'],
|
insertableBy: ['admins'],
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import SimpleSchema from 'simpl-schema';
|
|
||||||
import Users from "meteor/nova:users";
|
import Users from "meteor/nova:users";
|
||||||
import Posts from "meteor/nova:posts";
|
import Posts from "meteor/nova:posts";
|
||||||
import Comments from "meteor/nova:comments";
|
import Comments from "meteor/nova:comments";
|
||||||
|
@ -28,77 +27,52 @@ Users.addField([
|
||||||
{
|
{
|
||||||
fieldName: '__upvotedComments',
|
fieldName: '__upvotedComments',
|
||||||
fieldSchema: {
|
fieldSchema: {
|
||||||
type: Array,
|
type: [voteSchema],
|
||||||
publish: false,
|
publish: false,
|
||||||
optional: true,
|
optional: true,
|
||||||
viewableBy: ['guests'],
|
viewableBy: ['guests'],
|
||||||
resolveAs: '__upvotedComments: [Vote]',
|
resolveAs: '__upvotedComments: [Vote]',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
fieldName: "__upvotedComments.$",
|
|
||||||
fieldSchema: {
|
|
||||||
type: voteSchema,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
An array containing posts upvotes
|
An array containing posts upvotes
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
fieldName: '__upvotedPosts',
|
fieldName: '__upvotedPosts',
|
||||||
fieldSchema: {
|
fieldSchema: {
|
||||||
type: Array,
|
type: [voteSchema],
|
||||||
publish: false,
|
publish: false,
|
||||||
optional: true,
|
optional: true,
|
||||||
viewableBy: ['guests'],
|
viewableBy: ['guests'],
|
||||||
resolveAs: '__upvotedPosts: [Vote]',
|
resolveAs: '__upvotedPosts: [Vote]',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
fieldName: "__upvotedPosts.$",
|
|
||||||
fieldSchema: {
|
|
||||||
type: voteSchema,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
An array containing comment downvotes
|
An array containing comment downvotes
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
fieldName: '__downvotedComments',
|
fieldName: '__downvotedComments',
|
||||||
fieldSchema: {
|
fieldSchema: {
|
||||||
type: Array,
|
type: [voteSchema],
|
||||||
publish: false,
|
publish: false,
|
||||||
optional: true,
|
optional: true,
|
||||||
viewableBy: ['guests'],
|
viewableBy: ['guests'],
|
||||||
resolveAs: '__downvotedComments: [Vote]',
|
resolveAs: '__downvotedComments: [Vote]',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
fieldName: "__downvotedComments.$",
|
|
||||||
fieldSchema: {
|
|
||||||
type: voteSchema,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
An array containing posts downvotes
|
An array containing posts downvotes
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
fieldName: '__downvotedPosts',
|
fieldName: '__downvotedPosts',
|
||||||
fieldSchema: {
|
fieldSchema: {
|
||||||
type: Array,
|
type: [voteSchema],
|
||||||
publish: false,
|
publish: false,
|
||||||
optional: true,
|
optional: true,
|
||||||
viewableBy: ['guests'],
|
viewableBy: ['guests'],
|
||||||
resolveAs: '__downvotedPosts: [Vote]',
|
resolveAs: '__downvotedPosts: [Vote]',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
fieldName: "__downvotedPosts.$",
|
|
||||||
fieldSchema: {
|
|
||||||
type: voteSchema,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Posts.addField([
|
Posts.addField([
|
||||||
|
@ -121,19 +95,13 @@ Posts.addField([
|
||||||
{
|
{
|
||||||
fieldName: "upvoters",
|
fieldName: "upvoters",
|
||||||
fieldSchema: {
|
fieldSchema: {
|
||||||
type: Array,
|
type: [String],
|
||||||
optional: true,
|
optional: true,
|
||||||
publish: true,
|
publish: true,
|
||||||
viewableBy: ['guests'],
|
viewableBy: ['guests'],
|
||||||
resolveAs: 'upvoters: [User]',
|
resolveAs: 'upvoters: [User]',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
fieldName: "upvoters.$",
|
|
||||||
fieldSchema: {
|
|
||||||
type: String,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
How many downvotes the post has received
|
How many downvotes the post has received
|
||||||
*/
|
*/
|
||||||
|
@ -153,20 +121,13 @@ Posts.addField([
|
||||||
{
|
{
|
||||||
fieldName: "downvoters",
|
fieldName: "downvoters",
|
||||||
fieldSchema: {
|
fieldSchema: {
|
||||||
type: Array,
|
type: [String],
|
||||||
optional: true,
|
optional: true,
|
||||||
publish: true,
|
publish: true,
|
||||||
viewableBy: ['guests'],
|
viewableBy: ['guests'],
|
||||||
resolveAs: 'downvoters: [User]',
|
resolveAs: 'downvoters: [User]',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
fieldName: "downvoters.$",
|
|
||||||
fieldSchema: {
|
|
||||||
type: String,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The post's base score (not factoring in the post's age)
|
The post's base score (not factoring in the post's age)
|
||||||
*/
|
*/
|
||||||
|
@ -174,6 +135,7 @@ Posts.addField([
|
||||||
fieldName: "baseScore",
|
fieldName: "baseScore",
|
||||||
fieldSchema: {
|
fieldSchema: {
|
||||||
type: Number,
|
type: Number,
|
||||||
|
decimal: true,
|
||||||
optional: true,
|
optional: true,
|
||||||
publish: true,
|
publish: true,
|
||||||
defaultValue: 0,
|
defaultValue: 0,
|
||||||
|
@ -187,6 +149,7 @@ Posts.addField([
|
||||||
fieldName: "score",
|
fieldName: "score",
|
||||||
fieldSchema: {
|
fieldSchema: {
|
||||||
type: Number,
|
type: Number,
|
||||||
|
decimal: true,
|
||||||
optional: true,
|
optional: true,
|
||||||
publish: true,
|
publish: true,
|
||||||
defaultValue: 0,
|
defaultValue: 0,
|
||||||
|
@ -215,19 +178,13 @@ Comments.addField([
|
||||||
{
|
{
|
||||||
fieldName: "upvoters",
|
fieldName: "upvoters",
|
||||||
fieldSchema: {
|
fieldSchema: {
|
||||||
type: Array,
|
type: [String],
|
||||||
optional: true,
|
optional: true,
|
||||||
publish: true,
|
publish: true,
|
||||||
viewableBy: ['guests'],
|
viewableBy: ['guests'],
|
||||||
resolveAs: 'upvoters: [User]',
|
resolveAs: 'upvoters: [User]',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
fieldName: "upvoters.$",
|
|
||||||
fieldSchema: {
|
|
||||||
type: String,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
The number of downvotes the comment has received
|
The number of downvotes the comment has received
|
||||||
*/
|
*/
|
||||||
|
@ -247,19 +204,13 @@ Comments.addField([
|
||||||
{
|
{
|
||||||
fieldName: "downvoters",
|
fieldName: "downvoters",
|
||||||
fieldSchema: {
|
fieldSchema: {
|
||||||
type: Array,
|
type: [String],
|
||||||
optional: true,
|
optional: true,
|
||||||
publish: true,
|
publish: true,
|
||||||
viewableBy: ['guests'],
|
viewableBy: ['guests'],
|
||||||
resolveAs: 'downvoters: [User]',
|
resolveAs: 'downvoters: [User]',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
fieldName: "downvoters.$",
|
|
||||||
fieldSchema: {
|
|
||||||
type: String,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
The comment's base score (not factoring in the comment's age)
|
The comment's base score (not factoring in the comment's age)
|
||||||
*/
|
*/
|
||||||
|
@ -267,6 +218,7 @@ Comments.addField([
|
||||||
fieldName: "baseScore",
|
fieldName: "baseScore",
|
||||||
fieldSchema: {
|
fieldSchema: {
|
||||||
type: Number,
|
type: Number,
|
||||||
|
decimal: true,
|
||||||
optional: true,
|
optional: true,
|
||||||
publish: true,
|
publish: true,
|
||||||
defaultValue: 0,
|
defaultValue: 0,
|
||||||
|
@ -280,6 +232,7 @@ Comments.addField([
|
||||||
fieldName: "score",
|
fieldName: "score",
|
||||||
fieldSchema: {
|
fieldSchema: {
|
||||||
type: Number,
|
type: Number,
|
||||||
|
decimal: true,
|
||||||
optional: true,
|
optional: true,
|
||||||
publish: true,
|
publish: true,
|
||||||
defaultValue: 0,
|
defaultValue: 0,
|
||||||
|
@ -287,3 +240,4 @@ Comments.addField([
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue