feat(plugins/pagerduty): prefix exported types with PagerDuty

* generate api-report.md
* ensure generic exported types are prefixed with PagerDuty for ease of
  import by consumers

Signed-off-by: Alec Jacobs <cajacobs5401@gmail.com>
This commit is contained in:
Alec Jacobs
2022-06-17 08:37:28 -07:00
parent 24511a3beb
commit 8ac5b73da2
14 changed files with 210 additions and 193 deletions
+115 -111
View File
@@ -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<PagerDutyApi>;
// 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<PagerDutyApi>;
// 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<ChangeEventsResponse>;
getChangeEventsByServiceId(
serviceId: string,
): Promise<PagerDutyChangeEventsResponse>;
// (undocumented)
getIncidentsByServiceId(serviceId: string): Promise<IncidentsResponse>;
getIncidentsByServiceId(
serviceId: string,
): Promise<PagerDutyIncidentsResponse>;
// (undocumented)
getOnCallByPolicyId(policyId: string): Promise<OnCallsResponse>;
getOnCallByPolicyId(policyId: string): Promise<PagerDutyOnCallsResponse>;
// (undocumented)
getServiceByEntity(
pagerDutyEntity: PagerDutyEntity,
): Promise<ServiceResponse>;
): Promise<PagerDutyServiceResponse>;
// (undocumented)
triggerAlarm(request: TriggerAlarmRequest): Promise<Response>;
triggerAlarm(request: PagerDutyTriggerAlarmRequest): Promise<Response>;
}
// 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;
};
```
+3 -3
View File
@@ -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',
+25 -21
View File
@@ -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<ServiceResponse> {
): Promise<PagerDutyServiceResponse> {
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<ServicesResponse>(url);
const { services } = await this.getByUrl<PagerDutyServicesResponse>(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<ServiceResponse>(url);
response = await this.getByUrl<PagerDutyServiceResponse>(url);
} else {
throw new NotFoundError();
}
@@ -87,36 +87,40 @@ export class PagerDutyClient implements PagerDutyApi {
return response;
}
async getIncidentsByServiceId(serviceId: string): Promise<IncidentsResponse> {
async getIncidentsByServiceId(
serviceId: string,
): Promise<PagerDutyIncidentsResponse> {
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<IncidentsResponse>(url);
return await this.getByUrl<PagerDutyIncidentsResponse>(url);
}
async getChangeEventsByServiceId(
serviceId: string,
): Promise<ChangeEventsResponse> {
): Promise<PagerDutyChangeEventsResponse> {
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<ChangeEventsResponse>(url);
return await this.getByUrl<PagerDutyChangeEventsResponse>(url);
}
async getOnCallByPolicyId(policyId: string): Promise<OnCallsResponse> {
async getOnCallByPolicyId(
policyId: string,
): Promise<PagerDutyOnCallsResponse> {
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<OnCallsResponse>(url);
return await this.getByUrl<PagerDutyOnCallsResponse>(url);
}
triggerAlarm(request: TriggerAlarmRequest): Promise<Response> {
triggerAlarm(request: PagerDutyTriggerAlarmRequest): Promise<Response> {
const { integrationKey, source, description, userName } = request;
const body = JSON.stringify({
+7 -7
View File
@@ -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';
+28 -19
View File
@@ -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<ServiceResponse>;
): Promise<PagerDutyServiceResponse>;
/**
* Fetches a list of incidents a provided service has.
*
*/
getIncidentsByServiceId(serviceId: string): Promise<IncidentsResponse>;
getIncidentsByServiceId(
serviceId: string,
): Promise<PagerDutyIncidentsResponse>;
/**
* Fetches a list of change events a provided service has.
*
*/
getChangeEventsByServiceId(serviceId: string): Promise<ChangeEventsResponse>;
getChangeEventsByServiceId(
serviceId: string,
): Promise<PagerDutyChangeEventsResponse>;
/**
* Fetches the list of users in an escalation policy.
*
*/
getOnCallByPolicyId(policyId: string): Promise<OnCallsResponse>;
getOnCallByPolicyId(policyId: string): Promise<PagerDutyOnCallsResponse>;
/**
* Triggers an incident to whoever is on-call.
*/
triggerAlarm(request: TriggerAlarmRequest): Promise<Response>;
triggerAlarm(request: PagerDutyTriggerAlarmRequest): Promise<Response>;
}
export type ClientApiDependencies = {
export type PagerDutyClientApiDependencies = {
discoveryApi: DiscoveryApi;
fetchApi: FetchApi;
};
export type ClientApiConfig = ClientApiDependencies & {
export type PagerDutyClientApiConfig = PagerDutyClientApiDependencies & {
eventsBaseUrl?: string;
};
@@ -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<BackstageTheme>({
});
type Props = {
changeEvent: ChangeEvent;
changeEvent: PagerDutyChangeEvent;
};
export const ChangeEventListItem = ({ changeEvent }: Props) => {
@@ -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(
@@ -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,
},
],
}));
@@ -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) => {
@@ -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<BackstageTheme>(theme => ({
}));
type Props = {
incident: Incident;
incident: PagerDutyIncident;
};
export const IncidentListItem = ({ incident }: Props) => {
@@ -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(
@@ -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',
+6 -6
View File
@@ -15,12 +15,12 @@
*/
export type {
ChangeEvent,
Incident,
Service,
OnCall,
Assignee,
User,
PagerDutyChangeEvent,
PagerDutyIncident,
PagerDutyService,
PagerDutyOnCall,
PagerDutyAssignee,
PagerDutyUser,
} from './types';
export {
+10 -10
View File
@@ -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;