{ "kind": "open-flow-workflow", "version": 1, "name": "Sync a Squarespace Collection to Sheets", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_3774901f0d1fc231": { "name": "Daily at midnight UTC", "kind": "cron", "cronTimes": [ { "type": "cron", "expression": "0 0 * * *", "timezone": "UTC" } ] }, "n_f6f369618bdacb4d": { "name": "Run manually", "kind": "start", "inputDefs": [] }, "n_830a9df194c6125d": { "inputs": { "url": { "kind": "value", "value": "https://YOUR_SQUARESPACE_DOMAIN/blog" }, "spreadsheetId": { "kind": "value", "value": "YOUR_SPREADSHEET_ID" }, "sheetName": { "kind": "value", "value": "Articles" } }, "name": "Configure the collection and sheet", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "url" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "spreadsheetId" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "sheetName" } ], "outputs": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "url" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "spreadsheetId" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "sheetName" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "range" } ], "name": "Configure the collection and sheet", "moduleId": "n_9476766db0ad5707", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_3cf1204b13db58cf": { "inputs": { "previous": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_3cf1204b13db58cf", "output": "state" } ] }, "response": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_19b3086f4d709a3b", "output": "body" } ] } }, "name": "Collect collection pages", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": true, "handle": "previous" }, { "jsonSchema": {}, "nullable": true, "handle": "response" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "state" }, { "jsonSchema": { "type": "boolean" }, "nullable": false, "handle": "more" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "offset" }, { "jsonSchema": { "type": "array", "items": { "type": "object", "additionalProperties": true } }, "nullable": false, "handle": "items" } ], "name": "Collect collection pages", "moduleId": "n_815cd691d682da13", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_7ca1f16b5b1f321b": { "inputs": {}, "name": "More collection pages?", "kind": "condition", "matchMode": "first", "cases": [ { "output": "yes", "groups": [ { "expressions": [ { "left": { "kind": "source", "source": { "kind": "node", "nodeId": "n_3cf1204b13db58cf", "output": "more" } }, "operator": "isTrue" } ] } ] } ] }, "n_19b3086f4d709a3b": { "inputs": { "url": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_830a9df194c6125d", "output": "url" } ] }, "query.format": { "kind": "value", "value": "json" }, "query.offset": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_3cf1204b13db58cf", "output": "offset" } ] } }, "name": "Read the collection page", "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.format" }, { "jsonSchema": { "anyOf": [ { "type": [ "string", "number", "boolean" ] }, { "type": "array", "items": { "type": [ "string", "number", "boolean" ] } } ] }, "nullable": true, "handle": "query.offset" } ], "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 the collection page", "executor": { "method": "GET", "query": { "mode": "fields", "names": [ "format", "offset" ] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "none", "authentication": { "type": "none" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_a7b282d1b2b9111b": { "inputs": { "spreadsheetId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_830a9df194c6125d", "output": "spreadsheetId" } ] }, "range": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_830a9df194c6125d", "output": "range" } ] }, "majorDimension": { "kind": "value", "value": "ROWS" }, "valueRenderOption": { "kind": "value", "value": "UNFORMATTED_VALUE" } }, "name": "Read the article sheet", "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 article sheet", "executor": { "kind": "connector", "action": "googlesheets.values_get" } } }, "n_55647b8acb14d513": { "inputs": { "items": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_3cf1204b13db58cf", "output": "items" } ] }, "values": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_a7b282d1b2b9111b", "output": "values" } ] }, "sheetName": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_830a9df194c6125d", "output": "sheetName" } ] } }, "name": "Match articles to rows", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "array", "items": { "type": "object", "additionalProperties": true } }, "nullable": false, "handle": "items" }, { "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" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "sheetName" } ], "outputs": [ { "jsonSchema": { "type": "array", "items": { "type": "object", "additionalProperties": true } }, "nullable": false, "handle": "tasks" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "sheetName" } ], "name": "Match articles to rows", "moduleId": "n_af3b916217b874ac", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_39dd704512ae82af": { "inputs": { "tasks": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_55647b8acb14d513", "output": "tasks" } ] }, "previous": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_39dd704512ae82af", "output": "state" } ] }, "sheetName": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_55647b8acb14d513", "output": "sheetName" } ] }, "confirmation": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_d19874427952ae48", "output": "totalUpdatedCells" } ] } }, "name": "Select the next article", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "array", "items": { "type": "object", "additionalProperties": true } }, "nullable": false, "handle": "tasks" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": true, "handle": "previous" }, { "jsonSchema": { "type": "integer", "description": "The total number of cells updated across all ranges." }, "nullable": true, "handle": "confirmation" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "sheetName" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "state" }, { "jsonSchema": { "type": "boolean" }, "nullable": false, "handle": "more" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "item" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "range" } ], "name": "Select the next article", "moduleId": "n_65f50cfd572ae64b", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_3c9ddff67af8604c": { "inputs": {}, "name": "More articles?", "kind": "condition", "matchMode": "first", "cases": [ { "output": "yes", "groups": [ { "expressions": [ { "left": { "kind": "source", "source": { "kind": "node", "nodeId": "n_39dd704512ae82af", "output": "more" } }, "operator": "isTrue" } ] } ] } ] }, "n_5567148c00e9a84b": { "inputs": { "spreadsheetId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_830a9df194c6125d", "output": "spreadsheetId" } ] }, "range": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_39dd704512ae82af", "output": "range" } ] }, "majorDimension": { "kind": "value", "value": "ROWS" }, "valueRenderOption": { "kind": "value", "value": "UNFORMATTED_VALUE" } }, "name": "Recheck the sheet row", "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": "Recheck the sheet row", "executor": { "kind": "connector", "action": "googlesheets.values_get" } } }, "n_dc6c73dfa7c0c0fd": { "inputs": { "item": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_39dd704512ae82af", "output": "item" } ] }, "checked": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_5567148c00e9a84b", "output": "values" } ] }, "sheetName": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_830a9df194c6125d", "output": "sheetName" } ] } }, "name": "Prepare the article cells", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "item" }, { "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": "checked" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "sheetName" } ], "outputs": [ { "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "range": { "type": "string", "minLength": 1, "description": "The A1 notation of the range to write to." }, "values": { "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 to write into the range." }, "majorDimension": { "type": "string", "enum": [ "ROWS", "COLUMNS" ], "description": "The major dimension of the values array." } }, "required": [ "range", "values" ], "additionalProperties": false, "description": "A batch values update item." }, "minItems": 1, "description": "The list of value ranges to update." }, "nullable": false, "handle": "data" } ], "name": "Prepare the article cells", "moduleId": "n_ef8b90db30936512", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_d19874427952ae48": { "inputs": { "spreadsheetId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_830a9df194c6125d", "output": "spreadsheetId" } ] }, "data": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_dc6c73dfa7c0c0fd", "output": "data" } ] }, "valueInputOption": { "kind": "value", "value": "RAW" } }, "name": "Write the article cells", "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 list of value ranges to update.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "range": { "type": "string", "minLength": 1, "description": "The A1 notation of the range to write to." }, "values": { "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 to write into the range." }, "majorDimension": { "type": "string", "enum": [ "ROWS", "COLUMNS" ], "description": "The major dimension of the values array." } }, "required": [ "range", "values" ], "additionalProperties": false, "description": "A batch values update item." }, "minItems": 1, "description": "The list of value ranges to update." }, "nullable": false, "handle": "data" }, { "description": "How the input data should be interpreted.", "jsonSchema": { "type": "string", "enum": [ "INPUT_VALUE_OPTION_UNSPECIFIED", "RAW", "USER_ENTERED" ], "description": "How the input data should be interpreted." }, "nullable": true, "handle": "valueInputOption", "value": null }, { "description": "Whether to include the written values in the response.", "jsonSchema": { "type": "boolean", "description": "Whether to include the written values in the response." }, "nullable": true, "handle": "includeValuesInResponse", "value": null }, { "description": "How values in the response should be rendered.", "jsonSchema": { "type": "string", "enum": [ "FORMATTED_VALUE", "UNFORMATTED_VALUE", "FORMULA" ], "description": "How values in the response should be rendered." }, "nullable": true, "handle": "responseValueRenderOption", "value": null }, { "description": "How dates in the response should be rendered.", "jsonSchema": { "type": "string", "enum": [ "SERIAL_NUMBER", "FORMATTED_STRING" ], "description": "How dates in the response should be rendered." }, "nullable": true, "handle": "responseDateTimeRenderOption", "value": null } ], "outputs": [ { "description": "The unique ID of the spreadsheet.", "jsonSchema": { "type": "string", "description": "The unique ID of the spreadsheet." }, "nullable": false, "handle": "spreadsheetId" }, { "description": "The total number of rows updated across all ranges.", "jsonSchema": { "type": "integer", "description": "The total number of rows updated across all ranges." }, "nullable": false, "handle": "totalUpdatedRows" }, { "description": "The total number of columns updated across all ranges.", "jsonSchema": { "type": "integer", "description": "The total number of columns updated across all ranges." }, "nullable": false, "handle": "totalUpdatedColumns" }, { "description": "The total number of cells updated across all ranges.", "jsonSchema": { "type": "integer", "description": "The total number of cells updated across all ranges." }, "nullable": false, "handle": "totalUpdatedCells" }, { "description": "The per-range update responses.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "updatedRange": { "type": "string", "description": "The A1 notation of the range that was updated." }, "updatedRows": { "type": "integer", "description": "The number of rows that were updated." }, "updatedColumns": { "type": "integer", "description": "The number of columns that were updated." }, "updatedCells": { "type": "integer", "description": "The number of cells that were updated." }, "updatedData": { "type": "object", "properties": { "range": { "type": "string", "description": "The A1 notation of the range." }, "majorDimension": { "type": "string", "description": "The major dimension of the values (ROWS or COLUMNS)." }, "values": { "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." } }, "required": [ "range", "majorDimension", "values" ], "additionalProperties": false, "description": "The values of the cells after the update." } }, "required": [ "updatedRange", "updatedRows", "updatedColumns", "updatedCells" ], "additionalProperties": false, "description": "The batch update item schema." }, "description": "The per-range update responses." }, "nullable": false, "handle": "responses" } ], "name": "Write the article cells", "executor": { "kind": "connector", "action": "googlesheets.update_values_batch" } } } }, "edges": [ { "source": "n_3774901f0d1fc231", "target": "n_830a9df194c6125d" }, { "source": "n_f6f369618bdacb4d", "target": "n_830a9df194c6125d" }, { "source": "n_830a9df194c6125d", "target": "n_3cf1204b13db58cf" }, { "source": "n_3cf1204b13db58cf", "target": "n_7ca1f16b5b1f321b" }, { "source": "n_7ca1f16b5b1f321b", "target": "n_19b3086f4d709a3b", "sourceHandle": "yes" }, { "source": "n_19b3086f4d709a3b", "target": "n_3cf1204b13db58cf" }, { "source": "n_7ca1f16b5b1f321b", "target": "n_a7b282d1b2b9111b", "sourceHandle": "otherwise" }, { "source": "n_a7b282d1b2b9111b", "target": "n_55647b8acb14d513" }, { "source": "n_55647b8acb14d513", "target": "n_39dd704512ae82af" }, { "source": "n_39dd704512ae82af", "target": "n_3c9ddff67af8604c" }, { "source": "n_3c9ddff67af8604c", "target": "n_5567148c00e9a84b", "sourceHandle": "yes" }, { "source": "n_5567148c00e9a84b", "target": "n_dc6c73dfa7c0c0fd" }, { "source": "n_dc6c73dfa7c0c0fd", "target": "n_d19874427952ae48" }, { "source": "n_d19874427952ae48", "target": "n_39dd704512ae82af" } ] } }, "modules": { "n_9476766db0ad5707": { "name": "Configure the collection and sheet", "imports": [], "source": "export default function config({url,spreadsheetId,sheetName}){if(typeof url!=='string'||!/^https:\\/\\/[a-zA-Z0-9](?:[a-zA-Z0-9.-]*[a-zA-Z0-9])?(?:\\/[a-zA-Z0-9._~!$&'()*+,;=:@%/-]*)?$/.test(url)||url.includes('YOUR_'))throw Error('Configure the HTTPS public Squarespace collection URL without query parameters');if(typeof spreadsheetId!=='string'||!spreadsheetId.trim()||spreadsheetId.startsWith('YOUR_')||typeof sheetName!=='string'||!sheetName.trim()||/[!\\r\\n]/.test(sheetName))throw Error('Configure the spreadsheet and sheet');const q=\"'\"+sheetName.replace(/'/g,\"''\")+\"'\";return{url,spreadsheetId,sheetName,range:q+'!A:ZZZ'}}\n" }, "n_815cd691d682da13": { "name": "Collect collection pages", "imports": [], "source": "export default function collect({previous,response}){const s=previous??{items:[],offset:'',seen:[],started:false};if(!s.started)return{state:{...s,started:true},more:true,offset:'',items:[]};if(!response||typeof response!=='object'||!Array.isArray(response.items)||!response.pagination||typeof response.pagination.nextPage!=='boolean')throw Error('Invalid Squarespace collection page');const items=[...s.items,...response.items],next=response.pagination.nextPage;if(!next)return{state:{...s,items},more:false,offset:'',items};const value=response.pagination.nextPageOffset;if(!Number.isSafeInteger(value)||value<0||s.seen.includes(value))throw Error('Invalid or repeated Squarespace offset');return{state:{...s,items,offset:String(value),seen:[...s.seen,value]},more:true,offset:String(value),items:[]}}\n" }, "n_af3b916217b874ac": { "name": "Match articles to rows", "imports": [], "source": "export default function plan({items,values,sheetName}){if(!Array.isArray(items)||!Array.isArray(values)||!values.length||!Array.isArray(values[0]))throw Error('The sheet needs headers');const h=values[0],fields=['id','tags','title','urlId','addedOn','fullUrl','assetUrl','publishOn','categories'];if(fields.some(x=>h.indexOf(x)<0||h.indexOf(x)!==h.lastIndexOf(x)))throw Error('The sheet needs unique required headers');const indexes=Object.fromEntries(fields.map(x=>[x,h.indexOf(x)])),existing=new Map();for(let i=1;i{if((typeof v!=='number'&&typeof v!=='string')||v===''||!Number.isFinite(new Date(v).getTime()))throw Error('Invalid collection date');return new Date(v).toISOString().slice(0,10)},tasks=[];let appendIndex=values.length+1;for(const item of items){if(!item||typeof item.id!=='string'||!item.id||seen.has(item.id))throw Error('Invalid or duplicate collection ID');seen.add(item.id);for(const key of ['title','urlId','fullUrl'])if(typeof item[key]!=='string')throw Error('Missing collection field');for(const key of ['tags','categories'])if(!Array.isArray(item[key])||item[key].some(x=>typeof x!=='string'))throw Error('Invalid collection tags');if(item.assetUrl!=null&&typeof item.assetUrl!=='string')throw Error('Invalid image URL');const fieldsValue={id:item.id,tags:item.tags.join(', '),title:item.title,urlId:item.urlId,addedOn:date(item.addedOn),fullUrl:item.fullUrl,assetUrl:item.assetUrl??'',publishOn:date(item.publishOn),categories:item.categories.join(', ')},target=existing.get(item.id)??{index:appendIndex++,raw:[]};tasks.push({id:item.id,index:target.index,raw:target.raw,indexes,fieldsValue})}return{tasks,sheetName}}\n" }, "n_65f50cfd572ae64b": { "name": "Select the next article", "imports": [], "source": "export default function next({tasks,previous,confirmation,sheetName}){const s=previous??{index:0,waiting:false,pageId:null};if(s.waiting){if(confirmation!==9)throw Error('Sheet update not fully confirmed');s.index++;s.waiting=false}s.pageId=null;if(s.index>=tasks.length)return{state:s,more:false,item:{},range:\"'unused'!A1:ZZZ1\"};const item=tasks[s.index];if(!item||!Number.isSafeInteger(item.index)||item.index<2)throw Error('Invalid sheet task');const q=\"'\"+sheetName.replace(/'/g,\"''\")+\"'\";return{state:{...s,waiting:true,pageId:item.id},more:true,item,range:q+'!A'+item.index+':ZZZ'+item.index}}\n" }, "n_ef8b90db30936512": { "name": "Prepare the article cells", "imports": [], "source": "export default function update({item,checked,sheetName}){if(!Array.isArray(checked)||checked.length>1||JSON.stringify(checked[0]??[])!==JSON.stringify(item.raw))throw Error('Sheet row changed since reading');const q=\"'\"+sheetName.replace(/'/g,\"''\")+\"'\",col=n=>{let x=n+1,s='';while(x){x--;s=String.fromCharCode(65+x%26)+s;x=Math.floor(x/26)}return s};return{data:Object.entries(item.fieldsValue).map(([key,v])=>({range:q+'!'+col(item.indexes[key])+item.index,values:[[v]]}))}}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }