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/src/routing/extractRouteInfoFromAppNode.ts b/packages/frontend-app-api/src/routing/extractRouteInfoFromAppNode.ts index 43955328a8..2bfd09a3e8 100644 --- a/packages/frontend-app-api/src/routing/extractRouteInfoFromAppNode.ts +++ b/packages/frontend-app-api/src/routing/extractRouteInfoFromAppNode.ts @@ -15,10 +15,9 @@ */ import { RouteRef, coreExtensionData } from '@backstage/frontend-plugin-api'; -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { toLegacyPlugin } from '../wiring/createApp'; import { BackstageRouteObject } from './types'; import { AppNode } from '@backstage/frontend-plugin-api'; +import { toLegacyPlugin } from './toLegacyPlugin'; // We always add a child that matches all subroutes but without any route refs. This makes // sure that we're always able to match each route no matter how deep the navigation goes. diff --git a/packages/frontend-app-api/src/routing/toLegacyPlugin.ts b/packages/frontend-app-api/src/routing/toLegacyPlugin.ts new file mode 100644 index 0000000000..2d04d04dda --- /dev/null +++ b/packages/frontend-app-api/src/routing/toLegacyPlugin.ts @@ -0,0 +1,55 @@ +/* + * Copyright 2023 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { BackstagePlugin } from '@backstage/frontend-plugin-api'; +import { BackstagePlugin as LegacyBackstagePlugin } from '@backstage/core-plugin-api'; +import { getOrCreateGlobalSingleton } from '@backstage/version-bridge'; + +// Make sure that we only convert each new plugin instance to its legacy equivalent once +const legacyPluginStore = getOrCreateGlobalSingleton( + 'legacy-plugin-compatibility-store', + () => new WeakMap(), +); + +export function toLegacyPlugin(plugin: BackstagePlugin): LegacyBackstagePlugin { + let legacy = legacyPluginStore.get(plugin); + if (legacy) { + return legacy; + } + + const errorMsg = 'Not implemented in legacy plugin compatibility layer'; + const notImplemented = () => { + throw new Error(errorMsg); + }; + + legacy = { + getId(): string { + return plugin.id; + }, + get routes() { + return {}; + }, + get externalRoutes() { + return {}; + }, + getApis: notImplemented, + getFeatureFlags: notImplemented, + provide: notImplemented, + }; + + legacyPluginStore.set(plugin, legacy); + return legacy; +} diff --git a/packages/frontend-app-api/src/wiring/createApp.tsx b/packages/frontend-app-api/src/wiring/createApp.tsx index 8495f961db..d39111eb99 100644 --- a/packages/frontend-app-api/src/wiring/createApp.tsx +++ b/packages/frontend-app-api/src/wiring/createApp.tsx @@ -80,7 +80,6 @@ import { BrowserRouter, Route } from 'react-router-dom'; import { SidebarItem } from '@backstage/core-components'; import { DarkTheme, LightTheme } from '../extensions/themes'; import { extractRouteInfoFromAppNode } from '../routing/extractRouteInfoFromAppNode'; -import { getOrCreateGlobalSingleton } from '@backstage/version-bridge'; import { appLanguageApiRef, translationApiRef, @@ -91,6 +90,7 @@ import { resolveRouteBindings } from '../routing/resolveRouteBindings'; import { collectRouteIds } from '../routing/collectRouteIds'; import { createAppTree } from '../tree'; import { AppNode } from '@backstage/frontend-plugin-api'; +import { toLegacyPlugin } from '../routing/toLegacyPlugin'; const builtinExtensions = [ Core, @@ -328,42 +328,6 @@ export function createSpecializedApp(options?: { }; } -// Make sure that we only convert each new plugin instance to its legacy equivalent once -const legacyPluginStore = getOrCreateGlobalSingleton( - 'legacy-plugin-compatibility-store', - () => new WeakMap(), -); - -export function toLegacyPlugin(plugin: BackstagePlugin): LegacyBackstagePlugin { - let legacy = legacyPluginStore.get(plugin); - if (legacy) { - return legacy; - } - - const errorMsg = 'Not implemented in legacy plugin compatibility layer'; - const notImplemented = () => { - throw new Error(errorMsg); - }; - - legacy = { - getId(): string { - return plugin.id; - }, - get routes() { - return {}; - }, - get externalRoutes() { - return {}; - }, - getApis: notImplemented, - getFeatureFlags: notImplemented, - provide: notImplemented, - }; - - legacyPluginStore.set(plugin, legacy); - return legacy; -} - function createLegacyAppContext(plugins: BackstagePlugin[]): AppContext { return { getPlugins(): LegacyBackstagePlugin[] { diff --git a/packages/frontend-plugin-api/api-report.md b/packages/frontend-plugin-api/api-report.md index 794da9617b..f1537fd5b7 100644 --- a/packages/frontend-plugin-api/api-report.md +++ b/packages/frontend-plugin-api/api-report.md @@ -5,19 +5,90 @@ ```ts /// +import { AlertApi } from '@backstage/core-plugin-api'; +import { alertApiRef } from '@backstage/core-plugin-api'; +import { AlertMessage } from '@backstage/core-plugin-api'; import { AnyApiFactory } from '@backstage/core-plugin-api'; import { AnyApiRef } from '@backstage/core-plugin-api'; +import { ApiFactory } from '@backstage/core-plugin-api'; +import { ApiHolder } from '@backstage/core-plugin-api'; import { ApiRef } from '@backstage/core-plugin-api'; +import { ApiRefConfig } from '@backstage/core-plugin-api'; import { AppTheme } from '@backstage/core-plugin-api'; -import { IconComponent } from '@backstage/core-plugin-api'; +import { AppThemeApi } from '@backstage/core-plugin-api'; +import { appThemeApiRef } from '@backstage/core-plugin-api'; +import { atlassianAuthApiRef } from '@backstage/core-plugin-api'; +import { AuthProviderInfo } from '@backstage/core-plugin-api'; +import { AuthRequestOptions } from '@backstage/core-plugin-api'; +import { BackstageIdentityApi } from '@backstage/core-plugin-api'; +import { BackstageIdentityResponse } from '@backstage/core-plugin-api'; +import { BackstageUserIdentity } from '@backstage/core-plugin-api'; +import { bitbucketAuthApiRef } from '@backstage/core-plugin-api'; +import { bitbucketServerAuthApiRef } from '@backstage/core-plugin-api'; +import { ComponentType } from 'react'; +import { ConfigApi } from '@backstage/core-plugin-api'; +import { configApiRef } from '@backstage/core-plugin-api'; +import { createApiFactory } from '@backstage/core-plugin-api'; +import { createApiRef } from '@backstage/core-plugin-api'; +import { DiscoveryApi } from '@backstage/core-plugin-api'; +import { discoveryApiRef } from '@backstage/core-plugin-api'; +import { ErrorApi } from '@backstage/core-plugin-api'; +import { ErrorApiError } from '@backstage/core-plugin-api'; +import { ErrorApiErrorContext } from '@backstage/core-plugin-api'; +import { errorApiRef } from '@backstage/core-plugin-api'; +import { FeatureFlag } from '@backstage/core-plugin-api'; +import { FeatureFlagsApi } from '@backstage/core-plugin-api'; +import { featureFlagsApiRef } from '@backstage/core-plugin-api'; +import { FeatureFlagsSaveOptions } from '@backstage/core-plugin-api'; +import { FeatureFlagState } from '@backstage/core-plugin-api'; +import { FetchApi } from '@backstage/core-plugin-api'; +import { fetchApiRef } from '@backstage/core-plugin-api'; +import { githubAuthApiRef } from '@backstage/core-plugin-api'; +import { gitlabAuthApiRef } from '@backstage/core-plugin-api'; +import { googleAuthApiRef } from '@backstage/core-plugin-api'; +import { IconComponent as IconComponent_2 } from '@backstage/core-plugin-api'; +import { IdentityApi } from '@backstage/core-plugin-api'; +import { identityApiRef } from '@backstage/core-plugin-api'; import { JsonObject } from '@backstage/types'; import { JSX as JSX_2 } from 'react'; +import { microsoftAuthApiRef } from '@backstage/core-plugin-api'; +import { OAuthApi } from '@backstage/core-plugin-api'; +import { OAuthRequestApi } from '@backstage/core-plugin-api'; +import { oauthRequestApiRef } from '@backstage/core-plugin-api'; +import { OAuthRequester } from '@backstage/core-plugin-api'; +import { OAuthRequesterOptions } from '@backstage/core-plugin-api'; +import { OAuthScope } from '@backstage/core-plugin-api'; +import { oktaAuthApiRef } from '@backstage/core-plugin-api'; +import { oneloginAuthApiRef } from '@backstage/core-plugin-api'; +import { OpenIdConnectApi } from '@backstage/core-plugin-api'; +import { PendingOAuthRequest } from '@backstage/core-plugin-api'; +import { ProfileInfo } from '@backstage/core-plugin-api'; +import { ProfileInfoApi } from '@backstage/core-plugin-api'; import { default as React_2 } from 'react'; import { ReactNode } from 'react'; +import { SessionApi } from '@backstage/core-plugin-api'; +import { SessionState } from '@backstage/core-plugin-api'; +import { StorageApi } from '@backstage/core-plugin-api'; +import { storageApiRef } from '@backstage/core-plugin-api'; +import { StorageValueSnapshot } from '@backstage/core-plugin-api'; +import { TypesToApiRefs } from '@backstage/core-plugin-api'; +import { useApi } from '@backstage/core-plugin-api'; +import { useApiHolder } from '@backstage/core-plugin-api'; +import { withApis } from '@backstage/core-plugin-api'; import { z } from 'zod'; import { ZodSchema } from 'zod'; import { ZodTypeDef } from 'zod'; +export { AlertApi }; + +export { alertApiRef }; + +export { AlertMessage }; + +export { AnyApiFactory }; + +export { AnyApiRef }; + // @public (undocumented) export type AnyExtensionDataMap = { [name in string]: ExtensionDataRef< @@ -56,6 +127,14 @@ export type AnyRoutes = { [name in string]: RouteRef; }; +export { ApiFactory }; + +export { ApiHolder }; + +export { ApiRef }; + +export { ApiRefConfig }; + // @public export interface AppNode { readonly edges: AppNodeEdges; @@ -99,6 +178,12 @@ export interface AppNodeSpec { readonly source?: BackstagePlugin; } +export { AppTheme }; + +export { AppThemeApi }; + +export { appThemeApiRef }; + // @public export interface AppTree { readonly nodes: ReadonlyMap; @@ -116,6 +201,16 @@ export interface AppTreeApi { // @public export const appTreeApiRef: ApiRef; +export { atlassianAuthApiRef }; + +export { AuthProviderInfo }; + +export { AuthRequestOptions }; + +export { BackstageIdentityApi }; + +export { BackstageIdentityResponse }; + // @public (undocumented) export interface BackstagePlugin< Routes extends AnyRoutes = AnyRoutes, @@ -133,6 +228,16 @@ export interface BackstagePlugin< routes: Routes; } +export { BackstageUserIdentity }; + +export { bitbucketAuthApiRef }; + +export { bitbucketServerAuthApiRef }; + +export { ConfigApi }; + +export { configApiRef }; + // @public (undocumented) export interface ConfigurableExtensionDataRef< TData, @@ -181,6 +286,10 @@ export function createApiExtension< }, ): Extension; +export { createApiFactory }; + +export { createApiRef }; + // @public (undocumented) export function createExtension< TOutput extends AnyExtensionDataMap, @@ -277,7 +386,7 @@ export function createNavItemExtension(options: { id: string; routeRef: RouteRef; title: string; - icon: IconComponent; + icon: IconComponent_2; }): Extension<{ title: string; }>; @@ -357,6 +466,18 @@ export function createSubRouteRef< // @public (undocumented) export function createThemeExtension(theme: AppTheme): Extension; +export { DiscoveryApi }; + +export { discoveryApiRef }; + +export { ErrorApi }; + +export { ErrorApiError }; + +export { ErrorApiErrorContext }; + +export { errorApiRef }; + // @public (undocumented) export interface Extension { // (undocumented) @@ -488,13 +609,69 @@ export interface ExternalRouteRef< readonly T: TParams; } +export { FeatureFlag }; + +export { FeatureFlagsApi }; + +export { featureFlagsApiRef }; + +export { FeatureFlagsSaveOptions }; + +export { FeatureFlagState }; + +export { FetchApi }; + +export { fetchApiRef }; + +export { githubAuthApiRef }; + +export { gitlabAuthApiRef }; + +export { googleAuthApiRef }; + +// @public +export type IconComponent = ComponentType< + | { + fontSize?: 'large' | 'small' | 'default' | 'inherit'; + } + | { + fontSize?: 'medium' | 'large' | 'small' | 'inherit'; + } +>; + +export { IdentityApi }; + +export { identityApiRef }; + +export { microsoftAuthApiRef }; + // @public (undocumented) export type NavTarget = { title: string; - icon: IconComponent; + icon: IconComponent_2; routeRef: RouteRef; }; +export { OAuthApi }; + +export { OAuthRequestApi }; + +export { oauthRequestApiRef }; + +export { OAuthRequester }; + +export { OAuthRequesterOptions }; + +export { OAuthScope }; + +export { oktaAuthApiRef }; + +export { oneloginAuthApiRef }; + +export { OpenIdConnectApi }; + +export { PendingOAuthRequest }; + // @public (undocumented) export interface PluginOptions< Routes extends AnyRoutes, @@ -516,6 +693,10 @@ export type PortableSchema = { schema: JsonObject; }; +export { ProfileInfo }; + +export { ProfileInfoApi }; + // @public export type RouteFunc = ( ...[params]: TParams extends undefined @@ -533,6 +714,16 @@ export interface RouteRef< readonly T: TParams; } +export { SessionApi }; + +export { SessionState }; + +export { StorageApi }; + +export { storageApiRef }; + +export { StorageValueSnapshot }; + // @public export interface SubRouteRef< TParams extends AnyRouteRefParams = AnyRouteRefParams, @@ -545,6 +736,12 @@ export interface SubRouteRef< readonly T: TParams; } +export { TypesToApiRefs }; + +export { useApi }; + +export { useApiHolder }; + // @public export function useRouteRef< TOptional extends boolean, @@ -562,4 +759,6 @@ export function useRouteRef( export function useRouteRefParams( _routeRef: RouteRef | SubRouteRef, ): Params; + +export { withApis }; ``` diff --git a/packages/frontend-plugin-api/package.json b/packages/frontend-plugin-api/package.json index 2a1d741d3d..d7d19e3d74 100644 --- a/packages/frontend-plugin-api/package.json +++ b/packages/frontend-plugin-api/package.json @@ -39,6 +39,7 @@ "react-router-dom": "6.0.0-beta.0 || ^6.3.0" }, "dependencies": { + "@backstage/config": "workspace:^", "@backstage/core-components": "workspace:^", "@backstage/core-plugin-api": "workspace:^", "@backstage/types": "workspace:^", diff --git a/packages/frontend-plugin-api/src/apis/definitions/AlertApi.ts b/packages/frontend-plugin-api/src/apis/definitions/AlertApi.ts new file mode 100644 index 0000000000..649a930b50 --- /dev/null +++ b/packages/frontend-plugin-api/src/apis/definitions/AlertApi.ts @@ -0,0 +1,21 @@ +/* + * Copyright 2020 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { + type AlertApi, + type AlertMessage, + alertApiRef, +} from '@backstage/core-plugin-api'; diff --git a/packages/frontend-plugin-api/src/apis/definitions/AppLanguageApi.ts b/packages/frontend-plugin-api/src/apis/definitions/AppLanguageApi.ts new file mode 100644 index 0000000000..37ffcfa820 --- /dev/null +++ b/packages/frontend-plugin-api/src/apis/definitions/AppLanguageApi.ts @@ -0,0 +1,20 @@ +/* + * Copyright 2023 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { + type AppLanguageApi, + appLanguageApiRef, +} from '@backstage/core-plugin-api/alpha'; diff --git a/packages/frontend-plugin-api/src/apis/definitions/AppThemeApi.ts b/packages/frontend-plugin-api/src/apis/definitions/AppThemeApi.ts new file mode 100644 index 0000000000..ce62cd72c3 --- /dev/null +++ b/packages/frontend-plugin-api/src/apis/definitions/AppThemeApi.ts @@ -0,0 +1,21 @@ +/* + * Copyright 2020 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { + type AppTheme, + type AppThemeApi, + appThemeApiRef, +} from '@backstage/core-plugin-api'; diff --git a/packages/frontend-plugin-api/src/apis/definitions/ConfigApi.ts b/packages/frontend-plugin-api/src/apis/definitions/ConfigApi.ts new file mode 100644 index 0000000000..968a2843ba --- /dev/null +++ b/packages/frontend-plugin-api/src/apis/definitions/ConfigApi.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2020 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { type ConfigApi, configApiRef } from '@backstage/core-plugin-api'; diff --git a/packages/frontend-plugin-api/src/apis/definitions/DiscoveryApi.ts b/packages/frontend-plugin-api/src/apis/definitions/DiscoveryApi.ts new file mode 100644 index 0000000000..98b3f0bbf0 --- /dev/null +++ b/packages/frontend-plugin-api/src/apis/definitions/DiscoveryApi.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2020 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { type DiscoveryApi, discoveryApiRef } from '@backstage/core-plugin-api'; diff --git a/packages/frontend-plugin-api/src/apis/definitions/ErrorApi.ts b/packages/frontend-plugin-api/src/apis/definitions/ErrorApi.ts new file mode 100644 index 0000000000..57782a05dc --- /dev/null +++ b/packages/frontend-plugin-api/src/apis/definitions/ErrorApi.ts @@ -0,0 +1,22 @@ +/* + * Copyright 2020 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { + type ErrorApiError, + type ErrorApiErrorContext, + type ErrorApi, + errorApiRef, +} from '@backstage/core-plugin-api'; diff --git a/packages/frontend-plugin-api/src/apis/definitions/FeatureFlagsApi.ts b/packages/frontend-plugin-api/src/apis/definitions/FeatureFlagsApi.ts new file mode 100644 index 0000000000..820efc0a25 --- /dev/null +++ b/packages/frontend-plugin-api/src/apis/definitions/FeatureFlagsApi.ts @@ -0,0 +1,23 @@ +/* + * Copyright 2020 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { + type FeatureFlag, + type FeatureFlagState, + type FeatureFlagsSaveOptions, + type FeatureFlagsApi, + featureFlagsApiRef, +} from '@backstage/core-plugin-api'; diff --git a/packages/frontend-plugin-api/src/apis/definitions/FetchApi.ts b/packages/frontend-plugin-api/src/apis/definitions/FetchApi.ts new file mode 100644 index 0000000000..bcc9bc6a91 --- /dev/null +++ b/packages/frontend-plugin-api/src/apis/definitions/FetchApi.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2021 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { type FetchApi, fetchApiRef } from '@backstage/core-plugin-api'; diff --git a/packages/frontend-plugin-api/src/apis/definitions/IdentityApi.ts b/packages/frontend-plugin-api/src/apis/definitions/IdentityApi.ts new file mode 100644 index 0000000000..03503a8fba --- /dev/null +++ b/packages/frontend-plugin-api/src/apis/definitions/IdentityApi.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2020 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { type IdentityApi, identityApiRef } from '@backstage/core-plugin-api'; diff --git a/packages/frontend-plugin-api/src/apis/definitions/OAuthRequestApi.ts b/packages/frontend-plugin-api/src/apis/definitions/OAuthRequestApi.ts new file mode 100644 index 0000000000..ff7a0f2852 --- /dev/null +++ b/packages/frontend-plugin-api/src/apis/definitions/OAuthRequestApi.ts @@ -0,0 +1,23 @@ +/* + * Copyright 2020 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { + type OAuthRequesterOptions, + type OAuthRequester, + type PendingOAuthRequest, + type OAuthRequestApi, + oauthRequestApiRef, +} from '@backstage/core-plugin-api'; diff --git a/packages/frontend-plugin-api/src/apis/definitions/StorageApi.ts b/packages/frontend-plugin-api/src/apis/definitions/StorageApi.ts new file mode 100644 index 0000000000..2309d2414c --- /dev/null +++ b/packages/frontend-plugin-api/src/apis/definitions/StorageApi.ts @@ -0,0 +1,21 @@ +/* + * Copyright 2020 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { + type StorageValueSnapshot, + type StorageApi, + storageApiRef, +} from '@backstage/core-plugin-api'; diff --git a/packages/frontend-plugin-api/src/apis/definitions/alpha.ts b/packages/frontend-plugin-api/src/apis/definitions/alpha.ts new file mode 100644 index 0000000000..a4ccde1170 --- /dev/null +++ b/packages/frontend-plugin-api/src/apis/definitions/alpha.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2023 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { appLanguageApiRef, type AppLanguageApi } from './AppLanguageApi'; diff --git a/packages/frontend-plugin-api/src/apis/definitions/auth.ts b/packages/frontend-plugin-api/src/apis/definitions/auth.ts new file mode 100644 index 0000000000..d27aebbf47 --- /dev/null +++ b/packages/frontend-plugin-api/src/apis/definitions/auth.ts @@ -0,0 +1,39 @@ +/* + * Copyright 2020 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { + type BackstageIdentityApi, + type BackstageIdentityResponse, + type BackstageUserIdentity, + type AuthProviderInfo, + type AuthRequestOptions, + type OAuthScope, + type OAuthApi, + type OpenIdConnectApi, + type ProfileInfoApi, + type ProfileInfo, + type SessionApi, + SessionState, + atlassianAuthApiRef, + bitbucketAuthApiRef, + bitbucketServerAuthApiRef, + githubAuthApiRef, + gitlabAuthApiRef, + googleAuthApiRef, + oktaAuthApiRef, + microsoftAuthApiRef, + oneloginAuthApiRef, +} from '@backstage/core-plugin-api'; diff --git a/packages/frontend-plugin-api/src/apis/definitions/index.ts b/packages/frontend-plugin-api/src/apis/definitions/index.ts index 8facdca2ca..420942cb19 100644 --- a/packages/frontend-plugin-api/src/apis/definitions/index.ts +++ b/packages/frontend-plugin-api/src/apis/definitions/index.ts @@ -23,3 +23,22 @@ export { type AppTree, type AppTreeApi, } from './AppTreeApi'; + +// This folder contains definitions for all core APIs. +// +// Plugins should rely on these APIs for functionality as much as possible. +// +// If you think some API definition is missing, please open an Issue or send a PR! + +export * from './auth'; + +export * from './AlertApi'; +export * from './AppThemeApi'; +export * from './ConfigApi'; +export * from './DiscoveryApi'; +export * from './ErrorApi'; +export * from './FeatureFlagsApi'; +export * from './FetchApi'; +export * from './IdentityApi'; +export * from './OAuthRequestApi'; +export * from './StorageApi'; diff --git a/packages/frontend-plugin-api/src/apis/index.ts b/packages/frontend-plugin-api/src/apis/index.ts index 5a012c0553..5def6cb0f9 100644 --- a/packages/frontend-plugin-api/src/apis/index.ts +++ b/packages/frontend-plugin-api/src/apis/index.ts @@ -15,3 +15,4 @@ */ export * from './definitions'; +export * from './system'; diff --git a/packages/frontend-plugin-api/src/apis/system/ApiRef.ts b/packages/frontend-plugin-api/src/apis/system/ApiRef.ts new file mode 100644 index 0000000000..0d1f8312cb --- /dev/null +++ b/packages/frontend-plugin-api/src/apis/system/ApiRef.ts @@ -0,0 +1,21 @@ +/* + * Copyright 2020 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { + type ApiRef, + type ApiRefConfig, + createApiRef, +} from '@backstage/core-plugin-api'; diff --git a/packages/frontend-plugin-api/src/apis/system/helpers.ts b/packages/frontend-plugin-api/src/apis/system/helpers.ts new file mode 100644 index 0000000000..5de265be99 --- /dev/null +++ b/packages/frontend-plugin-api/src/apis/system/helpers.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2023 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { createApiFactory } from '@backstage/core-plugin-api'; diff --git a/packages/frontend-plugin-api/src/apis/system/index.ts b/packages/frontend-plugin-api/src/apis/system/index.ts new file mode 100644 index 0000000000..b1bd3ac2b3 --- /dev/null +++ b/packages/frontend-plugin-api/src/apis/system/index.ts @@ -0,0 +1,21 @@ +/* + * Copyright 2023 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { useApi, useApiHolder, withApis } from './useApi'; +export { createApiRef } from './ApiRef'; +export type { ApiRefConfig } from './ApiRef'; +export * from './types'; +export * from './helpers'; diff --git a/packages/frontend-plugin-api/src/apis/system/types.ts b/packages/frontend-plugin-api/src/apis/system/types.ts new file mode 100644 index 0000000000..cc44e19e3f --- /dev/null +++ b/packages/frontend-plugin-api/src/apis/system/types.ts @@ -0,0 +1,24 @@ +/* + * Copyright 2023 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export type { + ApiRef, + AnyApiRef, + TypesToApiRefs, + ApiHolder, + ApiFactory, + AnyApiFactory, +} from '@backstage/core-plugin-api'; diff --git a/packages/frontend-plugin-api/src/apis/system/useApi.tsx b/packages/frontend-plugin-api/src/apis/system/useApi.tsx new file mode 100644 index 0000000000..d2efa49fa1 --- /dev/null +++ b/packages/frontend-plugin-api/src/apis/system/useApi.tsx @@ -0,0 +1,17 @@ +/* + * Copyright 2023 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { useApiHolder, useApi, withApis } from '@backstage/core-plugin-api'; diff --git a/packages/frontend-plugin-api/src/icons/index.ts b/packages/frontend-plugin-api/src/icons/index.ts new file mode 100644 index 0000000000..9c9e45e54c --- /dev/null +++ b/packages/frontend-plugin-api/src/icons/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2020 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export type { IconComponent } from './types'; diff --git a/packages/frontend-plugin-api/src/icons/types.ts b/packages/frontend-plugin-api/src/icons/types.ts new file mode 100644 index 0000000000..4d54629de2 --- /dev/null +++ b/packages/frontend-plugin-api/src/icons/types.ts @@ -0,0 +1,45 @@ +/* + * Copyright 2020 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ComponentType } from 'react'; + +/** + * IconComponent is the common icon type used throughout Backstage when + * working with and rendering generic icons, including the app system icons. + * + * @remarks + * + * The type is based on SvgIcon from Material UI, but both do not what the plugin-api + * package to have a dependency on Material UI, nor do we want the props to be as broad + * as the SvgIconProps interface. + * + * If you have the need to forward additional props from SvgIconProps, you can + * open an issue or submit a PR to the main Backstage repo. When doing so please + * also describe your use-case and reasoning of the addition. + * + * @public + */ + +export type IconComponent = ComponentType< + /* Material UI v4 */ + | { + fontSize?: 'large' | 'small' | 'default' | 'inherit'; + } + /* Material UI v5: https://mui.com/material-ui/migration/v5-component-changes/#icon */ + | { + fontSize?: 'medium' | 'large' | 'small' | 'inherit'; + } +>; diff --git a/packages/frontend-plugin-api/src/index.ts b/packages/frontend-plugin-api/src/index.ts index 498bc96a77..3248e79945 100644 --- a/packages/frontend-plugin-api/src/index.ts +++ b/packages/frontend-plugin-api/src/index.ts @@ -23,6 +23,8 @@ export * from './apis'; export * from './components'; export * from './extensions'; +export * from './icons'; export * from './routing'; export * from './schema'; +export * from './apis/system'; export * from './wiring'; diff --git a/yarn.lock b/yarn.lock index 608d608907..44d83b5d4a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4046,6 +4046,7 @@ __metadata: resolution: "@backstage/frontend-plugin-api@workspace:packages/frontend-plugin-api" dependencies: "@backstage/cli": "workspace:^" + "@backstage/config": "workspace:^" "@backstage/core-components": "workspace:^" "@backstage/core-plugin-api": "workspace:^" "@backstage/frontend-app-api": "workspace:^"