npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dweber019/backstage-plugin-relations-backend

v0.0.4

Published

This relations processor plugin emits additional custom relations, which are shown in the [Catalog Graph](https://github.com/backstage/backstage/blob/master/plugins/catalog-graph/README.md) out of box.

Downloads

177

Readme

Relations processor

This relations processor plugin emits additional custom relations, which are shown in the Catalog Graph out of box.

Additionally, you can install the Relations frontend plugin for a better frontend experience with this processor.

Install

Setup plugin

First we need to add the @dweber019/backstage-plugin-relations-backend package:

# From your Backstage root directory
yarn add --cwd packages/backend @dweber019/backstage-plugin-relations-backend

Then we open the file named packages/backend/src/plugins/catalog.ts, and extend it with:

import { RelationsEntitiesProcessor } from '@dweber019/backstage-plugin-relations-backend';

export default async function createPlugin(
  env: PluginEnvironment,
): Promise<Router> {
  const builder = await CatalogBuilder.create(env);

  builder.addProcessor(RelationEntitiesProcessor.fromConfig(env));

  const { processingEngine, router } = await builder.build();
  // ..
}

Configuration

See the config.d.ts file for a documentation of the configuration.

Here is a simple configuration, which will add an attribute named supporter, which allows relations to User and Group on a Resource. Additionally, we can use the attribute applicationOwner on Component to allow relations to a User.

relationsProcessor:
  relations:
    - sourceKind: component
      targetKinds:
        - user
      attribute: applicationOwner
      pairs:
        - incoming: applicationOwnerOf
          outgoing: applicationOwnerBy
    - sourceKind: resource
      targetKinds:
        - user
        - group
      attribute: supporter
      multi: true
      pairs:
        - incoming: supporterOf
          outgoing: supportedBy

Usage

The above definitions would allow to define the following entities

apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
  name: resource-1
spec:
  type: db
  owner: group:default/group-1
  supporter:
    - john-doe
    - group:default/group-1
---
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
  name: component-1
spec:
  type: service
  lifecycle: production
  owner: group:default/group-1
  applicationOwner: user:default/kevin-po

Catalog graph

It's recommend to use the Relations frontend plugin to add new relations to the filters and set good defaults.

Using well known relations

You can use the Well-known Relations between Catalog Entities relations with this plugin. This is useful if a component is owned by a group and has an application owner, which should have an ownership too.

apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
  name: component-1
spec:
  type: service
  lifecycle: production
  owner: group:default/group-1
  applicationOwner: user:default/kevin-po

To enable the owner relation use the following configuration.

relationsProcessor:
  relations:
    - sourceKind: component
      targetKinds:
        - user
      attribute: applicationOwner
      pairs:
        - incoming: applicationOwnerOf
          outgoing: applicationOwnerBy
        - incoming: ownerOf
          outgoing: ownerBy

New Backend System

The backend plugin has support for the new backend system, here's how you can set that up:

In your packages/backend/src/index.ts make the following changes:

const backend = createBackend();

backend.add(import('@dweber019/backstage-plugin-relations-backend'));

// ... other feature additions

backend.start();

This was not tested and is here for reference

Icon

Thanks for the icon Machine-learning icons created by Becris - Flaticon