Do not unpack arguments directly on exported items

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2021-12-07 19:42:10 +01:00
parent 95ab7baba6
commit dcd1a0c3f4
66 changed files with 433 additions and 708 deletions
+25
View File
@@ -0,0 +1,25 @@
---
'@backstage/backend-common': patch
'@backstage/core-app-api': patch
'@backstage/core-components': patch
'@backstage/core-plugin-api': patch
'@backstage/dev-utils': patch
'@backstage/techdocs-common': patch
'@backstage/test-utils': patch
'@backstage/plugin-analytics-module-ga': patch
'@backstage/plugin-auth-backend': patch
'@backstage/plugin-catalog-backend': patch
'@backstage/plugin-config-schema': patch
'@backstage/plugin-github-deployments': patch
'@backstage/plugin-pagerduty': patch
'@backstage/plugin-permission-node': patch
'@backstage/plugin-permission-react': patch
'@backstage/plugin-search-backend': patch
'@backstage/plugin-search-backend-module-elasticsearch': patch
'@backstage/plugin-search-backend-module-pg': patch
'@backstage/plugin-techdocs-backend': patch
'@backstage/plugin-todo': patch
'@backstage/plugin-todo-backend': patch
---
Minor improvement to the API reports, by not unpacking arguments directly
+19 -70
View File
@@ -180,18 +180,9 @@ export class DatabaseManager {
// @public (undocumented)
export class DockerContainerRunner implements ContainerRunner {
constructor({ dockerClient }: { dockerClient: Docker });
constructor(options: { dockerClient: Docker });
// (undocumented)
runContainer({
imageName,
command,
args,
logStream,
mountDirs,
workingDir,
envVars,
pullImage,
}: RunContainerOptions): Promise<void>;
runContainer(options: RunContainerOptions): Promise<void>;
}
// @public
@@ -227,34 +218,17 @@ export function getVoidLogger(): winston.Logger;
// @public (undocumented)
export class Git {
// (undocumented)
add({ dir, filepath }: { dir: string; filepath: string }): Promise<void>;
add(options: { dir: string; filepath: string }): Promise<void>;
// (undocumented)
addRemote({
dir,
url,
remote,
}: {
addRemote(options: {
dir: string;
remote: string;
url: string;
}): Promise<void>;
// (undocumented)
clone({
url,
dir,
ref,
}: {
url: string;
dir: string;
ref?: string;
}): Promise<void>;
clone(options: { url: string; dir: string; ref?: string }): Promise<void>;
// (undocumented)
commit({
dir,
message,
author,
committer,
}: {
commit(options: {
dir: string;
message: string;
author: {
@@ -267,41 +241,22 @@ export class Git {
};
}): Promise<string>;
// (undocumented)
currentBranch({
dir,
fullName,
}: {
currentBranch(options: {
dir: string;
fullName?: boolean;
}): Promise<string | undefined>;
// (undocumented)
fetch({ dir, remote }: { dir: string; remote?: string }): Promise<void>;
fetch(options: { dir: string; remote?: string }): Promise<void>;
// (undocumented)
static fromAuth: ({
username,
password,
logger,
}: {
username?: string | undefined;
password?: string | undefined;
logger?: Logger_2 | undefined;
static fromAuth: (options: {
username?: string;
password?: string;
logger?: Logger_2;
}) => Git;
// (undocumented)
init({
dir,
defaultBranch,
}: {
dir: string;
defaultBranch?: string;
}): Promise<void>;
init(options: { dir: string; defaultBranch?: string }): Promise<void>;
// (undocumented)
merge({
dir,
theirs,
ours,
author,
committer,
}: {
merge(options: {
dir: string;
theirs: string;
ours?: string;
@@ -315,17 +270,11 @@ export class Git {
};
}): Promise<MergeResult>;
// (undocumented)
push({ dir, remote }: { dir: string; remote: string }): Promise<PushResult>;
push(options: { dir: string; remote: string }): Promise<PushResult>;
// (undocumented)
readCommit({
dir,
sha,
}: {
dir: string;
sha: string;
}): Promise<ReadCommitResult>;
readCommit(options: { dir: string; sha: string }): Promise<ReadCommitResult>;
// (undocumented)
resolveRef({ dir, ref }: { dir: string; ref: string }): Promise<string>;
resolveRef(options: { dir: string; ref: string }): Promise<string>;
}
// @public
@@ -623,8 +572,8 @@ export type UrlReaderPredicateTuple = {
// @public
export class UrlReaders {
static create({ logger, config, factories }: UrlReadersOptions): UrlReader;
static default({ logger, config, factories }: UrlReadersOptions): UrlReader;
static create(options: UrlReadersOptions): UrlReader;
static default(options: UrlReadersOptions): UrlReader;
}
// @public (undocumented)
@@ -46,7 +46,8 @@ export class UrlReaders {
/**
* Creates a UrlReader without any known types.
*/
static create({ logger, config, factories }: UrlReadersOptions): UrlReader {
static create(options: UrlReadersOptions): UrlReader {
const { logger, config, factories } = options;
const mux = new UrlReaderPredicateMux(logger);
const treeResponseFactory = DefaultReadTreeResponseFactory.create({
config,
@@ -68,7 +69,8 @@ export class UrlReaders {
*
* Any additional factories passed will be loaded before the default ones.
*/
static default({ logger, config, factories = [] }: UrlReadersOptions) {
static default(options: UrlReadersOptions) {
const { logger, config, factories = [] } = options;
return UrlReaders.create({
logger,
config,
+32 -74
View File
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import git, {
ProgressCallback,
MergeResult,
@@ -42,44 +43,32 @@ export class Git {
},
) {}
async add({
dir,
filepath,
}: {
dir: string;
filepath: string;
}): Promise<void> {
async add(options: { dir: string; filepath: string }): Promise<void> {
const { dir, filepath } = options;
this.config.logger?.info(`Adding file {dir=${dir},filepath=${filepath}}`);
return git.add({ fs, dir, filepath });
}
async addRemote({
dir,
url,
remote,
}: {
async addRemote(options: {
dir: string;
remote: string;
url: string;
}): Promise<void> {
const { dir, url, remote } = options;
this.config.logger?.info(
`Creating new remote {dir=${dir},remote=${remote},url=${url}}`,
);
return git.addRemote({ fs, dir, remote, url });
}
async commit({
dir,
message,
author,
committer,
}: {
async commit(options: {
dir: string;
message: string;
author: { name: string; email: string };
committer: { name: string; email: string };
}): Promise<string> {
const { dir, message, author, committer } = options;
this.config.logger?.info(
`Committing file to repo {dir=${dir},message=${message}}`,
);
@@ -87,15 +76,12 @@ export class Git {
return git.commit({ fs, dir, message, author, committer });
}
async clone({
url,
dir,
ref,
}: {
async clone(options: {
url: string;
dir: string;
ref?: string;
}): Promise<void> {
const { url, dir, ref } = options;
this.config.logger?.info(`Cloning repo {dir=${dir},url=${url}}`);
return git.clone({
fs,
@@ -114,51 +100,35 @@ export class Git {
}
// https://isomorphic-git.org/docs/en/currentBranch
async currentBranch({
dir,
fullName,
}: {
async currentBranch(options: {
dir: string;
fullName?: boolean;
}): Promise<string | undefined> {
const fullname = fullName ?? false;
return git.currentBranch({ fs, dir, fullname }) as Promise<
const { dir, fullName = false } = options;
return git.currentBranch({ fs, dir, fullname: fullName }) as Promise<
string | undefined
>;
}
// https://isomorphic-git.org/docs/en/fetch
async fetch({
dir,
remote,
}: {
dir: string;
remote?: string;
}): Promise<void> {
const remoteValue = remote ?? 'origin';
async fetch(options: { dir: string; remote?: string }): Promise<void> {
const { dir, remote = 'origin' } = options;
this.config.logger?.info(
`Fetching remote=${remoteValue} for repository {dir=${dir}}`,
`Fetching remote=${remote} for repository {dir=${dir}}`,
);
await git.fetch({
fs,
http,
dir,
remote: remoteValue,
remote,
onProgress: this.onProgressHandler(),
headers: {
'user-agent': 'git/@isomorphic-git',
},
headers: { 'user-agent': 'git/@isomorphic-git' },
onAuth: this.onAuth,
});
}
async init({
dir,
defaultBranch = 'master',
}: {
dir: string;
defaultBranch?: string;
}): Promise<void> {
async init(options: { dir: string; defaultBranch?: string }): Promise<void> {
const { dir, defaultBranch = 'master' } = options;
this.config.logger?.info(`Init git repository {dir=${dir}}`);
return git.init({
@@ -169,19 +139,14 @@ export class Git {
}
// https://isomorphic-git.org/docs/en/merge
async merge({
dir,
theirs,
ours,
author,
committer,
}: {
async merge(options: {
dir: string;
theirs: string;
ours?: string;
author: { name: string; email: string };
committer: { name: string; email: string };
}): Promise<MergeResult> {
const { dir, theirs, ours, author, committer } = options;
this.config.logger?.info(
`Merging branch '${theirs}' into '${ours}' for repository {dir=${dir}}`,
);
@@ -197,7 +162,8 @@ export class Git {
});
}
async push({ dir, remote }: { dir: string; remote: string }) {
async push(options: { dir: string; remote: string }) {
const { dir, remote } = options;
this.config.logger?.info(
`Pushing directory to remote {dir=${dir},remote=${remote}}`,
);
@@ -215,24 +181,17 @@ export class Git {
}
// https://isomorphic-git.org/docs/en/readCommit
async readCommit({
dir,
sha,
}: {
async readCommit(options: {
dir: string;
sha: string;
}): Promise<ReadCommitResult> {
const { dir, sha } = options;
return git.readCommit({ fs, dir, oid: sha });
}
// https://isomorphic-git.org/docs/en/resolveRef
async resolveRef({
dir,
ref,
}: {
dir: string;
ref: string;
}): Promise<string> {
async resolveRef(options: { dir: string; ref: string }): Promise<string> {
const { dir, ref } = options;
return git.resolveRef({ fs, dir, ref });
}
@@ -256,13 +215,12 @@ export class Git {
};
};
static fromAuth = ({
username,
password,
logger,
}: {
static fromAuth = (options: {
username?: string;
password?: string;
logger?: Logger;
}) => new Git({ username, password, logger });
}) => {
const { username, password, logger } = options;
return new Git({ username, password, logger });
};
}
@@ -28,20 +28,22 @@ export type UserOptions = {
export class DockerContainerRunner implements ContainerRunner {
private readonly dockerClient: Docker;
constructor({ dockerClient }: { dockerClient: Docker }) {
this.dockerClient = dockerClient;
constructor(options: { dockerClient: Docker }) {
this.dockerClient = options.dockerClient;
}
async runContainer({
imageName,
command,
args,
logStream = new PassThrough(),
mountDirs = {},
workingDir,
envVars = {},
pullImage = true,
}: RunContainerOptions) {
async runContainer(options: RunContainerOptions) {
const {
imageName,
command,
args,
logStream = new PassThrough(),
mountDirs = {},
workingDir,
envVars = {},
pullImage = true,
} = options;
// Show a better error message when Docker is unavailable.
try {
await this.dockerClient.ping();
+13 -74
View File
@@ -250,24 +250,13 @@ export class AppThemeSelector implements AppThemeApi {
// @public
export class AtlassianAuth {
// (undocumented)
static create({
discoveryApi,
environment,
provider,
oauthRequestApi,
}: OAuthApiCreateOptions): typeof atlassianAuthApiRef.T;
static create(options: OAuthApiCreateOptions): typeof atlassianAuthApiRef.T;
}
// @public
export class Auth0Auth {
// (undocumented)
static create({
discoveryApi,
environment,
provider,
oauthRequestApi,
defaultScopes,
}: OAuthApiCreateOptions): typeof auth0AuthApiRef.T;
static create(options: OAuthApiCreateOptions): typeof auth0AuthApiRef.T;
}
// @public
@@ -303,13 +292,7 @@ export type BackstagePluginWithAnyOutput = Omit<
// @public
export class BitbucketAuth {
// (undocumented)
static create({
discoveryApi,
environment,
provider,
oauthRequestApi,
defaultScopes,
}: OAuthApiCreateOptions): typeof bitbucketAuthApiRef.T;
static create(options: OAuthApiCreateOptions): typeof bitbucketAuthApiRef.T;
}
// @public
@@ -402,13 +385,7 @@ export class GithubAuth implements OAuthApi, SessionApi {
// @deprecated
constructor(sessionManager: SessionManager<GithubSession>);
// (undocumented)
static create({
discoveryApi,
environment,
provider,
oauthRequestApi,
defaultScopes,
}: OAuthApiCreateOptions): GithubAuth;
static create(options: OAuthApiCreateOptions): GithubAuth;
// (undocumented)
getAccessToken(scope?: string, options?: AuthRequestOptions): Promise<string>;
// (undocumented)
@@ -441,25 +418,13 @@ export type GithubSession = {
// @public
export class GitlabAuth {
// (undocumented)
static create({
discoveryApi,
environment,
provider,
oauthRequestApi,
defaultScopes,
}: OAuthApiCreateOptions): typeof gitlabAuthApiRef.T;
static create(options: OAuthApiCreateOptions): typeof gitlabAuthApiRef.T;
}
// @public
export class GoogleAuth {
// (undocumented)
static create({
discoveryApi,
oauthRequestApi,
environment,
provider,
defaultScopes,
}: OAuthApiCreateOptions): typeof googleAuthApiRef.T;
static create(options: OAuthApiCreateOptions): typeof googleAuthApiRef.T;
}
// @public
@@ -477,13 +442,7 @@ export class LocalStorageFeatureFlags implements FeatureFlagsApi {
// @public
export class MicrosoftAuth {
// (undocumented)
static create({
environment,
provider,
oauthRequestApi,
discoveryApi,
defaultScopes,
}: OAuthApiCreateOptions): typeof microsoftAuthApiRef.T;
static create(options: OAuthApiCreateOptions): typeof microsoftAuthApiRef.T;
}
// @public
@@ -507,14 +466,7 @@ export class OAuth2
scopeTransform: (scopes: string[]) => string[];
});
// (undocumented)
static create({
discoveryApi,
environment,
provider,
oauthRequestApi,
defaultScopes,
scopeTransform,
}: OAuth2CreateOptions): OAuth2;
static create(options: OAuth2CreateOptions): OAuth2;
// (undocumented)
getAccessToken(
scope?: string | string[],
@@ -570,24 +522,15 @@ export class OAuthRequestManager implements OAuthRequestApi {
// @public
export class OktaAuth {
// (undocumented)
static create({
discoveryApi,
environment,
provider,
oauthRequestApi,
defaultScopes,
}: OAuthApiCreateOptions): typeof oktaAuthApiRef.T;
static create(options: OAuthApiCreateOptions): typeof oktaAuthApiRef.T;
}
// @public
export class OneLoginAuth {
// (undocumented)
static create({
discoveryApi,
environment,
provider,
oauthRequestApi,
}: OneLoginAuthCreateOptions): typeof oneloginAuthApiRef.T;
static create(
options: OneLoginAuthCreateOptions,
): typeof oneloginAuthApiRef.T;
}
// @public
@@ -607,11 +550,7 @@ export class SamlAuth
// @deprecated
constructor(sessionManager: SessionManager<SamlSession>);
// (undocumented)
static create({
discoveryApi,
environment,
provider,
}: AuthApiCreateOptions): SamlAuth;
static create(options: AuthApiCreateOptions): SamlAuth;
// (undocumented)
getBackstageIdentity(
options?: AuthRequestOptions,
@@ -30,12 +30,14 @@ const DEFAULT_PROVIDER = {
* @public
*/
export default class AtlassianAuth {
static create({
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
}: OAuthApiCreateOptions): typeof atlassianAuthApiRef.T {
static create(options: OAuthApiCreateOptions): typeof atlassianAuthApiRef.T {
const {
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
} = options;
return OAuth2.create({
discoveryApi,
oauthRequestApi,
@@ -30,13 +30,15 @@ const DEFAULT_PROVIDER = {
* @public
*/
export default class Auth0Auth {
static create({
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
defaultScopes = ['openid', `email`, `profile`],
}: OAuthApiCreateOptions): typeof auth0AuthApiRef.T {
static create(options: OAuthApiCreateOptions): typeof auth0AuthApiRef.T {
const {
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
defaultScopes = ['openid', `email`, `profile`],
} = options;
return OAuth2.create({
discoveryApi,
oauthRequestApi,
@@ -45,13 +45,15 @@ const DEFAULT_PROVIDER = {
* @public
*/
export default class BitbucketAuth {
static create({
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
defaultScopes = ['team'],
}: OAuthApiCreateOptions): typeof bitbucketAuthApiRef.T {
static create(options: OAuthApiCreateOptions): typeof bitbucketAuthApiRef.T {
const {
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
defaultScopes = ['team'],
} = options;
return OAuth2.create({
discoveryApi,
oauthRequestApi,
@@ -56,13 +56,15 @@ const DEFAULT_PROVIDER = {
* @public
*/
export default class GithubAuth implements OAuthApi, SessionApi {
static create({
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
defaultScopes = ['read:user'],
}: OAuthApiCreateOptions) {
static create(options: OAuthApiCreateOptions) {
const {
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
defaultScopes = ['read:user'],
} = options;
const connector = new DefaultAuthConnector({
discoveryApi,
environment,
@@ -30,13 +30,15 @@ const DEFAULT_PROVIDER = {
* @public
*/
export default class GitlabAuth {
static create({
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
defaultScopes = ['read_user'],
}: OAuthApiCreateOptions): typeof gitlabAuthApiRef.T {
static create(options: OAuthApiCreateOptions): typeof gitlabAuthApiRef.T {
const {
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
defaultScopes = ['read_user'],
} = options;
return OAuth2.create({
discoveryApi,
oauthRequestApi,
@@ -32,17 +32,19 @@ const SCOPE_PREFIX = 'https://www.googleapis.com/auth/';
* @public
*/
export default class GoogleAuth {
static create({
discoveryApi,
oauthRequestApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
defaultScopes = [
'openid',
`${SCOPE_PREFIX}userinfo.email`,
`${SCOPE_PREFIX}userinfo.profile`,
],
}: OAuthApiCreateOptions): typeof googleAuthApiRef.T {
static create(options: OAuthApiCreateOptions): typeof googleAuthApiRef.T {
const {
discoveryApi,
oauthRequestApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
defaultScopes = [
'openid',
`${SCOPE_PREFIX}userinfo.email`,
`${SCOPE_PREFIX}userinfo.profile`,
],
} = options;
return OAuth2.create({
discoveryApi,
oauthRequestApi,
@@ -30,19 +30,21 @@ const DEFAULT_PROVIDER = {
* @public
*/
export default class MicrosoftAuth {
static create({
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
discoveryApi,
defaultScopes = [
'openid',
'offline_access',
'profile',
'email',
'User.Read',
],
}: OAuthApiCreateOptions): typeof microsoftAuthApiRef.T {
static create(options: OAuthApiCreateOptions): typeof microsoftAuthApiRef.T {
const {
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
discoveryApi,
defaultScopes = [
'openid',
'offline_access',
'profile',
'email',
'User.Read',
],
} = options;
return OAuth2.create({
discoveryApi,
oauthRequestApi,
@@ -70,14 +70,16 @@ export default class OAuth2
BackstageIdentityApi,
SessionApi
{
static create({
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
defaultScopes = [],
scopeTransform = x => x,
}: OAuth2CreateOptions) {
static create(options: OAuth2CreateOptions) {
const {
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
defaultScopes = [],
scopeTransform = x => x,
} = options;
const connector = new DefaultAuthConnector({
discoveryApi,
environment,
@@ -42,13 +42,15 @@ const OKTA_SCOPE_PREFIX: string = 'okta.';
* @public
*/
export default class OktaAuth {
static create({
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
defaultScopes = ['openid', 'email', 'profile', 'offline_access'],
}: OAuthApiCreateOptions): typeof oktaAuthApiRef.T {
static create(options: OAuthApiCreateOptions): typeof oktaAuthApiRef.T {
const {
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
defaultScopes = ['openid', 'email', 'profile', 'offline_access'],
} = options;
return OAuth2.create({
discoveryApi,
oauthRequestApi,
@@ -57,12 +57,16 @@ const SCOPE_PREFIX: string = 'onelogin.';
* @public
*/
export default class OneLoginAuth {
static create({
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
}: OneLoginAuthCreateOptions): typeof oneloginAuthApiRef.T {
static create(
options: OneLoginAuthCreateOptions,
): typeof oneloginAuthApiRef.T {
const {
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
} = options;
return OAuth2.create({
discoveryApi,
oauthRequestApi,
@@ -52,11 +52,13 @@ const DEFAULT_PROVIDER = {
export default class SamlAuth
implements ProfileInfoApi, BackstageIdentityApi, SessionApi
{
static create({
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
}: AuthApiCreateOptions) {
static create(options: AuthApiCreateOptions) {
const {
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
} = options;
const connector = new DirectAuthConnector<SamlSession>({
discoveryApi,
environment,
+1 -4
View File
@@ -1982,10 +1982,7 @@ export const SidebarSpacer: React_2.ComponentType<
>;
// @public
export const SidebarSubmenu: ({
title,
children,
}: PropsWithChildren<SidebarSubmenuProps>) => JSX.Element;
export const SidebarSubmenu: (props: SidebarSubmenuProps) => JSX.Element;
// @public
export const SidebarSubmenuItem: (
@@ -16,7 +16,7 @@
import { makeStyles } from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography';
import clsx from 'clsx';
import React, { PropsWithChildren, ReactNode, useContext } from 'react';
import React, { ReactNode, useContext } from 'react';
import {
SidebarItemWithSubmenuContext,
sidebarConfig,
@@ -83,16 +83,12 @@ export type SidebarSubmenuProps = {
*
* @public
*/
export const SidebarSubmenu = ({
title,
children,
}: PropsWithChildren<SidebarSubmenuProps>) => {
export const SidebarSubmenu = (props: SidebarSubmenuProps) => {
const { isOpen } = useContext(SidebarContext);
const left = isOpen
? sidebarConfig.drawerWidthOpen
: sidebarConfig.drawerWidthClosed;
const props = { left: left };
const classes = useStyles(props)();
const classes = useStyles({ left: left })();
const { isHoveredOn } = useContext(SidebarItemWithSubmenuContext);
return (
@@ -102,9 +98,9 @@ export const SidebarSubmenu = ({
})}
>
<Typography variant="h5" className={classes.title}>
{title}
{props.title}
</Typography>
{children}
{props.children}
</div>
);
};
+1 -4
View File
@@ -43,10 +43,7 @@ export type AnalyticsApi = {
export const analyticsApiRef: ApiRef<AnalyticsApi>;
// @public
export const AnalyticsContext: ({
attributes,
children,
}: {
export const AnalyticsContext: (options: {
attributes: Partial<AnalyticsContextValue>;
children: ReactNode;
}) => JSX.Element;
@@ -62,13 +62,12 @@ export const useAnalyticsContext = (): AnalyticsContextValue => {
*
* @public
*/
export const AnalyticsContext = ({
attributes,
children,
}: {
export const AnalyticsContext = (options: {
attributes: Partial<AnalyticsContextValue>;
children: ReactNode;
}) => {
const { attributes, children } = options;
const parentValues = useAnalyticsContext();
const combinedValue = {
...parentValues,
+5 -7
View File
@@ -44,11 +44,9 @@ export type DevAppPageOptions = {
};
// @public (undocumented)
export const EntityGridItem: ({
entity,
classes,
...rest
}: Omit<GridProps<'div', {}>, 'container' | 'item'> & {
entity: Entity;
}) => JSX.Element;
export const EntityGridItem: (
props: Omit<GridProps, 'item' | 'container'> & {
entity: Entity;
},
) => JSX.Element;
```
@@ -35,11 +35,10 @@ const useStyles = makeStyles<BackstageTheme, { entity: Entity }>(theme => ({
}));
/** @public */
export const EntityGridItem = ({
entity,
classes,
...rest
}: Omit<GridProps, 'item' | 'container'> & { entity: Entity }): JSX.Element => {
export const EntityGridItem = (
props: Omit<GridProps, 'item' | 'container'> & { entity: Entity },
): JSX.Element => {
const { entity, classes, ...rest } = props;
const itemClasses = useStyles({ entity });
return (
+10 -44
View File
@@ -49,22 +49,6 @@ export type GeneratorBuilder = {
get(entity: Entity): GeneratorBase;
};
// Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// Warning: (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
// Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// Warning: (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
// Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// Warning: (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
// Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// Warning: (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
// Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// Warning: (tsdoc-param-tag-with-invalid-optional-name) The @param should not include a JSDoc-style optional name; it must not be enclosed in '[ ]' brackets.
// Warning: (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
// Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// Warning: (tsdoc-param-tag-with-invalid-optional-name) The @param should not include a JSDoc-style optional name; it must not be enclosed in '[ ]' brackets.
// Warning: (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
// Warning: (ae-missing-release-tag) "GeneratorRunOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
export type GeneratorRunOptions = {
inputDir: string;
@@ -82,10 +66,7 @@ export class Generators implements GeneratorBuilder {
// (undocumented)
static fromConfig(
config: Config,
{
logger,
containerRunner,
}: {
options: {
logger: Logger_2;
containerRunner: ContainerRunner;
},
@@ -185,13 +166,10 @@ export class Publisher {
): Promise<PublisherBase>;
}
// Warning: (ae-missing-release-tag) "PublisherBase" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
export interface PublisherBase {
docsRouter(): express.Handler;
fetchTechDocsMetadata(entityName: EntityName): Promise<TechDocsMetadata>;
// Warning: (ae-forgotten-export) The symbol "ReadinessResponse" needs to be exported by the entry point index.d.ts
getReadiness(): Promise<ReadinessResponse>;
hasDocsBeenGenerated(entityName: Entity): Promise<boolean>;
// Warning: (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
@@ -202,7 +180,6 @@ export interface PublisherBase {
// Warning: (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
// Warning: (ae-forgotten-export) The symbol "MigrateRequest" needs to be exported by the entry point index.d.ts
migrateDocsCase?(migrateRequest: MigrateRequest): Promise<void>;
// Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// Warning: (ae-forgotten-export) The symbol "PublishRequest" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "PublishResponse" needs to be exported by the entry point index.d.ts
publish(request: PublishRequest): Promise<PublishResponse>;
@@ -218,6 +195,11 @@ export type PublisherType =
| 'azureBlobStorage'
| 'openStackSwift';
// @public
export type ReadinessResponse = {
isAvailable: boolean;
};
// Warning: (ae-missing-release-tag) "RemoteProtocol" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
@@ -245,12 +227,7 @@ export interface TechDocsDocument extends IndexableDocument {
//
// @public (undocumented)
export class TechdocsGenerator implements GeneratorBase {
constructor({
logger,
containerRunner,
config,
scmIntegrations,
}: {
constructor(options: {
logger: Logger_2;
containerRunner: ContainerRunner;
config: Config;
@@ -260,26 +237,15 @@ export class TechdocsGenerator implements GeneratorBase {
// (undocumented)
static fromConfig(
config: Config,
{
containerRunner,
logger,
}: {
options: {
containerRunner: ContainerRunner;
logger: Logger_2;
},
): TechdocsGenerator;
// (undocumented)
run({
inputDir,
outputDir,
parsedLocationAnnotation,
etag,
logger: childLogger,
logStream,
}: GeneratorRunOptions): Promise<void>;
run(options: GeneratorRunOptions): Promise<void>;
}
// Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// Warning: (ae-missing-release-tag) "TechDocsMetadata" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
@@ -319,7 +285,7 @@ export class UrlPreparer implements PreparerBase {
// Warnings were encountered during analysis:
//
// src/stages/generate/types.d.ts:44:5 - (ae-forgotten-export) The symbol "SupportedGeneratorKey" needs to be exported by the entry point index.d.ts
// src/stages/generate/types.d.ts:45:5 - (ae-forgotten-export) The symbol "SupportedGeneratorKey" needs to be exported by the entry point index.d.ts
// src/stages/prepare/types.d.ts:18:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// src/stages/prepare/types.d.ts:19:8 - (tsdoc-param-tag-with-invalid-name) The @param block should be followed by a valid parameter name: The identifier cannot non-word characters
// src/stages/prepare/types.d.ts:21:33 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
@@ -31,17 +31,11 @@ export class Generators implements GeneratorBuilder {
static async fromConfig(
config: Config,
{
logger,
containerRunner,
}: { logger: Logger; containerRunner: ContainerRunner },
options: { logger: Logger; containerRunner: ContainerRunner },
): Promise<GeneratorBuilder> {
const generators = new Generators();
const techdocsGenerator = TechdocsGenerator.fromConfig(config, {
logger,
containerRunner,
});
const techdocsGenerator = TechdocsGenerator.fromConfig(config, options);
generators.register('techdocs', techdocsGenerator);
return generators;
@@ -52,11 +52,9 @@ export class TechdocsGenerator implements GeneratorBase {
static fromConfig(
config: Config,
{
containerRunner,
logger,
}: { containerRunner: ContainerRunner; logger: Logger },
options: { containerRunner: ContainerRunner; logger: Logger },
) {
const { containerRunner, logger } = options;
const scmIntegrations = ScmIntegrations.fromConfig(config);
return new TechdocsGenerator({
logger,
@@ -66,31 +64,28 @@ export class TechdocsGenerator implements GeneratorBase {
});
}
constructor({
logger,
containerRunner,
config,
scmIntegrations,
}: {
constructor(options: {
logger: Logger;
containerRunner: ContainerRunner;
config: Config;
scmIntegrations: ScmIntegrationRegistry;
}) {
this.logger = logger;
this.options = readGeneratorConfig(config, logger);
this.containerRunner = containerRunner;
this.scmIntegrations = scmIntegrations;
this.logger = options.logger;
this.options = readGeneratorConfig(options.config, options.logger);
this.containerRunner = options.containerRunner;
this.scmIntegrations = options.scmIntegrations;
}
public async run({
inputDir,
outputDir,
parsedLocationAnnotation,
etag,
logger: childLogger,
logStream,
}: GeneratorRunOptions): Promise<void> {
public async run(options: GeneratorRunOptions): Promise<void> {
const {
inputDir,
outputDir,
parsedLocationAnnotation,
etag,
logger: childLogger,
logStream,
} = options;
// Do some updates to mkdocs.yml before generating docs e.g. adding repo_url
const { path: mkdocsYmlPath, content } = await getMkdocsYml(inputDir);
@@ -34,12 +34,13 @@ export type GeneratorConfig = {
/**
* The values that the generator will receive.
*
* @param {string} inputDir The directory of the uncompiled documentation, with the values from the frontend
* @param {string} outputDir Directory to store generated docs in. Usually - a newly created temporary directory.
* @param {ParsedLocationAnnotation} parsedLocationAnnotation backstage.io/techdocs-ref annotation of an entity
* @param {string} etag A unique identifier for the prepared tree e.g. commit SHA. If provided it will be stored in techdocs_metadata.json.
* @param {Logger} [logger] A logger that forwards the messages to the caller to be displayed outside of the backend.
* @param {Writable} [logStream] A log stream that can send raw log messages to the caller to be displayed outside of the backend..
* @public
* @param inputDir - The directory of the uncompiled documentation, with the values from the frontend
* @param outputDir - Directory to store generated docs in. Usually - a newly created temporary directory.
* @param parsedLocationAnnotation - backstage.io/techdocs-ref annotation of an entity
* @param etag - A unique identifier for the prepared tree e.g. commit SHA. If provided it will be stored in techdocs_metadata.json.
* @param logger - A logger that forwards the messages to the caller to be displayed outside of the backend.
* @param logStream - A log stream that can send raw log messages to the caller to be displayed outside of the backend.
*/
export type GeneratorRunOptions = {
inputDir: string;
@@ -14,4 +14,9 @@
* limitations under the License.
*/
export { Publisher } from './publish';
export type { PublisherBase, PublisherType, TechDocsMetadata } from './types';
export type {
PublisherBase,
PublisherType,
TechDocsMetadata,
ReadinessResponse,
} from './types';
@@ -51,6 +51,8 @@ export type PublishResponse = {
/**
* Result for the validation check.
*
* @public
*/
export type ReadinessResponse = {
/** If true, the publisher is able to interact with the backing storage. */
@@ -59,7 +61,7 @@ export type ReadinessResponse = {
/**
* Type to hold metadata found in techdocs_metadata.json and associated with each site
* @param etag ETag of the resource used to generate the site. Usually the latest commit sha of the source repository.
* @param etag - ETag of the resource used to generate the site. Usually the latest commit sha of the source repository.
*/
export type TechDocsMetadata = {
site_name: string;
@@ -86,6 +88,8 @@ export type MigrateRequest = {
* Base class for a TechDocs publisher (e.g. Local, Google GCS Bucket, AWS S3, etc.)
* The publisher handles publishing of the generated static files after the prepare and generate steps of TechDocs.
* It also provides APIs to communicate with the storage service.
*
* @public
*/
export interface PublisherBase {
/**
@@ -99,8 +103,8 @@ export interface PublisherBase {
/**
* Store the generated static files onto a storage service (either local filesystem or external service).
*
* @param request Object containing the entity from the service
* catalog, and the directory that contains the generated static files from TechDocs.
* @param request - Object containing the entity from the service
* catalog, and the directory that contains the generated static files from TechDocs.
*/
publish(request: PublishRequest): Promise<PublishResponse>;
+5 -16
View File
@@ -89,23 +89,13 @@ export type LogFuncs = 'log' | 'warn' | 'error';
// @public
export class MockAnalyticsApi implements AnalyticsApi {
// (undocumented)
captureEvent({
action,
subject,
value,
attributes,
context,
}: AnalyticsEvent): void;
captureEvent(event: AnalyticsEvent): void;
// (undocumented)
getEvents(): AnalyticsEvent[];
}
// @public
export function mockBreakpoint({
matches,
}: {
matches?: boolean | undefined;
}): void;
export function mockBreakpoint(options: { matches: boolean }): void;
// @public
export class MockErrorApi implements ErrorApi {
@@ -178,10 +168,9 @@ export function setupRequestMockHandlers(worker: {
export type SyncLogCollector = () => void;
// @public
export const TestApiProvider: <T extends any[]>({
apis,
children,
}: TestApiProviderProps<T>) => JSX.Element;
export const TestApiProvider: <T extends any[]>(
props: TestApiProviderProps<T>,
) => JSX.Element;
// @public
export type TestApiProviderProps<TApiPairs extends any[]> = {
@@ -120,11 +120,13 @@ export class TestApiRegistry implements ApiHolder {
*
* @public
**/
export const TestApiProvider = <T extends any[]>({
apis,
children,
}: TestApiProviderProps<T>) => {
export const TestApiProvider = <T extends any[]>(
props: TestApiProviderProps<T>,
) => {
return (
<ApiProvider apis={TestApiRegistry.from(...apis)} children={children} />
<ApiProvider
apis={TestApiRegistry.from(...props.apis)}
children={props.children}
/>
);
};
@@ -19,18 +19,15 @@ import { AnalyticsApi, AnalyticsEvent } from '@backstage/core-plugin-api';
/**
* Mock implementation of {@link core-plugin-api#AnalyticsApi} with helpers to ensure that events are sent correctly.
* Use getEvents in tests to verify captured events.
*
* @public
*/
export class MockAnalyticsApi implements AnalyticsApi {
private events: AnalyticsEvent[] = [];
captureEvent({
action,
subject,
value,
attributes,
context,
}: AnalyticsEvent) {
captureEvent(event: AnalyticsEvent) {
const { action, subject, value, attributes, context } = event;
this.events.push({
action,
subject,
@@ -15,8 +15,8 @@
*/
/**
* This is a mocking method suggested in the Jest Doc's, as it is not implemented in JSDOM yet.
* It can be used to mock values when the MUI `useMediaQuery` hook if it is used in a tested component.
* This is a mocking method suggested in the Jest docs, as it is not implemented in JSDOM yet.
* It can be used to mock values for the MUI `useMediaQuery` hook if it is used in a tested component.
*
* For issues checkout the documentation:
* https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
@@ -26,11 +26,11 @@
*
* @public
*/
export default function mockBreakpoint({ matches = false }) {
export default function mockBreakpoint(options: { matches: boolean }) {
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation(query => ({
matches: matches,
matches: options.matches ?? false,
media: query,
onchange: null,
addListener: jest.fn(), // deprecated
+1 -7
View File
@@ -17,13 +17,7 @@ export const analyticsModuleGA: BackstagePlugin<{}, {}>;
//
// @public
export class GoogleAnalytics implements AnalyticsApi {
captureEvent({
context,
action,
subject,
value,
attributes,
}: AnalyticsEvent): void;
captureEvent(event: AnalyticsEvent): void;
static fromConfig(config: Config): GoogleAnalytics;
}
@@ -39,19 +39,15 @@ export class GoogleAnalytics implements AnalyticsApi {
/**
* Instantiate the implementation and initialize ReactGA.
*/
private constructor({
cdmConfig,
trackingId,
scriptSrc,
testMode,
debug,
}: {
private constructor(options: {
cdmConfig: CustomDimensionOrMetricConfig[];
trackingId: string;
scriptSrc?: string;
testMode: boolean;
debug: boolean;
}) {
const { cdmConfig, trackingId, scriptSrc, testMode, debug } = options;
this.cdmConfig = cdmConfig;
// Initialize Google Analytics.
@@ -102,13 +98,8 @@ export class GoogleAnalytics implements AnalyticsApi {
* pageview and the rest as custom events. All custom dimensions/metrics are
* applied as they should be (set on pageview, merged object on events).
*/
captureEvent({
context,
action,
subject,
value,
attributes,
}: AnalyticsEvent) {
captureEvent(event: AnalyticsEvent) {
const { context, action, subject, value, attributes } = event;
const customMetadata = this.getCustomDimensionMetrics(context, attributes);
if (action === 'navigate' && context.extension === 'App') {
+2 -11
View File
@@ -185,10 +185,7 @@ export class CatalogIdentityClient {
// Warning: (ae-forgotten-export) The symbol "UserQuery" needs to be exported by the entry point index.d.ts
findUser(query: UserQuery): Promise<UserEntity>;
// Warning: (ae-forgotten-export) The symbol "MemberClaimQuery" needs to be exported by the entry point index.d.ts
resolveCatalogMembership({
entityRefs,
logger,
}: MemberClaimQuery): Promise<string[]>;
resolveCatalogMembership(query: MemberClaimQuery): Promise<string[]>;
}
// Warning: (ae-missing-release-tag) "createAtlassianProvider" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
@@ -270,13 +267,7 @@ export function createOriginFilter(config: Config): (origin: string) => boolean;
// Warning: (ae-missing-release-tag) "createRouter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export function createRouter({
logger,
config,
discovery,
database,
providerFactories,
}: RouterOptions): Promise<express.Router>;
export function createRouter(options: RouterOptions): Promise<express.Router>;
// @public (undocumented)
export const createSamlProvider: (
@@ -84,10 +84,8 @@ export class CatalogIdentityClient {
*
* Returns a superset of the entity names that can be passed directly to `issueToken` as `ent`.
*/
async resolveCatalogMembership({
entityRefs,
logger,
}: MemberClaimQuery): Promise<string[]> {
async resolveCatalogMembership(query: MemberClaimQuery): Promise<string[]> {
const { entityRefs, logger } = query;
const resolvedEntityRefs = entityRefs
.map((ref: string) => {
try {
+4 -7
View File
@@ -44,13 +44,10 @@ export interface RouterOptions {
providerFactories?: ProviderFactories;
}
export async function createRouter({
logger,
config,
discovery,
database,
providerFactories,
}: RouterOptions): Promise<express.Router> {
export async function createRouter(
options: RouterOptions,
): Promise<express.Router> {
const { logger, config, discovery, database, providerFactories } = options;
const router = Router();
const appUrl = config.getString('app.baseUrl');
+1 -7
View File
@@ -752,13 +752,7 @@ export type DbPageInfo =
//
// @public (undocumented)
export class DefaultCatalogCollator implements DocumentCollator {
constructor({
discovery,
locationTemplate,
filter,
catalogClient,
tokenManager,
}: {
constructor(options: {
discovery: PluginEndpointDiscovery;
tokenManager: TokenManager;
locationTemplate?: string;
@@ -56,19 +56,16 @@ export class DefaultCatalogCollator implements DocumentCollator {
});
}
constructor({
discovery,
locationTemplate,
filter,
catalogClient,
tokenManager,
}: {
constructor(options: {
discovery: PluginEndpointDiscovery;
tokenManager: TokenManager;
locationTemplate?: string;
filter?: CatalogEntitiesRequest['filter'];
catalogClient?: CatalogApi;
}) {
const { discovery, locationTemplate, filter, catalogClient, tokenManager } =
options;
this.discovery = discovery;
this.locationTemplate =
locationTemplate || '/catalog/:namespace/:kind/:name';
+1 -3
View File
@@ -41,11 +41,9 @@ export const configSchemaPlugin: BackstagePlugin<
{}
>;
// Warning: (ae-missing-release-tag) "StaticSchemaLoader" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
export class StaticSchemaLoader implements ConfigSchemaApi {
constructor({ url }?: { url?: string });
constructor(options?: { url?: string });
// (undocumented)
schema$(): Observable<ConfigSchemaResult>;
}
@@ -24,12 +24,14 @@ const DEFAULT_URL = 'config-schema.json';
/**
* A ConfigSchemaApi implementation that loads the configuration from a URL.
*
* @public
*/
export class StaticSchemaLoader implements ConfigSchemaApi {
private readonly url: string;
constructor({ url = DEFAULT_URL }: { url?: string } = {}) {
this.url = url;
constructor(options: { url?: string } = {}) {
this.url = options?.url ?? DEFAULT_URL;
}
schema$(): Observable<ConfigSchemaResult> {
+5 -12
View File
@@ -38,11 +38,7 @@ function createStatusColumn(): TableColumn<GithubDeployment>;
// Warning: (ae-missing-release-tag) "EntityGithubDeploymentsCard" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const EntityGithubDeploymentsCard: ({
last,
lastStatuses,
columns,
}: {
export const EntityGithubDeploymentsCard: (props: {
last?: number | undefined;
lastStatuses?: number | undefined;
columns?: TableColumn<GithubDeployment>[] | undefined;
@@ -58,12 +54,9 @@ export const githubDeploymentsPlugin: BackstagePlugin<{}, {}>;
// Warning: (ae-missing-release-tag) "GithubDeploymentsTable" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export function GithubDeploymentsTable({
deployments,
isLoading,
reload,
columns,
}: GithubDeploymentsTableProps): JSX.Element;
export function GithubDeploymentsTable(
props: GithubDeploymentsTableProps,
): JSX.Element;
// @public (undocumented)
export namespace GithubDeploymentsTable {
@@ -78,7 +71,7 @@ export namespace GithubDeploymentsTable {
// Warning: (ae-missing-release-tag) "GithubStateIndicator" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
const GithubStateIndicator: ({ state }: { state: string }) => JSX.Element;
const GithubStateIndicator: (props: { state: string }) => JSX.Element;
// Warning: (ae-missing-release-tag) "isGithubDeploymentsAvailable" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
@@ -80,15 +80,12 @@ const GithubDeploymentsComponent = ({
);
};
export const GithubDeploymentsCard = ({
last,
lastStatuses,
columns,
}: {
export const GithubDeploymentsCard = (props: {
last?: number;
lastStatuses?: number;
columns?: TableColumn<GithubDeployment>[];
}) => {
const { last, lastStatuses, columns } = props;
const { entity } = useEntity();
const [host] = [
entity?.metadata.annotations?.[SOURCE_LOCATION_ANNOTATION],
@@ -36,12 +36,8 @@ type GithubDeploymentsTableProps = {
columns: TableColumn<GithubDeployment>[];
};
export function GithubDeploymentsTable({
deployments,
isLoading,
reload,
columns,
}: GithubDeploymentsTableProps) {
export function GithubDeploymentsTable(props: GithubDeploymentsTableProps) {
const { deployments, isLoading, reload, columns } = props;
const classes = useStyles();
return (
@@ -27,8 +27,8 @@ import {
Link,
} from '@backstage/core-components';
export const GithubStateIndicator = ({ state }: { state: string }) => {
switch (state) {
export const GithubStateIndicator = (props: { state: string }) => {
switch (props.state) {
case 'PENDING':
return <StatusPending />;
case 'IN_PROGRESS':
+3 -10
View File
@@ -10,7 +10,7 @@ import { BackstagePlugin } from '@backstage/core-plugin-api';
import { ConfigApi } from '@backstage/core-plugin-api';
import { DiscoveryApi } from '@backstage/core-plugin-api';
import { Entity } from '@backstage/catalog-model';
import { PropsWithChildren } from 'react';
import { ReactNode } from 'react';
// Warning: (ae-missing-release-tag) "EntityPagerDutyCard" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
@@ -65,12 +65,7 @@ export class PagerDutyClient implements PagerDutyApi {
// Warning: (ae-forgotten-export) The symbol "TriggerAlarmRequest" needs to be exported by the entry point index.d.ts
//
// (undocumented)
triggerAlarm({
integrationKey,
source,
description,
userName,
}: TriggerAlarmRequest): Promise<Response>;
triggerAlarm(request: TriggerAlarmRequest): Promise<Response>;
}
// Warning: (ae-missing-release-tag) "pagerDutyPlugin" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
@@ -84,9 +79,7 @@ export { pagerDutyPlugin as plugin };
// Warning: (ae-missing-release-tag) "TriggerButton" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export function TriggerButton({
children,
}: PropsWithChildren<TriggerButtonProps>): JSX.Element;
export function TriggerButton(props: TriggerButtonProps): JSX.Element;
// Warning: (ae-missing-release-tag) "UnauthorizedError" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
+3 -6
View File
@@ -91,12 +91,9 @@ export class PagerDutyClient implements PagerDutyApi {
return oncalls;
}
triggerAlarm({
integrationKey,
source,
description,
userName,
}: TriggerAlarmRequest): Promise<Response> {
triggerAlarm(request: TriggerAlarmRequest): Promise<Response> {
const { integrationKey, source, description, userName } = request;
const body = JSON.stringify({
event_action: 'trigger',
routing_key: integrationKey,
@@ -13,14 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React, { useCallback, PropsWithChildren, useState } from 'react';
import React, { useCallback, ReactNode, useState } from 'react';
import { makeStyles, Button } from '@material-ui/core';
import { BackstageTheme } from '@backstage/theme';
import { usePagerdutyEntity } from '../../hooks';
import { TriggerDialog } from '../TriggerDialog';
export type TriggerButtonProps = {};
export type TriggerButtonProps = {
children?: ReactNode;
};
const useStyles = makeStyles<BackstageTheme>(theme => ({
buttonStyle: {
@@ -32,9 +34,7 @@ const useStyles = makeStyles<BackstageTheme>(theme => ({
},
}));
export function TriggerButton({
children,
}: PropsWithChildren<TriggerButtonProps>) {
export function TriggerButton(props: TriggerButtonProps) {
const { buttonStyle } = useStyles();
const { integrationKey } = usePagerdutyEntity();
const [dialogShown, setDialogShown] = useState<boolean>(false);
@@ -56,7 +56,7 @@ export function TriggerButton({
disabled={disabled}
>
{integrationKey
? children ?? 'Create Incident'
? props.children ?? 'Create Incident'
: 'Missing integration key'}
</Button>
{integrationKey && (
+1 -5
View File
@@ -83,11 +83,7 @@ export const createConditionTransformer: <
) => ConditionTransformer<TQuery>;
// @public
export const createPermissionIntegrationRouter: <TResource>({
resourceType,
rules,
getResource,
}: {
export const createPermissionIntegrationRouter: <TResource>(options: {
resourceType: string;
rules: PermissionRule<TResource, any, unknown[]>[];
getResource: (resourceRef: string) => Promise<TResource | undefined>;
@@ -116,17 +116,15 @@ const applyConditions = <TResource>(
* This is used to construct the `createPermissionIntegrationRouter`, a function to add an
* authorization route to your backend plugin. This route will be called by the `permission-backend`
* when authorization conditions relating to this plugin need to be evaluated.
*
* @public
*/
export const createPermissionIntegrationRouter = <TResource>({
resourceType,
rules,
getResource,
}: {
export const createPermissionIntegrationRouter = <TResource>(options: {
resourceType: string;
rules: PermissionRule<TResource, any>[];
getResource: (resourceRef: string) => Promise<TResource | undefined>;
}): Router => {
const { resourceType, rules, getResource } = options;
const router = Router();
const getRule = createGetRule(rules);
+11 -20
View File
@@ -6,12 +6,13 @@
import { ApiRef } from '@backstage/core-plugin-api';
import { AuthorizeRequest } from '@backstage/plugin-permission-common';
import { AuthorizeResponse } from '@backstage/plugin-permission-common';
import { ComponentProps } from 'react';
import { Config } from '@backstage/config';
import { DiscoveryApi } from '@backstage/core-plugin-api';
import { IdentityApi } from '@backstage/core-plugin-api';
import { Permission } from '@backstage/plugin-permission-common';
import { default as React_2 } from 'react';
import { RouteProps } from 'react-router';
import { ReactElement } from 'react';
import { Route } from 'react-router';
// @public (undocumented)
export type AsyncPermissionResult = {
@@ -25,11 +26,7 @@ export class IdentityPermissionApi implements PermissionApi {
// (undocumented)
authorize(request: AuthorizeRequest): Promise<AuthorizeResponse>;
// (undocumented)
static create({
configApi,
discoveryApi,
identityApi,
}: {
static create(options: {
configApi: Config;
discoveryApi: DiscoveryApi;
identityApi: IdentityApi;
@@ -45,19 +42,13 @@ export type PermissionApi = {
export const permissionApiRef: ApiRef<PermissionApi>;
// @public
export const PermissionedRoute: ({
permission,
resourceRef,
errorComponent,
...props
}: RouteProps & {
permission: Permission;
resourceRef?: string | undefined;
errorComponent?:
| React_2.ReactElement<any, string | React_2.JSXElementConstructor<any>>
| null
| undefined;
}) => JSX.Element;
export const PermissionedRoute: (
props: ComponentProps<typeof Route> & {
permission: Permission;
resourceRef?: string;
errorComponent?: ReactElement | null;
},
) => JSX.Element;
// @public
export const usePermission: (
@@ -34,15 +34,12 @@ export class IdentityPermissionApi implements PermissionApi {
private readonly identityApi: IdentityApi,
) {}
static create({
configApi,
discoveryApi,
identityApi,
}: {
static create(options: {
configApi: Config;
discoveryApi: DiscoveryApi;
identityApi: IdentityApi;
}) {
const { configApi, discoveryApi, identityApi } = options;
const permissionClient = new PermissionClient({ discoveryApi, configApi });
return new IdentityPermissionApi(permissionClient, identityApi);
}
@@ -21,20 +21,19 @@ import { usePermission } from '../hooks';
import { Permission } from '@backstage/plugin-permission-common';
/**
* Returns a React Router Route which only renders the element when authorized. If unathorized, the Route will render a
* Returns a React Router Route which only renders the element when authorized. If unauthorized, the Route will render a
* NotFoundErrorPage (see {@link @backstage/core-app-api#AppComponents}).
*
* @public
*/
export const PermissionedRoute = ({
permission,
resourceRef,
errorComponent,
...props
}: ComponentProps<typeof Route> & {
permission: Permission;
resourceRef?: string;
errorComponent?: ReactElement | null;
}) => {
export const PermissionedRoute = (
props: ComponentProps<typeof Route> & {
permission: Permission;
resourceRef?: string;
errorComponent?: ReactElement | null;
},
) => {
const { permission, resourceRef, errorComponent, ...otherProps } = props;
const permissionResult = usePermission(permission, resourceRef);
const app = useApp();
const { NotFoundErrorPage } = app.getComponents();
@@ -48,5 +47,5 @@ export const PermissionedRoute = ({
shownElement = props.element;
}
return <Route {...props} element={shownElement} />;
return <Route {...otherProps} element={shownElement} />;
};
@@ -11,8 +11,6 @@ import { SearchEngine } from '@backstage/search-common';
import { SearchQuery } from '@backstage/search-common';
import { SearchResultSet } from '@backstage/search-common';
// Warning: (ae-missing-release-tag) "ElasticSearchSearchEngine" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export class ElasticSearchSearchEngine implements SearchEngine {
constructor(
@@ -24,12 +22,9 @@ export class ElasticSearchSearchEngine implements SearchEngine {
// Warning: (ae-forgotten-export) The symbol "ElasticSearchOptions" needs to be exported by the entry point index.d.ts
//
// (undocumented)
static fromConfig({
logger,
config,
aliasPostfix,
indexPrefix,
}: ElasticSearchOptions): Promise<ElasticSearchSearchEngine>;
static fromConfig(
options: ElasticSearchOptions,
): Promise<ElasticSearchSearchEngine>;
// (undocumented)
index(type: string, documents: IndexableDocument[]): Promise<void>;
// (undocumented)
@@ -41,11 +36,6 @@ export class ElasticSearchSearchEngine implements SearchEngine {
// Warning: (ae-forgotten-export) The symbol "ConcreteElasticSearchQuery" needs to be exported by the entry point index.d.ts
//
// (undocumented)
protected translator({
term,
filters,
types,
pageCursor,
}: SearchQuery): ConcreteElasticSearchQuery;
protected translator(query: SearchQuery): ConcreteElasticSearchQuery;
}
```
@@ -64,6 +64,9 @@ function isBlank(str: string) {
return (isEmpty(str) && !isNumber(str)) || nan(str);
}
/**
* @public
*/
export class ElasticSearchSearchEngine implements SearchEngine {
constructor(
private readonly elasticSearchClient: Client,
@@ -72,12 +75,14 @@ export class ElasticSearchSearchEngine implements SearchEngine {
private readonly logger: Logger,
) {}
static async fromConfig({
logger,
config,
aliasPostfix = `search`,
indexPrefix = ``,
}: ElasticSearchOptions) {
static async fromConfig(options: ElasticSearchOptions) {
const {
logger,
config,
aliasPostfix = `search`,
indexPrefix = ``,
} = options;
return new ElasticSearchSearchEngine(
await ElasticSearchSearchEngine.constructElasticSearchClient(
logger,
@@ -164,12 +169,9 @@ export class ElasticSearchSearchEngine implements SearchEngine {
});
}
protected translator({
term,
filters = {},
types,
pageCursor,
}: SearchQuery): ConcreteElasticSearchQuery {
protected translator(query: SearchQuery): ConcreteElasticSearchQuery {
const { term, filters = {}, types, pageCursor } = query;
const filter = Object.entries(filters)
.filter(([_, value]) => Boolean(value))
.map(([key, value]: [key: string, value: any]) => {
@@ -190,7 +192,7 @@ export class ElasticSearchSearchEngine implements SearchEngine {
'Failed to add filters to query. Unrecognized filter type',
);
});
const query = isBlank(term)
const esbQuery = isBlank(term)
? esb.matchAllQuery()
: esb
.multiMatchQuery(['*'], term)
@@ -202,7 +204,7 @@ export class ElasticSearchSearchEngine implements SearchEngine {
return {
elasticSearchQuery: esb
.requestBodySearch()
.query(esb.boolQuery().filter(filter).must([query]))
.query(esb.boolQuery().filter(filter).must([esbQuery]))
.from(page * pageSize)
.size(pageSize)
.toJSON(),
@@ -77,9 +77,7 @@ export interface DatabaseStore {
export class PgSearchEngine implements SearchEngine {
constructor(databaseStore: DatabaseStore);
// (undocumented)
static from({
database,
}: {
static from(options: {
database: PluginDatabaseManager;
}): Promise<PgSearchEngine>;
// (undocumented)
@@ -35,13 +35,11 @@ export type ConcretePgSearchQuery = {
export class PgSearchEngine implements SearchEngine {
constructor(private readonly databaseStore: DatabaseStore) {}
static async from({
database,
}: {
static async from(options: {
database: PluginDatabaseManager;
}): Promise<PgSearchEngine> {
return new PgSearchEngine(
await DatabaseDocumentStore.create(await database.getClient()),
await DatabaseDocumentStore.create(await options.database.getClient()),
);
}
+9 -5
View File
@@ -7,12 +7,16 @@ import express from 'express';
import { Logger as Logger_2 } from 'winston';
import { SearchEngine } from '@backstage/plugin-search-backend-node';
// Warning: (ae-forgotten-export) The symbol "RouterOptions" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "createRouter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export function createRouter({
engine,
logger,
}: RouterOptions): Promise<express.Router>;
export function createRouter(options: RouterOptions): Promise<express.Router>;
// Warning: (ae-missing-release-tag) "RouterOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type RouterOptions = {
engine: SearchEngine;
logger: Logger_2;
};
```
+5 -5
View File
@@ -20,15 +20,15 @@ import { Logger } from 'winston';
import { SearchQuery, SearchResultSet } from '@backstage/search-common';
import { SearchEngine } from '@backstage/plugin-search-backend-node';
type RouterOptions = {
export type RouterOptions = {
engine: SearchEngine;
logger: Logger;
};
export async function createRouter({
engine,
logger,
}: RouterOptions): Promise<express.Router> {
export async function createRouter(
options: RouterOptions,
): Promise<express.Router> {
const { engine, logger } = options;
const router = Router();
router.get(
'/query',
+1 -9
View File
@@ -28,15 +28,7 @@ export function createRouter(options: RouterOptions): Promise<express.Router>;
// @public (undocumented)
export class DefaultTechDocsCollator implements DocumentCollator {
// @deprecated
constructor({
discovery,
locationTemplate,
logger,
catalogClient,
tokenManager,
parallelismLimit,
legacyPathCasing,
}: TechDocsCollatorOptions);
constructor(options: TechDocsCollatorOptions);
// (undocumented)
protected applyArgsToFormat(
format: string,
@@ -63,24 +63,17 @@ export class DefaultTechDocsCollator implements DocumentCollator {
/**
* @deprecated use static fromConfig method instead.
*/
constructor({
discovery,
locationTemplate,
logger,
catalogClient,
tokenManager,
parallelismLimit = 10,
legacyPathCasing = false,
}: TechDocsCollatorOptions) {
this.discovery = discovery;
constructor(options: TechDocsCollatorOptions) {
this.discovery = options.discovery;
this.locationTemplate =
locationTemplate || '/docs/:namespace/:kind/:name/:path';
this.logger = logger;
options.locationTemplate || '/docs/:namespace/:kind/:name/:path';
this.logger = options.logger;
this.catalogClient =
catalogClient || new CatalogClient({ discoveryApi: discovery });
this.parallelismLimit = parallelismLimit;
this.legacyPathCasing = legacyPathCasing;
this.tokenManager = tokenManager;
options.catalogClient ||
new CatalogClient({ discoveryApi: options.discovery });
this.parallelismLimit = options.parallelismLimit ?? 10;
this.legacyPathCasing = options.legacyPathCasing ?? false;
this.tokenManager = options.tokenManager;
}
static fromConfig(config: Config, options: TechDocsCollatorOptions) {
+1 -1
View File
@@ -112,7 +112,7 @@ export class TodoScmReader implements TodoReader {
options: Omit<Options, 'integrations'>,
): TodoScmReader;
// (undocumented)
readTodos({ url }: ReadTodosOptions): Promise<ReadTodosResult>;
readTodos(options: ReadTodosOptions): Promise<ReadTodosResult>;
}
// Warning: (ae-missing-release-tag) "TodoService" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
@@ -76,7 +76,8 @@ export class TodoScmReader implements TodoReader {
this.integrations = options.integrations;
}
async readTodos({ url }: ReadTodosOptions): Promise<ReadTodosResult> {
async readTodos(options: ReadTodosOptions): Promise<ReadTodosResult> {
const { url } = options;
const inFlightRead = this.inFlightReads.get(url);
if (inFlightRead) {
return inFlightRead.then(read => read.result);
@@ -101,9 +102,10 @@ export class TodoScmReader implements TodoReader {
}
private async doReadTodos(
{ url }: ReadTodosOptions,
options: ReadTodosOptions,
etag?: string,
): Promise<CacheItem> {
const { url } = options;
const tree = await this.reader.readTree(url, {
etag,
filter(filePath, info) {
+1 -7
View File
@@ -26,13 +26,7 @@ export const todoApiRef: ApiRef<TodoApi>;
export class TodoClient implements TodoApi {
constructor(options: TodoClientOptions);
// (undocumented)
listTodos({
entity,
offset,
limit,
orderBy,
filters,
}: TodoListOptions): Promise<TodoListResult>;
listTodos(options: TodoListOptions): Promise<TodoListResult>;
}
// @public
+2 -7
View File
@@ -43,13 +43,8 @@ export class TodoClient implements TodoApi {
this.identityApi = options.identityApi;
}
async listTodos({
entity,
offset,
limit,
orderBy,
filters,
}: TodoListOptions): Promise<TodoListResult> {
async listTodos(options: TodoListOptions): Promise<TodoListResult> {
const { entity, offset, limit, orderBy, filters } = options;
const baseUrl = await this.discoveryApi.getBaseUrl('todo');
const token = await this.identityApi.getIdToken();