0.1.50 • Published 12 days ago

@backstage/plugin-tech-insights-backend-module-jsonfc v0.1.50

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
12 days ago

Tech Insights Backend JSON Rules engine fact checker module

This is an extension to module to tech-insights-backend plugin, which provides basic framework and functionality to implement tech insights within Backstage.

This module provides functionality to run checks against a json-rules-engine and provide boolean logic by simply building checks using JSON conditions.

Getting started

To add this FactChecker into your Tech Insights you need to install the module into your backend application:

# From your Backstage root directory
cd packages/backend
yarn add @backstage/plugin-tech-insights-backend-module-jsonfc

and modify the techInsights.ts file to contain a reference to the FactCheckers implementation.

+import { JsonRulesEngineFactCheckerFactory } from '@backstage/plugin-tech-insights-backend-module-jsonfc';

+const myFactCheckerFactory = new JsonRulesEngineFactCheckerFactory({
+   checks: [],
+   logger,
+}),

 const builder = new DefaultTechInsightsBuilder({
   logger,
   config,
   database,
   discovery,
   factRetrievers: [myFactRetrieverRegistration],
+  factCheckerFactory: myFactCheckerFactory
 });

By default this implementation comes with an in-memory storage to store checks. You can inject an additional data store by adding an implementation of TechInsightCheckRegistry into the constructor options when creating a JsonRulesEngineFactCheckerFactory. That can be done as follows

 const myTechInsightCheckRegistry: TechInsightCheckRegistry<MyCheckType> = // snip
 const myFactCheckerFactory = new JsonRulesEngineFactCheckerFactory({
   checks: [],
   logger,
+  checkRegistry: myTechInsightCheckRegistry
 }),

Adding checks

Checks for this FactChecker are constructed as json-rules-engine compatible JSON rules. A check could look like the following for example:

import { TechInsightJsonRuleCheck } from '../types';
import { JSON_RULE_ENGINE_CHECK_TYPE } from '../constants';

export const exampleCheck: TechInsightJsonRuleCheck = {
  id: 'demodatacheck', // Unique identifier of this check
  name: 'demodatacheck', // A human readable name of this check to be displayed in the UI
  type: JSON_RULE_ENGINE_CHECK_TYPE, // Type identifier of the check. Used to run logic against, determine persistence option to use and render correct components on the UI
  description: 'A fact check for demoing purposes', // A description to be displayed in the UI
  factRefs: ['demo-poc.factretriever'], // References to fact containers that this check uses. See documentation on FactRetrievers for more information on these
  rule: {
    // The actual rule
    conditions: {
      all: [
        // 2 options are available, all and any conditions.
        {
          fact: 'examplenumberfact', // Reference to an individual fact to check against
          operator: 'greaterThanInclusive', // Operator to use. See: https://github.com/CacheControl/json-rules-engine/blob/master/docs/rules.md#operators for more
          value: 2, // The threshold value that the fact must satisfy
        },
      ],
    },
  },
  successMetadata: {
    // Additional metadata to be returned if the check has passed
    link: 'https://link.to.some.information.com',
  },
  failureMetadata: {
    // Additional metadata to be returned if the check has failed
    link: 'https://sonar.mysonarqube.com/increasing-number-value',
  },
};
0.1.50

14 days ago

0.1.49

17 days ago

0.1.49-next.1

24 days ago

0.1.49-next.0

1 month ago

0.1.48

1 month ago

0.1.47

1 month ago

0.1.46

1 month ago

0.1.46-next.2

2 months ago

0.1.46-next.1

2 months ago

0.1.45

2 months ago

0.1.45-next.0

2 months ago

0.1.43

2 months ago

0.1.44

2 months ago

0.1.42

2 months ago

0.1.42-next.3

3 months ago

0.1.42-next.2

3 months ago

0.1.42-next.1

3 months ago

0.1.42-next.0

3 months ago

0.1.41

4 months ago

0.1.41-next.2

4 months ago

0.1.41-next.1

4 months ago

0.1.41-next.0

4 months ago

0.1.40

5 months ago

0.1.40-next.3

5 months ago

0.1.40-next.2

5 months ago

0.1.40-next.1

5 months ago

0.1.40-next.0

5 months ago

0.1.39-next.0

6 months ago

0.1.39-next.1

6 months ago

0.1.35-next.2

8 months ago

0.1.39-next.2

6 months ago

0.1.35-next.1

8 months ago

0.1.35-next.3

8 months ago

0.1.34-next.0

9 months ago

0.1.38-next.2

7 months ago

0.1.32-next.0

9 months ago

0.1.32-next.1

9 months ago

0.1.32-next.2

9 months ago

0.1.37-next.0

7 months ago

0.1.37-next.1

7 months ago

0.1.38

7 months ago

0.1.39

6 months ago

0.1.31

10 months ago

0.1.32

9 months ago

0.1.33

9 months ago

0.1.34

8 months ago

0.1.35

8 months ago

0.1.36

7 months ago

0.1.37

7 months ago

0.1.31-next.0

10 months ago

0.1.30-next.2

11 months ago

0.1.30

11 months ago

0.1.29-next.1

1 year ago

0.1.30-next.0

12 months ago

0.1.30-next.1

11 months ago

0.1.29

12 months ago

0.1.29-next.0

1 year ago

0.1.28

1 year ago

0.1.28-next.0

1 year ago

0.1.28-next.2

1 year ago

0.1.28-next.1

1 year ago

0.1.27-next.2

1 year ago

0.1.27-next.1

1 year ago

0.1.27-next.0

1 year ago

0.1.27

1 year ago

0.1.26

1 year ago

0.1.26-next.0

1 year ago

0.1.26-next.1

1 year ago

0.1.24-next.1

1 year ago

0.1.26-next.2

1 year ago

0.1.24-next.0

1 year ago

0.1.24

1 year ago

0.1.25

1 year ago

0.1.22-next.1

1 year ago

0.1.22-next.0

2 years ago

0.1.21

2 years ago

0.1.22

1 year ago

0.1.23

1 year ago

0.1.23-next.3

1 year ago

0.1.23-next.2

1 year ago

0.1.23-next.1

1 year ago

0.1.23-next.0

1 year ago

0.1.21-next.2

2 years ago

0.1.21-next.0

2 years ago

0.1.21-next.1

2 years ago

0.1.20-next.1

2 years ago

0.1.20-next.0

2 years ago

0.1.20

2 years ago

0.1.18-next.2

2 years ago

0.1.18-next.0

2 years ago

0.1.18-next.1

2 years ago

0.1.19-next.0

2 years ago

0.1.17-next.1

2 years ago

0.1.17-next.0

2 years ago

0.1.17

2 years ago

0.1.18

2 years ago

0.1.19

2 years ago

0.1.16

2 years ago

0.1.16-next.2

2 years ago

0.1.16-next.0

2 years ago

0.1.16-next.1

2 years ago

0.1.13

2 years ago

0.1.14

2 years ago

0.1.15

2 years ago

0.1.15-next.1

2 years ago

0.1.15-next.0

2 years ago

0.1.13-next.0

2 years ago

0.1.12

2 years ago

0.1.10

2 years ago

0.1.8-next.0

2 years ago

0.1.11

2 years ago

0.1.7-next.0

2 years ago

0.1.6-next.0

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.9

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

3 years ago