Remove node package, update api-report & props
Signed-off-by: ivgo <ivgo@spreadgroup.com>
This commit is contained in:
@@ -9,12 +9,9 @@ import { BackstagePlugin } from '@backstage/core-plugin-api';
|
||||
import { RouteRef } from '@backstage/core-plugin-api';
|
||||
|
||||
// @public (undocumented)
|
||||
export const EntityValidationPage: ({
|
||||
defaultPreviewCatalog,
|
||||
locationPlaceholder,
|
||||
}: {
|
||||
defaultPreviewCatalog?: string | undefined;
|
||||
locationPlaceholder?: string | undefined;
|
||||
export const EntityValidationPage: (props: {
|
||||
defaultYaml?: string | undefined;
|
||||
defaultLocation?: string | undefined;
|
||||
}) => JSX.Element;
|
||||
|
||||
// @public (undocumented)
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
"@backstage/catalog-model": "workspace:^",
|
||||
"@backstage/core-components": "workspace:^",
|
||||
"@backstage/core-plugin-api": "workspace:^",
|
||||
"@backstage/errors": "workspace:^",
|
||||
"@backstage/plugin-catalog-common": "workspace:^",
|
||||
"@backstage/plugin-catalog-node": "workspace:^",
|
||||
"@backstage/plugin-catalog-react": "workspace:^",
|
||||
"@backstage/theme": "workspace:^",
|
||||
"@codemirror/language": "^6.0.0",
|
||||
|
||||
+1
-1
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
import React from 'react';
|
||||
import { identityApiRef, useApi } from '@backstage/core-plugin-api';
|
||||
import { CatalogProcessorResult } from '@backstage/plugin-catalog-node';
|
||||
import {
|
||||
catalogApiRef,
|
||||
humanizeEntityRef,
|
||||
@@ -25,6 +24,7 @@ import useAsync from 'react-use/lib/useAsync';
|
||||
import { InfoCard, Progress } from '@backstage/core-components';
|
||||
import Alert from '@material-ui/lab/Alert';
|
||||
import {
|
||||
CatalogProcessorResult,
|
||||
ValidationOutput,
|
||||
ValidationOutputError,
|
||||
ValidationOutputOk,
|
||||
|
||||
+12
-9
@@ -17,7 +17,7 @@ import React, { useState } from 'react';
|
||||
import { Button, Content, Header, Page } from '@backstage/core-components';
|
||||
import { EntityTextArea } from '../EntityTextArea';
|
||||
import { Grid, TextField } from '@material-ui/core';
|
||||
import { CatalogProcessorResult } from '@backstage/plugin-catalog-node';
|
||||
import { CatalogProcessorResult } from '../../types';
|
||||
import { parseEntityYaml } from '../../utils';
|
||||
import { EntityValidationOutput } from '../EntityValidationOutput';
|
||||
|
||||
@@ -36,14 +36,16 @@ spec:
|
||||
owner: owner
|
||||
`;
|
||||
|
||||
export const EntityValidationPage = ({
|
||||
defaultPreviewCatalog = EXAMPLE_CATALOG_INFO_YAML,
|
||||
locationPlaceholder = 'https://github.com/backstage/backstage/blob/master/catalog-info.yaml',
|
||||
}: {
|
||||
defaultPreviewCatalog?: string;
|
||||
locationPlaceholder?: string;
|
||||
export const EntityValidationPage = (props: {
|
||||
defaultYaml?: string;
|
||||
defaultLocation?: string;
|
||||
}) => {
|
||||
const [catalogYaml, setCatalogYaml] = useState(defaultPreviewCatalog);
|
||||
const {
|
||||
defaultYaml = EXAMPLE_CATALOG_INFO_YAML,
|
||||
defaultLocation = 'https://github.com/backstage/backstage/blob/master/catalog-info.yaml',
|
||||
} = props;
|
||||
|
||||
const [catalogYaml, setCatalogYaml] = useState(defaultYaml);
|
||||
const [yamlFiles, setYamlFiles] = useState<CatalogProcessorResult[]>();
|
||||
const [locationUrl, setLocationUrl] = useState('');
|
||||
|
||||
@@ -72,7 +74,8 @@ export const EntityValidationPage = ({
|
||||
margin="normal"
|
||||
variant="outlined"
|
||||
required
|
||||
placeholder={locationPlaceholder}
|
||||
value={defaultLocation}
|
||||
placeholder={defaultLocation}
|
||||
helperText="Location where you catalog-info.yaml file is, or will be, located"
|
||||
onChange={e => setLocationUrl(e.target.value)}
|
||||
/>
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright 2020 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.
|
||||
*/
|
||||
|
||||
// File copied from https://github.com/backstage/backstage/blob/master/plugins/catalog-node/src/api/processingResult.ts
|
||||
import { InputError, NotFoundError } from '@backstage/errors';
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { LocationSpec } from '@backstage/plugin-catalog-common';
|
||||
import { CatalogProcessorResult, EntityRelationSpec } from './types';
|
||||
|
||||
/**
|
||||
* Factory functions for the standard processing result types.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const processingResult = Object.freeze({
|
||||
notFoundError(
|
||||
atLocation: LocationSpec,
|
||||
message: string,
|
||||
): CatalogProcessorResult {
|
||||
return {
|
||||
type: 'error',
|
||||
location: atLocation,
|
||||
error: new NotFoundError(message),
|
||||
};
|
||||
},
|
||||
|
||||
inputError(
|
||||
atLocation: LocationSpec,
|
||||
message: string,
|
||||
): CatalogProcessorResult {
|
||||
return {
|
||||
type: 'error',
|
||||
location: atLocation,
|
||||
error: new InputError(message),
|
||||
};
|
||||
},
|
||||
|
||||
generalError(
|
||||
atLocation: LocationSpec,
|
||||
message: string,
|
||||
): CatalogProcessorResult {
|
||||
return { type: 'error', location: atLocation, error: new Error(message) };
|
||||
},
|
||||
|
||||
location(newLocation: LocationSpec): CatalogProcessorResult {
|
||||
return { type: 'location', location: newLocation };
|
||||
},
|
||||
|
||||
entity(atLocation: LocationSpec, newEntity: Entity): CatalogProcessorResult {
|
||||
return { type: 'entity', location: atLocation, entity: newEntity };
|
||||
},
|
||||
|
||||
relation(spec: EntityRelationSpec): CatalogProcessorResult {
|
||||
return { type: 'relation', relation: spec };
|
||||
},
|
||||
|
||||
refresh(key: string): CatalogProcessorResult {
|
||||
return { type: 'refresh', key };
|
||||
},
|
||||
} as const);
|
||||
@@ -13,8 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { CompoundEntityRef, Entity } from '@backstage/catalog-model';
|
||||
import { ValidateEntityResponse } from '@backstage/catalog-client';
|
||||
import { LocationSpec } from '@backstage/plugin-catalog-common';
|
||||
|
||||
export type ValidationOutputError = {
|
||||
type: 'error';
|
||||
@@ -28,3 +29,54 @@ export type ValidationOutputOk = {
|
||||
};
|
||||
|
||||
export type ValidationOutput = ValidationOutputOk | ValidationOutputError;
|
||||
|
||||
export type EntityRelationSpec = {
|
||||
/**
|
||||
* The source entity of this relation.
|
||||
*/
|
||||
source: CompoundEntityRef;
|
||||
|
||||
/**
|
||||
* The type of the relation.
|
||||
*/
|
||||
type: string;
|
||||
|
||||
/**
|
||||
* The target entity of this relation.
|
||||
*/
|
||||
target: CompoundEntityRef;
|
||||
};
|
||||
|
||||
type CatalogProcessorLocationResult = {
|
||||
type: 'location';
|
||||
location: LocationSpec;
|
||||
};
|
||||
|
||||
type CatalogProcessorEntityResult = {
|
||||
type: 'entity';
|
||||
entity: Entity;
|
||||
location: LocationSpec;
|
||||
};
|
||||
|
||||
type CatalogProcessorRelationResult = {
|
||||
type: 'relation';
|
||||
relation: EntityRelationSpec;
|
||||
};
|
||||
|
||||
type CatalogProcessorErrorResult = {
|
||||
type: 'error';
|
||||
error: Error;
|
||||
location: LocationSpec;
|
||||
};
|
||||
|
||||
type CatalogProcessorRefreshKeysResult = {
|
||||
type: 'refresh';
|
||||
key: string;
|
||||
};
|
||||
|
||||
export type CatalogProcessorResult =
|
||||
| CatalogProcessorLocationResult
|
||||
| CatalogProcessorEntityResult
|
||||
| CatalogProcessorRelationResult
|
||||
| CatalogProcessorErrorResult
|
||||
| CatalogProcessorRefreshKeysResult;
|
||||
|
||||
+2
-4
@@ -17,10 +17,8 @@ import { Entity, stringifyLocationRef } from '@backstage/catalog-model';
|
||||
import lodash from 'lodash';
|
||||
import yaml from 'yaml';
|
||||
import { LocationSpec } from '@backstage/plugin-catalog-common';
|
||||
import {
|
||||
CatalogProcessorResult,
|
||||
processingResult,
|
||||
} from '@backstage/plugin-catalog-node';
|
||||
import { CatalogProcessorResult } from './types';
|
||||
import { processingResult } from './processingResult';
|
||||
|
||||
// Copy from: https://github.com/backstage/backstage/blob/master/plugins/catalog-backend/src/modules/util/parse.ts
|
||||
export function* parseEntityYaml(
|
||||
@@ -1,16 +0,0 @@
|
||||
/*
|
||||
* Copyright 2023 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.
|
||||
*/
|
||||
export * from './utils';
|
||||
@@ -5770,8 +5770,8 @@ __metadata:
|
||||
"@backstage/core-components": "workspace:^"
|
||||
"@backstage/core-plugin-api": "workspace:^"
|
||||
"@backstage/dev-utils": "workspace:^"
|
||||
"@backstage/errors": "workspace:^"
|
||||
"@backstage/plugin-catalog-common": "workspace:^"
|
||||
"@backstage/plugin-catalog-node": "workspace:^"
|
||||
"@backstage/plugin-catalog-react": "workspace:^"
|
||||
"@backstage/test-utils": "workspace:^"
|
||||
"@backstage/theme": "workspace:^"
|
||||
|
||||
Reference in New Issue
Block a user