Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const createBase = ({ maxPerPage = 100 } = {}) =>
flow(
withFields({
id: context.commodo.fields.id()
}),
withStorage({ driver, maxPerPage }),
withUser(context),
withSoftDelete(),
withCrudLogs()
)();
export default ({ createBase, SecurityRole }) =>
flow(
withName("SecurityRoles2Models"),
withFields(() => ({
model: ref({ instanceOf: [], refNameField: "modelClassId" }),
modelClassId: string(),
role: ref({
instanceOf: SecurityRole
})
}))
)(createBase());
export default ({ createBase, SecurityRole, SecurityRoles2Models }) => {
const SecurityGroup = flow(
withName("SecurityGroup"),
withFields(() => ({
description: string(),
name: string(),
slug: string(),
system: boolean(),
roles: ref({
list: true,
instanceOf: [SecurityRole, "model"],
using: [SecurityRoles2Models, "role"]
})
})),
withHooks({
async beforeCreate() {
const existingGroup = await SecurityGroup.findOne({
query: { slug: this.slug }
});
if (existingGroup) {
const createBase = () =>
flow(
withFields({
id: context.commodo.fields.id()
}),
withStorage({ driver }),
withUser(context),
withSoftDelete(),
withCrudLogs()
)();
export default ({ createBase, Form }) => {
return flow(
withName("FormSubmission"),
withFields(instance => ({
form: fields({
instanceOf: withFields({
parent: ref({
parent: instance,
instanceOf: Form,
validation: validation.create("required")
}),
revision: ref({
parent: instance,
instanceOf: Form,
validation: validation.create("required")
})
})()
}),
data: object({ validation: validation.create("required") }),
meta: fields({
export default ({ createBase }) => {
const ColorsModel = withFields({
background: string(),
text: string()
})();
return flow(
withName("Settings"),
withStaticProps({
async load() {
return await this.findOne({ query: { key: SETTINGS_KEY } });
}
}),
withFields({
key: setOnce()(string({ value: SETTINGS_KEY })),
data: fields({
instanceOf: withFields({
enabled: boolean(),
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({
const createBase = ({ maxPerPage = 100 } = {}) =>
flow(
withFields({
id: context.commodo.fields.id()
}),
withStorage({ driver, maxPerPage }),
withUser(context),
withSoftDelete(),
withCrudLogs()
)();
const createBase = () =>
flow(
withFields({
id: context.commodo.fields.id()
}),
withStorage({ driver }),
withUser(context),
withSoftDelete(),
withCrudLogs()
)();
const createBase = () =>
flow(
withFields({
id: context.commodo.fields.id()
}),
withStorage({ driver }),
withUser(context),
withSoftDelete(),
withCrudLogs()
)();
export default context => baseFn => {
return flow(
withProps({
getUser() {
return context.user;
},
getUserId() {
return context.user ? context.user.id : null;
}
}),
withFields({
createdBy: skipOnPopulate()(id()),
updatedBy: skipOnPopulate()(id()),
deletedBy: skipOnPopulate()(id())
}),
withHooks({
beforeCreate() {
this.createdBy = this.getUserId();
},
beforeUpdate() {
this.updatedBy = this.getUserId();
},
beforeDelete() {
this.deletedBy = this.getUserId();
}
})
)(baseFn);