diff --git a/components/notion/actions/append-block/append-block.mjs b/components/notion/actions/append-block/append-block.mjs index 235e6c5ce5bb8..ea876272da8ab 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.2", + version: "0.3.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 453f45e0e8f6f..7e5801728ada9 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.3", + version: "0.0.4", type: "action", props: { notion, 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 645b4d1071d57..001008fe3ec05 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 @@ -7,7 +7,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.1.17", + version: "0.1.18", type: "action", props: { notion, diff --git a/components/notion/actions/create-page/create-page.mjs b/components/notion/actions/create-page/create-page.mjs index f6096725a0a5d..9a625e62feb19 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.15", + version: "0.2.16", 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 f8f1e4bed2f24..41796128df4d7 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.12", + version: "0.0.13", 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 3bda23f2f11c9..9b58bd5bab6fa 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 Database", description: "Query a database with a specified filter. [See the documentation](https://developers.notion.com/reference/post-database-query)", - version: "0.0.10", + version: "0.0.11", 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 c14647bd69097..75b4eff23bca6 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.1", + version: "0.2.2", type: "action", props: { notion, @@ -33,20 +33,20 @@ export default { }, }, async run({ $ }) { - let markdownContent; - if (this.retrieveMarkdown) { - markdownContent = await this.notion.getPageAsMarkdown(this.blockId); - } - const { retrieveChildren } = this; const subpagesOnly = retrieveChildren === "Sub-Pages Only"; - - const block = await this.notion.retrieveBlock(this.blockId); const shouldRetrieveChildren = [ true, "All Children", "Sub-Pages Only", ].includes(retrieveChildren); + + let markdownContent; + if (this.retrieveMarkdown) { + markdownContent = await this.notion.getPageAsMarkdown(this.blockId, shouldRetrieveChildren); + } + + const block = await this.notion.retrieveBlock(this.blockId); if (shouldRetrieveChildren) { block.children = await this.notion.retrieveBlockChildren(block, subpagesOnly); } 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 88000bf71ec5a..f467afc3fd274 100644 --- a/components/notion/actions/retrieve-database-content/retrieve-database-content.mjs +++ b/components/notion/actions/retrieve-database-content/retrieve-database-content.mjs @@ -4,7 +4,7 @@ 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.5", + version: "0.0.6", type: "action", props: { notion, 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 505e9f50865c2..7b89670fab886 100644 --- a/components/notion/actions/retrieve-database-schema/retrieve-database-schema.mjs +++ b/components/notion/actions/retrieve-database-schema/retrieve-database-schema.mjs @@ -4,7 +4,7 @@ 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.7", + version: "0.0.8", 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 3b7bb8c8c95db..ccb9ed8fe4395 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.6", + version: "0.0.7", 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 fff82edfa8f3f..fd9330b973e69 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.7", + version: "0.0.8", type: "action", props: { notion, diff --git a/components/notion/actions/search/search.mjs b/components/notion/actions/search/search.mjs index de6f0f24b8d2c..e9d6bb04cea7f 100644 --- a/components/notion/actions/search/search.mjs +++ b/components/notion/actions/search/search.mjs @@ -5,7 +5,7 @@ export default { 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.6", + version: "0.0.7", type: "action", props: { ...common.props, diff --git a/components/notion/actions/update-page/update-page.mjs b/components/notion/actions/update-page/update-page.mjs index 6eed2dc03b6b2..4a315cb2d07e6 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.5", + version: "1.1.6", type: "action", props: { notion, diff --git a/components/notion/notion.app.mjs b/components/notion/notion.app.mjs index 6215f9e9d1674..2ad068034c625 100644 --- a/components/notion/notion.app.mjs +++ b/components/notion/notion.app.mjs @@ -1,8 +1,7 @@ import notion from "@notionhq/client"; import NOTION_META from "./common/notion-meta-selection.mjs"; import { ConfigurationError } from "@pipedream/platform"; -import { NotionConverter } from "notion-to-md"; -import { DefaultExporter } from "notion-to-md/plugins/exporter"; +import { NotionToMarkdown } from "notion-to-md"; export default { type: "app", @@ -358,19 +357,20 @@ export default { return response.results; }, - async getPageAsMarkdown(pageId) { - const client = this._getNotionClient(); + async getPageAsMarkdown(pageId, shouldRetrieveChildren) { + const notion = this._getNotionClient(); - const buffer = {}; - const exporter = new DefaultExporter({ - outputType: "buffer", - buffer, + const n2m = new NotionToMarkdown({ + notionClient: notion, + config: { + separateChildPage: true, + }, }); - - const n2m = new NotionConverter(client).withExporter(exporter); - await n2m.convert(pageId); - - return Object.values(buffer)[0]; + const blocks = await n2m.pageToMarkdown(pageId); + const output = n2m.toMarkdownString(blocks); + return shouldRetrieveChildren + ? output + : output.parent; }, }, }; diff --git a/components/notion/package.json b/components/notion/package.json index eb2fb03e09613..ae4ae745b378f 100644 --- a/components/notion/package.json +++ b/components/notion/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/notion", - "version": "0.6.1", + "version": "0.6.2", "description": "Pipedream Notion Components", "main": "notion.app.mjs", "keywords": [ @@ -14,7 +14,7 @@ "@pipedream/platform": "^3.0.3", "@tryfabric/martian": "^1.2.4", "lodash-es": "^4.17.21", - "notion-to-md": "^4.0.0-alpha.4" + "notion-to-md": "3.1.8" }, "publishConfig": { "access": "public" 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 555648fb8183c..207e7143afc73 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.3", + version: "0.0.4", 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 ee892e5a6f7e1..c10dbd418dc8d 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-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.10", + version: "0.0.11", 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 ce77cd14d9102..6c6dc2cfbae27 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 Database", description: "Emit new event when a page is created in the selected database. [See the documentation](https://developers.notion.com/reference/page)", - version: "0.0.12", + version: "0.0.13", type: "source", props: { ...base.props, 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 43a33b8110964..ad97c51a88474 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.8", + version: "0.0.9", 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 b3fc32ead6de6..1f8680827da86 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.7", + version: "0.0.8", 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 040f26d9d12a3..668fdbc4ff220 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 Database", /* eslint-disable-line pipedream/source-name */ 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.1.6", + version: "0.1.7", type: "source", dedupe: "unique", props: { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 29c6699ad1c74..f6aed162ba790 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8691,8 +8691,8 @@ importers: specifier: ^4.17.21 version: 4.17.21 notion-to-md: - specifier: ^4.0.0-alpha.4 - version: 4.0.0-alpha.4(@notionhq/client@2.2.15) + specifier: 3.1.8 + version: 3.1.8 components/nozbe_teams: {} @@ -25866,11 +25866,9 @@ packages: resolution: {integrity: sha512-IO9QvjUMWxPQQhs60oOu10CRkWCiZzSUkzbXGGV9pviYl1fXYcvkzQ5jV9z8Y6un8ARoVRl4EtC6v6jNqbaJ/w==} engines: {node: '>=14.16'} - notion-to-md@4.0.0-alpha.4: - resolution: {integrity: sha512-MxK71vIj0l8jCDbzTAROp/2pXI8f2bhjJINuUk/uIlGKs2XPJCzYKFu+4ELvSG+DiNvmGWxdr+Dtba47fnULTg==} + notion-to-md@3.1.8: + resolution: {integrity: sha512-DuEslJAbmUG2IRVcoeiCdsE2tI8yXOG6NiHlzxYTcKMmkAtoj2Fgq35Gf5T8s92uzpT2ueVf3aCOq7XuVLVYOA==} engines: {node: '>=12'} - peerDependencies: - '@notionhq/client': ^2.0.0 npm-normalize-package-bin@1.0.1: resolution: {integrity: sha512-EPfafl6JL5/rU+ot6P3gRSCpPDW5VmIzX959Ob1+ySFUuuYHWHekXpwdUZcKP5C+DS4GEtdJluwBjnsNDl+fSA==} @@ -44336,10 +44334,9 @@ snapshots: normalize-url@8.0.1: {} - notion-to-md@4.0.0-alpha.4(@notionhq/client@2.2.15): + notion-to-md@3.1.8: dependencies: - '@notionhq/client': 2.2.15 - mime: 3.0.0 + markdown-table: 2.0.0 node-fetch: 2.7.0 transitivePeerDependencies: - encoding