Skip to content

Commit a625b95

Browse files
[Notion] emit original page, not modified (#14160)
* emit original page not modified version * bump versions
1 parent dd8a023 commit a625b95

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

components/notion/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/notion",
3-
"version": "0.2.1",
3+
"version": "0.2.2",
44
"description": "Pipedream Notion Components",
55
"main": "notion.app.mjs",
66
"keywords": [

components/notion/sources/updated-page/updated-page.mjs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default {
99
key: "notion-updated-page",
1010
name: "Updated Page in Database", /* eslint-disable-line pipedream/source-name */
1111
description: "Emit new event when a page in a database is updated. To select a specific page, use `Updated Page ID` instead",
12-
version: "0.1.1",
12+
version: "0.1.2",
1313
type: "source",
1414
dedupe: "unique",
1515
props: {
@@ -91,11 +91,13 @@ export default {
9191
// Files & Media type:
9292
// `url` and `expiry_time` are constantly updated by Notion, so ignore these fields
9393
if (property.type === "files") {
94-
for (const file of property.files) {
94+
const modified = structuredClone(property);
95+
for (const file of modified.files) {
9596
if (file.type === "file") {
9697
delete file.file;
9798
}
9899
}
100+
return modified;
99101
}
100102
return property;
101103
},
@@ -153,34 +155,38 @@ export default {
153155

154156
for (const propertyName of propertiesToCheck) {
155157
const previousValue = structuredClone(propertyValues[page.id]?.[propertyName]);
156-
const currentValue = this.maybeRemoveFileSubItems(page.properties[propertyName]);
158+
// value used to compare and to save to this.db
159+
const currentValueToSave = this.maybeRemoveFileSubItems(page.properties[propertyName]);
160+
// (unmodified) value that should be emitted
161+
const currentValueToEmit = page.properties[propertyName];
157162

158163
const pageExistsInDB = propertyValues[page.id] != null;
159-
const propertyChanged = JSON.stringify(previousValue) !== JSON.stringify(currentValue);
164+
const propertyChanged =
165+
JSON.stringify(previousValue) !== JSON.stringify(currentValueToSave);
160166

161167
if (pageExistsInDB && propertyChanged) {
162168
propertyHasChanged = true;
163169
propertyValues[page.id] = {
164170
...propertyValues[page.id],
165-
[propertyName]: currentValue,
171+
[propertyName]: currentValueToSave,
166172
};
167173
changes.push({
168174
property: propertyName,
169175
previousValue,
170-
currentValue,
176+
currentValue: currentValueToEmit,
171177
});
172178
}
173179

174180
if (!pageExistsInDB) {
175181
isNewPage = true;
176182
propertyHasChanged = true;
177183
propertyValues[page.id] = {
178-
[propertyName]: currentValue,
184+
[propertyName]: currentValueToSave,
179185
};
180186
changes.push({
181187
property: propertyName,
182188
previousValue,
183-
currentValue,
189+
currentValue: currentValueToEmit,
184190
});
185191
}
186192
}

0 commit comments

Comments
 (0)