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

View file

@ -2,27 +2,21 @@ Package.describe({
name: 'vulcan:admin', name: 'vulcan:admin',
summary: 'Vulcan components package', summary: 'Vulcan components package',
version: '1.12.14', 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.versionsFrom('1.6.1');
api.use([ api.use([
'fourseven:scss@4.10.0', 'fourseven:scss@4.10.0',
'dynamic-import@0.1.1', 'dynamic-import@0.1.1',
// Vulcan packages // Vulcan packages
'vulcan:core@1.12.14', 'vulcan:core@1.12.14',
]); ]);
api.mainModule('lib/server/main.js', 'server'); api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client'); api.mainModule('lib/client/main.js', 'client');
api.addFiles([ api.addFiles(['lib/stylesheets/style.scss'], ['client']);
'lib/stylesheets/style.scss'
], ['client']);
}); });

View file

@ -2,18 +2,14 @@ Package.describe({
name: 'vulcan:cloudinary', name: 'vulcan:cloudinary',
summary: 'Vulcan file upload package.', summary: 'Vulcan file upload package.',
version: '1.12.14', 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.versionsFrom('1.6.1');
api.use([ api.use(['vulcan:core@1.12.14']);
'vulcan:core@1.12.14'
]);
api.mainModule('lib/client/main.js', 'client'); api.mainModule('lib/client/main.js', 'client');
api.mainModule('lib/server/main.js', 'server'); api.mainModule('lib/server/main.js', 'server');
}); });

View file

@ -2,10 +2,10 @@ Package.describe({
name: 'vulcan:core', name: 'vulcan:core',
summary: 'Vulcan core package', summary: 'Vulcan core package',
version: '1.12.14', 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.versionsFrom('1.6.1');
api.use([ api.use([
@ -13,7 +13,7 @@ Package.onUse(function (api) {
'vulcan:i18n@1.12.14', 'vulcan:i18n@1.12.14',
'vulcan:users@1.12.14', 'vulcan:users@1.12.14',
'vulcan:routing@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']); api.imply(['vulcan:lib@1.12.14']);
@ -22,7 +22,7 @@ Package.onUse(function (api) {
api.mainModule('lib/client/main.js', 'client'); 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.use(['ecmascript', 'meteortesting:mocha', 'vulcan:test', 'vulcan:core']);
api.mainModule('./test/index.js'); api.mainModule('./test/index.js');
}); });

View file

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

View file

@ -2,18 +2,14 @@ Package.describe({
name: 'vulcan:email', name: 'vulcan:email',
summary: 'Vulcan email package', summary: 'Vulcan email package',
version: '1.12.14', 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.versionsFrom('1.6.1');
api.use([ api.use(['vulcan:lib@1.12.14']);
'vulcan:lib@1.12.14'
]);
api.mainModule('lib/server.js', 'server'); api.mainModule('lib/server.js', 'server');
api.mainModule('lib/client.js', 'client'); api.mainModule('lib/client.js', 'client');
}); });

View file

@ -2,25 +2,16 @@ Package.describe({
name: 'vulcan:embed', name: 'vulcan:embed',
summary: 'Vulcan Embed package', summary: 'Vulcan Embed package',
version: '1.12.14', 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.versionsFrom('1.6.1');
api.use([ api.use(['http', 'vulcan:core@1.12.14', 'fourseven:scss@4.10.0']);
'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/client/main.js', 'client');
api.mainModule('lib/server/main.js', 'server'); api.mainModule('lib/server/main.js', 'server');
}); });

View file

@ -2,21 +2,14 @@ Package.describe({
name: 'vulcan:errors-sentry', name: 'vulcan:errors-sentry',
summary: 'Vulcan Sentry error tracking package', summary: 'Vulcan Sentry error tracking package',
version: '1.12.14', 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.versionsFrom('1.6.1');
api.use([ api.use(['ecmascript', 'vulcan:core@1.12.14', 'vulcan:users@1.12.14', 'vulcan:errors@1.12.14']);
'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/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client'); api.mainModule('lib/client/main.js', 'client');
}); });

View file

@ -2,19 +2,14 @@ Package.describe({
name: 'vulcan:errors', name: 'vulcan:errors',
summary: 'Vulcan error tracking package', summary: 'Vulcan error tracking package',
version: '1.12.14', 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.versionsFrom('1.6.1');
api.use([ api.use(['ecmascript', 'vulcan:core@1.12.14']);
'ecmascript',
'vulcan:core@1.12.14',
]);
api.mainModule('lib/server/main.js', 'server'); api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client'); api.mainModule('lib/client/main.js', 'client');
}); });

View file

@ -2,19 +2,14 @@ Package.describe({
name: 'vulcan:events-ga', name: 'vulcan:events-ga',
summary: 'Vulcan Google Analytics event tracking package', summary: 'Vulcan Google Analytics event tracking package',
version: '1.12.14', 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.versionsFrom('1.6.1');
api.use([ api.use(['vulcan:core@1.12.14', 'vulcan:events@1.12.14']);
'vulcan:core@1.12.14',
'vulcan:events@1.12.14',
]);
api.mainModule('lib/server/main.js', 'server'); api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client'); api.mainModule('lib/client/main.js', 'client');
}); });

View file

@ -2,19 +2,14 @@ Package.describe({
name: 'vulcan:events-intercom', name: 'vulcan:events-intercom',
summary: 'Vulcan Intercom integration package.', summary: 'Vulcan Intercom integration package.',
version: '1.12.14', 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.versionsFrom('1.6.1');
api.use([ api.use(['vulcan:core@1.12.14', 'vulcan:events@1.12.14']);
'vulcan:core@1.12.14',
'vulcan:events@1.12.14'
]);
api.mainModule('lib/client/main.js', 'client'); api.mainModule('lib/client/main.js', 'client');
api.mainModule('lib/server/main.js', 'server'); api.mainModule('lib/server/main.js', 'server');
}); });

View file

@ -2,19 +2,14 @@ Package.describe({
name: 'vulcan:events-internal', name: 'vulcan:events-internal',
summary: 'Vulcan internal event tracking package', summary: 'Vulcan internal event tracking package',
version: '1.12.14', 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.versionsFrom('1.6.1');
api.use([ api.use(['vulcan:core@1.12.14', 'vulcan:events@1.12.14']);
'vulcan:core@1.12.14',
'vulcan:events@1.12.14',
]);
api.mainModule('lib/server/main.js', 'server'); api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client'); api.mainModule('lib/client/main.js', 'client');
}); });

View file

@ -2,19 +2,14 @@ Package.describe({
name: 'vulcan:events-segment', name: 'vulcan:events-segment',
summary: 'Vulcan Segment', summary: 'Vulcan Segment',
version: '1.12.14', 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.versionsFrom('1.6.1');
api.use([ api.use(['vulcan:core@1.12.14', 'vulcan:events@1.12.14']);
'vulcan:core@1.12.14',
'vulcan:events@1.12.14',
]);
api.mainModule('lib/server/main.js', 'server'); api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client'); api.mainModule('lib/client/main.js', 'client');
}); });

View file

@ -2,18 +2,14 @@ Package.describe({
name: 'vulcan:events', name: 'vulcan:events',
summary: 'Vulcan event tracking package', summary: 'Vulcan event tracking package',
version: '1.12.14', 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.versionsFrom('1.6.1');
api.use([ api.use(['vulcan:core@1.12.14']);
'vulcan:core@1.12.14',
]);
api.mainModule('lib/server/main.js', 'server'); api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client'); api.mainModule('lib/client/main.js', 'client');
}); });

View file

