From 10b7b62359081424951d45c91028938138602f19 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 22 Oct 2024 14:30:57 +0200 Subject: [PATCH] catalog-node: restore old alpha client Signed-off-by: Patrik Oldsberg --- plugins/catalog-node/src/alpha.ts | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/plugins/catalog-node/src/alpha.ts b/plugins/catalog-node/src/alpha.ts index 159b642e52..63b817fbb3 100644 --- a/plugins/catalog-node/src/alpha.ts +++ b/plugins/catalog-node/src/alpha.ts @@ -14,19 +14,31 @@ * limitations under the License. */ -import { ServiceRef } from '@backstage/backend-plugin-api'; +import { + coreServices, + createServiceFactory, + createServiceRef, +} from '@backstage/backend-plugin-api'; import { catalogServiceRef as _catalogServiceRef } from './catalogService'; -import { CatalogApi } from '@backstage/catalog-client'; +import { CatalogApi, CatalogClient } from '@backstage/catalog-client'; /** * @alpha * @deprecated Use {@link @backstage/plugin-catalog-node#catalogServiceRef} instead */ -export const catalogServiceRef = _catalogServiceRef as ServiceRef< - CatalogApi, - 'plugin', - 'singleton' ->; +export const catalogServiceRef = createServiceRef({ + id: 'catalog-client', + defaultFactory: async service => + createServiceFactory({ + service, + deps: { + discoveryApi: coreServices.discovery, + }, + async factory({ discoveryApi }) { + return new CatalogClient({ discoveryApi }); + }, + }), +}); export type { CatalogLocationsExtensionPoint } from './extensions'; export { catalogLocationsExtensionPoint } from './extensions';