Skip to content

Commit 7224a54

Browse files
authored
Notion - create-page-from-database update props (#17471)
* update properties * pnpm-lock.yaml * versions
1 parent 640fb76 commit 7224a54

File tree

8 files changed

+59
-32
lines changed

8 files changed

+59
-32
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
name: "Append Block to Parent",
88
description:
99
"Append new and/or existing blocks to the specified parent. [See the documentation](https://developers.notion.com/reference/patch-block-children)",
10-
version: "0.3.3",
10+
version: "0.3.4",
1111
type: "action",
1212
props: {
1313
notion,

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

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import notion from "../../notion.app.mjs";
22
import base from "../common/base-page-builder.mjs";
3-
import pick from "lodash-es/pick.js";
3+
import NOTION_ICONS from "../../common/notion-icons.mjs";
4+
import utils from "../../common/utils.mjs";
45

56
export default {
67
...base,
78
key: "notion-create-page-from-database",
89
name: "Create Page from Database",
910
description: "Create a page from a database. [See the documentation](https://developers.notion.com/reference/post-page)",
10-
version: "0.1.18",
11+
version: "0.2.0",
1112
type: "action",
1213
props: {
1314
notion,
@@ -18,24 +19,30 @@ export default {
1819
],
1920
label: "Parent Database ID",
2021
description: "Select a parent database or provide a database ID",
21-
reloadProps: true,
2222
},
23-
metaTypes: {
24-
propDefinition: [
25-
notion,
26-
"metaTypes",
27-
],
23+
Name: {
24+
type: "string",
25+
label: "Name",
26+
description: "The name of the page",
2827
},
29-
propertyTypes: {
30-
propDefinition: [
31-
notion,
32-
"propertyTypes",
33-
(c) => ({
34-
parentId: c.parent,
35-
parentType: "database",
36-
}),
37-
],
38-
reloadProps: true,
28+
properties: {
29+
type: "object",
30+
label: "Properties",
31+
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\" }`",
32+
optional: true,
33+
},
34+
icon: {
35+
type: "string",
36+
label: "Icon Emoji",
37+
description: "Page Icon [Emoji](https://developers.notion.com/reference/emoji-object)",
38+
options: NOTION_ICONS,
39+
optional: true,
40+
},
41+
cover: {
42+
type: "string",
43+
label: "Cover URL",
44+
description: "Cover [External URL](https://developers.notion.com/reference/file-object#external-file-objects)",
45+
optional: true,
3946
},
4047
alert: {
4148
type: "alert",
@@ -49,14 +56,6 @@ export default {
4956
],
5057
},
5158
},
52-
async additionalProps() {
53-
const { properties } = await this.notion.retrieveDatabase(this.parent);
54-
const selectedProperties = pick(properties, this.propertyTypes);
55-
return this.buildAdditionalProps({
56-
properties: selectedProperties,
57-
meta: this.metaTypes,
58-
});
59-
},
6059
methods: {
6160
...base.methods,
6261
/**
@@ -66,6 +65,7 @@ export default {
6665
*/
6766
buildPage(parentDatabase) {
6867
const meta = this.buildDatabaseMeta(parentDatabase);
68+
this.properties = utils.parseObject(this.properties);
6969
const properties = this.buildPageProperties(parentDatabase.properties);
7070
const children = this.createBlocks(this.pageContent);
7171
return {

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: "Create a page from a parent page. [See the documentation](https://developers.notion.com/reference/post-page)",
10-
version: "0.2.16",
10+
version: "0.2.17",
1111
type: "action",
1212
props: {
1313
notion,

components/notion/actions/duplicate-page/duplicate-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-duplicate-page",
88
name: "Duplicate Page",
99
description: "Create a new page copied from an existing page block. [See the documentation](https://developers.notion.com/reference/post-page)",
10-
version: "0.0.13",
10+
version: "0.0.14",
1111
type: "action",
1212
props: {
1313
notion,

components/notion/actions/query-database/query-database.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "notion-query-database",
66
name: "Query Database",
77
description: "Query a database with a specified filter. [See the documentation](https://developers.notion.com/reference/post-database-query)",
8-
version: "0.0.11",
8+
version: "0.0.12",
99
type: "action",
1010
props: {
1111
notion,

components/notion/actions/update-page/update-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-update-page",
88
name: "Update Page",
99
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)",
10-
version: "1.1.6",
10+
version: "1.1.7",
1111
type: "action",
1212
props: {
1313
notion,

components/notion/common/utils.mjs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,35 @@ function parseArray(value) {
3030
: value;
3131
}
3232

33+
function parseObject(obj) {
34+
if (!obj) {
35+
return {};
36+
}
37+
if (typeof obj === "string") {
38+
try {
39+
return JSON.parse(obj);
40+
} catch {
41+
return obj;
42+
}
43+
}
44+
if (Array.isArray(obj)) {
45+
return obj.map(parseObject);
46+
}
47+
if (typeof obj === "object") {
48+
return Object.fromEntries(Object.entries(obj).map(([
49+
key,
50+
value,
51+
]) => [
52+
key,
53+
parseObject(value),
54+
]));
55+
}
56+
return obj;
57+
}
58+
3359
export default {
3460
buildTextProperty,
3561
parseStringToJSON,
3662
parseArray,
63+
parseObject,
3764
};

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.6.2",
3+
"version": "0.7.0",
44
"description": "Pipedream Notion Components",
55
"main": "notion.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)