Merge pull request #8070 from backstage/jhaals/core-api-api-cleanup

core-app-api: Add missing exports and API annotations
This commit is contained in:
Johan Haals
2021-11-16 15:49:22 +01:00
committed by GitHub
15 changed files with 103 additions and 23 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/core-app-api': patch
---
Start exporting and marking several types as public to address errors in the API report.
+52 -16
View File
@@ -95,7 +95,6 @@ export class ApiFactoryRegistry implements ApiFactoryHolder {
| undefined;
// (undocumented)
getAllApis(): Set<AnyApiRef>;
// Warning: (ae-forgotten-export) The symbol "ApiFactoryScope" needs to be exported by the entry point index.d.ts
register<
Api,
Impl extends Api,
@@ -105,6 +104,9 @@ export class ApiFactoryRegistry implements ApiFactoryHolder {
>(scope: ApiFactoryScope, factory: ApiFactory<Api, Impl, Deps>): boolean;
}
// @public
export type ApiFactoryScope = 'default' | 'app' | 'static';
// @public
export const ApiProvider: {
(props: PropsWithChildren<ApiProviderProps>): JSX.Element;
@@ -118,6 +120,12 @@ export const ApiProvider: {
};
};
// @public
export type ApiProviderProps = {
apis: ApiHolder;
children: ReactNode;
};
// @public
export class ApiRegistry implements ApiHolder {
constructor(apis: Map<string, unknown>);
@@ -245,8 +253,6 @@ export class AppThemeSelector implements AppThemeApi {
// @public
export class AtlassianAuth {
// Warning: (ae-forgotten-export) The symbol "OAuthApiCreateOptions" needs to be exported by the entry point index.d.ts
//
// (undocumented)
static create({
discoveryApi,
@@ -268,6 +274,15 @@ export class Auth0Auth {
}: OAuthApiCreateOptions): typeof auth0AuthApiRef.T;
}
// @public
export type AuthApiCreateOptions = {
discoveryApi: DiscoveryApi;
environment?: string;
provider?: AuthProvider & {
id: string;
};
};
// @public
export type BackstageApp = {
getPlugins(): BackstagePlugin<any, any>[];
@@ -385,6 +400,8 @@ export type FlatRoutesProps = {
// @public
export class GithubAuth implements OAuthApi, SessionApi {
// Warning: (ae-forgotten-export) The symbol "SessionManager" needs to be exported by the entry point index.d.ts
//
// @deprecated
constructor(sessionManager: SessionManager<GithubSession>);
// (undocumented)
static create({
@@ -486,12 +503,11 @@ export class OAuth2
BackstageIdentityApi,
SessionApi
{
// @deprecated
constructor(options: {
sessionManager: SessionManager<OAuth2Session>;
scopeTransform: (scopes: string[]) => string[];
});
// Warning: (ae-forgotten-export) The symbol "CreateOptions" needs to be exported by the entry point index.d.ts
//
// (undocumented)
static create({
discoveryApi,
@@ -500,7 +516,7 @@ export class OAuth2
oauthRequestApi,
defaultScopes,
scopeTransform,
}: CreateOptions): OAuth2;
}: OAuth2CreateOptions): OAuth2;
// (undocumented)
getAccessToken(
scope?: string | string[],
@@ -522,6 +538,11 @@ export class OAuth2
signOut(): Promise<void>;
}
// @public
export type OAuth2CreateOptions = OAuthApiCreateOptions & {
scopeTransform?: (scopes: string[]) => string[];
};
// @public
export type OAuth2Session = {
providerInfo: {
@@ -534,6 +555,12 @@ export type OAuth2Session = {
backstageIdentity: BackstageIdentity;
};
// @public
export type OAuthApiCreateOptions = AuthApiCreateOptions & {
oauthRequestApi: OAuthRequestApi;
defaultScopes?: string[];
};
// @public
export class OAuthRequestManager implements OAuthRequestApi {
// (undocumented)
@@ -556,25 +583,31 @@ export class OktaAuth {
// @public
export class OneLoginAuth {
// Warning: (ae-forgotten-export) The symbol "CreateOptions" needs to be exported by the entry point index.d.ts
//
// (undocumented)
static create({
discoveryApi,
environment,
provider,
oauthRequestApi,
}: CreateOptions_2): typeof oneloginAuthApiRef.T;
}: OneLoginAuthCreateOptions): typeof oneloginAuthApiRef.T;
}
// @public
export type OneLoginAuthCreateOptions = {
discoveryApi: DiscoveryApi;
oauthRequestApi: OAuthRequestApi;
environment?: string;
provider?: AuthProvider & {
id: string;
};
};
// @public
export class SamlAuth
implements ProfileInfoApi, BackstageIdentityApi, SessionApi
{
// Warning: (ae-forgotten-export) The symbol "SamlSession" needs to be exported by the entry point index.d.ts
// @deprecated
constructor(sessionManager: SessionManager<SamlSession>);
// Warning: (ae-forgotten-export) The symbol "AuthApiCreateOptions" needs to be exported by the entry point index.d.ts
//
// (undocumented)
static create({
discoveryApi,
@@ -595,6 +628,13 @@ export class SamlAuth
signOut(): Promise<void>;
}
// @public
export type SamlSession = {
userId: string;
profile: ProfileInfo;
backstageIdentity: BackstageIdentity;
};
// @public
export type SignInPageProps = {
onResult(result: SignInResult): void;
@@ -639,8 +679,4 @@ export class WebStorage implements StorageApi {
// (undocumented)
set<T>(key: string, data: T): Promise<void>;
}
// Warnings were encountered during analysis:
//
// src/apis/system/ApiProvider.d.ts:15:5 - (ae-forgotten-export) The symbol "ApiProviderProps" needs to be exported by the entry point index.d.ts
```
@@ -21,7 +21,7 @@ describe('GithubAuth', () => {
const getSession = jest
.fn()
.mockResolvedValue({ providerInfo: { accessToken: 'access-token' } });
const githubAuth = new GithubAuth({ getSession } as any);
const githubAuth = new (GithubAuth as any)({ getSession }) as GithubAuth;
expect(await githubAuth.getAccessToken()).toBe('access-token');
expect(getSession).toBeCalledTimes(1);
@@ -116,6 +116,9 @@ export default class GithubAuth implements OAuthApi, SessionApi {
return new GithubAuth(sessionManagerMux);
}
/**
* @deprecated will be made private in the future. Use create method instead.
*/
constructor(private readonly sessionManager: SessionManager<GithubSession>) {}
async signIn() {
@@ -25,3 +25,4 @@ export * from './microsoft';
export * from './onelogin';
export * from './bitbucket';
export * from './atlassian';
export type { OAuthApiCreateOptions, AuthApiCreateOptions } from './types';
@@ -32,7 +32,11 @@ import { Observable } from '@backstage/types';
import { OAuth2Session } from './types';
import { OAuthApiCreateOptions } from '../types';
type CreateOptions = OAuthApiCreateOptions & {
/**
* OAuth2 create options.
* @public
*/
export type OAuth2CreateOptions = OAuthApiCreateOptions & {
scopeTransform?: (scopes: string[]) => string[];
};
@@ -73,7 +77,7 @@ export default class OAuth2
oauthRequestApi,
defaultScopes = [],
scopeTransform = x => x,
}: CreateOptions) {
}: OAuth2CreateOptions) {
const connector = new DefaultAuthConnector({
discoveryApi,
environment,
@@ -114,6 +118,9 @@ export default class OAuth2
private readonly sessionManager: SessionManager<OAuth2Session>;
private readonly scopeTransform: (scopes: string[]) => string[];
/**
* @deprecated will be made private in the future. Use create method instead.
*/
constructor(options: {
sessionManager: SessionManager<OAuth2Session>;
scopeTransform: (scopes: string[]) => string[];
@@ -16,6 +16,7 @@
import { ProfileInfo, BackstageIdentity } from '@backstage/core-plugin-api';
export type { OAuth2CreateOptions } from './OAuth2';
/**
* Session information for generic OAuth2 auth.
*
@@ -22,7 +22,11 @@ import {
} from '@backstage/core-plugin-api';
import { OAuth2 } from '../oauth2';
type CreateOptions = {
/**
* OneLogin auth provider create options.
* @public
*/
export type OneLoginAuthCreateOptions = {
discoveryApi: DiscoveryApi;
oauthRequestApi: OAuthRequestApi;
environment?: string;
@@ -58,7 +62,7 @@ export default class OneLoginAuth {
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
}: CreateOptions): typeof oneloginAuthApiRef.T {
}: OneLoginAuthCreateOptions): typeof oneloginAuthApiRef.T {
return OAuth2.create({
discoveryApi,
oauthRequestApi,
@@ -15,3 +15,4 @@
*/
export { default as OneLoginAuth } from './OneLoginAuth';
export type { OneLoginAuthCreateOptions } from './OneLoginAuth';
@@ -79,6 +79,9 @@ export default class SamlAuth
return this.sessionManager.sessionState$();
}
/**
* @deprecated will be made private in the future. Use create method instead.
*/
constructor(private readonly sessionManager: SessionManager<SamlSession>) {}
async signIn() {
@@ -14,3 +14,4 @@
* limitations under the License.
*/
export { default as SamlAuth } from './SamlAuth';
export type { SamlSession } from './types';
@@ -20,11 +20,19 @@ import {
OAuthRequestApi,
} from '@backstage/core-plugin-api';
/**
* Create options for OAuth APIs.
* @public
*/
export type OAuthApiCreateOptions = AuthApiCreateOptions & {
oauthRequestApi: OAuthRequestApi;
defaultScopes?: string[];
};
/**
* Generic create options for auth APIs.
* @public
*/
export type AuthApiCreateOptions = {
discoveryApi: DiscoveryApi;
environment?: string;
@@ -22,7 +22,11 @@ import {
AnyApiFactory,
} from '@backstage/core-plugin-api';
type ApiFactoryScope =
/**
* Scope type when registering API factories.
* @public
*/
export type ApiFactoryScope =
| 'default' // Default factories registered by core and plugins
| 'app' // Factories registered in the app, overriding default ones
| 'static'; // APIs that can't be overridden, e.g. config
@@ -23,7 +23,11 @@ import {
createVersionedContext,
} from '@backstage/version-bridge';
type ApiProviderProps = {
/**
* Prop types for the ApiProvider component.
* @public
*/
export type ApiProviderProps = {
apis: ApiHolder;
children: ReactNode;
};
@@ -15,7 +15,9 @@
*/
export { ApiProvider } from './ApiProvider';
export type { ApiProviderProps } from './ApiProvider';
export { ApiRegistry } from './ApiRegistry';
export { ApiResolver } from './ApiResolver';
export { ApiFactoryRegistry } from './ApiFactoryRegistry';
export type { ApiFactoryScope } from './ApiFactoryRegistry';
export * from './types';