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 @@ -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.3",
version: "0.3.4",
type: "action",
props: {
notion,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import notion from "../../notion.app.mjs";
import base from "../common/base-page-builder.mjs";
import pick from "lodash-es/pick.js";
import NOTION_ICONS from "../../common/notion-icons.mjs";
import utils from "../../common/utils.mjs";

export default {
...base,
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.18",
version: "0.2.0",
type: "action",
props: {
notion,
Expand All @@ -18,26 +19,32 @@
],
label: "Parent Database ID",
description: "Select a parent database or provide a database ID",
reloadProps: true,
},
metaTypes: {
propDefinition: [
notion,
"metaTypes",
],
Name: {
type: "string",
label: "Name",
description: "The name of the page",
},
propertyTypes: {
propDefinition: [
notion,
"propertyTypes",
(c) => ({
parentId: c.parent,
parentType: "database",
}),
],
reloadProps: true,
properties: {
type: "object",
label: "Properties",
description: "The values of the page's properties. The schema must match the parent database's properties. [See the documentation](https://developers.notion.com/reference/property-object) for information on various property types. Example: `{ \"Tags\": [ \"tag1\" ], \"Link\": \"https://pipedream.com\" }`",
optional: true,
},
icon: {
type: "string",
label: "Icon Emoji",
description: "Page Icon [Emoji](https://developers.notion.com/reference/emoji-object)",
options: NOTION_ICONS,
optional: true,
},
cover: {
type: "string",
label: "Cover URL",
description: "Cover [External URL](https://developers.notion.com/reference/file-object#external-file-objects)",
optional: true,
},
alert: {

Check warning on line 47 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

Check warning on line 47 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
type: "alert",
alertType: "info",
content: "This action will create an empty page by default. To add content, use the `Page Content` prop below.",
Expand All @@ -49,14 +56,6 @@
],
},
},
async additionalProps() {
const { properties } = await this.notion.retrieveDatabase(this.parent);
const selectedProperties = pick(properties, this.propertyTypes);
return this.buildAdditionalProps({
properties: selectedProperties,
meta: this.metaTypes,
});
},
methods: {
...base.methods,
/**
Expand All @@ -66,6 +65,7 @@
*/
buildPage(parentDatabase) {
const meta = this.buildDatabaseMeta(parentDatabase);
this.properties = utils.parseObject(this.properties);
const properties = this.buildPageProperties(parentDatabase.properties);
const children = this.createBlocks(this.pageContent);
return {
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: "Create a page from a parent page. [See the documentation](https://developers.notion.com/reference/post-page)",
version: "0.2.16",
version: "0.2.17",
type: "action",
props: {
notion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.13",
version: "0.0.14",
type: "action",
props: {
notion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.11",
version: "0.0.12",
type: "action",
props: {
notion,
Expand Down
2 changes: 1 addition & 1 deletion components/notion/actions/update-page/update-page.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
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.6",
version: "1.1.7",
type: "action",
props: {
notion,
infoLabel: {

Check warning on line 14 in components/notion/actions/update-page/update-page.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

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

Check warning on line 14 in components/notion/actions/update-page/update-page.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop infoLabel must have a label. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "info",
content: "Properties that are not set will remain unchanged.",
Expand Down
27 changes: 27 additions & 0 deletions components/notion/common/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,35 @@ function parseArray(value) {
: value;
}

function parseObject(obj) {
if (!obj) {
return {};
}
if (typeof obj === "string") {
try {
return JSON.parse(obj);
} catch {
return obj;
}
}
if (Array.isArray(obj)) {
return obj.map(parseObject);
}
if (typeof obj === "object") {
return Object.fromEntries(Object.entries(obj).map(([
key,
value,
]) => [
key,
parseObject(value),
]));
}
return obj;
}

export default {
buildTextProperty,
parseStringToJSON,
parseArray,
parseObject,
};
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.6.2",
"version": "0.7.0",
"description": "Pipedream Notion Components",
"main": "notion.app.mjs",
"keywords": [
Expand Down
6 changes: 2 additions & 4 deletions pnpm-lock.yaml

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

Loading