diff --git a/components/notion/actions/append-block/append-block.mjs b/components/notion/actions/append-block/append-block.mjs index dbc581d1453e4..d96ec6c84c7b2 100644 --- a/components/notion/actions/append-block/append-block.mjs +++ b/components/notion/actions/append-block/append-block.mjs @@ -5,8 +5,9 @@ export default { ...base, key: "notion-append-block", name: "Append Block to Parent", - description: "Creates and appends blocks to the specified parent. [See the documentation](https://developers.notion.com/reference/patch-block-children)", - version: "0.2.17", + 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.0", type: "action", props: { notion, @@ -16,13 +17,27 @@ export default { "pageId", ], label: "Parent Block ID", - description: "The identifier for the parent block", + description: "Select a parent block/page or provide its ID", }, - blockObjects: { + blockTypes: { type: "string[]", - label: "Block Objects", - description: "This prop accepts an array of block objects to be appended. Using a custom expression in this prop is recommended.", - optional: true, + label: "Block Type(s)", + description: "Select which type(s) of block you'd like to append", + reloadProps: true, + options: [ + { + label: "Append existing blocks", + value: "blockIds", + }, + { + label: "Provide Markdown content to create new blocks with", + value: "markdownContents", + }, + { + label: "Provide Image URLs to create new image blocks", + value: "imageUrls", + }, + ], }, blockIds: { propDefinition: [ @@ -30,23 +45,37 @@ export default { "pageId", ], type: "string[]", - label: "Block IDs", - description: "Contents of selected blocks will be appended", - optional: true, + label: "Existing Block IDs", + description: "Select one or more block(s) or page(s) to append (selecting a page appends its children). You can also provide block or page IDs.", + hidden: true, }, - markupContents: { + markdownContents: { type: "string[]", - label: "Markup Contents", - description: "Content of new blocks to append. You must use Markdown syntax [See docs](https://www.notion.so/help/writing-and-editing-basics#markdown-&-shortcuts)", - optional: true, + label: "Markdown Contents", + description: + "Each entry is the content of a new block to append, using Markdown syntax. [See the documentation](https://www.notion.com/help/writing-and-editing-basics#markdown-and-shortcuts) for more information", + hidden: true, }, imageUrls: { type: "string[]", label: "Image URLs", - description: "List of URLs to append as image blocks", - optional: true, + description: "One or more Image URLs to append new image blocks with. [See the documentation](https://www.notion.com/help/images-files-and-media#media-block-types) for more information", + hidden: true, }, }, + additionalProps(currentProps) { + const { blockTypes } = this; + + for (let prop of [ + "blockIds", + "markdownContents", + "imageUrls", + ]) { + currentProps[prop].hidden = !blockTypes.includes(prop); + } + + return {}; + }, methods: { ...base.methods, chunkArray(array, chunkSize = 100) { @@ -58,19 +87,11 @@ export default { }, }, async run({ $ }) { + const { blockTypes } = this; const children = []; - // add blocks from blockObjects - if (this.blockObjects?.length > 0) { - for (const obj of this.blockObjects) { - const child = (typeof obj === "string") - ? JSON.parse(obj) - : obj; - children.push(child); - } - } // add blocks from blockIds - if (this.blockIds?.length > 0) { + if (blockTypes.includes("blockIds") && this.blockIds?.length > 0) { for (const id of this.blockIds) { const block = await this.notion.retrieveBlock(id); block.children = await this.notion.retrieveBlockChildren(block); @@ -80,15 +101,15 @@ export default { } // add blocks from markup - if (this.markupContents?.length > 0) { - for (const content of this.markupContents) { + if (blockTypes.includes("markdownContents") && this.markdownContents?.length > 0) { + for (const content of this.markdownContents) { const block = this.createBlocks(content); children.push(...block); } } // add image blocks - if (this.imageUrls?.length) { + if (blockTypes.includes("imageUrls") && this.imageUrls?.length) { for (const url of this.imageUrls) { children.push({ type: "image", @@ -111,7 +132,10 @@ export default { const chunks = this.chunkArray(children); for (const chunk of chunks) { - const { results: payload } = await this.notion.appendBlock(this.pageId, chunk); + const { results: payload } = await this.notion.appendBlock( + this.pageId, + chunk, + ); results.push(payload); } diff --git a/components/notion/actions/common/base-page-builder.mjs b/components/notion/actions/common/base-page-builder.mjs index af11d746910ac..145c6099b086f 100644 --- a/components/notion/actions/common/base-page-builder.mjs +++ b/components/notion/actions/common/base-page-builder.mjs @@ -39,7 +39,7 @@ export default { */ _buildPropDescription(type, example) { const typeName = type.replace(/_/g, "-"); - const description = `The type of this property is \`${type}\`. [See ${type} type docs here](https://developers.notion.com/reference/property-object#${typeName}).`; + const description = `The type of this property is \`${type}\`. [See ${type} type documentation here](https://developers.notion.com/reference/property-object#${typeName}).`; const descriptionExample = example ? `e.g. ${example}.` : ""; diff --git a/components/notion/actions/create-comment/create-comment.mjs b/components/notion/actions/create-comment/create-comment.mjs index 8471473e20d62..86e11f332cde0 100644 --- a/components/notion/actions/create-comment/create-comment.mjs +++ b/components/notion/actions/create-comment/create-comment.mjs @@ -4,23 +4,27 @@ import { ConfigurationError } from "@pipedream/platform"; export default { key: "notion-create-comment", name: "Create Comment", - description: "Creates a comment in a page or existing discussion thread. [See the documentation](https://developers.notion.com/reference/create-a-comment)", - version: "0.0.1", + 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.2", type: "action", props: { notion, + infoLabel: { + type: "alert", + alertType: "info", + content: "Provide either a Page ID or a Discussion ID to create the comment under.", + }, pageId: { propDefinition: [ notion, "pageId", ], - description: "Unique identifier of a page. Either this or a Discussion ID is required (not both)", optional: true, }, discussionId: { type: "string", label: "Discussion ID", - description: "A UUID identifier for a discussion thread. Either this or a Page ID is required (not both)", + description: "The ID of a discussion thread. [See the documentation](https://developers.notion.com/docs/working-with-comments#retrieving-a-discussion-id) for more information", optional: true, }, comment: { @@ -31,7 +35,7 @@ export default { }, async run({ $ }) { if ((this.pageId && this.discussionId) || (!this.pageId && !this.discussionId)) { - throw new ConfigurationError("Either a Page ID or a Discussion ID is required (not both)"); + throw new ConfigurationError("Provide either a page ID or a discussion thread ID to create the comment under"); } const response = await this.notion._getNotionClient().comments.create({ @@ -47,7 +51,7 @@ export default { }, ], }); - $.export("$summary", `Successfully added comment with ID: ${response.id}`); + $.export("$summary", `Successfully created comment (ID: ${response.id})`); return response; }, }; 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 971c77ec95102..2b22e89114bd3 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,8 +6,8 @@ export default { ...base, key: "notion-create-page-from-database", name: "Create Page from Database", - description: "Creates a page from a database. [See the documentation](https://developers.notion.com/reference/post-page)", - version: "0.1.15", + description: "Create a page from a database. [See the documentation](https://developers.notion.com/reference/post-page)", + version: "0.1.16", type: "action", props: { notion, @@ -17,7 +17,7 @@ export default { "databaseId", ], label: "Parent Database ID", - description: "The identifier for a Notion parent page", + description: "Select a parent database or provide a database ID", reloadProps: true, }, metaTypes: { @@ -40,13 +40,13 @@ export default { alert: { type: "alert", alertType: "info", - content: "This action will create an empty page by default. To add content, use the `pageContent` prop below.", + content: "This action will create an empty page by default. To add content, use the `Page Content` prop below.", }, pageContent: { - type: "string", - label: "Page Content", - description: "Content of the page. You can use Markdown syntax [See docs](https://www.notion.so/help/writing-and-editing-basics#markdown-&-shortcuts)", - optional: true, + propDefinition: [ + notion, + "pageContent", + ], }, }, async additionalProps() { diff --git a/components/notion/actions/create-page/create-page.mjs b/components/notion/actions/create-page/create-page.mjs index b818d7c3a92db..d26be9917e810 100644 --- a/components/notion/actions/create-page/create-page.mjs +++ b/components/notion/actions/create-page/create-page.mjs @@ -6,8 +6,8 @@ export default { ...base, key: "notion-create-page", name: "Create Page", - description: "Creates a page from a parent page. The only valid property is *title*. [See the documentation](https://developers.notion.com/reference/post-page)", - version: "0.2.13", + description: "Create a page from a parent page. [See the documentation](https://developers.notion.com/reference/post-page)", + version: "0.2.14", type: "action", props: { notion, @@ -17,7 +17,7 @@ export default { "pageId", ], label: "Parent Page ID", - description: "The identifier for a Notion parent page", + description: "Select a parent page or provide a page ID", reloadProps: true, }, title: { @@ -33,10 +33,10 @@ export default { ], }, pageContent: { - type: "string", - label: "Page Content", - description: "Content of the page. You can use Markdown syntax [See docs](https://www.notion.so/help/writing-and-editing-basics#markdown-&-shortcuts)", - optional: true, + propDefinition: [ + notion, + "pageContent", + ], }, }, async additionalProps() { diff --git a/components/notion/actions/duplicate-page/duplicate-page.mjs b/components/notion/actions/duplicate-page/duplicate-page.mjs index 6d21c41091280..f3872a47af34e 100644 --- a/components/notion/actions/duplicate-page/duplicate-page.mjs +++ b/components/notion/actions/duplicate-page/duplicate-page.mjs @@ -6,8 +6,8 @@ export default { ...base, key: "notion-duplicate-page", name: "Duplicate Page", - description: "Creates a new page copied from an existing page block. [See the documentation](https://developers.notion.com/reference/post-page)", - version: "0.0.9", + description: "Create a new page copied from an existing page block. [See the documentation](https://developers.notion.com/reference/post-page)", + version: "0.0.10", type: "action", props: { notion, @@ -16,7 +16,7 @@ export default { notion, "pageId", ], - description: "The page to copy", + description: "Select a page to copy or provide a page ID", }, title: { propDefinition: [ @@ -31,7 +31,7 @@ export default { "pageId", ], label: "Parent Page ID", - description: "The parent page of the new page being created", + description: "Select a parent page for the new page being created, or provide the ID of a parent page", }, }, async run({ $ }) { @@ -65,7 +65,7 @@ export default { const results = await this.notion.createPage(page); const pageName = this.notion.extractPageTitle(results); - $.export("$summary", `Successfully created the new page, "[${pageName}](${results.url})"`); + $.export("$summary", `Successfully created page "[${pageName}](${results.url})"`); return results; }, }; diff --git a/components/notion/actions/find-page/find-page.mjs b/components/notion/actions/find-page/find-page.mjs deleted file mode 100644 index bbf4c8291934d..0000000000000 --- a/components/notion/actions/find-page/find-page.mjs +++ /dev/null @@ -1,22 +0,0 @@ -import common from "../common/base-search.mjs"; - -export default { - ...common, - key: "notion-find-page", - name: "Find a Page", - description: "Searches for a page by its title. [See the docs](https://developers.notion.com/reference/post-search)", - version: "0.0.6", - type: "action", - methods: { - getSummary({ - response, title, - }) { - return `Found ${response.results.length} pages ${title - ? `with title search ${this.title}` - : ""}`; - }, - getFilter() { - return "page"; - }, - }, -}; diff --git a/components/notion/actions/query-database/query-database.mjs b/components/notion/actions/query-database/query-database.mjs index b7a03be37761c..1734228add3fd 100644 --- a/components/notion/actions/query-database/query-database.mjs +++ b/components/notion/actions/query-database/query-database.mjs @@ -4,8 +4,8 @@ import utils from "../../common/utils.mjs"; export default { key: "notion-query-database", name: "Query Database", - description: "Query a database. [See the docs](https://developers.notion.com/reference/post-database-query)", - version: "0.0.8", + description: "Query a database with a specified filter. [See the documentation](https://developers.notion.com/reference/post-database-query)", + version: "0.0.9", type: "action", props: { notion, @@ -16,8 +16,8 @@ export default { ], }, filter: { - label: "Filter", - description: "The filter to query. [See how filters work here](https://developers.notion.com/reference/post-database-query-filter). E.g. { \"property\": \"Email\", \"rich_text\": { \"contains\": \"gmail.com\" } }", + 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\" } }`", type: "string", }, }, @@ -28,7 +28,11 @@ export default { filter: utils.parseStringToJSON(filter), }); - $.export("$summary", "Retrieved database query result"); + const length = response?.results?.length; + + $.export("$summary", `Retrieved ${length} result${length === 1 + ? "" + : "s"}`); return response; }, diff --git a/components/notion/actions/retrieve-block/retrieve-block.mjs b/components/notion/actions/retrieve-block/retrieve-block.mjs index aeaccb92ae413..a049022cca6b5 100644 --- a/components/notion/actions/retrieve-block/retrieve-block.mjs +++ b/components/notion/actions/retrieve-block/retrieve-block.mjs @@ -3,8 +3,8 @@ import notion from "../../notion.app.mjs"; export default { key: "notion-retrieve-block", name: "Retrieve Block", - description: "Retrieves a block. A block object represents content within Notion. Blocks can be text, lists, media, and more. A page is also a type of block. [See the docs](https://developers.notion.com/reference/retrieve-a-block)", - version: "0.0.4", + description: "Get details of a block, which can be text, lists, media, a page, among others. [See the documentation](https://developers.notion.com/reference/retrieve-a-block)", + version: "0.0.5", type: "action", props: { notion, @@ -14,12 +14,12 @@ export default { "pageId", ], label: "Block ID", - description: "The identifier for a Notion block", + description: "Select a block or provide a block ID", }, retrieveChildren: { type: "boolean", - label: "Retrieve Block Children", - description: "Returns recursively all the children for the block ID specified. [See docs](https://developers.notion.com/reference/get-block-children)", + label: "Retrieve Children", + description: "Retrieve all the children (recursively) for the specified block. [See the documentation](https://developers.notion.com/reference/get-block-children) for more information", optional: true, default: false, }, @@ -29,7 +29,9 @@ export default { if (this.retrieveChildren) { block.children = await this.notion.retrieveBlockChildren(block); } - $.export("$summary", "Retrieved block successfully"); + $.export("$summary", `Successfully retrieved block${this.retrieveChildren + ? ` with ${block.children.length ?? 0} children` + : ""}`); return block; }, }; 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 7af746c5a9921..ffcd8cb6fd50c 100644 --- a/components/notion/actions/retrieve-database-content/retrieve-database-content.mjs +++ b/components/notion/actions/retrieve-database-content/retrieve-database-content.mjs @@ -3,8 +3,8 @@ import notion from "../../notion.app.mjs"; export default { key: "notion-retrieve-database-content", name: "Retrieve Database Content", - description: "Retreive the content of a database. [See the docs](https://developers.notion.com/reference/post-database-query)", - version: "0.0.3", + description: "Get all content of a database. [See the documentation](https://developers.notion.com/reference/post-database-query)", + version: "0.0.4", type: "action", props: { notion, @@ -17,7 +17,9 @@ export default { }, async run({ $ }) { const { results } = await this.notion.queryDatabase(this.databaseId); - $.export("$summary", "Retrieved database content"); + $.export("$summary", `Successfully retrieved ${results.length} object${results.length === 1 + ? "" + : "s"} in database`); return results; }, }; 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 40c614c3b0b6f..30152f8c47035 100644 --- a/components/notion/actions/retrieve-database-schema/retrieve-database-schema.mjs +++ b/components/notion/actions/retrieve-database-schema/retrieve-database-schema.mjs @@ -3,8 +3,8 @@ import notion from "../../notion.app.mjs"; export default { key: "notion-retrieve-database-schema", name: "Retrieve Database Schema", - description: "Retrieves a database object. Database objects describe the property schema of a database in Notion. [See the docs](https://developers.notion.com/reference/retrieve-a-database)", - version: "0.0.5", + description: "Get the property schema of a database in Notion. [See the documentation](https://developers.notion.com/reference/retrieve-a-database)", + version: "0.0.6", type: "action", props: { notion, @@ -17,7 +17,7 @@ export default { }, async run({ $ }) { const response = await this.notion.retrieveDatabase(this.databaseId); - $.export("$summary", "Retrieved database successfully"); + $.export("$summary", "Successfully retrieved database schema"); return response; }, }; 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 9ee0ec1ba09fe..8bb72609c4021 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 @@ -3,8 +3,8 @@ import notion from "../../notion.app.mjs"; export default { key: "notion-retrieve-page-property-item", name: "Retrieve Page Property Item", - description: "Retrieves a `property_item` object for a given `page_id` and `property_id`.", - version: "0.0.4", + 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.5", type: "action", props: { notion, @@ -29,7 +29,7 @@ export default { this.pageId, this.propertyId, ); - $.export("$summary", "Retrieved property item successfully"); + $.export("$summary", "Successfully retrieved property item"); return response; }, }; diff --git a/components/notion/actions/retrieve-page/retrieve-page.mjs b/components/notion/actions/retrieve-page/retrieve-page.mjs index f1af22c26eb28..15e234bc8787d 100644 --- a/components/notion/actions/retrieve-page/retrieve-page.mjs +++ b/components/notion/actions/retrieve-page/retrieve-page.mjs @@ -3,8 +3,8 @@ import notion from "../../notion.app.mjs"; export default { key: "notion-retrieve-page", name: "Retrieve Page", - description: "Retrieves a page. [See the docs](https://developers.notion.com/reference/retrieve-a-page)", - version: "0.0.4", + description: "Get details of a page. [See the documentation](https://developers.notion.com/reference/retrieve-a-page)", + version: "0.0.5", type: "action", props: { notion, @@ -17,7 +17,10 @@ export default { }, async run({ $ }) { const response = await this.notion.retrievePage(this.pageId); - $.export("$summary", "Retrieved page successfully"); + const title = response?.properties?.Name?.title[0]?.plain_text; + $.export("$summary", `Successfully retrieved page${title + ? ` "${title}"` + : ""}`); return response; }, }; diff --git a/components/notion/actions/search/search.mjs b/components/notion/actions/search/search.mjs index ff86e409c06fc..b65558756cdc8 100644 --- a/components/notion/actions/search/search.mjs +++ b/components/notion/actions/search/search.mjs @@ -3,19 +3,16 @@ import common from "../common/base-search.mjs"; export default { ...common, key: "notion-search", - name: "Search", - description: "Searches for a page or database. [See the docs](https://developers.notion.com/reference/post-search)", - version: "0.0.4", + 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.5", type: "action", props: { ...common.props, title: { - propDefinition: [ - common.props.notion, - "title", - ], - label: "Query", - description: "The object title.", + type: "string", + label: "Query (Title)", + description: "The object title to search for", }, filter: { propDefinition: [ @@ -25,14 +22,10 @@ export default { }, }, methods: { - getSummary({ - response, title, - }) { - return `Found ${response.results.length} object${response.results.length > 1 - ? "s" - : ""} ${title - ? `with query search ${this.title}` - : ""}`; + getSummary({ response }) { + return `Found ${response.results?.length} object${response.results?.length === 1 + ? "" + : "s"} with query search ${this.title}`; }, getFilter() { return this.filter; diff --git a/components/notion/actions/update-page/update-page.mjs b/components/notion/actions/update-page/update-page.mjs index b1fcdd6a7fa8b..a38141162c497 100644 --- a/components/notion/actions/update-page/update-page.mjs +++ b/components/notion/actions/update-page/update-page.mjs @@ -6,18 +6,23 @@ export default { ...base, key: "notion-update-page", name: "Update Page", - description: "Updates page property values for the specified page. Properties that are not set will remain unchanged. To append page content, use the *append block* action. [See the documentation](https://developers.notion.com/reference/patch-page)", - version: "1.1.3", + 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.4", type: "action", props: { notion, + infoLabel: { + type: "alert", + alertType: "info", + content: "Properties that are not set will remain unchanged.", + }, parent: { propDefinition: [ notion, "databaseId", ], label: "Parent Database ID", - description: "The identifier for a Notion parent database", + 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", reloadProps: true, }, pageId: { diff --git a/components/notion/notion.app.mjs b/components/notion/notion.app.mjs index 0d3d120c7e6b0..fb6cc9061aa5b 100644 --- a/components/notion/notion.app.mjs +++ b/components/notion/notion.app.mjs @@ -1,5 +1,6 @@ import notion from "@notionhq/client"; import NOTION_META from "./common/notion-meta-selection.mjs"; +import { ConfigurationError } from "@pipedream/platform"; export default { type: "app", @@ -8,7 +9,7 @@ export default { databaseId: { type: "string", label: "Database ID", - description: "The identifier for a Notion database", + description: "Select a database or provide a database ID", async options({ prevContext }) { const response = await this.listDatabases({ start_cursor: prevContext.nextPageParameters ?? undefined, @@ -20,7 +21,7 @@ export default { pageId: { type: "string", label: "Page ID", - description: "The identifier for a Notion page", + description: "Select a page or provide a page ID", async options({ prevContext }) { const response = await this.search(undefined, { start_cursor: prevContext.nextPageParameters ?? undefined, @@ -32,10 +33,11 @@ export default { pageIdInDatabase: { type: "string", label: "Page ID", - description: "The identifier for a Notion page", + description: "Select a page from the database or provide a page ID", async options({ prevContext, databaseId, }) { + this._checkOptionsContext(databaseId, "Database ID"); const response = await this.queryDatabase(databaseId, { start_cursor: prevContext.nextPageParameters ?? undefined, }); @@ -46,8 +48,9 @@ export default { propertyId: { type: "string", label: "Property ID", - description: "The identifier for a Notion page property", + description: "Select a page property or provide a property ID", async options({ pageId }) { + this._checkOptionsContext(pageId, "Page ID"); const response = await this.retrievePage(pageId); const parentType = response.parent.type; @@ -77,7 +80,7 @@ export default { metaTypes: { type: "string[]", label: "Meta Types", - description: "Select the page attributes such as icon and cover", + description: "Select one or more page attributes (such as icon and cover)", options: Object.keys(NOTION_META), optional: true, reloadProps: true, @@ -85,11 +88,12 @@ export default { propertyTypes: { type: "string[]", label: "Property Types", - description: "Select the page properties", + description: "Select one or more page properties", optional: true, async options({ parentId, parentType, }) { + this._checkOptionsContext(parentId, "Database ID"); try { const { properties } = parentType === "database" ? await this.retrieveDatabase(parentId) @@ -103,21 +107,20 @@ export default { }, archived: { type: "boolean", - label: "Archive page", - description: "Set to true to archive (delete) a page. Set to false to un-archive\ -(restore) a page.", + label: "Archive Page", + description: "Set to `true` to archive (delete) a page. Set to `false` to un-archive (restore) a page", optional: true, }, title: { type: "string", label: "Page Title", - description: "The page title. Defaults to `Untitled`.", + description: "The page title (defaults to `Untitled`)", optional: true, }, userIds: { type: "string[]", label: "Users", - description: "A list of users", + description: "Select one or more users, or provide user IDs", async options() { const users = await this.getUsers(); @@ -130,7 +133,7 @@ export default { sortDirection: { type: "string", label: "Sort Direction", - description: "The direction to sort.", + description: "The direction to sort by", optional: true, options: [ "ascending", @@ -140,28 +143,41 @@ export default { pageSize: { type: "integer", label: "Page Size", - description: "The number of items from the full list desired in the response. Maximum: 100", + description: "The number of items from the full list desired in the response (max 100)", default: 100, + min: 1, + max: 100, optional: true, }, startCursor: { type: "string", label: "Start Cursor (page_id)", - description: "If supplied, this endpoint will return a page of results starting after the cursor provided. If not supplied, this endpoint will return the first page of results.", + description: "Leave blank to retrieve the first page of results. Otherwise, the response will be the page of results starting after the provided cursor", optional: true, }, filter: { type: "string", - label: "Filter", - description: "The value of the property to filter the results by. Possible values for object type include `page` or `database`. Limitation: Currently the only filter allowed is `object` which will filter by type of object (either `page` or `database`)", + label: "Page or Database", + description: "Whether to search for pages or databases", optional: true, options: [ "page", "database", ], }, + pageContent: { + type: "string", + label: "Page Content", + description: "The content of the page, using Markdown syntax. [See the documentation](https://www.notion.com/help/writing-and-editing-basics#markdown-and-shortcuts) for more information", + optional: true, + }, }, methods: { + _checkOptionsContext(value, name) { + if (value.match(/{{\s?steps/)) { + throw new ConfigurationError(`Please use a custom expression to reference a previous value, since you are also using one for \`${name}\``); + } + }, _getNotionClient() { return new notion.Client({ auth: this.$auth.oauth_access_token, diff --git a/components/notion/package.json b/components/notion/package.json index c06202a516975..b8f2af93970a2 100644 --- a/components/notion/package.json +++ b/components/notion/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/notion", - "version": "0.3.0", + "version": "0.4.0", "description": "Pipedream Notion Components", "main": "notion.app.mjs", "keywords": [ @@ -13,18 +13,7 @@ "@notionhq/client": "^2.2.3", "@pipedream/platform": "^3.0.3", "@tryfabric/martian": "^1.2.4", - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "delayed-stream": "^1.0.0", - "form-data": "^3.0.1", - "lodash-es": "^4.17.21", - "md5": "^2.3.0", - "mime-db": "^1.52.0", - "mime-types": "^2.1.35", - "node-fetch": "^2.6.7", - "tr46": "^0.0.3", - "webidl-conversions": "^3.0.1", - "whatwg-url": "^5.0.0" + "lodash-es": "^4.17.21" }, "publishConfig": { "access": "public" diff --git a/components/notion/sources/common/base.mjs b/components/notion/sources/common/base.mjs index 954e5abf3b9e5..b2340a2a4dd4e 100644 --- a/components/notion/sources/common/base.mjs +++ b/components/notion/sources/common/base.mjs @@ -47,7 +47,7 @@ export default { return { id, - summary: `${summary}: ${title} - ${id}`, + summary: `${summary}: ${title || id}`, ts, }; }, 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 b8b04ae1ebb5a..99e6a361d3f18 100644 --- a/components/notion/sources/new-comment-created/new-comment-created.mjs +++ b/components/notion/sources/new-comment-created/new-comment-created.mjs @@ -5,26 +5,38 @@ 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.1", + version: "0.0.2", type: "source", dedupe: "unique", props: { ...base.props, + infoLabel: { + type: "alert", + alertType: "info", + content: "Ensure the selected page is shared with your Pipedream integration to receive events.", + }, pageId: { propDefinition: [ base.props.notion, "pageId", ], - description: "Unique identifier of a page or block", + description: "Select the page to watch for new comments, or provide a page ID", }, }, methods: { ...base.methods, generateMeta(comment) { + const { id } = comment; + const text = comment.rich_text?.[0]?.plain_text; + const summary = text + ? `"${text.length > 40 + ? text.slice(0, 35) + "[...]" + : text}"` + : `ID ${id}`; return { - id: comment.id, - summary: `New Comment ID: ${comment.id}`, - ts: comment.created_time, + id, + summary: `New Comment: ${summary}`, + ts: Date.parse(comment.created_time), }; }, }, diff --git a/components/notion/sources/new-database/new-database.mjs b/components/notion/sources/new-database/new-database.mjs index 7b8bad6a0728b..dd8669d0357c6 100644 --- a/components/notion/sources/new-database/new-database.mjs +++ b/components/notion/sources/new-database/new-database.mjs @@ -5,10 +5,18 @@ import constants from "../common/constants.mjs"; export default { ...base, key: "notion-new-database", - name: "New Database", - description: "Emit new event when a database is created. Note: Databases must be shared with your Pipedream Integtration to trigger event.", - version: "0.0.8", + 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.9", 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(); diff --git a/components/notion/sources/new-page/new-page.mjs b/components/notion/sources/new-page/new-page.mjs index 6a33e004f0eff..de1f75b0785b4 100644 --- a/components/notion/sources/new-page/new-page.mjs +++ b/components/notion/sources/new-page/new-page.mjs @@ -7,8 +7,8 @@ export default { ...base, key: "notion-new-page", name: "New Page in Database", - description: "Emit new event when a page in a database is created", - version: "0.0.10", + 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.11", 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 ca198883b96ee..92461540fe57d 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 @@ -6,12 +6,17 @@ export default { ...base, key: "notion-page-or-subpage-updated", name: "Page or Subpage Updated", /* eslint-disable-line pipedream/source-name */ - description: "Emit new event when a page or one of its sub-pages is updated.", - version: "0.0.6", + 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.7", type: "source", dedupe: "unique", props: { ...base.props, + infoLabel: { + type: "alert", + alertType: "info", + content: "Ensure the selected page is shared with your Pipedream integration to receive events.", + }, pageId: { propDefinition: [ base.props.notion, 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 d3e4b49e5d1f8..528452682e792 100644 --- a/components/notion/sources/updated-page-id/updated-page-id.mjs +++ b/components/notion/sources/updated-page-id/updated-page-id.mjs @@ -5,13 +5,18 @@ import constants from "../common/constants.mjs"; export default { ...base, key: "notion-updated-page-id", - name: "Updated Page ID", /* eslint-disable-line pipedream/source-name */ - description: "Emit new event when a selected page is updated", - version: "0.0.5", + 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.6", type: "source", dedupe: "unique", props: { ...base.props, + infoLabel: { + type: "alert", + alertType: "info", + content: "Ensure the selected page is shared with your Pipedream integration to receive events.", + }, pageId: { propDefinition: [ notion, diff --git a/components/notion/sources/updated-page/updated-page.mjs b/components/notion/sources/updated-page/updated-page.mjs index 8df7f1e15855b..e5d718b3c3083 100644 --- a/components/notion/sources/updated-page/updated-page.mjs +++ b/components/notion/sources/updated-page/updated-page.mjs @@ -7,9 +7,9 @@ import zlib from "zlib"; export default { ...base, key: "notion-updated-page", - name: "Updated Page in Database", /* eslint-disable-line pipedream/source-name */ - description: "Emit new event when a page in a database is updated. To select a specific page, use `Updated Page ID` instead", - version: "0.1.4", + 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.5", type: "source", dedupe: "unique", props: { @@ -23,7 +23,7 @@ export default { includeNewPages: { type: "boolean", label: "Include New Pages", - description: "Set to `true` to emit events when pages are created. Set to `false` to ignore new pages.", + description: "Set to `false` to emit events only for updates, not for new pages.", default: true, }, properties: { @@ -40,7 +40,7 @@ export default { }, alert: { type: "alert", - alertType: "info", + alertType: "warning", content: "Source not saving? Your database might be too large. If deployment takes longer than one minute, an error will occur.", }, }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d521b9d3b386d..d6fdba023b6ec 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8495,42 +8495,9 @@ importers: '@tryfabric/martian': specifier: ^1.2.4 version: 1.2.4 - asynckit: - specifier: ^0.4.0 - version: 0.4.0 - combined-stream: - specifier: ^1.0.8 - version: 1.0.8 - delayed-stream: - specifier: ^1.0.0 - version: 1.0.0 - form-data: - specifier: ^3.0.1 - version: 3.0.2 lodash-es: specifier: ^4.17.21 version: 4.17.21 - md5: - specifier: ^2.3.0 - version: 2.3.0 - mime-db: - specifier: ^1.52.0 - version: 1.53.0 - mime-types: - specifier: ^2.1.35 - version: 2.1.35 - node-fetch: - specifier: ^2.6.7 - version: 2.7.0 - tr46: - specifier: ^0.0.3 - version: 0.0.3 - webidl-conversions: - specifier: ^3.0.1 - version: 3.0.1 - whatwg-url: - specifier: ^5.0.0 - version: 5.0.0 components/nozbe_teams: {}