@@ -186,19 +186,18 @@ export default class PolicyPackPlugin extends Plugin {
186
186
}
187
187
188
188
// TODO: Generalize data processor moving storage module to SDK with its interfaces
189
- private getDataProcessor ( {
190
- entity,
191
- provider,
192
- } : {
193
- entity : string
194
- provider : string
189
+ private getDataProcessor ( config : {
190
+ providerName : string
191
+ entityName : string
192
+ typenameToFieldMap ?: { [ tn : string ] : string }
193
+ extraFields ?: string [ ]
195
194
} ) : DataProcessor {
196
- const dataProcessorKey = `${ provider } ${ entity } `
195
+ const dataProcessorKey = `${ config . providerName } ${ config . entityName } `
197
196
if ( this . dataProcessors [ dataProcessorKey ] ) {
198
197
return this . dataProcessors [ dataProcessorKey ]
199
198
}
200
199
201
- const dataProcessor = new DgraphDataProcessor ( provider , entity )
200
+ const dataProcessor = new DgraphDataProcessor ( config )
202
201
this . dataProcessors [ dataProcessorKey ] = dataProcessor
203
202
return dataProcessor
204
203
}
@@ -256,14 +255,17 @@ export default class PolicyPackPlugin extends Plugin {
256
255
continue // eslint-disable-line no-continue
257
256
}
258
257
259
- // Initialize RulesEngine
260
- const rulesEngine = new RulesEngine ( {
258
+ // Initialize Data Processor
259
+ const dataProcessor = this . getDataProcessor ( {
261
260
providerName : this . provider . name ,
262
261
entityName : policyPackPlugin . entity ,
263
262
typenameToFieldMap : resourceTypeNamesToFieldsMap ,
264
263
extraFields : policyPackPlugin . extraFields ,
265
264
} )
266
265
266
+ // Initialize RulesEngine
267
+ const rulesEngine = new RulesEngine ( dataProcessor )
268
+
267
269
this . policyPacksPlugins [ policyPack ] = {
268
270
engine : rulesEngine ,
269
271
entity : policyPackPlugin . entity ,
@@ -318,14 +320,8 @@ export default class PolicyPackPlugin extends Plugin {
318
320
storageEngine,
319
321
} )
320
322
321
- // Data Processor
322
- const dataProcessor = this . getDataProcessor ( {
323
- entity,
324
- provider : this . provider . name ,
325
- } )
326
-
327
323
// Prepare mutations
328
- const mutations = dataProcessor . prepareMutations ( findings )
324
+ const mutations = engine . prepareMutations ( findings , rules )
329
325
330
326
// Save connections
331
327
processConnectionsBetweenEntities ( {
0 commit comments