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
26 changes: 22 additions & 4 deletions 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.13",
version: "0.2.14",
type: "action",
props: {
notion,
Expand Down Expand Up @@ -47,6 +47,15 @@ export default {
optional: true,
},
},
methods: {
chunkArray(array, chunkSize = 100) {
const chunks = [];
for (let i = 0; i < array.length; i += chunkSize) {
chunks.push(array.slice(i, i + chunkSize));
}
return chunks;
},
},
async run({ $ }) {
const children = [];
// add blocks from blockObjects
Expand Down Expand Up @@ -97,8 +106,17 @@ export default {
return;
}

const { results } = await this.notion.appendBlock(this.pageId, children);
$.export("$summary", `Appended ${results.length} block(s) successfully`);
return results;
const results = [];
const chunks = this.chunkArray(children);

for (const chunk of chunks) {
const { results: payload } = await this.notion.appendBlock(this.pageId, chunk);
results.push(payload);
}

const totalAppended = results.reduce((sum, res) => sum + res.length, 0);

$.export("$summary", `Appended ${totalAppended} block(s) successfully`);
return results.flat();
},
};
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.1.19",
"version": "0.1.20",
"description": "Pipedream Notion Components",
"main": "notion.app.mjs",
"keywords": [
Expand Down
Loading