diff --git a/.changeset/angry-walls-despacito.md b/.changeset/angry-walls-despacito.md new file mode 100644 index 0000000000..f380b6df77 --- /dev/null +++ b/.changeset/angry-walls-despacito.md @@ -0,0 +1,5 @@ +--- +'@backstage/core-compat-api': patch +--- + +Added `convertLegacyRouteRef` utility to convert existing route refs to be used with the new experimental packages. diff --git a/.changeset/angry-walls-juggle.md b/.changeset/angry-walls-juggle.md new file mode 100644 index 0000000000..3df4a80b28 --- /dev/null +++ b/.changeset/angry-walls-juggle.md @@ -0,0 +1,5 @@ +--- +'@backstage/core-plugin-api': patch +--- + +Removed the alpha `convertLegacyRouteRef` utility, which as been moved to `@backstage/core-compat-api` diff --git a/.changeset/mighty-beans-wink.md b/.changeset/mighty-beans-wink.md new file mode 100644 index 0000000000..e0623643e1 --- /dev/null +++ b/.changeset/mighty-beans-wink.md @@ -0,0 +1,11 @@ +--- +'@backstage/plugin-catalog-import': patch +'@backstage/plugin-user-settings': patch +'@backstage/plugin-tech-radar': patch +'@backstage/plugin-graphiql': patch +'@backstage/plugin-techdocs': patch +'@backstage/plugin-catalog': patch +'@backstage/plugin-search': patch +--- + +The `convertLegacyRouteRef` utility used by the alpha exports is now imported from `@backstage/core-compat-api`. diff --git a/packages/core-compat-api/api-report.md b/packages/core-compat-api/api-report.md index 3dd2eb6b22..877aefa24f 100644 --- a/packages/core-compat-api/api-report.md +++ b/packages/core-compat-api/api-report.md @@ -5,9 +5,16 @@ ```ts /// +import { AnyRouteRefParams } from '@backstage/core-plugin-api'; import { BackstagePlugin } from '@backstage/frontend-plugin-api'; import { ExtensionOverrides } from '@backstage/frontend-plugin-api'; +import { ExternalRouteRef } from '@backstage/core-plugin-api'; +import { ExternalRouteRef as ExternalRouteRef_2 } from '@backstage/frontend-plugin-api'; import { default as React_2 } from 'react'; +import { RouteRef } from '@backstage/core-plugin-api'; +import { RouteRef as RouteRef_2 } from '@backstage/frontend-plugin-api'; +import { SubRouteRef } from '@backstage/core-plugin-api'; +import { SubRouteRef as SubRouteRef_2 } from '@backstage/frontend-plugin-api'; // @public (undocumented) export function collectLegacyRoutes( @@ -19,5 +26,23 @@ export function convertLegacyApp( rootElement: React_2.JSX.Element, ): (ExtensionOverrides | BackstagePlugin)[]; +// @public +export function convertLegacyRouteRef( + ref: RouteRef, +): RouteRef_2; + +// @public +export function convertLegacyRouteRef( + ref: SubRouteRef, +): SubRouteRef_2; + +// @public +export function convertLegacyRouteRef< + TParams extends AnyRouteRefParams, + TOptional extends boolean, +>( + ref: ExternalRouteRef, +): ExternalRouteRef_2; + // (No @packageDocumentation comment for this package) ``` diff --git a/packages/core-compat-api/package.json b/packages/core-compat-api/package.json index bb2454c073..7ead3d858f 100644 --- a/packages/core-compat-api/package.json +++ b/packages/core-compat-api/package.json @@ -25,7 +25,6 @@ }, "devDependencies": { "@backstage/cli": "workspace:^", - "@backstage/core-app-api": "workspace:^", "@backstage/plugin-puppetdb": "workspace:^", "@backstage/plugin-stackstorm": "workspace:^", "@oriflame/backstage-plugin-score-card": "^0.7.0", @@ -39,6 +38,7 @@ "react-router-dom": "6.0.0-beta.0 || ^6.3.0" }, "dependencies": { + "@backstage/core-app-api": "workspace:^", "@backstage/core-plugin-api": "workspace:^", "@backstage/frontend-plugin-api": "workspace:^" } diff --git a/packages/core-compat-api/src/collectLegacyRoutes.tsx b/packages/core-compat-api/src/collectLegacyRoutes.tsx index 8178de2876..037107bfda 100644 --- a/packages/core-compat-api/src/collectLegacyRoutes.tsx +++ b/packages/core-compat-api/src/collectLegacyRoutes.tsx @@ -28,7 +28,7 @@ import { RouteRef, getComponentData, } from '@backstage/core-plugin-api'; -import { convertLegacyRouteRef } from '@backstage/core-plugin-api/alpha'; +import { convertLegacyRouteRef } from './convertLegacyRouteRef'; /* diff --git a/packages/core-plugin-api/src/routing/convertLegacyRouteRef.ts b/packages/core-compat-api/src/convertLegacyRouteRef.ts similarity index 79% rename from packages/core-plugin-api/src/routing/convertLegacyRouteRef.ts rename to packages/core-compat-api/src/convertLegacyRouteRef.ts index 940a4174a9..2495f3719c 100644 --- a/packages/core-plugin-api/src/routing/convertLegacyRouteRef.ts +++ b/packages/core-compat-api/src/convertLegacyRouteRef.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import { routeRefType } from './types'; import { RouteRef as LegacyRouteRef, SubRouteRef as LegacySubRouteRef, @@ -22,9 +21,9 @@ import { AnyRouteRefParams, } from '@backstage/core-plugin-api'; -// Relative imports to avoid dependency, at least for now - // eslint-disable-next-line @backstage/no-relative-monorepo-imports +import { routeRefType } from '../../core-plugin-api/src/routing/types'; + import { RouteRef, SubRouteRef, @@ -32,29 +31,14 @@ import { createRouteRef, createSubRouteRef, createExternalRouteRef, -} from '../../../frontend-plugin-api/src/routing'; +} from '@backstage/frontend-plugin-api'; + // eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { toInternalRouteRef } from '../../../frontend-plugin-api/src/routing/RouteRef'; +import { toInternalRouteRef } from '../../frontend-plugin-api/src/routing/RouteRef'; // eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { toInternalSubRouteRef } from '../../../frontend-plugin-api/src/routing/SubRouteRef'; +import { toInternalSubRouteRef } from '../../frontend-plugin-api/src/routing/SubRouteRef'; // eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { toInternalExternalRouteRef } from '../../../frontend-plugin-api/src/routing/ExternalRouteRef'; - -// TODO(Rugvip): Once this is moved to a compat package these aliases can be removed and imported from frontend- instead - -/** @ignore */ -type NewRouteRef = - RouteRef; - -/** @ignore */ -type NewSubRouteRef = - SubRouteRef; - -/** @ignore */ -type NewExternalRouteRef< - TParams extends AnyRouteRefParams = AnyRouteRefParams, - TOptional extends boolean = boolean, -> = ExternalRouteRef; +import { toInternalExternalRouteRef } from '../../frontend-plugin-api/src/routing/ExternalRouteRef'; /** * A temporary helper to convert a legacy route ref to the new system. @@ -66,7 +50,7 @@ type NewExternalRouteRef< */ export function convertLegacyRouteRef( ref: LegacyRouteRef, -): NewRouteRef; +): RouteRef; /** * A temporary helper to convert a legacy sub route ref to the new system. @@ -78,7 +62,7 @@ export function convertLegacyRouteRef( */ export function convertLegacyRouteRef( ref: LegacySubRouteRef, -): NewSubRouteRef; +): SubRouteRef; /** * A temporary helper to convert a legacy external route ref to the new system. @@ -93,14 +77,14 @@ export function convertLegacyRouteRef< TOptional extends boolean, >( ref: LegacyExternalRouteRef, -): NewExternalRouteRef; +): ExternalRouteRef; export function convertLegacyRouteRef( ref: LegacyRouteRef | LegacySubRouteRef | LegacyExternalRouteRef, -): NewRouteRef | NewSubRouteRef | NewExternalRouteRef { +): RouteRef | SubRouteRef | ExternalRouteRef { // Ref has already been converted if ('$$type' in ref) { - return ref as unknown as NewRouteRef | NewSubRouteRef | NewExternalRouteRef; + return ref as unknown as RouteRef | SubRouteRef | ExternalRouteRef; } const type = (ref as unknown as { [routeRefType]: unknown })[routeRefType]; diff --git a/packages/core-compat-api/src/index.ts b/packages/core-compat-api/src/index.ts index e5f61119a3..421ced7054 100644 --- a/packages/core-compat-api/src/index.ts +++ b/packages/core-compat-api/src/index.ts @@ -15,3 +15,4 @@ */ export { collectLegacyRoutes } from './collectLegacyRoutes'; export { convertLegacyApp } from './convertLegacyApp'; +export { convertLegacyRouteRef } from './convertLegacyRouteRef'; diff --git a/packages/core-plugin-api/alpha-api-report.md b/packages/core-plugin-api/alpha-api-report.md index 0284d691a9..ba3583142f 100644 --- a/packages/core-plugin-api/alpha-api-report.md +++ b/packages/core-plugin-api/alpha-api-report.md @@ -3,12 +3,8 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -import { AnyRouteRefParams } from '@backstage/core-plugin-api'; import { ApiRef } from '@backstage/core-plugin-api'; -import { ExternalRouteRef } from '@backstage/core-plugin-api'; import { Observable } from '@backstage/types'; -import { RouteRef } from '@backstage/core-plugin-api'; -import { SubRouteRef } from '@backstage/core-plugin-api'; import { TranslationMessages as TranslationMessages_2 } from '@backstage/core-plugin-api/alpha'; import { TranslationRef as TranslationRef_2 } from '@backstage/core-plugin-api/alpha'; @@ -29,24 +25,6 @@ export type AppLanguageApi = { // @alpha (undocumented) export const appLanguageApiRef: ApiRef; -// @public -export function convertLegacyRouteRef( - ref: RouteRef, -): NewRouteRef; - -// @public -export function convertLegacyRouteRef( - ref: SubRouteRef, -): NewSubRouteRef; - -// @public -export function convertLegacyRouteRef< - TParams extends AnyRouteRefParams, - TOptional extends boolean, ->( - ref: ExternalRouteRef, -): NewExternalRouteRef; - // @alpha export function createTranslationMessages< TId extends string, diff --git a/packages/core-plugin-api/src/alpha.ts b/packages/core-plugin-api/src/alpha.ts index 540b4ed22a..ebcbcf34c0 100644 --- a/packages/core-plugin-api/src/alpha.ts +++ b/packages/core-plugin-api/src/alpha.ts @@ -16,4 +16,3 @@ export * from './translation'; export * from './apis/alpha'; -export { convertLegacyRouteRef } from './routing/convertLegacyRouteRef'; diff --git a/plugins/catalog-import/package.json b/plugins/catalog-import/package.json index f70a68c40a..6cb369cf47 100644 --- a/plugins/catalog-import/package.json +++ b/plugins/catalog-import/package.json @@ -49,6 +49,7 @@ "@backstage/catalog-client": "workspace:^", "@backstage/catalog-model": "workspace:^", "@backstage/config": "workspace:^", + "@backstage/core-compat-api": "workspace:^", "@backstage/core-components": "workspace:^", "@backstage/core-plugin-api": "workspace:^", "@backstage/errors": "workspace:^", diff --git a/plugins/catalog-import/src/alpha.tsx b/plugins/catalog-import/src/alpha.tsx index bde1048f13..18ddda2ceb 100644 --- a/plugins/catalog-import/src/alpha.tsx +++ b/plugins/catalog-import/src/alpha.tsx @@ -20,7 +20,7 @@ import { discoveryApiRef, identityApiRef, } from '@backstage/core-plugin-api'; -import { convertLegacyRouteRef } from '@backstage/core-plugin-api/alpha'; +import { convertLegacyRouteRef } from '@backstage/core-compat-api'; import { createApiExtension, createPageExtension, diff --git a/plugins/catalog/package.json b/plugins/catalog/package.json index efce469ba1..150f5362f3 100644 --- a/plugins/catalog/package.json +++ b/plugins/catalog/package.json @@ -48,6 +48,7 @@ "dependencies": { "@backstage/catalog-client": "workspace:^", "@backstage/catalog-model": "workspace:^", + "@backstage/core-compat-api": "workspace:^", "@backstage/core-components": "workspace:^", "@backstage/core-plugin-api": "workspace:^", "@backstage/errors": "workspace:^", diff --git a/plugins/catalog/src/alpha/navItems.tsx b/plugins/catalog/src/alpha/navItems.tsx index b6481fd764..77ea394a97 100644 --- a/plugins/catalog/src/alpha/navItems.tsx +++ b/plugins/catalog/src/alpha/navItems.tsx @@ -15,7 +15,7 @@ */ import HomeIcon from '@material-ui/icons/Home'; -import { convertLegacyRouteRef } from '@backstage/core-plugin-api/alpha'; +import { convertLegacyRouteRef } from '@backstage/core-compat-api'; import { createNavItemExtension } from '@backstage/frontend-plugin-api'; import { rootRouteRef } from '../routes'; diff --git a/plugins/catalog/src/alpha/pages.tsx b/plugins/catalog/src/alpha/pages.tsx index 6270ae777d..6324f53083 100644 --- a/plugins/catalog/src/alpha/pages.tsx +++ b/plugins/catalog/src/alpha/pages.tsx @@ -15,7 +15,7 @@ */ import React from 'react'; -import { convertLegacyRouteRef } from '@backstage/core-plugin-api/alpha'; +import { convertLegacyRouteRef } from '@backstage/core-compat-api'; import { createPageExtension, coreExtensionData, diff --git a/plugins/catalog/src/alpha/plugin.tsx b/plugins/catalog/src/alpha/plugin.tsx index 2f019ca33e..9b8494f1b0 100644 --- a/plugins/catalog/src/alpha/plugin.tsx +++ b/plugins/catalog/src/alpha/plugin.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ -import { convertLegacyRouteRef } from '@backstage/core-plugin-api/alpha'; +import { convertLegacyRouteRef } from '@backstage/core-compat-api'; import { createPlugin } from '@backstage/frontend-plugin-api'; import { entityRouteRef } from '@backstage/plugin-catalog-react'; diff --git a/plugins/graphiql/package.json b/plugins/graphiql/package.json index c86829b80e..bd8de81087 100644 --- a/plugins/graphiql/package.json +++ b/plugins/graphiql/package.json @@ -46,6 +46,7 @@ "clean": "backstage-cli package clean" }, "dependencies": { + "@backstage/core-compat-api": "workspace:^", "@backstage/core-components": "workspace:^", "@backstage/core-plugin-api": "workspace:^", "@backstage/frontend-plugin-api": "workspace:^", diff --git a/plugins/graphiql/src/alpha.tsx b/plugins/graphiql/src/alpha.tsx index 8b2b962355..760bc77d8e 100644 --- a/plugins/graphiql/src/alpha.tsx +++ b/plugins/graphiql/src/alpha.tsx @@ -34,7 +34,7 @@ import { } from '@backstage/plugin-graphiql'; import { createApiFactory, IconComponent } from '@backstage/core-plugin-api'; import { graphiQLRouteRef } from './route-refs'; -import { convertLegacyRouteRef } from '@backstage/core-plugin-api/alpha'; +import { convertLegacyRouteRef } from '@backstage/core-compat-api'; /** @alpha */ export const GraphiqlPage = createPageExtension({ diff --git a/plugins/search/package.json b/plugins/search/package.json index 544e607a10..a856804a08 100644 --- a/plugins/search/package.json +++ b/plugins/search/package.json @@ -48,6 +48,7 @@ "dependencies": { "@backstage/catalog-model": "workspace:^", "@backstage/config": "workspace:^", + "@backstage/core-compat-api": "workspace:^", "@backstage/core-components": "workspace:^", "@backstage/core-plugin-api": "workspace:^", "@backstage/errors": "workspace:^", diff --git a/plugins/search/src/alpha.tsx b/plugins/search/src/alpha.tsx index 14e7067dfa..ef11828c71 100644 --- a/plugins/search/src/alpha.tsx +++ b/plugins/search/src/alpha.tsx @@ -67,7 +67,7 @@ import { rootRouteRef } from './plugin'; import { SearchClient } from './apis'; import { SearchType } from './components/SearchType'; import { UrlUpdater } from './components/SearchPage/SearchPage'; -import { convertLegacyRouteRef } from '@backstage/core-plugin-api/alpha'; +import { convertLegacyRouteRef } from '@backstage/core-compat-api'; /** @alpha */ export const SearchApi = createApiExtension({ diff --git a/plugins/tech-radar/package.json b/plugins/tech-radar/package.json index 20c795f635..a7d8a41e8e 100644 --- a/plugins/tech-radar/package.json +++ b/plugins/tech-radar/package.json @@ -46,6 +46,7 @@ "start": "backstage-cli package start" }, "dependencies": { + "@backstage/core-compat-api": "workspace:^", "@backstage/core-components": "workspace:^", "@backstage/core-plugin-api": "workspace:^", "@backstage/frontend-plugin-api": "workspace:^", diff --git a/plugins/tech-radar/src/alpha.tsx b/plugins/tech-radar/src/alpha.tsx index 78230c0337..f9a34e2158 100644 --- a/plugins/tech-radar/src/alpha.tsx +++ b/plugins/tech-radar/src/alpha.tsx @@ -24,7 +24,7 @@ import { import React from 'react'; import { techRadarApiRef } from './api'; import { SampleTechRadarApi } from './sample'; -import { convertLegacyRouteRef } from '@backstage/core-plugin-api/alpha'; +import { convertLegacyRouteRef } from '@backstage/core-compat-api'; import { rootRouteRef } from './plugin'; /** @alpha */ diff --git a/plugins/techdocs/package.json b/plugins/techdocs/package.json index e477b8e891..19f3883565 100644 --- a/plugins/techdocs/package.json +++ b/plugins/techdocs/package.json @@ -49,6 +49,7 @@ "dependencies": { "@backstage/catalog-model": "workspace:^", "@backstage/config": "workspace:^", + "@backstage/core-compat-api": "workspace:^", "@backstage/core-components": "workspace:^", "@backstage/core-plugin-api": "workspace:^", "@backstage/errors": "workspace:^", diff --git a/plugins/techdocs/src/alpha.tsx b/plugins/techdocs/src/alpha.tsx index ceb5f47364..533b4cb524 100644 --- a/plugins/techdocs/src/alpha.tsx +++ b/plugins/techdocs/src/alpha.tsx @@ -31,7 +31,7 @@ import { fetchApiRef, identityApiRef, } from '@backstage/core-plugin-api'; -import { convertLegacyRouteRef } from '@backstage/core-plugin-api/alpha'; +import { convertLegacyRouteRef } from '@backstage/core-compat-api'; import { techdocsApiRef, techdocsStorageApiRef, diff --git a/plugins/user-settings/package.json b/plugins/user-settings/package.json index 38db104528..4edb08dc4a 100644 --- a/plugins/user-settings/package.json +++ b/plugins/user-settings/package.json @@ -47,6 +47,7 @@ }, "dependencies": { "@backstage/core-app-api": "workspace:^", + "@backstage/core-compat-api": "workspace:^", "@backstage/core-components": "workspace:^", "@backstage/core-plugin-api": "workspace:^", "@backstage/errors": "workspace:^", diff --git a/plugins/user-settings/src/alpha.tsx b/plugins/user-settings/src/alpha.tsx index 07cc8ce547..419ee2808d 100644 --- a/plugins/user-settings/src/alpha.tsx +++ b/plugins/user-settings/src/alpha.tsx @@ -19,7 +19,7 @@ import { createPageExtension, createPlugin, } from '@backstage/frontend-plugin-api'; -import { convertLegacyRouteRef } from '@backstage/core-plugin-api/alpha'; +import { convertLegacyRouteRef } from '@backstage/core-compat-api'; import { settingsRouteRef } from './plugin'; import React from 'react'; diff --git a/yarn.lock b/yarn.lock index 8b36d1245c..53e1959f8b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5892,6 +5892,7 @@ __metadata: "@backstage/cli": "workspace:^" "@backstage/config": "workspace:^" "@backstage/core-app-api": "workspace:^" + "@backstage/core-compat-api": "workspace:^" "@backstage/core-components": "workspace:^" "@backstage/core-plugin-api": "workspace:^" "@backstage/dev-utils": "workspace:^" @@ -6024,6 +6025,7 @@ __metadata: "@backstage/catalog-model": "workspace:^" "@backstage/cli": "workspace:^" "@backstage/core-app-api": "workspace:^" + "@backstage/core-compat-api": "workspace:^" "@backstage/core-components": "workspace:^" "@backstage/core-plugin-api": "workspace:^" "@backstage/dev-utils": "workspace:^" @@ -7220,6 +7222,7 @@ __metadata: dependencies: "@backstage/cli": "workspace:^" "@backstage/core-app-api": "workspace:^" + "@backstage/core-compat-api": "workspace:^" "@backstage/core-components": "workspace:^" "@backstage/core-plugin-api": "workspace:^" "@backstage/dev-utils": "workspace:^" @@ -9119,6 +9122,7 @@ __metadata: "@backstage/cli": "workspace:^" "@backstage/config": "workspace:^" "@backstage/core-app-api": "workspace:^" + "@backstage/core-compat-api": "workspace:^" "@backstage/core-components": "workspace:^" "@backstage/core-plugin-api": "workspace:^" "@backstage/dev-utils": "workspace:^" @@ -9523,6 +9527,7 @@ __metadata: dependencies: "@backstage/cli": "workspace:^" "@backstage/core-app-api": "workspace:^" + "@backstage/core-compat-api": "workspace:^" "@backstage/core-components": "workspace:^" "@backstage/core-plugin-api": "workspace:^" "@backstage/dev-utils": "workspace:^" @@ -9736,6 +9741,7 @@ __metadata: "@backstage/cli": "workspace:^" "@backstage/config": "workspace:^" "@backstage/core-app-api": "workspace:^" + "@backstage/core-compat-api": "workspace:^" "@backstage/core-components": "workspace:^" "@backstage/core-plugin-api": "workspace:^" "@backstage/dev-utils": "workspace:^" @@ -9865,6 +9871,7 @@ __metadata: dependencies: "@backstage/cli": "workspace:^" "@backstage/core-app-api": "workspace:^" + "@backstage/core-compat-api": "workspace:^" "@backstage/core-components": "workspace:^" "@backstage/core-plugin-api": "workspace:^" "@backstage/dev-utils": "workspace:^"