diff --git a/.changeset/gentle-masks-lie.md b/.changeset/gentle-masks-lie.md new file mode 100644 index 0000000000..2f61ef656d --- /dev/null +++ b/.changeset/gentle-masks-lie.md @@ -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 diff --git a/packages/backend-common/api-report.md b/packages/backend-common/api-report.md index 9c66c0573e..376cdc8b64 100644 --- a/packages/backend-common/api-report.md +++ b/packages/backend-common/api-report.md @@ -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; + runContainer(options: RunContainerOptions): Promise; } // @public @@ -227,34 +218,17 @@ export function getVoidLogger(): winston.Logger; // @public (undocumented) export class Git { // (undocumented) - add({ dir, filepath }: { dir: string; filepath: string }): Promise; + add(options: { dir: string; filepath: string }): Promise; // (undocumented) - addRemote({ - dir, - url, - remote, - }: { + addRemote(options: { dir: string; remote: string; url: string; }): Promise; // (undocumented) - clone({ - url, - dir, - ref, - }: { - url: string; - dir: string; - ref?: string; - }): Promise; + clone(options: { url: string; dir: string; ref?: string }): Promise; // (undocumented) - commit({ - dir, - message, - author, - committer, - }: { + commit(options: { dir: string; message: string; author: { @@ -267,41 +241,22 @@ export class Git { }; }): Promise; // (undocumented) - currentBranch({ - dir, - fullName, - }: { + currentBranch(options: { dir: string; fullName?: boolean; }): Promise; // (undocumented) - fetch({ dir, remote }: { dir: string; remote?: string }): Promise; + fetch(options: { dir: string; remote?: string }): Promise; // (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; + init(options: { dir: string; defaultBranch?: string }): Promise; // (undocumented) - merge({ - dir, - theirs, - ours, - author, - committer, - }: { + merge(options: { dir: string; theirs: string; ours?: string; @@ -315,17 +270,11 @@ export class Git { }; }): Promise; // (undocumented) - push({ dir, remote }: { dir: string; remote: string }): Promise; + push(options: { dir: string; remote: string }): Promise; // (undocumented) - readCommit({ - dir, - sha, - }: { - dir: string; - sha: string; - }): Promise; + readCommit(options: { dir: string; sha: string }): Promise; // (undocumented) - resolveRef({ dir, ref }: { dir: string; ref: string }): Promise; + resolveRef(options: { dir: string; ref: string }): Promise; } // @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) diff --git a/packages/backend-common/src/reading/UrlReaders.ts b/packages/backend-common/src/reading/UrlReaders.ts index 7120a9570f..a920ec080b 100644 --- a/packages/backend-common/src/reading/UrlReaders.ts +++ b/packages/backend-common/src/reading/UrlReaders.ts @@ -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, diff --git a/packages/backend-common/src/scm/git.ts b/packages/backend-common/src/scm/git.ts index 00b103b240..372ecb0260 100644 --- a/packages/backend-common/src/scm/git.ts +++ b/packages/backend-common/src/scm/git.ts @@ -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 { + async add(options: { dir: string; filepath: string }): Promise { + 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 { + 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 { + 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 { + 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 { - 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 { - const remoteValue = remote ?? 'origin'; + async fetch(options: { dir: string; remote?: string }): Promise { + 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 { + async init(options: { dir: string; defaultBranch?: string }): Promise { + 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 { + 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 { + 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 { + async resolveRef(options: { dir: string; ref: string }): Promise { + 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 }); + }; } diff --git a/packages/backend-common/src/util/DockerContainerRunner.ts b/packages/backend-common/src/util/DockerContainerRunner.ts index b81bd995ca..424913f316 100644 --- a/packages/backend-common/src/util/DockerContainerRunner.ts +++ b/packages/backend-common/src/util/DockerContainerRunner.ts @@ -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(); diff --git a/packages/core-app-api/api-report.md b/packages/core-app-api/api-report.md index e69ee4f325..339e0a7c8b 100644 --- a/packages/core-app-api/api-report.md +++ b/packages/core-app-api/api-report.md @@ -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); // (undocumented) - static create({ - discoveryApi, - environment, - provider, - oauthRequestApi, - defaultScopes, - }: OAuthApiCreateOptions): GithubAuth; + static create(options: OAuthApiCreateOptions): GithubAuth; // (undocumented) getAccessToken(scope?: string, options?: AuthRequestOptions): Promise; // (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); // (undocumented) - static create({ - discoveryApi, - environment, - provider, - }: AuthApiCreateOptions): SamlAuth; + static create(options: AuthApiCreateOptions): SamlAuth; // (undocumented) getBackstageIdentity( options?: AuthRequestOptions, diff --git a/packages/core-app-api/src/apis/implementations/auth/atlassian/AtlassianAuth.ts b/packages/core-app-api/src/apis/implementations/auth/atlassian/AtlassianAuth.ts index caad40ddbf..07ebefca28 100644 --- a/packages/core-app-api/src/apis/implementations/auth/atlassian/AtlassianAuth.ts +++ b/packages/core-app-api/src/apis/implementations/auth/atlassian/AtlassianAuth.ts @@ -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, diff --git a/packages/core-app-api/src/apis/implementations/auth/auth0/Auth0Auth.ts b/packages/core-app-api/src/apis/implementations/auth/auth0/Auth0Auth.ts index 0a158ccb9e..d0a9dc5d99 100644 --- a/packages/core-app-api/src/apis/implementations/auth/auth0/Auth0Auth.ts +++ b/packages/core-app-api/src/apis/implementations/auth/auth0/Auth0Auth.ts @@ -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, diff --git a/packages/core-app-api/src/apis/implementations/auth/bitbucket/BitbucketAuth.ts b/packages/core-app-api/src/apis/implementations/auth/bitbucket/BitbucketAuth.ts index e488580c4d..c97cccc6ed 100644 --- a/packages/core-app-api/src/apis/implementations/auth/bitbucket/BitbucketAuth.ts +++ b/packages/core-app-api/src/apis/implementations/auth/bitbucket/BitbucketAuth.ts @@ -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, diff --git a/packages/core-app-api/src/apis/implementations/auth/github/GithubAuth.ts b/packages/core-app-api/src/apis/implementations/auth/github/GithubAuth.ts index 3e9c899346..4da92efbdf 100644 --- a/packages/core-app-api/src/apis/implementations/auth/github/GithubAuth.ts +++ b/packages/core-app-api/src/apis/implementations/auth/github/GithubAuth.ts @@ -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, diff --git a/packages/core-app-api/src/apis/implementations/auth/gitlab/GitlabAuth.ts b/packages/core-app-api/src/apis/implementations/auth/gitlab/GitlabAuth.ts index f46f2ef72e..00085de8ac 100644 --- a/packages/core-app-api/src/apis/implementations/auth/gitlab/GitlabAuth.ts +++ b/packages/core-app-api/src/apis/implementations/auth/gitlab/GitlabAuth.ts @@ -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, diff --git a/packages/core-app-api/src/apis/implementations/auth/google/GoogleAuth.ts b/packages/core-app-api/src/apis/implementations/auth/google/GoogleAuth.ts index a6f37b250f..8a528f4511 100644 --- a/packages/core-app-api/src/apis/implementations/auth/google/GoogleAuth.ts +++ b/packages/core-app-api/src/apis/implementations/auth/google/GoogleAuth.ts @@ -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, diff --git a/packages/core-app-api/src/apis/implementations/auth/microsoft/MicrosoftAuth.ts b/packages/core-app-api/src/apis/implementations/auth/microsoft/MicrosoftAuth.ts index 148be66873..be5776609d 100644 --- a/packages/core-app-api/src/apis/implementations/auth/microsoft/MicrosoftAuth.ts +++ b/packages/core-app-api/src/apis/implementations/auth/microsoft/MicrosoftAuth.ts @@ -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, diff --git a/packages/core-app-api/src/apis/implementations/auth/oauth2/OAuth2.ts b/packages/core-app-api/src/apis/implementations/auth/oauth2/OAuth2.ts index 403e8445d8..582526083b 100644 --- a/packages/core-app-api/src/apis/implementations/auth/oauth2/OAuth2.ts +++ b/packages/core-app-api/src/apis/implementations/auth/oauth2/OAuth2.ts @@ -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, diff --git a/packages/core-app-api/src/apis/implementations/auth/okta/OktaAuth.ts b/packages/core-app-api/src/apis/implementations/auth/okta/OktaAuth.ts index 465a124051..42c0ddd0ed 100644 --- a/packages/core-app-api/src/apis/implementations/auth/okta/OktaAuth.ts +++ b/packages/core-app-api/src/apis/implementations/auth/okta/OktaAuth.ts @@ -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, diff --git a/packages/core-app-api/src/apis/implementations/auth/onelogin/OneLoginAuth.ts b/packages/core-app-api/src/apis/implementations/auth/onelogin/OneLoginAuth.ts index 93b9f6634c..9493d0809e 100644 --- a/packages/core-app-api/src/apis/implementations/auth/onelogin/OneLoginAuth.ts +++ b/packages/core-app-api/src/apis/implementations/auth/onelogin/OneLoginAuth.ts @@ -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, diff --git a/packages/core-app-api/src/apis/implementations/auth/saml/SamlAuth.ts b/packages/core-app-api/src/apis/implementations/auth/saml/SamlAuth.ts index c1b70e963d..5988e81c48 100644 --- a/packages/core-app-api/src/apis/implementations/auth/saml/SamlAuth.ts +++ b/packages/core-app-api/src/apis/implementations/auth/saml/SamlAuth.ts @@ -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({ discoveryApi, environment, diff --git a/packages/core-components/api-report.md b/packages/core-components/api-report.md index c1e021391e..cc7db32586 100644 --- a/packages/core-components/api-report.md +++ b/packages/core-components/api-report.md @@ -1982,10 +1982,7 @@ export const SidebarSpacer: React_2.ComponentType< >; // @public -export const SidebarSubmenu: ({ - title, - children, -}: PropsWithChildren) => JSX.Element; +export const SidebarSubmenu: (props: SidebarSubmenuProps) => JSX.Element; // @public export const SidebarSubmenuItem: ( diff --git a/packages/core-components/src/layout/Sidebar/SidebarSubmenu.tsx b/packages/core-components/src/layout/Sidebar/SidebarSubmenu.tsx index 51324980fe..df671c7514 100644 --- a/packages/core-components/src/layout/Sidebar/SidebarSubmenu.tsx +++ b/packages/core-components/src/layout/Sidebar/SidebarSubmenu.tsx @@ -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) => { +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 = ({ })} > - {title} + {props.title} - {children} + {props.children} ); }; diff --git a/packages/core-plugin-api/api-report.md b/packages/core-plugin-api/api-report.md index 560071e1fa..f403594e34 100644 --- a/packages/core-plugin-api/api-report.md +++ b/packages/core-plugin-api/api-report.md @@ -43,10 +43,7 @@ export type AnalyticsApi = { export const analyticsApiRef: ApiRef; // @public -export const AnalyticsContext: ({ - attributes, - children, -}: { +export const AnalyticsContext: (options: { attributes: Partial; children: ReactNode; }) => JSX.Element; diff --git a/packages/core-plugin-api/src/analytics/AnalyticsContext.tsx b/packages/core-plugin-api/src/analytics/AnalyticsContext.tsx index bb2141d47f..075cdff3ff 100644 --- a/packages/core-plugin-api/src/analytics/AnalyticsContext.tsx +++ b/packages/core-plugin-api/src/analytics/AnalyticsContext.tsx @@ -62,13 +62,12 @@ export const useAnalyticsContext = (): AnalyticsContextValue => { * * @public */ -export const AnalyticsContext = ({ - attributes, - children, -}: { +export const AnalyticsContext = (options: { attributes: Partial; children: ReactNode; }) => { + const { attributes, children } = options; + const parentValues = useAnalyticsContext(); const combinedValue = { ...parentValues, diff --git a/packages/dev-utils/api-report.md b/packages/dev-utils/api-report.md index c10de7d529..e1cb93313f 100644 --- a/packages/dev-utils/api-report.md +++ b/packages/dev-utils/api-report.md @@ -44,11 +44,9 @@ export type DevAppPageOptions = { }; // @public (undocumented) -export const EntityGridItem: ({ - entity, - classes, - ...rest -}: Omit, 'container' | 'item'> & { - entity: Entity; -}) => JSX.Element; +export const EntityGridItem: ( + props: Omit & { + entity: Entity; + }, +) => JSX.Element; ``` diff --git a/packages/dev-utils/src/components/EntityGridItem/EntityGridItem.tsx b/packages/dev-utils/src/components/EntityGridItem/EntityGridItem.tsx index 55327f35e5..a66550a4d2 100644 --- a/packages/dev-utils/src/components/EntityGridItem/EntityGridItem.tsx +++ b/packages/dev-utils/src/components/EntityGridItem/EntityGridItem.tsx @@ -35,11 +35,10 @@ const useStyles = makeStyles(theme => ({ })); /** @public */ -export const EntityGridItem = ({ - entity, - classes, - ...rest -}: Omit & { entity: Entity }): JSX.Element => { +export const EntityGridItem = ( + props: Omit & { entity: Entity }, +): JSX.Element => { + const { entity, classes, ...rest } = props; const itemClasses = useStyles({ entity }); return ( diff --git a/packages/techdocs-common/api-report.md b/packages/techdocs-common/api-report.md index b2f9e40d0a..5c0a9f87f6 100644 --- a/packages/techdocs-common/api-report.md +++ b/packages/techdocs-common/api-report.md @@ -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; } -// 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; - // Warning: (ae-forgotten-export) The symbol "ReadinessResponse" needs to be exported by the entry point index.d.ts getReadiness(): Promise; hasDocsBeenGenerated(entityName: Entity): Promise; // 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; - // 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; @@ -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; + run(options: GeneratorRunOptions): Promise; } -// 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 diff --git a/packages/techdocs-common/src/stages/generate/generators.ts b/packages/techdocs-common/src/stages/generate/generators.ts index 3d1ad2b73b..de39d4e7c3 100644 --- a/packages/techdocs-common/src/stages/generate/generators.ts +++ b/packages/techdocs-common/src/stages/generate/generators.ts @@ -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 { const generators = new Generators(); - const techdocsGenerator = TechdocsGenerator.fromConfig(config, { - logger, - containerRunner, - }); + const techdocsGenerator = TechdocsGenerator.fromConfig(config, options); generators.register('techdocs', techdocsGenerator); return generators; diff --git a/packages/techdocs-common/src/stages/generate/techdocs.ts b/packages/techdocs-common/src/stages/generate/techdocs.ts index 8681736815..a6eb8d38d2 100644 --- a/packages/techdocs-common/src/stages/generate/techdocs.ts +++ b/packages/techdocs-common/src/stages/generate/techdocs.ts @@ -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 { + public async run(options: GeneratorRunOptions): Promise { + 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); diff --git a/packages/techdocs-common/src/stages/generate/types.ts b/packages/techdocs-common/src/stages/generate/types.ts index 3559716be0..2a090d5584 100644 --- a/packages/techdocs-common/src/stages/generate/types.ts +++ b/packages/techdocs-common/src/stages/generate/types.ts @@ -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; diff --git a/packages/techdocs-common/src/stages/publish/index.ts b/packages/techdocs-common/src/stages/publish/index.ts index b342f33287..083cf2b8ff 100644 --- a/packages/techdocs-common/src/stages/publish/index.ts +++ b/packages/techdocs-common/src/stages/publish/index.ts @@ -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'; diff --git a/packages/techdocs-common/src/stages/publish/types.ts b/packages/techdocs-common/src/stages/publish/types.ts index 1fb301340b..b7415722d6 100644 --- a/packages/techdocs-common/src/stages/publish/types.ts +++ b/packages/techdocs-common/src/stages/publish/types.ts @@ -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; diff --git a/packages/test-utils/api-report.md b/packages/test-utils/api-report.md index 83c209122d..a01f306fab 100644 --- a/packages/test-utils/api-report.md +++ b/packages/test-utils/api-report.md @@ -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: ({ - apis, - children, -}: TestApiProviderProps) => JSX.Element; +export const TestApiProvider: ( + props: TestApiProviderProps, +) => JSX.Element; // @public export type TestApiProviderProps = { diff --git a/packages/test-utils/src/testUtils/TestApiProvider.tsx b/packages/test-utils/src/testUtils/TestApiProvider.tsx index b1499b0cde..6e0be81d53 100644 --- a/packages/test-utils/src/testUtils/TestApiProvider.tsx +++ b/packages/test-utils/src/testUtils/TestApiProvider.tsx @@ -120,11 +120,13 @@ export class TestApiRegistry implements ApiHolder { * * @public **/ -export const TestApiProvider = ({ - apis, - children, -}: TestApiProviderProps) => { +export const TestApiProvider = ( + props: TestApiProviderProps, +) => { return ( - + ); }; diff --git a/packages/test-utils/src/testUtils/apis/AnalyticsApi/MockAnalyticsApi.ts b/packages/test-utils/src/testUtils/apis/AnalyticsApi/MockAnalyticsApi.ts index 3e2fc2a01c..6da225df1c 100644 --- a/packages/test-utils/src/testUtils/apis/AnalyticsApi/MockAnalyticsApi.ts +++ b/packages/test-utils/src/testUtils/apis/AnalyticsApi/MockAnalyticsApi.ts @@ -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, diff --git a/packages/test-utils/src/testUtils/mockBreakpoint.ts b/packages/test-utils/src/testUtils/mockBreakpoint.ts index 3bc285a81d..ee759c07a5 100644 --- a/packages/test-utils/src/testUtils/mockBreakpoint.ts +++ b/packages/test-utils/src/testUtils/mockBreakpoint.ts @@ -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 diff --git a/plugins/analytics-module-ga/api-report.md b/plugins/analytics-module-ga/api-report.md index 7ca3b1646f..b0f3b736c3 100644 --- a/plugins/analytics-module-ga/api-report.md +++ b/plugins/analytics-module-ga/api-report.md @@ -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; } diff --git a/plugins/analytics-module-ga/src/apis/implementations/AnalyticsApi/GoogleAnalytics.ts b/plugins/analytics-module-ga/src/apis/implementations/AnalyticsApi/GoogleAnalytics.ts index 23da7c8589..28202607be 100644 --- a/plugins/analytics-module-ga/src/apis/implementations/AnalyticsApi/GoogleAnalytics.ts +++ b/plugins/analytics-module-ga/src/apis/implementations/AnalyticsApi/GoogleAnalytics.ts @@ -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') { diff --git a/plugins/auth-backend/api-report.md b/plugins/auth-backend/api-report.md index 46d8b03cbb..2037bd240a 100644 --- a/plugins/auth-backend/api-report.md +++ b/plugins/auth-backend/api-report.md @@ -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; // Warning: (ae-forgotten-export) The symbol "MemberClaimQuery" needs to be exported by the entry point index.d.ts - resolveCatalogMembership({ - entityRefs, - logger, - }: MemberClaimQuery): Promise; + resolveCatalogMembership(query: MemberClaimQuery): Promise; } // 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; +export function createRouter(options: RouterOptions): Promise; // @public (undocumented) export const createSamlProvider: ( diff --git a/plugins/auth-backend/src/lib/catalog/CatalogIdentityClient.ts b/plugins/auth-backend/src/lib/catalog/CatalogIdentityClient.ts index 02fe9818cb..a1f915d152 100644 --- a/plugins/auth-backend/src/lib/catalog/CatalogIdentityClient.ts +++ b/plugins/auth-backend/src/lib/catalog/CatalogIdentityClient.ts @@ -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 { + async resolveCatalogMembership(query: MemberClaimQuery): Promise { + const { entityRefs, logger } = query; const resolvedEntityRefs = entityRefs .map((ref: string) => { try { diff --git a/plugins/auth-backend/src/service/router.ts b/plugins/auth-backend/src/service/router.ts index 4aa9ed8778..6a96d421da 100644 --- a/plugins/auth-backend/src/service/router.ts +++ b/plugins/auth-backend/src/service/router.ts @@ -44,13 +44,10 @@ export interface RouterOptions { providerFactories?: ProviderFactories; } -export async function createRouter({ - logger, - config, - discovery, - database, - providerFactories, -}: RouterOptions): Promise { +export async function createRouter( + options: RouterOptions, +): Promise { + const { logger, config, discovery, database, providerFactories } = options; const router = Router(); const appUrl = config.getString('app.baseUrl'); diff --git a/plugins/catalog-backend/api-report.md b/plugins/catalog-backend/api-report.md index 43eb8d61b7..f773905ca0 100644 --- a/plugins/catalog-backend/api-report.md +++ b/plugins/catalog-backend/api-report.md @@ -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; diff --git a/plugins/catalog-backend/src/search/DefaultCatalogCollator.ts b/plugins/catalog-backend/src/search/DefaultCatalogCollator.ts index 4c6342c6c6..ebad95e72f 100644 --- a/plugins/catalog-backend/src/search/DefaultCatalogCollator.ts +++ b/plugins/catalog-backend/src/search/DefaultCatalogCollator.ts @@ -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'; diff --git a/plugins/config-schema/api-report.md b/plugins/config-schema/api-report.md index efeb1646eb..f3b620738f 100644 --- a/plugins/config-schema/api-report.md +++ b/plugins/config-schema/api-report.md @@ -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; } diff --git a/plugins/config-schema/src/api/StaticSchemaLoader.ts b/plugins/config-schema/src/api/StaticSchemaLoader.ts index 71eae63376..5fc979b76d 100644 --- a/plugins/config-schema/src/api/StaticSchemaLoader.ts +++ b/plugins/config-schema/src/api/StaticSchemaLoader.ts @@ -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 { diff --git a/plugins/github-deployments/api-report.md b/plugins/github-deployments/api-report.md index a8fca185e5..36680cb020 100644 --- a/plugins/github-deployments/api-report.md +++ b/plugins/github-deployments/api-report.md @@ -38,11 +38,7 @@ function createStatusColumn(): TableColumn; // 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[] | 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) // diff --git a/plugins/github-deployments/src/components/GithubDeploymentsCard.tsx b/plugins/github-deployments/src/components/GithubDeploymentsCard.tsx index c01cd98a45..c1c33607a1 100644 --- a/plugins/github-deployments/src/components/GithubDeploymentsCard.tsx +++ b/plugins/github-deployments/src/components/GithubDeploymentsCard.tsx @@ -80,15 +80,12 @@ const GithubDeploymentsComponent = ({ ); }; -export const GithubDeploymentsCard = ({ - last, - lastStatuses, - columns, -}: { +export const GithubDeploymentsCard = (props: { last?: number; lastStatuses?: number; columns?: TableColumn[]; }) => { + const { last, lastStatuses, columns } = props; const { entity } = useEntity(); const [host] = [ entity?.metadata.annotations?.[SOURCE_LOCATION_ANNOTATION], diff --git a/plugins/github-deployments/src/components/GithubDeploymentsTable/GithubDeploymentsTable.tsx b/plugins/github-deployments/src/components/GithubDeploymentsTable/GithubDeploymentsTable.tsx index 2de7cdf419..2c48f3eef1 100644 --- a/plugins/github-deployments/src/components/GithubDeploymentsTable/GithubDeploymentsTable.tsx +++ b/plugins/github-deployments/src/components/GithubDeploymentsTable/GithubDeploymentsTable.tsx @@ -36,12 +36,8 @@ type GithubDeploymentsTableProps = { columns: TableColumn[]; }; -export function GithubDeploymentsTable({ - deployments, - isLoading, - reload, - columns, -}: GithubDeploymentsTableProps) { +export function GithubDeploymentsTable(props: GithubDeploymentsTableProps) { + const { deployments, isLoading, reload, columns } = props; const classes = useStyles(); return ( diff --git a/plugins/github-deployments/src/components/GithubDeploymentsTable/columns.tsx b/plugins/github-deployments/src/components/GithubDeploymentsTable/columns.tsx index e892b12427..9a720c0e75 100644 --- a/plugins/github-deployments/src/components/GithubDeploymentsTable/columns.tsx +++ b/plugins/github-deployments/src/components/GithubDeploymentsTable/columns.tsx @@ -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 ; case 'IN_PROGRESS': diff --git a/plugins/pagerduty/api-report.md b/plugins/pagerduty/api-report.md index 689edae1e0..bd26531da6 100644 --- a/plugins/pagerduty/api-report.md +++ b/plugins/pagerduty/api-report.md @@ -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; + triggerAlarm(request: TriggerAlarmRequest): Promise; } // 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): 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) // diff --git a/plugins/pagerduty/src/api/client.ts b/plugins/pagerduty/src/api/client.ts index c006403fe7..65ff83e7ba 100644 --- a/plugins/pagerduty/src/api/client.ts +++ b/plugins/pagerduty/src/api/client.ts @@ -91,12 +91,9 @@ export class PagerDutyClient implements PagerDutyApi { return oncalls; } - triggerAlarm({ - integrationKey, - source, - description, - userName, - }: TriggerAlarmRequest): Promise { + triggerAlarm(request: TriggerAlarmRequest): Promise { + const { integrationKey, source, description, userName } = request; + const body = JSON.stringify({ event_action: 'trigger', routing_key: integrationKey, diff --git a/plugins/pagerduty/src/components/TriggerButton/index.tsx b/plugins/pagerduty/src/components/TriggerButton/index.tsx index 93897c77be..6f83effcf4 100644 --- a/plugins/pagerduty/src/components/TriggerButton/index.tsx +++ b/plugins/pagerduty/src/components/TriggerButton/index.tsx @@ -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(theme => ({ buttonStyle: { @@ -32,9 +34,7 @@ const useStyles = makeStyles(theme => ({ }, })); -export function TriggerButton({ - children, -}: PropsWithChildren) { +export function TriggerButton(props: TriggerButtonProps) { const { buttonStyle } = useStyles(); const { integrationKey } = usePagerdutyEntity(); const [dialogShown, setDialogShown] = useState(false); @@ -56,7 +56,7 @@ export function TriggerButton({ disabled={disabled} > {integrationKey - ? children ?? 'Create Incident' + ? props.children ?? 'Create Incident' : 'Missing integration key'} {integrationKey && ( diff --git a/plugins/permission-node/api-report.md b/plugins/permission-node/api-report.md index 75c45a9250..adc1cbc3c6 100644 --- a/plugins/permission-node/api-report.md +++ b/plugins/permission-node/api-report.md @@ -83,11 +83,7 @@ export const createConditionTransformer: < ) => ConditionTransformer; // @public -export const createPermissionIntegrationRouter: ({ - resourceType, - rules, - getResource, -}: { +export const createPermissionIntegrationRouter: (options: { resourceType: string; rules: PermissionRule[]; getResource: (resourceRef: string) => Promise; diff --git a/plugins/permission-node/src/integration/createPermissionIntegrationRouter.ts b/plugins/permission-node/src/integration/createPermissionIntegrationRouter.ts index 70b72fef7e..b8d3e02a81 100644 --- a/plugins/permission-node/src/integration/createPermissionIntegrationRouter.ts +++ b/plugins/permission-node/src/integration/createPermissionIntegrationRouter.ts @@ -116,17 +116,15 @@ const applyConditions = ( * 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 = ({ - resourceType, - rules, - getResource, -}: { +export const createPermissionIntegrationRouter = (options: { resourceType: string; rules: PermissionRule[]; getResource: (resourceRef: string) => Promise; }): Router => { + const { resourceType, rules, getResource } = options; const router = Router(); const getRule = createGetRule(rules); diff --git a/plugins/permission-react/api-report.md b/plugins/permission-react/api-report.md index 65f93de8a0..c10317495a 100644 --- a/plugins/permission-react/api-report.md +++ b/plugins/permission-react/api-report.md @@ -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; // (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; // @public -export const PermissionedRoute: ({ - permission, - resourceRef, - errorComponent, - ...props -}: RouteProps & { - permission: Permission; - resourceRef?: string | undefined; - errorComponent?: - | React_2.ReactElement> - | null - | undefined; -}) => JSX.Element; +export const PermissionedRoute: ( + props: ComponentProps & { + permission: Permission; + resourceRef?: string; + errorComponent?: ReactElement | null; + }, +) => JSX.Element; // @public export const usePermission: ( diff --git a/plugins/permission-react/src/apis/IdentityPermissionApi.ts b/plugins/permission-react/src/apis/IdentityPermissionApi.ts index a68060a61d..19de564f84 100644 --- a/plugins/permission-react/src/apis/IdentityPermissionApi.ts +++ b/plugins/permission-react/src/apis/IdentityPermissionApi.ts @@ -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); } diff --git a/plugins/permission-react/src/components/PermissionedRoute.tsx b/plugins/permission-react/src/components/PermissionedRoute.tsx index 1a3668205b..76017308aa 100644 --- a/plugins/permission-react/src/components/PermissionedRoute.tsx +++ b/plugins/permission-react/src/components/PermissionedRoute.tsx @@ -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 & { - permission: Permission; - resourceRef?: string; - errorComponent?: ReactElement | null; -}) => { +export const PermissionedRoute = ( + props: ComponentProps & { + 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 ; + return ; }; diff --git a/plugins/search-backend-module-elasticsearch/api-report.md b/plugins/search-backend-module-elasticsearch/api-report.md index da1f7d4804..1e798119c3 100644 --- a/plugins/search-backend-module-elasticsearch/api-report.md +++ b/plugins/search-backend-module-elasticsearch/api-report.md @@ -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; + static fromConfig( + options: ElasticSearchOptions, + ): Promise; // (undocumented) index(type: string, documents: IndexableDocument[]): Promise; // (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; } ``` diff --git a/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngine.ts b/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngine.ts index 1a41099c9c..7912c691b3 100644 --- a/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngine.ts +++ b/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngine.ts @@ -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(), diff --git a/plugins/search-backend-module-pg/api-report.md b/plugins/search-backend-module-pg/api-report.md index 7a171127a3..e2edfc291a 100644 --- a/plugins/search-backend-module-pg/api-report.md +++ b/plugins/search-backend-module-pg/api-report.md @@ -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; // (undocumented) diff --git a/plugins/search-backend-module-pg/src/PgSearchEngine/PgSearchEngine.ts b/plugins/search-backend-module-pg/src/PgSearchEngine/PgSearchEngine.ts index a032dd783e..6fd6c571a8 100644 --- a/plugins/search-backend-module-pg/src/PgSearchEngine/PgSearchEngine.ts +++ b/plugins/search-backend-module-pg/src/PgSearchEngine/PgSearchEngine.ts @@ -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 { return new PgSearchEngine( - await DatabaseDocumentStore.create(await database.getClient()), + await DatabaseDocumentStore.create(await options.database.getClient()), ); } diff --git a/plugins/search-backend/api-report.md b/plugins/search-backend/api-report.md index f2479610fe..cac97bd725 100644 --- a/plugins/search-backend/api-report.md +++ b/plugins/search-backend/api-report.md @@ -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; +export function createRouter(options: RouterOptions): Promise; + +// 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; +}; ``` diff --git a/plugins/search-backend/src/service/router.ts b/plugins/search-backend/src/service/router.ts index 6df39ca1eb..5bd99988a7 100644 --- a/plugins/search-backend/src/service/router.ts +++ b/plugins/search-backend/src/service/router.ts @@ -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 { +export async function createRouter( + options: RouterOptions, +): Promise { + const { engine, logger } = options; const router = Router(); router.get( '/query', diff --git a/plugins/techdocs-backend/api-report.md b/plugins/techdocs-backend/api-report.md index 9736555687..b241917bc0 100644 --- a/plugins/techdocs-backend/api-report.md +++ b/plugins/techdocs-backend/api-report.md @@ -28,15 +28,7 @@ export function createRouter(options: RouterOptions): Promise; // @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, diff --git a/plugins/techdocs-backend/src/search/DefaultTechDocsCollator.ts b/plugins/techdocs-backend/src/search/DefaultTechDocsCollator.ts index 283d0264e4..fa8a1156fe 100644 --- a/plugins/techdocs-backend/src/search/DefaultTechDocsCollator.ts +++ b/plugins/techdocs-backend/src/search/DefaultTechDocsCollator.ts @@ -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) { diff --git a/plugins/todo-backend/api-report.md b/plugins/todo-backend/api-report.md index f989755a62..00e243d1a2 100644 --- a/plugins/todo-backend/api-report.md +++ b/plugins/todo-backend/api-report.md @@ -112,7 +112,7 @@ export class TodoScmReader implements TodoReader { options: Omit, ): TodoScmReader; // (undocumented) - readTodos({ url }: ReadTodosOptions): Promise; + readTodos(options: ReadTodosOptions): Promise; } // Warning: (ae-missing-release-tag) "TodoService" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) diff --git a/plugins/todo-backend/src/lib/TodoReader/TodoScmReader.ts b/plugins/todo-backend/src/lib/TodoReader/TodoScmReader.ts index 8442983637..804dd1146d 100644 --- a/plugins/todo-backend/src/lib/TodoReader/TodoScmReader.ts +++ b/plugins/todo-backend/src/lib/TodoReader/TodoScmReader.ts @@ -76,7 +76,8 @@ export class TodoScmReader implements TodoReader { this.integrations = options.integrations; } - async readTodos({ url }: ReadTodosOptions): Promise { + async readTodos(options: ReadTodosOptions): Promise { + 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 { + const { url } = options; const tree = await this.reader.readTree(url, { etag, filter(filePath, info) { diff --git a/plugins/todo/api-report.md b/plugins/todo/api-report.md index e0fdb8ba58..0784f5d56e 100644 --- a/plugins/todo/api-report.md +++ b/plugins/todo/api-report.md @@ -26,13 +26,7 @@ export const todoApiRef: ApiRef; export class TodoClient implements TodoApi { constructor(options: TodoClientOptions); // (undocumented) - listTodos({ - entity, - offset, - limit, - orderBy, - filters, - }: TodoListOptions): Promise; + listTodos(options: TodoListOptions): Promise; } // @public diff --git a/plugins/todo/src/api/TodoClient.ts b/plugins/todo/src/api/TodoClient.ts index f75e4b6954..7e4e4c8f79 100644 --- a/plugins/todo/src/api/TodoClient.ts +++ b/plugins/todo/src/api/TodoClient.ts @@ -43,13 +43,8 @@ export class TodoClient implements TodoApi { this.identityApi = options.identityApi; } - async listTodos({ - entity, - offset, - limit, - orderBy, - filters, - }: TodoListOptions): Promise { + async listTodos(options: TodoListOptions): Promise { + const { entity, offset, limit, orderBy, filters } = options; const baseUrl = await this.discoveryApi.getBaseUrl('todo'); const token = await this.identityApi.getIdToken();