{ "kind": "open-flow-workflow", "version": 1, "name": "Create and Update a Google Contact", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_ee2ad8be4a3ae272": { "name": "Enter contact details", "kind": "start", "inputDefs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "givenName" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "familyName" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "company" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "title" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "domain" } ] }, "n_7f48894b1e6067f7": { "inputs": { "givenName": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ee2ad8be4a3ae272", "output": "givenName" } ] }, "familyName": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ee2ad8be4a3ae272", "output": "familyName" } ] }, "company": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ee2ad8be4a3ae272", "output": "company" } ] }, "title": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ee2ad8be4a3ae272", "output": "title" } ] }, "domain": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ee2ad8be4a3ae272", "output": "domain" } ] } }, "name": "Validate contact details", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "givenName" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "familyName" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "company" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "title" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "domain" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "givenName" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "familyName" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "company" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "title" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "domain" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "body" } ], "name": "Validate contact details", "moduleId": "n_c1c6783643999a3e", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_c890cb780b66a422": { "inputs": { "url": { "kind": "value", "value": "https://people.googleapis.com/v1/people:createContact" }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7f48894b1e6067f7", "output": "body" } ] }, "auth.token": { "kind": "unset" } }, "name": "Create contact", "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 contact", "executor": { "method": "POST", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "json", "authentication": { "type": "bearer" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_2f6642a4394e43bf": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_c890cb780b66a422", "output": "body" } ] } }, "name": "Identify contact", "kind": "task", "task": { "inputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "resourceName" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" } ], "name": "Identify contact", "moduleId": "n_039fbc6e349cfdba", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_6b14c84bbb15d23e": { "inputs": { "url": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_2f6642a4394e43bf", "output": "url" } ] }, "query.personFields": { "kind": "value", "value": "metadata" }, "auth.token": { "kind": "unset" } }, "name": "Read contact version", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": { "anyOf": [ { "type": [ "string", "number", "boolean" ] }, { "type": "array", "items": { "type": [ "string", "number", "boolean" ] } } ] }, "nullable": true, "handle": "query.personFields" }, { "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 contact version", "executor": { "method": "GET", "query": { "mode": "fields", "names": [ "personFields" ] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "none", "authentication": { "type": "bearer" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_3d6a490ef19a6e85": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_6b14c84bbb15d23e", "output": "body" } ] }, "resourceName": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_2f6642a4394e43bf", "output": "resourceName" } ] }, "company": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7f48894b1e6067f7", "output": "company" } ] }, "title": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7f48894b1e6067f7", "output": "title" } ] }, "domain": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7f48894b1e6067f7", "output": "domain" } ] } }, "name": "Prepare organization update", "kind": "task", "task": { "inputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "resourceName" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "company" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "title" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "domain" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "body" } ], "name": "Prepare organization update", "moduleId": "n_5e358dc5b6980717", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_3a3bb21deaee35a6": { "inputs": { "url": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_3d6a490ef19a6e85", "output": "url" } ] }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_3d6a490ef19a6e85", "output": "body" } ] }, "query.updatePersonFields": { "kind": "value", "value": "organizations" }, "query.personFields": { "kind": "value", "value": "metadata,organizations" }, "auth.token": { "kind": "unset" } }, "name": "Set the organization", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": { "anyOf": [ { "type": [ "string", "number", "boolean" ] }, { "type": "array", "items": { "type": [ "string", "number", "boolean" ] } } ] }, "nullable": true, "handle": "query.updatePersonFields" }, { "jsonSchema": { "anyOf": [ { "type": [ "string", "number", "boolean" ] }, { "type": "array", "items": { "type": [ "string", "number", "boolean" ] } } ] }, "nullable": true, "handle": "query.personFields" }, { "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": "Set the organization", "executor": { "method": "PATCH", "query": { "mode": "fields", "names": [ "updatePersonFields", "personFields" ] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "json", "authentication": { "type": "bearer" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_6a04f17d28661c3d": { "inputs": { "url": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_2f6642a4394e43bf", "output": "url" } ] }, "query.personFields": { "kind": "value", "value": "names,organizations,metadata" }, "auth.token": { "kind": "unset" } }, "name": "Read updated contact", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": { "anyOf": [ { "type": [ "string", "number", "boolean" ] }, { "type": "array", "items": { "type": [ "string", "number", "boolean" ] } } ] }, "nullable": true, "handle": "query.personFields" }, { "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 updated contact", "executor": { "method": "GET", "query": { "mode": "fields", "names": [ "personFields" ] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "none", "authentication": { "type": "bearer" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_8bcc0bcc2cae6eb7": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_6a04f17d28661c3d", "output": "body" } ] }, "resourceName": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_2f6642a4394e43bf", "output": "resourceName" } ] }, "company": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7f48894b1e6067f7", "output": "company" } ] }, "title": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7f48894b1e6067f7", "output": "title" } ] }, "domain": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7f48894b1e6067f7", "output": "domain" } ] } }, "name": "Verify the contact", "kind": "task", "task": { "inputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "resourceName" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "company" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "title" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "domain" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "contact" } ], "name": "Verify the contact", "moduleId": "n_8aaa64cd6611ba5d", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_5fd294781ceb4c70": { "name": "Saved contact", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "contact" } ], "outputMappings": { "contact": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_8bcc0bcc2cae6eb7", "output": "contact" } ] } } } }, "edges": [ { "source": "n_ee2ad8be4a3ae272", "target": "n_7f48894b1e6067f7" }, { "source": "n_7f48894b1e6067f7", "target": "n_c890cb780b66a422" }, { "source": "n_c890cb780b66a422", "target": "n_2f6642a4394e43bf" }, { "source": "n_2f6642a4394e43bf", "target": "n_6b14c84bbb15d23e" }, { "source": "n_6b14c84bbb15d23e", "target": "n_3d6a490ef19a6e85" }, { "source": "n_3d6a490ef19a6e85", "target": "n_3a3bb21deaee35a6" }, { "source": "n_3a3bb21deaee35a6", "target": "n_6a04f17d28661c3d" }, { "source": "n_6a04f17d28661c3d", "target": "n_8bcc0bcc2cae6eb7" }, { "source": "n_8bcc0bcc2cae6eb7", "target": "n_5fd294781ceb4c70" } ] } }, "modules": { "n_c1c6783643999a3e": { "name": "Validate contact details", "imports": [], "source": "export default function setup({givenName,familyName,company,title,domain}){for(const [k,v]of Object.entries({givenName,familyName,company,title,domain}))if(typeof v!=='string'||!v.trim())throw Error('Enter '+k);return {givenName:givenName.trim(),familyName:familyName.trim(),company:company.trim(),title:title.trim(),domain:domain.trim(),body:{names:[{givenName:givenName.trim(),familyName:familyName.trim(),middleName:''}]}};}\n" }, "n_039fbc6e349cfdba": { "name": "Identify contact", "imports": [], "source": "export default function created({body}){const resourceName=body?.resourceName;if(typeof resourceName!=='string'||!/^people\\/[a-zA-Z0-9_-]+$/.test(resourceName))throw Error('Contact resource name missing');return {resourceName,url:'https://people.googleapis.com/v1/'+resourceName};}\n" }, "n_5e358dc5b6980717": { "name": "Prepare organization update", "imports": [], "source": "export default function prepare({body,resourceName,company,title,domain}){if(body?.resourceName!==resourceName||!Array.isArray(body?.metadata?.sources))throw Error('Contact metadata missing');const sources=body.metadata.sources.filter(s=>s?.type==='CONTACT'&&typeof s.etag==='string'&&s.etag);if(sources.length!==1)throw Error('Expected one contact source with etag');return {url:'https://people.googleapis.com/v1/'+resourceName+':updateContact',body:{resourceName,metadata:{sources},organizations:[{name:company,title,domain,current:true}]}};}\n" }, "n_8aaa64cd6611ba5d": { "name": "Verify the contact", "imports": [], "source": "export default function confirm({body,resourceName,company,title,domain}){if(body?.resourceName!==resourceName||!Array.isArray(body.organizations)||!body.organizations.some(o=>o.name===company&&o.title===title&&o.domain===domain&&o.current===true))throw Error('Updated contact does not match');return {contact:body};}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }