prettier commit

This commit is contained in:
eric-burel 2019-02-05 19:36:13 +01:00
parent c7c5091a22
commit 083a7d676b
33 changed files with 356 additions and 317 deletions

View file

@ -3,12 +3,12 @@ Package.describe({
version: '1.12.14',
summary: 'Accounts UI for React in Meteor 1.3+',
git: 'https://github.com/studiointeract/accounts-ui',
documentation: 'README.md'
documentation: 'README.md',
});
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use('vulcan:core@1.12.14');
api.use('ecmascript');
@ -23,8 +23,8 @@ Package.onUse(function(api) {
api.imply('accounts-base');
api.use('accounts-oauth', {weak: true});
api.use('accounts-password', {weak: true});
api.use('accounts-oauth', { weak: true });
api.use('accounts-password', { weak: true });
api.mainModule('main_client.js', 'client');
api.mainModule('main_server.js', 'server');

View file

@ -2,27 +2,21 @@ Package.describe({
name: 'vulcan:admin',
summary: 'Vulcan components package',
version: '1.12.14',
git: 'https://github.com/VulcanJS/Vulcan.git'
git: 'https://github.com/VulcanJS/Vulcan.git',
});
Package.onUse(function (api) {
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use([
'fourseven:scss@4.10.0',
'dynamic-import@0.1.1',
// Vulcan packages
'vulcan:core@1.12.14',
]);
api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client');
api.addFiles([
'lib/stylesheets/style.scss'
], ['client']);
api.addFiles(['lib/stylesheets/style.scss'], ['client']);
});

View file

@ -2,18 +2,14 @@ Package.describe({
name: 'vulcan:cloudinary',
summary: 'Vulcan file upload package.',
version: '1.12.14',
git: 'https://github.com/VulcanJS/Vulcan.git'
git: 'https://github.com/VulcanJS/Vulcan.git',
});
Package.onUse(function (api) {
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use([
'vulcan:core@1.12.14'
]);
api.use(['vulcan:core@1.12.14']);
api.mainModule('lib/client/main.js', 'client');
api.mainModule('lib/server/main.js', 'server');
});

View file

@ -2,10 +2,10 @@ Package.describe({
name: 'vulcan:core',
summary: 'Vulcan core package',
version: '1.12.14',
git: 'https://github.com/VulcanJS/Vulcan.git'
git: 'https://github.com/VulcanJS/Vulcan.git',
});
Package.onUse(function (api) {
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use([
@ -13,7 +13,7 @@ Package.onUse(function (api) {
'vulcan:i18n@1.12.14',
'vulcan:users@1.12.14',
'vulcan:routing@1.12.14',
'vulcan:debug@1.12.14'
'vulcan:debug@1.12.14',
]);
api.imply(['vulcan:lib@1.12.14']);
@ -22,7 +22,7 @@ Package.onUse(function (api) {
api.mainModule('lib/client/main.js', 'client');
});
Package.onTest(function (api) {
Package.onTest(function(api) {
api.use(['ecmascript', 'meteortesting:mocha', 'vulcan:test', 'vulcan:core']);
api.mainModule('./test/index.js');
});

View file

@ -3,15 +3,13 @@ Package.describe({
summary: 'Vulcan debug package',
version: '1.12.14',
git: 'https://github.com/VulcanJS/Vulcan.git',
debugOnly: true
debugOnly: true,
});
Package.onUse(function (api) {
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use([
'fourseven:scss@4.10.0',
'dynamic-import@0.1.1',
@ -19,14 +17,10 @@ Package.onUse(function (api) {
'vulcan:lib@1.12.14',
'vulcan:email@1.12.14',
]);
api.addFiles([
'lib/stylesheets/debug.scss'
], ['client']);
api.addFiles(['lib/stylesheets/debug.scss'], ['client']);
api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client');
});

View file

@ -2,18 +2,14 @@ Package.describe({
name: 'vulcan:email',
summary: 'Vulcan email package',
version: '1.12.14',
git: 'https://github.com/VulcanJS/Vulcan.git'
git: 'https://github.com/VulcanJS/Vulcan.git',
});
Package.onUse(function (api) {
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use([
'vulcan:lib@1.12.14'
]);
api.use(['vulcan:lib@1.12.14']);
api.mainModule('lib/server.js', 'server');
api.mainModule('lib/client.js', 'client');
});

View file

@ -2,25 +2,16 @@ Package.describe({
name: 'vulcan:embed',
summary: 'Vulcan Embed package',
version: '1.12.14',
git: 'https://github.com/VulcanJS/Vulcan.git'
git: 'https://github.com/VulcanJS/Vulcan.git',
});
Package.onUse( function(api) {
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use([
'http',
'vulcan:core@1.12.14',
'fourseven:scss@4.10.0'
]);
api.use(['http', 'vulcan:core@1.12.14', 'fourseven:scss@4.10.0']);
api.addFiles([
'lib/stylesheets/embedly.scss'
], ['client']);
api.addFiles(['lib/stylesheets/embedly.scss'], ['client']);
api.mainModule('lib/client/main.js', 'client');
api.mainModule('lib/server/main.js', 'server');
});

View file

@ -2,21 +2,14 @@ Package.describe({
name: 'vulcan:errors-sentry',
summary: 'Vulcan Sentry error tracking package',
version: '1.12.14',
git: 'https://github.com/VulcanJS/Vulcan.git'
git: 'https://github.com/VulcanJS/Vulcan.git',
});
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use([
'ecmascript',
'vulcan:core@1.12.14',
'vulcan:users@1.12.14',
'vulcan:errors@1.12.14',
]);
api.use(['ecmascript', 'vulcan:core@1.12.14', 'vulcan:users@1.12.14', 'vulcan:errors@1.12.14']);
api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client');
});

View file

@ -2,19 +2,14 @@ Package.describe({
name: 'vulcan:errors',
summary: 'Vulcan error tracking package',
version: '1.12.14',
git: 'https://github.com/VulcanJS/Vulcan.git'
git: 'https://github.com/VulcanJS/Vulcan.git',
});
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use([
'ecmascript',
'vulcan:core@1.12.14',
]);
api.use(['ecmascript', 'vulcan:core@1.12.14']);
api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client');
});

View file

@ -2,19 +2,14 @@ Package.describe({
name: 'vulcan:events-ga',
summary: 'Vulcan Google Analytics event tracking package',
version: '1.12.14',
git: 'https://github.com/VulcanJS/Vulcan.git'
git: 'https://github.com/VulcanJS/Vulcan.git',
});
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use([
'vulcan:core@1.12.14',
'vulcan:events@1.12.14',
]);
api.use(['vulcan:core@1.12.14', 'vulcan:events@1.12.14']);
api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client');
});

View file

@ -2,19 +2,14 @@ Package.describe({
name: 'vulcan:events-intercom',
summary: 'Vulcan Intercom integration package.',
version: '1.12.14',
git: 'https://github.com/VulcanJS/Vulcan.git'
git: 'https://github.com/VulcanJS/Vulcan.git',
});
Package.onUse(function (api) {
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use([
'vulcan:core@1.12.14',
'vulcan:events@1.12.14'
]);
api.use(['vulcan:core@1.12.14', 'vulcan:events@1.12.14']);
api.mainModule('lib/client/main.js', 'client');
api.mainModule('lib/server/main.js', 'server');
});

View file

@ -2,19 +2,14 @@ Package.describe({
name: 'vulcan:events-internal',
summary: 'Vulcan internal event tracking package',
version: '1.12.14',
git: 'https://github.com/VulcanJS/Vulcan.git'
git: 'https://github.com/VulcanJS/Vulcan.git',
});
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use([
'vulcan:core@1.12.14',
'vulcan:events@1.12.14',
]);
api.use(['vulcan:core@1.12.14', 'vulcan:events@1.12.14']);
api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client');
});

View file

@ -2,19 +2,14 @@ Package.describe({
name: 'vulcan:events-segment',
summary: 'Vulcan Segment',
version: '1.12.14',
git: 'https://github.com/VulcanJS/Vulcan.git'
git: 'https://github.com/VulcanJS/Vulcan.git',
});
Package.onUse(function (api) {
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use([
'vulcan:core@1.12.14',
'vulcan:events@1.12.14',
]);
api.use(['vulcan:core@1.12.14', 'vulcan:events@1.12.14']);
api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client');
});

View file

@ -2,18 +2,14 @@ Package.describe({
name: 'vulcan:events',
summary: 'Vulcan event tracking package',
version: '1.12.14',
git: 'https://github.com/VulcanJS/Vulcan.git'
git: 'https://github.com/VulcanJS/Vulcan.git',
});
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use([
'vulcan:core@1.12.14',
]);
api.use(['vulcan:core@1.12.14']);
api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client');
});

View file

@ -2,18 +2,13 @@ Package.describe({
name: 'vulcan:forms-tags',
summary: 'Vulcan tag input package',
version: '1.12.14',
git: 'https://github.com/VulcanJS/Vulcan.git'
git: 'https://github.com/VulcanJS/Vulcan.git',
});
Package.onUse( function(api) {
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use([
'vulcan:core@1.12.14',
'vulcan:forms@1.12.14'
]);
api.use(['vulcan:core@1.12.14', 'vulcan:forms@1.12.14']);
api.mainModule('lib/export.js', ['client', 'server']);
});

View file

@ -2,23 +2,15 @@ Package.describe({
name: 'vulcan:forms-upload',
summary: 'Vulcan package extending vulcan:forms to upload images to Cloudinary from a drop zone.',
version: '1.12.14',
git: 'https://github.com/xavcz/nova-forms-upload.git'
git: 'https://github.com/xavcz/nova-forms-upload.git',
});
Package.onUse( function(api) {
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use([
'vulcan:core@1.12.14',
'vulcan:forms@1.12.14',
'fourseven:scss@4.10.0'
]);
api.use(['vulcan:core@1.12.14', 'vulcan:forms@1.12.14', 'fourseven:scss@4.10.0']);
api.addFiles([
'lib/Upload.scss'
], 'client');
api.addFiles(['lib/Upload.scss'], 'client');
api.mainModule('lib/modules.js', ['client', 'server']);
});

View file

@ -2,10 +2,10 @@ Package.describe({
name: 'vulcan:forms',
summary: 'Form containers for React',
version: '1.12.14',
git: 'https://github.com/meteor-utilities/react-form-containers.git'
git: 'https://github.com/meteor-utilities/react-form-containers.git',
});
Package.onUse(function (api) {
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use(['vulcan:core@1.12.14']);
@ -14,7 +14,7 @@ Package.onUse(function (api) {
api.mainModule('lib/server/main.js', ['server']);
});
Package.onTest(function (api) {
Package.onTest(function(api) {
api.use(['ecmascript', 'meteortesting:mocha', 'vulcan:test', 'vulcan:forms']);
api.mainModule('./test/index.js');
});

View file

@ -2,18 +2,13 @@ Package.describe({
name: 'vulcan:i18n-en-us',
summary: 'Vulcan i18n package (en_US)',
version: '1.12.14',
git: 'https://github.com/VulcanJS/Vulcan.git'
git: 'https://github.com/VulcanJS/Vulcan.git',
});
Package.onUse(function (api) {
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use([
'vulcan:core@1.12.14'
]);
api.use(['vulcan:core@1.12.14']);
api.addFiles([
'lib/en_US.js'
], ['client', 'server']);
api.addFiles(['lib/en_US.js'], ['client', 'server']);
});

View file

@ -2,18 +2,13 @@ Package.describe({
name: 'vulcan:i18n-es-es',
summary: 'Vulcan i18n package (es_ES)',
version: '1.12.14',
git: 'https://github.com/VulcanJS/Vulcan.git'
git: 'https://github.com/VulcanJS/Vulcan.git',
});
Package.onUse(function (api) {
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use([
'vulcan:core@1.12.14'
]);
api.use(['vulcan:core@1.12.14']);
api.addFiles([
'lib/es_ES.js'
], ['client', 'server']);
api.addFiles(['lib/es_ES.js'], ['client', 'server']);
});

View file

@ -2,18 +2,13 @@ Package.describe({
name: 'vulcan:i18n-fr-fr',
summary: 'Vulcan i18n package (fr_FR)',
version: '1.12.14',
git: 'https://github.com/VulcanJS/Vulcan.git'
git: 'https://github.com/VulcanJS/Vulcan.git',
});
Package.onUse(function (api) {
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use([
'vulcan:core@1.12.14'
]);
api.use(['vulcan:core@1.12.14']);
api.addFiles([
'lib/fr_FR.js'
], ['client', 'server']);
api.addFiles(['lib/fr_FR.js'], ['client', 'server']);
});

View file

@ -2,18 +2,14 @@ Package.describe({
name: 'vulcan:i18n',
summary: 'i18n client polyfill',
version: '1.12.14',
git: 'https://github.com/VulcanJS/Vulcan'
git: 'https://github.com/VulcanJS/Vulcan',
});
Package.onUse(function (api) {
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use([
'vulcan:lib@1.12.14',
]);
api.use(['vulcan:lib@1.12.14']);
api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client');
});

View file

@ -20,7 +20,8 @@ export const Collections = [];
export const getCollection = name =>
Collections.find(
({ options: { collectionName } }) => name === collectionName || name === collectionName.toLowerCase()
({ options: { collectionName } }) =>
name === collectionName || name === collectionName.toLowerCase()
);
// TODO: find more reliable way to get collection name from type name?
@ -105,7 +106,9 @@ Mongo.Collection.prototype.helpers = function(helpers) {
var self = this;
if (self._transform && !self._helpers)
throw new Meteor.Error('Can\'t apply helpers to \'' + self._name + '\' a transform function already exists!');
throw new Meteor.Error(
"Can't apply helpers to '" + self._name + "' a transform function already exists!"
);
if (!self._helpers) {
self._helpers = function Document(doc) {
@ -126,7 +129,7 @@ export const createCollection = options => {
typeName,
collectionName = getCollectionName(typeName),
generateGraphQLSchema = true,
dbCollectionName
dbCollectionName,
} = options;
let { schema } = options;
@ -155,7 +158,7 @@ export const createCollection = options => {
//register individual collection callback
registerCollectionCallback(typeName.toLowerCase());
// if schema has at least one intl field, add intl callback just before
// if schema has at least one intl field, add intl callback just before
// `${collectionName}.collection` callbacks run to make sure it always runs last
if (schemaHasIntlFields(schema)) {
hasIntlFields = true; // we have at least one intl field
@ -163,8 +166,12 @@ export const createCollection = options => {
}
//run schema callbacks and run general callbacks last
schema = runCallbacks({ name: `${typeName.toLowerCase()}.collection`, iterator: schema, properties: { options }});
schema = runCallbacks({ name: '*.collection', iterator: schema, properties: { options }});
schema = runCallbacks({
name: `${typeName.toLowerCase()}.collection`,
iterator: schema,
properties: { options },
});
schema = runCallbacks({ name: '*.collection', iterator: schema, properties: { options } });
if (schema) {
// attach schema to collection
@ -196,20 +203,29 @@ export const createCollection = options => {
let parameters = {
selector: {},
options: {}
options: {},
};
if (collection.defaultView) {
parameters = Utils.deepExtend(true, parameters, collection.defaultView(terms, apolloClient, context));
parameters = Utils.deepExtend(
true,
parameters,
collection.defaultView(terms, apolloClient, context)
);
}
// handle view option
if (terms.view && collection.views[terms.view]) {
const viewFn = collection.views[terms.view];
const view = viewFn(terms, apolloClient, context)
const view = viewFn(terms, apolloClient, context);
let mergedParameters = Utils.deepExtend(true, parameters, view);
if (mergedParameters.options && mergedParameters.options.sort && view.options && view.options.sort) {
if (
mergedParameters.options &&
mergedParameters.options.sort &&
view.options &&
view.options.sort
) {
// If both the default view and the selected view have sort options,
// don't merge them together; take the selected view's sort. (Otherwise
// they merge in the wrong order, so that the default-view's sort takes
@ -254,7 +270,12 @@ export const createCollection = options => {
// note: check that context exists to avoid calling this from withList during SSR
if (Meteor.isServer && context) {
parameters = runCallbacks(`${typeName.toLowerCase()}.parameters.server`, parameters, _.clone(terms), context);
parameters = runCallbacks(
`${typeName.toLowerCase()}.parameters.server`,
parameters,
_.clone(terms),
context
);
// OpenCRUD backwards compatibility
parameters = runCallbacks(
`${collectionName.toLowerCase()}.parameters.server`,
@ -293,12 +314,17 @@ export const createCollection = options => {
if (terms.query) {
const query = escapeStringRegexp(terms.query);
const currentSchema = collection.simpleSchema()._schema;
const searchableFieldNames = _.filter(_.keys(currentSchema), fieldName => currentSchema[fieldName].searchable);
const searchableFieldNames = _.filter(
_.keys(currentSchema),
fieldName => currentSchema[fieldName].searchable
);
if (searchableFieldNames.length) {
parameters = Utils.deepExtend(true, parameters, {
selector: {
$or: searchableFieldNames.map(fieldName => ({ [fieldName]: { $regex: query, $options: 'i' } }))
}
$or: searchableFieldNames.map(fieldName => ({
[fieldName]: { $regex: query, $options: 'i' },
})),
},
});
} else {
// eslint-disable-next-line no-console
@ -332,11 +358,11 @@ function registerCollectionCallback(typeName) {
iterator: { schema: 'the schema of the collection' },
properties: [
{ schema: 'The schema of the collection' },
{ validationErrors: 'An Object that can be used to accumulate validation errors' }
{ validationErrors: 'An Object that can be used to accumulate validation errors' },
],
runs: 'sync',
returns: 'schema',
description: 'Modifies schemas on collection creation'
description: 'Modifies schemas on collection creation',
});
}
@ -346,7 +372,7 @@ registerCallback({
iterator: { schema: 'the schema of the collection' },
properties: [
{ schema: 'The schema of the collection' },
{ validationErrors: 'An object that can be used to accumulate validation errors' }
{ validationErrors: 'An object that can be used to accumulate validation errors' },
],
runs: 'sync',
returns: 'schema',
@ -358,7 +384,6 @@ function addIntlFields(schema) {
Object.keys(schema).forEach(fieldName => {
const fieldSchema = schema[fieldName];
if (isIntlField(fieldSchema)) {
// remove `intl` to avoid treating new _intl field as a field to internationalize
// eslint-disable-next-line no-unused-vars
const { intl, ...propertiesToCopy } = schema[fieldName];
@ -367,13 +392,13 @@ function addIntlFields(schema) {
...propertiesToCopy, // copy properties from regular field
hidden: true,
type: Array,
isIntlData: true
isIntlData: true,
};
delete schema[`${fieldName}_intl`].intl;
schema[`${fieldName}_intl.$`] = {
type: getIntlString()
type: getIntlString(),
};
// if original field is required, enable custom validation function instead of `optional` property

View file

@ -14,7 +14,7 @@ Vulcan.VERSION = '1.12.14';
// ------------------------------------- Schemas -------------------------------- //
SimpleSchema.extendOptions([
'hidden', // hidden: true means the field is never shown in a form no matter what
'hidden', // hidden: true means the field is never shown in a form no matter what
'mustComplete', // mustComplete: true means the field is required to have a complete profile
'form', // extra form properties
'inputProperties', // extra form properties
@ -22,7 +22,7 @@ SimpleSchema.extendOptions([
'control', // SmartForm control (String or React component) (legacy)
'order', // position in the form
'group', // form fieldset group
'onCreate', // field insert callback
'onInsert', // field insert callback (OpenCRUD backwards compatibility)

View file

@ -32,7 +32,12 @@ to the client.
*/
import { runCallbacks, runCallbacksAsync } from '../modules/index.js';
import { validateDocument, validateData, dataToModifier, modifierToData } from '../modules/validation.js';
import {
validateDocument,
validateData,
dataToModifier,
modifierToData,
} from '../modules/validation.js';
import { registerSetting } from '../modules/settings.js';
import { debug, debugGroup, debugGroupEnd } from '../modules/debug.js';
import { throwError } from '../modules/errors.js';
@ -48,8 +53,14 @@ registerSetting('database', 'mongo', 'Which database to use for your back-end');
Create
*/
export const createMutator = async ({ collection, document, data, currentUser, validate, context }) => {
export const createMutator = async ({
collection,
document,
data,
currentUser,
validate,
context,
}) => {
// OpenCRUD backwards compatibility: accept either data or document
// we don't want to modify the original document
document = data || document;
@ -77,10 +88,23 @@ export const createMutator = async ({ collection, document, data, currentUser, v
let validationErrors = [];
validationErrors = validationErrors.concat(validateDocument(document, collection, context));
// run validation callbacks
validationErrors = await runCallbacks({ name: `${typeName.toLowerCase()}.create.validate`, iterator: validationErrors, properties });
validationErrors = await runCallbacks({ name: '*.create.validate', iterator: validationErrors, properties });
validationErrors = await runCallbacks({
name: `${typeName.toLowerCase()}.create.validate`,
iterator: validationErrors,
properties,
});
validationErrors = await runCallbacks({
name: '*.create.validate',
iterator: validationErrors,
properties,
});
// OpenCRUD backwards compatibility
document = await runCallbacks(`${collectionName.toLowerCase()}.new.validate`, document, currentUser, validationErrors);
document = await runCallbacks(
`${collectionName.toLowerCase()}.new.validate`,
document,
currentUser,
validationErrors
);
if (validationErrors.length) {
console.log(validationErrors); // eslint-disable-line no-console
throwError({ id: 'app.validation_error', data: { break: true, errors: validationErrors } });
@ -134,10 +158,18 @@ export const createMutator = async ({ collection, document, data, currentUser, v
Before
*/
document = await runCallbacks({ name: `${typeName.toLowerCase()}.create.before`, iterator: document, properties });
document = await runCallbacks({
name: `${typeName.toLowerCase()}.create.before`,
iterator: document,
properties,
});
document = await runCallbacks({ name: '*.create.before', iterator: document, properties });
// OpenCRUD backwards compatibility
document = await runCallbacks(`${collectionName.toLowerCase()}.new.before`, document, currentUser);
document = await runCallbacks(
`${collectionName.toLowerCase()}.new.before`,
document,
currentUser
);
document = await runCallbacks(`${collectionName.toLowerCase()}.new.sync`, document, currentUser);
/*
@ -153,7 +185,11 @@ export const createMutator = async ({ collection, document, data, currentUser, v
*/
// run any post-operation sync callbacks
document = await runCallbacks({ name: `${typeName.toLowerCase()}.create.after`, iterator: document, properties });
document = await runCallbacks({
name: `${typeName.toLowerCase()}.create.after`,
iterator: document,
properties,
});
document = await runCallbacks({ name: '*.create.after', iterator: document, properties });
// OpenCRUD backwards compatibility
document = await runCallbacks(`${collectionName.toLowerCase()}.new.after`, document, currentUser);
@ -167,10 +203,18 @@ export const createMutator = async ({ collection, document, data, currentUser, v
*/
// note: make sure properties.document is up to date
await runCallbacksAsync({ name: `${typeName.toLowerCase()}.create.async`, properties: { ...properties, document: document } });
await runCallbacksAsync({
name: `${typeName.toLowerCase()}.create.async`,
properties: { ...properties, document: document },
});
await runCallbacksAsync({ name: '*.create.async', properties });
// OpenCRUD backwards compatibility
await runCallbacksAsync(`${collectionName.toLowerCase()}.new.async`, document, currentUser, collection);
await runCallbacksAsync(
`${collectionName.toLowerCase()}.new.async`,
document,
currentUser,
collection
);
endDebugMutator(collectionName, 'Create', { document });
@ -182,8 +226,18 @@ export const createMutator = async ({ collection, document, data, currentUser, v
Update
*/
export const updateMutator = async ({ collection, documentId, selector, data, set = {}, unset = {}, currentUser, validate, context, document: oldDocument }) => {
export const updateMutator = async ({
collection,
documentId,
selector,
data,
set = {},
unset = {},
currentUser,
validate,
context,
document: oldDocument,
}) => {
const { collectionName, typeName } = collection.options;
const schema = collection.simpleSchema()._schema;
@ -225,10 +279,26 @@ export const updateMutator = async ({ collection, documentId, selector, data, se
validationErrors = validationErrors.concat(validateData(data, document, collection, context));
validationErrors = await runCallbacks({ name: `${typeName.toLowerCase()}.update.validate`, iterator: validationErrors, properties });
validationErrors = await runCallbacks({ name: '*.update.validate', iterator: validationErrors, properties });
validationErrors = await runCallbacks({
name: `${typeName.toLowerCase()}.update.validate`,
iterator: validationErrors,
properties,
});
validationErrors = await runCallbacks({
name: '*.update.validate',
iterator: validationErrors,
properties,
});
// OpenCRUD backwards compatibility
data = modifierToData(await runCallbacks(`${collectionName.toLowerCase()}.edit.validate`, dataToModifier(data), document, currentUser, validationErrors));
data = modifierToData(
await runCallbacks(
`${collectionName.toLowerCase()}.edit.validate`,
dataToModifier(data),
document,
currentUser,
validationErrors
)
);
if (validationErrors.length) {
console.log(validationErrors); // eslint-disable-line no-console
@ -247,7 +317,12 @@ export const updateMutator = async ({ collection, documentId, selector, data, se
autoValue = await schema[fieldName].onUpdate(properties); // eslint-disable-line no-await-in-loop
} else if (schema[fieldName].onEdit) {
// OpenCRUD backwards compatibility
autoValue = await schema[fieldName].onEdit(dataToModifier(clone(data)), document, currentUser, document); // eslint-disable-line no-await-in-loop
autoValue = await schema[fieldName].onEdit(
dataToModifier(clone(data)),
document,
currentUser,
document
); // eslint-disable-line no-await-in-loop
}
if (typeof autoValue !== 'undefined') {
data[fieldName] = autoValue;
@ -259,11 +334,31 @@ export const updateMutator = async ({ collection, documentId, selector, data, se
Before
*/
data = await runCallbacks({ name: `${typeName.toLowerCase()}.update.before`, iterator: data, properties });
data = await runCallbacks({
name: `${typeName.toLowerCase()}.update.before`,
iterator: data,
properties,
});
data = await runCallbacks({ name: '*.update.before', iterator: data, properties });
// OpenCRUD backwards compatibility
data = modifierToData(await runCallbacks(`${collectionName.toLowerCase()}.edit.before`, dataToModifier(data), document, currentUser, document));
data = modifierToData(await runCallbacks(`${collectionName.toLowerCase()}.edit.sync`, dataToModifier(data), document, currentUser, document));
data = modifierToData(
await runCallbacks(
`${collectionName.toLowerCase()}.edit.before`,
dataToModifier(data),
document,
currentUser,
document
)
);
data = modifierToData(
await runCallbacks(
`${collectionName.toLowerCase()}.edit.sync`,
dataToModifier(data),
document,
currentUser,
document
)
);
// update connector requires a modifier, so get it from data
const modifier = dataToModifier(data);
@ -301,10 +396,19 @@ export const updateMutator = async ({ collection, documentId, selector, data, se
After
*/
document = await runCallbacks({ name: `${typeName.toLowerCase()}.update.after`, iterator: document, properties });
document = await runCallbacks({
name: `${typeName.toLowerCase()}.update.after`,
iterator: document,
properties,
});
document = await runCallbacks({ name: '*.update.after', iterator: document, properties });
// OpenCRUD backwards compatibility
document = await runCallbacks(`${collectionName.toLowerCase()}.edit.after`, document, oldDocument, currentUser);
document = await runCallbacks(
`${collectionName.toLowerCase()}.edit.after`,
document,
oldDocument,
currentUser
);
/*
@ -315,7 +419,13 @@ export const updateMutator = async ({ collection, documentId, selector, data, se
await runCallbacksAsync({ name: `${typeName.toLowerCase()}.update.async`, properties });
await runCallbacksAsync({ name: '*.update.async', properties });
// OpenCRUD backwards compatibility
await runCallbacksAsync(`${collectionName.toLowerCase()}.edit.async`, document, oldDocument, currentUser, collection);
await runCallbacksAsync(
`${collectionName.toLowerCase()}.edit.async`,
document,
oldDocument,
currentUser,
collection
);
endDebugMutator(collectionName, 'Update', { modifier });
@ -327,7 +437,15 @@ export const updateMutator = async ({ collection, documentId, selector, data, se
Delete
*/
export const deleteMutator = async ({ collection, documentId, selector, currentUser, validate, context, document }) => {
export const deleteMutator = async ({
collection,
documentId,
selector,
currentUser,
validate,
context,
document,
}) => {
const { collectionName, typeName } = collection.options;
const schema = collection.simpleSchema()._schema;
// OpenCRUD backwards compatibility
@ -358,10 +476,22 @@ export const deleteMutator = async ({ collection, documentId, selector, currentU
if (validate) {
let validationErrors = [];
validationErrors = await runCallbacks({ name: `${typeName.toLowerCase()}.delete.validate`, iterator: validationErrors, properties });
validationErrors = await runCallbacks({ name: '*.delete.validate', iterator: validationErrors, properties });
validationErrors = await runCallbacks({
name: `${typeName.toLowerCase()}.delete.validate`,
iterator: validationErrors,
properties,
});
validationErrors = await runCallbacks({
name: '*.delete.validate',
iterator: validationErrors,
properties,
});
// OpenCRUD backwards compatibility
document = await runCallbacks(`${collectionName.toLowerCase()}.remove.validate`, document, currentUser);
document = await runCallbacks(
`${collectionName.toLowerCase()}.remove.validate`,
document,
currentUser
);
if (validationErrors.length) {
console.log(validationErrors); // eslint-disable-line no-console
@ -388,7 +518,11 @@ export const deleteMutator = async ({ collection, documentId, selector, currentU
Before
*/
await runCallbacks({ name: `${typeName.toLowerCase()}.delete.before`, iterator: document, properties });
await runCallbacks({
name: `${typeName.toLowerCase()}.delete.before`,
iterator: document,
properties,
});
await runCallbacks({ name: '*.delete.before', iterator: document, properties });
// OpenCRUD backwards compatibility
await runCallbacks(`${collectionName.toLowerCase()}.remove.before`, document, currentUser);
@ -415,7 +549,12 @@ export const deleteMutator = async ({ collection, documentId, selector, currentU
await runCallbacksAsync({ name: `${typeName.toLowerCase()}.delete.async`, properties });
await runCallbacksAsync({ name: '*.delete.async', properties });
// OpenCRUD backwards compatibility
await runCallbacksAsync(`${collectionName.toLowerCase()}.remove.async`, document, currentUser, collection);
await runCallbacksAsync(
`${collectionName.toLowerCase()}.remove.async`,
document,
currentUser,
collection
);
endDebugMutator(collectionName, 'Delete');

View file

@ -2,7 +2,7 @@ Package.describe({
name: 'vulcan:lib',
summary: 'Vulcan libraries.',
version: '1.12.14',
git: 'https://github.com/VulcanJS/Vulcan.git'
git: 'https://github.com/VulcanJS/Vulcan.git',
});
Package.onUse(function(api) {

View file

@ -2,19 +2,14 @@ Package.describe({
name: 'vulcan:newsletter',
summary: 'Vulcan email newsletter package',
version: '1.12.14',
git: 'https://github.com/VulcanJS/Vulcan.git'
git: 'https://github.com/VulcanJS/Vulcan.git',
});
Package.onUse(function (api) {
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use([
'vulcan:core@1.12.14',
'vulcan:email@1.12.14'
]);
api.use(['vulcan:core@1.12.14', 'vulcan:email@1.12.14']);
api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client');
});

View file

@ -2,25 +2,16 @@ Package.describe({
name: 'vulcan:payments',
summary: 'Vulcan payments package',
version: '1.12.14',
git: 'https://github.com/VulcanJS/Vulcan.git'
git: 'https://github.com/VulcanJS/Vulcan.git',
});
Package.onUse(function (api) {
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use([
'promise',
'vulcan:core@1.12.14',
'fourseven:scss@4.5.4',
]);
api.use(['promise', 'vulcan:core@1.12.14', 'fourseven:scss@4.5.4']);
api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client');
api.addFiles([
'lib/stylesheets/style.scss',
]);
api.addFiles(['lib/stylesheets/style.scss']);
});

View file

@ -2,18 +2,14 @@ Package.describe({
name: 'vulcan:routing',
summary: 'Vulcan router package',
version: '1.12.14',
git: 'https://github.com/VulcanJS/Vulcan.git'
git: 'https://github.com/VulcanJS/Vulcan.git',
});
Package.onUse(function (api) {
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use([
'vulcan:lib@1.12.14',
]);
api.use(['vulcan:lib@1.12.14']);
api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client');
});

View file

@ -2,26 +2,21 @@ Package.describe({
name: 'vulcan:subscribe',
summary: 'Subscribe to posts, users, etc. to be notified of new activity',
version: '1.12.14',
git: 'https://github.com/VulcanJS/Vulcan.git'
git: 'https://github.com/VulcanJS/Vulcan.git',
});
Package.onUse(function (api) {
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use([
'vulcan:core@1.12.14',
// dependencies on posts, categories are done with nested imports to reduce explicit dependencies
]);
api.use([
'vulcan:posts@1.12.14',
'vulcan:comments@1.12.14',
'vulcan:categories@1.12.14',
], {weak: true});
api.use(['vulcan:posts@1.12.14', 'vulcan:comments@1.12.14', 'vulcan:categories@1.12.14'], {
weak: true,
});
api.mainModule('lib/modules.js', ['client']);
api.mainModule('lib/modules.js', ['server']);
});

View file

@ -2,24 +2,16 @@ Package.describe({
name: 'vulcan:ui-bootstrap',
summary: 'Vulcan Bootstrap UI components.',
version: '1.12.14',
git: 'https://github.com/VulcanJS/Vulcan.git'
git: 'https://github.com/VulcanJS/Vulcan.git',
});
Package.onUse(function (api) {
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use([
'vulcan:lib@1.12.14',
'fourseven:scss@4.10.0',
]);
api.addFiles([
'lib/stylesheets/style.scss',
'lib/stylesheets/datetime.scss'
], 'client');
api.use(['vulcan:lib@1.12.14', 'fourseven:scss@4.10.0']);
api.addFiles(['lib/stylesheets/style.scss', 'lib/stylesheets/datetime.scss'], 'client');
api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client');
});

View file

@ -2,11 +2,11 @@ import SimpleSchema from 'simpl-schema';
import { Utils, getCollection, Connectors, Locales } from 'meteor/vulcan:lib'; // import from vulcan:lib because vulcan:core isn't loaded yet
///////////////////////////////////////
// Order for the Schema is as follows. Change as you see fit:
// 00.
// Order for the Schema is as follows. Change as you see fit:
// 00.
// 10. Display Name
// 20. Email
// 30. Bio
// 30. Bio
// 40. Slug
// 50. Website
// 60. Twitter username
@ -23,13 +23,13 @@ const createDisplayName = user => {
const linkedinFirstName = Utils.getNestedProperty(user, 'services.linkedin.firstName');
if (profileName) return profileName;
if (twitterName) return twitterName;
if (linkedinFirstName) return `${linkedinFirstName} ${Utils.getNestedProperty(user, 'services.linkedin.lastName')}`;
if (linkedinFirstName)
return `${linkedinFirstName} ${Utils.getNestedProperty(user, 'services.linkedin.lastName')}`;
if (user.username) return user.username;
if (user.email) return user.email.slice(0, user.email.indexOf('@'));
return undefined;
};
const adminGroup = {
name: 'admin',
order: 100,
@ -56,11 +56,16 @@ const schema = {
canUpdate: ['admins'],
canCreate: ['members'],
onCreate: ({ document: user }) => {
if ((!user.username) && user.services && user.services.twitter && user.services.twitter.screenName) {
if (
!user.username &&
user.services &&
user.services.twitter &&
user.services.twitter.screenName
) {
return user.services.twitter.screenName;
}
},
searchable: true
searchable: true,
},
emails: {
type: Array,
@ -85,7 +90,7 @@ const schema = {
canRead: ['admins'],
onCreate: () => {
return new Date();
}
},
},
isAdmin: {
type: Boolean,
@ -140,7 +145,7 @@ const schema = {
onCreate: ({ document: user }) => {
return createDisplayName(user);
},
searchable: true
searchable: true,
},
/**
The user's email. Modifiable.
@ -170,7 +175,7 @@ const schema = {
if (linkedinEmail) return linkedinEmail;
return undefined;
},
searchable: true
searchable: true,
// unique: true // note: find a way to fix duplicate accounts before enabling this
},
/**
@ -184,27 +189,27 @@ const schema = {
if (user.email) {
return getCollection('Users').avatar.hash(user.email);
}
}
},
},
avatarUrl: {
type: String,
optional: true,
canRead: ['guests'],
onCreate: ({ document: user }) => {
const twitterAvatar = Utils.getNestedProperty(user, 'services.twitter.profile_image_url_https');
const twitterAvatar = Utils.getNestedProperty(
user,
'services.twitter.profile_image_url_https'
);
const facebookId = Utils.getNestedProperty(user, 'services.facebook.id');
if (twitterAvatar) return twitterAvatar;
if (facebookId) return `https://graph.facebook.com/${facebookId}/picture?type=large`;
return undefined;
},
resolveAs: {
fieldName: 'avatarUrl',
type: 'String',
resolver: async (user, args, { Users }) => {
if (_.isEmpty(user)) return null;
if (user.avatarUrl) {
@ -215,9 +220,8 @@ const schema = {
const fullUser = await Users.loader.load(user._id);
return Users.avatar.getUrl(fullUser);
}
}
}
},
},
},
/**
The user's profile URL slug // TODO: change this when displayName changes
@ -256,7 +260,7 @@ const schema = {
if (user.services && user.services.twitter && user.services.twitter.screenName) {
return user.services.twitter.screenName;
}
}
},
},
/**
Groups
@ -270,15 +274,22 @@ const schema = {
canRead: ['guests'],
group: adminGroup,
form: {
options: function () {
const groups = _.without(_.keys(getCollection('Users').groups), 'guests', 'members', 'admins');
return groups.map(group => { return { value: group, label: group }; });
}
options: function() {
const groups = _.without(
_.keys(getCollection('Users').groups),
'guests',
'members',
'admins'
);
return groups.map(group => {
return { value: group, label: group };
});
},
},
},
'groups.$': {
type: String,
optional: true
optional: true,
},
// GraphQL only fields
@ -292,7 +303,7 @@ const schema = {
resolver: (user, args, { Users }) => {
return Users.getProfileUrl(user, true);
},
}
},
},
editUrl: {
@ -304,9 +315,8 @@ const schema = {
resolver: (user, args, { Users }) => {
return Users.getEditUrl(user, true);
},
}
}
},
},
};
export default schema;

View file

@ -2,20 +2,16 @@ Package.describe({
name: 'vulcan:users',
summary: 'Vulcan permissions.',
version: '1.12.14',
git: 'https://github.com/VulcanJS/Vulcan.git'
git: 'https://github.com/VulcanJS/Vulcan.git',
});
Package.onUse(function (api) {
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use([
'vulcan:lib@1.12.14'
]);
api.use(['vulcan:lib@1.12.14']);
api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client');
});
Package.onTest(function(api) {
api.use('vulcan:users');

View file

@ -2,20 +2,17 @@ Package.describe({
name: 'vulcan:voting',
summary: 'Vulcan scoring package.',
version: '1.12.14',
git: 'https://github.com/VulcanJS/Vulcan.git'
git: 'https://github.com/VulcanJS/Vulcan.git',
});
Package.onUse(function (api) {
Package.onUse(function(api) {
api.versionsFrom('1.6.1');
api.use([
'fourseven:scss@4.10.0',
'vulcan:core@1.12.14',
'vulcan:i18n@1.12.14',
], ['client', 'server']);
api.use(
['fourseven:scss@4.10.0', 'vulcan:core@1.12.14', 'vulcan:i18n@1.12.14'],
['client', 'server'],
);
api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client');
});