Introduce additional JsonValue types to be storable as facts. This enables the possibility to store more complex objects for fact checking purposes. The rules engine supports walking keyed object values directly to create rules and checks

Modify facts database table to have a more restricted timestamp precision for cases where the postgres server isn't configured to contain such value. This fixes the issue where in some cases `maxItems` lifecycle condition didn't work as expected.

resolves #11595

Signed-off-by: Jussi Hallila <jussi@hallila.com>
This commit is contained in:
Jussi Hallila
2022-06-10 08:36:53 +02:00
parent d76cabf329
commit aa15229ec3
4 changed files with 56 additions and 2 deletions
+8
View File
@@ -0,0 +1,8 @@
---
'@backstage/plugin-tech-insights-backend': patch
'@backstage/plugin-tech-insights-node': patch
---
Introduce additional JsonValue types to be storable as facts. This enables the possibility to store more complex objects for fact checking purposes. The rules engine supports walking keyed object values directly to create rules and checks
Modify facts database table to have a more restricted timestamp precision for cases where the postgres server isn't configured to contain such value. This fixes the issue where in some cases `maxItems` lifecycle condition didn't work as expected.
@@ -0,0 +1,36 @@
/*
* Copyright 2021 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-check
/**
* @param {import('knex').Knex} knex
*/
exports.up = async function up(knex) {
await knex.schema.alterTable('facts', table => {
table
.dateTime('timestamp', { precision: 0 })
.defaultTo(knex.fn.now())
.notNullable()
.comment('The timestamp when this entry was created')
.alter();
});
};
/**
* @param {import('knex').Knex} _knex
*/
exports.down = async function down(_knex) {};
+1
View File
@@ -36,6 +36,7 @@
"@backstage/backend-common": "^0.14.0-next.2",
"@backstage/config": "^1.0.1",
"@backstage/plugin-tech-insights-common": "^0.2.4",
"@backstage/types": "^1.0.0",
"@types/luxon": "^2.0.5",
"luxon": "^2.0.2",
"winston": "^3.2.1"
+11 -2
View File
@@ -15,6 +15,7 @@
*/
import { DateTime, Duration, DurationLike } from 'luxon';
import { Config } from '@backstage/config';
import { JsonValue } from '@backstage/types';
import {
PluginEndpointDiscovery,
TokenManager,
@@ -55,6 +56,7 @@ export type TechInsightFact = {
| string[]
| boolean[]
| DateTime[]
| JsonValue
>;
/**
@@ -94,9 +96,16 @@ export type FactSchema = {
* Type of the individual fact value
*
* Numbers are split into integers and floating point values.
* `set` indicates a collection of values
* `set` indicates a collection of values, `object` indicates JSON serializable value
*/
type: 'integer' | 'float' | 'string' | 'boolean' | 'datetime' | 'set';
type:
| 'integer'
| 'float'
| 'string'
| 'boolean'
| 'datetime'
| 'set'
| 'object';
/**
* A description of this individual fact value