Skip to content

Commit d0a55d8

Browse files
authored
Merge pull request #74 from squaredup/plugin/add-notion
Add Notion plugin
2 parents 79d605d + 8db1006 commit d0a55d8

31 files changed

Lines changed: 1428 additions & 0 deletions

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ plugins/TransportForLondon/* @clarkd
2424
plugins/UniFi/* @adamkinniburgh
2525
plugins/UptimeRobot/* @kieranlangton
2626
plugins/WorldCup2026/* @TimWheeler-SQUP
27+
plugins/Notion/* @clarkd
2728
plugins/Algolia/* @andrewmumblebee
2829

2930

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"steps": [
3+
{
4+
"displayName": "Authenticate",
5+
"dataStream": { "name": "currentUser" },
6+
"required": true,
7+
"error": "Could not connect to Notion. Make sure you have signed in and authorised access to your workspace.",
8+
"success": "Connected to Notion successfully."
9+
}
10+
]
11+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[
2+
{
3+
"name": "Notion User",
4+
"sourceType": "Notion User",
5+
"icon": "user",
6+
"singular": "User",
7+
"plural": "Users"
8+
},
9+
{
10+
"name": "Notion Data Source",
11+
"sourceType": "Notion Data Source",
12+
"icon": "table",
13+
"singular": "Data Source",
14+
"plural": "Data Sources"
15+
},
16+
{
17+
"name": "Notion Page",
18+
"sourceType": "Notion Page",
19+
"icon": "file-lines",
20+
"singular": "Page",
21+
"plural": "Pages"
22+
}
23+
]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "currentUser",
3+
"displayName": "Current User",
4+
"description": "The authenticated Notion bot user and its workspace",
5+
"tags": ["Account"],
6+
"baseDataSourceName": "httpRequestUnscoped",
7+
"config": {
8+
"httpMethod": "get",
9+
"endpointPath": "users/me",
10+
"postRequestScript": "currentUser.js"
11+
},
12+
"matches": "none",
13+
"visibility": { "type": "hidden" },
14+
"metadata": [
15+
{ "name": "name", "displayName": "Name", "shape": "string", "role": "label" },
16+
{ "name": "workspaceName", "displayName": "Workspace", "shape": "string" },
17+
{ "name": "type", "displayName": "Type", "shape": "string" },
18+
{ "name": "id", "displayName": "ID", "shape": "string", "role": "id", "visible": false }
19+
],
20+
"timeframes": false
21+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "dataSourceRows",
3+
"displayName": "Data Source Contents",
4+
"description": "Pages within a data source with their property values",
5+
"tags": ["Data Sources", "Pages"],
6+
"baseDataSourceName": "httpRequestScopedSingle",
7+
"config": {
8+
"httpMethod": "post",
9+
"endpointPath": "data_sources/{{object.rawId}}/query",
10+
"postBody": {},
11+
"postRequestScript": "dataSourceRows.js",
12+
"paging": {
13+
"mode": "token",
14+
"pageSize": { "realm": "body", "path": "page_size", "value": 100 },
15+
"in": { "realm": "payload", "path": "next_cursor" },
16+
"out": { "realm": "body", "path": "start_cursor" }
17+
}
18+
},
19+
"matches": {
20+
"sourceType": { "type": "oneOf", "values": ["Notion Data Source"] }
21+
},
22+
"metadata": [
23+
{ "name": "name", "displayName": "Name", "shape": "string", "role": "label" },
24+
{ "name": "lastEditedTime", "displayName": "Last Edited", "shape": "date" },
25+
{ "name": "createdTime", "displayName": "Created", "shape": "date", "visible": false },
26+
{ "name": "url", "displayName": "URL", "shape": ["url", { "label": "Open in Notion" }], "visible": false },
27+
{ "name": "id", "displayName": "ID", "shape": "string", "role": "id", "visible": false },
28+
{ "pattern": ".*" }
29+
],
30+
"timeframes": false
31+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "dataSourceSchema",
3+
"displayName": "Data Source Schema",
4+
"description": "Property names and types (schema) for a single data source",
5+
"tags": ["Data Sources"],
6+
"baseDataSourceName": "httpRequestScopedSingle",
7+
"config": {
8+
"httpMethod": "get",
9+
"endpointPath": "data_sources/{{object.rawId}}",
10+
"paging": { "mode": "none" },
11+
"postRequestScript": "dataSourceSchema.js"
12+
},
13+
"matches": {
14+
"sourceType": { "type": "oneOf", "values": ["Notion Data Source"] }
15+
},
16+
"metadata": [
17+
{ "name": "name", "displayName": "Name", "shape": "string", "role": "label" },
18+
{ "name": "type", "displayName": "Type", "shape": "string" },
19+
{ "name": "details", "displayName": "Details", "shape": "string" }
20+
],
21+
"timeframes": false
22+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "dataSourcesSearch",
3+
"displayName": "Data Sources",
4+
"description": "Data sources (database tables) shared with the integration",
5+
"tags": ["Data Sources"],
6+
"baseDataSourceName": "httpRequestUnscoped",
7+
"config": {
8+
"httpMethod": "post",
9+
"endpointPath": "search",
10+
"postBody": { "filter": { "property": "object", "value": "data_source" } },
11+
"postRequestScript": "dataSourcesSearch.js",
12+
"paging": {
13+
"mode": "token",
14+
"pageSize": { "realm": "body", "path": "page_size", "value": 100 },
15+
"in": { "realm": "payload", "path": "next_cursor" },
16+
"out": { "realm": "body", "path": "start_cursor" }
17+
}
18+
},
19+
"matches": "none",
20+
"metadata": [
21+
{ "name": "id", "displayName": "ID", "shape": "string", "role": "id", "visible": false },
22+
{ "name": "name", "displayName": "Name", "shape": "string", "role": "label" },
23+
{ "name": "createdTime", "displayName": "Created", "shape": "date" },
24+
{ "name": "lastEditedTime", "displayName": "Last Edited", "shape": "date" },
25+
{ "name": "url", "displayName": "URL", "shape": ["url", { "label": "Open in Notion" }] },
26+
{ "name": "parentDatabaseId", "displayName": "Parent Database ID", "shape": "string", "visible": false }
27+
],
28+
"timeframes": false
29+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "pageComments",
3+
"displayName": "Page Comments",
4+
"description": "Comments and discussion threads on a single Notion page",
5+
"tags": ["Comments"],
6+
"baseDataSourceName": "httpRequestScopedSingle",
7+
"config": {
8+
"httpMethod": "get",
9+
"endpointPath": "comments",
10+
"getArgs": [
11+
{ "key": "block_id", "value": "{{object.rawId}}" }
12+
],
13+
"postRequestScript": "pageComments.js",
14+
"paging": {
15+
"mode": "token",
16+
"pageSize": { "realm": "queryArg", "path": "page_size", "value": "100" },
17+
"in": { "realm": "payload", "path": "next_cursor" },
18+
"out": { "realm": "queryArg", "path": "start_cursor" }
19+
},
20+
"errorHandling": {
21+
"type": "script",
22+
"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));"
23+
}
24+
},
25+
"matches": {
26+
"sourceType": { "type": "oneOf", "values": ["Notion Page"] }
27+
},
28+
"metadata": [
29+
{ "name": "id", "displayName": "ID", "shape": "string", "visible": false },
30+
{ "name": "createdTime", "displayName": "Created", "shape": "date" },
31+
{ "name": "text", "displayName": "Comment", "shape": "string", "role": "label" },
32+
{ "name": "createdById", "displayName": "Created By ID", "shape": "string", "visible": false },
33+
{
34+
"name": "author",
35+
"displayName": "Author",
36+
"sourceId": "createdById",
37+
"sourceType": "Notion User",
38+
"objectPropertyPath": "name"
39+
}
40+
],
41+
"timeframes": false
42+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "pageContent",
3+
"displayName": "Page Content",
4+
"description": "Block-level content of a Notion page — paragraphs, headings, to-do items, lists, quotes, callouts and code blocks",
5+
"tags": ["Pages"],
6+
"baseDataSourceName": "httpRequestScopedSingle",
7+
"config": {
8+
"httpMethod": "get",
9+
"endpointPath": "blocks/{{object.rawId}}/children",
10+
"paging": {
11+
"mode": "token",
12+
"pageSize": { "realm": "queryArg", "path": "page_size", "value": "100" },
13+
"in": { "realm": "payload", "path": "next_cursor" },
14+
"out": { "realm": "queryArg", "path": "start_cursor" }
15+
},
16+
"postRequestScript": "pageContent.js"
17+
},
18+
"matches": { "sourceType": { "type": "oneOf", "values": ["Notion Page"] } },
19+
"metadata": [
20+
{ "name": "type", "displayName": "Type", "shape": "string" },
21+
{ "name": "text", "displayName": "Text", "shape": "string", "role": "label" },
22+
{ "name": "checked", "displayName": "Checked", "shape": "boolean" },
23+
{ "name": "hasChildren", "displayName": "Has Children", "shape": "boolean", "visible": false },
24+
{ "pattern": ".*" }
25+
],
26+
"timeframes": false
27+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "pageProperties",
3+
"displayName": "Page Properties",
4+
"description": "Property values for a single Notion page",
5+
"tags": ["Pages"],
6+
"baseDataSourceName": "httpRequestScopedSingle",
7+
"config": {
8+
"httpMethod": "get",
9+
"endpointPath": "pages/{{object.rawId}}",
10+
"postRequestScript": "pageProperties.js",
11+
"paging": { "mode": "none" }
12+
},
13+
"matches": {
14+
"sourceType": { "type": "oneOf", "values": ["Notion Page"] }
15+
},
16+
"metadata": [
17+
{ "name": "name", "displayName": "Name", "shape": "string", "role": "label" },
18+
{ "name": "lastEditedTime", "displayName": "Last Edited", "shape": "date" },
19+
{ "name": "createdTime", "displayName": "Created", "shape": "date", "visible": false },
20+
{ "name": "url", "displayName": "URL", "shape": ["url", { "label": "Open in Notion" }], "visible": false },
21+
{ "name": "id", "displayName": "ID", "shape": "string", "role": "id", "visible": false },
22+
{ "pattern": ".*" }
23+
],
24+
"timeframes": false
25+
}

0 commit comments

Comments
 (0)