Skip to content

Commit 09bba55

Browse files
authored
Notion API Update (#18317)
* Initial database > dataSource conversion * More data source updates * "Update Page" updates * Other data source updates * Lots of other data source updates * Reverting key change * Version bumps * Key adjustment * Fixing "Page Properties Updated" source * Fixing query method * Page builder fixes * Text/link fixes
1 parent c7f60dc commit 09bba55

File tree

41 files changed

+259
-215
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+259
-215
lines changed

components/notion/actions/append-block/append-block.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
name: "Append Block to Parent",
88
description:
99
"Append new and/or existing blocks to the specified parent. [See the documentation](https://developers.notion.com/reference/patch-block-children)",
10-
version: "0.3.7",
10+
version: "0.3.8",
1111
type: "action",
1212
props: {
1313
notion,

components/notion/actions/common/base-page-builder.mjs

Lines changed: 54 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { markdownToBlocks } from "@tryfabric/martian";
22
import {
3-
NOTION_DATABASE_META,
3+
NOTION_DATA_SOURCE_META,
44
NOTION_PAGE_META,
55
} from "../../common/notion-meta-properties.mjs";
66
import NOTION_META from "../../common/notion-meta-selection.mjs";
@@ -10,7 +10,7 @@ export default {
1010
methods: {
1111
/**
1212
* Creates additional props for page properties and the selected block children
13-
* @param properties - The selected (database) properties from the page obtained from Notion
13+
* @param properties - The selected (data source) properties from the page obtained from Notion
1414
* @param meta - The selected meta properties
1515
* @param blocks - The selected block children from the workflow UI
1616
* @returns additional props
@@ -74,7 +74,8 @@ export default {
7474
* @param properties - Properties from the selected page obtained from Notion
7575
* @returns the selected props inputted by the user with the following attributes:
7676
* - type: the Notion property type used in notion-page-properties.mjs
77-
* - label: the page's property name
77+
* - label: the property ID for API calls
78+
* (was property name before data source migration)
7879
* - value: the property value inputted by the user
7980
*/
8081
_filterProps(properties = {}) {
@@ -83,7 +84,7 @@ export default {
8384
|| (this.properties && this.properties[property]))
8485
.map((property) => ({
8586
type: properties[property]?.type ?? property,
86-
label: property,
87+
label: properties[property]?.id || property,
8788
value: this[property] || this.properties?.[property],
8889
}));
8990
},
@@ -96,20 +97,26 @@ export default {
9697
_convertPropertiesToNotion(properties = [], NOTION_CONVERTER = {}) {
9798
const notionProperties = {};
9899
for (const property of properties) {
99-
const notionProperty = NOTION_CONVERTER[property.type];
100-
notionProperties[property.label] = notionProperty?.convertToNotion(property);
100+
// If the property value is already in Notion format, use it directly
101+
if (this._isAlreadyNotionFormat(property.value, property.type)) {
102+
notionProperties[property.label] = property.value;
103+
} else {
104+
// Otherwise, convert using the appropriate converter
105+
const notionProperty = NOTION_CONVERTER[property.type];
106+
notionProperties[property.label] = notionProperty?.convertToNotion(property);
107+
}
101108
}
102109
return notionProperties;
103110
},
104111
/**
105-
* Builds page meta properties (parent, icon, cover, archived) from a parent database
112+
* Builds page meta properties (parent, icon, cover, archived) from a parent data source
106113
* Uses the property label as its type to be able to select in notion-meta-properties.mjs
107114
* @param properties - list of Notion page properties inputted by the user
108115
* @returns the meta properties in Notion format inputted by the user
109116
*/
110-
_buildNotionDatabaseMeta(properties = []) {
117+
_buildNotionDataSourceMeta(properties = []) {
111118
properties.forEach((property) => property.type = property.label);
112-
return this._convertPropertiesToNotion(properties, NOTION_DATABASE_META);
119+
return this._convertPropertiesToNotion(properties, NOTION_DATA_SOURCE_META);
113120
},
114121
/**
115122
* Builds page meta properties (parent, icon, cover, archived) from a parent page
@@ -122,21 +129,21 @@ export default {
122129
return this._convertPropertiesToNotion(properties, NOTION_PAGE_META);
123130
},
124131
/**
125-
* Builds page properties from a parent database/page
132+
* Builds page properties from a parent data source/page
126133
* @param properties - list of Notion page properties inputted by the user
127134
* @returns the properties in Notion format inputted by the user
128135
*/
129136
_buildNotionPageProperties(properties = []) {
130137
return this._convertPropertiesToNotion(properties, NOTION_PAGE_PROPERTIES);
131138
},
132139
/**
133-
* Builds the page meta inputted by the user in Notion format from a parent database
134-
* @param parentDatabase - the parent database that contains the meta properties
140+
* Builds the page meta inputted by the user in Notion format from a parent data source
141+
* @param parentDataSource - the parent data source that contains the meta properties
135142
* @returns the meta properties in Notion format
136143
*/
137-
buildDatabaseMeta(parentDatabase) {
138-
const filteredMeta = this._filterProps(parentDatabase);
139-
return this._buildNotionDatabaseMeta(filteredMeta);
144+
buildDataSourceMeta(parentDataSource) {
145+
const filteredMeta = this._filterProps(parentDataSource);
146+
return this._buildNotionDataSourceMeta(filteredMeta);
140147
},
141148
/**
142149
* Builds the page meta inputted by the user in Notion format from a parent page
@@ -156,6 +163,32 @@ export default {
156163
const filteredProperties = this._filterProps(parentProperties);
157164
return this._buildNotionPageProperties(filteredProperties);
158165
},
166+
/**
167+
* Checks if a property value is already in Notion format
168+
* @param value - the property value to check
169+
* @returns true if already in Notion format, false otherwise
170+
*/
171+
_isAlreadyNotionFormat(value) {
172+
if (!value || typeof value !== "object") return false;
173+
174+
// Check for common Notion property structures
175+
const notionKeys = [
176+
"title",
177+
"rich_text",
178+
"number",
179+
"select",
180+
"multi_select",
181+
"date",
182+
"people",
183+
"files",
184+
"checkbox",
185+
"url",
186+
"email",
187+
"phone_number",
188+
"relation",
189+
];
190+
return notionKeys.some((key) => key in value);
191+
},
159192
/**
160193
* Creates the block children inputted by the user in Notion format
161194
* @returns the block children in Notion format
@@ -210,13 +243,13 @@ export default {
210243
},
211244
};
212245
},
213-
childDatabaseToLink(block) {
246+
childDataSourceToLink(block) {
214247
return {
215248
object: "block",
216249
type: "link_to_page",
217250
link_to_page: {
218-
type: "database_id",
219-
database_id: block.id,
251+
type: "data_source_id",
252+
data_source_id: block.id,
220253
},
221254
};
222255
},
@@ -236,9 +269,9 @@ export default {
236269
if (child.type === "child_page") {
237270
// convert child pages to links
238271
children[i] = this.childPageToLink(child);
239-
} else if (child.type === "child_database") {
240-
// convert child databases to links
241-
children[i] = this.childDatabaseToLink(child);
272+
} else if (child.type === "child_data_source") {
273+
// convert child data sources to links
274+
children[i] = this.childDataSourceToLink(child);
242275
} else {
243276
if (this.notValid(child, c)) {
244277
children[i] = undefined;

components/notion/actions/complete-file-upload/complete-file-upload.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "notion-complete-file-upload",
77
name: "Complete File Upload",
88
description: "Use this action to finalize a `mode=multi_part` file upload after all of the parts have been sent successfully. [See the documentation](https://developers.notion.com/reference/complete-a-file-upload)",
9-
version: "0.0.2",
9+
version: "0.0.3",
1010
type: "action",
1111
props: {
1212
notion,

components/notion/actions/create-comment/create-comment.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "notion-create-comment",
66
name: "Create Comment",
77
description: "Create a comment in a page or existing discussion thread. [See the documentation](https://developers.notion.com/reference/create-a-comment)",
8-
version: "0.0.7",
8+
version: "0.0.8",
99
type: "action",
1010
props: {
1111
notion,

components/notion/actions/create-database/create-database.mjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ export default {
66
...base,
77
key: "notion-create-database",
88
name: "Create Database",
9-
description: "Create a database. [See the documentation](https://developers.notion.com/reference/create-a-database)",
10-
version: "0.0.2",
9+
description: "Create a database and its initial data source. [See the documentation](https://developers.notion.com/reference/database-create)",
10+
version: "0.1.0",
1111
type: "action",
1212
props: {
1313
notion,
@@ -45,7 +45,9 @@ export default {
4545
},
4646
},
4747
],
48-
properties: utils.parseObject(this.properties),
48+
initial_data_source: {
49+
properties: utils.parseObject(this.properties),
50+
},
4951
});
5052

5153
$.export("$summary", `Successfully created database with ID ${response.id}`);

components/notion/actions/create-file-upload/create-file-upload.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "notion-create-file-upload",
77
name: "Create File Upload",
88
description: "Create a file upload. [See the documentation](https://developers.notion.com/reference/create-a-file-upload)",
9-
version: "0.0.2",
9+
version: "0.0.3",
1010
type: "action",
1111
props: {
1212
notion,
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
# Overview
22

3-
The Notion Create Page from Database action allows you to add pages to a Notion Database.
3+
The Notion Create Page from Data Source action allows you to add pages to a Notion Data Source.
44

5-
This action features easy to use dropdowns that automatically populate your databases as well as your database's properties, also known as columns.
5+
This action features easy to use dropdowns that automatically populate your data source as well as your data source's properties, also known as columns.
66

7-
This action interacts with the [Notion create a Page API endpoint](https://developers.notion.com/reference/post-page). The Database selected in the `Parent Database ID` is used as the `parent_id` parameter to that endpoint so the page is added to your databaset .
7+
This action interacts with the [Notion create a Page API endpoint](https://developers.notion.com/reference/post-page). The Data Source selected in the `Parent Data Source ID` is used as the `parent_id` parameter to that endpoint so the page is added to your data source.
88

99
# Getting Started
1010

1111
<iframe width="560" height="315" src="https://www.youtube.com/embed/wciWsu564_0" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
1212

13-
[Follow this short 4 minute guide to connect your Notion account and add new Database pages](https://youtu.be/wciWsu564_0)
13+
[Follow this short 4 minute guide to connect your Notion account and add new Data Source pages](https://youtu.be/wciWsu564_0) (note: as of 2025-09-02, Databases are divided into multiple Data Sources, which are the entities that contain the pages)
1414

1515
### Props
1616

17-
When using the **Create Page from Database** action, there are several props to define:
17+
When using the **Create Page from Data Source** action, there are several props to define:
1818

1919
1. `Notion Account` - see the **Accounts** section below.
20-
2. `Parent Database ID` - the database to add a page to.
20+
2. `Parent Data Source ID` - the data source to add a page to.
2121
3. `Meta Types` - an icon or cover to add to the new page (optional).
22-
4. `Property Types` - one or more properties to add to the new page that correspond with columns in the database.
22+
4. `Property Types` - one or more properties to add to the new page that correspond with columns in the data source.
2323
5. `Page Content` - the content of the page that appears when it's opened in a side view.
2424

2525
Each selected `Property Type` will also add a new prop for that given column.
@@ -37,12 +37,12 @@ Each selected `Property Type` will also add a new prop for that given column.
3737
1. [Create a new workflow](https://pipedream.com/new).
3838
2. Select your trigger (HTTP, Cron, etc.).
3939
3. Click on the **+** button below the trigger step, and search for "Notion".
40-
4. Select the **Create Page from Database** action.
40+
4. Select the **Create Page from Data Source** action.
4141
5. Click the **Connect Account** button near the top of the step. This will prompt you to select any existing Notion accounts you've previously authenticated with Pipedream, or you can select a **New** account. Clicking **New** opens a new window asking you to allow Pipedream access to your Notion workspaces and pages. Choose the workspaces and pages where you'd like to install the app, then click **Allow**.
4242
6. That's it! You can now connect to the Notion API using any of the Slack actions within a Pipedream workflow.
4343

4444
# Troubleshooting
4545

46-
If your database doesn't appear under the options, try deleting your Notion account connection and reconnecting.
46+
If your data source doesn't appear under the options, try deleting your Notion account connection and reconnecting.
4747

48-
There's an issue with Notion Databases not appearing in the options if the Database was created _after_ you connected your Notion account to Pipedream.
48+
There's an issue with Notion Data Sources not appearing in the options if the Data Source was created _after_ you connected your Notion account to Pipedream.

components/notion/actions/create-page-from-database/create-page-from-database.mjs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,30 @@ import base from "../common/base-page-builder.mjs";
66
export default {
77
...base,
88
key: "notion-create-page-from-database",
9-
name: "Create Page from Database",
10-
description: "Create a page from a database. [See the documentation](https://developers.notion.com/reference/post-page)",
11-
version: "0.2.4",
9+
name: "Create Page from Data Source",
10+
description: "Create a page from a data source. [See the documentation](https://developers.notion.com/reference/post-page)",
11+
version: "1.0.0",
1212
type: "action",
1313
props: {
1414
notion,
15-
parent: {
15+
parentDataSource: {
1616
propDefinition: [
1717
notion,
18-
"databaseId",
18+
"dataSourceId",
1919
],
20-
label: "Parent Database ID",
21-
description: "Select a parent database or provide a database ID",
20+
label: "Parent Data Source ID",
21+
description: "Select a parent data source or provide a data source ID",
2222
},
2323
Name: {
2424
type: "string",
2525
label: "Name",
26-
description: "The name of the page. Use this only if the database has a `title` property named `Name`. Otherwise, use the `Properties` prop below to set the title property.",
26+
description: "The name of the page. Use this only if the data source has a `title` property named `Name`. Otherwise, use the `Properties` prop below to set the title property.",
2727
optional: true,
2828
},
2929
properties: {
3030
type: "object",
3131
label: "Properties",
32-
description: "The values of the page's properties. The schema must match the parent database's properties. [See the documentation](https://developers.notion.com/reference/property-object) for information on various property types. Example: `{ \"Tags\": [ \"tag1\" ], \"Link\": \"https://pipedream.com\" }`",
32+
description: "The values of the page's properties. The schema must match the parent data source's properties. [See the documentation](https://developers.notion.com/reference/property-object) for information on various property types. Example: `{ \"Tags\": [ \"tag1\" ], \"Link\": \"https://pipedream.com\" }`",
3333
optional: true,
3434
},
3535
icon: {
@@ -60,14 +60,14 @@ export default {
6060
methods: {
6161
...base.methods,
6262
/**
63-
* Builds a page from a parent database
64-
* @param parentDatabase - the parent database
63+
* Builds a page from a parent data source
64+
* @param parentDataSource - the parent data source
6565
* @returns the constructed page in Notion format
6666
*/
67-
buildPage(parentDatabase) {
68-
const meta = this.buildDatabaseMeta(parentDatabase);
67+
buildPage(parentDataSource) {
68+
const meta = this.buildDataSourceMeta(parentDataSource);
6969
this.properties = utils.parseObject(this.properties);
70-
const properties = this.buildPageProperties(parentDatabase.properties);
70+
const properties = this.buildPageProperties(parentDataSource.properties);
7171
const children = this.createBlocks(this.pageContent);
7272
return {
7373
...meta,
@@ -78,7 +78,7 @@ export default {
7878
},
7979
async run({ $ }) {
8080
const MAX_BLOCKS = 100;
81-
const parentPage = await this.notion.retrieveDatabase(this.parent);
81+
const parentPage = await this.notion.retrieveDataSource(this.parentDataSource);
8282
const {
8383
children, ...page
8484
} = this.buildPage(parentPage);

components/notion/actions/create-page/create-page.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
key: "notion-create-page",
88
name: "Create Page",
99
description: "Create a page from a parent page. [See the documentation](https://developers.notion.com/reference/post-page)",
10-
version: "0.2.20",
10+
version: "0.2.21",
1111
type: "action",
1212
props: {
1313
notion,

components/notion/actions/delete-block/delete-block.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "notion-delete-block",
77
name: "Delete Block",
88
description: "Sets a Block object, including page blocks, to archived: true using the ID specified. [See the documentation](https://developers.notion.com/reference/delete-a-block)",
9-
version: "0.0.2",
9+
version: "0.0.3",
1010
type: "action",
1111
props: {
1212
notion,

0 commit comments

Comments
 (0)