{ "kind": "open-flow-workflow", "version": 1, "name": "Create, Update and Read a Strapi Post", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_46cc184e09f44d9a": { "name": "Enter post details", "kind": "start", "inputDefs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "instanceUrl" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "title" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "content" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "description" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "slug" } ] }, "n_24b14ae40d4cfb42": { "inputs": { "instanceUrl": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_46cc184e09f44d9a", "output": "instanceUrl" } ] }, "title": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_46cc184e09f44d9a", "output": "title" } ] }, "content": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_46cc184e09f44d9a", "output": "content" } ] }, "description": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_46cc184e09f44d9a", "output": "description" } ] }, "slug": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_46cc184e09f44d9a", "output": "slug" } ] } }, "name": "Prepare post", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "instanceUrl" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "title" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "content" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "description" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "slug" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "slug" } ], "name": "Prepare post", "moduleId": "n_52954c0e286064c3", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_93134ee5650f0e8c": { "inputs": { "url": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_24b14ae40d4cfb42", "output": "url" } ] }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_24b14ae40d4cfb42", "output": "body" } ] }, "auth.token": { "kind": "unset" } }, "name": "Create post", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "auth.token" } ], "outputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "type": "object", "additionalProperties": { "type": "string" } }, "nullable": false, "handle": "headers" } ], "name": "Create post", "executor": { "method": "POST", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "json", "authentication": { "type": "bearer" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_488b7519e706cdda": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_93134ee5650f0e8c", "output": "body" } ] }, "url": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_24b14ae40d4cfb42", "output": "url" } ] }, "slug": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_24b14ae40d4cfb42", "output": "slug" } ] } }, "name": "Prepare slug update", "kind": "task", "task": { "inputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "slug" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "id" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "body" } ], "name": "Prepare slug update", "moduleId": "n_2108ab81003455c9", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_c52fc83c4b13d688": { "inputs": { "url": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_488b7519e706cdda", "output": "url" } ] }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_488b7519e706cdda", "output": "body" } ] }, "auth.token": { "kind": "unset" } }, "name": "Update slug", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "auth.token" } ], "outputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "type": "object", "additionalProperties": { "type": "string" } }, "nullable": false, "handle": "headers" } ], "name": "Update slug", "executor": { "method": "PUT", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "json", "authentication": { "type": "bearer" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_29ef26fc8964f541": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_c52fc83c4b13d688", "output": "body" } ] }, "url": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_488b7519e706cdda", "output": "url" } ] }, "id": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_488b7519e706cdda", "output": "id" } ] }, "slug": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_24b14ae40d4cfb42", "output": "slug" } ] } }, "name": "Confirm update", "kind": "task", "task": { "inputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "id" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "slug" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "id" } ], "name": "Confirm update", "moduleId": "n_7b544fd52115100e", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_7772c4acac89dd2b": { "inputs": { "url": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_29ef26fc8964f541", "output": "url" } ] }, "auth.token": { "kind": "unset" } }, "name": "Read post", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "auth.token" } ], "outputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "type": "object", "additionalProperties": { "type": "string" } }, "nullable": false, "handle": "headers" } ], "name": "Read post", "executor": { "method": "GET", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "none", "authentication": { "type": "bearer" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_fca8c92baf922159": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7772c4acac89dd2b", "output": "body" } ] }, "id": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_488b7519e706cdda", "output": "id" } ] } }, "name": "Confirm post", "kind": "task", "task": { "inputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "id" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "post" } ], "name": "Confirm post", "moduleId": "n_aedf56a1f2cf2d9b", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_15bb755ee1914fd4": { "name": "Post", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "post" } ], "outputMappings": { "post": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_fca8c92baf922159", "output": "post" } ] } } } }, "edges": [ { "source": "n_46cc184e09f44d9a", "target": "n_24b14ae40d4cfb42" }, { "source": "n_24b14ae40d4cfb42", "target": "n_93134ee5650f0e8c" }, { "source": "n_93134ee5650f0e8c", "target": "n_488b7519e706cdda" }, { "source": "n_488b7519e706cdda", "target": "n_c52fc83c4b13d688" }, { "source": "n_c52fc83c4b13d688", "target": "n_29ef26fc8964f541" }, { "source": "n_29ef26fc8964f541", "target": "n_7772c4acac89dd2b" }, { "source": "n_7772c4acac89dd2b", "target": "n_fca8c92baf922159" }, { "source": "n_fca8c92baf922159", "target": "n_15bb755ee1914fd4" } ] } }, "modules": { "n_52954c0e286064c3": { "name": "Prepare post", "imports": [], "source": "export default async function({instanceUrl,title,content,description,slug}){let u;try{u=new URL(instanceUrl)}catch{throw Error('Enter an HTTPS Strapi instance URL')}if(u.protocol!=='https:'||u.username||u.password||u.search||u.hash)throw Error('Enter an HTTPS Strapi instance URL');if(!title.trim()||!content.trim()||!description.trim()||!slug.trim())throw Error('Enter post fields and slug');return {url:u.toString().replace(/\\/$/,'')+'/api/posts',body:{data:{Title:title,Content:content,Description:description}},slug}}\n" }, "n_2108ab81003455c9": { "name": "Prepare slug update", "imports": [], "source": "export default async function({body,url,slug}){const d=body?.data;if(!d||typeof d.documentId!=='string'||!/^[A-Za-z0-9_-]+$/.test(d.documentId))throw Error('Strapi did not return a document ID');return {url:url+'/'+encodeURIComponent(d.documentId),id:d.documentId,body:{data:{slug}}}}\n" }, "n_7b544fd52115100e": { "name": "Confirm update", "imports": [], "source": "export default async function({body,url,id,slug}){if(body?.data?.documentId!==id||body?.data?.slug!==slug)throw Error('Strapi did not confirm the update');return {url,id}}\n" }, "n_aedf56a1f2cf2d9b": { "name": "Confirm post", "imports": [], "source": "export default async function({body,id}){if(body?.data?.documentId!==id)throw Error('Strapi returned a different document');return {post:body.data}}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }