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 }) => {
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();
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()
})()
}),
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 }),
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());
};
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 => {