{ "kind": "open-flow-workflow", "version": 1, "name": "Google Books Add to Shelf", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_7250f422c8fd1bec": { "name": "Enter book and shelf IDs", "kind": "start", "inputDefs": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "volumeId" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "shelfId" } ] }, "n_801fa61967c86333": { "inputs": { "volumeId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7250f422c8fd1bec", "output": "volumeId" } ] }, "shelfId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7250f422c8fd1bec", "output": "shelfId" } ] } }, "name": "Prepare Google Books URLs", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "volumeId" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "shelfId" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "volumeUrl" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "addUrl" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "listUrl" } ], "name": "Prepare Google Books URLs", "moduleId": "n_9e0da1baf0be59c0", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_5216a4236b9a608f": { "inputs": { "url": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_801fa61967c86333", "output": "volumeUrl" } ] }, "auth.token": { "kind": "unset" } }, "name": "Get Google Books volume", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "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": "Get Google Books volume", "executor": { "method": "GET", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "none", "authentication": { "type": "bearer" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_8a7aa8f5f65bea59": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_5216a4236b9a608f", "output": "body" } ] } }, "name": "Read fetched volume ID", "kind": "task", "task": { "inputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "volumeId" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "volume" } ], "name": "Read fetched volume ID", "moduleId": "n_1893fba05c562a65", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_b144fc74dd033a54": { "inputs": { "url": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_801fa61967c86333", "output": "addUrl" } ] }, "query.volumeId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_8a7aa8f5f65bea59", "output": "volumeId" } ] }, "auth.token": { "kind": "unset" } }, "name": "Add volume to My Library", "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.volumeId" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "auth.token" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "type": "object", "additionalProperties": { "type": "string" } }, "nullable": false, "handle": "headers" } ], "name": "Add volume to My Library", "executor": { "method": "POST", "query": { "mode": "fields", "names": [ "volumeId" ] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "none", "authentication": { "type": "bearer" }, "responseFormat": "text", "statusPolicy": "success", "kind": "http-request" } } }, "n_bd7d7279b99e3a1f": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_b144fc74dd033a54", "output": "body" } ] }, "statusCode": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_b144fc74dd033a54", "output": "statusCode" } ] } }, "name": "Confirm bookshelf addition", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" } ], "outputs": [ { "jsonSchema": { "type": "boolean" }, "nullable": false, "handle": "added" } ], "name": "Confirm bookshelf addition", "moduleId": "n_c2ff6ca5499379b1", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_81bf20d99ae81583": { "inputs": { "url": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_801fa61967c86333", "output": "listUrl" } ] }, "query.maxResults": { "kind": "value", "value": "40" }, "auth.token": { "kind": "unset" } }, "name": "List first bookshelf 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.maxResults" }, { "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": "List first bookshelf page", "executor": { "method": "GET", "query": { "mode": "fields", "names": [ "maxResults" ] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "none", "authentication": { "type": "bearer" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_7da7a9f8ee946b62": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_81bf20d99ae81583", "output": "body" } ] }, "volume": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_8a7aa8f5f65bea59", "output": "volume" } ] } }, "name": "Read bookshelf results", "kind": "task", "task": { "inputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "volume" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "volume" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "shelfPage" }, { "jsonSchema": { "type": "array", "items": { "type": "object", "additionalProperties": true } }, "nullable": false, "handle": "items" }, { "jsonSchema": { "type": "integer", "minimum": 0 }, "nullable": false, "handle": "count" } ], "name": "Read bookshelf results", "moduleId": "n_42095303b5829194", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_8c032cee06685dcb": { "name": "Book and first shelf page", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "volume" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "shelfPage" }, { "jsonSchema": { "type": "array", "items": { "type": "object", "additionalProperties": true } }, "nullable": false, "handle": "items" }, { "jsonSchema": { "type": "integer", "minimum": 0 }, "nullable": false, "handle": "count" } ], "outputMappings": { "volume": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7da7a9f8ee946b62", "output": "volume" } ] }, "shelfPage": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7da7a9f8ee946b62", "output": "shelfPage" } ] }, "items": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7da7a9f8ee946b62", "output": "items" } ] }, "count": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7da7a9f8ee946b62", "output": "count" } ] } } } }, "edges": [ { "source": "n_7250f422c8fd1bec", "target": "n_801fa61967c86333" }, { "source": "n_801fa61967c86333", "target": "n_5216a4236b9a608f" }, { "source": "n_5216a4236b9a608f", "target": "n_8a7aa8f5f65bea59" }, { "source": "n_8a7aa8f5f65bea59", "target": "n_b144fc74dd033a54" }, { "source": "n_b144fc74dd033a54", "target": "n_bd7d7279b99e3a1f" }, { "source": "n_bd7d7279b99e3a1f", "target": "n_81bf20d99ae81583" }, { "source": "n_81bf20d99ae81583", "target": "n_7da7a9f8ee946b62" }, { "source": "n_7da7a9f8ee946b62", "target": "n_8c032cee06685dcb" } ] } }, "modules": { "n_9e0da1baf0be59c0": { "name": "Prepare Google Books URLs", "imports": [], "source": "export default function bookRequest({ volumeId, shelfId }) {\n if ([volumeId, shelfId].some((value) => typeof value !== 'string' || !value)) throw new Error('Configure the Google Books volume and bookshelf IDs');\n const root = 'https://www.googleapis.com/books/v1/';\n return { volumeUrl: root + 'volumes/' + encodeURIComponent(volumeId), addUrl: root + 'mylibrary/bookshelves/' + encodeURIComponent(shelfId) + '/addVolume', listUrl: root + 'mylibrary/bookshelves/' + encodeURIComponent(shelfId) + '/volumes' };\n}\n" }, "n_1893fba05c562a65": { "name": "Read fetched volume ID", "imports": [], "source": "export default function bookVolume({ body }) {\n if (!body || typeof body !== 'object' || Array.isArray(body) || typeof body.id !== 'string' || !body.id) throw new Error('Google Books did not return a valid volume record');\n return { volumeId: body.id, volume: body };\n}\n" }, "n_c2ff6ca5499379b1": { "name": "Confirm bookshelf addition", "imports": [], "source": "export default function addedToShelf({ body, statusCode }) {\n if (![200, 204].includes(statusCode) || body !== null && body !== '') throw new Error('Google Books did not confirm the completed bookshelf addition');\n return { added: true };\n}\n" }, "n_42095303b5829194": { "name": "Read bookshelf results", "imports": [], "source": "export default function shelfResult({ body, volume }) {\n if (!body || typeof body !== 'object' || Array.isArray(body) || body.items != null && (!Array.isArray(body.items) || body.items.some((item) => !item || typeof item !== 'object' || Array.isArray(item)))) throw new Error('Google Books returned an invalid bookshelf page');\n if (body.items === null) throw new Error('Google Books returned invalid bookshelf items');\n return { volume, shelfPage: body, items: body.items ?? [], count: body.items?.length ?? 0 };\n}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }