diff --git a/.changeset/long-wolves-return.md b/.changeset/long-wolves-return.md
new file mode 100644
index 0000000000..8d4d78792f
--- /dev/null
+++ b/.changeset/long-wolves-return.md
@@ -0,0 +1,5 @@
+---
+'@backstage/frontend-app-api': patch
+---
+
+Bringing over apis from core-plugin-api
diff --git a/packages/frontend-app-api/api-report.md b/packages/frontend-app-api/api-report.md
index 3ca51f6331..5781891549 100644
--- a/packages/frontend-app-api/api-report.md
+++ b/packages/frontend-app-api/api-report.md
@@ -5,7 +5,7 @@
```ts
import { BackstagePlugin } from '@backstage/frontend-plugin-api';
import { Config } from '@backstage/config';
-import { ConfigApi } from '@backstage/core-plugin-api';
+import { ConfigApi } from '@backstage/frontend-plugin-api';
import { ExtensionDataRef } from '@backstage/frontend-plugin-api';
import { ExtensionOverrides } from '@backstage/frontend-plugin-api';
import { ExternalRouteRef } from '@backstage/frontend-plugin-api';
diff --git a/packages/frontend-plugin-api/api-report.md b/packages/frontend-plugin-api/api-report.md
index 794da9617b..08dec96eba 100644
--- a/packages/frontend-plugin-api/api-report.md
+++ b/packages/frontend-plugin-api/api-report.md
@@ -5,19 +5,54 @@
```ts
///
-import { AnyApiFactory } from '@backstage/core-plugin-api';
-import { AnyApiRef } from '@backstage/core-plugin-api';
-import { ApiRef } from '@backstage/core-plugin-api';
-import { AppTheme } from '@backstage/core-plugin-api';
-import { IconComponent } from '@backstage/core-plugin-api';
+import { AnyApiFactory as AnyApiFactory_2 } from '@backstage/core-plugin-api';
+import { AnyApiRef as AnyApiRef_2 } from '@backstage/core-plugin-api';
+import { ApiFactory as ApiFactory_2 } from '@backstage/core-plugin-api';
+import { ApiHolder as ApiHolder_2 } from '@backstage/core-plugin-api';
+import { ApiRef as ApiRef_2 } from '@backstage/core-plugin-api';
+import { AppTheme as AppTheme_2 } from '@backstage/core-plugin-api';
+import { ComponentType } from 'react';
+import { Config } from '@backstage/config';
+import { IconComponent as IconComponent_2 } from '@backstage/core-plugin-api';
import { JsonObject } from '@backstage/types';
+import { JsonValue } from '@backstage/types';
import { JSX as JSX_2 } from 'react';
+import { Observable } from '@backstage/types';
+import { PropsWithChildren } from 'react';
import { default as React_2 } from 'react';
import { ReactNode } from 'react';
import { z } from 'zod';
import { ZodSchema } from 'zod';
import { ZodTypeDef } from 'zod';
+// @public
+export type AlertApi = {
+ post(alert: AlertMessage): void;
+ alert$(): Observable;
+};
+
+// @public
+export const alertApiRef: ApiRef;
+
+// @public
+export type AlertMessage = {
+ message: string;
+ severity?: 'success' | 'info' | 'warning' | 'error';
+ display?: 'permanent' | 'transient';
+};
+
+// @public
+export type AnyApiFactory = ApiFactory<
+ unknown,
+ unknown,
+ {
+ [key in string]: unknown;
+ }
+>;
+
+// @public
+export type AnyApiRef = ApiRef;
+
// @public (undocumented)
export type AnyExtensionDataMap = {
[name in string]: ExtensionDataRef<
@@ -56,6 +91,96 @@ export type AnyRoutes = {
[name in string]: RouteRef;
};
+// @public
+export type ApiFactory<
+ Api,
+ Impl extends Api,
+ Deps extends {
+ [name in string]: unknown;
+ },
+> = {
+ api: ApiRef;
+ deps: TypesToApiRefs;
+ factory(deps: Deps): Impl;
+};
+
+// @public (undocumented)
+export type ApiFactoryHolder = {
+ get(api: ApiRef):
+ | ApiFactory<
+ T,
+ T,
+ {
+ [key in string]: unknown;
+ }
+ >
+ | undefined;
+};
+
+// @public
+export class ApiFactoryRegistry implements ApiFactoryHolder {
+ // (undocumented)
+ get(api: ApiRef_2):
+ | ApiFactory_2<
+ T,
+ T,
+ {
+ [x: string]: unknown;
+ }
+ >
+ | undefined;
+ // (undocumented)
+ getAllApis(): Set;
+ register<
+ Api,
+ Impl extends Api,
+ Deps extends {
+ [name in string]: unknown;
+ },
+ >(scope: ApiFactoryScope, factory: ApiFactory_2): boolean;
+}
+
+// @public
+export type ApiFactoryScope = 'default' | 'app' | 'static';
+
+// @public
+export type ApiHolder = {
+ get(api: ApiRef): T | undefined;
+};
+
+// @public
+export const ApiProvider: (
+ props: PropsWithChildren,
+) => React_2.JSX.Element;
+
+// @public
+export type ApiProviderProps = {
+ apis: ApiHolder_2;
+ children: ReactNode;
+};
+
+// @public
+export type ApiRef = {
+ id: string;
+ T: T;
+};
+
+// @public
+export type ApiRefConfig = {
+ id: string;
+};
+
+// @public
+export class ApiResolver implements ApiHolder_2 {
+ constructor(factories: ApiFactoryHolder);
+ // (undocumented)
+ get(ref: ApiRef_2): T | undefined;
+ static validateFactories(
+ factories: ApiFactoryHolder,
+ apis: Iterable,
+ ): void;
+}
+
// @public
export interface AppNode {
readonly edges: AppNodeEdges;
@@ -99,6 +224,26 @@ export interface AppNodeSpec {
readonly source?: BackstagePlugin;
}
+// @public
+export type AppTheme = {
+ id: string;
+ title: string;
+ variant: 'light' | 'dark';
+ icon?: React.ReactElement;
+ Provider(props: { children: ReactNode }): JSX.Element | null;
+};
+
+// @public
+export type AppThemeApi = {
+ getInstalledThemes(): AppTheme[];
+ activeThemeId$(): Observable;
+ getActiveThemeId(): string | undefined;
+ setActiveThemeId(themeId?: string): void;
+};
+
+// @public
+export const appThemeApiRef: ApiRef;
+
// @public
export interface AppTree {
readonly nodes: ReadonlyMap;
@@ -114,7 +259,39 @@ export interface AppTreeApi {
}
// @public
-export const appTreeApiRef: ApiRef;
+export const appTreeApiRef: ApiRef_2;
+
+// @public
+export const atlassianAuthApiRef: ApiRef<
+ OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi
+>;
+
+// @public
+export type AuthProviderInfo = {
+ id: string;
+ title: string;
+ icon: IconComponent;
+};
+
+// @public
+export type AuthRequestOptions = {
+ optional?: boolean;
+ instantPopup?: boolean;
+};
+
+// @public
+export type BackstageIdentityApi = {
+ getBackstageIdentity(
+ options?: AuthRequestOptions,
+ ): Promise;
+};
+
+// @public
+export type BackstageIdentityResponse = {
+ token: string;
+ expiresAt?: Date;
+ identity: BackstageUserIdentity;
+};
// @public (undocumented)
export interface BackstagePlugin<
@@ -133,6 +310,29 @@ export interface BackstagePlugin<
routes: Routes;
}
+// @public
+export type BackstageUserIdentity = {
+ type: 'user';
+ userEntityRef: string;
+ ownershipEntityRefs: string[];
+};
+
+// @public
+export const bitbucketAuthApiRef: ApiRef<
+ OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi
+>;
+
+// @public
+export const bitbucketServerAuthApiRef: ApiRef<
+ OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi
+>;
+
+// @public
+export type ConfigApi = Config;
+
+// @public
+export const configApiRef: ApiRef;
+
// @public (undocumented)
export interface ConfigurableExtensionDataRef<
TData,
@@ -153,10 +353,10 @@ export interface ConfigurableExtensionDataRef<
export const coreExtensionData: {
reactElement: ConfigurableExtensionDataRef;
routePath: ConfigurableExtensionDataRef;
- apiFactory: ConfigurableExtensionDataRef;
+ apiFactory: ConfigurableExtensionDataRef;
routeRef: ConfigurableExtensionDataRef, {}>;
navTarget: ConfigurableExtensionDataRef;
- theme: ConfigurableExtensionDataRef;
+ theme: ConfigurableExtensionDataRef;
};
// @public (undocumented)
@@ -166,14 +366,14 @@ export function createApiExtension<
>(
options: (
| {
- api: AnyApiRef;
+ api: AnyApiRef_2;
factory: (options: {
config: TConfig;
inputs: Expand>;
- }) => AnyApiFactory;
+ }) => AnyApiFactory_2;
}
| {
- factory: AnyApiFactory;
+ factory: AnyApiFactory_2;
}
) & {
configSchema?: PortableSchema;
@@ -181,6 +381,9 @@ export function createApiExtension<
},
): Extension;
+// @public
+export function createApiRef(config: ApiRefConfig): ApiRef;
+
// @public (undocumented)
export function createExtension<
TOutput extends AnyExtensionDataMap,
@@ -277,7 +480,7 @@ export function createNavItemExtension(options: {
id: string;
routeRef: RouteRef;
title: string;
- icon: IconComponent;
+ icon: IconComponent_2;
}): Extension<{
title: string;
}>;
@@ -355,7 +558,39 @@ export function createSubRouteRef<
}): MakeSubRouteRef, ParentParams>;
// @public (undocumented)
-export function createThemeExtension(theme: AppTheme): Extension;
+export function createThemeExtension(theme: AppTheme_2): Extension;
+
+// @public
+export type DiscoveryApi = {
+ getBaseUrl(pluginId: string): Promise;
+};
+
+// @public
+export const discoveryApiRef: ApiRef;
+
+// @public
+export type ErrorApi = {
+ post(error: ErrorApiError, context?: ErrorApiErrorContext): void;
+ error$(): Observable<{
+ error: ErrorApiError;
+ context?: ErrorApiErrorContext;
+ }>;
+};
+
+// @public
+export type ErrorApiError = {
+ name: string;
+ message: string;
+ stack?: string;
+};
+
+// @public
+export type ErrorApiErrorContext = {
+ hidden?: boolean;
+};
+
+// @public
+export const errorApiRef: ApiRef;
// @public (undocumented)
export interface Extension {
@@ -488,13 +723,169 @@ export interface ExternalRouteRef<
readonly T: TParams;
}
+// @public
+export type FeatureFlag = {
+ name: string;
+ pluginId: string;
+ description?: string;
+};
+
+// @public
+export interface FeatureFlagsApi {
+ getRegisteredFlags(): FeatureFlag[];
+ isActive(name: string): boolean;
+ registerFlag(flag: FeatureFlag): void;
+ save(options: FeatureFlagsSaveOptions): void;
+}
+
+// @public
+export const featureFlagsApiRef: ApiRef;
+
+// @public
+export type FeatureFlagsSaveOptions = {
+ states: Record;
+ merge?: boolean;
+};
+
+// @public
+export enum FeatureFlagState {
+ Active = 1,
+ None = 0,
+}
+
+// @public
+export type FetchApi = {
+ fetch: typeof fetch;
+};
+
+// @public
+export const fetchApiRef: ApiRef;
+
+// @public
+export const githubAuthApiRef: ApiRef<
+ OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi
+>;
+
+// @public
+export const gitlabAuthApiRef: ApiRef<
+ OAuthApi &
+ OpenIdConnectApi &
+ ProfileInfoApi &
+ BackstageIdentityApi &
+ SessionApi
+>;
+
+// @public
+export const googleAuthApiRef: ApiRef<
+ OAuthApi &
+ OpenIdConnectApi &
+ ProfileInfoApi &
+ BackstageIdentityApi &
+ SessionApi
+>;
+
+// @public
+export type IconComponent = ComponentType<
+ | {
+ fontSize?: 'large' | 'small' | 'default' | 'inherit';
+ }
+ | {
+ fontSize?: 'medium' | 'large' | 'small' | 'inherit';
+ }
+>;
+
+// @public
+export type IdentityApi = {
+ getProfileInfo(): Promise;
+ getBackstageIdentity(): Promise;
+ getCredentials(): Promise<{
+ token?: string;
+ }>;
+ signOut(): Promise;
+};
+
+// @public
+export const identityApiRef: ApiRef;
+
+// @public
+export const microsoftAuthApiRef: ApiRef<
+ OAuthApi &
+ OpenIdConnectApi &
+ ProfileInfoApi &
+ BackstageIdentityApi &
+ SessionApi
+>;
+
// @public (undocumented)
export type NavTarget = {
title: string;
- icon: IconComponent;
+ icon: IconComponent_2;
routeRef: RouteRef;
};
+// @public
+export type OAuthApi = {
+ getAccessToken(
+ scope?: OAuthScope,
+ options?: AuthRequestOptions,
+ ): Promise;
+};
+
+// @public
+export type OAuthRequestApi = {
+ createAuthRequester(
+ options: OAuthRequesterOptions,
+ ): OAuthRequester;
+ authRequest$(): Observable;
+};
+
+// @public
+export const oauthRequestApiRef: ApiRef;
+
+// @public
+export type OAuthRequester = (
+ scopes: Set,
+) => Promise;
+
+// @public
+export type OAuthRequesterOptions = {
+ provider: AuthProviderInfo;
+ onAuthRequest(scopes: Set): Promise;
+};
+
+// @public
+export type OAuthScope = string | string[];
+
+// @public
+export const oktaAuthApiRef: ApiRef<
+ OAuthApi &
+ OpenIdConnectApi &
+ ProfileInfoApi &
+ BackstageIdentityApi &
+ SessionApi
+>;
+
+// @public
+export const oneloginAuthApiRef: ApiRef<
+ OAuthApi &
+ OpenIdConnectApi &
+ ProfileInfoApi &
+ BackstageIdentityApi &
+ SessionApi
+>;
+
+// @public
+export type OpenIdConnectApi = {
+ getIdToken(options?: AuthRequestOptions): Promise;
+};
+
+// @public
+export type PendingOAuthRequest = {
+ provider: AuthProviderInfo;
+ reject(): void;
+ trigger(): Promise;
+};
+
// @public (undocumented)
export interface PluginOptions<
Routes extends AnyRoutes,
@@ -516,6 +907,18 @@ export type PortableSchema = {
schema: JsonObject;
};
+// @public
+export type ProfileInfo = {
+ email?: string;
+ displayName?: string;
+ picture?: string;
+};
+
+// @public
+export type ProfileInfoApi = {
+ getProfile(options?: AuthRequestOptions): Promise;
+};
+
// @public
export type RouteFunc = (
...[params]: TParams extends undefined
@@ -533,6 +936,46 @@ export interface RouteRef<
readonly T: TParams;
}
+// @public
+export type SessionApi = {
+ signIn(): Promise;
+ signOut(): Promise;
+ sessionState$(): Observable;
+};
+
+// @public
+export enum SessionState {
+ SignedIn = 'SignedIn',
+ SignedOut = 'SignedOut',
+}
+
+// @public
+export interface StorageApi {
+ forBucket(name: string): StorageApi;
+ observe$(
+ key: string,
+ ): Observable>;
+ remove(key: string): Promise;
+ set(key: string, data: T): Promise;
+ snapshot(key: string): StorageValueSnapshot;
+}
+
+// @public
+export const storageApiRef: ApiRef;
+
+// @public
+export type StorageValueSnapshot =
+ | {
+ key: string;
+ presence: 'unknown' | 'absent';
+ value?: undefined;
+ }
+ | {
+ key: string;
+ presence: 'present';
+ value: TValue;
+ };
+
// @public
export interface SubRouteRef<
TParams extends AnyRouteRefParams = AnyRouteRefParams,
@@ -545,6 +988,11 @@ export interface SubRouteRef<
readonly T: TParams;
}
+// @public
+export type TypesToApiRefs = {
+ [key in keyof T]: ApiRef;
+};
+
// @public
export function useRouteRef<
TOptional extends boolean,
diff --git a/packages/frontend-plugin-api/src/system/index.ts b/packages/frontend-plugin-api/src/system/index.ts
index 0650bff063..ec8984f00f 100644
--- a/packages/frontend-plugin-api/src/system/index.ts
+++ b/packages/frontend-plugin-api/src/system/index.ts
@@ -17,6 +17,8 @@
export { createApiRef } from './ApiRef';
export type { ApiRefConfig } from './ApiRef';
export { ApiFactoryRegistry } from './ApiFactoryRegistry';
+export type { ApiFactoryScope } from './ApiFactoryRegistry';
export { ApiProvider } from './ApiProvider';
+export type { ApiProviderProps } from './ApiProvider';
export { ApiResolver } from './ApiResolver';
export * from './types';