Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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 {
key: "notion-append-block",
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.4.0",
version: "0.4.1",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "notion-complete-file-upload",
name: "Complete File Upload",
description: "Use this action to finalize a `mode=multi_part` file upload after all of the parts have been sent successfully. [See the documentation](https://developers.notion.com/reference/complete-a-file-upload)",
version: "0.0.7",
version: "0.0.8",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
key: "notion-create-comment",
name: "Create Comment",
description: "Create a comment in a page or existing discussion thread. [See the documentation](https://developers.notion.com/reference/create-a-comment)",
version: "0.0.9",
version: "0.0.10",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand All @@ -14,7 +14,7 @@
type: "action",
props: {
notion,
infoLabel: {

Check warning on line 17 in components/notion/actions/create-comment/create-comment.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 17 in components/notion/actions/create-comment/create-comment.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: "Provide either a Page ID or a Discussion ID to create the comment under.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
key: "notion-create-database",
name: "Create Database",
description: "Create a database and its initial data source. [See the documentation](https://developers.notion.com/reference/database-create)",
version: "0.1.4",
version: "0.1.5",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "notion-create-file-upload",
name: "Create File Upload",
description: "Create a file upload. [See the documentation](https://developers.notion.com/reference/create-a-file-upload)",
version: "0.0.7",
version: "0.0.8",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
/* eslint-disable no-case-declarations */
import pick from "lodash-es/pick.js";
import NOTION_ICONS from "../../common/notion-icons.mjs";
import utils from "../../common/utils.mjs";
import notion from "../../notion.app.mjs";
import base from "../common/base-page-builder.mjs";
import pick from "lodash-es/pick.js";

export default {
...base,
key: "notion-create-page-from-database",
name: "Create Page from Data Source",
description: "Create a page from a data source. [See the documentation](https://developers.notion.com/reference/post-page)",
version: "1.1.0",
version: "2.0.0",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand All @@ -25,13 +26,26 @@ export default {
],
label: "Parent Data Source ID",
description: "Select a parent data source or provide a data source ID",
reloadProps: true,
},
Name: {
templateType: {
type: "string",
label: "Name",
description: "The name of the page. Use this only if the data source has a `title` property named `Name`. Otherwise, use the `Properties` prop below to set the title property.",
optional: true,
label: "Template Type",
description: "The type of template to use for the page. [See the documentation](https://developers.notion.com/docs/creating-pages-from-templates) for more information.",
options: [
{
label: "No template. Provided children and properties are immediately applied.",
value: "none",
},
{
label: "Applies the data source's default template to the newly created page. `children` cannot be specified in the create page request.",
value: "default",
},
{
label: "Indicates which exact template to apply to the newly created page. children cannot be specified in the create page request.",
value: "template_id",
},
],
reloadProps: true,
},
propertyTypes: {
propDefinition: [
Expand Down Expand Up @@ -64,11 +78,6 @@ export default {
description: "Cover [External URL](https://developers.notion.com/reference/file-object#external-file-objects)",
optional: true,
},
alert: {
type: "alert",
alertType: "info",
content: "This action will create an empty page by default. To add content, use the `Page Content` prop below.",
},
pageContent: {
propDefinition: [
notion,
Expand All @@ -77,11 +86,61 @@ export default {
},
},
async additionalProps() {
const { properties } = await this.notion.retrieveDataSource(this.parentDataSource);
const selectedProperties = pick(properties, this.propertyTypes);
return this.buildAdditionalProps({
properties: selectedProperties,
});
switch (this.templateType) {
case "none":
const { properties } = await this.notion.retrieveDataSource(this.parentDataSource);
const selectedProperties = pick(properties, this.propertyTypes);
return {
alert: {
type: "alert",
alertType: "info",
content: "This action will create an empty page by default. To add content, use the `Page Content` prop below.",
},
...this.buildAdditionalProps({
properties: selectedProperties,
}),
};
case "default":
return {
alert: {
type: "alert",
alertType: "info",
content: "This action will create a page using the data source's default template. Using the `Page Content` prop below will `not` apply to the page.",
},
};
case "template_id":
return {
templateId: {
type: "string",
label: "Template ID",
description: "The ID of the template to use for the page. [See the documentation](https://developers.notion.com/docs/creating-pages-from-templates) for more information.",
options: async({ prevContext }) => {
const {
templates, next_cursor: nCursor,
} = await this.notion.listTemplates({
data_source_id: this.parentDataSource,
start_cursor: prevContext?.nCursor,
});
return {
options: templates.map(({
name: label, id: value,
}) => ({
label,
value,
})),
context: {
nCursor,
},
};
},
},
alert: {
type: "alert",
alertType: "info",
content: "This action will create a page using the selected template. Using the `Page Content` prop below will `not` apply to the page.",
},
};
}
},
methods: {
...base.methods,
Expand All @@ -91,33 +150,45 @@ export default {
* @returns the constructed page in Notion format
*/
buildPage(parentDataSource) {
const meta = this.buildDataSourceMeta(parentDataSource);
this.properties = utils.parseObject(this.properties);
const properties = this.buildPageProperties(parentDataSource.properties);

const propertiesArray = [];
for (const property of Object.values(parentDataSource.properties)) {
if (properties[property.id]) {
propertiesArray.push({
label: property.name,
type: property.type,
value: this[property.name] || this.properties[property.name],
});
}
}

return propertiesArray;
const children = this.createBlocks(this.pageContent);
return {
...meta,
properties,
children,
};
},
},
async run({ $ }) {
const MAX_BLOCKS = 100;
const parentPage = await this.notion.retrieveDataSource(this.parentDataSource);
const properties = await this.buildPage(parentPage);
const response = await this.buildPageFromDataSource({
pageContent: this.pageContent,
parentDataSourceId: this.parentDataSource,
properties,
icon: this.icon,
cover: this.cover,
const {
children, ...page
} = this.buildPage(parentPage);
const data = this.templateId
? {
template: {
type: this.templateType,
template_id: this.templateId,
},
}
: {
children: children.slice(0, MAX_BLOCKS),
};
const response = await this.notion.createPage({
...data,
...page,
parent: {
data_source_id: this.parentDataSource,
},
});
let remainingBlocks = children.slice(MAX_BLOCKS);
while (remainingBlocks.length > 0) {
await this.notion.appendBlock(response.id, remainingBlocks.slice(0, MAX_BLOCKS));
remainingBlocks = remainingBlocks.slice(MAX_BLOCKS);
}
$.export("$summary", "Created page successfully");
return response;
},
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 @@ -6,7 +6,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.3.0",
version: "0.3.1",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
2 changes: 1 addition & 1 deletion components/notion/actions/delete-block/delete-block.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
key: "notion-delete-block",
name: "Delete Block",
description: "Sets a Block object, including page blocks, to archived: true using the ID specified. [See the documentation](https://developers.notion.com/reference/delete-a-block)",
version: "0.0.7",
version: "0.0.8",
annotations: {
destructiveHint: true,
openWorldHint: true,
Expand All @@ -15,7 +15,7 @@
type: "action",
props: {
notion,
infoLabel: {

Check warning on line 18 in components/notion/actions/delete-block/delete-block.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 18 in components/notion/actions/delete-block/delete-block.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: "**Note:** In the Notion UI application, this moves the block to the \"Trash\" where it can still be accessed and restored.",
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.22",
version: "0.0.23",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "notion-get-current-user",
name: "Get Current User",
description: "Retrieve the Notion identity tied to the current OAuth token, returning the full `users.retrieve` payload for `me` (person or bot). Includes the user ID, name, avatar URL, type (`person` vs `bot`), and workspace ownership metadata—useful for confirming which workspace is connected, adapting downstream queries, or giving an LLM the context it needs about who is operating inside Notion. [See the documentation](https://developers.notion.com/reference/get-user).",
version: "0.0.1",
version: "0.0.2",
type: "action",
annotations: {
destructiveHint: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "notion-list-all-users",
name: "List All Users",
description: "Returns all users in the workspace. [See the documentation](https://developers.notion.com/reference/get-users)",
version: "0.0.4",
version: "0.0.5",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "notion-list-file-uploads",
name: "List File Uploads",
description: "Use this action to list file uploads. [See the documentation](https://developers.notion.com/reference/list-file-uploads)",
version: "0.0.7",
version: "0.0.8",
annotations: {
destructiveHint: false,
openWorldHint: true,
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 Data Source",
description: "Query a data source with a specified filter. [See the documentation](https://developers.notion.com/reference/query-a-data-source)",
version: "1.0.1",
version: "1.0.2",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "notion-retrieve-block",
name: "Retrieve Page Content",
description: "Get page content as block objects or markdown. Blocks can be text, lists, media, a page, among others. [See the documentation](https://developers.notion.com/reference/retrieve-a-block)",
version: "0.2.7",
version: "0.2.8",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "notion-retrieve-database-content",
name: "Retrieve Data Source Content",
description: "Get all content of a data source. [See the documentation](https://developers.notion.com/reference/query-a-data-source)",
version: "1.0.1",
version: "1.0.2",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "notion-retrieve-database-schema",
name: "Retrieve Data Source Schema",
description: "Get the property schema of a data source in Notion. [See the documentation](https://developers.notion.com/reference/retrieve-a-data-source)",
version: "1.0.1",
version: "1.0.2",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "notion-retrieve-file-upload",
name: "Retrieve File Upload",
description: "Use this action to retrieve a file upload. [See the documentation](https://developers.notion.com/reference/retrieve-a-file-upload)",
version: "0.0.7",
version: "0.0.8",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "notion-retrieve-page-property-item",
name: "Retrieve Page Property Item",
description: "Get a Property Item object for a selected page and property. [See the documentation](https://developers.notion.com/reference/retrieve-a-page-property)",
version: "0.0.12",
version: "0.0.13",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
2 changes: 1 addition & 1 deletion components/notion/actions/retrieve-page/retrieve-page.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
key: "notion-retrieve-page",
name: "Retrieve Page Metadata",
description: "Get details of a page. [See the documentation](https://developers.notion.com/reference/retrieve-a-page)",
version: "0.0.13",
version: "0.0.14",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand All @@ -13,7 +13,7 @@
type: "action",
props: {
notion,
infoLabel: {

Check warning on line 16 in components/notion/actions/retrieve-page/retrieve-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 16 in components/notion/actions/retrieve-page/retrieve-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: "If you need to retrieve page content or block objects, use the **Retrieve Page Content** action instead.",
Expand Down
2 changes: 1 addition & 1 deletion components/notion/actions/retrieve-user/retrieve-user.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "notion-retrieve-user",
name: "Retrieve User",
description: "Returns a user using the ID specified. [See the documentation](https://developers.notion.com/reference/get-user)",
version: "0.0.4",
version: "0.0.5",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
2 changes: 1 addition & 1 deletion components/notion/actions/search/search.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "notion-search",
name: "Find Pages or Data Sources",
description: "Searches for a page or data source. [See the documentation](https://developers.notion.com/reference/post-search)",
version: "0.1.1",
version: "0.1.2",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
key: "notion-send-file-upload",
name: "Send File Upload",
description: "Send a file upload. [See the documentation](https://developers.notion.com/reference/send-a-file-upload)",
version: "0.0.7",
version: "0.0.8",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
2 changes: 1 addition & 1 deletion components/notion/actions/update-block/update-block.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
key: "notion-update-block",
name: "Update Child Block",
description: "Updates a child block object. [See the documentation](https://developers.notion.com/reference/update-a-block)",
version: "0.0.7",
version: "0.0.8",
annotations: {
destructiveHint: true,
openWorldHint: true,
Expand All @@ -21,7 +21,7 @@
label: "Block ID",
description: "Block ID retrieved from the **Retrieve Page Content** action",
},
infoLabel: {

Check warning on line 24 in components/notion/actions/update-block/update-block.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 24 in components/notion/actions/update-block/update-block.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: "**Note:** The update replaces the entire value for a given field. If a field is omitted (ex: omitting checked when updating a to_do block), the value will not be changed.",
Expand Down
Loading
Loading