How to use the @webiny/commodo.withStaticProps 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-mailchimp / src / mailchimpSettings.model.js View on Github external
export default ({ createBase }) => {
    return flow(
        withName("Settings"),
        withStaticProps({
            async load() {
                return await this.findOne({ query: { key: SETTINGS_KEY } });
            }
        }),
        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();
github webiny / webiny-js / packages / api-page-builder / src / plugins / models / pbSettings.model.js View on Github external
for (let number = 1; number <= 5; number++) {
                    if (!this.getStep(number).completed) {
                        return false;
                    }
                }

                return true;
            }
        })
    )();

    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()
                        })()
                    }),
github webiny / webiny-js / packages / api-cookie-policy / src / cookiePolicySettings.model.js View on Github external
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 }),
github webiny / webiny-js / packages / api-google-tag-manager / src / googleTagManagerSettings.model.js View on Github external
export default ({ createBase }) => {
    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(),
                    code: string()
                })()
            })
        })
    )(createBase());
};
github webiny / webiny-js / packages / api-files / src / plugins / models / filesSettings.model.js View on Github external
export default ({ createBase }) => {
    const FilesSettings = flow(
        withName("Settings"),
        withStaticProps({
            async load() {
                let settings = await this.findOne({ query: { key: SETTINGS_KEY } });
                if (!settings) {
                    settings = new FilesSettings();
                    await settings.save();
                }
                return settings;
            }
        }),
        withFields({
            key: setOnce()(string({ value: SETTINGS_KEY })),
            data: fields({
                value: {},
                instanceOf: withFields({
                    installed: boolean({ value: false }),
                    srcPrefix: onSet(value => {