diff --git a/.changeset/seven-stingrays-suffer.md b/.changeset/seven-stingrays-suffer.md new file mode 100644 index 0000000000..a5b8695d2a --- /dev/null +++ b/.changeset/seven-stingrays-suffer.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-notifications': patch +'@backstage/plugin-signals': patch +--- + +Added support for the new frontend system via `/alpha` export. diff --git a/plugins/notifications/package.json b/plugins/notifications/package.json index 38765e5acd..b6d3b7af7c 100644 --- a/plugins/notifications/package.json +++ b/plugins/notifications/package.json @@ -12,9 +12,7 @@ ] }, "publishConfig": { - "access": "public", - "main": "dist/index.esm.js", - "types": "dist/index.d.ts" + "access": "public" }, "repository": { "type": "git", @@ -23,8 +21,23 @@ }, "license": "Apache-2.0", "sideEffects": false, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.tsx", + "./package.json": "./package.json" + }, "main": "src/index.ts", "types": "src/index.ts", + "typesVersions": { + "*": { + "alpha": [ + "src/alpha.tsx" + ], + "package.json": [ + "package.json" + ] + } + }, "files": [ "dist" ], @@ -38,9 +51,11 @@ "test": "backstage-cli package test" }, "dependencies": { + "@backstage/core-compat-api": "workspace:^", "@backstage/core-components": "workspace:^", "@backstage/core-plugin-api": "workspace:^", "@backstage/errors": "workspace:^", + "@backstage/frontend-plugin-api": "workspace:^", "@backstage/plugin-notifications-common": "workspace:^", "@backstage/plugin-signals-react": "workspace:^", "@backstage/theme": "workspace:^", diff --git a/plugins/notifications/report-alpha.api.md b/plugins/notifications/report-alpha.api.md new file mode 100644 index 0000000000..96bb31a925 --- /dev/null +++ b/plugins/notifications/report-alpha.api.md @@ -0,0 +1,71 @@ +## API Report File for "@backstage/plugin-notifications" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { AnyApiFactory } from '@backstage/frontend-plugin-api'; +import { AnyRouteRefParams } from '@backstage/frontend-plugin-api'; +import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api'; +import { ExtensionDefinition } from '@backstage/frontend-plugin-api'; +import { FrontendPlugin } from '@backstage/frontend-plugin-api'; +import { default as React_2 } from 'react'; +import { RouteRef } from '@backstage/frontend-plugin-api'; + +// @alpha (undocumented) +const _default: FrontendPlugin< + { + root: RouteRef; + }, + {}, + { + 'page:notifications': ExtensionDefinition<{ + kind: 'page'; + name: undefined; + config: { + path: string | undefined; + }; + configInput: { + path?: string | undefined; + }; + output: + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + > + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + RouteRef, + 'core.routing.ref', + { + optional: true; + } + >; + inputs: {}; + params: { + defaultPath: string; + loader: () => Promise; + routeRef?: RouteRef | undefined; + }; + }>; + 'api:notifications': ExtensionDefinition<{ + kind: 'api'; + name: undefined; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: {}; + params: { + factory: AnyApiFactory; + }; + }>; + } +>; +export default _default; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/notifications/src/alpha.tsx b/plugins/notifications/src/alpha.tsx new file mode 100644 index 0000000000..60f2136533 --- /dev/null +++ b/plugins/notifications/src/alpha.tsx @@ -0,0 +1,63 @@ +/* + * Copyright 2025 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 React from 'react'; +import { + ApiBlueprint, + PageBlueprint, + createApiFactory, + createFrontendPlugin, + discoveryApiRef, + fetchApiRef, +} from '@backstage/frontend-plugin-api'; +import { rootRouteRef } from './routes'; +import { + convertLegacyRouteRef, + convertLegacyRouteRefs, +} from '@backstage/core-compat-api'; +import { NotificationsClient, notificationsApiRef } from './api'; + +const page = PageBlueprint.make({ + params: { + defaultPath: '/notifications', + routeRef: convertLegacyRouteRef(rootRouteRef), + loader: () => + import('./components/NotificationsPage').then(m => ( + + )), + }, +}); + +const api = ApiBlueprint.make({ + params: { + factory: createApiFactory({ + api: notificationsApiRef, + deps: { discoveryApi: discoveryApiRef, fetchApi: fetchApiRef }, + factory: ({ discoveryApi, fetchApi }) => + new NotificationsClient({ discoveryApi, fetchApi }), + }), + }, +}); + +/** @alpha */ +export default createFrontendPlugin({ + id: 'notifications', + routes: convertLegacyRouteRefs({ + root: rootRouteRef, + }), + // TODO(Rugvip): Nav item (i.e. NotificationsSidebarItem) currently needs to be installed manually + extensions: [page, api], +}); diff --git a/plugins/signals/package.json b/plugins/signals/package.json index 974e46bcc5..a0832ec149 100644 --- a/plugins/signals/package.json +++ b/plugins/signals/package.json @@ -12,9 +12,7 @@ ] }, "publishConfig": { - "access": "public", - "main": "dist/index.esm.js", - "types": "dist/index.d.ts" + "access": "public" }, "repository": { "type": "git", @@ -23,8 +21,23 @@ }, "license": "Apache-2.0", "sideEffects": false, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.tsx", + "./package.json": "./package.json" + }, "main": "src/index.ts", "types": "src/index.ts", + "typesVersions": { + "*": { + "alpha": [ + "src/alpha.tsx" + ], + "package.json": [ + "package.json" + ] + } + }, "files": [ "dist" ], @@ -40,6 +53,7 @@ "dependencies": { "@backstage/core-components": "workspace:^", "@backstage/core-plugin-api": "workspace:^", + "@backstage/frontend-plugin-api": "workspace:^", "@backstage/plugin-signals-react": "workspace:^", "@backstage/theme": "workspace:^", "@backstage/types": "workspace:^", diff --git a/plugins/signals/report-alpha.api.md b/plugins/signals/report-alpha.api.md new file mode 100644 index 0000000000..45ee0da3b8 --- /dev/null +++ b/plugins/signals/report-alpha.api.md @@ -0,0 +1,36 @@ +## API Report File for "@backstage/plugin-signals" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { AnyApiFactory } from '@backstage/frontend-plugin-api'; +import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api'; +import { ExtensionDefinition } from '@backstage/frontend-plugin-api'; +import { FrontendPlugin } from '@backstage/frontend-plugin-api'; + +// @alpha (undocumented) +const _default: FrontendPlugin< + {}, + {}, + { + 'api:signals': ExtensionDefinition<{ + kind: 'api'; + name: undefined; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: {}; + params: { + factory: AnyApiFactory; + }; + }>; + } +>; +export default _default; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/signals/src/alpha.tsx b/plugins/signals/src/alpha.tsx new file mode 100644 index 0000000000..6d4eb73af3 --- /dev/null +++ b/plugins/signals/src/alpha.tsx @@ -0,0 +1,49 @@ +/* + * Copyright 2025 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 { + ApiBlueprint, + createApiFactory, + createFrontendPlugin, + discoveryApiRef, + identityApiRef, +} from '@backstage/frontend-plugin-api'; +import { signalApiRef } from '@backstage/plugin-signals-react'; +import { SignalClient } from './api/SignalClient'; + +const api = ApiBlueprint.make({ + params: { + factory: createApiFactory({ + api: signalApiRef, + deps: { + identity: identityApiRef, + discoveryApi: discoveryApiRef, + }, + factory: ({ identity, discoveryApi }) => { + return SignalClient.create({ + identity, + discoveryApi, + }); + }, + }), + }, +}); + +/** @alpha */ +export default createFrontendPlugin({ + id: 'signals', + extensions: [api], +}); diff --git a/yarn.lock b/yarn.lock index 8ae7f225e3..56767924ab 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7130,10 +7130,12 @@ __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:^" "@backstage/errors": "workspace:^" + "@backstage/frontend-plugin-api": "workspace:^" "@backstage/plugin-notifications-common": "workspace:^" "@backstage/plugin-signals": "workspace:^" "@backstage/plugin-signals-react": "workspace:^" @@ -8330,6 +8332,7 @@ __metadata: "@backstage/core-components": "workspace:^" "@backstage/core-plugin-api": "workspace:^" "@backstage/dev-utils": "workspace:^" + "@backstage/frontend-plugin-api": "workspace:^" "@backstage/plugin-signals-react": "workspace:^" "@backstage/test-utils": "workspace:^" "@backstage/theme": "workspace:^"