Merge pull request #9754 from backstage/freben/the-ref-revolution

Remove all usage of, and deprecate, `EntityRef`
This commit is contained in:
Fredrik Adelöw
2022-02-23 15:34:08 +01:00
committed by GitHub
21 changed files with 142 additions and 139 deletions
@@ -26,7 +26,7 @@ import { rsort } from 'semver';
import { groupBy, omit } from 'lodash';
import { DateTime } from 'luxon';
import { Logger } from 'winston';
import { parseEntityName, stringifyEntityRef } from '@backstage/catalog-model';
import { parseEntityRef, stringifyEntityRef } from '@backstage/catalog-model';
import { isMaxItems, isTtl } from '../fact/factRetrievers/utils';
type Transaction = Knex.Transaction;
@@ -161,7 +161,7 @@ export class TechInsightsDatabase implements TechInsightsStore {
return groupBy(
results.map(it => {
const { namespace, kind, name } = parseEntityName(it.entity);
const { namespace, kind, name } = parseEntityRef(it.entity);
const timestamp =
typeof it.timestamp === 'string'
? DateTime.fromISO(it.timestamp)
@@ -253,7 +253,7 @@ export class TechInsightsDatabase implements TechInsightsStore {
private dbFactRowsToTechInsightFacts(rows: RawDbFactRow[]) {
return rows.reduce((acc, it) => {
const { namespace, kind, name } = parseEntityName(it.entity);
const { namespace, kind, name } = parseEntityRef(it.entity);
const timestamp =
typeof it.timestamp === 'string'
? DateTime.fromISO(it.timestamp)
@@ -28,8 +28,7 @@ import { DateTime } from 'luxon';
import { PersistenceContext } from './persistence/persistenceContext';
import {
EntityName,
EntityRef,
parseEntityName,
parseEntityRef,
stringifyEntityRef,
} from '@backstage/catalog-model';
import { errorHandler } from '@backstage/backend-common';
@@ -130,7 +129,7 @@ export async function createRouter<
*/
router.get('/facts/latest', async (req, res) => {
const { entity } = req.query;
const { namespace, kind, name } = parseEntityName(entity as EntityRef);
const { namespace, kind, name } = parseEntityRef(entity as string);
const ids = req.query.ids as string[];
return res.send(
await techInsightsStore.getLatestFactsByIds(
@@ -145,7 +144,7 @@ export async function createRouter<
*/
router.get('/facts/range', async (req, res) => {
const { entity } = req.query;
const { namespace, kind, name } = parseEntityName(entity as EntityRef);
const { namespace, kind, name } = parseEntityRef(entity as string);
const ids = req.query.ids as string[];
const startDatetime = DateTime.fromISO(req.query.startDatetime as string);