{ "kind": "open-flow-workflow", "version": 1, "name": "Create and Update a MailerLite Subscriber", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_a05b24c4c72dee69": { "name": "Enter subscriber details", "kind": "start", "inputDefs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "email" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "name" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "city" } ] }, "n_832b3877ac3d10da": { "inputs": { "email": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_a05b24c4c72dee69", "output": "email" } ] }, "name": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_a05b24c4c72dee69", "output": "name" } ] }, "city": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_a05b24c4c72dee69", "output": "city" } ] } }, "name": "Validate subscriber details", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "email" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "name" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "city" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "email" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "name" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "city" } ], "name": "Validate subscriber details", "moduleId": "n_3d03a7383168b4c1", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_f902a4c9c2dba71d": { "inputs": { "email": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_832b3877ac3d10da", "output": "email" } ] }, "name": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_832b3877ac3d10da", "output": "name" } ] } }, "name": "Create or update subscriber", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "email" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "name" } ], "outputs": [ { "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "Subscriber object returned after a MailerLite upsert request." }, "nullable": false, "handle": "data" } ], "name": "Create or update subscriber", "moduleId": "n_770637fb5c7f4829", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [ { "action": "mailerlite.upsert_subscriber" } ] } ] } }, "n_1f57693cf183c4c9": { "inputs": { "data": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_f902a4c9c2dba71d", "output": "data" } ] }, "email": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_832b3877ac3d10da", "output": "email" } ] } }, "name": "Identify subscriber", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "Subscriber object returned after a MailerLite upsert request." }, "nullable": false, "handle": "data" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "email" } ], "outputs": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "id" } ], "name": "Identify subscriber", "moduleId": "n_93d34d05f5298f2d", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_c6db0cf2423cd90a": { "inputs": { "id": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_1f57693cf183c4c9", "output": "id" } ] }, "city": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_832b3877ac3d10da", "output": "city" } ] } }, "name": "Update city", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "id" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "city" } ], "outputs": [ { "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "Subscriber object returned after a MailerLite update request." }, "nullable": false, "handle": "data" } ], "name": "Update city", "moduleId": "n_452ffdf3f6b2010e", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [ { "action": "mailerlite.update_subscriber" } ] } ] } }, "n_2e840c53b9f1c6be": { "inputs": { "data": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_c6db0cf2423cd90a", "output": "data" } ] }, "id": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_1f57693cf183c4c9", "output": "id" } ] } }, "name": "Confirm update", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "Subscriber object returned after a MailerLite update request." }, "nullable": false, "handle": "data" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "id" } ], "outputs": [ { "jsonSchema": { "type": "boolean" }, "nullable": false, "handle": "ok" } ], "name": "Confirm update", "moduleId": "n_c49391187658b335", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_76d337c1bde40eae": { "inputs": { "subscriber_id_or_email": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_1f57693cf183c4c9", "output": "id" } ] } }, "name": "Read subscriber", "kind": "task", "task": { "inputs": [ { "description": "Subscriber ID or email accepted by the official MailerLite fetch endpoint.", "jsonSchema": { "type": "string", "minLength": 1, "description": "Subscriber ID or email accepted by the official MailerLite fetch endpoint." }, "nullable": false, "handle": "subscriber_id_or_email" } ], "outputs": [ { "description": "Subscriber object returned by MailerLite.", "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "Subscriber object returned by MailerLite." }, "nullable": false, "handle": "data" } ], "name": "Read subscriber", "executor": { "kind": "connector", "action": "mailerlite.get_subscriber" } } }, "n_5f68ee4558af9f3b": { "inputs": { "data": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_76d337c1bde40eae", "output": "data" } ] }, "id": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_1f57693cf183c4c9", "output": "id" } ] }, "email": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_832b3877ac3d10da", "output": "email" } ] }, "name": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_832b3877ac3d10da", "output": "name" } ] }, "city": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_832b3877ac3d10da", "output": "city" } ] } }, "name": "Verify subscriber", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "Subscriber object returned by MailerLite." }, "nullable": false, "handle": "data" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "id" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "email" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "name" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "city" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "subscriber" } ], "name": "Verify subscriber", "moduleId": "n_5d0fc627a94b1c25", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_cacf2d090294a704": { "name": "MailerLite subscriber", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "subscriber" } ], "outputMappings": { "subscriber": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_5f68ee4558af9f3b", "output": "subscriber" } ] } } } }, "edges": [ { "source": "n_a05b24c4c72dee69", "target": "n_832b3877ac3d10da" }, { "source": "n_832b3877ac3d10da", "target": "n_f902a4c9c2dba71d" }, { "source": "n_f902a4c9c2dba71d", "target": "n_1f57693cf183c4c9" }, { "source": "n_1f57693cf183c4c9", "target": "n_c6db0cf2423cd90a" }, { "source": "n_c6db0cf2423cd90a", "target": "n_2e840c53b9f1c6be" }, { "source": "n_2e840c53b9f1c6be", "target": "n_76d337c1bde40eae" }, { "source": "n_76d337c1bde40eae", "target": "n_5f68ee4558af9f3b" }, { "source": "n_5f68ee4558af9f3b", "target": "n_cacf2d090294a704" } ] } }, "modules": { "n_3d03a7383168b4c1": { "name": "Validate subscriber details", "imports": [], "source": "export default function setup({email,name,city}){if(typeof email!=='string'||!/^\\S+@\\S+\\.\\S+$/.test(email.trim())||typeof name!=='string'||!name.trim()||typeof city!=='string'||!city.trim())throw Error('Enter an email, name and city');return{email:email.trim(),name:name.trim(),city:city.trim()};}\n" }, "n_770637fb5c7f4829": { "name": "Create or update subscriber", "imports": [], "source": "export default async function create({email,name},context){return await context.actions.call('mailerlite.upsert_subscriber',{email,fields:{name}});}\n" }, "n_93d34d05f5298f2d": { "name": "Identify subscriber", "imports": [], "source": "export default function identify({data,email}){if(!data||typeof data.id!=='string'||!data.id||data.email?.toLowerCase()!==email.toLowerCase())throw Error('MailerLite did not return the requested subscriber');return{id:data.id};}\n" }, "n_452ffdf3f6b2010e": { "name": "Update city", "imports": [], "source": "export default async function update({id,city},context){return await context.actions.call('mailerlite.update_subscriber',{subscriber_id:id,fields:{city}});}\n" }, "n_c49391187658b335": { "name": "Confirm update", "imports": [], "source": "export default function updated({data,id}){if(!data||data.id!==id)throw Error('MailerLite did not confirm the same subscriber');return{ok:true};}\n" }, "n_5d0fc627a94b1c25": { "name": "Verify subscriber", "imports": [], "source": "export default function result({data,id,email,name,city}){if(!data||data.id!==id||data.email?.toLowerCase()!==email.toLowerCase()||data.fields?.name!==name||data.fields?.city!==city)throw Error('MailerLite did not return the expected subscriber');return{subscriber:data};}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }