Pass entityFilter to fact retriever handler context
Signed-off-by: Iain Billett <iain@roadie.io>
This commit is contained in:
@@ -44,7 +44,7 @@ const testFactRetriever: FactRetriever = {
|
||||
description: '',
|
||||
},
|
||||
},
|
||||
handler: async () => {
|
||||
handler: jest.fn(async () => {
|
||||
return [
|
||||
{
|
||||
entity: {
|
||||
@@ -57,7 +57,7 @@ const testFactRetriever: FactRetriever = {
|
||||
},
|
||||
},
|
||||
];
|
||||
},
|
||||
}),
|
||||
};
|
||||
const cadence = '1 * * * *';
|
||||
describe('FactRetrieverEngine', () => {
|
||||
@@ -145,5 +145,8 @@ describe('FactRetrieverEngine', () => {
|
||||
const job: any = engine.getJob('test-factretriever');
|
||||
job.triggerScheduledJobNow();
|
||||
expect(job.cadence!!).toEqual(cadence);
|
||||
expect(testFactRetriever.handler).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ entityFilter: testFactRetriever.entityFilter }),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -108,7 +108,10 @@ export class FactRetrieverEngine {
|
||||
this.logger.info(
|
||||
`Retrieving facts for fact retriever ${factRetriever.id}`,
|
||||
);
|
||||
const facts = await factRetriever.handler(this.factRetrieverContext);
|
||||
const facts = await factRetriever.handler({
|
||||
...this.factRetrieverContext,
|
||||
entityFilter: factRetriever.entityFilter,
|
||||
});
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug(
|
||||
`Retrieved ${facts.length} facts for fact retriever ${
|
||||
|
||||
@@ -53,6 +53,9 @@ export type FactRetrieverContext = {
|
||||
config: Config;
|
||||
discovery: PluginEndpointDiscovery;
|
||||
logger: Logger_2;
|
||||
entityFilter?:
|
||||
| Record<string, string | symbol | (string | symbol)[]>[]
|
||||
| Record<string, string | symbol | (string | symbol)[]>;
|
||||
};
|
||||
|
||||
// @public
|
||||
|
||||
@@ -136,6 +136,9 @@ export type FactRetrieverContext = {
|
||||
config: Config;
|
||||
discovery: PluginEndpointDiscovery;
|
||||
logger: Logger;
|
||||
entityFilter?:
|
||||
| Record<string, string | symbol | (string | symbol)[]>[]
|
||||
| Record<string, string | symbol | (string | symbol)[]>;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user