{ "kind": "open-flow-workflow", "version": 1, "name": "Travis CI Build Request", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_c92a795e79a7d499": { "name": "Enter Travis CI build request", "kind": "start", "inputDefs": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "repositorySlug" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "branch" } ] }, "n_4c7de05cc9a37ad5": { "inputs": { "repositorySlug": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_c92a795e79a7d499", "output": "repositorySlug" } ] }, "branch": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_c92a795e79a7d499", "output": "branch" } ] } }, "name": "Prepare repository build request", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "repositorySlug" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "branch" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "body" } ], "name": "Prepare repository build request", "moduleId": "n_a447aab349aaa9da", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_17790182bf102326": { "inputs": { "url": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_4c7de05cc9a37ad5", "output": "url" } ] }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_4c7de05cc9a37ad5", "output": "body" } ] }, "header.Travis-API-Version": { "kind": "value", "value": "3" }, "header.Accept": { "kind": "value", "value": "application/json" }, "auth.token": { "kind": "unset" } }, "name": "Request Travis CI build", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "header.Travis-API-Version" }, { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "header.Accept" }, { "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": "Request Travis CI build", "executor": { "method": "POST", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [ "Travis-API-Version", "Accept" ] }, "bodyFormat": "json", "authentication": { "type": "apiKey", "name": "Authorization", "in": "header" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_f8aa573132bbe4ec": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_17790182bf102326", "output": "body" } ] }, "statusCode": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_17790182bf102326", "output": "statusCode" } ] } }, "name": "Confirm accepted build request", "kind": "task", "task": { "inputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "acceptance" } ], "name": "Confirm accepted build request", "moduleId": "n_35d4e35e6660264b", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_d45fa39d2bdc306a": { "name": "Travis CI request acceptance", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "acceptance" } ], "outputMappings": { "acceptance": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_f8aa573132bbe4ec", "output": "acceptance" } ] } } } }, "edges": [ { "source": "n_c92a795e79a7d499", "target": "n_4c7de05cc9a37ad5" }, { "source": "n_4c7de05cc9a37ad5", "target": "n_17790182bf102326" }, { "source": "n_17790182bf102326", "target": "n_f8aa573132bbe4ec" }, { "source": "n_f8aa573132bbe4ec", "target": "n_d45fa39d2bdc306a" } ] } }, "modules": { "n_a447aab349aaa9da": { "name": "Prepare repository build request", "imports": [], "source": "export default function travisCiRequest({ repositorySlug, branch }) {\n if (typeof repositorySlug !== 'string' || !/^[^\\s/\\\\]+\\/[^\\s/\\\\]+$/.test(repositorySlug) || repositorySlug.split('/').some((part) => part === '.' || part === '..')) throw new Error('Enter a repository slug in owner/repository form');\n if (typeof branch !== 'string' || branch.trim().length === 0 || /[\\u0000-\\u001f\\u007f]/.test(branch)) throw new Error('Enter a branch to build');\n return { url: 'https://api.travis-ci.com/repo/' + encodeURIComponent(repositorySlug) + '/requests', body: { request: { branch } } };\n}\n" }, "n_35d4e35e6660264b": { "name": "Confirm accepted build request", "imports": [], "source": "function readTravisAcceptance(body, statusCode) {\n if (statusCode !== 202 || !body || typeof body !== 'object' || Array.isArray(body) || body['@type'] !== 'pending' || !body.request || typeof body.request !== 'object' || !Number.isSafeInteger(body.request.id) || body.request.id < 1) throw new Error('Travis CI did not confirm an accepted build request');\n return body;\n}\nexport default function travisCiResult({ body, statusCode }) {\n return { acceptance: readTravisAcceptance(body, statusCode) };\n}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }