{ "kind": "open-flow-workflow", "version": 1, "name": "Google Sheet Table JSON API", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_8dc14e67ef7b4a91": { "name": "Read the table by GET", "kind": "webhook", "bodyFields": [], "method": "GET", "options": { "responseBody": { "kind": "workflow-outputs", "output": "rows", "timeoutMs": 60000 }, "responseHeaders": { "Content-Type": "application/json; charset=utf-8" }, "responseStatusCode": 200 } }, "n_f5d3c07824b58c9e": { "inputs": { "spreadsheetId": { "kind": "value", "value": "YOUR_SPREADSHEET_ID" }, "range": { "kind": "value", "value": "Problems!A:D" }, "majorDimension": { "kind": "value", "value": "ROWS" }, "valueRenderOption": { "kind": "value", "value": "UNFORMATTED_VALUE" }, "dateTimeRenderOption": { "kind": "value", "value": "SERIAL_NUMBER" } }, "name": "Read the problem table", "kind": "task", "task": { "inputs": [ { "description": "The spreadsheet ID.", "jsonSchema": { "type": "string", "minLength": 1, "description": "The spreadsheet ID." }, "nullable": true, "handle": "spreadsheetId", "value": null }, { "description": "The A1 notation of the range to retrieve.", "jsonSchema": { "type": "string", "minLength": 1, "description": "The A1 notation of the range to retrieve." }, "nullable": false, "handle": "range" }, { "description": "The major dimension for the returned values.", "jsonSchema": { "type": "string", "enum": [ "DIMENSION_UNSPECIFIED", "ROWS", "COLUMNS" ], "description": "The major dimension for the returned values." }, "nullable": true, "handle": "majorDimension", "value": null }, { "description": "How values should be rendered in the output.", "jsonSchema": { "type": "string", "enum": [ "FORMATTED_VALUE", "UNFORMATTED_VALUE", "FORMULA" ], "description": "How values should be rendered in the output." }, "nullable": true, "handle": "valueRenderOption", "value": null }, { "description": "How dates and times should be rendered in the output.", "jsonSchema": { "type": "string", "enum": [ "SERIAL_NUMBER", "FORMATTED_STRING" ], "description": "How dates and times should be rendered in the output." }, "nullable": true, "handle": "dateTimeRenderOption", "value": null } ], "outputs": [ { "description": "The A1 notation of the range.", "jsonSchema": { "type": "string", "description": "The A1 notation of the range." }, "nullable": false, "handle": "range" }, { "description": "The major dimension of the values (ROWS or COLUMNS).", "jsonSchema": { "type": "string", "description": "The major dimension of the values (ROWS or COLUMNS)." }, "nullable": false, "handle": "majorDimension" }, { "description": "The data values in the range.", "jsonSchema": { "type": "array", "items": { "type": "array", "items": { "anyOf": [ { "type": "string", "description": "A union variant." }, { "type": "number", "description": "A union variant." }, { "type": "boolean", "description": "A union variant." }, { "const": null, "description": "A union variant." } ], "description": "The cell value schema." }, "description": "An array item." }, "description": "The data values in the range." }, "nullable": false, "handle": "values" } ], "name": "Read the problem table", "executor": { "kind": "connector", "action": "googlesheets.values_get" } } }, "n_335be5a3829f7627": { "inputs": { "values": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_f5d3c07824b58c9e", "output": "values" } ] } }, "name": "Build table rows from headers", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "array", "items": { "type": "array", "items": { "anyOf": [ { "type": "string", "description": "A union variant." }, { "type": "number", "description": "A union variant." }, { "type": "boolean", "description": "A union variant." }, { "const": null, "description": "A union variant." } ], "description": "The cell value schema." }, "description": "An array item." }, "description": "The data values in the range." }, "nullable": false, "handle": "values" } ], "outputs": [ { "jsonSchema": { "type": "array", "items": { "type": "object", "additionalProperties": true } }, "nullable": false, "handle": "rows" } ], "name": "Build table rows from headers", "moduleId": "n_6d9ef7858dc6c5c0", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_33501a1aaefa13dd": { "name": "Return all table rows", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "array", "items": { "type": "object", "additionalProperties": true } }, "nullable": false, "handle": "rows" } ], "outputMappings": { "rows": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_335be5a3829f7627", "output": "rows" } ] } } } }, "edges": [ { "source": "n_8dc14e67ef7b4a91", "target": "n_f5d3c07824b58c9e" }, { "source": "n_f5d3c07824b58c9e", "target": "n_335be5a3829f7627" }, { "source": "n_335be5a3829f7627", "target": "n_33501a1aaefa13dd" } ] } }, "modules": { "n_6d9ef7858dc6c5c0": { "name": "Build table rows from headers", "imports": [], "source": "export default function sheetTableRows({ values }) {\n if (!Array.isArray(values) || values.some(row => !Array.isArray(row))) throw new Error('Expected the sheet range as rows of cell values');\n for (const row of values) for (const cell of row) if (cell !== null && typeof cell !== 'string' && typeof cell !== 'boolean' && !(typeof cell === 'number' && Number.isFinite(cell))) throw new Error('The sheet returned an invalid cell value');\n if (!values.length) return { rows: [] };\n const headers = values[0], rows = [];\n for (const cells of values.slice(1)) {\n const row = Object.create(null);\n for (let column = 0; column < cells.length; column++) {\n const header = headers[column];\n if (header) row[String(header)] = cells[column];\n }\n if (Object.keys(row).length) rows.push(row);\n }\n return { rows };\n}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }