@@ -110,8 +110,10 @@ class DataFilter extends MetadataType {
110110 */
111111 static async _getFilterFolderIds ( recached = false ) {
112112 const fromCache =
113- this . cache . folderFilter || cache . getCache ( ) . folder
114- ? Object . values ( this . cache . folderFilter || cache . getCache ( ) . folder )
113+ this . cache [ this . buObject . mid ] ?. folderFilter || cache . getCache ( ) . folder
114+ ? Object . values (
115+ this . cache [ this . buObject . mid ] ?. folderFilter || cache . getCache ( ) . folder
116+ )
115117 . filter ( ( item ) => item . ContentType === 'filterdefinition' )
116118 . filter (
117119 ( item ) =>
@@ -135,7 +137,10 @@ class DataFilter extends MetadataType {
135137 Folder . client = this . client ;
136138 Folder . buObject = this . buObject ;
137139 Folder . properties = this . properties ;
138- this . cache . folderFilter = ( await Folder . retrieveForCache ( null , subTypeArr ) ) . metadata ;
140+ this . cache [ this . buObject . mid ] ||= { } ;
141+ this . cache [ this . buObject . mid ] . folderFilter = (
142+ await Folder . retrieveForCache ( null , subTypeArr )
143+ ) . metadata ;
139144 return this . _getFilterFolderIds ( true ) ;
140145 }
141146 /**
@@ -145,9 +150,9 @@ class DataFilter extends MetadataType {
145150 */
146151 static async _getMeasureFolderIds ( ) {
147152 const fromCache =
148- this . cache . folderMeasure ?. [ this . buObject . mid ] || cache . getCache ( ) . folder
153+ this . cache [ this . buObject . mid ] ?. folderMeasure || cache . getCache ( ) . folder
149154 ? Object . values (
150- this . cache . folderMeasure ?. [ this . buObject . mid ] || cache . getCache ( ) . folder
155+ this . cache [ this . buObject . mid ] ?. folderMeasure || cache . getCache ( ) . folder
151156 )
152157 . filter ( ( item ) => item . ContentType === 'measure' )
153158 . map ( ( item ) => item . ID )
@@ -163,8 +168,8 @@ class DataFilter extends MetadataType {
163168 Folder . client = this . client ;
164169 Folder . buObject = this . buObject ;
165170 Folder . properties = this . properties ;
166- this . cache . folderMeasure ||= { } ;
167- this . cache . folderMeasure [ this . buObject . mid ] = (
171+ this . cache [ this . buObject . mid ] . folderMeasure ||= { } ;
172+ this . cache [ this . buObject . mid ] . folderMeasure = (
168173 await Folder . retrieveForCache ( null , subTypeArr )
169174 ) . metadata ;
170175 return this . _getMeasureFolderIds ( ) ;
@@ -205,8 +210,8 @@ class DataFilter extends MetadataType {
205210 . map ( ( item ) => item . r__source_dataExtension_key )
206211 . filter (
207212 ( deKey ) =>
208- ! this . cache . dataExtensionField ||
209- ! this . cache . dataExtensionField [ deKey ]
213+ ! this . cache [ this . buObject . mid ] ? .dataExtensionField ||
214+ ! this . cache [ this . buObject . mid ] ? .dataExtensionField [ deKey ]
210215 )
211216 . filter ( Boolean ) ;
212217 if ( deKeys . length ) {
@@ -246,7 +251,8 @@ class DataFilter extends MetadataType {
246251 * @param {DataExtensionFieldMap } deFieldCache -
247252 */
248253 static saveDataExtensionFieldCacheToMap ( deFieldCache ) {
249- this . cache . dataExtensionField ||= { } ;
254+ this . cache [ this . buObject . mid ] ||= { } ;
255+ this . cache [ this . buObject . mid ] . dataExtensionField ||= { } ;
250256
251257 if ( ! deFieldCache ) {
252258 return ;
@@ -255,11 +261,16 @@ class DataFilter extends MetadataType {
255261 if ( ! field ?. DataExtension ?. CustomerKey ) {
256262 continue ;
257263 }
258- if ( ! this . cache . dataExtensionField [ field . DataExtension . CustomerKey ] ) {
264+ if (
265+ ! this . cache [ this . buObject . mid ] . dataExtensionField [ field . DataExtension . CustomerKey ]
266+ ) {
259267 /** @type {Object.<string, DataExtensionFieldItem[]> } */
260- this . cache . dataExtensionField [ field . DataExtension . CustomerKey ] = [ ] ;
268+ this . cache [ this . buObject . mid ] . dataExtensionField [ field . DataExtension . CustomerKey ] =
269+ [ ] ;
261270 }
262- this . cache . dataExtensionField [ field . DataExtension . CustomerKey ] . push ( field ) ;
271+ this . cache [ this . buObject . mid ] . dataExtensionField [ field . DataExtension . CustomerKey ] . push (
272+ field
273+ ) ;
263274 }
264275 }
265276 /**
@@ -268,7 +279,7 @@ class DataFilter extends MetadataType {
268279 * @param {DataFilterMap } metadataTypeMap -
269280 */
270281 static async _cacheContactAttributes ( metadataTypeMap ) {
271- if ( this . cache . contactAttributes ?. [ this . buObject . mid ] ) {
282+ if ( this . cache [ this . buObject . mid ] ?. contactAttributes ) {
272283 return ;
273284 }
274285 const subscriberFilters = Object . values ( metadataTypeMap )
@@ -279,8 +290,8 @@ class DataFilter extends MetadataType {
279290 const response = await this . client . rest . get ( '/email/v1/Contacts/Attributes/' ) ;
280291 const keyFieldBackup = this . definition . keyField ;
281292 this . definition . keyField = 'id' ;
282- this . cache . contactAttributes ||= { } ;
283- this . cache . contactAttributes [ this . buObject . mid ] = this . parseResponseBody ( response ) ;
293+ this . cache [ this . buObject . mid ] ||= { } ;
294+ this . cache [ this . buObject . mid ] . contactAttributes = this . parseResponseBody ( response ) ;
284295 this . definition . keyField = keyFieldBackup ;
285296 }
286297 }
@@ -290,7 +301,7 @@ class DataFilter extends MetadataType {
290301 * @param {DataFilterMap } metadataTypeMap -
291302 */
292303 static async _cacheMeasures ( metadataTypeMap ) {
293- if ( this . cache . measures ?. [ this . buObject . mid ] ) {
304+ if ( this . cache [ this . buObject . mid ] . measures ) {
294305 return ;
295306 }
296307 const subscriberFilters = Object . values ( metadataTypeMap )
@@ -312,8 +323,8 @@ class DataFilter extends MetadataType {
312323
313324 const keyFieldBackup = this . definition . keyField ;
314325 this . definition . keyField = 'measureID' ;
315- this . cache . measures ||= { } ;
316- this . cache . measures [ this . buObject . mid ] = this . parseResponseBody ( response ) ;
326+ this . cache [ this . buObject . mid ] ||= { } ;
327+ this . cache [ this . buObject . mid ] . measures = this . parseResponseBody ( response ) ;
317328 this . definition . keyField = keyFieldBackup ;
318329 }
319330 }
@@ -439,7 +450,9 @@ class DataFilter extends MetadataType {
439450 return this . _resolveFields (
440451 metadata ,
441452 mode ,
442- this . cache . dataExtensionField [ metadata . r__source_dataExtension_key ] ,
453+ this . cache [ this . buObject . mid ] . dataExtensionField [
454+ metadata . r__source_dataExtension_key
455+ ] ,
443456 metadata . c__filterDefinition ?. ConditionSet
444457 ) ;
445458 }
@@ -530,8 +543,8 @@ class DataFilter extends MetadataType {
530543 metadata . c__filterDefinition ?. ConditionSet
531544 ) ;
532545 }
533- const contactAttributes = this . cache . contactAttributes [ this . buObject . mid ] ;
534- const measures = this . cache . measures [ this . buObject . mid ] ;
546+ const contactAttributes = this . cache [ this . buObject . mid ] ?. contactAttributes ;
547+ const measures = this . cache [ this . buObject . mid ] ?. measures ;
535548 const conditionsArr = Array . isArray ( filter . Condition )
536549 ? filter . Condition
537550 : [ filter . Condition ] ;
0 commit comments