@@ -186,19 +186,18 @@ export default class PolicyPackPlugin extends Plugin {
186186 }
187187
188188 // 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 [ ]
195194 } ) : DataProcessor {
196- const dataProcessorKey = `${ provider } ${ entity } `
195+ const dataProcessorKey = `${ config . providerName } ${ config . entityName } `
197196 if ( this . dataProcessors [ dataProcessorKey ] ) {
198197 return this . dataProcessors [ dataProcessorKey ]
199198 }
200199
201- const dataProcessor = new DgraphDataProcessor ( provider , entity )
200+ const dataProcessor = new DgraphDataProcessor ( config )
202201 this . dataProcessors [ dataProcessorKey ] = dataProcessor
203202 return dataProcessor
204203 }
@@ -256,14 +255,17 @@ export default class PolicyPackPlugin extends Plugin {
256255 continue // eslint-disable-line no-continue
257256 }
258257
259- // Initialize RulesEngine
260- const rulesEngine = new RulesEngine ( {
258+ // Initialize Data Processor
259+ const dataProcessor = this . getDataProcessor ( {
261260 providerName : this . provider . name ,
262261 entityName : policyPackPlugin . entity ,
263262 typenameToFieldMap : resourceTypeNamesToFieldsMap ,
264263 extraFields : policyPackPlugin . extraFields ,
265264 } )
266265
266+ // Initialize RulesEngine
267+ const rulesEngine = new RulesEngine ( dataProcessor )
268+
267269 this . policyPacksPlugins [ policyPack ] = {
268270 engine : rulesEngine ,
269271 entity : policyPackPlugin . entity ,
@@ -318,14 +320,8 @@ export default class PolicyPackPlugin extends Plugin {
318320 storageEngine,
319321 } )
320322
321- // Data Processor
322- const dataProcessor = this . getDataProcessor ( {
323- entity,
324- provider : this . provider . name ,
325- } )
326-
327323 // Prepare mutations
328- const mutations = dataProcessor . prepareMutations ( findings )
324+ const mutations = engine . prepareMutations ( findings , rules )
329325
330326 // Save connections
331327 processConnectionsBetweenEntities ( {
0 commit comments