frontend-plugin-api: rely on ApiRef inference

Remove explicit ApiRef constant annotations from frontend API ref declarations and rely on the createApiRef type argument for inference instead.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Made-with: Cursor
This commit is contained in:
Patrik Oldsberg
2026-03-16 19:04:34 +01:00
parent e8d410d915
commit cb8a487bde
14 changed files with 65 additions and 120 deletions
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { createApiRef, ApiRef } from '../system';
import { createApiRef } from '../system';
import { Observable } from '@backstage/types';
/**
@@ -51,7 +51,7 @@ export type AlertApi = {
*
* @public
*/
export const alertApiRef: ApiRef<AlertApi> = createApiRef<AlertApi>().with({
export const alertApiRef = createApiRef<AlertApi>().with({
id: 'core.alert',
pluginId: 'app',
});
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { ApiRef, createApiRef } from '../system';
import { createApiRef } from '../system';
import { AnalyticsContextValue } from '../../analytics/types';
/**
@@ -151,8 +151,7 @@ export type AnalyticsApi = {
*
* @public
*/
export const analyticsApiRef: ApiRef<AnalyticsApi> =
createApiRef<AnalyticsApi>().with({
id: 'core.analytics',
pluginId: 'app',
});
export const analyticsApiRef = createApiRef<AnalyticsApi>().with({
id: 'core.analytics',
pluginId: 'app',
});
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { ApiRef, createApiRef } from '../system';
import { createApiRef } from '../system';
import { Observable } from '@backstage/types';
/** @public */
@@ -31,8 +31,7 @@ export type AppLanguageApi = {
/**
* @public
*/
export const appLanguageApiRef: ApiRef<AppLanguageApi> =
createApiRef<AppLanguageApi>().with({
id: 'core.applanguage',
pluginId: 'app',
});
export const appLanguageApiRef = createApiRef<AppLanguageApi>().with({
id: 'core.applanguage',
pluginId: 'app',
});
@@ -15,7 +15,7 @@
*/
import { ReactNode } from 'react';
import { ApiRef, createApiRef } from '../system';
import { createApiRef } from '../system';
import { Observable } from '@backstage/types';
/**
@@ -82,8 +82,7 @@ export type AppThemeApi = {
*
* @public
*/
export const appThemeApiRef: ApiRef<AppThemeApi> =
createApiRef<AppThemeApi>().with({
id: 'core.apptheme',
pluginId: 'app',
});
export const appThemeApiRef = createApiRef<AppThemeApi>().with({
id: 'core.apptheme',
pluginId: 'app',
});
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ApiRef, createApiRef } from '../system';
import { createApiRef } from '../system';
import type { Config } from '@backstage/config';
/**
@@ -29,7 +29,7 @@ export type ConfigApi = Config;
*
* @public
*/
export const configApiRef: ApiRef<ConfigApi> = createApiRef<ConfigApi>().with({
export const configApiRef = createApiRef<ConfigApi>().with({
id: 'core.config',
pluginId: 'app',
});
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ApiRef, createApiRef } from '../system';
import { createApiRef } from '../system';
/**
* The discovery API is used to provide a mechanism for plugins to
@@ -50,8 +50,7 @@ export type DiscoveryApi = {
*
* @public
*/
export const discoveryApiRef: ApiRef<DiscoveryApi> =
createApiRef<DiscoveryApi>().with({
id: 'core.discovery',
pluginId: 'app',
});
export const discoveryApiRef = createApiRef<DiscoveryApi>().with({
id: 'core.discovery',
pluginId: 'app',
});
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { ApiRef, createApiRef } from '../system';
import { createApiRef } from '../system';
import { Observable } from '@backstage/types';
/**
@@ -86,7 +86,7 @@ export type ErrorApi = {
*
* @public
*/
export const errorApiRef: ApiRef<ErrorApi> = createApiRef<ErrorApi>().with({
export const errorApiRef = createApiRef<ErrorApi>().with({
id: 'core.error',
pluginId: 'app',
});
@@ -16,7 +16,7 @@
/* We want to maintain the same information as an enum, so we disable the redeclaration warning */
/* eslint-disable @typescript-eslint/no-redeclare */
import { ApiRef, createApiRef } from '../system';
import { createApiRef } from '../system';
/**
* Feature flag descriptor.
@@ -121,8 +121,7 @@ export interface FeatureFlagsApi {
*
* @public
*/
export const featureFlagsApiRef: ApiRef<FeatureFlagsApi> =
createApiRef<FeatureFlagsApi>().with({
id: 'core.featureflags',
pluginId: 'app',
});
export const featureFlagsApiRef = createApiRef<FeatureFlagsApi>().with({
id: 'core.featureflags',
pluginId: 'app',
});
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { ApiRef, createApiRef } from '../system';
import { createApiRef } from '../system';
/**
* A wrapper for the fetch API, that has additional behaviors such as the
@@ -46,7 +46,7 @@ export type FetchApi = {
*
* @public
*/
export const fetchApiRef: ApiRef<FetchApi> = createApiRef<FetchApi>().with({
export const fetchApiRef = createApiRef<FetchApi>().with({
id: 'core.fetch',
pluginId: 'app',
});
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ApiRef, createApiRef } from '../system';
import { createApiRef } from '../system';
import { BackstageUserIdentity, ProfileInfo } from './auth';
/**
@@ -51,8 +51,7 @@ export type IdentityApi = {
*
* @public
*/
export const identityApiRef: ApiRef<IdentityApi> =
createApiRef<IdentityApi>().with({
id: 'core.identity',
pluginId: 'app',
});
export const identityApiRef = createApiRef<IdentityApi>().with({
id: 'core.identity',
pluginId: 'app',
});
@@ -15,7 +15,7 @@
*/
import { Observable } from '@backstage/types';
import { ApiRef, createApiRef } from '../system';
import { createApiRef } from '../system';
import { AuthProviderInfo } from './auth';
/**
@@ -126,8 +126,7 @@ export type OAuthRequestApi = {
*
* @public
*/
export const oauthRequestApiRef: ApiRef<OAuthRequestApi> =
createApiRef<OAuthRequestApi>().with({
id: 'core.oauthrequest',
pluginId: 'app',
});
export const oauthRequestApiRef = createApiRef<OAuthRequestApi>().with({
id: 'core.oauthrequest',
pluginId: 'app',
});
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { ApiRef, createApiRef } from '../system';
import { createApiRef } from '../system';
import { JsonValue, Observable } from '@backstage/types';
/**
@@ -105,8 +105,7 @@ export interface StorageApi {
*
* @public
*/
export const storageApiRef: ApiRef<StorageApi> =
createApiRef<StorageApi>().with({
id: 'core.storage',
pluginId: 'app',
});
export const storageApiRef = createApiRef<StorageApi>().with({
id: 'core.storage',
pluginId: 'app',
});
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { ApiRef, createApiRef } from '../system';
import { createApiRef } from '../system';
import { Expand, ExpandRecursive, Observable } from '@backstage/types';
import { TranslationRef } from '../../translation';
import { JSX } from 'react';
@@ -358,8 +358,7 @@ export type TranslationApi = {
/**
* @public
*/
export const translationApiRef: ApiRef<TranslationApi> =
createApiRef<TranslationApi>().with({
id: 'core.translation',
pluginId: 'app',
});
export const translationApiRef = createApiRef<TranslationApi>().with({
id: 'core.translation',
pluginId: 'app',
});
@@ -16,7 +16,7 @@
/* We want to maintain the same information as an enum, so we disable the redeclaration warning */
/* eslint-disable @typescript-eslint/no-redeclare */
import { ApiRef, createApiRef } from '../system';
import { createApiRef } from '../system';
import { IconComponent, IconElement } from '../../icons/types';
import { Observable } from '@backstage/types';
@@ -336,13 +336,7 @@ export type SessionApi = {
* Note that the ID token payload is only guaranteed to contain the user's numerical Google ID,
* email and expiration information. Do not rely on any other fields, as they might not be present.
*/
export const googleAuthApiRef: ApiRef<
OAuthApi &
OpenIdConnectApi &
ProfileInfoApi &
BackstageIdentityApi &
SessionApi
> = createApiRef<
export const googleAuthApiRef = createApiRef<
OAuthApi &
OpenIdConnectApi &
ProfileInfoApi &
@@ -362,9 +356,7 @@ export const googleAuthApiRef: ApiRef<
* See {@link https://developer.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/}
* for a full list of supported scopes.
*/
export const githubAuthApiRef: ApiRef<
OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi
> = createApiRef<
export const githubAuthApiRef = createApiRef<
OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi
>().with({
id: 'core.auth.github',
@@ -380,13 +372,7 @@ export const githubAuthApiRef: ApiRef<
* See {@link https://developer.okta.com/docs/guides/implement-oauth-for-okta/scopes/}
* for a full list of supported scopes.
*/
export const oktaAuthApiRef: ApiRef<
OAuthApi &
OpenIdConnectApi &
ProfileInfoApi &
BackstageIdentityApi &
SessionApi
> = createApiRef<
export const oktaAuthApiRef = createApiRef<
OAuthApi &
OpenIdConnectApi &
ProfileInfoApi &
@@ -406,13 +392,7 @@ export const oktaAuthApiRef: ApiRef<
* See {@link https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#limiting-scopes-of-a-personal-access-token}
* for a full list of supported scopes.
*/
export const gitlabAuthApiRef: ApiRef<
OAuthApi &
OpenIdConnectApi &
ProfileInfoApi &
BackstageIdentityApi &
SessionApi
> = createApiRef<
export const gitlabAuthApiRef = createApiRef<
OAuthApi &
OpenIdConnectApi &
ProfileInfoApi &
@@ -433,13 +413,7 @@ export const gitlabAuthApiRef: ApiRef<
* - {@link https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-permissions-and-consent}
* - {@link https://docs.microsoft.com/en-us/graph/permissions-reference}
*/
export const microsoftAuthApiRef: ApiRef<
OAuthApi &
OpenIdConnectApi &
ProfileInfoApi &
BackstageIdentityApi &
SessionApi
> = createApiRef<
export const microsoftAuthApiRef = createApiRef<
OAuthApi &
OpenIdConnectApi &
ProfileInfoApi &
@@ -455,13 +429,7 @@ export const microsoftAuthApiRef: ApiRef<
*
* @public
*/
export const oneloginAuthApiRef: ApiRef<
OAuthApi &
OpenIdConnectApi &
ProfileInfoApi &
BackstageIdentityApi &
SessionApi
> = createApiRef<
export const oneloginAuthApiRef = createApiRef<
OAuthApi &
OpenIdConnectApi &
ProfileInfoApi &
@@ -481,9 +449,7 @@ export const oneloginAuthApiRef: ApiRef<
* See {@link https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/}
* for a full list of supported scopes.
*/
export const bitbucketAuthApiRef: ApiRef<
OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi
> = createApiRef<
export const bitbucketAuthApiRef = createApiRef<
OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi
>().with({
id: 'core.auth.bitbucket',
@@ -499,9 +465,7 @@ export const bitbucketAuthApiRef: ApiRef<
* See {@link https://confluence.atlassian.com/bitbucketserver/bitbucket-oauth-2-0-provider-api-1108483661.html#BitbucketOAuth2.0providerAPI-scopes}
* for a full list of supported scopes.
*/
export const bitbucketServerAuthApiRef: ApiRef<
OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi
> = createApiRef<
export const bitbucketServerAuthApiRef = createApiRef<
OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi
>().with({
id: 'core.auth.bitbucket-server',
@@ -517,9 +481,7 @@ export const bitbucketServerAuthApiRef: ApiRef<
* See {@link https://developer.atlassian.com/cloud/jira/platform/scopes-for-connect-and-oauth-2-3LO-apps/}
* for a full list of supported scopes.
*/
export const atlassianAuthApiRef: ApiRef<
OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi
> = createApiRef<
export const atlassianAuthApiRef = createApiRef<
OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi
>().with({
id: 'core.auth.atlassian',
@@ -535,13 +497,7 @@ export const atlassianAuthApiRef: ApiRef<
* For more info about VMware Cloud identity and access management:
* - {@link https://docs.vmware.com/en/VMware-Cloud-services/services/Using-VMware-Cloud-Services/GUID-53D39337-D93A-4B84-BD18-DDF43C21479A.html}
*/
export const vmwareCloudAuthApiRef: ApiRef<
OAuthApi &
OpenIdConnectApi &
ProfileInfoApi &
BackstageIdentityApi &
SessionApi
> = createApiRef<
export const vmwareCloudAuthApiRef = createApiRef<
OAuthApi &
OpenIdConnectApi &
ProfileInfoApi &
@@ -563,9 +519,7 @@ export const vmwareCloudAuthApiRef: ApiRef<
* {@link https://docs.redhat.com/en/documentation/openshift_container_platform/latest/html-single/authentication_and_authorization/index#tokens-scoping-about_configuring-internal-oauth}
* for available scopes.
*/
export const openshiftAuthApiRef: ApiRef<
OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi
> = createApiRef<
export const openshiftAuthApiRef = createApiRef<
OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi
>().with({
id: 'core.auth.openshift',