{ "kind": "open-flow-workflow", "version": 1, "name": "List All HubSpot Contacts", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_13696c265f796547": { "name": "List contacts", "kind": "start", "inputDefs": [] }, "n_ba92d7528b9c5f70": { "inputs": { "previousState": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ba92d7528b9c5f70", "output": "state" } ] }, "response": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_70348e28c23046e0", "output": "body" } ] }, "statusCode": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_70348e28c23046e0", "output": "statusCode" } ] } }, "name": "Collect contact pages", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": true, "handle": "previousState" }, { "jsonSchema": {}, "nullable": true, "handle": "response" }, { "jsonSchema": { "type": "integer" }, "nullable": true, "handle": "statusCode" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "state" }, { "jsonSchema": { "type": "boolean" }, "nullable": false, "handle": "more" }, { "jsonSchema": { "type": "object", "additionalProperties": { "type": [ "string", "number", "boolean" ] } }, "nullable": false, "handle": "params" }, { "jsonSchema": { "type": "array", "items": { "type": "object", "additionalProperties": true } }, "nullable": false, "handle": "contacts" } ], "name": "Collect contact pages", "moduleId": "n_045e34123066b639", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_a409495f045f9a28": { "inputs": {}, "name": "Another page?", "kind": "condition", "matchMode": "first", "cases": [ { "output": "yes", "groups": [ { "expressions": [ { "left": { "kind": "source", "source": { "kind": "node", "nodeId": "n_ba92d7528b9c5f70", "output": "more" } }, "operator": "isTrue" } ] } ] } ] }, "n_70348e28c23046e0": { "inputs": { "url": { "kind": "value", "value": "https://api.hubapi.com/contacts/v1/lists/all/contacts/all" }, "query": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ba92d7528b9c5f70", "output": "params" } ] }, "auth.token": { "kind": "unset" } }, "name": "Read contacts", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": { "type": "object", "additionalProperties": { "anyOf": [ { "type": [ "string", "number", "boolean" ] }, { "type": "array", "items": { "type": [ "string", "number", "boolean" ] } } ] } }, "nullable": true, "handle": "query" }, { "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 contacts", "executor": { "method": "GET", "query": { "mode": "object", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "none", "authentication": { "type": "bearer" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_096e3eef7febc08b": { "name": "Contacts", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "array", "items": { "type": "object", "additionalProperties": true } }, "nullable": false, "handle": "contacts" } ], "outputMappings": { "contacts": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ba92d7528b9c5f70", "output": "contacts" } ] } } } }, "edges": [ { "source": "n_13696c265f796547", "target": "n_ba92d7528b9c5f70" }, { "source": "n_ba92d7528b9c5f70", "target": "n_a409495f045f9a28" }, { "source": "n_a409495f045f9a28", "target": "n_70348e28c23046e0", "sourceHandle": "yes" }, { "source": "n_70348e28c23046e0", "target": "n_ba92d7528b9c5f70" }, { "source": "n_a409495f045f9a28", "target": "n_096e3eef7febc08b", "sourceHandle": "otherwise" } ] } }, "modules": { "n_045e34123066b639": { "name": "Collect contact pages", "imports": [], "source": "export default function pages({previousState,response,statusCode}){let state=previousState??{contacts:[],seen:[],cursor:null};if(!Array.isArray(state.contacts)||!Array.isArray(state.seen))throw Error('Invalid state');if(response!=null){if(statusCode<200||statusCode>=300||!Array.isArray(response.contacts)||typeof response['has-more']!=='boolean')throw Error('Invalid HubSpot page');const more=response['has-more'],cursor=response['vid-offset'];if(more&&(!Number.isSafeInteger(cursor)||cursor<0||state.seen.includes(cursor)))throw Error('Invalid or repeated cursor');state={contacts:state.contacts.concat(response.contacts),seen:more?state.seen.concat(cursor):state.seen,cursor:more?cursor:null}}return{state,more:response==null||state.cursor!==null,params:{count:100,limit:250,...(state.cursor!==null?{vidOffset:state.cursor}:{})},contacts:state.contacts}}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }