Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default ({ createBase }) => {
const SecurityRole = flow(
withName("SecurityRole"),
withFields({
name: string(),
slug: string(),
description: string(),
system: boolean(),
scopes: string({ list: true })
}),
withHooks({
async beforeCreate() {
const existingRole = await SecurityRole.findOne({
query: { slug: this.slug }
});
if (existingRole) {
throw Error(`Role with slug "${this.slug}" already exists.`);
}
},
async beforeDelete() {
if (this.system) {
throw Error(`Cannot delete system role.`);
export default ({ createBase }) =>
flow(
withName("PbCategory"),
withFields({
name: string({ validation: validation.create("required") }),
slug: string({ validation: validation.create("required") }),
url: string({ validation: validation.create("required") }),
layout: string()
})
)(createBase());
apply({ fields: settingsFields, context }) {
settingsFields.social = fields({
value: {},
instanceOf: withFields({
meta: fields({
value: [],
list: true,
instanceOf: withFields({
property: string(),
content: string()
})()
}),
title: string(),
description: string(),
image: context.commodo.fields.id()
})()
});
}
},
export default context =>
withFields({
_id: string({ validation: validation.create("required") }),
type: string({ validation: validation.create("required") }),
name: string({ validation: validation.create("required") }),
fieldId: string({ validation: validation.create("required") }),
label: i18nString({ context }),
helpText: i18nString({ context }),
placeholderText: i18nString({ context }),
options: fields({
list: true,
instanceOf: withFields({
label: i18nString({ context }),
value: string({ value: "" })
})()
}),
validation: fields({
list: true,
instanceOf: withFields({
name: string({ validation: validation.create("required") }),
export default ({ createBase }) =>
flow(
withName("PbCategory"),
withFields({
name: string({ validation: validation.create("required") }),
slug: string({ validation: validation.create("required") }),
url: string({ validation: validation.create("required") }),
layout: string()
})
)(createBase());
position: string({
value: "bottom",
validation: validation.create("in:bottom:top:bottom-left:bottom-right")
}),
palette: fields({
instanceOf: withFields({
popup: fields({ instanceOf: ColorsModel }),
button: fields({ instanceOf: ColorsModel })
})()
}),
content: fields({
instanceOf: withFields({
href: string(),
message: string(),
dismiss: string(),
link: string()
})()
})
})()
})
})
)(createBase());
};
export default ({ createBase }) => {
const SecurityRole = flow(
withName("SecurityRole"),
withFields({
name: string(),
slug: string(),
description: string(),
system: boolean(),
scopes: string({ list: true })
}),
withHooks({
async beforeCreate() {
const existingRole = await SecurityRole.findOne({
query: { slug: this.slug }
});
if (existingRole) {
throw Error(`Role with slug "${this.slug}" already exists.`);
}
},
async beforeDelete() {
if (this.system) {
throw Error(`Cannot delete system role.`);
}
export default context =>
withFields({
_id: string({ validation: validation.create("required") }),
type: string({ validation: validation.create("required") }),
name: string({ validation: validation.create("required") }),
fieldId: string({ validation: validation.create("required") }),
label: i18nString({ context }),
helpText: i18nString({ context }),
placeholderText: i18nString({ context }),
options: fields({
list: true,
instanceOf: withFields({
label: i18nString({ context }),
value: string({ value: "" })
})()
}),
validation: fields({
list: true,
instanceOf: withFields({
name: string({ validation: validation.create("required") }),
message: i18nString({ context }),
settings: object({ value: {} })
})()
}),
settings: object({ value: {} })
})();
export default ({ createBase, context }) =>
flow(
withName("PbPageElement"),
withFields({
name: string({ validation: validation.create("required") }),
category: string(),
type: string({ validation: validation.create("required,in:element:block") }),
content: content({ context }),
preview: context.commodo.fields.id()
})
)(createBase({ maxPerPage: 1000 }));
export default ({ createBase }) => {
const SecurityRole = flow(
withName("SecurityRole"),
withFields({
name: string(),
slug: string(),
description: string(),
system: boolean(),
scopes: string({ list: true })
}),
withHooks({
async beforeCreate() {
const existingRole = await SecurityRole.findOne({
query: { slug: this.slug }
});
if (existingRole) {
throw Error(`Role with slug "${this.slug}" already exists.`);
}
},
async beforeDelete() {
if (this.system) {