use object as param in refresh function

Signed-off-by: Kiss Miklos <miklos@roadie.io>
This commit is contained in:
Kiss Miklos
2022-09-07 17:16:54 +02:00
parent fabd576219
commit 9743bc788c
6 changed files with 24 additions and 5 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-node': minor
---
Added refresh function to the `EntityProviderConnection` to be able to schedule refreshes from entity providers.
+1 -1
View File
@@ -2,4 +2,4 @@
'@backstage/plugin-catalog-backend': minor
---
Added refresh function to the EntityProviderConnection to be able to schedule refreshes from entity providers.
Added the `refresh` function to the Connection of the entity providers.
@@ -22,6 +22,7 @@ import { ProcessingDatabase } from '../database/types';
import {
EntityProvider,
EntityProviderConnection,
EntityProviderRefreshOptions,
EntityProviderMutation,
} from '@backstage/plugin-catalog-node';
@@ -61,12 +62,12 @@ class Connection implements EntityProviderConnection {
}
}
async refresh(keys: string[]): Promise<void> {
async refresh(options: EntityProviderRefreshOptions): Promise<void> {
const db = this.config.processingDatabase;
await db.transaction(async (tx: any) => {
return db.refreshByRefreshKeys(tx, {
keys,
keys: options.keys,
});
});
}
+6 -1
View File
@@ -126,7 +126,7 @@ export interface EntityProvider {
// @public
export interface EntityProviderConnection {
applyMutation(mutation: EntityProviderMutation): Promise<void>;
refresh(keys: string[]): Promise<void>;
refresh(options: EntityProviderRefreshOptions): Promise<void>;
}
// @public
@@ -141,6 +141,11 @@ export type EntityProviderMutation =
removed: DeferredEntity[];
};
// @public (undocumented)
export type EntityProviderRefreshOptions = {
keys: string[];
};
// @public
export type EntityRelationSpec = {
source: CompoundEntityRef;
+1
View File
@@ -32,4 +32,5 @@ export type {
EntityProvider,
EntityProviderConnection,
EntityProviderMutation,
EntityProviderRefreshOptions,
} from './provider';
+8 -1
View File
@@ -26,6 +26,13 @@ export type EntityProviderMutation =
| { type: 'full'; entities: DeferredEntity[] }
| { type: 'delta'; added: DeferredEntity[]; removed: DeferredEntity[] };
/**
* @public
*/
export type EntityProviderRefreshOptions = {
keys: string[];
};
/**
* The EntityProviderConnection is the connection between the catalog and the entity provider.
* The EntityProvider use this connection to add and remove entities from the catalog.
@@ -40,7 +47,7 @@ export interface EntityProviderConnection {
/**
* Schedules a refresh on all of the entities that has a matching refresh key associated with the provided keys.
*/
refresh(keys: string[]): Promise<void>;
refresh(options: EntityProviderRefreshOptions): Promise<void>;
}
/**