@ -2,18 +2,13 @@ Package.describe({
name: 'vulcan:forms-tags', name: 'vulcan:forms-tags',
summary: 'Vulcan tag input package', summary: 'Vulcan tag input package',
version: '1.12.14', 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.versionsFrom('1.6.1');
api.use([ api.use(['vulcan:core@1.12.14', 'vulcan:forms@1.12.14']);
'vulcan:core@1.12.14',
'vulcan:forms@1.12.14'
]);
api.mainModule('lib/export.js', ['client', 'server']); api.mainModule('lib/export.js', ['client', 'server']);
}); });

View file

@ -2,23 +2,15 @@ Package.describe({
name: 'vulcan:forms-upload', name: 'vulcan:forms-upload',
summary: 'Vulcan package extending vulcan:forms to upload images to Cloudinary from a drop zone.', summary: 'Vulcan package extending vulcan:forms to upload images to Cloudinary from a drop zone.',
version: '1.12.14', 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.versionsFrom('1.6.1');
api.use([ api.use(['vulcan:core@1.12.14', 'vulcan:forms@1.12.14', 'fourseven:scss@4.10.0']);
'vulcan:core@1.12.14',
'vulcan:forms@1.12.14',
'fourseven:scss@4.10.0'
]);
api.addFiles([ api.addFiles(['lib/Upload.scss'], 'client');
'lib/Upload.scss'
], 'client');
api.mainModule('lib/modules.js', ['client', 'server']); api.mainModule('lib/modules.js', ['client', 'server']);
}); });

View file

@ -2,10 +2,10 @@ Package.describe({
name: 'vulcan:forms', name: 'vulcan:forms',
summary: 'Form containers for React', summary: 'Form containers for React',
version: '1.12.14', 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.versionsFrom('1.6.1');
api.use(['vulcan:core@1.12.14']); api.use(['vulcan:core@1.12.14']);
@ -14,7 +14,7 @@ Package.onUse(function (api) {
api.mainModule('lib/server/main.js', ['server']); 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.use(['ecmascript', 'meteortesting:mocha', 'vulcan:test', 'vulcan:forms']);
api.mainModule('./test/index.js'); api.mainModule('./test/index.js');
}); });

View file

@ -2,18 +2,13 @@ Package.describe({
name: 'vulcan:i18n-en-us', name: 'vulcan:i18n-en-us',
summary: 'Vulcan i18n package (en_US)', summary: 'Vulcan i18n package (en_US)',
version: '1.12.14', 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.versionsFrom('1.6.1');
api.use([ api.use(['vulcan:core@1.12.14']);
'vulcan:core@1.12.14'
]);
api.addFiles([ api.addFiles(['lib/en_US.js'], ['client', 'server']);
'lib/en_US.js'
], ['client', 'server']);
}); });

View file

@ -2,18 +2,13 @@ Package.describe({
name: 'vulcan:i18n-es-es', name: 'vulcan:i18n-es-es',
summary: 'Vulcan i18n package (es_ES)', summary: 'Vulcan i18n package (es_ES)',
version: '1.12.14', 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.versionsFrom('1.6.1');
api.use([ api.use(['vulcan:core@1.12.14']);
'vulcan:core@1.12.14'
]);
api.addFiles([ api.addFiles(['lib/es_ES.js'], ['client', 'server']);
'lib/es_ES.js'
], ['client', 'server']);
}); });

View file

@ -2,18 +2,13 @@ Package.describe({
name: 'vulcan:i18n-fr-fr', name: 'vulcan:i18n-fr-fr',
summary: 'Vulcan i18n package (fr_FR)', summary: 'Vulcan i18n package (fr_FR)',
version: '1.12.14', 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.versionsFrom('1.6.1');
api.use([ api.use(['vulcan:core@1.12.14']);
'vulcan:core@1.12.14'
]);
api.addFiles([ api.addFiles(['lib/fr_FR.js'], ['client', 'server']);
'lib/fr_FR.js'
], ['client', 'server']);
}); });

View file

