core-app-api: Add missing exports and API annotations
Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
@@ -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>);
|
||||
@@ -204,10 +212,6 @@ export type AppOptions = {
|
||||
bindRoutes?(context: { bind: AppRouteBinder }): void;
|
||||
};
|
||||
|
||||
// Warning: (ae-forgotten-export) The symbol "PartialKeys" needs to be exported by the entry point index.d.ts
|
||||
// Warning: (ae-forgotten-export) The symbol "TargetRouteMap" needs to be exported by the entry point index.d.ts
|
||||
// Warning: (ae-forgotten-export) The symbol "KeysWithType" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// @public
|
||||
export type AppRouteBinder = <
|
||||
ExternalRoutes extends {
|
||||
@@ -238,8 +242,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,
|
||||
@@ -261,6 +263,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>[];
|
||||
@@ -378,6 +389,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({
|
||||
@@ -440,6 +453,16 @@ export class GoogleAuth {
|
||||
}: OAuthApiCreateOptions): typeof googleAuthApiRef.T;
|
||||
}
|
||||
|
||||
// @public
|
||||
export type KeysWithType<
|
||||
Obj extends {
|
||||
[key in string]: any;
|
||||
},
|
||||
Type,
|
||||
> = {
|
||||
[key in keyof Obj]: Obj[key] extends Type ? key : never;
|
||||
}[keyof Obj];
|
||||
|
||||
// @public
|
||||
export class LocalStorageFeatureFlags implements FeatureFlagsApi {
|
||||
// (undocumented)
|
||||
@@ -479,12 +502,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,
|
||||
@@ -493,7 +515,7 @@ export class OAuth2
|
||||
oauthRequestApi,
|
||||
defaultScopes,
|
||||
scopeTransform,
|
||||
}: CreateOptions): OAuth2;
|
||||
}: OAuth2CreateOptions): OAuth2;
|
||||
// (undocumented)
|
||||
getAccessToken(
|
||||
scope?: string | string[],
|
||||
@@ -515,6 +537,11 @@ export class OAuth2
|
||||
signOut(): Promise<void>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export type OAuth2CreateOptions = OAuthApiCreateOptions & {
|
||||
scopeTransform?: (scopes: string[]) => string[];
|
||||
};
|
||||
|
||||
// @public
|
||||
export type OAuth2Session = {
|
||||
providerInfo: {
|
||||
@@ -527,6 +554,12 @@ export type OAuth2Session = {
|
||||
backstageIdentity: BackstageIdentity;
|
||||
};
|
||||
|
||||
// @public
|
||||
export type OAuthApiCreateOptions = AuthApiCreateOptions & {
|
||||
oauthRequestApi: OAuthRequestApi;
|
||||
defaultScopes?: string[];
|
||||
};
|
||||
|
||||
// @public
|
||||
export class OAuthRequestManager implements OAuthRequestApi {
|
||||
// (undocumented)
|
||||
@@ -549,25 +582,39 @@ 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 type PartialKeys<
|
||||
Map extends {
|
||||
[name in string]: any;
|
||||
},
|
||||
Keys extends keyof Map,
|
||||
> = Partial<Pick<Map, Keys>> & Required<Omit<Map, Keys>>;
|
||||
|
||||
// @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,
|
||||
@@ -588,6 +635,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;
|
||||
@@ -601,6 +655,20 @@ export type SignInResult = {
|
||||
signOut?: () => Promise<void>;
|
||||
};
|
||||
|
||||
// @public
|
||||
export type TargetRouteMap<
|
||||
ExternalRoutes extends {
|
||||
[name: string]: ExternalRouteRef;
|
||||
},
|
||||
> = {
|
||||
[name in keyof ExternalRoutes]: ExternalRoutes[name] extends ExternalRouteRef<
|
||||
infer Params,
|
||||
any
|
||||
>
|
||||
? RouteRef<Params> | SubRouteRef<Params>
|
||||
: never;
|
||||
};
|
||||
|
||||
// @public
|
||||
export class UnhandledErrorForwarder {
|
||||
static forward(errorApi: ErrorApi, errorContext: ErrorApiErrorContext): void;
|
||||
@@ -632,8 +700,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';
|
||||
|
||||
@@ -152,23 +152,26 @@ export type AppConfigLoader = () => Promise<AppConfig[]>;
|
||||
|
||||
/**
|
||||
* Extracts a union of the keys in a map whose value extends the given type
|
||||
* @public
|
||||
*/
|
||||
type KeysWithType<Obj extends { [key in string]: any }, Type> = {
|
||||
export type KeysWithType<Obj extends { [key in string]: any }, Type> = {
|
||||
[key in keyof Obj]: Obj[key] extends Type ? key : never;
|
||||
}[keyof Obj];
|
||||
|
||||
/**
|
||||
* Takes a map Map required values and makes all keys matching Keys optional
|
||||
* @public
|
||||
*/
|
||||
type PartialKeys<
|
||||
export type PartialKeys<
|
||||
Map extends { [name in string]: any },
|
||||
Keys extends keyof Map,
|
||||
> = Partial<Pick<Map, Keys>> & Required<Omit<Map, Keys>>;
|
||||
|
||||
/**
|
||||
* Creates a map of target routes with matching parameters based on a map of external routes.
|
||||
* @public
|
||||
*/
|
||||
type TargetRouteMap<
|
||||
export type TargetRouteMap<
|
||||
ExternalRoutes extends { [name: string]: ExternalRouteRef },
|
||||
> = {
|
||||
[name in keyof ExternalRoutes]: ExternalRoutes[name] extends ExternalRouteRef<
|
||||
|
||||
Reference in New Issue
Block a user