From 2e3ec6701225009980f9f1d6915f55e7a0b9ac3e Mon Sep 17 00:00:00 2001 From: Andrew Chuang Date: Wed, 2 Oct 2024 13:31:39 -0300 Subject: [PATCH 1/2] emit original page not modified version --- .../sources/updated-page/updated-page.mjs | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/components/notion/sources/updated-page/updated-page.mjs b/components/notion/sources/updated-page/updated-page.mjs index 2bdf9eae3b941..f5322c41f3208 100644 --- a/components/notion/sources/updated-page/updated-page.mjs +++ b/components/notion/sources/updated-page/updated-page.mjs @@ -91,11 +91,13 @@ export default { // Files & Media type: // `url` and `expiry_time` are constantly updated by Notion, so ignore these fields if (property.type === "files") { - for (const file of property.files) { + const modified = structuredClone(property); + for (const file of modified.files) { if (file.type === "file") { delete file.file; } } + return modified; } return property; }, @@ -153,21 +155,25 @@ export default { for (const propertyName of propertiesToCheck) { const previousValue = structuredClone(propertyValues[page.id]?.[propertyName]); - const currentValue = this.maybeRemoveFileSubItems(page.properties[propertyName]); + // value used to compare and to save to this.db + const currentValueToSave = this.maybeRemoveFileSubItems(page.properties[propertyName]); + // (unmodified) value that should be emitted + const currentValueToEmit = page.properties[propertyName]; const pageExistsInDB = propertyValues[page.id] != null; - const propertyChanged = JSON.stringify(previousValue) !== JSON.stringify(currentValue); + const propertyChanged = + JSON.stringify(previousValue) !== JSON.stringify(currentValueToSave); if (pageExistsInDB && propertyChanged) { propertyHasChanged = true; propertyValues[page.id] = { ...propertyValues[page.id], - [propertyName]: currentValue, + [propertyName]: currentValueToSave, }; changes.push({ property: propertyName, previousValue, - currentValue, + currentValue: currentValueToEmit, }); } @@ -175,12 +181,12 @@ export default { isNewPage = true; propertyHasChanged = true; propertyValues[page.id] = { - [propertyName]: currentValue, + [propertyName]: currentValueToSave, }; changes.push({ property: propertyName, previousValue, - currentValue, + currentValue: currentValueToEmit, }); } } From 3ad73924b0aed6a2d33d409ce002d8ff6502e261 Mon Sep 17 00:00:00 2001 From: Andrew Chuang Date: Wed, 2 Oct 2024 13:32:16 -0300 Subject: [PATCH 2/2] bump versions --- components/notion/package.json | 2 +- components/notion/sources/updated-page/updated-page.mjs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/notion/package.json b/components/notion/package.json index 1d18c56c5e010..61cc6a3554aff 100644 --- a/components/notion/package.json +++ b/components/notion/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/notion", - "version": "0.2.1", + "version": "0.2.2", "description": "Pipedream Notion Components", "main": "notion.app.mjs", "keywords": [ diff --git a/components/notion/sources/updated-page/updated-page.mjs b/components/notion/sources/updated-page/updated-page.mjs index f5322c41f3208..4c7b00f0a3357 100644 --- a/components/notion/sources/updated-page/updated-page.mjs +++ b/components/notion/sources/updated-page/updated-page.mjs @@ -9,7 +9,7 @@ export default { key: "notion-updated-page", name: "Updated Page in Database", /* eslint-disable-line pipedream/source-name */ description: "Emit new event when a page in a database is updated. To select a specific page, use `Updated Page ID` instead", - version: "0.1.1", + version: "0.1.2", type: "source", dedupe: "unique", props: {