diff --git a/plugins/pagerduty/api-report.md b/plugins/pagerduty/api-report.md index dd6155521b..04cda3da91 100644 --- a/plugins/pagerduty/api-report.md +++ b/plugins/pagerduty/api-report.md @@ -13,23 +13,46 @@ import { Entity } from '@backstage/catalog-model'; import { FetchApi } from '@backstage/core-plugin-api'; import { ReactNode } from 'react'; -// Warning: (ae-missing-release-tag) "Assignee" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// Warning: (ae-missing-release-tag) "EntityPagerDutyCard" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export type Assignee = { +export const EntityPagerDutyCard: () => JSX.Element; + +// Warning: (ae-missing-release-tag) "isPluginApplicableToEntity" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +const isPluginApplicableToEntity: (entity: Entity) => boolean; +export { isPluginApplicableToEntity as isPagerDutyAvailable }; +export { isPluginApplicableToEntity }; + +// Warning: (ae-forgotten-export) The symbol "PagerDutyApi" needs to be exported by the entry point index.d.ts +// Warning: (ae-missing-release-tag) "pagerDutyApiRef" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export const pagerDutyApiRef: ApiRef; + +// Warning: (ae-missing-release-tag) "PagerDutyAssignee" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type PagerDutyAssignee = { id: string; summary: string; html_url: string; }; -// Warning: (ae-missing-release-tag) "ChangeEvent" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// Warning: (ae-missing-release-tag) "PagerDutyCard" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export type ChangeEvent = { +export const PagerDutyCard: () => JSX.Element; + +// Warning: (ae-missing-release-tag) "PagerDutyChangeEvent" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type PagerDutyChangeEvent = { id: string; integration: [ { - service: Service; + service: PagerDutyService; }, ]; source: string; @@ -44,114 +67,56 @@ export type ChangeEvent = { timestamp: string; }; -// Warning: (ae-missing-release-tag) "ChangeEventsResponse" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// Warning: (ae-missing-release-tag) "PagerDutyChangeEventsResponse" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export type ChangeEventsResponse = { - change_events: ChangeEvent[]; +export type PagerDutyChangeEventsResponse = { + change_events: PagerDutyChangeEvent[]; }; -// Warning: (ae-missing-release-tag) "ClientApiConfig" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type ClientApiConfig = ClientApiDependencies & { - eventsBaseUrl?: string; -}; - -// Warning: (ae-missing-release-tag) "ClientApiDependencies" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type ClientApiDependencies = { - discoveryApi: DiscoveryApi; - fetchApi: FetchApi; -}; - -// Warning: (ae-missing-release-tag) "EntityPagerDutyCard" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export const EntityPagerDutyCard: () => JSX.Element; - -// Warning: (ae-missing-release-tag) "Incident" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type Incident = { - id: string; - title: string; - status: string; - html_url: string; - assignments: [ - { - assignee: Assignee; - }, - ]; - serviceId: string; - created_at: string; -}; - -// Warning: (ae-missing-release-tag) "IncidentsResponse" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type IncidentsResponse = { - incidents: Incident[]; -}; - -// Warning: (ae-missing-release-tag) "isPluginApplicableToEntity" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -const isPluginApplicableToEntity: (entity: Entity) => boolean; -export { isPluginApplicableToEntity as isPagerDutyAvailable }; -export { isPluginApplicableToEntity }; - -// Warning: (ae-missing-release-tag) "OnCall" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type OnCall = { - user: User; - escalation_level: number; -}; - -// Warning: (ae-missing-release-tag) "OnCallsResponse" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type OnCallsResponse = { - oncalls: OnCall[]; -}; - -// Warning: (ae-forgotten-export) The symbol "PagerDutyApi" needs to be exported by the entry point index.d.ts -// Warning: (ae-missing-release-tag) "pagerDutyApiRef" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export const pagerDutyApiRef: ApiRef; - -// Warning: (ae-missing-release-tag) "PagerDutyCard" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export const PagerDutyCard: () => JSX.Element; - // Warning: (ae-missing-release-tag) "PagerDutyClient" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) export class PagerDutyClient implements PagerDutyApi { - constructor(config: ClientApiConfig); + constructor(config: PagerDutyClientApiConfig); // (undocumented) static fromConfig( configApi: ConfigApi, - { discoveryApi, fetchApi }: ClientApiDependencies, + { discoveryApi, fetchApi }: PagerDutyClientApiDependencies, ): PagerDutyClient; // (undocumented) - getChangeEventsByServiceId(serviceId: string): Promise; + getChangeEventsByServiceId( + serviceId: string, + ): Promise; // (undocumented) - getIncidentsByServiceId(serviceId: string): Promise; + getIncidentsByServiceId( + serviceId: string, + ): Promise; // (undocumented) - getOnCallByPolicyId(policyId: string): Promise; + getOnCallByPolicyId(policyId: string): Promise; // (undocumented) getServiceByEntity( pagerDutyEntity: PagerDutyEntity, - ): Promise; + ): Promise; // (undocumented) - triggerAlarm(request: TriggerAlarmRequest): Promise; + triggerAlarm(request: PagerDutyTriggerAlarmRequest): Promise; } +// Warning: (ae-missing-release-tag) "PagerDutyClientApiConfig" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type PagerDutyClientApiConfig = PagerDutyClientApiDependencies & { + eventsBaseUrl?: string; +}; + +// Warning: (ae-missing-release-tag) "PagerDutyClientApiDependencies" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type PagerDutyClientApiDependencies = { + discoveryApi: DiscoveryApi; + fetchApi: FetchApi; +}; + // Warning: (ae-missing-release-tag) "PagerDutyEntity" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -161,6 +126,45 @@ export type PagerDutyEntity = { name: string; }; +// Warning: (ae-missing-release-tag) "PagerDutyIncident" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type PagerDutyIncident = { + id: string; + title: string; + status: string; + html_url: string; + assignments: [ + { + assignee: PagerDutyAssignee; + }, + ]; + serviceId: string; + created_at: string; +}; + +// Warning: (ae-missing-release-tag) "PagerDutyIncidentsResponse" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type PagerDutyIncidentsResponse = { + incidents: PagerDutyIncident[]; +}; + +// Warning: (ae-missing-release-tag) "PagerDutyOnCall" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type PagerDutyOnCall = { + user: PagerDutyUser; + escalation_level: number; +}; + +// Warning: (ae-missing-release-tag) "PagerDutyOnCallsResponse" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type PagerDutyOnCallsResponse = { + oncalls: PagerDutyOnCall[]; +}; + // Warning: (ae-missing-release-tag) "pagerDutyPlugin" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -168,38 +172,49 @@ const pagerDutyPlugin: BackstagePlugin<{}, {}>; export { pagerDutyPlugin }; export { pagerDutyPlugin as plugin }; -// Warning: (ae-missing-release-tag) "Service" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// Warning: (ae-missing-release-tag) "PagerDutyService" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export type Service = { +export type PagerDutyService = { id: string; name: string; html_url: string; integrationKey: string; escalation_policy: { id: string; - user: User; + user: PagerDutyUser; html_url: string; }; }; -// Warning: (ae-missing-release-tag) "ServiceResponse" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// Warning: (ae-missing-release-tag) "PagerDutyServiceResponse" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export type ServiceResponse = { - service: Service; +export type PagerDutyServiceResponse = { + service: PagerDutyService; }; -// Warning: (ae-missing-release-tag) "TriggerAlarmRequest" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// Warning: (ae-missing-release-tag) "PagerDutyTriggerAlarmRequest" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export type TriggerAlarmRequest = { +export type PagerDutyTriggerAlarmRequest = { integrationKey: string; source: string; description: string; userName: string; }; +// Warning: (ae-missing-release-tag) "PagerDutyUser" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type PagerDutyUser = { + id: string; + summary: string; + email: string; + html_url: string; + name: string; +}; + // Warning: (ae-forgotten-export) The symbol "TriggerButtonProps" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "TriggerButton" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -210,15 +225,4 @@ export function TriggerButton(props: TriggerButtonProps): JSX.Element; // // @public (undocumented) export class UnauthorizedError extends Error {} - -// Warning: (ae-missing-release-tag) "User" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type User = { - id: string; - summary: string; - email: string; - html_url: string; - name: string; -}; ``` diff --git a/plugins/pagerduty/src/api/client.test.ts b/plugins/pagerduty/src/api/client.test.ts index d3e9b58542..2e9efefb18 100644 --- a/plugins/pagerduty/src/api/client.test.ts +++ b/plugins/pagerduty/src/api/client.test.ts @@ -17,7 +17,7 @@ import { MockFetchApi } from '@backstage/test-utils'; import { DiscoveryApi } from '@backstage/core-plugin-api'; import { PagerDutyClient, UnauthorizedError } from './client'; import { PagerDutyEntity } from '../types'; -import { Service, User } from '../components/types'; +import { PagerDutyService, PagerDutyUser } from '../components/types'; import { NotFoundError } from '@backstage/errors'; const mockFetch = jest.fn().mockName('fetch'); @@ -34,7 +34,7 @@ const mockFetchApi: MockFetchApi = new MockFetchApi({ let client: PagerDutyClient; let pagerDutyEntity: PagerDutyEntity; -const user: User = { +const user: PagerDutyUser = { name: 'person1', id: 'p1', summary: 'person1', @@ -42,7 +42,7 @@ const user: User = { html_url: 'http://a.com/id1', }; -const service: Service = { +const service: PagerDutyService = { id: 'def456', name: 'pagerduty-name', html_url: 'www.example.com', diff --git a/plugins/pagerduty/src/api/client.ts b/plugins/pagerduty/src/api/client.ts index ebf350add2..dbb4248f0f 100644 --- a/plugins/pagerduty/src/api/client.ts +++ b/plugins/pagerduty/src/api/client.ts @@ -16,15 +16,15 @@ import { PagerDutyApi, - TriggerAlarmRequest, - ServicesResponse, - ServiceResponse, - IncidentsResponse, - OnCallsResponse, - ClientApiDependencies, - ClientApiConfig, + PagerDutyTriggerAlarmRequest, + PagerDutyServicesResponse, + PagerDutyServiceResponse, + PagerDutyIncidentsResponse, + PagerDutyOnCallsResponse, + PagerDutyClientApiDependencies, + PagerDutyClientApiConfig, RequestOptions, - ChangeEventsResponse, + PagerDutyChangeEventsResponse, } from './types'; import { createApiRef, ConfigApi } from '@backstage/core-plugin-api'; import { NotFoundError } from '@backstage/errors'; @@ -42,7 +42,7 @@ const commonGetServiceParams = export class PagerDutyClient implements PagerDutyApi { static fromConfig( configApi: ConfigApi, - { discoveryApi, fetchApi }: ClientApiDependencies, + { discoveryApi, fetchApi }: PagerDutyClientApiDependencies, ) { const eventsBaseUrl: string = configApi.getOptionalString('pagerDuty.eventsBaseUrl') ?? @@ -54,21 +54,21 @@ export class PagerDutyClient implements PagerDutyApi { fetchApi, }); } - constructor(private readonly config: ClientApiConfig) {} + constructor(private readonly config: PagerDutyClientApiConfig) {} async getServiceByEntity( pagerDutyEntity: PagerDutyEntity, - ): Promise { + ): Promise { const { integrationKey, serviceId } = pagerDutyEntity; - let response: ServiceResponse; + let response: PagerDutyServiceResponse; let url: string; if (integrationKey) { url = `${await this.config.discoveryApi.getBaseUrl( 'proxy', )}/pagerduty/services?${commonGetServiceParams}&query=${integrationKey}`; - const { services } = await this.getByUrl(url); + const { services } = await this.getByUrl(url); const service = services[0]; if (!service) throw new NotFoundError(); @@ -79,7 +79,7 @@ export class PagerDutyClient implements PagerDutyApi { 'proxy', )}/pagerduty/services/${serviceId}?${commonGetServiceParams}`; - response = await this.getByUrl(url); + response = await this.getByUrl(url); } else { throw new NotFoundError(); } @@ -87,36 +87,40 @@ export class PagerDutyClient implements PagerDutyApi { return response; } - async getIncidentsByServiceId(serviceId: string): Promise { + async getIncidentsByServiceId( + serviceId: string, + ): Promise { const params = `time_zone=UTC&sort_by=created_at&statuses[]=triggered&statuses[]=acknowledged&service_ids[]=${serviceId}`; const url = `${await this.config.discoveryApi.getBaseUrl( 'proxy', )}/pagerduty/incidents?${params}`; - return await this.getByUrl(url); + return await this.getByUrl(url); } async getChangeEventsByServiceId( serviceId: string, - ): Promise { + ): Promise { const params = `limit=5&time_zone=UTC&sort_by=timestamp`; const url = `${await this.config.discoveryApi.getBaseUrl( 'proxy', )}/pagerduty/services/${serviceId}/change_events?${params}`; - return await this.getByUrl(url); + return await this.getByUrl(url); } - async getOnCallByPolicyId(policyId: string): Promise { + async getOnCallByPolicyId( + policyId: string, + ): Promise { const params = `time_zone=UTC&include[]=users&escalation_policy_ids[]=${policyId}`; const url = `${await this.config.discoveryApi.getBaseUrl( 'proxy', )}/pagerduty/oncalls?${params}`; - return await this.getByUrl(url); + return await this.getByUrl(url); } - triggerAlarm(request: TriggerAlarmRequest): Promise { + triggerAlarm(request: PagerDutyTriggerAlarmRequest): Promise { const { integrationKey, source, description, userName } = request; const body = JSON.stringify({ diff --git a/plugins/pagerduty/src/api/index.ts b/plugins/pagerduty/src/api/index.ts index a88137b979..9a0c08973d 100644 --- a/plugins/pagerduty/src/api/index.ts +++ b/plugins/pagerduty/src/api/index.ts @@ -16,11 +16,11 @@ export { PagerDutyClient, pagerDutyApiRef, UnauthorizedError } from './client'; export type { - ServiceResponse, - IncidentsResponse, - ChangeEventsResponse, - OnCallsResponse, - TriggerAlarmRequest, - ClientApiDependencies, - ClientApiConfig, + PagerDutyServiceResponse, + PagerDutyIncidentsResponse, + PagerDutyChangeEventsResponse, + PagerDutyOnCallsResponse, + PagerDutyTriggerAlarmRequest, + PagerDutyClientApiDependencies, + PagerDutyClientApiConfig, } from './types'; diff --git a/plugins/pagerduty/src/api/types.ts b/plugins/pagerduty/src/api/types.ts index ed6c1f222a..5163718154 100644 --- a/plugins/pagerduty/src/api/types.ts +++ b/plugins/pagerduty/src/api/types.ts @@ -14,31 +14,36 @@ * limitations under the License. */ -import { Incident, ChangeEvent, OnCall, Service } from '../components/types'; +import { + PagerDutyIncident, + PagerDutyChangeEvent, + PagerDutyOnCall, + PagerDutyService, +} from '../components/types'; import { DiscoveryApi, FetchApi } from '@backstage/core-plugin-api'; import { PagerDutyEntity } from '../types'; -export type ServicesResponse = { - services: Service[]; +export type PagerDutyServicesResponse = { + services: PagerDutyService[]; }; -export type ServiceResponse = { - service: Service; +export type PagerDutyServiceResponse = { + service: PagerDutyService; }; -export type IncidentsResponse = { - incidents: Incident[]; +export type PagerDutyIncidentsResponse = { + incidents: PagerDutyIncident[]; }; -export type ChangeEventsResponse = { - change_events: ChangeEvent[]; +export type PagerDutyChangeEventsResponse = { + change_events: PagerDutyChangeEvent[]; }; -export type OnCallsResponse = { - oncalls: OnCall[]; +export type PagerDutyOnCallsResponse = { + oncalls: PagerDutyOnCall[]; }; -export type TriggerAlarmRequest = { +export type PagerDutyTriggerAlarmRequest = { integrationKey: string; source: string; description: string; @@ -52,38 +57,42 @@ export interface PagerDutyApi { */ getServiceByEntity( pagerDutyEntity: PagerDutyEntity, - ): Promise; + ): Promise; /** * Fetches a list of incidents a provided service has. * */ - getIncidentsByServiceId(serviceId: string): Promise; + getIncidentsByServiceId( + serviceId: string, + ): Promise; /** * Fetches a list of change events a provided service has. * */ - getChangeEventsByServiceId(serviceId: string): Promise; + getChangeEventsByServiceId( + serviceId: string, + ): Promise; /** * Fetches the list of users in an escalation policy. * */ - getOnCallByPolicyId(policyId: string): Promise; + getOnCallByPolicyId(policyId: string): Promise; /** * Triggers an incident to whoever is on-call. */ - triggerAlarm(request: TriggerAlarmRequest): Promise; + triggerAlarm(request: PagerDutyTriggerAlarmRequest): Promise; } -export type ClientApiDependencies = { +export type PagerDutyClientApiDependencies = { discoveryApi: DiscoveryApi; fetchApi: FetchApi; }; -export type ClientApiConfig = ClientApiDependencies & { +export type PagerDutyClientApiConfig = PagerDutyClientApiDependencies & { eventsBaseUrl?: string; }; diff --git a/plugins/pagerduty/src/components/ChangeEvents/ChangeEventListItem.tsx b/plugins/pagerduty/src/components/ChangeEvents/ChangeEventListItem.tsx index 4912277cee..505d58eabb 100644 --- a/plugins/pagerduty/src/components/ChangeEvents/ChangeEventListItem.tsx +++ b/plugins/pagerduty/src/components/ChangeEvents/ChangeEventListItem.tsx @@ -26,7 +26,7 @@ import { Typography, } from '@material-ui/core'; import { DateTime, Duration } from 'luxon'; -import { ChangeEvent } from '../types'; +import { PagerDutyChangeEvent } from '../types'; import OpenInBrowserIcon from '@material-ui/icons/OpenInBrowser'; import { BackstageTheme } from '@backstage/theme'; @@ -44,7 +44,7 @@ const useStyles = makeStyles({ }); type Props = { - changeEvent: ChangeEvent; + changeEvent: PagerDutyChangeEvent; }; export const ChangeEventListItem = ({ changeEvent }: Props) => { diff --git a/plugins/pagerduty/src/components/ChangeEvents/ChangeEvents.test.tsx b/plugins/pagerduty/src/components/ChangeEvents/ChangeEvents.test.tsx index 017e394de0..a518e0caea 100644 --- a/plugins/pagerduty/src/components/ChangeEvents/ChangeEvents.test.tsx +++ b/plugins/pagerduty/src/components/ChangeEvents/ChangeEvents.test.tsx @@ -15,7 +15,7 @@ */ import React from 'react'; import { render, waitFor } from '@testing-library/react'; -import { ChangeEvent } from '../types'; +import { PagerDutyChangeEvent } from '../types'; import { TestApiRegistry, wrapInTestApp } from '@backstage/test-utils'; import { pagerDutyApiRef } from '../../api'; import { ApiProvider } from '@backstage/core-app-api'; @@ -74,7 +74,7 @@ describe('Incidents', () => { summary: 'sum of EVENT', timestamp: '2020-07-18T08:42:58.315+0000', }, - ] as ChangeEvent[], + ] as PagerDutyChangeEvent[], })); const { getByText, getAllByTitle, queryByTestId } = render( wrapInTestApp( @@ -121,7 +121,7 @@ describe('Incidents', () => { summary: 'sum of EVENT', timestamp: '2020-07-18T08:42:58.315+0000', }, - ] as ChangeEvent[], + ] as PagerDutyChangeEvent[], })); const { getByText, getAllByTitle, queryByTestId } = render( wrapInTestApp( diff --git a/plugins/pagerduty/src/components/Escalation/Escalation.test.tsx b/plugins/pagerduty/src/components/Escalation/Escalation.test.tsx index 33e8865f59..97c02a37f3 100644 --- a/plugins/pagerduty/src/components/Escalation/Escalation.test.tsx +++ b/plugins/pagerduty/src/components/Escalation/Escalation.test.tsx @@ -17,7 +17,7 @@ import React from 'react'; import { render, waitFor } from '@testing-library/react'; import { EscalationPolicy } from './EscalationPolicy'; import { TestApiRegistry, wrapInTestApp } from '@backstage/test-utils'; -import { User } from '../types'; +import { PagerDutyUser } from '../types'; import { pagerDutyApiRef } from '../../api'; import { ApiProvider } from '@backstage/core-app-api'; @@ -57,7 +57,7 @@ describe('Escalation', () => { summary: 'person1', email: 'person1@example.com', html_url: 'http://a.com/id1', - } as User, + } as PagerDutyUser, }, ], })); diff --git a/plugins/pagerduty/src/components/Escalation/EscalationUser.tsx b/plugins/pagerduty/src/components/Escalation/EscalationUser.tsx index a460906d22..d418ad02c0 100644 --- a/plugins/pagerduty/src/components/Escalation/EscalationUser.tsx +++ b/plugins/pagerduty/src/components/Escalation/EscalationUser.tsx @@ -28,7 +28,7 @@ import { import Avatar from '@material-ui/core/Avatar'; import EmailIcon from '@material-ui/icons/Email'; import OpenInBrowserIcon from '@material-ui/icons/OpenInBrowser'; -import { User } from '../types'; +import { PagerDutyUser } from '../types'; const useStyles = makeStyles({ listItemPrimary: { @@ -37,7 +37,7 @@ const useStyles = makeStyles({ }); type Props = { - user: User; + user: PagerDutyUser; }; export const EscalationUser = ({ user }: Props) => { diff --git a/plugins/pagerduty/src/components/Incident/IncidentListItem.tsx b/plugins/pagerduty/src/components/Incident/IncidentListItem.tsx index 807685a83e..5945c45e83 100644 --- a/plugins/pagerduty/src/components/Incident/IncidentListItem.tsx +++ b/plugins/pagerduty/src/components/Incident/IncidentListItem.tsx @@ -29,7 +29,7 @@ import { import Done from '@material-ui/icons/Done'; import Warning from '@material-ui/icons/Warning'; import { DateTime, Duration } from 'luxon'; -import { Incident } from '../types'; +import { PagerDutyIncident } from '../types'; import OpenInBrowserIcon from '@material-ui/icons/OpenInBrowser'; import { BackstageTheme } from '@backstage/theme'; @@ -61,7 +61,7 @@ const useStyles = makeStyles(theme => ({ })); type Props = { - incident: Incident; + incident: PagerDutyIncident; }; export const IncidentListItem = ({ incident }: Props) => { diff --git a/plugins/pagerduty/src/components/Incident/Incidents.test.tsx b/plugins/pagerduty/src/components/Incident/Incidents.test.tsx index ad69bc083e..a83874a995 100644 --- a/plugins/pagerduty/src/components/Incident/Incidents.test.tsx +++ b/plugins/pagerduty/src/components/Incident/Incidents.test.tsx @@ -18,7 +18,7 @@ import { render, waitFor } from '@testing-library/react'; import { Incidents } from './Incidents'; import { TestApiRegistry, wrapInTestApp } from '@backstage/test-utils'; import { pagerDutyApiRef } from '../../api'; -import { Incident } from '../types'; +import { PagerDutyIncident } from '../types'; import { ApiProvider } from '@backstage/core-app-api'; const mockPagerDutyApi = { @@ -83,7 +83,7 @@ describe('Incidents', () => { html_url: 'http://a.com/id2', serviceId: 'sId2', }, - ] as Incident[], + ] as PagerDutyIncident[], })); const { getByText, getAllByTitle, queryByTestId } = render( wrapInTestApp( diff --git a/plugins/pagerduty/src/components/PagerDutyCard/index.test.tsx b/plugins/pagerduty/src/components/PagerDutyCard/index.test.tsx index 9a6e9a3ed2..85202a9cfc 100644 --- a/plugins/pagerduty/src/components/PagerDutyCard/index.test.tsx +++ b/plugins/pagerduty/src/components/PagerDutyCard/index.test.tsx @@ -21,7 +21,7 @@ import { EntityProvider } from '@backstage/plugin-catalog-react'; import { NotFoundError } from '@backstage/errors'; import { TestApiRegistry, wrapInTestApp } from '@backstage/test-utils'; import { pagerDutyApiRef, UnauthorizedError, PagerDutyClient } from '../../api'; -import { Service, User } from '../types'; +import { PagerDutyService, PagerDutyUser } from '../types'; import { alertApiRef } from '@backstage/core-plugin-api'; import { ApiProvider } from '@backstage/core-app-api'; @@ -69,7 +69,7 @@ const entityWithAllAnnotations: Entity = { }, }; -const user: User = { +const user: PagerDutyUser = { name: 'person1', id: 'p1', summary: 'person1', @@ -77,7 +77,7 @@ const user: User = { html_url: 'http://a.com/id1', }; -const service: Service = { +const service: PagerDutyService = { id: 'def456', name: 'pagerduty-name', html_url: 'www.example.com', diff --git a/plugins/pagerduty/src/components/index.ts b/plugins/pagerduty/src/components/index.ts index a452c12e12..17bb2c03dc 100644 --- a/plugins/pagerduty/src/components/index.ts +++ b/plugins/pagerduty/src/components/index.ts @@ -15,12 +15,12 @@ */ export type { - ChangeEvent, - Incident, - Service, - OnCall, - Assignee, - User, + PagerDutyChangeEvent, + PagerDutyIncident, + PagerDutyService, + PagerDutyOnCall, + PagerDutyAssignee, + PagerDutyUser, } from './types'; export { diff --git a/plugins/pagerduty/src/components/types.ts b/plugins/pagerduty/src/components/types.ts index d0d05d82d1..89cdffea16 100644 --- a/plugins/pagerduty/src/components/types.ts +++ b/plugins/pagerduty/src/components/types.ts @@ -14,11 +14,11 @@ * limitations under the License. */ -export type ChangeEvent = { +export type PagerDutyChangeEvent = { id: string; integration: [ { - service: Service; + service: PagerDutyService; }, ]; source: string; @@ -33,44 +33,44 @@ export type ChangeEvent = { timestamp: string; }; -export type Incident = { +export type PagerDutyIncident = { id: string; title: string; status: string; html_url: string; assignments: [ { - assignee: Assignee; + assignee: PagerDutyAssignee; }, ]; serviceId: string; created_at: string; }; -export type Service = { +export type PagerDutyService = { id: string; name: string; html_url: string; integrationKey: string; escalation_policy: { id: string; - user: User; + user: PagerDutyUser; html_url: string; }; }; -export type OnCall = { - user: User; +export type PagerDutyOnCall = { + user: PagerDutyUser; escalation_level: number; }; -export type Assignee = { +export type PagerDutyAssignee = { id: string; summary: string; html_url: string; }; -export type User = { +export type PagerDutyUser = { id: string; summary: string; email: string;