Integrated feedback from @freben

Signed-off-by: Taras <tarasm@gmail.com>
This commit is contained in:
Taras
2022-09-08 08:42:07 -04:00
parent 65d1d4343f
commit 2a46e3701e
4 changed files with 18 additions and 12 deletions
+1 -1
View File
@@ -2,4 +2,4 @@
'@backstage/catalog-client': minor
---
Adding validateEntity method that calls /validate-entity endpoint
Adding `validateEntity` method that calls `/validate-entity` endpoint.
+8 -4
View File
@@ -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[];
};
```
+6 -3
View File
@@ -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,
+3 -4
View File
@@ -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.