@ -2,18 +2,14 @@ Package.describe({
name: 'vulcan:i18n', name: 'vulcan:i18n',
summary: 'i18n client polyfill', summary: 'i18n client polyfill',
version: '1.12.14', 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.versionsFrom('1.6.1');
api.use([ api.use(['vulcan:lib@1.12.14']);
'vulcan:lib@1.12.14',
]);
api.mainModule('lib/server/main.js', 'server'); api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client'); api.mainModule('lib/client/main.js', 'client');
}); });

View file

@ -20,7 +20,8 @@ export const Collections = [];
export const getCollection = name => export const getCollection = name =>
Collections.find( 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? // 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; var self = this;
if (self._transform && !self._helpers) 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) { if (!self._helpers) {
self._helpers = function Document(doc) { self._helpers = function Document(doc) {
@ -126,7 +129,7 @@ export const createCollection = options => {
typeName, typeName,
collectionName = getCollectionName(typeName), collectionName = getCollectionName(typeName),
generateGraphQLSchema = true, generateGraphQLSchema = true,
dbCollectionName dbCollectionName,
} = options; } = options;
let { schema } = options; let { schema } = options;
@ -155,7 +158,7 @@ export const createCollection = options => {
//register individual collection callback //register individual collection callback
registerCollectionCallback(typeName.toLowerCase()); 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 // `${collectionName}.collection` callbacks run to make sure it always runs last
if (schemaHasIntlFields(schema)) { if (schemaHasIntlFields(schema)) {
hasIntlFields = true; // we have at least one intl field 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 //run schema callbacks and run general callbacks last
schema = runCallbacks({ name: `${typeName.toLowerCase()}.collection`, iterator: schema, properties: { options }}); schema = runCallbacks({
schema = runCallbacks({ name: '*.collection', iterator: schema, properties: { options }}); name: `${typeName.toLowerCase()}.collection`,
iterator: schema,
properties: { options },
});
schema = runCallbacks({ name: '*.collection', iterator: schema, properties: { options } });
if (schema) { if (schema) {
// attach schema to collection // attach schema to collection
@ -196,20 +203,29 @@ export const createCollection = options => {
let parameters = { let parameters = {
selector: {}, selector: {},
options: {} options: {},
}; };
if (collection.defaultView) { 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 // handle view option
if (terms.view && collection.views[terms.view]) { if (terms.view && collection.views[terms.view]) {
const viewFn = 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); 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, // If both the default view and the selected view have sort options,
// don't merge them together; take the selected view's sort. (Otherwise // 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 // 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 // note: check that context exists to avoid calling this from withList during SSR
if (Meteor.isServer && context) { 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 // OpenCRUD backwards compatibility
parameters = runCallbacks( parameters = runCallbacks(
`${collectionName.toLowerCase()}.parameters.server`, `${collectionName.toLowerCase()}.parameters.server`,
@ -293,12 +314,17 @@ export const createCollection = options => {
if (terms.query) { if (terms.query) {
const query = escapeStringRegexp(terms.query); const query = escapeStringRegexp(terms.query);
const currentSchema = collection.simpleSchema()._schema; 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) { if (searchableFieldNames.length) {
parameters = Utils.deepExtend(true, parameters, { parameters = Utils.deepExtend(true, parameters, {
selector: { selector: {
$or: searchableFieldNames.map(fieldName => ({ [fieldName]: { $regex: query, $options: 'i' } })) $or: searchableFieldNames.map(fieldName => ({
} [fieldName]: { $regex: query, $options: 'i' },
})),
},
}); });
} else { } else {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
@ -332,11 +358,11 @@ function registerCollectionCallback(typeName) {
iterator: { schema: 'the schema of the collection' }, iterator: { schema: 'the schema of the collection' },
properties: [ properties: [
{ schema: 'The schema of the collection' }, { 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', runs: 'sync',
returns: 'schema', 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' }, iterator: { schema: 'the schema of the collection' },
properties: [ properties: [
{ schema: 'The schema of the collection' }, { 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', runs: 'sync',
returns: 'schema', returns: 'schema',
@ -358,7 +384,6 @@ function addIntlFields(schema) {
Object.keys(schema).forEach(fieldName => { Object.keys(schema).forEach(fieldName => {
const fieldSchema = schema[fieldName]; const fieldSchema = schema[fieldName];
if (isIntlField(fieldSchema)) { if (isIntlField(fieldSchema)) {
// remove `intl` to avoid treating new _intl field as a field to internationalize // remove `intl` to avoid treating new _intl field as a field to internationalize
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { intl, ...propertiesToCopy } = schema[fieldName]; const { intl, ...propertiesToCopy } = schema[fieldName];
@ -367,13 +392,13 @@ function addIntlFields(schema) {
...propertiesToCopy, // copy properties from regular field ...propertiesToCopy, // copy properties from regular field
hidden: true, hidden: true,
type: Array, type: Array,
isIntlData: true isIntlData: true,
}; };
delete schema[`${fieldName}_intl`].intl; delete schema[`${fieldName}_intl`].intl;
schema[`${fieldName}_intl.$`] = { schema[`${fieldName}_intl.$`] = {
type: getIntlString() type: getIntlString(),
}; };
// if original field is required, enable custom validation function instead of `optional` property // 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 -------------------------------- // // ------------------------------------- Schemas -------------------------------- //
SimpleSchema.extendOptions([ 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 'mustComplete', // mustComplete: true means the field is required to have a complete profile
'form', // extra form properties 'form', // extra form properties
'inputProperties', // extra form properties 'inputProperties', // extra form properties
@ -22,7 +22,7 @@ SimpleSchema.extendOptions([
'control', // SmartForm control (String or React component) (legacy) 'control', // SmartForm control (String or React component) (legacy)
'order', // position in the form 'order', // position in the form
'group', // form fieldset group 'group', // form fieldset group
'onCreate', // field insert callback 'onCreate', // field insert callback
'onInsert', // field insert callback (OpenCRUD backwards compatibility) 'onInsert', // field insert callback (OpenCRUD backwards compatibility)

View file

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

View file

@ -2,7 +2,7 @@ Package.describe({
name: 'vulcan:lib', name: 'vulcan:lib',
summary: 'Vulcan libraries.', summary: 'Vulcan libraries.',
version: '1.12.14', 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) {

View file

@ -2,19 +2,14 @@ Package.describe({
name: 'vulcan:newsletter', name: 'vulcan:newsletter',
summary: 'Vulcan email newsletter package', summary: 'Vulcan email newsletter package',
version: '1.12.14', 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.versionsFrom('1.6.1');
api.use([ api.use(['vulcan:core@1.12.14', 'vulcan:email@1.12.14']);
'vulcan:core@1.12.14',
'vulcan:email@1.12.14'
]);
api.mainModule('lib/server/main.js', 'server'); api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client'); api.mainModule('lib/client/main.js', 'client');
}); });

View file

@ -2,25 +2,16 @@ Package.describe({
name: 'vulcan:payments', name: 'vulcan:payments',
summary: 'Vulcan payments package', summary: 'Vulcan payments package',
version: '1.12.14', 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.versionsFrom('1.6.1');
api.use([ api.use(['promise', 'vulcan:core@1.12.14', 'fourseven:scss@4.5.4']);
'promise',
'vulcan:core@1.12.14',
'fourseven:scss@4.5.4',
]);
api.mainModule('lib/server/main.js', 'server'); api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client'); api.mainModule('lib/client/main.js', 'client');
api.addFiles([ api.addFiles(['lib/stylesheets/style.scss']);
'lib/stylesheets/style.scss',
]);
}); });

View file

@ -2,18 +2,14 @@ Package.describe({
name: 'vulcan:routing', name: 'vulcan:routing',
summary: 'Vulcan router package', summary: 'Vulcan router package',
version: '1.12.14', 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.versionsFrom('1.6.1');
api.use([ api.use(['vulcan:lib@1.12.14']);
'vulcan:lib@1.12.14',
]);
api.mainModule('lib/server/main.js', 'server'); api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client'); api.mainModule('lib/client/main.js', 'client');
}); });

View file

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

View file

@ -2,24 +2,16 @@ Package.describe({
name: 'vulcan:ui-bootstrap', name: 'vulcan:ui-bootstrap',
summary: 'Vulcan Bootstrap UI components.', summary: 'Vulcan Bootstrap UI components.',
version: '1.12.14', 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.versionsFrom('1.6.1');
api.use([ api.use(['vulcan:lib@1.12.14', 'fourseven:scss@4.10.0']);
'vulcan:lib@1.12.14',
'fourseven:scss@4.10.0', api.addFiles(['lib/stylesheets/style.scss', 'lib/stylesheets/datetime.scss'], 'client');
]);
api.addFiles([
'lib/stylesheets/style.scss',
'lib/stylesheets/datetime.scss'
], 'client');
api.mainModule('lib/server/main.js', 'server'); api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client'); 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 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: // Order for the Schema is as follows. Change as you see fit:
// 00. // 00.
// 10. Display Name // 10. Display Name
// 20. Email // 20. Email
// 30. Bio // 30. Bio
// 40. Slug // 40. Slug
// 50. Website // 50. Website
// 60. Twitter username // 60. Twitter username
@ -23,13 +23,13 @@ const createDisplayName = user => {
const linkedinFirstName = Utils.getNestedProperty(user, 'services.linkedin.firstName'); const linkedinFirstName = Utils.getNestedProperty(user, 'services.linkedin.firstName');
if (profileName) return profileName; if (profileName) return profileName;
if (twitterName) return twitterName; 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.username) return user.username;
if (user.email) return user.email.slice(0, user.email.indexOf('@')); if (user.email) return user.email.slice(0, user.email.indexOf('@'));
return undefined; return undefined;
}; };
const adminGroup = { const adminGroup = {
name: 'admin', name: 'admin',
order: 100, order: 100,
@ -56,11 +56,16 @@ const schema = {
canUpdate: ['admins'], canUpdate: ['admins'],
canCreate: ['members'], canCreate: ['members'],
onCreate: ({ document: user }) => { 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; return user.services.twitter.screenName;
} }
}, },
searchable: true searchable: true,
}, },
emails: { emails: {
type: Array, type: Array,
@ -85,7 +90,7 @@ const schema = {
canRead: ['admins'], canRead: ['admins'],
onCreate: () => { onCreate: () => {
return new Date(); return new Date();
} },
}, },
isAdmin: { isAdmin: {
type: Boolean, type: Boolean,
@ -140,7 +145,7 @@ const schema = {
onCreate: ({ document: user }) => { onCreate: ({ document: user }) => {
return createDisplayName(user); return createDisplayName(user);
}, },
searchable: true searchable: true,
}, },
/** /**
The user's email. Modifiable. The user's email. Modifiable.
@ -170,7 +175,7 @@ const schema = {
if (linkedinEmail) return linkedinEmail; if (linkedinEmail) return linkedinEmail;
return undefined; return undefined;
}, },
searchable: true searchable: true,
// unique: true // note: find a way to fix duplicate accounts before enabling this // unique: true // note: find a way to fix duplicate accounts before enabling this
}, },
/** /**
@ -184,27 +189,27 @@ const schema = {
if (user.email) { if (user.email) {
return getCollection('Users').avatar.hash(user.email); return getCollection('Users').avatar.hash(user.email);
} }
} },
}, },
avatarUrl: { avatarUrl: {
type: String, type: String,
optional: true, optional: true,
canRead: ['guests'], canRead: ['guests'],
onCreate: ({ document: user }) => { onCreate: ({ document: user }) => {
const twitterAvatar = Utils.getNestedProperty(
const twitterAvatar = Utils.getNestedProperty(user, 'services.twitter.profile_image_url_https'); user,
'services.twitter.profile_image_url_https'
);
const facebookId = Utils.getNestedProperty(user, 'services.facebook.id'); const facebookId = Utils.getNestedProperty(user, 'services.facebook.id');
if (twitterAvatar) return twitterAvatar; if (twitterAvatar) return twitterAvatar;
if (facebookId) return `https://graph.facebook.com/${facebookId}/picture?type=large`; if (facebookId) return `https://graph.facebook.com/${facebookId}/picture?type=large`;
return undefined; return undefined;
}, },
resolveAs: { resolveAs: {
fieldName: 'avatarUrl', fieldName: 'avatarUrl',
type: 'String', type: 'String',
resolver: async (user, args, { Users }) => { resolver: async (user, args, { Users }) => {
if (_.isEmpty(user)) return null; if (_.isEmpty(user)) return null;
if (user.avatarUrl) { if (user.avatarUrl) {
@ -215,9 +220,8 @@ const schema = {
const fullUser = await Users.loader.load(user._id); const fullUser = await Users.loader.load(user._id);
return Users.avatar.getUrl(fullUser); return Users.avatar.getUrl(fullUser);
} }
},
} },
}
}, },
/** /**
The user's profile URL slug // TODO: change this when displayName changes 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) { if (user.services && user.services.twitter && user.services.twitter.screenName) {
return user.services.twitter.screenName; return user.services.twitter.screenName;
} }
} },
}, },
/** /**
Groups Groups
@ -270,15 +274,22 @@ const schema = {
canRead: ['guests'], canRead: ['guests'],
group: adminGroup, group: adminGroup,
form: { form: {
options: function () { options: function() {
const groups = _.without(_.keys(getCollection('Users').groups), 'guests', 'members', 'admins'); const groups = _.without(
return groups.map(group => { return { value: group, label: group }; }); _.keys(getCollection('Users').groups),
} 'guests',
'members',
'admins'
);
return groups.map(group => {
return { value: group, label: group };
});
},
}, },
}, },
'groups.$': { 'groups.$': {
type: String, type: String,
optional: true optional: true,
}, },
// GraphQL only fields // GraphQL only fields
@ -292,7 +303,7 @@ const schema = {
resolver: (user, args, { Users }) => { resolver: (user, args, { Users }) => {
return Users.getProfileUrl(user, true); return Users.getProfileUrl(user, true);
}, },
} },
}, },
editUrl: { editUrl: {
@ -304,9 +315,8 @@ const schema = {
resolver: (user, args, { Users }) => { resolver: (user, args, { Users }) => {
return Users.getEditUrl(user, true); return Users.getEditUrl(user, true);
}, },
} },
} },
}; };
export default schema; export default schema;

View file

@ -2,20 +2,16 @@ Package.describe({
name: 'vulcan:users', name: 'vulcan:users',
summary: 'Vulcan permissions.', summary: 'Vulcan permissions.',
version: '1.12.14', 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.versionsFrom('1.6.1');
api.use([ api.use(['vulcan:lib@1.12.14']);
'vulcan:lib@1.12.14'
]);
api.mainModule('lib/server/main.js', 'server'); api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client'); api.mainModule('lib/client/main.js', 'client');
}); });
Package.onTest(function(api) { Package.onTest(function(api) {
api.use('vulcan:users'); api.use('vulcan:users');

View file

@ -2,20 +2,17 @@ Package.describe({
name: 'vulcan:voting', name: 'vulcan:voting',
summary: 'Vulcan scoring package.', summary: 'Vulcan scoring package.',
version: '1.12.14', 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.versionsFrom('1.6.1');
api.use([ api.use(
'fourseven:scss@4.10.0', ['fourseven:scss@4.10.0', 'vulcan:core@1.12.14', 'vulcan:i18n@1.12.14'],
'vulcan:core@1.12.14', ['client', 'server'],
'vulcan:i18n@1.12.14', );
], ['client', 'server']);
api.mainModule('lib/server/main.js', 'server'); api.mainModule('lib/server/main.js', 'server');
api.mainModule('lib/client/main.js', 'client'); api.mainModule('lib/client/main.js', 'client');
}); });