Skip to content
Commits on Source (77)
......@@ -24,10 +24,11 @@
}
},
"globals": {
"msg": false
"msg": false,
"globalThis": false
},
"plugins": ["meteor", "import", "prettier", "i18n", "react", "jsx"],
"ignorePatterns": ["packages/**/*.js", "packages/**/*.jsx"],
"ignorePatterns": ["packages/**/*.js", "packages/**/*.jsx", "private/widget/"],
"rules": {
"import/prefer-default-export": "off",
"import/no-extraneous-dependencies": "off",
......
......@@ -5,6 +5,7 @@
"**/node_modules/**",
"**/.meteor/**",
"**/.reports/**",
"**/private/**",
"./packages/**",
"./i18n/*.json",
"**/*.svg",
......
......@@ -37,7 +37,6 @@ percolate:find-from-publication
percolate:migrations
matb33:collection-hooks
seba:method-hooks
email@2.2.5
check@1.3.2
tmeasday:publish-counts
......@@ -49,3 +48,4 @@ logging@1.3.3
mizzao:user-status
littledata:synced-cron
sakulstra:aggregate
eoleteam:method-hooks
......@@ -33,6 +33,7 @@ ejson@1.1.3
email@2.2.5
eoleteam:accounts-keycloak@2.1.0
eoleteam:keycloak-oauth@2.3.0
eoleteam:method-hooks@3.0.5
es5-shim@4.8.0
fetch@0.1.4
geojson-utils@1.0.11
......@@ -89,7 +90,6 @@ reload@1.3.1
retry@1.1.0
routepolicy@1.1.1
sakulstra:aggregate@1.4.4
seba:method-hooks@3.0.3
server-render@0.4.1
service-configuration@1.3.3
sha@1.0.9
......
import { Mongo } from 'meteor/mongo';
import SimpleSchema from 'simpl-schema';
import { Tracker } from 'meteor/tracker';
import moment from 'moment';
import { getLabel } from '../utils';
import RegEx from '../regExp';
const AnalyticsEvents = new Mongo.Collection('analytics');
......@@ -24,45 +24,42 @@ AnalyticsEvents.targets = {
WIDGET: 'WIDGET',
};
AnalyticsEvents.schema = new SimpleSchema(
{
target: {
type: String,
allowedValues: Object.keys(AnalyticsEvents.targets),
label: getLabel('api.analytics.labels.target'),
index: true,
},
content: {
type: String,
optional: true,
label: getLabel('api.analytics.labels.content'),
index: true,
},
count: {
type: Number,
label: getLabel('api.analytics.labels.count'),
defaultValue: 0,
},
structureId: {
type: SimpleSchema.RegEx.Id,
label: getLabel('api.analytics.labels.structure'),
optional: true,
index: true,
},
createdAt: {
type: Date,
label: getLabel('api.analytics.labels.createdAt'),
index: true,
autoValue() {
if (this.isUpsert) {
return new Date(moment().startOf('hour').format());
}
return this.value;
},
AnalyticsEvents.schema = new SimpleSchema({
target: {
type: String,
allowedValues: Object.keys(AnalyticsEvents.targets),
label: getLabel('api.analytics.labels.target'),
index: true,
},
content: {
type: String,
optional: true,
label: getLabel('api.analytics.labels.content'),
index: true,
},
count: {
type: Number,
label: getLabel('api.analytics.labels.count'),
defaultValue: 0,
},
structureId: {
type: RegEx.Id,
label: getLabel('api.analytics.labels.structure'),
optional: true,
index: true,
},
createdAt: {
type: Date,
label: getLabel('api.analytics.labels.createdAt'),
index: true,
autoValue() {
if (this.isUpsert) {
return new Date(moment().startOf('hour').format());
}
return this.value;
},
},
{ tracker: Tracker },
);
});
if (Meteor.isServer) {
AnalyticsEvents.createIndex({
......
import { Mongo } from 'meteor/mongo';
import SimpleSchema from 'simpl-schema';
import { Tracker } from 'meteor/tracker';
import { getLabel } from '../utils';
const AppSettings = new Mongo.Collection('appsettings');
......@@ -114,7 +113,7 @@ AppSettings.schema = new SimpleSchema(
label: getLabel('api.appsettings.label.userStructureValidationMandatory'),
},
},
{ clean: { removeEmptyStrings: false }, tracker: Tracker },
{ clean: { removeEmptyStrings: false } },
);
AppSettings.publicFields = {
......
/* eslint-disable func-names */
import { Mongo } from 'meteor/mongo';
import SimpleSchema from 'simpl-schema';
import { Tracker } from 'meteor/tracker';
import slugy from '../../ui/utils/slugy';
import { getLabel } from '../utils';
import Groups from '../groups/groups';
import RegEx from '../regExp';
const Articles = new Mongo.Collection('articles');
......@@ -57,7 +57,8 @@ Articles.schema = new SimpleSchema(
optional: true,
},
structure: {
type: SimpleSchema.RegEx.Id,
type: String,
// regEx: RegEx.Id, doesn't work, structure can be an empty string
label: getLabel('api.articles.labels.structure'),
},
markdown: { type: Boolean, label: getLabel('api.articles.labels.markdown'), defaultValue: false },
......@@ -74,7 +75,7 @@ Articles.schema = new SimpleSchema(
type: { type: Object },
},
'groups.$._id': {
type: { type: String, regEx: SimpleSchema.RegEx.Id },
type: { type: String, regEx: RegEx.Id },
},
'groups.$.name': {
type: { type: String },
......@@ -109,7 +110,7 @@ Articles.schema = new SimpleSchema(
defaultValue: '',
},
},
{ clean: { removeEmptyStrings: false }, tracker: Tracker },
{ clean: { removeEmptyStrings: false } },
);
Articles.publicFields = {
......
......@@ -6,6 +6,7 @@ import { ValidatedMethod } from 'meteor/mdg:validated-method';
import i18n from 'meteor/universe:i18n';
import sanitizeHtml from 'sanitize-html';
import logServer, { levels, scopes } from '../logging';
import RegEx from '../regExp';
import { isActive, getLabel, validateString, sanitizeParameters } from '../utils';
import Articles from './articles';
......@@ -61,7 +62,7 @@ export const createArticle = new ValidatedMethod({
export const removeArticle = new ValidatedMethod({
name: 'articles.removeArticle',
validate: new SimpleSchema({
articleId: { type: String, regEx: SimpleSchema.RegEx.Id, label: getLabel('api.articles.labels.id') },
articleId: { type: String, regEx: RegEx.Id, label: getLabel('api.articles.labels.id') },
}).validator(),
run({ articleId }) {
......@@ -101,7 +102,7 @@ export const removeArticle = new ValidatedMethod({
export const updateArticle = new ValidatedMethod({
name: 'articles.updateArticle',
validate: new SimpleSchema({
articleId: { type: String, regEx: SimpleSchema.RegEx.Id, label: getLabel('api.articles.labels.id') },
articleId: { type: String, regEx: RegEx.Id, label: getLabel('api.articles.labels.id') },
data: Articles.schema.omit('createdAt', 'updatedAt', 'userId', 'slug', 'structure'),
updateStructure: { type: Boolean, defaultValue: false },
}).validator({ clean: true }),
......@@ -156,7 +157,7 @@ export const updateArticle = new ValidatedMethod({
export const visitArticle = new ValidatedMethod({
name: 'articles.visitArticle',
validate: new SimpleSchema({
articleId: { type: String, regEx: SimpleSchema.RegEx.Id, label: getLabel('api.articles.labels.id') },
articleId: { type: String, regEx: RegEx.Id, label: getLabel('api.articles.labels.id') },
}).validator(),
run({ articleId }) {
......
......@@ -2,6 +2,7 @@ import { Meteor } from 'meteor/meteor';
import { Roles } from 'meteor/alanning:roles';
import { FindFromPublication } from 'meteor/percolate:find-from-publication';
import SimpleSchema from 'simpl-schema';
import RegEx from '../../regExp';
import logServer, { levels, scopes } from '../../logging';
import Tags from '../../tags/tags';
import { checkPaginationParams, getLabel, isActive } from '../../utils';
......@@ -48,7 +49,7 @@ FindFromPublication.publish(
userId: {
optional: true,
type: String,
regEx: SimpleSchema.RegEx.Id,
regEx: RegEx.Id,
label: getLabel('api.users.labels.id'),
},
})
......
import { Mongo } from 'meteor/mongo';
import SimpleSchema from 'simpl-schema';
import { getLabel } from '../utils';
import RegEx from '../regExp';
const AsamExtensions = new Mongo.Collection('asamextensions');
......@@ -39,7 +40,7 @@ AsamExtensions.schema = new SimpleSchema({
familleNomCourt: { type: String, label: getLabel('api.asamextensions.labels.familleNomCourt') },
familleNomLong: { type: String, label: getLabel('api.asamextensions.labels.familleNomLong') },
structureId: {
type: SimpleSchema.RegEx.Id,
type: RegEx.Id,
label: getLabel('api.asamextensions.labels.structureId'),
defaultValue: null,
},
......
......@@ -8,6 +8,7 @@ import AsamExtensions from './asamextensions';
import { validateString } from '../utils';
import logServer, { levels, scopes } from '../logging';
import RegEx from '../regExp';
const validateAsam = (extension, entiteNomCourt, entiteNomLong, familleNomCourt, familleNomLong) => {
if (extension) validateString(extension, true);
......@@ -21,10 +22,10 @@ export const assignStructureToAsam = new ValidatedMethod({
name: 'asam.assignStructureToAsam',
validate: new SimpleSchema({
structureId: {
type: SimpleSchema.RegEx.Id,
type: RegEx.Id,
},
extensionId: {
type: SimpleSchema.RegEx.Id,
type: RegEx.Id,
},
extension: {
type: String,
......@@ -74,7 +75,7 @@ export const assignStructureToAsam = new ValidatedMethod({
export const unassignStructureToAsam = new ValidatedMethod({
name: 'asam.unassignStructureToAsam',
validate: new SimpleSchema({ extensionId: { type: SimpleSchema.RegEx.Id } }).validator(),
validate: new SimpleSchema({ extensionId: { type: RegEx.Id } }).validator(),
run({ extensionId }) {
const isAdmin = Roles.userIsInRole(this.userId, 'admin');
if (!isAdmin) {
......@@ -97,7 +98,7 @@ export const unassignStructureToAsam = new ValidatedMethod({
export const deleteAsam = new ValidatedMethod({
name: 'asam.deleteAsam',
validate: new SimpleSchema({ extensionId: { type: SimpleSchema.RegEx.Id } }).validator(),
validate: new SimpleSchema({ extensionId: { type: RegEx.Id } }).validator(),
run({ extensionId }) {
const isAdmin = Roles.userIsInRole(this.userId, 'admin');
if (!isAdmin) {
......
import { Mongo } from 'meteor/mongo';
import SimpleSchema from 'simpl-schema';
import { Tracker } from 'meteor/tracker';
import { getLabel } from '../utils';
const Bookmarks = new Mongo.Collection('bookmarks');
......@@ -49,7 +48,7 @@ Bookmarks.schema = new SimpleSchema(
defaultValue: '',
},
},
{ clean: { removeEmptyStrings: false }, tracker: Tracker },
{ clean: { removeEmptyStrings: false } },
);
Bookmarks.publicFields = {
......
......@@ -10,6 +10,7 @@ import Bookmarks from './bookmarks';
import logServer, { levels, scopes } from '../logging';
import { addUserBookmark, removeElement } from '../personalspaces/methods';
import Groups from '../groups/groups';
import RegEx from '../regExp';
function _updateBookmarkURL(id, url, name, tag) {
logServer(`BOOKMARKS - METHOD - UPDATE - _updateBookmarkURL`, levels.VERBOSE, scopes.SYSTEM, { id, url, name, tag });
......@@ -103,11 +104,11 @@ export const createBookmark = new ValidatedMethod({
export const updateBookmark = new ValidatedMethod({
name: 'bookmark.updateURL',
validate: new SimpleSchema({
id: { type: String, regEx: SimpleSchema.RegEx.Id, label: getLabel('api.bookmarks.labels.id') },
url: { type: String, regEx: SimpleSchema.RegEx.url, label: getLabel('api.bookmarks.labels.url') },
id: { type: String, regEx: RegEx.Id, label: getLabel('api.bookmarks.labels.id') },
url: { type: String, label: getLabel('api.bookmarks.labels.url') },
name: { type: String, label: getLabel('api.bookmarks.labels.name') },
tag: { type: String, label: getLabel('api.bookmarks.labels.tag'), defaultValue: '' },
groupId: { type: String, regEx: SimpleSchema.RegEx.Id, label: getLabel('api.groups.labels.id') },
groupId: { type: String, regEx: RegEx.Id, label: getLabel('api.groups.labels.id') },
}).validator({ clean: true }),
run({ id, url, name, groupId, tag }) {
......@@ -150,8 +151,8 @@ export const updateBookmark = new ValidatedMethod({
export const removeBookmark = new ValidatedMethod({
name: 'bookmark.removeURL',
validate: new SimpleSchema({
url: { type: String, regEx: SimpleSchema.RegEx.url, label: getLabel('api.bookmarks.labels.url') },
groupId: { type: String, regEx: SimpleSchema.RegEx.Id, label: getLabel('api.groups.labels.id') },
url: { type: String, label: getLabel('api.bookmarks.labels.url') },
groupId: { type: String, regEx: RegEx.Id, label: getLabel('api.groups.labels.id') },
}).validator(),
run({ url, groupId }) {
......@@ -194,7 +195,7 @@ export const removeBookmark = new ValidatedMethod({
export const favGroupBookmark = new ValidatedMethod({
name: 'bookmarks.favGroupBookmark',
validate: new SimpleSchema({
bookmarkId: { type: String, regEx: SimpleSchema.RegEx.Id, label: getLabel('api.bookmarks.labels.id') },
bookmarkId: { type: String, regEx: RegEx.Id, label: getLabel('api.bookmarks.labels.id') },
}).validator(),
run({ bookmarkId }) {
......@@ -252,7 +253,7 @@ export const favGroupBookmark = new ValidatedMethod({
export const unfavGroupBookmark = new ValidatedMethod({
name: 'bookmarks.unfavGroupBookmark',
validate: new SimpleSchema({
bookmarkId: { type: String, regEx: SimpleSchema.RegEx.Id, label: getLabel('api.bookmarks.labels.id') },
bookmarkId: { type: String, regEx: RegEx.Id, label: getLabel('api.bookmarks.labels.id') },
}).validator(),
run({ bookmarkId }) {
......
......@@ -5,11 +5,12 @@ import { DDPRateLimiter } from 'meteor/ddp-rate-limiter';
import getFavicon from '../../getFavicon';
import Bookmarks from '../bookmarks';
import logServer, { levels, scopes } from '../../logging';
import RegEx from '../../regExp';
const getWebSiteFavicons = new ValidatedMethod({
name: 'bookmark.getFavicon',
validate: new SimpleSchema({
url: { type: String, regEx: SimpleSchema.RegEx.url },
url: { type: String, regEx: RegEx.Url },
}).validator(),
async run({ url }) {
try {
......
import { Mongo } from 'meteor/mongo';
import SimpleSchema from 'simpl-schema';
import { Tracker } from 'meteor/tracker';
import { getLabel } from '../utils';
import RegEx from '../regExp';
const BusinessReGrouping = new Mongo.Collection('BusinessReGrouping');
......@@ -18,21 +18,18 @@ BusinessReGrouping.deny({
},
});
BusinessReGrouping.schema = new SimpleSchema(
{
name: {
type: String,
min: 1,
label: getLabel('api.businessReGrouping.labels.name'),
},
structure: {
type: SimpleSchema.RegEx.Id,
label: getLabel('api.businessReGrouping.labels.structure'),
defaultValue: '',
},
BusinessReGrouping.schema = new SimpleSchema({
name: {
type: String,
min: 1,
label: getLabel('api.businessReGrouping.labels.name'),
},
{ tracker: Tracker },
);
structure: {
type: RegEx.Id,
label: getLabel('api.businessReGrouping.labels.structure'),
defaultValue: '',
},
});
BusinessReGrouping.publicFields = {
name: 1,
......
......@@ -11,6 +11,7 @@ import BusinessReGrouping from './businessReGrouping';
import Services from '../services/services';
import Structures from '../structures/structures';
import logServer, { levels, scopes } from '../logging';
import RegEx from '../regExp';
export const createBusinessReGrouping = new ValidatedMethod({
name: 'BusinessReGrouping.createBusinessReGrouping',
......@@ -19,7 +20,7 @@ export const createBusinessReGrouping = new ValidatedMethod({
name: { type: String, min: 1, label: getLabel('api.businessReGrouping.labels.name') },
structure: {
type: String,
regEx: SimpleSchema.RegEx.Id,
regEx: RegEx.Id,
label: getLabel('api.businessReGrouping.labels.structure'),
},
}).validator(),
......@@ -95,12 +96,12 @@ export const removeBusinessReGrouping = new ValidatedMethod({
validate: new SimpleSchema({
businessReGroupingId: {
type: String,
regEx: SimpleSchema.RegEx.Id,
regEx: RegEx.Id,
label: getLabel('api.businessReGrouping.labels.id'),
},
structure: {
type: String,
regEx: SimpleSchema.RegEx.Id,
regEx: RegEx.Id,
label: getLabel('api.businessReGrouping.labels.structure'),
},
}).validator(),
......@@ -159,14 +160,14 @@ export const updateBusinessReGrouping = new ValidatedMethod({
validate: new SimpleSchema({
businessReGroupingId: {
type: String,
regEx: SimpleSchema.RegEx.Id,
regEx: RegEx.Id,
label: getLabel('api.businessReGrouping.labels.id'),
},
data: Object,
'data.name': { type: String, min: 1, label: getLabel('api.businessReGrouping.labels.name') },
'data.structure': {
type: String,
regEx: SimpleSchema.RegEx.Id,
regEx: RegEx.Id,
label: getLabel('api.businessReGrouping.labels.structure'),
},
}).validator(),
......
import { Mongo } from 'meteor/mongo';
import SimpleSchema from 'simpl-schema';
import { Tracker } from 'meteor/tracker';
import { getLabel } from '../utils';
const Categories = new Mongo.Collection('categories');
......@@ -18,18 +17,15 @@ Categories.deny({
},
});
Categories.schema = new SimpleSchema(
{
name: {
type: String,
index: true,
unique: true,
min: 1,
label: getLabel('api.categories.labels.name'),
},
Categories.schema = new SimpleSchema({
name: {
type: String,
index: true,
unique: true,
min: 1,
label: getLabel('api.categories.labels.name'),
},
{ tracker: Tracker },
);
});
Categories.publicFields = {
name: 1,
......
......@@ -10,6 +10,7 @@ import { isActive, getLabel, validateString } from '../utils';
import Categories from './categories';
import Services from '../services/services';
import logServer, { levels, scopes } from '../logging';
import RegEx from '../regExp';
export const createCategorie = new ValidatedMethod({
name: 'categories.createCategorie',
......@@ -55,7 +56,7 @@ export const createCategorie = new ValidatedMethod({
export const removeCategorie = new ValidatedMethod({
name: 'categories.removeCategorie',
validate: new SimpleSchema({
categoryId: { type: String, regEx: SimpleSchema.RegEx.Id, label: getLabel('api.categories.labels.id') },
categoryId: { type: String, regEx: RegEx.Id, label: getLabel('api.categories.labels.id') },
}).validator(),
run({ categoryId }) {
......@@ -98,7 +99,7 @@ export const removeCategorie = new ValidatedMethod({
export const updateCategorie = new ValidatedMethod({
name: 'categories.updateCategorie',
validate: new SimpleSchema({
categoryId: { type: String, regEx: SimpleSchema.RegEx.Id, label: getLabel('api.categories.labels.id') },
categoryId: { type: String, regEx: RegEx.Id, label: getLabel('api.categories.labels.id') },
data: Object,
'data.name': { type: String, min: 1, label: getLabel('api.categories.labels.name') },
}).validator(),
......
import { Mongo } from 'meteor/mongo';
import SimpleSchema from 'simpl-schema';
import { Tracker } from 'meteor/tracker';
import PersonalSpaces from '../personalspaces/personalspaces';
import { getLabel } from '../utils';
......@@ -21,24 +20,21 @@ DefaultSpaces.deny({
const simplifiedPersonalSpacesSchema = PersonalSpaces.schema.omit('unsorted', 'userId');
const extensionSchema = new SimpleSchema(
{
structureId: {
type: String,
index: true,
unique: true,
min: 1,
},
updatedAt: {
type: Date,
label: getLabel('api.defaultspaces.labels.updatedAt'),
autoValue() {
return new Date();
},
const extensionSchema = new SimpleSchema({
structureId: {
type: String,
index: true,
unique: true,
min: 1,
},
updatedAt: {
type: Date,
label: getLabel('api.defaultspaces.labels.updatedAt'),
autoValue() {
return new Date();
},
},
{ tracker: Tracker },
);
});
DefaultSpaces.schema = extensionSchema.extend(simplifiedPersonalSpacesSchema);
......
......@@ -9,6 +9,7 @@ import DefaultSpaces from './defaultspaces';
import { checkPersonalSpaceData, generateDefaultPersonalSpace } from '../personalspaces/methods';
import { hasAdminRightOnStructure } from '../structures/utils';
import logServer, { levels, scopes } from '../logging';
import RegEx from '../regExp';
export const updateStructureSpace = new ValidatedMethod({
name: 'defaultspaces.updateStructureSpace',
......@@ -49,7 +50,7 @@ export const updateStructureSpace = new ValidatedMethod({
export const applyDefaultSpaceToAllUsers = new ValidatedMethod({
name: 'defaultspaces.applyDefaultSpaceToAllUsers',
validate: new SimpleSchema({
structureId: { type: String, regEx: SimpleSchema.RegEx.Id },
structureId: { type: String, regEx: RegEx.Id },
}).validator({ clean: true }),
run({ structureId }) {
......