Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@backstage/plugin-search-backend-module-catalog

Package Overview
Dependencies
Maintainers
3
Versions
665
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@backstage/plugin-search-backend-module-catalog

A module for the search backend that exports catalog modules

  • 0.2.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
57K
increased by0.75%
Maintainers
3
Weekly downloads
 
Created
Source

search-backend-module-catalog

This package exports a module that extends the search backend to also indexing the entities of your catalog.

Installation

Add the module package as a dependency:

# From your Backstage root directory
yarn --cwd packages/backend add @backstage/plugin-search-backend-module-catalog

Add the collator to your backend instance, along with the search plugin itself:

// packages/backend/src/index.ts
import { createBackend } from '@backstage/backend-defaults';
import { searchPlugin } from '@backstage/plugin-search-backend/alpha';
import { searchModuleCatalogCollator } from '@backstage/plugin-search-backend-module-catalog/alpha';

const backend = createBackend();
backend.add(searchPlugin);
backend.add(searchModuleCatalogCollator);
backend.start();

You may also want to add configuration parameters to your app-config, for example for controlling the scheduled indexing interval. These parameters should be placed under the search.collators.catalog key. See the config definition file for more details.

Advanced Customizations

This module also has an extension point, which lets you inject advanced customizations. Here's an example of how to leverage that extension point to tweak the transformer used for building the search indexer documents:

// packages/backend/src/index.ts
import { createBackend } from '@backstage/backend-defaults';
import { createBackendModule } from '@backstage/backend-plugin-api';
import { searchPlugin } from '@backstage/plugin-search-backend/alpha';
import { CatalogCollatorEntityTransformer } from '@backstage/plugin-search-backend-module-catalog';
import {
  searchModuleCatalogCollator,
  catalogCollatorExtensionPoint,
} from '@backstage/plugin-search-backend-module-catalog/alpha';

const customTransformer: CatalogCollatorEntityTransformer = entity => ({
  title: entity.metadata.title || entity.metadata.name,
  text: entity.metadata.description || '',
  componentType: entity.spec?.type?.toString() || 'other',
  type: entity.spec?.type?.toString() || 'other',
  namespace: entity.metadata.namespace || 'default',
  kind: entity.kind,
  lifecycle: (entity.spec?.lifecycle as string) || '',
  owner: (entity.spec?.owner as string) || '',
});

const backend = createBackend();
backend.add(searchPlugin);
backend.add(searchModuleCatalogCollator);
backend.add(
  createBackendModule({
    pluginId: 'search',
    moduleId: 'my-catalog-collator-options',
    register(reg) {
      reg.registerInit({
        deps: { collator: catalogCollatorExtensionPoint },
        async init({ collator }) {
          collator.setEntityTransformer(customTransformer);
        },
      });
    },
  })(),
);
backend.start();

FAQs

Package last updated on 19 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc