How to use the @webiny/commodo.ref function in @webiny/commodo

To help you get started, we’ve selected a few @webiny/commodo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webiny / webiny-js / packages / api-security / src / plugins / models / securityGroups2Models.model.js View on Github external
withFields(() => ({
            model: ref({ instanceOf: [], refNameField: "modelName" }),
            modelName: string(),
            group: ref({
                instanceOf: SecurityGroup
            })
        }))
    )(createBase());
github webiny / webiny-js / packages / api-security / src / plugins / models / securityRoles2Models.model.js View on Github external
withFields(() => ({
            model: ref({ instanceOf: [], refNameField: "modelClassId" }),
            modelClassId: string(),
            role: ref({
                instanceOf: SecurityRole
            })
        }))
    )(createBase());
github webiny / webiny-js / packages / api-forms / src / plugins / models / formSubmission.model.js View on Github external
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({
                instanceOf: withFields({
                    ip: string({ validation: validation.create("required") }),
                    locale: string({ validation: validation.create("required") }),
github webiny / webiny-js / packages / api-security / src / plugins / models / securityGroups2Models.model.js View on Github external
withFields(() => ({
            model: ref({ instanceOf: [], refNameField: "modelName" }),
            modelName: string(),
            group: ref({
                instanceOf: SecurityGroup
            })
        }))
    )(createBase());
github webiny / webiny-js / packages / api-forms / src / plugins / models / formSubmission.model.js View on Github external
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({
                instanceOf: withFields({
                    ip: string({ validation: validation.create("required") }),
                    locale: string({ validation: validation.create("required") }),
                    submittedOn: skipOnPopulate()(
                        date({ validation: validation.create("required") })
                    )
                })()
            }),
github webiny / webiny-js / packages / api-security / src / plugins / models / securityUser.model.js View on Github external
return bcrypt.hashSync(value, bcrypt.genSaltSync(10));
                }
                return instance.password;
            })(
                string({
                    validation: validation.create("required")
                })
            ),
            firstName: string(),
            lastName: string(),
            roles: ref({
                list: true,
                instanceOf: [SecurityRole, "model"],
                using: [SecurityRoles2Models, "role"]
            }),
            groups: ref({
                list: true,
                instanceOf: [SecurityGroup, "model"],
                using: [SecurityGroups2Models, "group"]
            }),
            avatar: context.commodo.fields.id()
        })),
        withProps(instance => ({
github webiny / webiny-js / packages / api-page-builder / src / plugins / models / pbPage.model.js View on Github external
withFields(instance => ({
            category: ref({ instanceOf: PbCategory, validation: validation.create("required") }),
            publishedOn: skipOnPopulate()(date()),
            title: onSet(value => (instance.locked ? instance.title : value))(
                string({ validation: validation.create("required") })
            ),
            snippet: onSet(value => (instance.locked ? instance.snippet : value))(string()),
            url: onSet(value => (instance.locked ? instance.url : value))(
                string({ validation: validation.create("required") })
            ),
            content: onSet(value => (instance.locked ? instance.content : value))(
                content({ context })
            ),
            settings: onSet(value => (instance.locked ? instance.settings : value))(
                fields({
                    instanceOf: PbPageSettings
                })
            ),
github webiny / webiny-js / packages / api-security / src / plugins / models / securityGroup.model.js View on Github external
withFields(() => ({
            description: string(),
            name: string(),
            slug: string(),
            system: boolean(),
            roles: ref({
                list: true,
                instanceOf: [SecurityRole, "model"],
                using: [SecurityRoles2Models, "role"]
            })
        })),
        withHooks({
github webiny / webiny-js / packages / api-security / src / plugins / models / securityRoles2Models.model.js View on Github external
withFields(() => ({
            model: ref({ instanceOf: [], refNameField: "modelClassId" }),
            modelClassId: string(),
            role: ref({
                instanceOf: SecurityRole
            })
        }))
    )(createBase());
github webiny / webiny-js / packages / api-security / src / plugins / models / securityUser.model.js View on Github external
validation: validation.create("required")
                })
            ),
            password: onSet(value => {
                if (value) {
                    return bcrypt.hashSync(value, bcrypt.genSaltSync(10));
                }
                return instance.password;
            })(
                string({
                    validation: validation.create("required")
                })
            ),
            firstName: string(),
            lastName: string(),
            roles: ref({
                list: true,
                instanceOf: [SecurityRole, "model"],
                using: [SecurityRoles2Models, "role"]
            }),
            groups: ref({
                list: true,
                instanceOf: [SecurityGroup, "model"],
                using: [SecurityGroups2Models, "group"]
            }),
            avatar: context.commodo.fields.id()
        })),
        withProps(instance => ({