How to use the @webiny/commodo.fields 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-forms / src / plugins / models / Form / createSettingsModel.js View on Github external
export default ({ context, FormSettings }) => {

    // When installing the FormBuilder app on a blank system, defaultLocale will be blank, because I18N app wasn't
    // installed yet, meaning no default locale was selected.
    let defaultLocale = null;
    if (context.i18n.getDefaultLocale()) {
        defaultLocale = context.i18n.getDefaultLocale().id;
    }

    return withFields({
        layout: fields({
            value: {},
            instanceOf: withFields({
                renderer: string({ value: "default" })
            })()
        }),
        submitButtonLabel: i18nString({ context }),
        successMessage: i18nObject({ context }),
        termsOfServiceMessage: fields({
            instanceOf: withFields({
                message: i18nObject({ context }),
                errorMessage: i18nString({ context }),
                enabled: boolean()
            })()
        }),
        reCaptcha: fields({
            instanceOf: flow(
github webiny / webiny-js / packages / api-forms / src / plugins / models / Form / createSettingsModel.js View on Github external
// installed yet, meaning no default locale was selected.
    let defaultLocale = null;
    if (context.i18n.getDefaultLocale()) {
        defaultLocale = context.i18n.getDefaultLocale().id;
    }

    return withFields({
        layout: fields({
            value: {},
            instanceOf: withFields({
                renderer: string({ value: "default" })
            })()
        }),
        submitButtonLabel: i18nString({ context }),
        successMessage: i18nObject({ context }),
        termsOfServiceMessage: fields({
            instanceOf: withFields({
                message: i18nObject({ context }),
                errorMessage: i18nString({ context }),
                enabled: boolean()
            })()
        }),
        reCaptcha: fields({
            instanceOf: flow(
                withProps({
                    settings: {
                        get enabled() {
                            return new Promise(async resolve => {
                                const settings = await FormSettings.load();
                                resolve(Boolean(get(settings, "data.reCaptcha.enabled")));
                            });
                        },
github webiny / webiny-js / packages / api-mailchimp / src / mailchimpSettings.model.js View on Github external
withFields(instance => ({
            key: setOnce()(string({ value: SETTINGS_KEY })),
            data: fields({
                instanceOf: withFields({
                    enabled: boolean(),
                    apiKey: onSet(value => {
                        if (value && value !== instance.apiKey) {
                            instance.registerHookCallback("beforeSave", async () => {
                                console.log("TODO: setOnce");

                                const mailchimp = new MailchimpApi({ apiKey: value });
                                const valid = await mailchimp.isValidApiKey();
                                if (!valid) {
                                    throw Error("API key invalid.");
                                }
                            });
                        }
                        return value;
                    })(string())
github webiny / webiny-js / packages / api-page-builder / src / plugins / pageSettings / seo.js View on Github external
apply({ fields: settingsFields }) {
            settingsFields.seo = fields({
                value: {},
                instanceOf: withFields({
                    title: string(),
                    description: string(),
                    meta: fields({
                        list: true,
                        value: [],
                        instanceOf: withFields({
                            name: string(),
                            content: string()
                        })()
                    })
                })()
            });
        }
    },
github webiny / webiny-js / packages / api-cookie-policy / src / cookiePolicySettings.model.js View on Github external
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({
                            href: string(),
                            message: string(),
                            dismiss: string(),
                            link: string()
                        })()
                    })
                })()
            })
        })
    )(createBase());
};
github webiny / webiny-js / packages / api-page-builder / src / plugins / models / pbSettings.model.js View on Github external
const { id } = context.commodo.fields;

    return flow(
        withName("Settings"),
        withStaticProps({
            async load() {
                return await this.findOne({ query: { key: SETTINGS_KEY } });
            }
        }),
        withFields({
            key: setOnce()(string({ value: SETTINGS_KEY })),
            data: fields({
                value: {},
                instanceOf: withFields({
                    pages: fields({
                        instanceOf: withFields({
                            home: id(),
                            notFound: id(),
                            error: id()
                        })()
                    }),
                    installation: fields({ instanceOf: InstallationFields, value: {} }),
                    name: string(),
                    domain: string(),
                    favicon: id(),
                    logo: id(),
                    social: fields({
                        instanceOf: withFields({
                            facebook: string(),
                            twitter: string(),
                            instagram: string(),
github webiny / webiny-js / packages / api-forms / src / plugins / models / formSubmission.model.js View on Github external
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") })
                    )
                })()
            }),
            logs: fields({
                list: true,
                value: [],
                instanceOf: withFields({
                    type: string({
                        validation: validation.create("required,in:error:warning:info:success"),
                        message: string(),
                        data: object(),
github webiny / webiny-js / packages / api-page-builder / src / plugins / pageSettings / seo.js View on Github external
apply({ fields: settingsFields }) {
            settingsFields.seo = fields({
                value: {},
                instanceOf: withFields({
                    title: string(),
                    description: string(),
                    meta: fields({
                        list: true,
                        value: [],
                        instanceOf: withFields({
                            name: string(),
                            content: string()
                        })()
                    })
                })()
            });
        }
    },
github webiny / webiny-js / packages / api-forms / src / plugins / models / formSubmission.model.js View on Github external
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") })
                    )
                })()
            }),
            logs: fields({
                list: true,
                value: [],
                instanceOf: withFields({
                    type: string({
                        validation: validation.create("required,in:error:warning:info:success"),
                        message: string(),
                        data: object(),
                        createdOn: date({ value: new Date() })
                    })
                })()
            })
        })),
        withHooks({
github webiny / webiny-js / packages / api-page-builder / src / plugins / models / pbSettings.model.js View on Github external
data: fields({
                value: {},
                instanceOf: withFields({
                    pages: fields({
                        instanceOf: withFields({
                            home: id(),
                            notFound: id(),
                            error: id()
                        })()
                    }),
                    installation: fields({ instanceOf: InstallationFields, value: {} }),
                    name: string(),
                    domain: string(),
                    favicon: id(),
                    logo: id(),
                    social: fields({
                        instanceOf: withFields({
                            facebook: string(),
                            twitter: string(),
                            instagram: string(),
                            image: id()
                        })()
                    })
                })()
            })
        })
    )(createBase());
};