Skip to content

Commit bd6ad10

Browse files
committed
dynamic properties
1 parent 6acf667 commit bd6ad10

File tree

7 files changed

+31
-17
lines changed

7 files changed

+31
-17
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "notion-append-block",
77
name: "Append Block to Parent",
88
description: "Creates and appends blocks to the specified parent. [See the documentation](https://developers.notion.com/reference/patch-block-children)",
9-
version: "0.2.16",
9+
version: "0.2.17",
1010
type: "action",
1111
props: {
1212
notion,

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,12 @@ export default {
7979
*/
8080
_filterProps(properties = {}) {
8181
return Object.keys(properties)
82-
.filter((property) => this[property] != null)
82+
.filter((property) => this[property] != null
83+
|| (this.properties && this.properties[property]))
8384
.map((property) => ({
8485
type: properties[property]?.type ?? property,
8586
label: property,
86-
value: this[property],
87+
value: this[property] || this.properties[property],
8788
}));
8889
},
8990
/**

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ export default {
66
...base,
77
key: "notion-create-page-from-database",
88
name: "Create Page from Database",
9-
description: "Creates a page from a database. [See the docs](https://developers.notion.com/reference/post-page)",
10-
version: "0.1.14",
9+
description: "Creates a page from a database. [See the documentation](https://developers.notion.com/reference/post-page)",
10+
version: "0.1.15",
1111
type: "action",
1212
props: {
1313
notion,

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

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ export default {
66
...base,
77
key: "notion-duplicate-page",
88
name: "Duplicate Page",
9-
description: "Creates a new page copied from an existing page block. [See the docs](https://developers.notion.com/reference/post-page)",
10-
version: "0.0.8",
9+
description: "Creates a new page copied from an existing page block. [See the documentation](https://developers.notion.com/reference/post-page)",
10+
version: "0.0.9",
1111
type: "action",
1212
props: {
1313
notion,

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

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ export default {
66
...base,
77
key: "notion-update-page",
88
name: "Update Page",
9-
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)",
10-
version: "1.1.2",
9+
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)",
10+
version: "1.1.3",
1111
type: "action",
1212
props: {
1313
notion,
@@ -54,13 +54,23 @@ export default {
5454
},
5555
},
5656
async additionalProps() {
57-
const { properties } = await this.notion.retrieveDatabase(this.parent);
58-
const selectedProperties = pick(properties, this.propertyTypes);
57+
try {
58+
const { properties } = await this.notion.retrieveDatabase(this.parent);
59+
const selectedProperties = pick(properties, this.propertyTypes);
5960

60-
return this.buildAdditionalProps({
61-
properties: selectedProperties,
62-
meta: this.metaTypes,
63-
});
61+
return this.buildAdditionalProps({
62+
properties: selectedProperties,
63+
meta: this.metaTypes,
64+
});
65+
} catch {
66+
return {
67+
properties: {
68+
type: "object",
69+
label: "Properties",
70+
description: "Enter the page properties as a JSON object",
71+
},
72+
};
73+
}
6474
},
6575
methods: {
6676
...base.methods,
@@ -80,6 +90,9 @@ export default {
8090
},
8191
async run({ $ }) {
8292
try {
93+
if (this.properties && typeof this.properties === "string") {
94+
this.properties = JSON.parse(this.properties);
95+
}
8396
const currentPage = await this.notion.retrievePage(this.pageId);
8497
const page = this.buildPage(currentPage);
8598
const response = await this.notion.updatePage(this.pageId, page);

components/notion/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/notion",
3-
"version": "0.2.6",
3+
"version": "0.2.7",
44
"description": "Pipedream Notion Components",
55
"main": "notion.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)