From 822de7f352f582a3e6418076a083457e3d5e5c69 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Wed, 3 Sep 2025 03:04:37 -0300 Subject: [PATCH 01/12] Initial database > dataSource conversion --- .../actions/common/base-page-builder.mjs | 34 +++++------ .../create-database/create-database.mjs | 8 ++- .../create-page-from-database.mjs | 23 +++++--- .../actions/query-database/query-database.mjs | 21 +++++-- components/notion/actions/search/search.mjs | 6 +- .../notion/common/notion-meta-properties.mjs | 8 +-- components/notion/notion.app.mjs | 58 ++++++++++++++----- pnpm-lock.yaml | 9 +-- 8 files changed, 107 insertions(+), 60 deletions(-) diff --git a/components/notion/actions/common/base-page-builder.mjs b/components/notion/actions/common/base-page-builder.mjs index 418d9ebd08c93..6c2c995b3ce2b 100644 --- a/components/notion/actions/common/base-page-builder.mjs +++ b/components/notion/actions/common/base-page-builder.mjs @@ -1,6 +1,6 @@ import { markdownToBlocks } from "@tryfabric/martian"; import { - NOTION_DATABASE_META, + NOTION_DATA_SOURCE_META, NOTION_PAGE_META, } from "../../common/notion-meta-properties.mjs"; import NOTION_META from "../../common/notion-meta-selection.mjs"; @@ -10,7 +10,7 @@ export default { methods: { /** * Creates additional props for page properties and the selected block children - * @param properties - The selected (database) properties from the page obtained from Notion + * @param properties - The selected (data source) properties from the page obtained from Notion * @param meta - The selected meta properties * @param blocks - The selected block children from the workflow UI * @returns additional props @@ -102,14 +102,14 @@ export default { return notionProperties; }, /** - * Builds page meta properties (parent, icon, cover, archived) from a parent database + * Builds page meta properties (parent, icon, cover, archived) from a parent data source * Uses the property label as its type to be able to select in notion-meta-properties.mjs * @param properties - list of Notion page properties inputted by the user * @returns the meta properties in Notion format inputted by the user */ - _buildNotionDatabaseMeta(properties = []) { + _buildNotionDataSourceMeta(properties = []) { properties.forEach((property) => property.type = property.label); - return this._convertPropertiesToNotion(properties, NOTION_DATABASE_META); + return this._convertPropertiesToNotion(properties, NOTION_DATA_SOURCE_META); }, /** * Builds page meta properties (parent, icon, cover, archived) from a parent page @@ -122,7 +122,7 @@ export default { return this._convertPropertiesToNotion(properties, NOTION_PAGE_META); }, /** - * Builds page properties from a parent database/page + * Builds page properties from a parent data source/page * @param properties - list of Notion page properties inputted by the user * @returns the properties in Notion format inputted by the user */ @@ -130,13 +130,13 @@ export default { return this._convertPropertiesToNotion(properties, NOTION_PAGE_PROPERTIES); }, /** - * Builds the page meta inputted by the user in Notion format from a parent database - * @param parentDatabase - the parent database that contains the meta properties + * Builds the page meta inputted by the user in Notion format from a parent data source + * @param parentDataSource - the parent data source that contains the meta properties * @returns the meta properties in Notion format */ - buildDatabaseMeta(parentDatabase) { - const filteredMeta = this._filterProps(parentDatabase); - return this._buildNotionDatabaseMeta(filteredMeta); + buildDataSourceMeta(parentDataSource) { + const filteredMeta = this._filterProps(parentDataSource); + return this._buildNotionDataSourceMeta(filteredMeta); }, /** * Builds the page meta inputted by the user in Notion format from a parent page @@ -210,13 +210,13 @@ export default { }, }; }, - childDatabaseToLink(block) { + childDataSourceToLink(block) { return { object: "block", type: "link_to_page", link_to_page: { - type: "database_id", - database_id: block.id, + type: "data_source_id", + data_source_id: block.id, }, }; }, @@ -236,9 +236,9 @@ export default { if (child.type === "child_page") { // convert child pages to links children[i] = this.childPageToLink(child); - } else if (child.type === "child_database") { - // convert child databases to links - children[i] = this.childDatabaseToLink(child); + } else if (child.type === "child_data_source") { + // convert child data sources to links + children[i] = this.childDataSourceToLink(child); } else { if (this.notValid(child, c)) { children[i] = undefined; diff --git a/components/notion/actions/create-database/create-database.mjs b/components/notion/actions/create-database/create-database.mjs index cec0be4d25774..8b46e52e8661b 100644 --- a/components/notion/actions/create-database/create-database.mjs +++ b/components/notion/actions/create-database/create-database.mjs @@ -6,8 +6,8 @@ export default { ...base, key: "notion-create-database", name: "Create Database", - description: "Create a database. [See the documentation](https://developers.notion.com/reference/create-a-database)", - version: "0.0.1", + description: "Create a database and its initial data source. [See the documentation](https://developers.notion.com/reference/database-create)", + version: "0.1.0", type: "action", props: { notion, @@ -45,7 +45,9 @@ export default { }, }, ], - properties: utils.parseObject(this.properties), + initial_data_source: { + properties: utils.parseObject(this.properties), + }, }); $.export("$summary", `Successfully created database with ID ${response.id}`); diff --git a/components/notion/actions/create-page-from-database/create-page-from-database.mjs b/components/notion/actions/create-page-from-database/create-page-from-database.mjs index b08e5c32bfe3f..c12b4af79556c 100644 --- a/components/notion/actions/create-page-from-database/create-page-from-database.mjs +++ b/components/notion/actions/create-page-from-database/create-page-from-database.mjs @@ -8,7 +8,7 @@ export default { key: "notion-create-page-from-database", name: "Create Page from Database", description: "Create a page from a database. [See the documentation](https://developers.notion.com/reference/post-page)", - version: "0.2.3", + version: "1.0.0", type: "action", props: { notion, @@ -20,6 +20,15 @@ export default { label: "Parent Database ID", description: "Select a parent database or provide a database ID", }, + dataSource: { + propDefinition: [ + notion, + "dataSourceId", + ({ parent }) => ({ + databaseId: parent, + }), + ], + }, Name: { type: "string", label: "Name", @@ -60,14 +69,14 @@ export default { methods: { ...base.methods, /** - * Builds a page from a parent database - * @param parentDatabase - the parent database + * Builds a page from a parent data source + * @param parentDataSource - the parent data source * @returns the constructed page in Notion format */ - buildPage(parentDatabase) { - const meta = this.buildDatabaseMeta(parentDatabase); + buildPage(parentDataSource) { + const meta = this.buildDataSourceMeta(parentDataSource); this.properties = utils.parseObject(this.properties); - const properties = this.buildPageProperties(parentDatabase.properties); + const properties = this.buildPageProperties(parentDataSource.properties); const children = this.createBlocks(this.pageContent); return { ...meta, @@ -78,7 +87,7 @@ export default { }, async run({ $ }) { const MAX_BLOCKS = 100; - const parentPage = await this.notion.retrieveDatabase(this.parent); + const parentPage = await this.notion.retrieveDataSource(this.dataSource); const { children, ...page } = this.buildPage(parentPage); diff --git a/components/notion/actions/query-database/query-database.mjs b/components/notion/actions/query-database/query-database.mjs index a5b977b740f1b..f09f6905d9497 100644 --- a/components/notion/actions/query-database/query-database.mjs +++ b/components/notion/actions/query-database/query-database.mjs @@ -3,9 +3,9 @@ import notion from "../../notion.app.mjs"; export default { key: "notion-query-database", - name: "Query Database", - description: "Query a database with a specified filter. [See the documentation](https://developers.notion.com/reference/post-database-query)", - version: "0.1.0", + name: "Query Data Source", + description: "Query a data source with a specified filter. [See the documentation](https://developers.notion.com/reference/query-a-data-source)", + version: "1.0.0", type: "action", props: { notion, @@ -15,14 +15,23 @@ export default { "databaseId", ], }, + dataSourceId: { + propDefinition: [ + notion, + "dataSourceId", + ({ databaseId }) => ({ + databaseId, + }), + ], + }, filter: { label: "Filter (query)", - description: "The filter to apply, as a JSON-stringified object. [See the documentation for available filters](https://developers.notion.com/reference/post-database-query-filter). Example: `{ \"property\": \"Name\", \"title\": { \"contains\": \"title to search for\" } }`", + description: "The filter to apply, as a JSON-stringified object. [See the documentation for available filters](https://developers.notion.com/reference/filter-data-source-entries). Example: `{ \"property\": \"Name\", \"title\": { \"contains\": \"title to search for\" } }`", type: "string", }, sorts: { label: "Sorts", - description: "The sort order for the query. [See the documentation for available sorts](https://developers.notion.com/reference/post-database-query-sort). Example: `[ { \"property\": \"Name\", \"direction\": \"ascending\" } ]`", + description: "The sort order for the query. [See the documentation for available sorts](https://developers.notion.com/reference/sort-data-source-entries). Example: `[ { \"property\": \"Name\", \"direction\": \"ascending\" } ]`", type: "string[]", }, }, @@ -31,7 +40,7 @@ export default { filter, sorts, } = this; - const response = await this.notion.queryDatabase(this.databaseId, { + const response = await this.notion.queryDataSource(this.dataSourceId, { filter: utils.parseStringToJSON(filter), sorts: utils.parseObject(sorts), }); diff --git a/components/notion/actions/search/search.mjs b/components/notion/actions/search/search.mjs index f1a02f940c942..384617ac6f7ed 100644 --- a/components/notion/actions/search/search.mjs +++ b/components/notion/actions/search/search.mjs @@ -3,9 +3,9 @@ import common from "../common/base-search.mjs"; export default { ...common, key: "notion-search", - name: "Find Pages or Databases", - description: "Searches for a page or database. [See the documentation](https://developers.notion.com/reference/post-search)", - version: "0.0.9", + name: "Find Pages or Data Sources", + description: "Searches for a page or data source. [See the documentation](https://developers.notion.com/reference/post-search)", + version: "0.1.0", type: "action", props: { ...common.props, diff --git a/components/notion/common/notion-meta-properties.mjs b/components/notion/common/notion-meta-properties.mjs index 0486ded9eb6d7..f426a3b1c4ea7 100644 --- a/components/notion/common/notion-meta-properties.mjs +++ b/components/notion/common/notion-meta-properties.mjs @@ -5,10 +5,10 @@ import utils from "./utils.mjs"; * * convertToNotion: converts the prop values to send to the Notion API */ -export const NOTION_DATABASE_META = { +export const NOTION_DATA_SOURCE_META = { parent: { convertToNotion: (property) => ({ - type: "database_id", + type: "data_source_id", database_id: property.value, }), }, @@ -42,7 +42,7 @@ export const NOTION_DATABASE_META = { * Implementation for Page Meta in Notion - https://developers.notion.com/reference/page */ export const NOTION_PAGE_META = { - ...NOTION_DATABASE_META, + ...NOTION_DATA_SOURCE_META, parent: { convertToNotion: (property) => ({ type: "page_id", @@ -52,6 +52,6 @@ export const NOTION_PAGE_META = { }; export default { - NOTION_DATABASE_META, + NOTION_DATA_SOURCE_META, NOTION_PAGE_META, }; diff --git a/components/notion/notion.app.mjs b/components/notion/notion.app.mjs index b831c907d8299..582204198682e 100644 --- a/components/notion/notion.app.mjs +++ b/components/notion/notion.app.mjs @@ -19,6 +19,19 @@ export default { return this._buildPaginatedOptions(options, response.next_cursor); }, }, + dataSourceId: { + type: "string", + label: "Data Source ID", + description: "Select a data source from the database or provide a data source ID", + async options({ databaseId }) { + this._checkOptionsContext(databaseId, "Database ID"); + const dataSources = await this.getDataSourcesForDatabase(databaseId); + return dataSources?.map((dataSource) => ({ + label: dataSource.name, + value: dataSource.id, + })) || []; + }, + }, pageId: { type: "string", label: "Page ID", @@ -41,13 +54,13 @@ export default { pageIdInDatabase: { type: "string", label: "Page ID", - description: "Search for a page from the database or provide a page ID", + description: "Search for a page from the data source or provide a page ID", useQuery: true, async options({ - query, prevContext, databaseId, + query, prevContext, dataSourceId, }) { - this._checkOptionsContext(databaseId, "Database ID"); - const response = await this.queryDatabase(databaseId, { + this._checkOptionsContext(dataSourceId, "Data Source ID"); + const response = await this.queryDataSource(dataSourceId, { query, start_cursor: prevContext.nextPageParameters ?? undefined, }); @@ -65,8 +78,8 @@ export default { const parentType = response.parent.type; try { - const { properties } = parentType === "database_id" - ? await this.retrieveDatabase(response.parent.database_id) + const { properties } = parentType === "data_source_id" + ? await this.retrieveDataSource(response.parent.data_source_id).properties : response; const propEntries = Object.entries(properties); @@ -195,12 +208,12 @@ export default { }, filter: { type: "string", - label: "Page or Database", - description: "Whether to search for pages or databases", + label: "Page or Data Source", + description: "Whether to search for pages or data sources.", optional: true, options: [ "page", - "database", + "data_source", ], }, pageContent: { @@ -219,7 +232,7 @@ export default { _getNotionClient() { return new notion.Client({ auth: this.$auth.oauth_access_token, - notionVersion: "2022-02-22", + notionVersion: "2025-09-03", }); }, _extractDatabaseTitleOptions(databases) { @@ -292,6 +305,23 @@ export default { async updateDatabase(database) { return this._getNotionClient().databases.update(database); }, + async queryDataSource(dataSourceId, params = {}) { + return this._getNotionClient().request({ + method: "POST", + path: `data_sources/${dataSourceId}/query`, + body: params, + }); + }, + async retrieveDataSource(dataSourceId) { + return this._getNotionClient().request({ + method: "GET", + path: `data_sources/${dataSourceId}`, + }); + }, + async getDataSourcesForDatabase(databaseId) { + const database = await this.retrieveDatabase(databaseId); + return database.data_sources || []; + }, async createFileUpload(file) { return this._getNotionClient().fileUploads.create(file); }, @@ -342,14 +372,14 @@ export default { }); }, /** - * This generator function scans the pages in a database yields each page + * This generator function scans the pages in a data source and yields each page * separately. * - * @param {string} databaseId - The database containing the pages to scan + * @param {string} dataSourceId - The data source containing the pages to scan * @param {object} [opts] - Options to customize the operation * @yield {object} The next page */ - async *getPages(databaseId, opts = {}) { + async *getPages(dataSourceId, opts = {}) { let cursor; do { @@ -357,7 +387,7 @@ export default { ...opts, start_cursor: cursor, }; - const response = await this.queryDatabase(databaseId, params); + const response = await this.queryDataSource(dataSourceId, params); const { results: pages, next_cursor: nextCursor, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8b48a599f2360..8ae7608403cf3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2044,8 +2044,7 @@ importers: specifier: ^3.0.0 version: 3.0.3 - components/buddee: - specifiers: {} + components/buddee: {} components/buddy: {} @@ -11010,8 +11009,7 @@ importers: components/postmaster: {} - components/postnl: - specifiers: {} + components/postnl: {} components/power_automate: {} @@ -11389,8 +11387,7 @@ importers: specifier: ^1.2.1 version: 1.6.6 - components/questdb: - specifiers: {} + components/questdb: {} components/questionpro: {} From 66ef1645e6c4b080bb96d8f44e1753de804dbeec Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Fri, 5 Sep 2025 19:04:46 -0300 Subject: [PATCH 02/12] More data source updates --- .../retrieve-database-content.mjs | 19 +++++++++++---- components/notion/notion.app.mjs | 2 +- .../page-properties-updated-instant.mjs | 17 ++++++++++---- .../sources/updated-page/updated-page.mjs | 23 +++++++++++++------ 4 files changed, 44 insertions(+), 17 deletions(-) diff --git a/components/notion/actions/retrieve-database-content/retrieve-database-content.mjs b/components/notion/actions/retrieve-database-content/retrieve-database-content.mjs index 0313e481dda99..f34b61ebcf45c 100644 --- a/components/notion/actions/retrieve-database-content/retrieve-database-content.mjs +++ b/components/notion/actions/retrieve-database-content/retrieve-database-content.mjs @@ -2,9 +2,9 @@ import notion from "../../notion.app.mjs"; export default { key: "notion-retrieve-database-content", - name: "Retrieve Database Content", - description: "Get all content of a database. [See the documentation](https://developers.notion.com/reference/post-database-query)", - version: "0.0.9", + name: "Retrieve Data Source Content", + description: "Get all content of a data source. [See the documentation](https://developers.notion.com/reference/query-a-data-source)", + version: "1.0.0", type: "action", props: { notion, @@ -14,12 +14,21 @@ export default { "databaseId", ], }, + dataSourceId: { + propDefinition: [ + notion, + "dataSourceId", + ({ databaseId }) => ({ + databaseId, + }), + ], + }, }, async run({ $ }) { - const { results } = await this.notion.queryDatabase(this.databaseId); + const { results } = await this.notion.queryDataSource(this.dataSourceId); $.export("$summary", `Successfully retrieved ${results.length} object${results.length === 1 ? "" - : "s"} in database`); + : "s"} in data source`); return results; }, }; diff --git a/components/notion/notion.app.mjs b/components/notion/notion.app.mjs index 582204198682e..8a01992c4d223 100644 --- a/components/notion/notion.app.mjs +++ b/components/notion/notion.app.mjs @@ -79,7 +79,7 @@ export default { const parentType = response.parent.type; try { const { properties } = parentType === "data_source_id" - ? await this.retrieveDataSource(response.parent.data_source_id).properties + ? await this.retrieveDataSource(response.parent.data_source_id) : response; const propEntries = Object.entries(properties); diff --git a/components/notion/sources/page-properties-updated-instant/page-properties-updated-instant.mjs b/components/notion/sources/page-properties-updated-instant/page-properties-updated-instant.mjs index 76e74bcd725bb..e9de27c47c1cd 100644 --- a/components/notion/sources/page-properties-updated-instant/page-properties-updated-instant.mjs +++ b/components/notion/sources/page-properties-updated-instant/page-properties-updated-instant.mjs @@ -5,7 +5,7 @@ export default { ...common, key: "notion-page-properties-updated-instant", name: "Page Properties Updated (Instant)", - description: "Emit new event each time a page property is updated in a database. For use with Page Properties Updated event type. Webhook must be set up in Notion. [See the documentation](https://developers.notion.com/reference/webhooks#step-1-creating-a-webhook-subscription)", + description: "Emit new event each time a page property is updated in a data source. For use with Page Properties Updated event type. Webhook must be set up in Notion. [See the documentation](https://developers.notion.com/reference/webhooks#step-1-creating-a-webhook-subscription)", version: "0.0.2", type: "source", dedupe: "unique", @@ -17,6 +17,15 @@ export default { "databaseId", ], }, + dataSourceId: { + propDefinition: [ + common.props.notion, + "dataSourceId", + ({ databaseId }) => ({ + databaseId, + }), + ], + }, properties: { type: "string[]", label: "Properties", @@ -24,7 +33,7 @@ export default { optional: true, async options() { try { - const { properties } = await this.notion.retrieveDatabase(this.databaseId); + const { properties } = await this.notion.retrieveDataSource(this.dataSourceId); const propEntries = Object.entries(properties); return propEntries.map((prop) => ({ label: prop[1].name, @@ -55,8 +64,8 @@ export default { return; } - if (event.data.parent.id !== this.databaseId) { - console.log(`Skipping event for database: ${event.data.parent.id}`); + if (event.data.parent.id !== this.dataSourceId) { + console.log(`Skipping event for data source: ${event.data.parent.id}`); return; } diff --git a/components/notion/sources/updated-page/updated-page.mjs b/components/notion/sources/updated-page/updated-page.mjs index 7ba099dce3a4e..8f76f0b46990e 100644 --- a/components/notion/sources/updated-page/updated-page.mjs +++ b/components/notion/sources/updated-page/updated-page.mjs @@ -7,8 +7,8 @@ import sampleEmit from "./test-event.mjs"; export default { ...base, key: "notion-updated-page", - name: "New or Updated Page in Database (By Property)", - description: "Emit new event when a page is created or updated in the selected database. [See the documentation](https://developers.notion.com/reference/page)", + name: "New or Updated Page in Data Source (By Property)", + description: "Emit new event when a page is created or updated in the selected data source. [See the documentation](https://developers.notion.com/reference/page)", version: "0.1.12", type: "source", dedupe: "unique", @@ -20,6 +20,15 @@ export default { "databaseId", ], }, + dataSourceId: { + propDefinition: [ + notion, + "dataSourceId", + ({ databaseId }) => ({ + databaseId, + }), + ], + }, includeNewPages: { type: "boolean", label: "Include New Pages", @@ -31,8 +40,8 @@ export default { notion, "propertyTypes", (c) => ({ - parentId: c.databaseId, - parentType: "database", + parentId: c.dataSourceId, + parentType: "data_source", }), ], description: "Only emit events when one or more of the selected properties have changed", @@ -51,7 +60,7 @@ export default { const propertyValues = {}; const propertiesToCheck = await this._getPropertiesToCheck(); const params = this.lastUpdatedSortParam(); - const pagesStream = this.notion.getPages(this.databaseId, params); + const pagesStream = this.notion.getPages(this.dataSourceId, params); for await (const page of pagesStream) { for (const propertyName of propertiesToCheck) { const currentValue = this._maybeRemoveFileSubItems(page.properties[propertyName]); @@ -91,7 +100,7 @@ export default { if (this.properties?.length) { return this.properties; } - const { properties } = await this.notion.retrieveDatabase(this.databaseId); + const { properties } = await this.notion.retrieveDataSource(this.dataSourceId); return Object.keys(properties); }, _maybeRemoveFileSubItems(property) { @@ -150,7 +159,7 @@ export default { }; let newLastUpdatedTimestamp = lastCheckedTimestamp; const propertiesToCheck = await this._getPropertiesToCheck(); - const pagesStream = this.notion.getPages(this.databaseId, params); + const pagesStream = this.notion.getPages(this.dataSourceId, params); for await (const page of pagesStream) { const changes = []; From 85cb57f8f39fe4859cc5c305052b103a347c542c Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Mon, 8 Sep 2025 13:07:16 -0300 Subject: [PATCH 03/12] "Update Page" updates --- .../actions/update-page/update-page.mjs | 25 +++++++++++++------ components/notion/notion.app.mjs | 2 +- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/components/notion/actions/update-page/update-page.mjs b/components/notion/actions/update-page/update-page.mjs index 7ea9dc753f8e8..4e64d2be4648f 100644 --- a/components/notion/actions/update-page/update-page.mjs +++ b/components/notion/actions/update-page/update-page.mjs @@ -16,21 +16,30 @@ export default { alertType: "info", content: "Properties that are not set will remain unchanged.", }, - parent: { + databaseId: { propDefinition: [ notion, "databaseId", ], - label: "Parent Database ID", - description: "Select the database that contains the page to update. If you instead provide a database ID in a custom expression, you will also have to provide the page's ID in a custom expression", + }, + parent: { + propDefinition: [ + notion, + "dataSourceId", + (c) => ({ + databaseId: c.databaseId, + }), + ], + label: "Parent Data Source ID", + description: "Select the data source that contains the page to update. If you instead provide a data source ID in a custom expression, you will also have to provide the page's ID in a custom expression", reloadProps: true, }, pageId: { propDefinition: [ notion, - "pageIdInDatabase", + "pageIdInDataSource", (c) => ({ - databaseId: c.parent, + dataSourceId: c.parent, }), ], }, @@ -52,7 +61,7 @@ export default { "propertyTypes", (c) => ({ parentId: c.parent, - parentType: "database", + parentType: "dataSource", }), ], reloadProps: true, @@ -60,7 +69,7 @@ export default { }, async additionalProps() { try { - const { properties } = await this.notion.retrieveDatabase(this.parent); + const { properties } = await this.notion.retrieveDataSource(this.parent); const selectedProperties = pick(properties, this.propertyTypes); return this.buildAdditionalProps({ @@ -85,7 +94,7 @@ export default { * @returns the constructed page in Notion format */ buildPage(page) { - const meta = this.buildDatabaseMeta(page); + const meta = this.buildDataSourceMeta(page); const properties = this.buildPageProperties(page.properties); return { ...meta, diff --git a/components/notion/notion.app.mjs b/components/notion/notion.app.mjs index 8a01992c4d223..da9d5a0579466 100644 --- a/components/notion/notion.app.mjs +++ b/components/notion/notion.app.mjs @@ -51,7 +51,7 @@ export default { return this._buildPaginatedOptions(options, response.next_cursor); }, }, - pageIdInDatabase: { + pageIdInDataSource: { type: "string", label: "Page ID", description: "Search for a page from the data source or provide a page ID", From fe0fcba3ba8db6631bdc77bdcce7608ae57a3097 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Mon, 8 Sep 2025 14:52:38 -0300 Subject: [PATCH 04/12] Other data source updates --- .../create-page-from-database.mjs | 12 +++--- .../retrieve-database-schema.mjs | 19 +++++++--- .../update-database/update-database.mjs | 37 ++++++++++++------- .../actions/update-page/update-page.mjs | 14 +++---- .../notion/common/notion-meta-properties.mjs | 3 +- components/notion/notion.app.mjs | 7 +--- components/notion/sources/common/base.mjs | 2 +- .../notion/sources/common/constants.mjs | 2 + .../notion/sources/new-page/new-page.mjs | 15 ++++++-- .../page-properties-updated-instant.mjs | 2 +- .../updated-page-by-timestamp.mjs | 17 +++++++-- 11 files changed, 83 insertions(+), 47 deletions(-) diff --git a/components/notion/actions/create-page-from-database/create-page-from-database.mjs b/components/notion/actions/create-page-from-database/create-page-from-database.mjs index c12b4af79556c..1330d03362007 100644 --- a/components/notion/actions/create-page-from-database/create-page-from-database.mjs +++ b/components/notion/actions/create-page-from-database/create-page-from-database.mjs @@ -17,10 +17,8 @@ export default { notion, "databaseId", ], - label: "Parent Database ID", - description: "Select a parent database or provide a database ID", }, - dataSource: { + parentDataSource: { propDefinition: [ notion, "dataSourceId", @@ -28,17 +26,19 @@ export default { databaseId: parent, }), ], + label: "Parent Data Source ID", + description: "Select a parent data source or provide a data source ID", }, Name: { type: "string", label: "Name", - 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.", + 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.", optional: true, }, properties: { type: "object", label: "Properties", - 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\" }`", + 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\" }`", optional: true, }, icon: { @@ -87,7 +87,7 @@ export default { }, async run({ $ }) { const MAX_BLOCKS = 100; - const parentPage = await this.notion.retrieveDataSource(this.dataSource); + const parentPage = await this.notion.retrieveDataSource(this.parentDataSource); const { children, ...page } = this.buildPage(parentPage); diff --git a/components/notion/actions/retrieve-database-schema/retrieve-database-schema.mjs b/components/notion/actions/retrieve-database-schema/retrieve-database-schema.mjs index 8d7e21379956d..42f2b4d59328e 100644 --- a/components/notion/actions/retrieve-database-schema/retrieve-database-schema.mjs +++ b/components/notion/actions/retrieve-database-schema/retrieve-database-schema.mjs @@ -2,9 +2,9 @@ import notion from "../../notion.app.mjs"; export default { key: "notion-retrieve-database-schema", - name: "Retrieve Database Schema", - description: "Get the property schema of a database in Notion. [See the documentation](https://developers.notion.com/reference/retrieve-a-database)", - version: "0.0.11", + name: "Retrieve Data Source Schema", + description: "Get the property schema of a data source in Notion. [See the documentation](https://developers.notion.com/reference/retrieve-a-data-source)", + version: "1.0.0", type: "action", props: { notion, @@ -14,10 +14,19 @@ export default { "databaseId", ], }, + dataSourceId: { + propDefinition: [ + notion, + "dataSourceId", + ({ databaseId }) => ({ + databaseId, + }), + ], + }, }, async run({ $ }) { - const response = await this.notion.retrieveDatabase(this.databaseId); - $.export("$summary", "Successfully retrieved database schema"); + const response = await this.notion.retrieveDataSource(this.dataSourceId); + $.export("$summary", "Successfully retrieved data source schema"); return response; }, }; diff --git a/components/notion/actions/update-database/update-database.mjs b/components/notion/actions/update-database/update-database.mjs index a90ce9a0dd3f5..2b21f498099bc 100644 --- a/components/notion/actions/update-database/update-database.mjs +++ b/components/notion/actions/update-database/update-database.mjs @@ -5,9 +5,9 @@ import base from "../common/base-page-builder.mjs"; export default { ...base, key: "notion-update-database", - name: "Update Database", - description: "Update a database. [See the documentation](https://developers.notion.com/reference/update-a-database)", - version: "0.0.2", + name: "Update Data Source", + description: "Update a data source. [See the documentation](https://developers.notion.com/reference/update-a-data-source)", + version: "1.0.0", type: "action", props: { notion, @@ -16,34 +16,43 @@ export default { notion, "databaseId", ], + }, + dataSourceId: { + propDefinition: [ + notion, + "dataSourceId", + ({ databaseId }) => ({ + databaseId, + }), + ], reloadProps: true, }, title: { type: "string", label: "Title", - description: "Title of database as it appears in Notion. An array of [rich text objects](https://developers.notion.com/reference/rich-text).", + description: "Title of the data source as it appears in Notion. An array of [rich text objects](https://developers.notion.com/reference/rich-text).", optional: true, }, description: { type: "string", label: "Description", - description: "An array of [rich text objects](https://developers.notion.com/reference/rich-text) that represents the description of the database that is displayed in the Notion UI. If omitted, then the database description remains unchanged.", + description: "An array of [rich text objects](https://developers.notion.com/reference/rich-text) that represents the description of the data source that is displayed in the Notion UI. If omitted, then the data source description remains unchanged.", optional: true, }, properties: { type: "object", label: "Properties", - description: "The properties of a database to be changed in the request, in the form of a JSON object. If updating an existing property, then the keys are the names or IDs of the properties as they appear in Notion, and the values are [property schema objects](https://developers.notion.com/reference/rich-text). If adding a new property, then the key is the name of the new database property and the value is a [property schema object](https://developers.notion.com/reference/property-schema-object).", + description: "The properties of a data source to be changed in the request, in the form of a JSON object. If updating an existing property, then the keys are the names or IDs of the properties as they appear in Notion, and the values are [property schema objects](https://developers.notion.com/reference/rich-text). If adding a new property, then the key is the name of the new data source property and the value is a [property schema object](https://developers.notion.com/reference/property-schema-object).", optional: true, }, }, async additionalProps(props) { - if (this.databaseId) { - const database = await this.notion.retrieveDatabase(this.databaseId); + if (this.databaseId && this.dataSourceId) { + const dataSource = await this.notion.retrieveDataSource(this.dataSourceId); - props.title.default = database.title.map((text) => text.text.content).join(" "); - props.description.default = database.description.map((text) => text.plain_text).join(" "); - props.properties.default = Object.entries(database.properties).reduce((acc, [ + props.title.default = dataSource.title.map((text) => text.text.content).join(" "); + props.description.default = dataSource.description.map((text) => text.plain_text).join(" "); + props.properties.default = Object.entries(dataSource.properties).reduce((acc, [ key, value, ]) => { @@ -54,8 +63,8 @@ export default { } }, async run({ $ }) { - const response = await this.notion.updateDatabase({ - database_id: this.databaseId, + const response = await this.notion.updateDataSource({ + dataSource_id: this.dataSourceId, title: [ { text: { @@ -73,7 +82,7 @@ export default { properties: utils.parseObject(this.properties), }); - $.export("$summary", `Successfully updated database with ID ${response.id}`); + $.export("$summary", `Successfully updated data source with ID ${response.id}`); return response; }, }; diff --git a/components/notion/actions/update-page/update-page.mjs b/components/notion/actions/update-page/update-page.mjs index 4e64d2be4648f..f6534a07e379c 100644 --- a/components/notion/actions/update-page/update-page.mjs +++ b/components/notion/actions/update-page/update-page.mjs @@ -7,7 +7,7 @@ export default { key: "notion-update-page", name: "Update Page", description: "Update a page's property values. To append page content, use the *Append Block* action instead. [See the documentation](https://developers.notion.com/reference/patch-page)", - version: "1.1.10", + version: "2.0.0", type: "action", props: { notion, @@ -16,18 +16,18 @@ export default { alertType: "info", content: "Properties that are not set will remain unchanged.", }, - databaseId: { + parent: { propDefinition: [ notion, "databaseId", ], }, - parent: { + parentDataSource: { propDefinition: [ notion, "dataSourceId", (c) => ({ - databaseId: c.databaseId, + databaseId: c.parent, }), ], label: "Parent Data Source ID", @@ -39,7 +39,7 @@ export default { notion, "pageIdInDataSource", (c) => ({ - dataSourceId: c.parent, + dataSourceId: c.parentDataSource, }), ], }, @@ -60,7 +60,7 @@ export default { notion, "propertyTypes", (c) => ({ - parentId: c.parent, + parentId: c.parentDataSource, parentType: "dataSource", }), ], @@ -69,7 +69,7 @@ export default { }, async additionalProps() { try { - const { properties } = await this.notion.retrieveDataSource(this.parent); + const { properties } = await this.notion.retrieveDataSource(this.parentDataSource); const selectedProperties = pick(properties, this.propertyTypes); return this.buildAdditionalProps({ diff --git a/components/notion/common/notion-meta-properties.mjs b/components/notion/common/notion-meta-properties.mjs index f426a3b1c4ea7..b0e2dfab572af 100644 --- a/components/notion/common/notion-meta-properties.mjs +++ b/components/notion/common/notion-meta-properties.mjs @@ -2,6 +2,7 @@ import utils from "./utils.mjs"; /** * Implementation for Database Meta in Notion - https://developers.notion.com/reference/database + * See also Data Sources - https://developers.notion.com/reference/data-source * * convertToNotion: converts the prop values to send to the Notion API */ @@ -9,7 +10,7 @@ export const NOTION_DATA_SOURCE_META = { parent: { convertToNotion: (property) => ({ type: "data_source_id", - database_id: property.value, + data_source_id: property.value, }), }, title: { diff --git a/components/notion/notion.app.mjs b/components/notion/notion.app.mjs index da9d5a0579466..8befdb75cd924 100644 --- a/components/notion/notion.app.mjs +++ b/components/notion/notion.app.mjs @@ -25,11 +25,8 @@ export default { description: "Select a data source from the database or provide a data source ID", async options({ databaseId }) { this._checkOptionsContext(databaseId, "Database ID"); - const dataSources = await this.getDataSourcesForDatabase(databaseId); - return dataSources?.map((dataSource) => ({ - label: dataSource.name, - value: dataSource.id, - })) || []; + const response = await this.getDataSourcesForDatabase(databaseId); + return this._extractDatabaseTitleOptions(response); }, }, pageId: { diff --git a/components/notion/sources/common/base.mjs b/components/notion/sources/common/base.mjs index b2340a2a4dd4e..d5b1959e6cc7a 100644 --- a/components/notion/sources/common/base.mjs +++ b/components/notion/sources/common/base.mjs @@ -34,7 +34,7 @@ export default { } = obj; const ts = Date.parse(lastTime); - if (type === constants.types.DATABASE) { + if (type === constants.types.DATABASE || type === constants.types.DATA_SOURCE) { title = this.notion.extractDatabaseTitle(obj); } else { title = this.notion.extractPageTitle(obj); diff --git a/components/notion/sources/common/constants.mjs b/components/notion/sources/common/constants.mjs index ab8e54972dc46..782084ee5e0f3 100644 --- a/components/notion/sources/common/constants.mjs +++ b/components/notion/sources/common/constants.mjs @@ -1,10 +1,12 @@ const types = { DATABASE: "database", + DATA_SOURCE: "data_source", PAGE: "page", }; const summaries = { DATABASE_ADDED: "Database added", + DATA_SOURCE_ADDED: "Data source added", PAGE_ADDED: "Page added", PAGE_UPDATED: "Page updated", }; diff --git a/components/notion/sources/new-page/new-page.mjs b/components/notion/sources/new-page/new-page.mjs index 6fe16c1eae166..3a9902383b9aa 100644 --- a/components/notion/sources/new-page/new-page.mjs +++ b/components/notion/sources/new-page/new-page.mjs @@ -6,8 +6,8 @@ import sampleEmit from "./test-event.mjs"; export default { ...base, key: "notion-new-page", - name: "New Page in Database", - description: "Emit new event when a page is created in the selected database. [See the documentation](https://developers.notion.com/reference/page)", + name: "New Page in Data Source", + description: "Emit new event when a page is created in the selected data source. [See the documentation](https://developers.notion.com/reference/page)", version: "0.0.16", type: "source", props: { @@ -18,6 +18,15 @@ export default { "databaseId", ], }, + dataSourceId: { + propDefinition: [ + notion, + "dataSourceId", + ({ databaseId }) => ({ + databaseId, + }), + ], + }, }, hooks: { ...base.hooks, @@ -46,7 +55,7 @@ export default { // Get pages in created order descending until the first page edited after // lastCreatedTimestamp, then reverse list of pages and emit - const pagesStream = this.notion.getPages(this.databaseId, params); + const pagesStream = this.notion.getPages(this.dataSourceId, params); for await (const page of pagesStream) { if (!this.isResultNew(page.created_time, lastCreatedTimestamp) diff --git a/components/notion/sources/page-properties-updated-instant/page-properties-updated-instant.mjs b/components/notion/sources/page-properties-updated-instant/page-properties-updated-instant.mjs index e9de27c47c1cd..b9652d93c1c93 100644 --- a/components/notion/sources/page-properties-updated-instant/page-properties-updated-instant.mjs +++ b/components/notion/sources/page-properties-updated-instant/page-properties-updated-instant.mjs @@ -6,7 +6,7 @@ export default { key: "notion-page-properties-updated-instant", name: "Page Properties Updated (Instant)", description: "Emit new event each time a page property is updated in a data source. For use with Page Properties Updated event type. Webhook must be set up in Notion. [See the documentation](https://developers.notion.com/reference/webhooks#step-1-creating-a-webhook-subscription)", - version: "0.0.2", + version: "1.0.0", type: "source", dedupe: "unique", props: { diff --git a/components/notion/sources/updated-page-by-timestamp/updated-page-by-timestamp.mjs b/components/notion/sources/updated-page-by-timestamp/updated-page-by-timestamp.mjs index cc38568e7ccf8..4587a869f6624 100644 --- a/components/notion/sources/updated-page-by-timestamp/updated-page-by-timestamp.mjs +++ b/components/notion/sources/updated-page-by-timestamp/updated-page-by-timestamp.mjs @@ -6,9 +6,9 @@ import sampleEmit from "./test-event.mjs"; export default { ...base, key: "notion-updated-page-by-timestamp", - name: "New or Updated Page in Database (By Timestamp)", - description: "Emit new event when a page is created or updated in the selected database. [See the documentation](https://developers.notion.com/reference/page)", - version: "0.0.4", + name: "New or Updated Page in Data Source (By Timestamp)", + description: "Emit new event when a page is created or updated in the selected data source. [See the documentation](https://developers.notion.com/reference/page)", + version: "1.0.0", type: "source", dedupe: "unique", props: { @@ -19,6 +19,15 @@ export default { "databaseId", ], }, + dataSourceId: { + propDefinition: [ + notion, + "dataSourceId", + ({ databaseId }) => ({ + databaseId, + }), + ], + }, includeNewPages: { type: "boolean", label: "Include New Pages", @@ -59,7 +68,7 @@ export default { }, }; - const pagesStream = this.notion.getPages(this.databaseId, params); + const pagesStream = this.notion.getPages(this.dataSourceId, params); for await (const page of pagesStream) { if (lastUpdatedTimestamp > Date.parse(page.last_edited_time)) { From 4abd414dfd5a1a771f75f6dae655bb4b621c9188 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Mon, 8 Sep 2025 18:59:59 -0300 Subject: [PATCH 05/12] Lots of other data source updates --- .../create-page-from-database.mjs | 13 +--- .../actions/query-database/query-database.mjs | 11 +--- .../retrieve-database-content.mjs | 9 --- .../retrieve-database-schema.mjs | 9 --- .../update-database/update-database.mjs | 13 +--- .../actions/update-page/update-page.mjs | 11 +--- components/notion/notion.app.mjs | 62 ++++++------------- components/notion/package.json | 4 +- components/notion/sources/common/base.mjs | 2 +- .../new-data-source/new-data-source.mjs | 55 ++++++++++++++++ .../test-event.mjs | 0 .../sources/new-database/new-database.mjs | 55 ---------------- .../notion/sources/new-page/new-page.mjs | 9 --- .../page-properties-updated-instant.mjs | 9 --- .../updated-page-by-timestamp.mjs | 9 --- .../sources/updated-page/updated-page.mjs | 9 --- pnpm-lock.yaml | 10 ++- 17 files changed, 90 insertions(+), 200 deletions(-) create mode 100644 components/notion/sources/new-data-source/new-data-source.mjs rename components/notion/sources/{new-database => new-data-source}/test-event.mjs (100%) delete mode 100644 components/notion/sources/new-database/new-database.mjs diff --git a/components/notion/actions/create-page-from-database/create-page-from-database.mjs b/components/notion/actions/create-page-from-database/create-page-from-database.mjs index 1330d03362007..31990728a340d 100644 --- a/components/notion/actions/create-page-from-database/create-page-from-database.mjs +++ b/components/notion/actions/create-page-from-database/create-page-from-database.mjs @@ -6,25 +6,16 @@ import base from "../common/base-page-builder.mjs"; export default { ...base, key: "notion-create-page-from-database", - name: "Create Page from Database", - description: "Create a page from a database. [See the documentation](https://developers.notion.com/reference/post-page)", + name: "Create Page from Data Source", + description: "Create a page from a data source. [See the documentation](https://developers.notion.com/reference/post-page)", version: "1.0.0", type: "action", props: { notion, - parent: { - propDefinition: [ - notion, - "databaseId", - ], - }, parentDataSource: { propDefinition: [ notion, "dataSourceId", - ({ parent }) => ({ - databaseId: parent, - }), ], label: "Parent Data Source ID", description: "Select a parent data source or provide a data source ID", diff --git a/components/notion/actions/query-database/query-database.mjs b/components/notion/actions/query-database/query-database.mjs index f09f6905d9497..f4fa4364719ba 100644 --- a/components/notion/actions/query-database/query-database.mjs +++ b/components/notion/actions/query-database/query-database.mjs @@ -5,23 +5,14 @@ export default { key: "notion-query-database", name: "Query Data Source", description: "Query a data source with a specified filter. [See the documentation](https://developers.notion.com/reference/query-a-data-source)", - version: "1.0.0", + version: "1.0.{{ts}}", type: "action", props: { notion, - databaseId: { - propDefinition: [ - notion, - "databaseId", - ], - }, dataSourceId: { propDefinition: [ notion, "dataSourceId", - ({ databaseId }) => ({ - databaseId, - }), ], }, filter: { diff --git a/components/notion/actions/retrieve-database-content/retrieve-database-content.mjs b/components/notion/actions/retrieve-database-content/retrieve-database-content.mjs index f34b61ebcf45c..2bcad9bb2b7b9 100644 --- a/components/notion/actions/retrieve-database-content/retrieve-database-content.mjs +++ b/components/notion/actions/retrieve-database-content/retrieve-database-content.mjs @@ -8,19 +8,10 @@ export default { type: "action", props: { notion, - databaseId: { - propDefinition: [ - notion, - "databaseId", - ], - }, dataSourceId: { propDefinition: [ notion, "dataSourceId", - ({ databaseId }) => ({ - databaseId, - }), ], }, }, diff --git a/components/notion/actions/retrieve-database-schema/retrieve-database-schema.mjs b/components/notion/actions/retrieve-database-schema/retrieve-database-schema.mjs index 42f2b4d59328e..785bbe38609df 100644 --- a/components/notion/actions/retrieve-database-schema/retrieve-database-schema.mjs +++ b/components/notion/actions/retrieve-database-schema/retrieve-database-schema.mjs @@ -8,19 +8,10 @@ export default { type: "action", props: { notion, - databaseId: { - propDefinition: [ - notion, - "databaseId", - ], - }, dataSourceId: { propDefinition: [ notion, "dataSourceId", - ({ databaseId }) => ({ - databaseId, - }), ], }, }, diff --git a/components/notion/actions/update-database/update-database.mjs b/components/notion/actions/update-database/update-database.mjs index 2b21f498099bc..542dcb27a9e55 100644 --- a/components/notion/actions/update-database/update-database.mjs +++ b/components/notion/actions/update-database/update-database.mjs @@ -11,19 +11,10 @@ export default { type: "action", props: { notion, - databaseId: { - propDefinition: [ - notion, - "databaseId", - ], - }, dataSourceId: { propDefinition: [ notion, "dataSourceId", - ({ databaseId }) => ({ - databaseId, - }), ], reloadProps: true, }, @@ -47,7 +38,7 @@ export default { }, }, async additionalProps(props) { - if (this.databaseId && this.dataSourceId) { + if (this.dataSourceId) { const dataSource = await this.notion.retrieveDataSource(this.dataSourceId); props.title.default = dataSource.title.map((text) => text.text.content).join(" "); @@ -64,7 +55,7 @@ export default { }, async run({ $ }) { const response = await this.notion.updateDataSource({ - dataSource_id: this.dataSourceId, + data_source_id: this.dataSourceId, title: [ { text: { diff --git a/components/notion/actions/update-page/update-page.mjs b/components/notion/actions/update-page/update-page.mjs index f6534a07e379c..09468438e14f6 100644 --- a/components/notion/actions/update-page/update-page.mjs +++ b/components/notion/actions/update-page/update-page.mjs @@ -16,19 +16,10 @@ export default { alertType: "info", content: "Properties that are not set will remain unchanged.", }, - parent: { - propDefinition: [ - notion, - "databaseId", - ], - }, parentDataSource: { propDefinition: [ notion, "dataSourceId", - (c) => ({ - databaseId: c.parent, - }), ], label: "Parent Data Source ID", description: "Select the data source that contains the page to update. If you instead provide a data source ID in a custom expression, you will also have to provide the page's ID in a custom expression", @@ -61,7 +52,7 @@ export default { "propertyTypes", (c) => ({ parentId: c.parentDataSource, - parentType: "dataSource", + parentType: "data_source", }), ], reloadProps: true, diff --git a/components/notion/notion.app.mjs b/components/notion/notion.app.mjs index 8befdb75cd924..dd55412b97c3a 100644 --- a/components/notion/notion.app.mjs +++ b/components/notion/notion.app.mjs @@ -7,28 +7,18 @@ export default { type: "app", app: "notion", propDefinitions: { - databaseId: { + dataSourceId: { type: "string", - label: "Database ID", - description: "Select a database or provide a database ID", + label: "Data Source ID", + description: "Select a data source or provide a data source ID", async options({ prevContext }) { - const response = await this.listDatabases({ + const response = await this.listDataSources({ start_cursor: prevContext.nextPageParameters ?? undefined, }); - const options = this._extractDatabaseTitleOptions(response.results); + const options = this._extractDataSourceTitleOptions(response.results); return this._buildPaginatedOptions(options, response.next_cursor); }, }, - dataSourceId: { - type: "string", - label: "Data Source ID", - description: "Select a data source from the database or provide a data source ID", - async options({ databaseId }) { - this._checkOptionsContext(databaseId, "Database ID"); - const response = await this.getDataSourcesForDatabase(databaseId); - return this._extractDatabaseTitleOptions(response); - }, - }, pageId: { type: "string", label: "Page ID", @@ -113,10 +103,10 @@ export default { async options({ parentId, parentType, }) { - this._checkOptionsContext(parentId, "Database ID"); + this._checkOptionsContext(parentId, "Data Source ID"); try { - const { properties } = parentType === "database" - ? await this.retrieveDatabase(parentId) + const { properties } = parentType === "data_source" + ? await this.retrieveDataSource(parentId) : await this.retrievePage(parentId); return Object.keys(properties); } catch (error) { @@ -232,7 +222,7 @@ export default { notionVersion: "2025-09-03", }); }, - _extractDatabaseTitleOptions(databases) { + _extractDataSourceTitleOptions(databases) { return databases.map((database) => { const title = database.title .map((title) => title.plain_text) @@ -266,8 +256,8 @@ export default { }, }; }, - extractDatabaseTitle(database) { - return this._extractDatabaseTitleOptions([ + extractDataSourceTitle(database) { + return this._extractDataSourceTitleOptions([ database, ])[0].label; }, @@ -276,31 +266,25 @@ export default { page, ])[0].label; }, - async listDatabases(params = {}) { + async listDataSources(params = {}) { return this._getNotionClient().search({ filter: { property: "object", - value: "database", + value: "data_source", }, ...params, }); }, - async queryDatabase(databaseId, params = {}) { - return this._getNotionClient().databases.query({ - database_id: databaseId, - ...params, - }); - }, - async retrieveDatabase(databaseId) { - return this._getNotionClient().databases.retrieve({ - database_id: databaseId, + async retrieveDataSource(dataSourceId) { + return this._getNotionClient().dataSources.retrieve({ + data_source_id: dataSourceId, }); }, async createDatabase(database) { return this._getNotionClient().databases.create(database); }, - async updateDatabase(database) { - return this._getNotionClient().databases.update(database); + async updateDataSource(database) { + return this._getNotionClient().dataSources.update(database); }, async queryDataSource(dataSourceId, params = {}) { return this._getNotionClient().request({ @@ -309,16 +293,6 @@ export default { body: params, }); }, - async retrieveDataSource(dataSourceId) { - return this._getNotionClient().request({ - method: "GET", - path: `data_sources/${dataSourceId}`, - }); - }, - async getDataSourcesForDatabase(databaseId) { - const database = await this.retrieveDatabase(databaseId); - return database.data_sources || []; - }, async createFileUpload(file) { return this._getNotionClient().fileUploads.create(file); }, diff --git a/components/notion/package.json b/components/notion/package.json index dbdc60948d951..15d66ac78804b 100644 --- a/components/notion/package.json +++ b/components/notion/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/notion", - "version": "0.10.1", + "version": "1.0.0", "description": "Pipedream Notion Components", "main": "notion.app.mjs", "keywords": [ @@ -10,7 +10,7 @@ "homepage": "https://pipedream.com/apps/notion", "author": "Pipedream (https://pipedream.com/)", "dependencies": { - "@notionhq/client": "4.0.2", + "@notionhq/client": "^5.0.0", "@pipedream/platform": "^3.1.0", "@tryfabric/martian": "^1.2.4", "lodash-es": "^4.17.21", diff --git a/components/notion/sources/common/base.mjs b/components/notion/sources/common/base.mjs index d5b1959e6cc7a..08e1bfe554e01 100644 --- a/components/notion/sources/common/base.mjs +++ b/components/notion/sources/common/base.mjs @@ -35,7 +35,7 @@ export default { const ts = Date.parse(lastTime); if (type === constants.types.DATABASE || type === constants.types.DATA_SOURCE) { - title = this.notion.extractDatabaseTitle(obj); + title = this.notion.extractDataSourceTitle(obj); } else { title = this.notion.extractPageTitle(obj); // Create composite ID so update events for the same page have unique keys diff --git a/components/notion/sources/new-data-source/new-data-source.mjs b/components/notion/sources/new-data-source/new-data-source.mjs new file mode 100644 index 0000000000000..0c24f4f354fb7 --- /dev/null +++ b/components/notion/sources/new-data-source/new-data-source.mjs @@ -0,0 +1,55 @@ +import base from "../common/base.mjs"; +import constants from "../common/constants.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...base, + key: "notion-new-data-source", + name: "New Data Source Created", + description: "Emit new event when a data source is created. [See the documentation](https://developers.notion.com/reference/data-source)", + version: "0.0.1", + type: "source", + props: { + ...base.props, + infoLabel: { + type: "alert", + alertType: "info", + content: "Ensure Data Sources are shared with your Pipedream integration to receive events.", + }, + }, + async run() { + const dataSources = []; + const params = this.lastCreatedSortParam(); + const lastCreatedTimestamp = this.getLastCreatedTimestamp(); + + do { + const response = await this.notion.listDataSources(params); + + for (const dataSource of response.results) { + if (!this.isResultNew(dataSource.created_time, lastCreatedTimestamp)) { + params.start_cursor = null; + break; + } + dataSources.push(dataSource); + } + + params.start_cursor = response.next_cursor; + } while (params.start_cursor); + + dataSources.reverse().forEach((dataSource) => { + const meta = this.generateMeta( + dataSource, + constants.types.DATA_SOURCE, + constants.timestamps.CREATED_TIME, + constants.summaries.DATA_SOURCE_ADDED, + ); + this.$emit(dataSource, meta); + }); + + const lastCreatedTime = dataSources[dataSources.length - 1]?.created_time; + if (lastCreatedTime) { + this.setLastCreatedTimestamp(Date.parse(lastCreatedTime)); + } + }, + sampleEmit, +}; diff --git a/components/notion/sources/new-database/test-event.mjs b/components/notion/sources/new-data-source/test-event.mjs similarity index 100% rename from components/notion/sources/new-database/test-event.mjs rename to components/notion/sources/new-data-source/test-event.mjs diff --git a/components/notion/sources/new-database/new-database.mjs b/components/notion/sources/new-database/new-database.mjs deleted file mode 100644 index 9f2d73f6b8c9c..0000000000000 --- a/components/notion/sources/new-database/new-database.mjs +++ /dev/null @@ -1,55 +0,0 @@ -import base from "../common/base.mjs"; -import constants from "../common/constants.mjs"; -import sampleEmit from "./test-event.mjs"; - -export default { - ...base, - key: "notion-new-database", - name: "New Database Created", - description: "Emit new event when a database is created. [See the documentation](https://developers.notion.com/reference/database)", - version: "0.0.14", - type: "source", - props: { - ...base.props, - infoLabel: { - type: "alert", - alertType: "info", - content: "Ensure Databases are shared with your Pipedream integration to receive events.", - }, - }, - async run() { - const databases = []; - const params = this.lastCreatedSortParam(); - const lastCreatedTimestamp = this.getLastCreatedTimestamp(); - - do { - const response = await this.notion.listDatabases(params); - - for (const database of response.results) { - if (!this.isResultNew(database.created_time, lastCreatedTimestamp)) { - params.start_cursor = null; - break; - } - databases.push(database); - } - - params.start_cursor = response.next_cursor; - } while (params.start_cursor); - - databases.reverse().forEach((database) => { - const meta = this.generateMeta( - database, - constants.types.DATABASE, - constants.timestamps.CREATED_TIME, - constants.summaries.DATABASE_ADDED, - ); - this.$emit(database, meta); - }); - - const lastCreatedTime = databases[databases.length - 1]?.created_time; - if (lastCreatedTime) { - this.setLastCreatedTimestamp(Date.parse(lastCreatedTime)); - } - }, - sampleEmit, -}; diff --git a/components/notion/sources/new-page/new-page.mjs b/components/notion/sources/new-page/new-page.mjs index 3a9902383b9aa..a96362cf56d1a 100644 --- a/components/notion/sources/new-page/new-page.mjs +++ b/components/notion/sources/new-page/new-page.mjs @@ -12,19 +12,10 @@ export default { type: "source", props: { ...base.props, - databaseId: { - propDefinition: [ - notion, - "databaseId", - ], - }, dataSourceId: { propDefinition: [ notion, "dataSourceId", - ({ databaseId }) => ({ - databaseId, - }), ], }, }, diff --git a/components/notion/sources/page-properties-updated-instant/page-properties-updated-instant.mjs b/components/notion/sources/page-properties-updated-instant/page-properties-updated-instant.mjs index b9652d93c1c93..a131cdf4b6c4d 100644 --- a/components/notion/sources/page-properties-updated-instant/page-properties-updated-instant.mjs +++ b/components/notion/sources/page-properties-updated-instant/page-properties-updated-instant.mjs @@ -11,19 +11,10 @@ export default { dedupe: "unique", props: { ...common.props, - databaseId: { - propDefinition: [ - common.props.notion, - "databaseId", - ], - }, dataSourceId: { propDefinition: [ common.props.notion, "dataSourceId", - ({ databaseId }) => ({ - databaseId, - }), ], }, properties: { diff --git a/components/notion/sources/updated-page-by-timestamp/updated-page-by-timestamp.mjs b/components/notion/sources/updated-page-by-timestamp/updated-page-by-timestamp.mjs index 4587a869f6624..78f76b8a4c251 100644 --- a/components/notion/sources/updated-page-by-timestamp/updated-page-by-timestamp.mjs +++ b/components/notion/sources/updated-page-by-timestamp/updated-page-by-timestamp.mjs @@ -13,19 +13,10 @@ export default { dedupe: "unique", props: { ...base.props, - databaseId: { - propDefinition: [ - notion, - "databaseId", - ], - }, dataSourceId: { propDefinition: [ notion, "dataSourceId", - ({ databaseId }) => ({ - databaseId, - }), ], }, includeNewPages: { diff --git a/components/notion/sources/updated-page/updated-page.mjs b/components/notion/sources/updated-page/updated-page.mjs index 8f76f0b46990e..126044436a46a 100644 --- a/components/notion/sources/updated-page/updated-page.mjs +++ b/components/notion/sources/updated-page/updated-page.mjs @@ -14,19 +14,10 @@ export default { dedupe: "unique", props: { ...base.props, - databaseId: { - propDefinition: [ - notion, - "databaseId", - ], - }, dataSourceId: { propDefinition: [ notion, "dataSourceId", - ({ databaseId }) => ({ - databaseId, - }), ], }, includeNewPages: { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 81354f113b0cf..a494b769ccf9e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9518,8 +9518,8 @@ importers: components/notion: dependencies: '@notionhq/client': - specifier: 4.0.2 - version: 4.0.2 + specifier: ^5.0.0 + version: 5.0.0 '@pipedream/platform': specifier: ^3.1.0 version: 3.1.0 @@ -19713,6 +19713,10 @@ packages: resolution: {integrity: sha512-4pk3dm4umhjsRI0umCnJ8lCZh0TMiaMdkY0rz6FV4OqVuTsmYFV3pk+YTR5S8792ZY2Rm4lJHlLj05HQVKDuIg==} engines: {node: '>=18'} + '@notionhq/client@5.0.0': + resolution: {integrity: sha512-eXq0bZTXN8+xwT6e3qlrH9QCUn8mQLJ9UkNgKSew2NKNV/hyKb2wmIzQAuass8a2Q6F1aMjMPi+EGLQwgbVlOA==} + engines: {node: '>=18'} + '@octokit/auth-token@2.5.0': resolution: {integrity: sha512-r5FVUJCOLl19AxiuZD2VRZ/ORjp/4IN98Of6YJoJOkY75CIBuYfmiNHGrDwXr+aLGG55igl9QrxX3hbiXlLb+g==} @@ -37493,6 +37497,8 @@ snapshots: '@notionhq/client@4.0.2': {} + '@notionhq/client@5.0.0': {} + '@octokit/auth-token@2.5.0': dependencies: '@octokit/types': 6.41.0 From 4613acaa26cb07b9972b40a83ebb2a3d1971d388 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Mon, 8 Sep 2025 19:00:25 -0300 Subject: [PATCH 06/12] Reverting key change --- .../new-data-source.mjs => new-database/new-database.mjs} | 0 .../sources/{new-data-source => new-database}/test-event.mjs | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename components/notion/sources/{new-data-source/new-data-source.mjs => new-database/new-database.mjs} (100%) rename components/notion/sources/{new-data-source => new-database}/test-event.mjs (100%) diff --git a/components/notion/sources/new-data-source/new-data-source.mjs b/components/notion/sources/new-database/new-database.mjs similarity index 100% rename from components/notion/sources/new-data-source/new-data-source.mjs rename to components/notion/sources/new-database/new-database.mjs diff --git a/components/notion/sources/new-data-source/test-event.mjs b/components/notion/sources/new-database/test-event.mjs similarity index 100% rename from components/notion/sources/new-data-source/test-event.mjs rename to components/notion/sources/new-database/test-event.mjs From 350242a78cf7a615dc4a5ada666dd351c281beb2 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Mon, 8 Sep 2025 19:18:32 -0300 Subject: [PATCH 07/12] Version bumps --- .../actions/append-block/append-block.mjs | 2 +- .../complete-file-upload.mjs | 2 +- .../actions/create-comment/create-comment.mjs | 2 +- .../create-file-upload/create-file-upload.mjs | 2 +- .../create-page-from-database/README.md | 20 +++++++++---------- .../actions/create-page/create-page.mjs | 2 +- .../actions/delete-block/delete-block.mjs | 2 +- .../actions/duplicate-page/duplicate-page.mjs | 2 +- .../actions/list-all-users/list-all-users.mjs | 2 +- .../list-file-uploads/list-file-uploads.mjs | 2 +- .../actions/query-database/query-database.mjs | 2 +- .../actions/retrieve-block/retrieve-block.mjs | 2 +- .../retrieve-file-upload.mjs | 2 +- .../retrieve-page-property-item.mjs | 2 +- .../actions/retrieve-page/retrieve-page.mjs | 2 +- .../actions/retrieve-user/retrieve-user.mjs | 2 +- .../send-file-upload/send-file-upload.mjs | 2 +- .../actions/update-block/update-block.mjs | 2 +- .../new-comment-created.mjs | 2 +- .../sources/new-database/new-database.mjs | 2 +- .../notion/sources/new-page/new-page.mjs | 2 +- .../new-webhook-event-instant.mjs | 2 +- .../page-or-subpage-updated.mjs | 2 +- .../updated-page-id/updated-page-id.mjs | 2 +- .../sources/updated-page/updated-page.mjs | 2 +- 25 files changed, 34 insertions(+), 34 deletions(-) diff --git a/components/notion/actions/append-block/append-block.mjs b/components/notion/actions/append-block/append-block.mjs index b76b6f97b667a..ef74394108aa8 100644 --- a/components/notion/actions/append-block/append-block.mjs +++ b/components/notion/actions/append-block/append-block.mjs @@ -7,7 +7,7 @@ export default { name: "Append Block to Parent", description: "Append new and/or existing blocks to the specified parent. [See the documentation](https://developers.notion.com/reference/patch-block-children)", - version: "0.3.7", + version: "0.3.8", type: "action", props: { notion, diff --git a/components/notion/actions/complete-file-upload/complete-file-upload.mjs b/components/notion/actions/complete-file-upload/complete-file-upload.mjs index adb2869f82b75..108cd25aeae97 100644 --- a/components/notion/actions/complete-file-upload/complete-file-upload.mjs +++ b/components/notion/actions/complete-file-upload/complete-file-upload.mjs @@ -6,7 +6,7 @@ export default { key: "notion-complete-file-upload", name: "Complete File Upload", 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)", - version: "0.0.2", + version: "0.0.3", type: "action", props: { notion, diff --git a/components/notion/actions/create-comment/create-comment.mjs b/components/notion/actions/create-comment/create-comment.mjs index fbcffa707efba..77a1cc32cd482 100644 --- a/components/notion/actions/create-comment/create-comment.mjs +++ b/components/notion/actions/create-comment/create-comment.mjs @@ -5,7 +5,7 @@ export default { key: "notion-create-comment", name: "Create Comment", description: "Create a comment in a page or existing discussion thread. [See the documentation](https://developers.notion.com/reference/create-a-comment)", - version: "0.0.7", + version: "0.0.8", type: "action", props: { notion, diff --git a/components/notion/actions/create-file-upload/create-file-upload.mjs b/components/notion/actions/create-file-upload/create-file-upload.mjs index 7e0c975584a27..68bf8591c5c18 100644 --- a/components/notion/actions/create-file-upload/create-file-upload.mjs +++ b/components/notion/actions/create-file-upload/create-file-upload.mjs @@ -6,7 +6,7 @@ export default { key: "notion-create-file-upload", name: "Create File Upload", description: "Create a file upload. [See the documentation](https://developers.notion.com/reference/create-a-file-upload)", - version: "0.0.2", + version: "0.0.3", type: "action", props: { notion, diff --git a/components/notion/actions/create-page-from-database/README.md b/components/notion/actions/create-page-from-database/README.md index 900d852a72b40..12e476fa8a51d 100644 --- a/components/notion/actions/create-page-from-database/README.md +++ b/components/notion/actions/create-page-from-database/README.md @@ -1,25 +1,25 @@ # Overview -The Notion Create Page from Database action allows you to add pages to a Notion Database. +The Notion Create Page from Data Source action allows you to add pages to a Notion Data Source. -This action features easy to use dropdowns that automatically populate your databases as well as your database's properties, also known as columns. +This action features easy to use dropdowns that automatically populate your data sources as well as your data sources's properties, also known as columns. -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 . +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. # Getting Started -[Follow this short 4 minute guide to connect your Notion account and add new Database pages](https://youtu.be/wciWsu564_0) +[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) ### Props -When using the **Create Page from Database** action, there are several props to define: +When using the **Create Page from Data Source** action, there are several props to define: 1. `Notion Account` - see the **Accounts** section below. -2. `Parent Database ID` - the database to add a page to. +2. `Parent Data Source ID` - the data source to add a page to. 3. `Meta Types` - an icon or cover to add to the new page (optional). -4. `Property Types` - one or more properties to add to the new page that correspond with columns in the database. +4. `Property Types` - one or more properties to add to the new page that correspond with columns in the data source. 5. `Page Content` - the content of the page that appears when it's opened in a side view. 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. 1. [Create a new workflow](https://pipedream.com/new). 2. Select your trigger (HTTP, Cron, etc.). 3. Click on the **+** button below the trigger step, and search for "Notion". -4. Select the **Create Page from Database** action. +4. Select the **Create Page from Data Source** action. 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**. 6. That's it! You can now connect to the Notion API using any of the Slack actions within a Pipedream workflow. # Troubleshooting -If your database doesn't appear under the options, try deleting your Notion account connection and reconnecting. +If your data source doesn't appear under the options, try deleting your Notion account connection and reconnecting. -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. \ No newline at end of file +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. \ No newline at end of file diff --git a/components/notion/actions/create-page/create-page.mjs b/components/notion/actions/create-page/create-page.mjs index d87c029ec05e7..164b747ff15e6 100644 --- a/components/notion/actions/create-page/create-page.mjs +++ b/components/notion/actions/create-page/create-page.mjs @@ -7,7 +7,7 @@ export default { key: "notion-create-page", name: "Create Page", description: "Create a page from a parent page. [See the documentation](https://developers.notion.com/reference/post-page)", - version: "0.2.20", + version: "0.2.21", type: "action", props: { notion, diff --git a/components/notion/actions/delete-block/delete-block.mjs b/components/notion/actions/delete-block/delete-block.mjs index 3fa6525eae513..a98f6083e12dd 100644 --- a/components/notion/actions/delete-block/delete-block.mjs +++ b/components/notion/actions/delete-block/delete-block.mjs @@ -6,7 +6,7 @@ export default { key: "notion-delete-block", name: "Delete Block", 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)", - version: "0.0.2", + version: "0.0.3", type: "action", props: { notion, diff --git a/components/notion/actions/duplicate-page/duplicate-page.mjs b/components/notion/actions/duplicate-page/duplicate-page.mjs index 743f4c0e38114..8a1c6e4a1a864 100644 --- a/components/notion/actions/duplicate-page/duplicate-page.mjs +++ b/components/notion/actions/duplicate-page/duplicate-page.mjs @@ -7,7 +7,7 @@ export default { key: "notion-duplicate-page", name: "Duplicate Page", description: "Create a new page copied from an existing page block. [See the documentation](https://developers.notion.com/reference/post-page)", - version: "0.0.17", + version: "0.0.18", type: "action", props: { notion, diff --git a/components/notion/actions/list-all-users/list-all-users.mjs b/components/notion/actions/list-all-users/list-all-users.mjs index dbf9d1765a053..e45b6438afef8 100644 --- a/components/notion/actions/list-all-users/list-all-users.mjs +++ b/components/notion/actions/list-all-users/list-all-users.mjs @@ -4,7 +4,7 @@ export default { key: "notion-list-all-users", name: "List All Users", description: "Returns all users in the workspace. [See the documentation](https://developers.notion.com/reference/get-users)", - version: "0.0.2", + version: "0.0.3", type: "action", props: { notion, diff --git a/components/notion/actions/list-file-uploads/list-file-uploads.mjs b/components/notion/actions/list-file-uploads/list-file-uploads.mjs index 9655b34fe6e98..0ed02d25c15b0 100644 --- a/components/notion/actions/list-file-uploads/list-file-uploads.mjs +++ b/components/notion/actions/list-file-uploads/list-file-uploads.mjs @@ -6,7 +6,7 @@ export default { key: "notion-list-file-uploads", name: "List File Uploads", description: "Use this action to list file uploads. [See the documentation](https://developers.notion.com/reference/list-file-uploads)", - version: "0.0.2", + version: "0.0.3", type: "action", props: { notion, diff --git a/components/notion/actions/query-database/query-database.mjs b/components/notion/actions/query-database/query-database.mjs index f4fa4364719ba..0d3ab32f83d46 100644 --- a/components/notion/actions/query-database/query-database.mjs +++ b/components/notion/actions/query-database/query-database.mjs @@ -5,7 +5,7 @@ export default { key: "notion-query-database", name: "Query Data Source", description: "Query a data source with a specified filter. [See the documentation](https://developers.notion.com/reference/query-a-data-source)", - version: "1.0.{{ts}}", + version: "1.0.0", type: "action", props: { notion, diff --git a/components/notion/actions/retrieve-block/retrieve-block.mjs b/components/notion/actions/retrieve-block/retrieve-block.mjs index 1b0e0fb86067d..565016bbbd54d 100644 --- a/components/notion/actions/retrieve-block/retrieve-block.mjs +++ b/components/notion/actions/retrieve-block/retrieve-block.mjs @@ -4,7 +4,7 @@ export default { key: "notion-retrieve-block", name: "Retrieve Page Content", description: "Get page content as block objects or markdown. Blocks can be text, lists, media, a page, among others. [See the documentation](https://developers.notion.com/reference/retrieve-a-block)", - version: "0.2.5", + version: "0.2.6", type: "action", props: { notion, diff --git a/components/notion/actions/retrieve-file-upload/retrieve-file-upload.mjs b/components/notion/actions/retrieve-file-upload/retrieve-file-upload.mjs index dcc417513a7bc..059e9858ec2c5 100644 --- a/components/notion/actions/retrieve-file-upload/retrieve-file-upload.mjs +++ b/components/notion/actions/retrieve-file-upload/retrieve-file-upload.mjs @@ -6,7 +6,7 @@ export default { key: "notion-retrieve-file-upload", name: "Retrieve File Upload", description: "Use this action to retrieve a file upload. [See the documentation](https://developers.notion.com/reference/retrieve-a-file-upload)", - version: "0.0.2", + version: "0.0.3", type: "action", props: { notion, diff --git a/components/notion/actions/retrieve-page-property-item/retrieve-page-property-item.mjs b/components/notion/actions/retrieve-page-property-item/retrieve-page-property-item.mjs index 7f1b2c9090428..13eaf7c0a079c 100644 --- a/components/notion/actions/retrieve-page-property-item/retrieve-page-property-item.mjs +++ b/components/notion/actions/retrieve-page-property-item/retrieve-page-property-item.mjs @@ -4,7 +4,7 @@ export default { key: "notion-retrieve-page-property-item", name: "Retrieve Page Property Item", description: "Get a Property Item object for a selected page and property. [See the documentation](https://developers.notion.com/reference/retrieve-a-page-property)", - version: "0.0.10", + version: "0.0.11", type: "action", props: { notion, diff --git a/components/notion/actions/retrieve-page/retrieve-page.mjs b/components/notion/actions/retrieve-page/retrieve-page.mjs index dd7de041ca7a6..f56af679ed887 100644 --- a/components/notion/actions/retrieve-page/retrieve-page.mjs +++ b/components/notion/actions/retrieve-page/retrieve-page.mjs @@ -4,7 +4,7 @@ export default { key: "notion-retrieve-page", name: "Retrieve Page Metadata", description: "Get details of a page. [See the documentation](https://developers.notion.com/reference/retrieve-a-page)", - version: "0.0.11", + version: "0.0.12", type: "action", props: { notion, diff --git a/components/notion/actions/retrieve-user/retrieve-user.mjs b/components/notion/actions/retrieve-user/retrieve-user.mjs index 76718e58673c3..d604f9fb7171a 100644 --- a/components/notion/actions/retrieve-user/retrieve-user.mjs +++ b/components/notion/actions/retrieve-user/retrieve-user.mjs @@ -4,7 +4,7 @@ export default { key: "notion-retrieve-user", name: "Retrieve User", description: "Returns a user using the ID specified. [See the documentation](https://developers.notion.com/reference/get-user)", - version: "0.0.2", + version: "0.0.3", type: "action", props: { notion, diff --git a/components/notion/actions/send-file-upload/send-file-upload.mjs b/components/notion/actions/send-file-upload/send-file-upload.mjs index 87392063107d7..9141bfe8bfc38 100644 --- a/components/notion/actions/send-file-upload/send-file-upload.mjs +++ b/components/notion/actions/send-file-upload/send-file-upload.mjs @@ -8,7 +8,7 @@ export default { key: "notion-send-file-upload", name: "Send File Upload", description: "Send a file upload. [See the documentation](https://developers.notion.com/reference/send-a-file-upload)", - version: "0.0.2", + version: "0.0.3", type: "action", props: { notion, diff --git a/components/notion/actions/update-block/update-block.mjs b/components/notion/actions/update-block/update-block.mjs index 72faf2f32a5a4..b82a2a1ae5b8a 100644 --- a/components/notion/actions/update-block/update-block.mjs +++ b/components/notion/actions/update-block/update-block.mjs @@ -7,7 +7,7 @@ export default { key: "notion-update-block", name: "Update Child Block", description: "Updates a child block object. [See the documentation](https://developers.notion.com/reference/update-a-block)", - version: "0.0.2", + version: "0.0.3", type: "action", props: { notion, diff --git a/components/notion/sources/new-comment-created/new-comment-created.mjs b/components/notion/sources/new-comment-created/new-comment-created.mjs index bc64a408f336d..ee509db1f9754 100644 --- a/components/notion/sources/new-comment-created/new-comment-created.mjs +++ b/components/notion/sources/new-comment-created/new-comment-created.mjs @@ -5,7 +5,7 @@ export default { key: "notion-new-comment-created", name: "New Comment Created", description: "Emit new event when a new comment is created in a page or block. [See the documentation](https://developers.notion.com/reference/retrieve-a-comment)", - version: "0.0.7", + version: "0.0.8", type: "source", dedupe: "unique", props: { diff --git a/components/notion/sources/new-database/new-database.mjs b/components/notion/sources/new-database/new-database.mjs index 0c24f4f354fb7..2a4004f065ede 100644 --- a/components/notion/sources/new-database/new-database.mjs +++ b/components/notion/sources/new-database/new-database.mjs @@ -7,7 +7,7 @@ export default { key: "notion-new-data-source", name: "New Data Source Created", description: "Emit new event when a data source is created. [See the documentation](https://developers.notion.com/reference/data-source)", - version: "0.0.1", + version: "0.1.0", type: "source", props: { ...base.props, diff --git a/components/notion/sources/new-page/new-page.mjs b/components/notion/sources/new-page/new-page.mjs index a96362cf56d1a..e2cd78e5dbe01 100644 --- a/components/notion/sources/new-page/new-page.mjs +++ b/components/notion/sources/new-page/new-page.mjs @@ -8,7 +8,7 @@ export default { key: "notion-new-page", name: "New Page in Data Source", description: "Emit new event when a page is created in the selected data source. [See the documentation](https://developers.notion.com/reference/page)", - version: "0.0.16", + version: "1.0.0", type: "source", props: { ...base.props, diff --git a/components/notion/sources/new-webhook-event-instant/new-webhook-event-instant.mjs b/components/notion/sources/new-webhook-event-instant/new-webhook-event-instant.mjs index ea409a5b32115..4992fe61a1d8e 100644 --- a/components/notion/sources/new-webhook-event-instant/new-webhook-event-instant.mjs +++ b/components/notion/sources/new-webhook-event-instant/new-webhook-event-instant.mjs @@ -6,7 +6,7 @@ export default { key: "notion-new-webhook-event-instant", name: "New Webhook Event (Instant)", description: "Emit new event each time a webhook event is received. Webhook must be setup in Notion. [See the documentation](https://developers.notion.com/reference/webhooks#step-1-creating-a-webhook-subscription)", - version: "0.0.2", + version: "0.0.3", type: "source", dedupe: "unique", methods: { diff --git a/components/notion/sources/page-or-subpage-updated/page-or-subpage-updated.mjs b/components/notion/sources/page-or-subpage-updated/page-or-subpage-updated.mjs index 81348d87e13c8..ea79655e767c2 100644 --- a/components/notion/sources/page-or-subpage-updated/page-or-subpage-updated.mjs +++ b/components/notion/sources/page-or-subpage-updated/page-or-subpage-updated.mjs @@ -7,7 +7,7 @@ export default { key: "notion-page-or-subpage-updated", name: "Page or Subpage Updated", /* eslint-disable-line pipedream/source-name */ description: "Emit new event when the selected page or one of its sub-pages is updated. [See the documentation](https://developers.notion.com/reference/page)", - version: "0.0.12", + version: "0.0.13", type: "source", dedupe: "unique", props: { diff --git a/components/notion/sources/updated-page-id/updated-page-id.mjs b/components/notion/sources/updated-page-id/updated-page-id.mjs index 3bc50dee1aa0c..467acb47351d1 100644 --- a/components/notion/sources/updated-page-id/updated-page-id.mjs +++ b/components/notion/sources/updated-page-id/updated-page-id.mjs @@ -7,7 +7,7 @@ export default { key: "notion-updated-page-id", name: "Page Updated", /* eslint-disable-line pipedream/source-name */ description: "Emit new event when a selected page is updated. [See the documentation](https://developers.notion.com/reference/page)", - version: "0.0.11", + version: "0.0.12", type: "source", dedupe: "unique", props: { diff --git a/components/notion/sources/updated-page/updated-page.mjs b/components/notion/sources/updated-page/updated-page.mjs index 126044436a46a..2f8dbf408ceb5 100644 --- a/components/notion/sources/updated-page/updated-page.mjs +++ b/components/notion/sources/updated-page/updated-page.mjs @@ -9,7 +9,7 @@ export default { key: "notion-updated-page", name: "New or Updated Page in Data Source (By Property)", description: "Emit new event when a page is created or updated in the selected data source. [See the documentation](https://developers.notion.com/reference/page)", - version: "0.1.12", + version: "1.0.0", type: "source", dedupe: "unique", props: { From 9974ceb8bbffcbb6276c9eb61dd7adce0fadc8d5 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Mon, 8 Sep 2025 19:30:54 -0300 Subject: [PATCH 08/12] Key adjustment --- components/notion/sources/new-database/new-database.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/notion/sources/new-database/new-database.mjs b/components/notion/sources/new-database/new-database.mjs index 2a4004f065ede..fbe83f13bce6e 100644 --- a/components/notion/sources/new-database/new-database.mjs +++ b/components/notion/sources/new-database/new-database.mjs @@ -4,7 +4,7 @@ import sampleEmit from "./test-event.mjs"; export default { ...base, - key: "notion-new-data-source", + key: "notion-new-database", name: "New Data Source Created", description: "Emit new event when a data source is created. [See the documentation](https://developers.notion.com/reference/data-source)", version: "0.1.0", From 9a889448fba230347fb087ee6980f725f26dd802 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Wed, 10 Sep 2025 23:07:29 -0300 Subject: [PATCH 09/12] Fixing "Page Properties Updated" source --- .../page-properties-updated-instant.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/notion/sources/page-properties-updated-instant/page-properties-updated-instant.mjs b/components/notion/sources/page-properties-updated-instant/page-properties-updated-instant.mjs index a131cdf4b6c4d..0e45844c78189 100644 --- a/components/notion/sources/page-properties-updated-instant/page-properties-updated-instant.mjs +++ b/components/notion/sources/page-properties-updated-instant/page-properties-updated-instant.mjs @@ -55,8 +55,8 @@ export default { return; } - if (event.data.parent.id !== this.dataSourceId) { - console.log(`Skipping event for data source: ${event.data.parent.id}`); + if (event.data.parent.data_source_id !== this.dataSourceId) { + console.log(`Skipping event for data source: ${event.data.parent.data_source_id}`); return; } From a50e854037f1fa769023807d9bab0e8f2e3382e2 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Wed, 10 Sep 2025 23:39:39 -0300 Subject: [PATCH 10/12] Fixing query method --- components/notion/notion.app.mjs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/components/notion/notion.app.mjs b/components/notion/notion.app.mjs index dd55412b97c3a..f95dc708c9b98 100644 --- a/components/notion/notion.app.mjs +++ b/components/notion/notion.app.mjs @@ -287,10 +287,9 @@ export default { return this._getNotionClient().dataSources.update(database); }, async queryDataSource(dataSourceId, params = {}) { - return this._getNotionClient().request({ - method: "POST", - path: `data_sources/${dataSourceId}/query`, - body: params, + return this._getNotionClient().dataSources.query({ + data_source_id: dataSourceId, + ...params, }); }, async createFileUpload(file) { From 85169c44d684b6765cb86f1ef9765d04976e5b09 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 11 Sep 2025 00:37:52 -0300 Subject: [PATCH 11/12] Page builder fixes --- .../actions/common/base-page-builder.mjs | 41 +++++++++++++++++-- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/components/notion/actions/common/base-page-builder.mjs b/components/notion/actions/common/base-page-builder.mjs index 6c2c995b3ce2b..2bb116155e2c5 100644 --- a/components/notion/actions/common/base-page-builder.mjs +++ b/components/notion/actions/common/base-page-builder.mjs @@ -74,7 +74,8 @@ export default { * @param properties - Properties from the selected page obtained from Notion * @returns the selected props inputted by the user with the following attributes: * - type: the Notion property type used in notion-page-properties.mjs - * - label: the page's property name + * - label: the property ID for API calls + * (was property name before data source migration) * - value: the property value inputted by the user */ _filterProps(properties = {}) { @@ -83,7 +84,7 @@ export default { || (this.properties && this.properties[property])) .map((property) => ({ type: properties[property]?.type ?? property, - label: property, + label: properties[property]?.id || property, value: this[property] || this.properties?.[property], })); }, @@ -96,8 +97,14 @@ export default { _convertPropertiesToNotion(properties = [], NOTION_CONVERTER = {}) { const notionProperties = {}; for (const property of properties) { - const notionProperty = NOTION_CONVERTER[property.type]; - notionProperties[property.label] = notionProperty?.convertToNotion(property); + // If the property value is already in Notion format, use it directly + if (this._isAlreadyNotionFormat(property.value, property.type)) { + notionProperties[property.label] = property.value; + } else { + // Otherwise, convert using the appropriate converter + const notionProperty = NOTION_CONVERTER[property.type]; + notionProperties[property.label] = notionProperty?.convertToNotion(property); + } } return notionProperties; }, @@ -156,6 +163,32 @@ export default { const filteredProperties = this._filterProps(parentProperties); return this._buildNotionPageProperties(filteredProperties); }, + /** + * Checks if a property value is already in Notion format + * @param value - the property value to check + * @returns true if already in Notion format, false otherwise + */ + _isAlreadyNotionFormat(value) { + if (!value || typeof value !== "object") return false; + + // Check for common Notion property structures + const notionKeys = [ + "title", + "rich_text", + "number", + "select", + "multi_select", + "date", + "people", + "files", + "checkbox", + "url", + "email", + "phone_number", + "relation", + ]; + return notionKeys.some((key) => key in value); + }, /** * Creates the block children inputted by the user in Notion format * @returns the block children in Notion format From a6fc9fbe79e63f37349787065f7ea94a9dd26e51 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 11 Sep 2025 00:45:55 -0300 Subject: [PATCH 12/12] Text/link fixes --- components/notion/actions/create-page-from-database/README.md | 2 +- components/notion/actions/update-database/update-database.mjs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/notion/actions/create-page-from-database/README.md b/components/notion/actions/create-page-from-database/README.md index 12e476fa8a51d..8e92c4457c02e 100644 --- a/components/notion/actions/create-page-from-database/README.md +++ b/components/notion/actions/create-page-from-database/README.md @@ -2,7 +2,7 @@ The Notion Create Page from Data Source action allows you to add pages to a Notion Data Source. -This action features easy to use dropdowns that automatically populate your data sources as well as your data sources's properties, also known as columns. +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. 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. diff --git a/components/notion/actions/update-database/update-database.mjs b/components/notion/actions/update-database/update-database.mjs index 542dcb27a9e55..333783c1d5de1 100644 --- a/components/notion/actions/update-database/update-database.mjs +++ b/components/notion/actions/update-database/update-database.mjs @@ -33,7 +33,7 @@ export default { properties: { type: "object", label: "Properties", - description: "The properties of a data source to be changed in the request, in the form of a JSON object. If updating an existing property, then the keys are the names or IDs of the properties as they appear in Notion, and the values are [property schema objects](https://developers.notion.com/reference/rich-text). If adding a new property, then the key is the name of the new data source property and the value is a [property schema object](https://developers.notion.com/reference/property-schema-object).", + description: "The properties of a data source to be changed in the request, in the form of a JSON object. If updating an existing property, then the keys are the names or IDs of the properties as they appear in Notion, and the values are [property schema objects](https://developers.notion.com/reference/property-schema-object). If adding a new property, then the key is the name of the new data source property and the value is a [property schema object](https://developers.notion.com/reference/property-schema-object).", optional: true, }, },