Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ plugins/TransportForLondon/* @clarkd
plugins/UniFi/* @adamkinniburgh
plugins/UptimeRobot/* @kieranlangton
plugins/WorldCup2026/* @TimWheeler-SQUP
plugins/Notion/* @clarkd
plugins/Algolia/* @andrewmumblebee


Expand Down
11 changes: 11 additions & 0 deletions plugins/Notion/v1/configValidation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"steps": [
{
"displayName": "Authenticate",
"dataStream": { "name": "currentUser" },
"required": true,
"error": "Could not connect to Notion. Make sure you have signed in and authorised access to your workspace.",
"success": "Connected to Notion successfully."
}
]
}
23 changes: 23 additions & 0 deletions plugins/Notion/v1/custom_types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
{
"name": "Notion User",
"sourceType": "Notion User",
"icon": "user",
"singular": "User",
"plural": "Users"
},
{
"name": "Notion Data Source",
"sourceType": "Notion Data Source",
"icon": "table",
"singular": "Data Source",
"plural": "Data Sources"
},
{
"name": "Notion Page",
"sourceType": "Notion Page",
"icon": "file-lines",
"singular": "Page",
"plural": "Pages"
}
]
21 changes: 21 additions & 0 deletions plugins/Notion/v1/dataStreams/currentUser.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "currentUser",
"displayName": "Current User",
"description": "The authenticated Notion bot user and its workspace",
"tags": ["Account"],
"baseDataSourceName": "httpRequestUnscoped",
"config": {
"httpMethod": "get",
"endpointPath": "users/me",
"postRequestScript": "currentUser.js"
},
"matches": "none",
"visibility": { "type": "hidden" },
"metadata": [
{ "name": "name", "displayName": "Name", "shape": "string", "role": "label" },
{ "name": "workspaceName", "displayName": "Workspace", "shape": "string" },
{ "name": "type", "displayName": "Type", "shape": "string" },
{ "name": "id", "displayName": "ID", "shape": "string", "role": "id", "visible": false }
],
"timeframes": false
}
31 changes: 31 additions & 0 deletions plugins/Notion/v1/dataStreams/dataSourceRows.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "dataSourceRows",
"displayName": "Data Source Contents",
"description": "Pages within a data source with their property values",
"tags": ["Data Sources", "Pages"],
"baseDataSourceName": "httpRequestScopedSingle",
"config": {
"httpMethod": "post",
"endpointPath": "data_sources/{{object.rawId}}/query",
"postBody": {},
"postRequestScript": "dataSourceRows.js",
"paging": {
"mode": "token",
"pageSize": { "realm": "body", "path": "page_size", "value": 100 },
"in": { "realm": "payload", "path": "next_cursor" },
"out": { "realm": "body", "path": "start_cursor" }
}
},
"matches": {
"sourceType": { "type": "oneOf", "values": ["Notion Data Source"] }
},
"metadata": [
{ "name": "name", "displayName": "Name", "shape": "string", "role": "label" },
{ "name": "lastEditedTime", "displayName": "Last Edited", "shape": "date" },
{ "name": "createdTime", "displayName": "Created", "shape": "date", "visible": false },
Comment thread
coderabbitai[bot] marked this conversation as resolved.
{ "name": "url", "displayName": "URL", "shape": ["url", { "label": "Open in Notion" }], "visible": false },
{ "name": "id", "displayName": "ID", "shape": "string", "role": "id", "visible": false },
{ "pattern": ".*" }
],
"timeframes": false
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
22 changes: 22 additions & 0 deletions plugins/Notion/v1/dataStreams/dataSourceSchema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "dataSourceSchema",
"displayName": "Data Source Schema",
"description": "Property names and types (schema) for a single data source",
"tags": ["Data Sources"],
"baseDataSourceName": "httpRequestScopedSingle",
"config": {
"httpMethod": "get",
"endpointPath": "data_sources/{{object.rawId}}",
"paging": { "mode": "none" },
"postRequestScript": "dataSourceSchema.js"
},
"matches": {
"sourceType": { "type": "oneOf", "values": ["Notion Data Source"] }
},
"metadata": [
{ "name": "name", "displayName": "Name", "shape": "string", "role": "label" },
{ "name": "type", "displayName": "Type", "shape": "string" },
{ "name": "details", "displayName": "Details", "shape": "string" }
],
"timeframes": false
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
29 changes: 29 additions & 0 deletions plugins/Notion/v1/dataStreams/dataSourcesSearch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "dataSourcesSearch",
"displayName": "Data Sources",
"description": "Data sources (database tables) shared with the integration",
"tags": ["Data Sources"],
"baseDataSourceName": "httpRequestUnscoped",
"config": {
"httpMethod": "post",
"endpointPath": "search",
"postBody": { "filter": { "property": "object", "value": "data_source" } },
"postRequestScript": "dataSourcesSearch.js",
"paging": {
"mode": "token",
"pageSize": { "realm": "body", "path": "page_size", "value": 100 },
"in": { "realm": "payload", "path": "next_cursor" },
"out": { "realm": "body", "path": "start_cursor" }
}
},
"matches": "none",
"metadata": [
{ "name": "id", "displayName": "ID", "shape": "string", "role": "id", "visible": false },
{ "name": "name", "displayName": "Name", "shape": "string", "role": "label" },
{ "name": "createdTime", "displayName": "Created", "shape": "date" },
{ "name": "lastEditedTime", "displayName": "Last Edited", "shape": "date" },
{ "name": "url", "displayName": "URL", "shape": ["url", { "label": "Open in Notion" }] },
{ "name": "parentDatabaseId", "displayName": "Parent Database ID", "shape": "string", "visible": false }
],
"timeframes": false
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
42 changes: 42 additions & 0 deletions plugins/Notion/v1/dataStreams/pageComments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "pageComments",
"displayName": "Page Comments",
"description": "Comments and discussion threads on a single Notion page",
"tags": ["Comments"],
"baseDataSourceName": "httpRequestScopedSingle",
"config": {
"httpMethod": "get",
"endpointPath": "comments",
"getArgs": [
{ "key": "block_id", "value": "{{object.rawId}}" }
],
"postRequestScript": "pageComments.js",
"paging": {
"mode": "token",
"pageSize": { "realm": "queryArg", "path": "page_size", "value": "100" },
"in": { "realm": "payload", "path": "next_cursor" },
"out": { "realm": "queryArg", "path": "start_cursor" }
},
"errorHandling": {
"type": "script",
"script": "result = response.status === 403 ? 'Notion did not grant the Read comments capability. Enable \"Read comments\" on your Notion integration, then reconnect the plugin in SquaredUp.' : ((data && data.message) || ('Notion comments API returned status ' + response.status));"
}
},
"matches": {
"sourceType": { "type": "oneOf", "values": ["Notion Page"] }
},
"metadata": [
{ "name": "id", "displayName": "ID", "shape": "string", "visible": false },
{ "name": "createdTime", "displayName": "Created", "shape": "date" },
{ "name": "text", "displayName": "Comment", "shape": "string", "role": "label" },
{ "name": "createdById", "displayName": "Created By ID", "shape": "string", "visible": false },
{
"name": "author",
"displayName": "Author",
"sourceId": "createdById",
"sourceType": "Notion User",
"objectPropertyPath": "name"
}
],
"timeframes": false
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
27 changes: 27 additions & 0 deletions plugins/Notion/v1/dataStreams/pageContent.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "pageContent",
"displayName": "Page Content",
"description": "Block-level content of a Notion page β€” paragraphs, headings, to-do items, lists, quotes, callouts and code blocks",
"tags": ["Pages"],
"baseDataSourceName": "httpRequestScopedSingle",
"config": {
"httpMethod": "get",
"endpointPath": "blocks/{{object.rawId}}/children",
"paging": {
"mode": "token",
"pageSize": { "realm": "queryArg", "path": "page_size", "value": "100" },
"in": { "realm": "payload", "path": "next_cursor" },
"out": { "realm": "queryArg", "path": "start_cursor" }
},
"postRequestScript": "pageContent.js"
},
"matches": { "sourceType": { "type": "oneOf", "values": ["Notion Page"] } },
"metadata": [
{ "name": "type", "displayName": "Type", "shape": "string" },
{ "name": "text", "displayName": "Text", "shape": "string", "role": "label" },
{ "name": "checked", "displayName": "Checked", "shape": "boolean" },
{ "name": "hasChildren", "displayName": "Has Children", "shape": "boolean", "visible": false },
{ "pattern": ".*" }
],
"timeframes": false
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
25 changes: 25 additions & 0 deletions plugins/Notion/v1/dataStreams/pageProperties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "pageProperties",
"displayName": "Page Properties",
"description": "Property values for a single Notion page",
"tags": ["Pages"],
"baseDataSourceName": "httpRequestScopedSingle",
"config": {
"httpMethod": "get",
"endpointPath": "pages/{{object.rawId}}",
"postRequestScript": "pageProperties.js",
"paging": { "mode": "none" }
},
"matches": {
"sourceType": { "type": "oneOf", "values": ["Notion Page"] }
},
"metadata": [
{ "name": "name", "displayName": "Name", "shape": "string", "role": "label" },
{ "name": "lastEditedTime", "displayName": "Last Edited", "shape": "date" },
{ "name": "createdTime", "displayName": "Created", "shape": "date", "visible": false },
{ "name": "url", "displayName": "URL", "shape": ["url", { "label": "Open in Notion" }], "visible": false },
{ "name": "id", "displayName": "ID", "shape": "string", "role": "id", "visible": false },
{ "pattern": ".*" }
],
"timeframes": false
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
40 changes: 40 additions & 0 deletions plugins/Notion/v1/dataStreams/pagesSearch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "pagesSearch",
"displayName": "Pages",
"description": "Pages shared with the integration, including database rows",
"tags": ["Pages"],
"baseDataSourceName": "httpRequestUnscoped",
"config": {
"httpMethod": "post",
"endpointPath": "search",
"postBody": { "filter": { "property": "object", "value": "page" } },
"postRequestScript": "pagesSearch.js",
"paging": {
"mode": "token",
"pageSize": { "realm": "body", "path": "page_size", "value": 100 },
"in": { "realm": "payload", "path": "next_cursor" },
"out": { "realm": "body", "path": "start_cursor" }
}
},
"matches": "none",
"ui": [
{
"type": "objects",
"name": "scope",
"label": "Page or data source (optional)",
"matches": {
"sourceType": { "type": "oneOf", "values": ["Notion Page", "Notion Data Source"] }
}
}
],
"metadata": [
{ "name": "id", "displayName": "ID", "shape": "string", "role": "id", "visible": false },
{ "name": "name", "displayName": "Name", "shape": "string", "role": "label" },
{ "name": "createdTime", "displayName": "Created", "shape": "date" },
{ "name": "lastEditedTime", "displayName": "Last Edited", "shape": "date" },
{ "name": "url", "displayName": "URL", "shape": ["url", { "label": "Open in Notion" }] },
{ "name": "parentType", "displayName": "Parent Type", "shape": "string", "visible": false },
{ "name": "parentDataSourceId", "displayName": "Parent Data Source ID", "shape": "string", "visible": false }
],
"timeframes": false
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
10 changes: 10 additions & 0 deletions plugins/Notion/v1/dataStreams/scripts/currentUser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// /v1/users/me returns a single user object (the integration's bot user),
// not an array β€” wrap it as one row and surface the workspace name.
result = [
{
id: data.id,
name: data.name || (data.bot && data.bot.workspace_name) || "Notion bot",
type: data.type,
workspaceName: data.bot && data.bot.workspace_name
}
];
89 changes: 89 additions & 0 deletions plugins/Notion/v1/dataStreams/scripts/dataSourceRows.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// POST /v1/data_sources/{id}/query returns the pages (rows) of a data source,
// accumulated across pages under data.results. Each page's `properties` is a bag
// of typed Notion property values keyed by the property name; flatten each to a
// scalar so the custom fields become plain columns.
const plain = (rich) => (rich || []).map((t) => t.plain_text).join("");

const valueOf = (prop) => {
if (!prop) return null;
switch (prop.type) {
case "title":
return plain(prop.title);
case "rich_text":
return plain(prop.rich_text);
case "number":
return prop.number;
case "select":
return prop.select ? prop.select.name : null;
case "status":
return prop.status ? prop.status.name : null;
case "multi_select":
return (prop.multi_select || []).map((s) => s.name).join(", ");
case "date":
return prop.date ? prop.date.start : null;
case "checkbox":
return prop.checkbox;
case "url":
return prop.url;
case "email":
return prop.email;
case "phone_number":
return prop.phone_number;
case "people":
return (prop.people || []).map((p) => p.name || p.id).join(", ");
case "files":
return (prop.files || []).map((f) => f.name).join(", ");
case "created_time":
return prop.created_time;
case "last_edited_time":
return prop.last_edited_time;
case "created_by":
return prop.created_by ? prop.created_by.name || prop.created_by.id : null;
case "last_edited_by":
return prop.last_edited_by ? prop.last_edited_by.name || prop.last_edited_by.id : null;
case "unique_id":
return prop.unique_id
? (prop.unique_id.prefix ? prop.unique_id.prefix + "-" : "") + prop.unique_id.number
: null;
case "formula":
return prop.formula
? prop.formula.string ??
prop.formula.number ??
prop.formula.boolean ??
(prop.formula.date ? prop.formula.date.start : null)
: null;
case "rollup":
if (!prop.rollup) return null;
if (prop.rollup.type === "array") {
return (prop.rollup.array || []).map((item) => valueOf(item)).filter((v) => v != null).join(", ");
}
return prop.rollup.number ?? (prop.rollup.date ? prop.rollup.date.start : null);
case "relation":
return (prop.relation || []).map((r) => r.id).join(", ");
default:
return null;
}
};

result = (data.results || []).map((page) => {
const props = page.properties || {};
const row = {
id: page.id,
url: page.url || null,
createdTime: page.created_time || null,
lastEditedTime: page.last_edited_time || null
};
let title = "";
for (const key of Object.keys(props)) {
const prop = props[key];
const value = valueOf(prop);
// The title property is surfaced as `name` β€” don't also emit it as a duplicate column.
if (prop && prop.type === "title") {
title = value || title;
continue;
}
row[key] = value;
}
row.name = title || "Untitled";
return row;
});
Loading
Loading