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/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/notion",
"version": "0.7.1",
"version": "0.8.0",
"description": "Pipedream Notion Components",
"main": "notion.app.mjs",
"keywords": [
Expand Down
59 changes: 59 additions & 0 deletions components/notion/sources/updated-page-by-timestamp/test-event.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
export default {
"object": "page",
"id": "15e73a03-a25e-811d-8ff0-e99f0561c344",
"created_time": "2024-12-16T22:15:00.000Z",
"last_edited_time": "2025-07-23T17:00:00.000Z",
"created_by": {
"object": "user",
"id": "a697c2ad-539d-4523-a9e8-66f855e6caef"
},
"last_edited_by": {
"object": "user",
"id": "a697c2ad-539d-4523-a9e8-66f855e6caef"
},
"cover": null,
"icon": null,
"parent": {
"type": "database_id",
"database_id": "9813bf8c-a429-4d63-b73b-f476783ff448"
},
"archived": false,
"in_trash": false,
"properties": {
"Created": {
"id": "GsAx",
"type": "created_time",
"created_time": "2024-12-16T22:15:00.000Z"
},
"Tags": {
"id": "h~%7Da",
"type": "multi_select",
"multi_select": []
},
"Name": {
"id": "title",
"type": "title",
"title": [
{
"type": "text",
"text": {
"content": "TestPage",
"link": null
},
"annotations": {
"bold": false,
"italic": false,
"strikethrough": false,
"underline": false,
"code": false,
"color": "default"
},
"plain_text": "TestPage",
"href": null
}
]
}
},
"url": "https://www.notion.so/TestPage-15e73a03a25e811d8ff0e99f0561c344",
"public_url": "https://held-danger-051.notion.site/TestPage-15e73a03a25e811d8ff0e99f0561c344"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import notion from "../../notion.app.mjs";
import base from "../common/base.mjs";
import constants from "../common/constants.mjs";
import sampleEmit from "./test-event.mjs";

export default {
...base,
key: "notion-updated-page-by-timestamp",
name: "New or Updated Page in Database (By Timestamp)",
description: "Emit new event when a page is created or updated in the selected database. [See the documentation](https://developers.notion.com/reference/page)",
version: "0.0.1",
type: "source",
dedupe: "unique",
props: {
...base.props,
databaseId: {
propDefinition: [
notion,
"databaseId",
],
},
includeNewPages: {
type: "boolean",
label: "Include New Pages",
description: "Set to `false` to emit events only for updates, not for new pages.",
default: true,
},
},
methods: {
...base.methods,
_generateMeta(obj, summary) {
const { id } = obj;
const title = this.notion.extractPageTitle(obj);
const ts = Date.parse(obj.last_edited_time);
return {
id: `${id}-${ts}`,
summary: `${summary}: ${title}`,
ts,
};
},
_emitEvent(page, isNewPage = true) {
const meta = isNewPage
? this._generateMeta(page, constants.summaries.PAGE_ADDED)
: this._generateMeta(page, constants.summaries.PAGE_UPDATED);
this.$emit(page, meta);
},
},
async run() {
const lastUpdatedTimestamp = this.getLastUpdatedTimestamp();
let newLastUpdatedTimestamp = lastUpdatedTimestamp;

const params = {
...this.lastUpdatedSortParam(),
filter: {
timestamp: "last_edited_time",
last_edited_time: {
on_or_after: new Date(lastUpdatedTimestamp).toISOString(),
},
},
};

const pagesStream = this.notion.getPages(this.databaseId, params);

for await (const page of pagesStream) {
if (lastUpdatedTimestamp > Date.parse(page.last_edited_time)) {
break;
}

newLastUpdatedTimestamp = Math.max(
newLastUpdatedTimestamp,
Date.parse(page.last_edited_time),
);

const isNewPage = page.last_edited_time === page.created_time;

if (isNewPage && !this.includeNewPages) {
console.log(`Ignoring new page: ${page.id}`);
continue;
}

this._emitEvent(page, isNewPage);
}

this.setLastUpdatedTimestamp(newLastUpdatedTimestamp);
},
sampleEmit,
};
4 changes: 2 additions & 2 deletions components/notion/sources/updated-page/updated-page.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
export default {
...base,
key: "notion-updated-page",
name: "New or Updated Page in Database", /* eslint-disable-line pipedream/source-name */
name: "New or Updated Page in Database (By Property)",
description: "Emit new event when a page is created or updated in the selected database. [See the documentation](https://developers.notion.com/reference/page)",
version: "0.1.7",
version: "0.1.8",
type: "source",
dedupe: "unique",
props: {
Expand Down Expand Up @@ -38,7 +38,7 @@
description: "Only emit events when one or more of the selected properties have changed",
optional: true,
},
alert: {

Check warning on line 41 in components/notion/sources/updated-page/updated-page.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 41 in components/notion/sources/updated-page/updated-page.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: "warning",
content: "Source not saving? Your database might be too large. If deployment takes longer than one minute, an error will occur.",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

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

Loading