@@ -9,7 +9,7 @@ export default {
9
9
key : "notion-updated-page" ,
10
10
name : "Updated Page in Database" , /* eslint-disable-line pipedream/source-name */
11
11
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 " ,
13
13
type : "source" ,
14
14
dedupe : "unique" ,
15
15
props : {
@@ -91,11 +91,13 @@ export default {
91
91
// Files & Media type:
92
92
// `url` and `expiry_time` are constantly updated by Notion, so ignore these fields
93
93
if ( property . type === "files" ) {
94
- for ( const file of property . files ) {
94
+ const modified = structuredClone ( property ) ;
95
+ for ( const file of modified . files ) {
95
96
if ( file . type === "file" ) {
96
97
delete file . file ;
97
98
}
98
99
}
100
+ return modified ;
99
101
}
100
102
return property ;
101
103
} ,
@@ -153,34 +155,38 @@ export default {
153
155
154
156
for ( const propertyName of propertiesToCheck ) {
155
157
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 ] ;
157
162
158
163
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 ) ;
160
166
161
167
if ( pageExistsInDB && propertyChanged ) {
162
168
propertyHasChanged = true ;
163
169
propertyValues [ page . id ] = {
164
170
...propertyValues [ page . id ] ,
165
- [ propertyName ] : currentValue ,
171
+ [ propertyName ] : currentValueToSave ,
166
172
} ;
167
173
changes . push ( {
168
174
property : propertyName ,
169
175
previousValue,
170
- currentValue,
176
+ currentValue : currentValueToEmit ,
171
177
} ) ;
172
178
}
173
179
174
180
if ( ! pageExistsInDB ) {
175
181
isNewPage = true ;
176
182
propertyHasChanged = true ;
177
183
propertyValues [ page . id ] = {
178
- [ propertyName ] : currentValue ,
184
+ [ propertyName ] : currentValueToSave ,
179
185
} ;
180
186
changes . push ( {
181
187
property : propertyName ,
182
188
previousValue,
183
- currentValue,
189
+ currentValue : currentValueToEmit ,
184
190
} ) ;
185
191
}
186
192
}
0 commit comments