Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/notion/actions/append-block/append-block.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions components/notion/actions/common/base-page-builder.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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],
}));
},
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
...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,
Expand Down Expand Up @@ -37,7 +37,7 @@
],
reloadProps: true,
},
alert: {

Check warning on line 40 in components/notion/actions/create-page-from-database/create-page-from-database.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop alert must have a label. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 40 in components/notion/actions/create-page-from-database/create-page-from-database.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop alert must have a description. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "info",
content: "This action will create an empty page by default. To add content, use the `pageContent` prop below.",
Expand Down
2 changes: 1 addition & 1 deletion components/notion/actions/create-page/create-page.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions components/notion/actions/duplicate-page/duplicate-page.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
56 changes: 47 additions & 9 deletions components/notion/actions/update-page/update-page.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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);
}
},
};
2 changes: 1 addition & 1 deletion components/notion/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/notion",
"version": "0.2.6",
"version": "0.2.7",
"description": "Pipedream Notion Components",
"main": "notion.app.mjs",
"keywords": [
Expand Down
3 changes: 1 addition & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading