Integrated feedback from @freben
Signed-off-by: Taras <tarasm@gmail.com>
This commit is contained in:
@@ -2,4 +2,4 @@
|
||||
'@backstage/catalog-client': minor
|
||||
---
|
||||
|
||||
Adding validateEntity method that calls /validate-entity endpoint
|
||||
Adding `validateEntity` method that calls `/validate-entity` endpoint.
|
||||
|
||||
@@ -209,8 +209,12 @@ type Location_2 = {
|
||||
export { Location_2 as Location };
|
||||
|
||||
// @public
|
||||
export type ValidateEntityResponse = {
|
||||
valid: boolean;
|
||||
errors?: SerializedError[];
|
||||
};
|
||||
export type ValidateEntityResponse =
|
||||
| {
|
||||
valid: true;
|
||||
}
|
||||
| {
|
||||
valid: false;
|
||||
errors: SerializedError[];
|
||||
};
|
||||
```
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
stringifyEntityRef,
|
||||
stringifyLocationRef,
|
||||
} from '@backstage/catalog-model';
|
||||
import { ResponseError, SerializedError } from '@backstage/errors';
|
||||
import { ResponseError } from '@backstage/errors';
|
||||
import crossFetch from 'cross-fetch';
|
||||
import {
|
||||
CATALOG_FILTER_EXISTS,
|
||||
@@ -377,11 +377,14 @@ export class CatalogClient implements CatalogApi {
|
||||
if (response.ok) {
|
||||
return {
|
||||
valid: true,
|
||||
errors: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
const { errors } = (await response.json()) as { errors: SerializedError[] };
|
||||
if (response.status !== 400) {
|
||||
throw await ResponseError.fromResponse(response);
|
||||
}
|
||||
|
||||
const { errors = [] } = await response.json();
|
||||
|
||||
return {
|
||||
valid: false,
|
||||
|
||||
@@ -275,10 +275,9 @@ export type AddLocationResponse = {
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type ValidateEntityResponse = {
|
||||
valid: boolean;
|
||||
errors?: SerializedError[];
|
||||
};
|
||||
export type ValidateEntityResponse =
|
||||
| { valid: true }
|
||||
| { valid: false; errors: SerializedError[] };
|
||||
|
||||
/**
|
||||
* A client for interacting with the Backstage software catalog through its API.
|
||||
|
||||
Reference in New Issue
Block a user