diff --git a/components/notion/actions/append-block/append-block.mjs b/components/notion/actions/append-block/append-block.mjs index 9c1be436470c0..dbc581d1453e4 100644 --- a/components/notion/actions/append-block/append-block.mjs +++ b/components/notion/actions/append-block/append-block.mjs @@ -6,7 +6,7 @@ export default { 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.16", + version: "0.2.17", type: "action", props: { notion, diff --git a/components/notion/actions/common/base-page-builder.mjs b/components/notion/actions/common/base-page-builder.mjs index 31c3a8c99cc32..af11d746910ac 100644 --- a/components/notion/actions/common/base-page-builder.mjs +++ b/components/notion/actions/common/base-page-builder.mjs @@ -79,11 +79,12 @@ export default { */ _filterProps(properties = {}) { return Object.keys(properties) - .filter((property) => this[property] != null) + .filter((property) => this[property] != null + || (this.properties && this.properties[property])) .map((property) => ({ type: properties[property]?.type ?? property, label: property, - value: this[property], + value: this[property] || this.properties[property], })); }, /** 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 c0c71904fb112..971c77ec95102 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 docs](https://developers.notion.com/reference/post-page)", - version: "0.1.14", + description: "Creates a page from a database. [See the documentation](https://developers.notion.com/reference/post-page)", + version: "0.1.15", 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 70fca6573e189..b818d7c3a92db 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: "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.12", + version: "0.2.13", 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 fa7b22d26eb7f..6d21c41091280 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 docs](https://developers.notion.com/reference/post-page)", - version: "0.0.8", + 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", type: "action", props: { notion, diff --git a/components/notion/actions/update-page/update-page.mjs b/components/notion/actions/update-page/update-page.mjs index df6c194eaa631..b1fcdd6a7fa8b 100644 --- a/components/notion/actions/update-page/update-page.mjs +++ b/components/notion/actions/update-page/update-page.mjs @@ -6,8 +6,8 @@ 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 docs](https://developers.notion.com/reference/patch-page)", - version: "1.1.2", + 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", type: "action", props: { notion, @@ -54,13 +54,23 @@ export default { }, }, async additionalProps() { - const { properties } = await this.notion.retrieveDatabase(this.parent); - const selectedProperties = pick(properties, this.propertyTypes); + try { + const { properties } = await this.notion.retrieveDatabase(this.parent); + const selectedProperties = pick(properties, this.propertyTypes); - return this.buildAdditionalProps({ - properties: selectedProperties, - meta: this.metaTypes, - }); + return this.buildAdditionalProps({ + properties: selectedProperties, + meta: this.metaTypes, + }); + } catch { + return { + properties: { + type: "object", + label: "Properties", + description: "The property values to update for the page. The keys are the names or IDs of the property and the values are property values. If a page property ID is not included, then it is not changed. Example: `{ \"Name\": \"Tuscan Kale\", \"Description\": \"A dark green leafy vegetable\" }`", + }, + }; + } }, methods: { ...base.methods, @@ -77,16 +87,44 @@ export default { properties, }; }, + parseProperties(properties) { + if (!properties) { + return undefined; + } + if (typeof properties === "string") { + try { + return JSON.parse(properties); + } catch { + throw new Error("Could not parse properties as JSON object"); + } + } + const parsedProperties = {}; + for (const [ + key, + value, + ] of Object.entries(properties)) { + try { + parsedProperties[key] = typeof value === "string" + ? JSON.parse(value) + : value; + } catch { + parsedProperties[key] = value; + } + } + return parsedProperties; + }, }, async run({ $ }) { try { + this.properties = this.parseProperties(this.properties); + const currentPage = await this.notion.retrievePage(this.pageId); const page = this.buildPage(currentPage); const response = await this.notion.updatePage(this.pageId, page); $.export("$summary", "Updated page successfully"); return response; } catch (error) { - throw new Error(error.body); + throw new Error(error.body || error); } }, }; diff --git a/components/notion/package.json b/components/notion/package.json index 72bfe730977f0..8d9c22a9dd694 100644 --- a/components/notion/package.json +++ b/components/notion/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/notion", - "version": "0.2.6", + "version": "0.2.7", "description": "Pipedream Notion Components", "main": "notion.app.mjs", "keywords": [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b3349d11d314b..927835c79122b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1499,8 +1499,7 @@ importers: components/call_fire: {} - components/callerapi: - specifiers: {} + components/callerapi: {} components/callhub: dependencies: