{ "kind": "open-flow-workflow", "version": 1, "name": "Google Drive New Files to Notion", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_546366099ce8bfd0": { "name": "Watch for new Drive files", "kind": "poll", "config": { "changeType": { "kind": "value", "value": "created" }, "folderId": { "kind": "value", "value": "YOUR_GOOGLE_DRIVE_FOLDER_ID" }, "driveId": { "kind": "value", "value": "" }, "itemTypes": { "kind": "value", "value": [ "file" ] }, "mimeTypes": { "kind": "value", "value": [] }, "namePrefix": { "kind": "value", "value": "" }, "maxFilesPerPoll": { "kind": "value", "value": 50 } }, "definition": { "configInputs": [ { "jsonSchema": { "type": "string", "enum": [ "created", "updated" ] }, "nullable": false, "handle": "changeType" }, { "jsonSchema": { "type": "string", "pattern": "^[A-Za-z0-9_-]{0,512}$" }, "nullable": false, "handle": "driveId", "value": "" }, { "jsonSchema": { "type": "string", "pattern": "^[A-Za-z0-9_-]{2,512}$" }, "nullable": false, "handle": "folderId" }, { "jsonSchema": { "type": "array", "items": { "type": "string", "enum": [ "file", "folder" ] }, "minItems": 1, "uniqueItems": true }, "nullable": false, "handle": "itemTypes", "value": [ "file" ] }, { "jsonSchema": { "type": "array", "items": { "type": "string", "minLength": 1 } }, "nullable": false, "handle": "mimeTypes", "value": [] }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "namePrefix", "value": "" }, { "collapsed": true, "group": "Advanced settings" }, { "jsonSchema": { "type": "integer", "minimum": 1, "maximum": 200 }, "nullable": false, "handle": "maxFilesPerPoll", "value": 50 } ], "definitionVersion": 2, "description": "Polls one Google Drive folder and triggers when a file or folder directly inside it is created or updated.", "displayName": "File or Folder Change in a Folder", "key": "googledrive.on_file_change", "name": "on_file_change", "outputs": [ { "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "createdTime": { "type": [ "string", "null" ] }, "driveId": { "type": [ "string", "null" ] }, "eventType": { "type": "string", "enum": [ "file_created", "file_updated", "folder_created", "folder_updated" ] }, "fileId": { "type": "string" }, "itemType": { "type": "string", "enum": [ "file", "folder" ] }, "lastModifyingUser": { "type": [ "object", "null" ] }, "mimeType": { "type": "string" }, "modifiedTime": { "type": [ "string", "null" ] }, "name": { "type": "string" }, "parents": { "type": "array", "items": { "type": "string" } }, "size": { "type": "string" }, "webViewLink": { "type": [ "string", "null" ] } }, "additionalProperties": false, "required": [ "eventType", "itemType", "fileId", "name", "mimeType", "createdTime", "modifiedTime", "parents", "webViewLink", "driveId", "lastModifyingUser" ] } }, "nullable": false, "handle": "events" } ], "provider": "googledrive", "type": "poll" }, "pollTimes": [ { "type": "every", "unit": "minute", "value": 1 } ] }, "n_1416cbc2413eb6c1": { "inputs": { "events": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_546366099ce8bfd0", "output": "events" } ] } }, "name": "Validate the new-file links", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "createdTime": { "type": [ "string", "null" ] }, "driveId": { "type": [ "string", "null" ] }, "eventType": { "type": "string", "enum": [ "file_created", "file_updated", "folder_created", "folder_updated" ] }, "fileId": { "type": "string" }, "itemType": { "type": "string", "enum": [ "file", "folder" ] }, "lastModifyingUser": { "type": [ "object", "null" ] }, "mimeType": { "type": "string" }, "modifiedTime": { "type": [ "string", "null" ] }, "name": { "type": "string" }, "parents": { "type": "array", "items": { "type": "string" } }, "size": { "type": "string" }, "webViewLink": { "type": [ "string", "null" ] } }, "additionalProperties": false, "required": [ "eventType", "itemType", "fileId", "name", "mimeType", "createdTime", "modifiedTime", "parents", "webViewLink", "driveId", "lastModifyingUser" ] } }, "nullable": false, "handle": "events" } ], "outputs": [ { "jsonSchema": { "type": "array", "items": { "type": "object", "additionalProperties": true } }, "nullable": false, "handle": "files" } ], "name": "Validate the new-file links", "moduleId": "n_9292aa4401de0324", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_286b7cc6a6947ca1": { "inputs": { "dataSourceId": { "kind": "value", "value": "YOUR_NOTION_DATA_SOURCE_ID" } }, "name": "Read the Notion data source", "kind": "task", "task": { "inputs": [ { "description": "The data source ID to retrieve.", "jsonSchema": { "type": "string", "description": "The data source ID to retrieve." }, "nullable": false, "handle": "dataSourceId" } ], "outputs": [ { "description": "The full data source object returned by the API.", "jsonSchema": { "type": "object", "properties": { "object": { "const": "data_source", "description": "The Notion object type." }, "id": { "type": "string", "description": "The data source ID." }, "created_time": { "type": "string", "format": "date-time", "description": "The time when the data source was created." }, "last_edited_time": { "type": "string", "format": "date-time", "description": "The time when the data source was last edited." }, "created_by": { "type": "object", "properties": { "object": { "const": "user", "description": "The Notion object type." }, "id": { "type": "string", "description": "The Notion user ID." }, "name": { "type": [ "string", "null" ], "description": "The user's display name, or null when unavailable." }, "avatar_url": { "type": [ "string", "null" ], "description": "The user's avatar URL, or null when unavailable." }, "type": { "type": "string", "enum": [ "person", "bot" ], "description": "The user type returned by Notion." }, "person": { "type": "object", "properties": { "email": { "type": "string", "format": "email", "description": "The person's email address." } }, "additionalProperties": true, "description": "Details about a person user." }, "bot": { "type": "object", "additionalProperties": { "description": "A Notion API field value." }, "description": "Details about a bot user." } }, "additionalProperties": true, "description": "A Notion user reference." }, "last_edited_by": { "type": "object", "properties": { "object": { "const": "user", "description": "The Notion object type." }, "id": { "type": "string", "description": "The Notion user ID." }, "name": { "type": [ "string", "null" ], "description": "The user's display name, or null when unavailable." }, "avatar_url": { "type": [ "string", "null" ], "description": "The user's avatar URL, or null when unavailable." }, "type": { "type": "string", "enum": [ "person", "bot" ], "description": "The user type returned by Notion." }, "person": { "type": "object", "properties": { "email": { "type": "string", "format": "email", "description": "The person's email address." } }, "additionalProperties": true, "description": "Details about a person user." }, "bot": { "type": "object", "additionalProperties": { "description": "A Notion API field value." }, "description": "Details about a bot user." } }, "additionalProperties": true, "description": "A Notion user reference." }, "title": { "type": "array", "items": { "type": "object", "additionalProperties": { "description": "A Notion API field value." }, "description": "A Notion rich text object." }, "description": "The data source title rich text objects." }, "description": { "type": "array", "items": { "type": "object", "additionalProperties": { "description": "A Notion API field value." }, "description": "A Notion rich text object." }, "description": "The data source description rich text objects." }, "icon": { "type": [ "object", "null" ], "additionalProperties": { "description": "A Notion API field value." }, "description": "The data source icon object, or null when it has no icon." }, "properties": { "type": "object", "additionalProperties": { "description": "A Notion property value or property schema object." }, "description": "The Notion page, database, or data source properties keyed by property name." }, "parent": { "type": "object", "properties": { "type": { "type": "string", "description": "The parent type, such as workspace, page_id, data_source_id, database_id, or block_id." } }, "additionalProperties": true, "description": "The parent object that contains this Notion object." }, "url": { "type": "string", "format": "uri", "description": "The canonical Notion URL for the data source." }, "in_trash": { "type": "boolean", "description": "Whether the data source is in the trash." } }, "additionalProperties": true, "description": "The full data source object returned by the API." }, "nullable": false, "handle": "output" } ], "name": "Read the Notion data source", "executor": { "kind": "connector", "action": "notion.retrieve_data_source", "outputMode": "value" } } }, "n_e9a0a7f845dc9033": { "inputs": { "dataSource": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_286b7cc6a6947ca1", "output": "output" } ] } }, "name": "Check the title and File fields", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object", "properties": { "object": { "const": "data_source", "description": "The Notion object type." }, "id": { "type": "string", "description": "The data source ID." }, "created_time": { "type": "string", "format": "date-time", "description": "The time when the data source was created." }, "last_edited_time": { "type": "string", "format": "date-time", "description": "The time when the data source was last edited." }, "created_by": { "type": "object", "properties": { "object": { "const": "user", "description": "The Notion object type." }, "id": { "type": "string", "description": "The Notion user ID." }, "name": { "type": [ "string", "null" ], "description": "The user's display name, or null when unavailable." }, "avatar_url": { "type": [ "string", "null" ], "description": "The user's avatar URL, or null when unavailable." }, "type": { "type": "string", "enum": [ "person", "bot" ], "description": "The user type returned by Notion." }, "person": { "type": "object", "properties": { "email": { "type": "string", "format": "email", "description": "The person's email address." } }, "additionalProperties": true, "description": "Details about a person user." }, "bot": { "type": "object", "additionalProperties": { "description": "A Notion API field value." }, "description": "Details about a bot user." } }, "additionalProperties": true, "description": "A Notion user reference." }, "last_edited_by": { "type": "object", "properties": { "object": { "const": "user", "description": "The Notion object type." }, "id": { "type": "string", "description": "The Notion user ID." }, "name": { "type": [ "string", "null" ], "description": "The user's display name, or null when unavailable." }, "avatar_url": { "type": [ "string", "null" ], "description": "The user's avatar URL, or null when unavailable." }, "type": { "type": "string", "enum": [ "person", "bot" ], "description": "The user type returned by Notion." }, "person": { "type": "object", "properties": { "email": { "type": "string", "format": "email", "description": "The person's email address." } }, "additionalProperties": true, "description": "Details about a person user." }, "bot": { "type": "object", "additionalProperties": { "description": "A Notion API field value." }, "description": "Details about a bot user." } }, "additionalProperties": true, "description": "A Notion user reference." }, "title": { "type": "array", "items": { "type": "object", "additionalProperties": { "description": "A Notion API field value." }, "description": "A Notion rich text object." }, "description": "The data source title rich text objects." }, "description": { "type": "array", "items": { "type": "object", "additionalProperties": { "description": "A Notion API field value." }, "description": "A Notion rich text object." }, "description": "The data source description rich text objects." }, "icon": { "type": [ "object", "null" ], "additionalProperties": { "description": "A Notion API field value." }, "description": "The data source icon object, or null when it has no icon." }, "properties": { "type": "object", "additionalProperties": { "description": "A Notion property value or property schema object." }, "description": "The Notion page, database, or data source properties keyed by property name." }, "parent": { "type": "object", "properties": { "type": { "type": "string", "description": "The parent type, such as workspace, page_id, data_source_id, database_id, or block_id." } }, "additionalProperties": true, "description": "The parent object that contains this Notion object." }, "url": { "type": "string", "format": "uri", "description": "The canonical Notion URL for the data source." }, "in_trash": { "type": "boolean", "description": "Whether the data source is in the trash." } }, "additionalProperties": true, "description": "The full data source object returned by the API." }, "nullable": false, "handle": "dataSource" } ], "outputs": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "dataSourceId" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "titleKey" } ], "name": "Check the title and File fields", "moduleId": "n_cd6f7073a1a2e01f", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_011990b7add3c229": { "inputs": { "files": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_1416cbc2413eb6c1", "output": "files" } ] }, "dataSourceId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_e9a0a7f845dc9033", "output": "dataSourceId" } ] }, "titleKey": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_e9a0a7f845dc9033", "output": "titleKey" } ] }, "previousState": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_011990b7add3c229", "output": "state" } ] }, "page": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_29dac63794497a24", "output": "output" } ] } }, "name": "Prepare the next Notion page", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "array", "items": { "type": "object", "additionalProperties": true } }, "nullable": false, "handle": "files" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "dataSourceId" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "titleKey" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": true, "handle": "previousState" }, { "jsonSchema": { "type": "object", "properties": { "object": { "const": "page", "description": "The Notion object type." }, "id": { "type": "string", "description": "The page ID." }, "created_time": { "type": "string", "format": "date-time", "description": "The time when the page was created." }, "last_edited_time": { "type": "string", "format": "date-time", "description": "The time when the page was last edited." }, "created_by": { "type": "object", "properties": { "object": { "const": "user", "description": "The Notion object type." }, "id": { "type": "string", "description": "The Notion user ID." }, "name": { "type": [ "string", "null" ], "description": "The user's display name, or null when unavailable." }, "avatar_url": { "type": [ "string", "null" ], "description": "The user's avatar URL, or null when unavailable." }, "type": { "type": "string", "enum": [ "person", "bot" ], "description": "The user type returned by Notion." }, "person": { "type": "object", "properties": { "email": { "type": "string", "format": "email", "description": "The person's email address." } }, "additionalProperties": true, "description": "Details about a person user." }, "bot": { "type": "object", "additionalProperties": { "description": "A Notion API field value." }, "description": "Details about a bot user." } }, "additionalProperties": true, "description": "A Notion user reference." }, "last_edited_by": { "type": "object", "properties": { "object": { "const": "user", "description": "The Notion object type." }, "id": { "type": "string", "description": "The Notion user ID." }, "name": { "type": [ "string", "null" ], "description": "The user's display name, or null when unavailable." }, "avatar_url": { "type": [ "string", "null" ], "description": "The user's avatar URL, or null when unavailable." }, "type": { "type": "string", "enum": [ "person", "bot" ], "description": "The user type returned by Notion." }, "person": { "type": "object", "properties": { "email": { "type": "string", "format": "email", "description": "The person's email address." } }, "additionalProperties": true, "description": "Details about a person user." }, "bot": { "type": "object", "additionalProperties": { "description": "A Notion API field value." }, "description": "Details about a bot user." } }, "additionalProperties": true, "description": "A Notion user reference." }, "cover": { "type": [ "object", "null" ], "additionalProperties": { "description": "A Notion API field value." }, "description": "The page cover object, or null when the page has no cover." }, "icon": { "type": [ "object", "null" ], "additionalProperties": { "description": "A Notion API field value." }, "description": "The page icon object, or null when the page has no icon." }, "parent": { "type": "object", "properties": { "type": { "type": "string", "description": "The parent type, such as workspace, page_id, data_source_id, database_id, or block_id." } }, "additionalProperties": true, "description": "The parent object that contains this Notion object." }, "is_archived": { "type": "boolean", "description": "Whether the page has been archived." }, "in_trash": { "type": "boolean", "description": "Whether the page is in the trash." }, "is_locked": { "type": "boolean", "description": "Whether the page is locked." }, "properties": { "type": "object", "additionalProperties": { "description": "A Notion property value or property schema object." }, "description": "The Notion page, database, or data source properties keyed by property name." }, "url": { "type": "string", "format": "uri", "description": "The canonical Notion URL for the page." }, "public_url": { "type": [ "string", "null" ], "format": "uri", "description": "The public Notion URL if the page is published to the web." } }, "additionalProperties": true, "description": "The created Notion page object returned by the API." }, "nullable": true, "handle": "page" } ], "outputs": [ { "jsonSchema": { "type": "object", "properties": { "index": { "type": "integer", "minimum": 0 }, "receipts": { "type": "array", "items": { "type": "object", "additionalProperties": true } } }, "required": [ "index", "receipts" ], "additionalProperties": false }, "nullable": false, "handle": "state" }, { "jsonSchema": { "type": "boolean" }, "nullable": false, "handle": "more" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "parent" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "properties" }, { "jsonSchema": { "type": "integer", "minimum": 0 }, "nullable": false, "handle": "count" } ], "name": "Prepare the next Notion page", "moduleId": "n_540f06def6d87e88", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_f1b0972ea8778613": { "inputs": {}, "name": "More files to record", "kind": "condition", "matchMode": "first", "cases": [ { "output": "more", "groups": [ { "expressions": [ { "left": { "kind": "source", "source": { "kind": "node", "nodeId": "n_011990b7add3c229", "output": "more" } }, "operator": "==", "right": { "kind": "value", "value": true } } ] } ] } ] }, "n_29dac63794497a24": { "inputs": { "parent": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_011990b7add3c229", "output": "parent" } ] }, "properties": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_011990b7add3c229", "output": "properties" } ] } }, "name": "Create one Notion file record", "kind": "task", "task": { "inputs": [ { "description": "The parent page ID.", "jsonSchema": { "type": "string", "description": "The parent page ID." }, "nullable": true, "handle": "parentId", "value": null }, { "description": "The page title.", "jsonSchema": { "type": "string", "description": "The page title." }, "nullable": true, "handle": "title", "value": null }, { "description": "The official Notion parent object payload. Use { page_id: \"...\" } for a child page under an existing page, { data_source_id: \"...\" } for a data source row, or { workspace: true } to create a workspace-level private page when the credential is an OAuth public integration. When parent is provided, do not use the top-level title field; set the title through properties.title instead. Internal integration secrets usually cannot create workspace-level private pages and should use a parent page or data source.", "jsonSchema": { "type": "object", "additionalProperties": { "description": "A Notion parent field value." }, "description": "The official Notion parent object payload. Use { page_id: \"...\" } for a child page under an existing page, { data_source_id: \"...\" } for a data source row, or { workspace: true } to create a workspace-level private page when the credential is an OAuth public integration. When parent is provided, do not use the top-level title field; set the title through properties.title instead. Internal integration secrets usually cannot create workspace-level private pages and should use a parent page or data source." }, "nullable": true, "handle": "parent", "value": null }, { "description": "The page properties.", "jsonSchema": { "type": "object", "additionalProperties": { "description": "A Notion page property value." }, "description": "The page properties." }, "nullable": true, "handle": "properties", "value": null }, { "description": "The child blocks to add.", "jsonSchema": { "type": "array", "items": { "type": "object", "additionalProperties": { "description": "A Notion API field value." }, "description": "A Notion block object." }, "description": "The child blocks to add." }, "nullable": true, "handle": "children", "value": null }, { "description": "Enhanced Markdown content to create page content. Mutually exclusive with children. Markdown-only private pages without parent are supported only for OAuth public connections or personal access tokens; internal integration secrets should provide a parent page or data source.", "jsonSchema": { "type": "string", "description": "Enhanced Markdown content to create page content. Mutually exclusive with children. Markdown-only private pages without parent are supported only for OAuth public connections or personal access tokens; internal integration secrets should provide a parent page or data source." }, "nullable": true, "handle": "markdown", "value": null }, { "description": "The data source template payload to apply to the created page.", "jsonSchema": { "type": "object", "additionalProperties": { "description": "A Notion template field value." }, "description": "The data source template payload to apply to the created page." }, "nullable": true, "handle": "template", "value": null }, { "description": "The page icon object.", "jsonSchema": { "type": "object", "additionalProperties": { "description": "A Notion icon field value." }, "description": "The page icon object." }, "nullable": true, "handle": "icon", "value": null }, { "description": "The page cover object.", "jsonSchema": { "type": "object", "additionalProperties": { "description": "A Notion cover field value." }, "description": "The page cover object." }, "nullable": true, "handle": "cover", "value": null } ], "outputs": [ { "description": "The created Notion page object returned by the API.", "jsonSchema": { "type": "object", "properties": { "object": { "const": "page", "description": "The Notion object type." }, "id": { "type": "string", "description": "The page ID." }, "created_time": { "type": "string", "format": "date-time", "description": "The time when the page was created." }, "last_edited_time": { "type": "string", "format": "date-time", "description": "The time when the page was last edited." }, "created_by": { "type": "object", "properties": { "object": { "const": "user", "description": "The Notion object type." }, "id": { "type": "string", "description": "The Notion user ID." }, "name": { "type": [ "string", "null" ], "description": "The user's display name, or null when unavailable." }, "avatar_url": { "type": [ "string", "null" ], "description": "The user's avatar URL, or null when unavailable." }, "type": { "type": "string", "enum": [ "person", "bot" ], "description": "The user type returned by Notion." }, "person": { "type": "object", "properties": { "email": { "type": "string", "format": "email", "description": "The person's email address." } }, "additionalProperties": true, "description": "Details about a person user." }, "bot": { "type": "object", "additionalProperties": { "description": "A Notion API field value." }, "description": "Details about a bot user." } }, "additionalProperties": true, "description": "A Notion user reference." }, "last_edited_by": { "type": "object", "properties": { "object": { "const": "user", "description": "The Notion object type." }, "id": { "type": "string", "description": "The Notion user ID." }, "name": { "type": [ "string", "null" ], "description": "The user's display name, or null when unavailable." }, "avatar_url": { "type": [ "string", "null" ], "description": "The user's avatar URL, or null when unavailable." }, "type": { "type": "string", "enum": [ "person", "bot" ], "description": "The user type returned by Notion." }, "person": { "type": "object", "properties": { "email": { "type": "string", "format": "email", "description": "The person's email address." } }, "additionalProperties": true, "description": "Details about a person user." }, "bot": { "type": "object", "additionalProperties": { "description": "A Notion API field value." }, "description": "Details about a bot user." } }, "additionalProperties": true, "description": "A Notion user reference." }, "cover": { "type": [ "object", "null" ], "additionalProperties": { "description": "A Notion API field value." }, "description": "The page cover object, or null when the page has no cover." }, "icon": { "type": [ "object", "null" ], "additionalProperties": { "description": "A Notion API field value." }, "description": "The page icon object, or null when the page has no icon." }, "parent": { "type": "object", "properties": { "type": { "type": "string", "description": "The parent type, such as workspace, page_id, data_source_id, database_id, or block_id." } }, "additionalProperties": true, "description": "The parent object that contains this Notion object." }, "is_archived": { "type": "boolean", "description": "Whether the page has been archived." }, "in_trash": { "type": "boolean", "description": "Whether the page is in the trash." }, "is_locked": { "type": "boolean", "description": "Whether the page is locked." }, "properties": { "type": "object", "additionalProperties": { "description": "A Notion property value or property schema object." }, "description": "The Notion page, database, or data source properties keyed by property name." }, "url": { "type": "string", "format": "uri", "description": "The canonical Notion URL for the page." }, "public_url": { "type": [ "string", "null" ], "format": "uri", "description": "The public Notion URL if the page is published to the web." } }, "additionalProperties": true, "description": "The created Notion page object returned by the API." }, "nullable": false, "handle": "output" } ], "name": "Create one Notion file record", "executor": { "kind": "connector", "action": "notion.create_page", "outputMode": "value" } } }, "n_42999ddaff23f0d4": { "name": "Notion page receipts", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "array", "items": { "type": "object", "additionalProperties": true } }, "nullable": false, "handle": "receipts" }, { "jsonSchema": { "type": "integer", "minimum": 0 }, "nullable": false, "handle": "count" } ], "outputMappings": { "receipts": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_011990b7add3c229", "output": "state", "field": "receipts" } ] }, "count": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_011990b7add3c229", "output": "count" } ] } } } }, "edges": [ { "source": "n_546366099ce8bfd0", "target": "n_1416cbc2413eb6c1" }, { "source": "n_1416cbc2413eb6c1", "target": "n_286b7cc6a6947ca1" }, { "source": "n_286b7cc6a6947ca1", "target": "n_e9a0a7f845dc9033" }, { "source": "n_e9a0a7f845dc9033", "target": "n_011990b7add3c229" }, { "source": "n_011990b7add3c229", "target": "n_f1b0972ea8778613" }, { "source": "n_f1b0972ea8778613", "target": "n_29dac63794497a24", "sourceHandle": "more" }, { "source": "n_29dac63794497a24", "target": "n_011990b7add3c229" }, { "source": "n_f1b0972ea8778613", "target": "n_42999ddaff23f0d4", "sourceHandle": "otherwise" } ] } }, "modules": { "n_9292aa4401de0324": { "name": "Validate the new-file links", "imports": [], "source": "export default function driveNotionFiles({ events }) {\n if (!Array.isArray(events)) throw new Error('Expected a Google Drive event batch');\n const seen = new Set();\n const files = events.map(event => {\n if (!event || event.eventType !== 'file_created' || event.itemType !== 'file' || typeof event.fileId !== 'string' || !event.fileId || typeof event.name !== 'string' || typeof event.webViewLink !== 'string' || !/^https:\\/\\/[^\\s/]+\\//.test(event.webViewLink)) throw new Error('Expected a new file with its original HTTPS viewer link');\n if (seen.has(event.fileId)) throw new Error('Duplicate Google Drive file in this batch');\n seen.add(event.fileId);\n return { fileId: event.fileId, name: event.name, webViewLink: event.webViewLink };\n });\n return { files };\n}\n" }, "n_cd6f7073a1a2e01f": { "name": "Check the title and File fields", "imports": [], "source": "export default function driveNotionSchema({ dataSource }) {\n if (!dataSource || dataSource.object !== 'data_source' || typeof dataSource.id !== 'string' || !dataSource.id || dataSource.in_trash === true || !dataSource.properties || typeof dataSource.properties !== 'object') throw new Error('Expected the configured Notion data source');\n const titles = Object.entries(dataSource.properties).filter(([, property]) => property?.type === 'title');\n if (titles.length !== 1 || dataSource.properties.File?.type !== 'files') throw new Error('Notion needs one title property and a File property of type files');\n return { dataSourceId: dataSource.id, titleKey: titles[0][0] };\n}\n" }, "n_540f06def6d87e88": { "name": "Prepare the next Notion page", "imports": [], "source": "export default function driveNotionProgress({ files, dataSourceId, titleKey, previousState, page }) {\n if (!Array.isArray(files) || typeof dataSourceId !== 'string' || !dataSourceId || typeof titleKey !== 'string' || !titleKey) throw new Error('Expected files and a checked Notion schema');\n let state;\n if (previousState == null) state = { index: 0, receipts: [] };\n else {\n if (!Number.isInteger(previousState.index) || previousState.index < 1 || previousState.index > files.length || !Array.isArray(previousState.receipts) || previousState.receipts.length !== previousState.index - 1) throw new Error('Invalid Notion page progress');\n if (!page || page.object !== 'page' || typeof page.id !== 'string' || !page.id || page.parent?.data_source_id !== dataSourceId) throw new Error('Notion did not confirm the page in the selected data source; creation may already have occurred');\n state = { index: previousState.index, receipts: [...previousState.receipts, { fileId: files[previousState.index - 1].fileId, page }] };\n }\n const file = files[state.index];\n const parent = { type: 'data_source_id', data_source_id: dataSourceId };\n if (file == null) return { state, more: false, parent, properties: {}, count: state.receipts.length };\n const properties = { File: { files: [{ name: file.name, type: 'external', external: { url: file.webViewLink } }] } };\n if (file.name !== '') properties[titleKey] = { title: [{ type: 'text', text: { content: file.name } }] };\n return { state: { index: state.index + 1, receipts: state.receipts }, more: true, parent, properties, count: state.receipts.length };\n}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }