Skip to content

Commit 84ca40d

Browse files
committed
Improvements
1 parent 8dc6a6e commit 84ca40d

File tree

2 files changed

+17
-30
lines changed

2 files changed

+17
-30
lines changed

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

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,44 +26,32 @@ export default {
2626
reloadProps: true,
2727
options: [
2828
{
29-
label:
30-
"Use objects of existing blocks (e.g. objects returned from previous steps)",
31-
value: "blockObjects",
32-
},
33-
{
34-
label: "Select existing blocks or provide their IDs",
29+
label: "Append existing blocks",
3530
value: "blockIds",
3631
},
3732
{
3833
label: "Provide Markdown content to create new blocks with",
39-
value: "markupContents",
34+
value: "markdownContents",
4035
},
4136
{
4237
label: "Provide Image URLs to create new image blocks",
4338
value: "imageUrls",
4439
},
4540
],
4641
},
47-
blockObjects: {
48-
type: "string[]",
49-
label: "Block Objects",
50-
description:
51-
"An array of block objects to be appended. You can use a custom expression to reference block objects from previous steps. [See the documentation](https://developers.notion.com/reference/block) for more information",
52-
hidden: true,
53-
},
5442
blockIds: {
5543
propDefinition: [
5644
notion,
5745
"pageId",
5846
],
5947
type: "string[]",
60-
label: "Block IDs",
48+
label: "Existing Block IDs",
6149
description: "Select one or more block(s) or page(s) to append (selecting a page appends its children). You can also provide block or page IDs.",
6250
hidden: true,
6351
},
64-
markupContents: {
52+
markdownContents: {
6553
type: "string[]",
66-
label: "Markup Contents",
54+
label: "Markdown Contents",
6755
description:
6856
"Each entry is the content of a new block to append, using Markdown syntax. [See the documentation](https://www.notion.com/help/writing-and-editing-basics#markdown-and-shortcuts) for more information",
6957
hidden: true,
@@ -79,9 +67,8 @@ export default {
7967
const { blockTypes } = this;
8068

8169
for (let prop of [
82-
"blockObjects",
8370
"blockIds",
84-
"markupContents",
71+
"markdownContents",
8572
"imageUrls",
8673
]) {
8774
currentProps[prop].hidden = !blockTypes.includes(prop);
@@ -102,15 +89,6 @@ export default {
10289
async run({ $ }) {
10390
const { blockTypes } = this;
10491
const children = [];
105-
// add blocks from blockObjects
106-
if (blockTypes.includes("blockObjects") && this.blockObjects?.length > 0) {
107-
for (const obj of this.blockObjects) {
108-
const child = typeof obj === "string"
109-
? JSON.parse(obj)
110-
: obj;
111-
children.push(child);
112-
}
113-
}
11492

11593
// add blocks from blockIds
11694
if (blockTypes.includes("blockIds") && this.blockIds?.length > 0) {
@@ -123,8 +101,8 @@ export default {
123101
}
124102

125103
// add blocks from markup
126-
if (blockTypes.includes("markupContents") && this.markupContents?.length > 0) {
127-
for (const content of this.markupContents) {
104+
if (blockTypes.includes("markdownContents") && this.markdownContents?.length > 0) {
105+
for (const content of this.markdownContents) {
128106
const block = this.createBlocks(content);
129107
children.push(...block);
130108
}

components/notion/notion.app.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import notion from "@notionhq/client";
22
import NOTION_META from "./common/notion-meta-selection.mjs";
3+
import { ConfigurationError } from "@pipedream/platform";
34

45
export default {
56
type: "app",
@@ -36,6 +37,7 @@ export default {
3637
async options({
3738
prevContext, databaseId,
3839
}) {
40+
this._checkOptionsContext(databaseId, "Database ID");
3941
const response = await this.queryDatabase(databaseId, {
4042
start_cursor: prevContext.nextPageParameters ?? undefined,
4143
});
@@ -48,6 +50,7 @@ export default {
4850
label: "Property ID",
4951
description: "Select a page property or provide a property ID",
5052
async options({ pageId }) {
53+
this._checkOptionsContext(pageId, "Page ID");
5154
const response = await this.retrievePage(pageId);
5255

5356
const parentType = response.parent.type;
@@ -90,6 +93,7 @@ export default {
9093
async options({
9194
parentId, parentType,
9295
}) {
96+
this._checkOptionsContext(parentId, "Database ID");
9397
try {
9498
const { properties } = parentType === "database"
9599
? await this.retrieveDatabase(parentId)
@@ -169,6 +173,11 @@ export default {
169173
},
170174
},
171175
methods: {
176+
_checkOptionsContext(value, name) {
177+
if (value.match(/{{\s?steps/)) {
178+
throw new ConfigurationError(`Please use a custom expression to reference a previous value, since you are also using one for \`${name}\``);
179+
}
180+
},
172181
_getNotionClient() {
173182
return new notion.Client({
174183
auth: this.$auth.oauth_access_token,

0 commit comments

Comments
 (0)