Merge branch 'master' into techdocs/remove-warnings

Signed-off-by: Morgan Bentell <morgan.bentell@gmail.com>
This commit is contained in:
Morgan Bentell
2023-03-16 16:18:32 +01:00
committed by GitHub
1099 changed files with 36089 additions and 25992 deletions
+37
View File
@@ -1,5 +1,42 @@
# @backstage/plugin-entity-feedback
## 0.1.1
### Patch Changes
- 52b0022dab7: Updated dependency `msw` to `^1.0.0`.
- Updated dependencies
- @backstage/core-components@0.12.5
- @backstage/plugin-catalog-react@1.4.0
- @backstage/errors@1.1.5
- @backstage/core-plugin-api@1.5.0
- @backstage/catalog-model@1.2.1
- @backstage/theme@0.2.18
- @backstage/plugin-entity-feedback-common@0.1.0
## 0.1.1-next.2
### Patch Changes
- Updated dependencies
- @backstage/core-components@0.12.5-next.2
- @backstage/plugin-catalog-react@1.4.0-next.2
- @backstage/core-plugin-api@1.5.0-next.2
## 0.1.1-next.1
### Patch Changes
- 52b0022dab7: Updated dependency `msw` to `^1.0.0`.
- Updated dependencies
- @backstage/core-components@0.12.5-next.1
- @backstage/errors@1.1.5-next.0
- @backstage/core-plugin-api@1.4.1-next.1
- @backstage/theme@0.2.18-next.0
- @backstage/plugin-catalog-react@1.4.0-next.1
- @backstage/catalog-model@1.2.1-next.1
- @backstage/plugin-entity-feedback-common@0.1.0
## 0.1.1-next.0
### Patch Changes
+4
View File
@@ -13,6 +13,7 @@ import { EntityRatingsData } from '@backstage/plugin-entity-feedback-common';
import { FeedbackResponse } from '@backstage/plugin-entity-feedback-common';
import { FetchApi } from '@backstage/core-plugin-api';
import { Rating } from '@backstage/plugin-entity-feedback-common';
import { Ratings } from '@backstage/plugin-entity-feedback-common';
import { ReactNode } from 'react';
import { RouteRef } from '@backstage/core-plugin-api';
@@ -22,6 +23,7 @@ export interface EntityFeedbackApi {
getAllRatings(): Promise<EntityRatingsData[]>;
// (undocumented)
getOwnedRatings(ownerRef: string): Promise<EntityRatingsData[]>;
getRatingAggregates(entityRef: string): Promise<Ratings>;
// (undocumented)
getRatings(entityRef: string): Promise<Omit<Rating, 'entityRef'>[]>;
// (undocumented)
@@ -48,6 +50,8 @@ export class EntityFeedbackClient implements EntityFeedbackApi {
// (undocumented)
getOwnedRatings(ownerRef: string): Promise<EntityRatingsData[]>;
// (undocumented)
getRatingAggregates(entityRef: string): Promise<Ratings>;
// (undocumented)
getRatings(entityRef: string): Promise<Omit<Rating, 'entityRef'>[]>;
// (undocumented)
getResponses(
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@backstage/plugin-entity-feedback",
"version": "0.1.1-next.0",
"version": "0.1.1",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "Apache-2.0",
@@ -19,6 +19,7 @@ import {
EntityRatingsData,
FeedbackResponse,
Rating,
Ratings,
} from '@backstage/plugin-entity-feedback-common';
/**
@@ -40,6 +41,11 @@ export interface EntityFeedbackApi {
getRatings(entityRef: string): Promise<Omit<Rating, 'entityRef'>[]>;
/**
* Returns anonymized aggregated results for one entityRef
*/
getRatingAggregates(entityRef: string): Promise<Ratings>;
recordResponse(
entityRef: string,
response: Omit<FeedbackResponse, 'entityRef' | 'userRef'>,
@@ -121,6 +121,24 @@ describe('EntityFeedbackClient', () => {
expect(response).toEqual(ratings);
});
it('getRatingAggregates', async () => {
const ratings = { LIKE: 3, DISLIKE: 5 };
server.use(
rest.get(
`${mockBaseUrl}/ratings/${encodeURIComponent(
'component:default/service',
)}/aggregate`,
(_, res, ctx) => res(ctx.json(ratings)),
),
);
const response = await client.getRatingAggregates(
'component:default/service',
);
expect(response).toEqual(ratings);
});
it('recordResponse', async () => {
expect.assertions(1);
const response = {
@@ -20,6 +20,7 @@ import {
EntityRatingsData,
FeedbackResponse,
Rating,
Ratings,
} from '@backstage/plugin-entity-feedback-common';
import { EntityFeedbackApi } from './EntityFeedbackApi';
@@ -97,6 +98,22 @@ export class EntityFeedbackClient implements EntityFeedbackApi {
return resp.json();
}
async getRatingAggregates(entityRef: string): Promise<Ratings> {
const baseUrl = await this.discoveryApi.getBaseUrl('entity-feedback');
const resp = await this.fetchApi.fetch(
`${baseUrl}/ratings/${encodeURIComponent(entityRef)}/aggregate`,
{
method: 'GET',
},
);
if (!resp.ok) {
throw await ResponseError.fromResponse(resp);
}
return resp.json();
}
async recordResponse(
entityRef: string,
response: Omit<FeedbackResponse, 'entityRef' | 'userRef'>,