unpack props inside component bodies

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2023-02-27 15:31:15 +01:00
parent babbaa9391
commit 65454876fb
51 changed files with 253 additions and 297 deletions
+21
View File
@@ -0,0 +1,21 @@
---
'@backstage/plugin-search-backend-module-elasticsearch': patch
'@backstage/plugin-tech-insights-backend-module-jsonfc': patch
'@backstage/plugin-catalog-backend-module-github': patch
'@backstage/plugin-scaffolder-backend': patch
'@backstage/plugin-scaffolder-react': patch
'@backstage/plugin-splunk-on-call': patch
'@backstage/plugin-techdocs-react': patch
'@backstage/plugin-catalog-react': patch
'@backstage/plugin-tech-insights': patch
'@backstage/plugin-techdocs-node': patch
'@backstage/plugin-search-react': patch
'@backstage/plugin-scaffolder': patch
'@backstage/plugin-auth-node': patch
'@backstage/plugin-sonarqube': patch
'@backstage/plugin-techdocs': patch
'@backstage/plugin-explore': patch
'@backstage/plugin-search': patch
---
Minor API report tweaks
+3 -5
View File
@@ -29,11 +29,9 @@ export class DefaultIdentityClient implements IdentityApi {
authenticate(token: string | undefined): Promise<BackstageIdentityResponse>;
static create(options: IdentityClientOptions): DefaultIdentityClient;
// (undocumented)
getIdentity({
request,
}: IdentityApiGetIdentityRequest): Promise<
BackstageIdentityResponse | undefined
>;
getIdentity(
options: IdentityApiGetIdentityRequest,
): Promise<BackstageIdentityResponse | undefined>;
}
// @public
@@ -78,13 +78,16 @@ export class DefaultIdentityClient implements IdentityApi {
: ['ES256'];
}
async getIdentity({ request }: IdentityApiGetIdentityRequest) {
if (!request.headers.authorization) {
async getIdentity(options: IdentityApiGetIdentityRequest) {
const {
request: { headers },
} = options;
if (!headers.authorization) {
return undefined;
}
try {
return await this.authenticate(
getBearerTokenFromAuthorizationHeader(request.headers.authorization),
getBearerTokenFromAuthorizationHeader(headers.authorization),
);
} catch (e) {
throw new AuthenticationError(e.message);
@@ -103,7 +103,7 @@ export class GithubEntityProvider implements EntityProvider, EventSubscriber {
export class GithubLocationAnalyzer implements ScmLocationAnalyzer {
constructor(options: GithubLocationAnalyzerOptions);
// (undocumented)
analyze({ url, catalogFilename }: AnalyzeOptions): Promise<{
analyze(options: AnalyzeOptions): Promise<{
existing: {
location: {
type: string;
@@ -63,7 +63,8 @@ export class GithubLocationAnalyzer implements ScmLocationAnalyzer {
return integration?.type === 'github';
}
async analyze({ url, catalogFilename }: AnalyzeOptions) {
async analyze(options: AnalyzeOptions) {
const { url, catalogFilename } = options;
const { owner, name: repo } = parseGitUrl(url);
const catalogFile = catalogFilename || 'catalog-info.yaml';
+11 -16
View File
@@ -27,13 +27,9 @@ import { SystemEntity } from '@backstage/catalog-model';
import { TableColumn } from '@backstage/core-components';
// @public
export const AsyncEntityProvider: ({
children,
entity,
loading,
error,
refresh,
}: AsyncEntityProviderProps) => JSX.Element;
export const AsyncEntityProvider: (
props: AsyncEntityProviderProps,
) => JSX.Element;
// @public
export interface AsyncEntityProviderProps {
@@ -220,9 +216,9 @@ export type EntityListContextProps<
};
// @public
export const EntityListProvider: <EntityFilters extends DefaultEntityFilters>({
children,
}: PropsWithChildren<{}>) => JSX.Element;
export const EntityListProvider: <EntityFilters extends DefaultEntityFilters>(
props: PropsWithChildren<{}>,
) => JSX.Element;
// @public (undocumented)
export type EntityLoadingStatus<TEntity extends Entity = Entity> = {
@@ -476,12 +472,11 @@ export function InspectEntityDialog(props: {
// @public (undocumented)
export function MockEntityListContextProvider<
T extends DefaultEntityFilters = DefaultEntityFilters,
>({
children,
value,
}: PropsWithChildren<{
value?: Partial<EntityListContextProps<T>>;
}>): JSX.Element;
>(
props: PropsWithChildren<{
value?: Partial<EntityListContextProps<T>>;
}>,
): JSX.Element;
// @public
export class MockStarredEntitiesApi implements StarredEntitiesApi {
@@ -55,13 +55,8 @@ export interface AsyncEntityProviderProps {
*
* @public
*/
export const AsyncEntityProvider = ({
children,
entity,
loading,
error,
refresh,
}: AsyncEntityProviderProps) => {
export const AsyncEntityProvider = (props: AsyncEntityProviderProps) => {
const { children, entity, loading, error, refresh } = props;
const value = { entity, loading, error, refresh };
// We provide both the old and the new context, since
// consumers might be doing things like `useContext(EntityContext)`
@@ -115,9 +115,9 @@ type OutputState<EntityFilters extends DefaultEntityFilters> = {
* Provides entities and filters for a catalog listing.
* @public
*/
export const EntityListProvider = <EntityFilters extends DefaultEntityFilters>({
children,
}: PropsWithChildren<{}>) => {
export const EntityListProvider = <EntityFilters extends DefaultEntityFilters>(
props: PropsWithChildren<{}>,
) => {
const isMounted = useMountedState();
const catalogApi = useApi(catalogApiRef);
const [requestedFilters, setRequestedFilters] = useState<EntityFilters>(
@@ -248,7 +248,7 @@ export const EntityListProvider = <EntityFilters extends DefaultEntityFilters>({
return (
<EntityListContext.Provider value={value}>
{children}
{props.children}
</EntityListContext.Provider>
);
};
@@ -29,12 +29,13 @@ import {
/** @public */
export function MockEntityListContextProvider<
T extends DefaultEntityFilters = DefaultEntityFilters,
>({
children,
value,
}: PropsWithChildren<{
value?: Partial<EntityListContextProps<T>>;
}>) {
>(
props: PropsWithChildren<{
value?: Partial<EntityListContextProps<T>>;
}>,
) {
const { children, value } = props;
// Provides a default implementation that stores filter state, for testing components that
// reflect filter state.
const [filters, setFilters] = useState<T>(value?.filters ?? ({} as T));
+1 -5
View File
@@ -50,11 +50,7 @@ export const exploreApiRef: ApiRef<ExploreApi>;
// @public
export class ExploreClient implements ExploreApi {
constructor({
discoveryApi,
fetchApi,
exploreToolsConfig,
}: {
constructor(options: {
discoveryApi: DiscoveryApi;
fetchApi: FetchApi;
exploreToolsConfig?: ExploreToolsConfig;
+8 -10
View File
@@ -24,7 +24,7 @@ import { ExploreToolsConfig } from '@backstage/plugin-explore-react';
import { ExploreApi } from './ExploreApi';
/**
* Default implementation of the ExploreApi.
* Default implementation of the {@link ExploreApi}.
*
* @public
*/
@@ -35,21 +35,19 @@ export class ExploreClient implements ExploreApi {
private readonly exploreToolsConfig: ExploreToolsConfig | undefined;
/**
* @remarks The exploreToolsConfig is for backwards compatibility with the exporeToolsConfigRef
* @remarks
*
* The `exploreToolsConfig` is for backwards compatibility with the `exploreToolsConfigRef`
* and will be removed in the future.
*/
constructor({
discoveryApi,
fetchApi,
exploreToolsConfig = undefined,
}: {
constructor(options: {
discoveryApi: DiscoveryApi;
fetchApi: FetchApi;
exploreToolsConfig?: ExploreToolsConfig;
}) {
this.discoveryApi = discoveryApi;
this.fetchApi = fetchApi;
this.exploreToolsConfig = exploreToolsConfig;
this.discoveryApi = options.discoveryApi;
this.fetchApi = options.fetchApi;
this.exploreToolsConfig = options.exploreToolsConfig;
}
async getTools(
+7 -9
View File
@@ -459,11 +459,9 @@ export function createPublishGithubAction(options: {
}>;
// @public
export const createPublishGithubPullRequestAction: ({
integrations,
githubCredentialsProvider,
clientFactory,
}: CreateGithubPullRequestActionOptions) => TemplateAction_2<{
export const createPublishGithubPullRequestAction: (
options: CreateGithubPullRequestActionOptions,
) => TemplateAction_2<{
title: string;
branchName: string;
description: string;
@@ -581,7 +579,7 @@ export class DatabaseTaskStore implements TaskStore {
}[];
}>;
// (undocumented)
shutdownTask({ taskId }: TaskStoreShutDownTaskOptions): Promise<void>;
shutdownTask(options: TaskStoreShutDownTaskOptions): Promise<void>;
}
// @public
@@ -792,7 +790,7 @@ export interface TaskStore {
options: TaskStoreCreateTaskOptions,
): Promise<TaskStoreCreateTaskResult>;
// (undocumented)
emitLogEvent({ taskId, body }: TaskStoreEmitOptions): Promise<void>;
emitLogEvent(options: TaskStoreEmitOptions): Promise<void>;
// (undocumented)
getTask(taskId: string): Promise<SerializedTask>;
// (undocumented)
@@ -802,7 +800,7 @@ export interface TaskStore {
tasks: SerializedTask[];
}>;
// (undocumented)
listEvents({ taskId, after }: TaskStoreListEventsOptions): Promise<{
listEvents(options: TaskStoreListEventsOptions): Promise<{
events: SerializedTaskEvent[];
}>;
// (undocumented)
@@ -812,7 +810,7 @@ export interface TaskStore {
}[];
}>;
// (undocumented)
shutdownTask?({ taskId }: TaskStoreShutDownTaskOptions): Promise<void>;
shutdownTask?(options: TaskStoreShutDownTaskOptions): Promise<void>;
}
// @public
@@ -116,11 +116,15 @@ type GithubPullRequest = {
* Creates a Github Pull Request action.
* @public
*/
export const createPublishGithubPullRequestAction = ({
integrations,
githubCredentialsProvider,
clientFactory = defaultClientFactory,
}: CreateGithubPullRequestActionOptions) => {
export const createPublishGithubPullRequestAction = (
options: CreateGithubPullRequestActionOptions,
) => {
const {
integrations,
githubCredentialsProvider,
clientFactory = defaultClientFactory,
} = options;
return createTemplateAction<{
title: string;
branchName: string;
@@ -381,7 +381,8 @@ export class DatabaseTaskStore implements TaskStore {
return { events };
}
async shutdownTask({ taskId }: TaskStoreShutDownTaskOptions): Promise<void> {
async shutdownTask(options: TaskStoreShutDownTaskOptions): Promise<void> {
const { taskId } = options;
const message = `This task was marked as stale as it exceeded its timeout`;
const statusStepEvents = (await this.listEvents({ taskId })).events.filter(
@@ -197,12 +197,11 @@ export interface TaskStore {
}>;
list?(options: { createdBy?: string }): Promise<{ tasks: SerializedTask[] }>;
emitLogEvent({ taskId, body }: TaskStoreEmitOptions): Promise<void>;
listEvents({
taskId,
after,
}: TaskStoreListEventsOptions): Promise<{ events: SerializedTaskEvent[] }>;
shutdownTask?({ taskId }: TaskStoreShutDownTaskOptions): Promise<void>;
emitLogEvent(options: TaskStoreEmitOptions): Promise<void>;
listEvents(
options: TaskStoreListEventsOptions,
): Promise<{ events: SerializedTaskEvent[] }>;
shutdownTask?(options: TaskStoreShutDownTaskOptions): Promise<void>;
}
export type WorkflowResponse = { output: { [key: string]: JsonValue } };
+3 -3
View File
@@ -277,9 +277,9 @@ export interface ScaffolderUseTemplateSecrets {
}
// @public
export const SecretsContextProvider: ({
children,
}: PropsWithChildren<{}>) => JSX.Element;
export const SecretsContextProvider: (
props: PropsWithChildren<{}>,
) => JSX.Element;
// @public
export type Step = {
@@ -43,14 +43,14 @@ const SecretsContext = createVersionedContext<{
* The Context Provider that holds the state for the secrets.
* @public
*/
export const SecretsContextProvider = ({ children }: PropsWithChildren<{}>) => {
export const SecretsContextProvider = (props: PropsWithChildren<{}>) => {
const [secrets, setSecrets] = useState<Record<string, string>>({});
return (
<SecretsContext.Provider
value={createVersionedValueMap({ 1: { secrets, setSecrets } })}
>
{children}
{props.children}
</SecretsContext.Provider>
);
};
+1 -1
View File
@@ -460,7 +460,7 @@ export type ScaffolderTaskStatus = ScaffolderTaskStatus_2;
export type ScaffolderUseTemplateSecrets = ScaffolderUseTemplateSecrets_2;
// @public
export const TaskPage: ({ loadingText }: TaskPageProps) => JSX.Element;
export const TaskPage: (props: TaskPageProps) => JSX.Element;
// @public
export type TaskPageProps = {
@@ -243,7 +243,9 @@ export type TaskPageProps = {
*
* @public
*/
export const TaskPage = ({ loadingText }: TaskPageProps) => {
export const TaskPage = (props: TaskPageProps) => {
const { loadingText } = props;
const classes = useStyles();
const navigate = useNavigate();
const rootPath = useRouteRef(rootRouteRef);
@@ -327,12 +327,9 @@ export class ElasticSearchSearchEngine implements SearchEngine {
highlightOptions?: ElasticSearchHighlightOptions,
);
// (undocumented)
static fromConfig({
logger,
config,
aliasPostfix,
indexPrefix,
}: ElasticSearchOptions): Promise<ElasticSearchSearchEngine>;
static fromConfig(
options: ElasticSearchOptions,
): Promise<ElasticSearchSearchEngine>;
// (undocumented)
getIndexer(type: string): Promise<ElasticSearchSearchEngineIndexer>;
newClient<T>(create: (options: ElasticSearchClientOptions) => T): T;
@@ -138,27 +138,29 @@ export class ElasticSearchSearchEngine implements SearchEngine {
};
}
static async fromConfig({
logger,
config,
aliasPostfix = `search`,
indexPrefix = ``,
}: ElasticSearchOptions) {
const options = await createElasticSearchClientOptions(
static async fromConfig(options: ElasticSearchOptions) {
const {
logger,
config,
aliasPostfix = `search`,
indexPrefix = ``,
} = options;
const clientOptions = await createElasticSearchClientOptions(
config.getConfig('search.elasticsearch'),
);
if (options.provider === 'elastic') {
if (clientOptions.provider === 'elastic') {
logger.info('Initializing Elastic.co ElasticSearch search engine.');
} else if (options.provider === 'aws') {
} else if (clientOptions.provider === 'aws') {
logger.info('Initializing AWS OpenSearch search engine.');
} else if (options.provider === 'opensearch') {
} else if (clientOptions.provider === 'opensearch') {
logger.info('Initializing OpenSearch search engine.');
} else {
logger.info('Initializing ElasticSearch search engine.');
}
return new ElasticSearchSearchEngine(
options,
clientOptions,
aliasPostfix,
indexPrefix,
logger,
@@ -175,12 +177,13 @@ export class ElasticSearchSearchEngine implements SearchEngine {
* This need not be the same client that the engine uses internally.
*
* @example Instantiate an instance of an Elasticsearch client.
*
* ```ts
* import { isOpenSearchCompatible } from '@backstage/plugin-search-backend-module-elasticsearch';
* import { Client } from '@elastic/elasticsearch';
*
* const client = searchEngine.newClient<Client>(options => {
* // This typeguard ensures options are compatible with either OpenSearch
* // This type guard ensures options are compatible with either OpenSearch
* // or Elasticsearch client constructors.
* if (!isOpenSearchCompatible(options)) {
* return new Client(options);
+7 -14
View File
@@ -60,11 +60,9 @@ export type DefaultResultListItemProps = {
};
// @public (undocumented)
export const HighlightedSearchResultText: ({
text,
preTag,
postTag,
}: HighlightedSearchResultTextProps) => JSX.Element;
export const HighlightedSearchResultText: (
props: HighlightedSearchResultTextProps,
) => JSX.Element;
// @public
export type HighlightedSearchResultTextProps = {
@@ -100,14 +98,9 @@ export type SearchAutocompleteComponent = <Option>(
) => JSX.Element;
// @public
export const SearchAutocompleteDefaultOption: ({
icon,
primaryText,
primaryTextTypographyProps,
secondaryText,
secondaryTextTypographyProps,
disableTextTypography,
}: SearchAutocompleteDefaultOptionProps) => JSX.Element;
export const SearchAutocompleteDefaultOption: (
props: SearchAutocompleteDefaultOptionProps,
) => JSX.Element;
// @public
export type SearchAutocompleteDefaultOptionProps = {
@@ -193,7 +186,7 @@ export type SearchContextValue = {
// @public (undocumented)
export const SearchFilter: {
({ component: Element, ...props }: SearchFilterWrapperProps): JSX.Element;
(props: SearchFilterWrapperProps): JSX.Element;
Checkbox(
props: Omit<SearchFilterWrapperProps, 'component'> &
SearchFilterComponentProps,
@@ -38,16 +38,17 @@ export type HighlightedSearchResultTextProps = {
/**
* @public
*/
export const HighlightedSearchResultText = ({
text,
preTag,
postTag,
}: HighlightedSearchResultTextProps) => {
export const HighlightedSearchResultText = (
props: HighlightedSearchResultTextProps,
) => {
const { text, preTag, postTag } = props;
const classes = useStyles();
const terms = useMemo(
() => text.split(new RegExp(`(${preTag}.+?${postTag})`)),
[postTag, preTag, text],
);
return (
<>
{terms.map((t, idx) =>
@@ -40,22 +40,28 @@ export type SearchAutocompleteDefaultOptionProps = {
*
* @public
*/
export const SearchAutocompleteDefaultOption = ({
icon,
primaryText,
primaryTextTypographyProps,
secondaryText,
secondaryTextTypographyProps,
disableTextTypography,
}: SearchAutocompleteDefaultOptionProps) => (
<>
{icon ? <ListItemIcon>{icon}</ListItemIcon> : null}
<ListItemText
primary={primaryText}
primaryTypographyProps={primaryTextTypographyProps}
secondary={secondaryText}
secondaryTypographyProps={secondaryTextTypographyProps}
disableTypography={disableTextTypography}
/>
</>
);
export const SearchAutocompleteDefaultOption = (
props: SearchAutocompleteDefaultOptionProps,
) => {
const {
icon,
primaryText,
primaryTextTypographyProps,
secondaryText,
secondaryTextTypographyProps,
disableTextTypography,
} = props;
return (
<>
{icon ? <ListItemIcon>{icon}</ListItemIcon> : null}
<ListItemText
primary={primaryText}
primaryTypographyProps={primaryTextTypographyProps}
secondary={secondaryText}
secondaryTypographyProps={secondaryTextTypographyProps}
disableTypography={disableTextTypography}
/>
</>
);
};
@@ -208,10 +208,10 @@ export const SelectFilter = (props: SearchFilterComponentProps) => {
/**
* @public
*/
const SearchFilter = ({
component: Element,
...props
}: SearchFilterWrapperProps) => <Element {...props} />;
const SearchFilter = (props: SearchFilterWrapperProps) => {
const { component: Element, ...elementProps } = props;
return <Element {...elementProps} />;
};
SearchFilter.Checkbox = (
props: Omit<SearchFilterWrapperProps, 'component'> &
+7 -13
View File
@@ -12,9 +12,9 @@ import { RouteRef } from '@backstage/core-plugin-api';
import { SearchBarBaseProps } from '@backstage/plugin-search-react';
// @public (undocumented)
export const HomePageSearchBar: ({
...props
}: Partial<Omit<SearchBarBaseProps, 'onChange' | 'onSubmit'>>) => JSX.Element;
export const HomePageSearchBar: (
props: Partial<Omit<SearchBarBaseProps, 'onChange' | 'onSubmit'>>,
) => JSX.Element;
// @public
export type HomePageSearchBarProps = Partial<
@@ -25,12 +25,7 @@ export type HomePageSearchBarProps = Partial<
export const Router: () => JSX.Element;
// @public (undocumented)
export const SearchModal: ({
open,
hidden,
toggleModal,
children,
}: SearchModalProps) => JSX.Element;
export const SearchModal: (props: SearchModalProps) => JSX.Element;
// @public (undocumented)
export interface SearchModalChildrenProps {
@@ -46,10 +41,9 @@ export interface SearchModalProps {
}
// @public
export const SearchModalProvider: ({
children,
showInitially,
}: SearchModalProviderProps) => JSX.Element;
export const SearchModalProvider: (
props: SearchModalProviderProps,
) => JSX.Element;
// @public
export type SearchModalProviderProps = {
@@ -42,7 +42,7 @@ export type HomePageSearchBarProps = Partial<
/**
* The search bar created specifically for the composable home page.
*/
export const HomePageSearchBar = ({ ...props }: HomePageSearchBarProps) => {
export const HomePageSearchBar = (props: HomePageSearchBarProps) => {
const classes = useStyles(props);
const [query, setQuery] = useState('');
const handleSearch = useNavigateToQuery();
@@ -168,12 +168,9 @@ export const Modal = ({ toggleModal }: SearchModalProps) => {
/**
* @public
*/
export const SearchModal = ({
open = true,
hidden,
toggleModal,
children,
}: SearchModalProps) => {
export const SearchModal = (props: SearchModalProps) => {
const { open = true, hidden, toggleModal, children } = props;
const classes = useStyles();
return (
@@ -84,15 +84,12 @@ export type SearchModalProviderProps = {
*
* @public
*/
export const SearchModalProvider = ({
children,
showInitially,
}: SearchModalProviderProps) => {
const value = useSearchModal(showInitially);
export const SearchModalProvider = (props: SearchModalProviderProps) => {
const value = useSearchModal(props.showInitially);
const versionedValue = createVersionedValueMap({ 1: value });
return (
<SearchModalContext.Provider value={versionedValue}>
{children}
{props.children}
</SearchModalContext.Provider>
);
};
+1 -4
View File
@@ -44,10 +44,7 @@ export const SonarQubeCard: (props: {
// @public (undocumented)
export class SonarQubeClient implements SonarQubeApi {
constructor({
discoveryApi,
identityApi,
}: {
constructor(options: {
discoveryApi: DiscoveryApi;
identityApi: IdentityApi;
});
+3 -6
View File
@@ -28,15 +28,12 @@ export class SonarQubeClient implements SonarQubeApi {
discoveryApi: DiscoveryApi;
identityApi: IdentityApi;
constructor({
discoveryApi,
identityApi,
}: {
constructor(options: {
discoveryApi: DiscoveryApi;
identityApi: IdentityApi;
}) {
this.discoveryApi = discoveryApi;
this.identityApi = identityApi;
this.discoveryApi = options.discoveryApi;
this.identityApi = options.identityApi;
}
private async callApi<T>(
+2 -9
View File
@@ -214,19 +214,12 @@ export class SplunkOnCallClient implements SplunkOnCallApi {
// (undocumented)
getUsers(): Promise<User[]>;
// (undocumented)
incidentAction({
routingKey,
incidentType,
incidentId,
incidentDisplayName,
incidentMessage,
incidentStartTime,
}: TriggerAlarmRequest): Promise<Response>;
incidentAction(options: TriggerAlarmRequest): Promise<Response>;
}
// @public (undocumented)
export const SplunkOnCallPage: {
({ title, subtitle, pageTitle }: SplunkOnCallPageProps): JSX.Element;
(props: SplunkOnCallPageProps): JSX.Element;
defaultProps: {
title: string;
subtitle: string;
+12 -10
View File
@@ -114,14 +114,16 @@ export class SplunkOnCallClient implements SplunkOnCallApi {
return policies;
}
async incidentAction({
routingKey,
incidentType,
incidentId,
incidentDisplayName,
incidentMessage,
incidentStartTime,
}: TriggerAlarmRequest): Promise<Response> {
async incidentAction(options: TriggerAlarmRequest): Promise<Response> {
const {
routingKey,
incidentType,
incidentId,
incidentDisplayName,
incidentMessage,
incidentStartTime,
} = options;
const body = JSON.stringify({
message_type: incidentType,
...(incidentId ? { entity_id: incidentId } : {}),
@@ -132,7 +134,7 @@ export class SplunkOnCallClient implements SplunkOnCallApi {
...(incidentStartTime ? { state_start_time: incidentStartTime } : {}),
});
const options = {
const request = {
method: 'POST',
headers: {
Accept: 'application/json',
@@ -143,7 +145,7 @@ export class SplunkOnCallClient implements SplunkOnCallApi {
const url = `${this.config.eventsRestEndpoint}/${routingKey}`;
return this.request(url, options);
return this.request(url, request);
}
private async findByUrl<T>(url: string): Promise<T> {
@@ -38,11 +38,8 @@ export type SplunkOnCallPageProps = {
pageTitle?: string;
};
export const SplunkOnCallPage = ({
title,
subtitle,
pageTitle,
}: SplunkOnCallPageProps): JSX.Element => {
export const SplunkOnCallPage = (props: SplunkOnCallPageProps): JSX.Element => {
const { title, subtitle, pageTitle } = props;
const classes = useStyles();
return (
@@ -46,13 +46,7 @@ export interface JsonRuleCheckResponse extends CheckResponse {
export class JsonRulesEngineFactChecker
implements FactChecker<TechInsightJsonRuleCheck, JsonRuleBooleanCheckResult>
{
constructor({
checks,
repository,
logger,
checkRegistry,
operators,
}: JsonRulesEngineFactCheckerOptions);
constructor(options: JsonRulesEngineFactCheckerOptions);
// (undocumented)
getChecks(): Promise<TechInsightJsonRuleCheck[]>;
// (undocumented)
@@ -66,12 +60,7 @@ export class JsonRulesEngineFactChecker
// @public
export class JsonRulesEngineFactCheckerFactory {
constructor({
checks,
logger,
checkRegistry,
operators,
}: JsonRulesEngineFactCheckerFactoryOptions);
constructor(options: JsonRulesEngineFactCheckerFactoryOptions);
// (undocumented)
construct(repository: TechInsightsStore): JsonRulesEngineFactChecker;
}
@@ -70,13 +70,9 @@ export class JsonRulesEngineFactChecker
private readonly validationSchema: SchemaObject;
private readonly operators: Operator[];
constructor({
checks,
repository,
logger,
checkRegistry,
operators,
}: JsonRulesEngineFactCheckerOptions) {
constructor(options: JsonRulesEngineFactCheckerOptions) {
const { checks, repository, logger, checkRegistry, operators } = options;
this.repository = repository;
this.logger = logger;
this.operators = operators || [];
@@ -361,16 +357,11 @@ export class JsonRulesEngineFactCheckerFactory {
private readonly checkRegistry?: TechInsightCheckRegistry<TechInsightJsonRuleCheck>;
private readonly operators?: Operator[];
constructor({
checks,
logger,
checkRegistry,
operators,
}: JsonRulesEngineFactCheckerFactoryOptions) {
this.logger = logger;
this.checks = checks;
this.checkRegistry = checkRegistry;
this.operators = operators;
constructor(options: JsonRulesEngineFactCheckerFactoryOptions) {
this.logger = options.logger;
this.checks = options.checks;
this.checkRegistry = options.checkRegistry;
this.operators = options.operators;
}
/**
+1 -5
View File
@@ -18,11 +18,7 @@ import { default as React_2 } from 'react';
import { RouteRef } from '@backstage/core-plugin-api';
// @public (undocumented)
export const BooleanCheck: ({
checkResult,
}: {
checkResult: CheckResult;
}) => JSX.Element;
export const BooleanCheck: (props: { checkResult: CheckResult }) => JSX.Element;
// @public
export type Check = {
@@ -22,8 +22,8 @@ import { CheckResult } from '@backstage/plugin-tech-insights-common';
/**
* @public
*/
export const BooleanCheck = ({ checkResult }: { checkResult: CheckResult }) => {
return !!checkResult.result ? (
export const BooleanCheck = (props: { checkResult: CheckResult }) => {
return !!props.checkResult.result ? (
<CheckCircleOutline color="primary" />
) : (
<ErrorOutlineIcon color="error" />
+4 -7
View File
@@ -19,10 +19,7 @@ import { Writable } from 'stream';
// @public
export class DirectoryPreparer implements PreparerBase {
static fromConfig(
config: Config,
{ logger, reader }: PreparerConfig,
): DirectoryPreparer;
static fromConfig(config: Config, options: PreparerConfig): DirectoryPreparer;
prepare(entity: Entity, options?: PreparerOptions): Promise<PreparerResponse>;
}
@@ -165,7 +162,7 @@ export type PreparerResponse = {
export class Preparers implements PreparerBuilder {
static fromConfig(
backstageConfig: Config,
{ logger, reader }: PreparerConfig,
options: PreparerConfig,
): Promise<PreparerBuilder>;
get(entity: Entity): PreparerBase;
register(protocol: RemoteProtocol, preparer: PreparerBase): void;
@@ -175,7 +172,7 @@ export class Preparers implements PreparerBuilder {
export class Publisher {
static fromConfig(
config: Config,
{ logger, discovery }: PublisherFactory,
options: PublisherFactory,
): Promise<PublisherBase>;
}
@@ -275,7 +272,7 @@ export const transformDirLocation: (
// @public
export class UrlPreparer implements PreparerBase {
static fromConfig({ reader, logger }: PreparerConfig): UrlPreparer;
static fromConfig(options: PreparerConfig): UrlPreparer;
prepare(entity: Entity, options?: PreparerOptions): Promise<PreparerResponse>;
}
```
@@ -46,9 +46,9 @@ export class DirectoryPreparer implements PreparerBase {
*/
static fromConfig(
config: Config,
{ logger, reader }: PreparerConfig,
options: PreparerConfig,
): DirectoryPreparer {
return new DirectoryPreparer(config, logger, reader);
return new DirectoryPreparer(config, options.logger, options.reader);
}
private constructor(
@@ -40,11 +40,14 @@ export class Preparers implements PreparerBuilder {
*/
static async fromConfig(
backstageConfig: Config,
{ logger, reader }: PreparerConfig,
options: PreparerConfig,
): Promise<PreparerBuilder> {
const preparers = new Preparers();
const urlPreparer = UrlPreparer.fromConfig({ reader, logger });
const urlPreparer = UrlPreparer.fromConfig({
reader: options.reader,
logger: options.logger,
});
preparers.register('url', urlPreparer);
/**
@@ -52,8 +55,8 @@ export class Preparers implements PreparerBuilder {
* When using dir preparer, the docs will be fetched using URL Reader.
*/
const directoryPreparer = DirectoryPreparer.fromConfig(backstageConfig, {
logger,
reader,
reader: options.reader,
logger: options.logger,
});
preparers.register('dir', directoryPreparer);
@@ -38,8 +38,8 @@ export class UrlPreparer implements PreparerBase {
* Returns a directory preparer instance
* @param config - A URL preparer config containing the a logger and reader
*/
static fromConfig({ reader, logger }: PreparerConfig): UrlPreparer {
return new UrlPreparer(reader, logger);
static fromConfig(options: PreparerConfig): UrlPreparer {
return new UrlPreparer(options.reader, options.logger);
}
private constructor(reader: UrlReader, logger: Logger) {
@@ -35,8 +35,10 @@ export class Publisher {
*/
static async fromConfig(
config: Config,
{ logger, discovery }: PublisherFactory,
options: PublisherFactory,
): Promise<PublisherBase> {
const { logger, discovery } = options;
const publisherType = (config.getOptionalString(
'techdocs.publisher.type',
) ?? 'local') as PublisherType;
+2 -6
View File
@@ -91,7 +91,7 @@ export type TechDocsMetadata = {
// @public
export const TechDocsReaderPageProvider: React_2.MemoExoticComponent<
({ entityRef, children }: TechDocsReaderPageProviderProps) => JSX.Element
(props: TechDocsReaderPageProviderProps) => JSX.Element
>;
// @public
@@ -120,11 +120,7 @@ export type TechDocsReaderPageValue = {
};
// @public
export const TechDocsShadowDom: ({
element,
onAppend,
children,
}: TechDocsShadowDomProps) => JSX.Element;
export const TechDocsShadowDom: (props: TechDocsShadowDomProps) => JSX.Element;
// @public
export type TechDocsShadowDomProps = PropsWithChildren<{
+3 -5
View File
@@ -204,11 +204,9 @@ export type TechDocsShadowDomProps = PropsWithChildren<{
* @param props - see {@link TechDocsShadowDomProps}.
* @public
*/
export const TechDocsShadowDom = ({
element,
onAppend,
children,
}: TechDocsShadowDomProps) => {
export const TechDocsShadowDom = (props: TechDocsShadowDomProps) => {
const { element, onAppend, children } = props;
const [jss, setJss] = useState(
create({
...jssPreset(),
+3 -1
View File
@@ -111,7 +111,9 @@ export type TechDocsReaderPageProviderProps = {
* @public
*/
export const TechDocsReaderPageProvider = memo(
({ entityRef, children }: TechDocsReaderPageProviderProps) => {
(props: TechDocsReaderPageProviderProps) => {
const { entityRef, children } = props;
const techdocsApi = useApi(techdocsApiRef);
const config = useApi(configApiRef);
+11 -12
View File
@@ -84,7 +84,7 @@ export const DocsTable: {
createStarEntityAction(
isStarredEntity: Function,
toggleStarredEntity: Function,
): ({ entity }: DocsTableRow) => {
): (row: DocsTableRow) => {
cellStyle: {
paddingLeft: string;
};
@@ -121,9 +121,9 @@ export const EmbeddedDocsRouter: (
) => JSX.Element | null;
// @public
export const EntityListDocsGrid: ({
groups,
}: EntityListDocsGridPageProps) => JSX.Element;
export const EntityListDocsGrid: (
props: EntityListDocsGridPageProps,
) => JSX.Element;
// @public
export type EntityListDocsGridPageProps = {
@@ -147,7 +147,7 @@ export const EntityListDocsTable: {
createStarEntityAction(
isStarredEntity: Function,
toggleStarredEntity: Function,
): ({ entity }: DocsTableRow) => {
): (row: DocsTableRow) => {
cellStyle: {
paddingLeft: string;
};
@@ -315,10 +315,9 @@ export { techdocsPlugin as plugin };
export { techdocsPlugin };
// @public
export const TechDocsReaderLayout: ({
withSearch,
withHeader,
}: TechDocsReaderLayoutProps) => JSX.Element;
export const TechDocsReaderLayout: (
props: TechDocsReaderLayoutProps,
) => JSX.Element;
// @public
export type TechDocsReaderLayoutProps = {
@@ -375,9 +374,9 @@ export const TechDocsReaderPageSubheader: (props: {
}) => JSX.Element | null;
// @public
export const TechDocsReaderProvider: ({
children,
}: TechDocsReaderProviderProps) => JSX.Element;
export const TechDocsReaderProvider: (
props: TechDocsReaderProviderProps,
) => JSX.Element;
// @public
export type TechDocsReaderProviderProps = {
@@ -55,13 +55,11 @@ const allEntitiesGroup: DocsGroupConfig = {
filterPredicate: () => true,
};
const EntityListDocsGridGroup = ({
entities,
group,
}: {
const EntityListDocsGridGroup = (props: {
group: DocsGroupConfig;
entities: Entity[];
}) => {
const { entities, group } = props;
const { loading: loadingOwnership, isOwnedEntity } = useEntityOwnership();
const shownEntities = entities.filter(entity => {
@@ -103,7 +101,7 @@ const EntityListDocsGridGroup = ({
*
* @public
*/
export const EntityListDocsGrid = ({ groups }: EntityListDocsGridPageProps) => {
export const EntityListDocsGrid = (props: EntityListDocsGridPageProps) => {
const { loading, error, entities } = useEntityList();
if (error) {
@@ -143,7 +141,7 @@ export const EntityListDocsGrid = ({ groups }: EntityListDocsGridPageProps) => {
return (
<Content>
{(groups || [allEntitiesGroup]).map((group, index: number) => (
{(props.groups || [allEntitiesGroup]).map((group, index: number) => (
<EntityListDocsGridGroup
entities={entities}
group={group}
@@ -47,7 +47,8 @@ export const actionFactories = {
isStarredEntity: Function,
toggleStarredEntity: Function,
) {
return ({ entity }: DocsTableRow) => {
return (row: DocsTableRow) => {
const entity = row.entity;
const isStarred = isStarredEntity(entity);
return {
cellStyle: { paddingLeft: '1em' },
@@ -132,10 +132,8 @@ export type TechDocsReaderLayoutProps = {
* Default TechDocs reader page structure composed with a header and content
* @public
*/
export const TechDocsReaderLayout = ({
withSearch,
withHeader = true,
}: TechDocsReaderLayoutProps) => {
export const TechDocsReaderLayout = (props: TechDocsReaderLayoutProps) => {
const { withSearch, withHeader = true } = props;
return (
<Page themeId="documentation">
{withHeader && <TechDocsReaderPageHeader />}
@@ -48,9 +48,9 @@ export type TechDocsReaderProviderProps = {
*
* @public
*/
export const TechDocsReaderProvider = ({
children,
}: TechDocsReaderProviderProps) => {
export const TechDocsReaderProvider = (props: TechDocsReaderProviderProps) => {
const { children } = props;
const { '*': path = '' } = useParams();
const { entityRef } = useTechDocsReaderPage();
const { kind, namespace, name } = entityRef;