From 0410fc9ce605f1495870eaee1715a33e706cf58b Mon Sep 17 00:00:00 2001 From: Heikki Hellgren Date: Tue, 30 Apr 2024 11:49:36 +0300 Subject: [PATCH 001/372] feat: allow setting notification read from web/snackbar when opening link from snackbar or web notification, the notification can be automatically set as read like in the notifications page Signed-off-by: Heikki Hellgren --- .changeset/ten-penguins-roll.md | 5 ++++ plugins/notifications/api-report.md | 6 ++++- .../NotificationsSideBarItem.tsx | 23 +++++++++++++++++-- .../src/hooks/useWebNotifications.ts | 23 ++++++++++++++++--- 4 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 .changeset/ten-penguins-roll.md diff --git a/.changeset/ten-penguins-roll.md b/.changeset/ten-penguins-roll.md new file mode 100644 index 0000000000..60e0ae773a --- /dev/null +++ b/.changeset/ten-penguins-roll.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-notifications': patch +--- + +Allow setting notification as read when opening snackbar or web notification link diff --git a/plugins/notifications/api-report.md b/plugins/notifications/api-report.md index 9240bdb1c2..2547204c7b 100644 --- a/plugins/notifications/api-report.md +++ b/plugins/notifications/api-report.md @@ -103,6 +103,7 @@ export const NotificationsSidebarItem: (props?: { titleCounterEnabled?: boolean; snackbarEnabled?: boolean; snackbarAutoHideDuration?: number | null; + markAsReadOnLinkOpen?: boolean; className?: string; icon?: IconComponent; text?: string; @@ -182,7 +183,10 @@ export function useTitleCounter(): { }; // @public (undocumented) -export function useWebNotifications(enabled: boolean): { +export function useWebNotifications( + enabled: boolean, + markAsReadOnLinkOpen: boolean, +): { sendWebNotification: (options: { id: string; title: string; diff --git a/plugins/notifications/src/components/NotificationsSideBarItem/NotificationsSideBarItem.tsx b/plugins/notifications/src/components/NotificationsSideBarItem/NotificationsSideBarItem.tsx index 7b55c63747..6e1f7c7d56 100644 --- a/plugins/notifications/src/components/NotificationsSideBarItem/NotificationsSideBarItem.tsx +++ b/plugins/notifications/src/components/NotificationsSideBarItem/NotificationsSideBarItem.tsx @@ -84,6 +84,7 @@ export const NotificationsSidebarItem = (props?: { titleCounterEnabled?: boolean; snackbarEnabled?: boolean; snackbarAutoHideDuration?: number | null; + markAsReadOnLinkOpen?: boolean; className?: string; icon?: IconComponent; text?: string; @@ -95,6 +96,7 @@ export const NotificationsSidebarItem = (props?: { titleCounterEnabled = true, snackbarEnabled = true, snackbarAutoHideDuration = 10000, + markAsReadOnLinkOpen = false, icon = NotificationsIcon, text = 'Notifications', ...restProps @@ -103,6 +105,7 @@ export const NotificationsSidebarItem = (props?: { titleCounterEnabled: true, snackbarEnabled: true, snackbarAutoHideDuration: 10000, + markAsReadOnLinkOpen: false, }; const { loading, error, value, retry } = useNotificationsApi(api => @@ -114,7 +117,10 @@ export const NotificationsSidebarItem = (props?: { const notificationsRoute = useRouteRef(rootRouteRef); // TODO: Do we want to add long polling in case signals are not available const { lastSignal } = useSignal('notifications'); - const { sendWebNotification } = useWebNotifications(webNotificationsEnabled); + const { sendWebNotification } = useWebNotifications( + webNotificationsEnabled, + markAsReadOnLinkOpen, + ); const [refresh, setRefresh] = React.useState(false); const { setNotificationCount } = useTitleCounter(); @@ -126,6 +132,19 @@ export const NotificationsSidebarItem = (props?: { component={Link} to={notification.payload.link ?? notificationsRoute()} onClick={() => { + if (markAsReadOnLinkOpen) { + notificationsApi + .updateNotifications({ + ids: [notification.id], + read: true, + }) + .catch(() => { + alertApi.post({ + message: 'Failed to mark notification as read', + severity: 'error', + }); + }); + } closeSnackbar(snackBarId); }} > @@ -156,7 +175,7 @@ export const NotificationsSidebarItem = (props?: { return { action }; }, - [notificationsRoute, notificationsApi, alertApi], + [notificationsRoute, markAsReadOnLinkOpen, notificationsApi, alertApi], ); useEffect(() => { diff --git a/plugins/notifications/src/hooks/useWebNotifications.ts b/plugins/notifications/src/hooks/useWebNotifications.ts index 728d992130..92a0a9b806 100644 --- a/plugins/notifications/src/hooks/useWebNotifications.ts +++ b/plugins/notifications/src/hooks/useWebNotifications.ts @@ -15,14 +15,19 @@ */ import { useCallback, useEffect, useState } from 'react'; import { rootRouteRef } from '../routes'; -import { useRouteRef } from '@backstage/core-plugin-api'; +import { useApi, useRouteRef } from '@backstage/core-plugin-api'; import { useNavigate } from 'react-router-dom'; +import { notificationsApiRef } from '../api'; /** @public */ -export function useWebNotifications(enabled: boolean) { +export function useWebNotifications( + enabled: boolean, + markAsReadOnLinkOpen: boolean, +) { const [webNotificationPermission, setWebNotificationPermission] = useState('default'); const notificationsRoute = useRouteRef(rootRouteRef); + const notificationsApi = useApi(notificationsApiRef); const navigate = useNavigate(); useEffect(() => { @@ -57,6 +62,12 @@ export function useWebNotifications(enabled: boolean) { event.preventDefault(); if (options.link) { window.open(options.link, '_blank'); + if (markAsReadOnLinkOpen) { + notificationsApi.updateNotifications({ + ids: [options.id], + read: true, + }); + } } else { navigate(notificationsRoute()); } @@ -65,7 +76,13 @@ export function useWebNotifications(enabled: boolean) { return notification; }, - [webNotificationPermission, navigate, notificationsRoute], + [ + webNotificationPermission, + markAsReadOnLinkOpen, + notificationsApi, + navigate, + notificationsRoute, + ], ); return { sendWebNotification }; From a880e941aaf1382189169b3416df51ec4b2c0b6c Mon Sep 17 00:00:00 2001 From: Heikki Hellgren Date: Thu, 30 May 2024 15:45:38 +0300 Subject: [PATCH 002/372] fix: change notification hooks to internal Signed-off-by: Heikki Hellgren --- plugins/notifications/api-report.md | 18 ------------------ .../notifications/src/hooks/useTitleCounter.ts | 2 +- .../src/hooks/useWebNotifications.ts | 2 +- plugins/notifications/src/index.ts | 2 +- 4 files changed, 3 insertions(+), 21 deletions(-) diff --git a/plugins/notifications/api-report.md b/plugins/notifications/api-report.md index 2547204c7b..c431664883 100644 --- a/plugins/notifications/api-report.md +++ b/plugins/notifications/api-report.md @@ -177,23 +177,5 @@ export function useNotificationsApi( value: T; }; -// @public (undocumented) -export function useTitleCounter(): { - setNotificationCount: (newCount: number) => void; -}; - -// @public (undocumented) -export function useWebNotifications( - enabled: boolean, - markAsReadOnLinkOpen: boolean, -): { - sendWebNotification: (options: { - id: string; - title: string; - description: string; - link?: string; - }) => Notification | null; -}; - // (No @packageDocumentation comment for this package) ``` diff --git a/plugins/notifications/src/hooks/useTitleCounter.ts b/plugins/notifications/src/hooks/useTitleCounter.ts index 0793cd58d6..399bfb84f4 100644 --- a/plugins/notifications/src/hooks/useTitleCounter.ts +++ b/plugins/notifications/src/hooks/useTitleCounter.ts @@ -25,7 +25,7 @@ const throttledSetTitle = throttle((shownTitle: string) => { document.title = shownTitle; }, 100); -/** @public */ +/** @internal */ export function useTitleCounter() { const [title, setTitle] = useState(document.title); const [count, setCount] = useState(0); diff --git a/plugins/notifications/src/hooks/useWebNotifications.ts b/plugins/notifications/src/hooks/useWebNotifications.ts index 92a0a9b806..3fbd3c5496 100644 --- a/plugins/notifications/src/hooks/useWebNotifications.ts +++ b/plugins/notifications/src/hooks/useWebNotifications.ts @@ -19,7 +19,7 @@ import { useApi, useRouteRef } from '@backstage/core-plugin-api'; import { useNavigate } from 'react-router-dom'; import { notificationsApiRef } from '../api'; -/** @public */ +/** @internal */ export function useWebNotifications( enabled: boolean, markAsReadOnLinkOpen: boolean, diff --git a/plugins/notifications/src/index.ts b/plugins/notifications/src/index.ts index bb5d76a0cf..25565f1ae1 100644 --- a/plugins/notifications/src/index.ts +++ b/plugins/notifications/src/index.ts @@ -15,5 +15,5 @@ */ export { notificationsPlugin, NotificationsPage } from './plugin'; export * from './api'; -export * from './hooks'; +export { useNotificationsApi } from './hooks'; export * from './components'; From aa2d3e302acff82c078dcc40dd75fe17144fc5ef Mon Sep 17 00:00:00 2001 From: Heikki Hellgren Date: Thu, 30 May 2024 21:14:02 +0300 Subject: [PATCH 003/372] feat: make default functionality to mark notification read when opening link Signed-off-by: Heikki Hellgren --- .changeset/ten-penguins-roll.md | 4 +-- plugins/notifications/api-report.md | 1 - .../NotificationsSideBarItem.tsx | 13 ++++----- .../src/hooks/useWebNotifications.ts | 29 ++++++------------- 4 files changed, 17 insertions(+), 30 deletions(-) diff --git a/.changeset/ten-penguins-roll.md b/.changeset/ten-penguins-roll.md index 60e0ae773a..152bb1524b 100644 --- a/.changeset/ten-penguins-roll.md +++ b/.changeset/ten-penguins-roll.md @@ -1,5 +1,5 @@ --- -'@backstage/plugin-notifications': patch +'@backstage/plugin-notifications': minor --- -Allow setting notification as read when opening snackbar or web notification link +By default, set notification as read when opening snackbar or web notification link diff --git a/plugins/notifications/api-report.md b/plugins/notifications/api-report.md index c431664883..5e06ae2616 100644 --- a/plugins/notifications/api-report.md +++ b/plugins/notifications/api-report.md @@ -103,7 +103,6 @@ export const NotificationsSidebarItem: (props?: { titleCounterEnabled?: boolean; snackbarEnabled?: boolean; snackbarAutoHideDuration?: number | null; - markAsReadOnLinkOpen?: boolean; className?: string; icon?: IconComponent; text?: string; diff --git a/plugins/notifications/src/components/NotificationsSideBarItem/NotificationsSideBarItem.tsx b/plugins/notifications/src/components/NotificationsSideBarItem/NotificationsSideBarItem.tsx index 6e1f7c7d56..457893b016 100644 --- a/plugins/notifications/src/components/NotificationsSideBarItem/NotificationsSideBarItem.tsx +++ b/plugins/notifications/src/components/NotificationsSideBarItem/NotificationsSideBarItem.tsx @@ -84,7 +84,6 @@ export const NotificationsSidebarItem = (props?: { titleCounterEnabled?: boolean; snackbarEnabled?: boolean; snackbarAutoHideDuration?: number | null; - markAsReadOnLinkOpen?: boolean; className?: string; icon?: IconComponent; text?: string; @@ -96,7 +95,6 @@ export const NotificationsSidebarItem = (props?: { titleCounterEnabled = true, snackbarEnabled = true, snackbarAutoHideDuration = 10000, - markAsReadOnLinkOpen = false, icon = NotificationsIcon, text = 'Notifications', ...restProps @@ -105,7 +103,6 @@ export const NotificationsSidebarItem = (props?: { titleCounterEnabled: true, snackbarEnabled: true, snackbarAutoHideDuration: 10000, - markAsReadOnLinkOpen: false, }; const { loading, error, value, retry } = useNotificationsApi(api => @@ -117,9 +114,8 @@ export const NotificationsSidebarItem = (props?: { const notificationsRoute = useRouteRef(rootRouteRef); // TODO: Do we want to add long polling in case signals are not available const { lastSignal } = useSignal('notifications'); - const { sendWebNotification } = useWebNotifications( + const { sendWebNotification, requestUserPermission } = useWebNotifications( webNotificationsEnabled, - markAsReadOnLinkOpen, ); const [refresh, setRefresh] = React.useState(false); const { setNotificationCount } = useTitleCounter(); @@ -132,7 +128,7 @@ export const NotificationsSidebarItem = (props?: { component={Link} to={notification.payload.link ?? notificationsRoute()} onClick={() => { - if (markAsReadOnLinkOpen) { + if (notification.payload.link) { notificationsApi .updateNotifications({ ids: [notification.id], @@ -175,7 +171,7 @@ export const NotificationsSidebarItem = (props?: { return { action }; }, - [notificationsRoute, markAsReadOnLinkOpen, notificationsApi, alertApi], + [notificationsRoute, notificationsApi, alertApi], ); useEffect(() => { @@ -278,6 +274,9 @@ export const NotificationsSidebarItem = (props?: { )} { + requestUserPermission(); + }} hasNotifications={!error && !!unreadCount} text={text} icon={icon} diff --git a/plugins/notifications/src/hooks/useWebNotifications.ts b/plugins/notifications/src/hooks/useWebNotifications.ts index 3fbd3c5496..ec120a614d 100644 --- a/plugins/notifications/src/hooks/useWebNotifications.ts +++ b/plugins/notifications/src/hooks/useWebNotifications.ts @@ -13,24 +13,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { useCallback, useEffect, useState } from 'react'; +import { useCallback, useState } from 'react'; import { rootRouteRef } from '../routes'; import { useApi, useRouteRef } from '@backstage/core-plugin-api'; import { useNavigate } from 'react-router-dom'; import { notificationsApiRef } from '../api'; /** @internal */ -export function useWebNotifications( - enabled: boolean, - markAsReadOnLinkOpen: boolean, -) { +export function useWebNotifications(enabled: boolean) { const [webNotificationPermission, setWebNotificationPermission] = useState('default'); const notificationsRoute = useRouteRef(rootRouteRef); const notificationsApi = useApi(notificationsApiRef); const navigate = useNavigate(); - useEffect(() => { + const requestUserPermission = useCallback(() => { if ( enabled && 'Notification' in window && @@ -62,12 +59,10 @@ export function useWebNotifications( event.preventDefault(); if (options.link) { window.open(options.link, '_blank'); - if (markAsReadOnLinkOpen) { - notificationsApi.updateNotifications({ - ids: [options.id], - read: true, - }); - } + notificationsApi.updateNotifications({ + ids: [options.id], + read: true, + }); } else { navigate(notificationsRoute()); } @@ -76,14 +71,8 @@ export function useWebNotifications( return notification; }, - [ - webNotificationPermission, - markAsReadOnLinkOpen, - notificationsApi, - navigate, - notificationsRoute, - ], + [webNotificationPermission, notificationsApi, navigate, notificationsRoute], ); - return { sendWebNotification }; + return { sendWebNotification, requestUserPermission }; } From cdb630d9d860d811256535f5525c51446f9e4031 Mon Sep 17 00:00:00 2001 From: Heikki Hellgren Date: Thu, 13 Jun 2024 14:05:27 +0300 Subject: [PATCH 004/372] feat: support for stream transport for debug purposes Signed-off-by: Heikki Hellgren --- .changeset/shy-games-poke.md | 5 +++++ .../README.md | 2 +- .../config.d.ts | 4 ++++ .../processor/NotificationsEmailProcessor.ts | 4 ++++ .../src/processor/transports/index.ts | 1 + .../src/processor/transports/stream.ts | 20 +++++++++++++++++++ 6 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 .changeset/shy-games-poke.md create mode 100644 plugins/notifications-backend-module-email/src/processor/transports/stream.ts diff --git a/.changeset/shy-games-poke.md b/.changeset/shy-games-poke.md new file mode 100644 index 0000000000..1d2abff39c --- /dev/null +++ b/.changeset/shy-games-poke.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-notifications-backend-module-email': patch +--- + +Add support for stream transport for debugging purposes diff --git a/plugins/notifications-backend-module-email/README.md b/plugins/notifications-backend-module-email/README.md index 7bbac05b62..1defad74b4 100644 --- a/plugins/notifications-backend-module-email/README.md +++ b/plugins/notifications-backend-module-email/README.md @@ -2,7 +2,7 @@ Adds support for sending Backstage notifications as emails to users. -Supports sending emails using `SMTP`, `SES`, or `sendmail`. +Supports sending emails using `SMTP`, `SES`, `sendmail`, or `stream` (for debugging purposes). ## Customizing email content diff --git a/plugins/notifications-backend-module-email/config.d.ts b/plugins/notifications-backend-module-email/config.d.ts index 92f3385d1b..56a238d0dd 100644 --- a/plugins/notifications-backend-module-email/config.d.ts +++ b/plugins/notifications-backend-module-email/config.d.ts @@ -79,6 +79,10 @@ export interface Config { * Newline style, defaults to 'unix' */ newline?: 'unix' | 'windows'; + } + | { + /** Only for debugging, disables the actual sending of emails */ + transport: 'stream'; }; /** * Sender email address diff --git a/plugins/notifications-backend-module-email/src/processor/NotificationsEmailProcessor.ts b/plugins/notifications-backend-module-email/src/processor/NotificationsEmailProcessor.ts index a78ebd3260..7085652b54 100644 --- a/plugins/notifications-backend-module-email/src/processor/NotificationsEmailProcessor.ts +++ b/plugins/notifications-backend-module-email/src/processor/NotificationsEmailProcessor.ts @@ -38,6 +38,7 @@ import { createSendmailTransport, createSesTransport, createSmtpTransport, + createStreamTransport, } from './transports'; import { UserEntity } from '@backstage/catalog-model'; import { compact } from 'lodash'; @@ -129,6 +130,8 @@ export class NotificationsEmailProcessor implements NotificationProcessor { ); } else if (transport === 'sendmail') { this.transporter = createSendmailTransport(this.transportConfig); + } else if (transport === 'stream') { + this.transporter = createStreamTransport(); } else { throw new Error(`Unsupported transport: ${transport}`); } @@ -229,6 +232,7 @@ export class NotificationsEmailProcessor implements NotificationProcessor { private async sendMail(options: Mail.Options) { try { + this.logger.debug(`Sending notification email to ${options.to}`); await this.transporter.sendMail(options); } catch (e) { this.logger.error(`Failed to send email to ${options.to}: ${e}`); diff --git a/plugins/notifications-backend-module-email/src/processor/transports/index.ts b/plugins/notifications-backend-module-email/src/processor/transports/index.ts index ccea9f77cc..9a679f3723 100644 --- a/plugins/notifications-backend-module-email/src/processor/transports/index.ts +++ b/plugins/notifications-backend-module-email/src/processor/transports/index.ts @@ -16,3 +16,4 @@ export { createSmtpTransport } from './smtp'; export { createSesTransport } from './ses'; export { createSendmailTransport } from './sendmail'; +export { createStreamTransport } from './stream'; diff --git a/plugins/notifications-backend-module-email/src/processor/transports/stream.ts b/plugins/notifications-backend-module-email/src/processor/transports/stream.ts new file mode 100644 index 0000000000..26ed401366 --- /dev/null +++ b/plugins/notifications-backend-module-email/src/processor/transports/stream.ts @@ -0,0 +1,20 @@ +/* + * Copyright 2024 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 { createTransport } from 'nodemailer'; + +export const createStreamTransport = () => { + return createTransport({ streamTransport: true }); +}; From 579afd0d3205548261334d476900721e19413561 Mon Sep 17 00:00:00 2001 From: Frank Kong Date: Fri, 14 Jun 2024 16:55:00 -0400 Subject: [PATCH 005/372] chore(auth-node): allow declarative signin resolvers to take precedence Signed-off-by: Frank Kong --- .changeset/neat-socks-cheer.md | 5 +++++ plugins/auth-node/src/oauth/createOAuthProviderFactory.ts | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 .changeset/neat-socks-cheer.md diff --git a/.changeset/neat-socks-cheer.md b/.changeset/neat-socks-cheer.md new file mode 100644 index 0000000000..5e2879b0a3 --- /dev/null +++ b/.changeset/neat-socks-cheer.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-auth-node': patch +--- + +allow declarative sign in resolvers declared in `signInResolverFactories` to take precedence over the statically defined sign in resolvers in `signInResolver` for the `createOAuthProviderFactory`. diff --git a/plugins/auth-node/src/oauth/createOAuthProviderFactory.ts b/plugins/auth-node/src/oauth/createOAuthProviderFactory.ts index a3387b7038..fccfcb94de 100644 --- a/plugins/auth-node/src/oauth/createOAuthProviderFactory.ts +++ b/plugins/auth-node/src/oauth/createOAuthProviderFactory.ts @@ -43,11 +43,10 @@ export function createOAuthProviderFactory(options: { return ctx => { return OAuthEnvironmentHandler.mapConfig(ctx.config, envConfig => { const signInResolver = - options.signInResolver ?? readDeclarativeSignInResolver({ config: envConfig, signInResolverFactories: options.signInResolverFactories ?? {}, - }); + }) ?? options.signInResolver; return createOAuthRouteHandlers({ authenticator: options.authenticator, From 54a0cc779b39f12aecb1c4e9439e18f2007ae83a Mon Sep 17 00:00:00 2001 From: Tavi Nolan Date: Mon, 24 Jun 2024 18:09:57 +0100 Subject: [PATCH 006/372] Creating dry run documentation Signed-off-by: Tavi Nolan --- docs/plugins/dry-run-testing.md | 135 ++++++++++++++++++++++++++++++++ mkdocs.yml | 1 + 2 files changed, 136 insertions(+) create mode 100644 docs/plugins/dry-run-testing.md diff --git a/docs/plugins/dry-run-testing.md b/docs/plugins/dry-run-testing.md new file mode 100644 index 0000000000..18b7343920 --- /dev/null +++ b/docs/plugins/dry-run-testing.md @@ -0,0 +1,135 @@ +--- +id: dry run testing +title: Dry Run Testing +description: Documentation on how to enable and implement dry run testing in actions +--- + +Scaffolder templates can be tested using the dry run feature of scaffolder actions. This allows you to simulate the effects of running a scaffolder action without making any actual changes to your environment, for example creating a webhook in Github. Once dry run is enabled in the scaffolder action, you can add handling to actions you use in your scaffolder templates to define how an action should operate in a dry run scenario. + +## Enabling dry run testing + +To enable dry run for your scaffolder action you need to add 'supportsDryRun: true' to the configuration object of 'createTemplateAction' in the function where the behavior of your action is defined: + +```typescript +export function exampleAction() { + return createTemplateAction<{ + example: string; + }>({ + id: 'action:example', + description: 'Example action', + schema: { + input: { + type: 'object', + properties: { + example: { + title: 'example', + type: 'string', + }, + }, + }, + }, + supportsDryRun: true, + async handler(ctx) { + ... + }, + }); +} +``` + +## Adding handling for dry run + +To add handling for dry run functionality you need to add a check for 'ctx.isDryRun' inside the handler of the configuration object which is being passed into 'createTemplateAction' in the function where the behavior of your action is defined. Once the check is successful, you can perform the desired actions expected in a dry run, e.g. outputting non-sensitive inputs. + +```typescript +async handler(ctx) { + ... + + // If this is a dry run, log and return + if (ctx.isDryRun) { + ctx.logger.info(`Dry run complete`); + return; + } + + ... + }, +``` + +## Testing dry run handling + +You will also need to add tests for the dry run handling, for example: + +```typescript + it('should not perform action during dry run', async () => { + ... + + // Create the context object with the necessary properties for a dry run + const ctx = { + ...mockContext, + isDryRun: true, + input: { + ... + }, + }; + + // Call the handler with the context + await action.handler(ctx); + + expect(...); + }); +``` + +## Dry run via API call + +Dry run can be performed using the dry-run API, which allows the dry run to be completed in code. +This [command line script](https://github.com/backstage/backstage/blob/master/contrib/scaffolder/template-testing-dry-run.md) offers a way for you to do work with dry-run API. You run it against a running instance, either locally or remote, and use it like: + +```bash +scaffolder-dry http://localhost:7007/ template-directory values.yml output-directory +``` + +If you're using backend permissions, pass a front-end auth token from a current browser session via --token $FRONTEND_TOKEN. + +You can also query the dry run endpoint directly in code, for example: + +`dry-run.js` + +```javascript +const template = yaml.load( + await fs.readFile('path/to/templates/template.yaml', 'utf-8'), +); +const values = JSON.parse( + await fs.readFile('path/to/templates/template_values.json', 'utf-8'), +); + +// Prepare the request body +const body = { + template, + values, + directoryContents, +}; + +// Send the request to the dry-run endpoint +const response = await fetch( + 'http://localhost:7000/api/scaffolder/v2/dry-run', + { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Authorization: 'Bearer ', // replace 'YOUR_API_KEY' with your actual API key + }, + body: JSON.stringify(body), + }, +); +``` + +`template_values.json` + +```json +{ + "example": "test", + "name": "helloworld" +} +``` + +In this example `template.yaml` is your template yaml file, `template_values.json` would be a json file containing key value pairs for your template inputs, and `directoryContents` is an array that is populated with objects representing the contents of a specified directory (e.g. the same directory where you have your template yaml). Each object in the array corresponds to a file within the directory and contains two properties; the name of the file and the content of the file, encoded in Base64. +This is needed if any other files were required by the actions your template is using. diff --git a/mkdocs.yml b/mkdocs.yml index b9f6d41d46..045238e97e 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -139,6 +139,7 @@ nav: - URL Reader: 'plugins/url-reader.md' - Testing: - Testing with Jest: 'plugins/testing.md' + - Dry Run Testing: 'plugins/dry-run-testing.md' - Publishing: - Publish private: 'plugins/publish-private.md' - Add to Directory: 'plugins/add-to-directory.md' From 5177f6f0e1ce1b453f0975eea0c0a49e6c3783c2 Mon Sep 17 00:00:00 2001 From: Marek Libra Date: Fri, 31 May 2024 12:35:40 +0200 Subject: [PATCH 007/372] User documentation for the Notifications and Signals Signed-off-by: Marek Libra --- docs/notifications/getting-started.md | 168 +++++++++++++++++++++++ docs/notifications/notificationsPage.png | Bin 0 -> 137787 bytes 2 files changed, 168 insertions(+) create mode 100644 docs/notifications/getting-started.md create mode 100644 docs/notifications/notificationsPage.png diff --git a/docs/notifications/getting-started.md b/docs/notifications/getting-started.md new file mode 100644 index 0000000000..6a7ea6314e --- /dev/null +++ b/docs/notifications/getting-started.md @@ -0,0 +1,168 @@ +--- +id: getting-started +title: Getting Started +description: How to get started with the notifications and signals +--- + +The Backstage Notifications System provides a way for plugins and external services to send notifications to Backstage users. +These notifications are displayed in the dedicated page of the Backstage frontend UI or by frontend plugins per specific scenarios. +Additionally, plugins can implement processors to send notifications through external channels like email, Slack, or MS Teams. + +Notifications can be optionally integrated with the signals (a push mechanism) to ensure users receive them immediately. + +### Upgrade to the latest version of Backstage + +To ensure your version of Backstage has all the latest notifications and signals related functionality, it’s important to upgrade to the latest version. The [Backstage upgrade helper](https://backstage.github.io/upgrade-helper/) is a great tool to help ensure that you’ve made all the necessary changes during the upgrade! + +## About notifications + +Notifications are messages sent to either individual users or groups. +They are not intended for inter-process communication of any kind. + +There are two basic types of notifications: + +- **Broadcast**: Messages sent to all users of Backstage. +- **Entity**: Messages delivered to specific listed entities, such as Users or Groups. + +Example of use-cases: + +- System-wide announcements or alerts +- Notifications for component owners: e.g., build failures, successful deployments, new vulnerabilities +- Notifications for individuals: e.g., updates you have subscribed to, new required training courses +- Notifications pertaining to a particular entity in the catalog: A notification might apply to an entity and the owning team. + +## Configuration + +### Notifications Backend + +The Notifications backend plugin provides an API to create notifications, list notifications per logged-in user, and search based on parameters. + +The plugin uses a relational [database](https://backstage.io/docs/getting-started/config/database) for persistence, no specifics are introduced in this context. + +No additional configuration in the app-config is needed, except for optional additional modules for `processors`. + +### Notifications Frontend + +The recipients of notifications have to be entities in the catalog, e.g. of the User or Group kind. + +Otherwise no specific configuration is needed for the front-end notifications plugin. + +All parametrization is done through component properties, such as the `NotificationsSidebarItem`, which can be used as an active left-side menu item in the front-end. + +![Notifications Page](notificationsPage.png) + +## Use + +New notifications can be sent either by a backend plugin or an external service through the REST API. + +### Backend + +Regardless of technical feasibility, a backend plugin should avoid directly accessing the notifications REST API. +Instead, it should integrate with the `@backstage/plugin-notifications-node` to `send` (create) a new notification. + +The reasons for this approach include the propagation of authorization in the API request and improved maintenance and backward compatibility in the future. + +```ts +import { notificationService } from '@backstage/plugin-notifications-node'; + +export const myPlugin = createBackendPlugin({ + pluginId: 'myPlugin', + register(env) { + env.registerInit({ + deps: { + // ... + notificationService: notificationService, + }, + async init({ config, logger, httpRouter, notificationService }) { + httpRouter.use( + await createRouter({ + // ... + notificationService, + }), + ); + }, + }); + }, +}); +``` + +To emit a new notification: + +```ts +notificationService.send({ + recipients /* of the broadcast or entity type */, + payload /* actual message */, +}); +``` + +Refer the [API documentation](https://github.com/backstage/backstage/blob/master/plugins/notifications-node/api-report.md) for further details. + +### Signals + +The use of signals with notifications is optional but generally enhances user experience and performance. + +When a notification is created, a new signal is emitted to a general-purpose message bus to announce it to subscribed listeners. + +The frontend maintains a persistent connection (web socket) to receive these announcements from the notifications channel. +The specific details of the updated or created notification should be retrieved via a request to the notifications API, except for new notifications, where the payload is included in the signal for performance reasons. + +In a frontend plugin, to subscribe for notifications' signals: + +```ts +import { useSignal } from '@backstage/plugin-signals-react'; + +const { lastSignal } = useSignal('notifications'); + +React.useEffect(() => { + /* ... */ +}, [lastSignal, notificationsApi]); +``` + +### Consuming Notifications + +In a front-end plugin, the simplest way to query a notification is by its ID: + +```ts +import { useApi } from '@backstage/core-plugin-api'; +import { notificationsApiRef } from '@backstage/plugin-notifications'; + +const notificationsApi = useApi(notificationsApiRef); + +notificationsApi.getNotification(yourId); + +// or with connection to signals: +notificationsApi.getNotification(lastSignal.notification_id); +``` + +### External Services + +When the emitter of a notification is a Backstage backend plugin, it is mandatory to use the integration via `@backstage/plugin-notifications-node` as described above. + +If the emitter is a service external to Backstage, an HTTP POST request can be issued directly to the API, assuming that authentication is properly configured. +Refer to the service-to-service auth documentation for more details, focusing on the Static Tokens section for the simplest setup option. + +An example request for creating a broadcast notification might look like: + +```bash +curl -X POST https://[BACKSTAGE_BACKEND]/api/notifications -H "Content-Type: application/json" -H "Authorization: Bearer YOUR_BASE64_SHARED_KEY_TOKEN" -d '{"recipients":{"type":"broadcast"},"payload": {"title": "Title of broadcast message","link": "http://foo.com/bar","severity": "high","topic": "The topic"}}' +``` + +## Additional info + +Up-to-date documentation can be found in the plugins' README files: + +- https://github.com/backstage/backstage/blob/master/plugins/notifications/README.md + +- https://github.com/backstage/backstage/blob/master/plugins/notifications-backend/README.md + +- https://github.com/backstage/backstage/blob/master/plugins/notifications-node/README.md + +- https://github.com/backstage/backstage/blob/master/plugins/signals-react/README.md + +## Processors + +The default backend behavior when emitting a new notification can be tweaked using processors. + +Depending on the needs, a processor can modify the content of a notification or route it to different systems like email, Slack, or other services. + +A good example of how to write a processor is the [Email Processor](https://github.com/backstage/backstage/tree/master/plugins/notifications-backend-module-email). diff --git a/docs/notifications/notificationsPage.png b/docs/notifications/notificationsPage.png new file mode 100644 index 0000000000000000000000000000000000000000..7c96ab77af2d2d9527acefa99027468e4d5b3782 GIT binary patch literal 137787 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

nobr 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

-ZZF}2&0dyTfeHG1VxJoZ)&u~SsmQN;u%#Z`Xd zoGD`JV0~eq6uZXBFNr-kpQ%02{H4F`opMo<=^l|&ed;L95b6OYGsNY0Hf@SXas{__ zEo$>QnS4S1VX>tf!66<#LLIwK74%oe*O+GBduDoqwx;uo2A_e5rdOM7gSd~lr4bng zF5Jp23}U&Hq5(>FwfoAbU?`9}4$2cO*Ou6_JO^Hp+YUKu?!5h#s?&ngEdsbIE_~f@ zk+V{hClJMOTQ=RTWAOeIF7qHZYR7e?yag6VQG5$}H%x}Q=?&$kwA|P-qq2=D>*`Vj zhOL34rG9zRo%q@>`7afqp&~40DMCsBAgK_Z0O(f{kl5xW1}?1tVnD~nNiq@J6e|1>m*XjA~N{| z!Hs%q?AnYMr;7FtP&OWdra$IPBjc4Opm}4fW}tk4NTKlTGoQI zEeAB-w8ETDnquRBf8^*S3>@&u46s>5v)&0Tn(5clluU;Xjw_@{%N(*4QWZoiqVqo) zo8}!6zFBJ99_n15GDEN~c(=4`guV4)*I@qhT(;6Yfb>CEc&}Ops85s>6VUqS=`hr! zNmzHI`+SujGq}www8Hx%`(BD>MP0CPEMb)su9Di7A2){yW`v#r@?7Tp{VN_3&I6%0 zU7Ny=o7@bM4Z@nY9jxJ@p%UbI+9*C`(IJTN2BC&h3vNpW#O?xydddU|wIKQBj~Gc7 zenP57o+vmq)bOyckkSbX5QD#+q;t@o6@?OCgSXa0-TZ=F!1RQ;Wtuu+8mTDs|5Bm) zf>0#VZ!OmWdH?GySCbdLlfi%BDFcxz@9T3u{g^feEn zd07bJleSH#8CmF(@ar!BqD6>;d5^|3T+CLkxak9}KV~RP&bto=7_?efZ&By~33kg&sjUn3R zjXHCf#uZ8O384Pc;{Ob{tJk~#^PPsSkYuNLd8y59MDp^|&7L(KzGQUeKrmOW9K zBfsIE;-vEC* z)TH*&{(AC2SXf{46{N+1kl;vVw>6G-l4`#Z_zeXO8fK_%5oR4J#%#m=41xue4JH)hO~Wv25*@*0(lz-i z=zse%z(F8kLROBi;tX?Sy~qr6CN0aYp$7EVJgj#DNn@< zY~1`7$fE?I6JjIkur%nUbr$dhqZ@veadP*GLnFSMQnKP%+s#6jO+db=9CWRTrY9%n;IYxUa3sUjHi)BvOK=E=p%cDAxTzfu6+MMzDu1N_9hR+iV!wXd)_m)1Uz#6I*VQO{k?#D=ji`oC9c}&gAZ#lPmTR23m{Q zdEOGkxQa-aUau4j{X}Y?RRD-(B{-yop!)iw(og7V(BS#j+*XExKs(S+EAL7=EJ!UD z)P^GKaze2oBsnlWln}2Jpw3G^NJ{I3*B37^4fEIR(*{9l zn9vGRoprD1VDIx6*^IMh6bk1lxjnm%6*#XO4p|<*5Q*upjt;83ZN#j1**vtoqW;lM zWs@J#Y()jbv)DdXI?E$}#26ZbkWL!UUUJ2!^yeBA2?s*piG(etm)XN>^V^lf-+ud5oMT#=q{0u2wZhaq9FrRQPr7>&ot5(^GPWc^qv?1MktI zhj!yEADuuSKjRcJD3#GbcOXnC_ov1cAq~pD=fdxdI*jP$)SzB%ZtvbbtS#)!!QTBT zF1zDi^XRamt9<->KPnwnKAj;Z>74Z?S@C3pDXWY+bef!e@XtaZAt>jHVNy~srI%c5 zL6j2Q>(SBCK}as7d$35K?bq3N?)RpFJj)a}Y}9&$j|U080l{D>IIyZgFWi%a>P}lG z#Q$g#j+HQ~c$pc~qSWpiWgchDe?Ztg;H$Y^cu;?iPRC0nyN$$=5~?<7p(EV>gPN~n zbn`A77^qfxmNSYQO1^0=7oXZ>%}V1|RZlE+9}4WD!B(byi|=GBER_a@i1Zv1Y6RL**C*s39*6Q2Kj85QI;B9I%_;eUk1{?*FR^a%=O zZxu~nS!~u7ww|$L?G+p#B}iK~*+t-xh+uba+{;MwwA@^J?w-Ie1+!83NappW?@mhD zIyST96bu#e>|1>$Qhv5sk@wkSN)LV>`&>0!JapIgc$~uy;)Y2(AfZY_FrR<4KFI18a0QCcW8nL)a zYkf2q`q?Sa(05!iV)*f`?dbmpkoY+<>n+1L*2Wk8$ zikAj&Lka%Pln_SH6+l?JB=-3hux=${Kl_2gp!yiPMmC9}!i?=UVJ&g2s2y3GNPixQ zCo!*Xm?RJ0ROgeqcIz|6&zh6o&ZH}spRFFM;7)&|wV?0DLd6VZChmkd3dxiBdS88X ztkVm+@7Z+!@_;z#IxC(2`h@flF&Z_t#sYmZ^*Yi_Rl?i`+|htw$o!#XPchllUxKpt zOAq8XgS`fVb&4CbA#2G#AS7u)G)?E)KZKn+4^m_|#LXVWN(_n|5BuFa~YxLs<+3w=vg~g-b-`iWpJuEdv_Sg9@Uxnp~(bzk5 zBzvD7`+lOKQ=F&p>Ce+X-aky936>Pn=B#P`LK`6c; z17bQIByS>VSCod19XHz}!geiq+O~v5O(J{Jz+y_SeNb}%gMoY^i|F9C5qH{CY12l? z|Ad6s1Mf~!R|Tnhm)&zRRdoV9I5xjug_i6b!kHORIcu4cl#s*~Cf|;7`wRV%p8n8#q#q@ z5B`|zH`E7RiaLa3x%8BtmW`%;Vs*#}$pmC+{6mDmD`Y?x&k6lQ$% z!{aZ6Irw9W7_%AsKdd@QJr)5FeV}~`S0x&^R}RB9eH7g*Enlmt_u7CzBE&gpd{cHc zkUzXUMfAZVONay~5^TA1Vf1Bo5q9kFiQ5Lc8GLg0`0TFc(r5Q7WSVOQX7=XoTqPOX zRQ@JCNA>p!R@3wL_%pRq{e$m@MEaztIC}A&dE$kxa=!^fI1#3S8LI>Y@F4nPNFW7X z-a4>%UcPv70Ki>VcD6D>?()pq?Jf_z|FOs<#Q5My%(B6Jcf?PQMJ<(42VHBaM#~x1 z>Gsid3$F7)(jAYSYlGbsvq)bVnrq+ai?t{@3>3EMcRjeHdHc>VBE5>o{SKr0TU(lM z-;|44%IrR!K-(V=E*NWiMh-FqB@5zcJzVBg=+XEincjhQR@d6_n;b2Y(h-Isx|XSJ z%nl93!I{)i=pXfo-xHJpC4!memG=o*dI?fD0%v{b`2ZRe`SW|i_urgDls7?$dkLY` zFSkLt_23AZe!lsHi{BgU#`#@g;)_O2t&4(9X*TZ`$DnCjN3lzaOYY7EqyI{wg!zvK z2>oaHC(TT)w_!z;7mLG>`k;^NWpor)vLVpM2tp<;n?_(a%4eSLH%u{+fzQSWVSm|e z13``iF{dgxwGpWIe-X5QgkAL2l5hC7bsGhHxDpvR1XHJVHhdZIXN&fIHpY^55ZdB! zM2EZ_4IL5ha!KY-5)9Z@8icAy8w}Yr$r{G5!(y`t?%{0LtW^RLgD6B|i1EbdO8k}q zud3)x!_w^+59jS{dPCYoK<<)rMIN`7$PidknH9X5L_mT!6Fb&UbeJUNQa^Z(8XId7 zK<(0Gpx?S_PKtnJukr8SHsG}C08bE^r8j1s;IOkj5;yo(y8x02GpbwnN~8yYfPaB#&e{ zum>JJ?Zj0MH@+f1wD+Hi-GBrD&HV@BG~RMal-B^Ky8Iv=f|tJewsyaaAR(X|;) zPptc!aum!$!*>i>J@nJy+5_o!cgdJ-js>ZMS&c zUE(mozlW|qIVzoN}Pu3pj8YZ$?5ZwkYtXL#ch zz1Lxp$n8Rqmdd%393L$sro;TwOwwitVdhJN_5JK9uaz@BB z2nYdhXyeKYzdC|ds&;jqt8^kPcAkCMg-?hZ9x55+zZ!f7(jA|1n+X{0j zgn-~3Jq&)ZoGUT&kPym5SZ9K4MjMTzBn?;|ATx?uN2+Q}OA#wG_md|hQt*#^f{SeF=DyBzZDfdhv6Z(Lub3Qg9PdBzzGh3^4NLwWZ`^}qRc~xjA59> zc3{y4T`~9Q6YU9~8x4vCVTm93^|}yxzPxg1AtU6-9ADv0*fol-7`PL@eSQEh06}F} zZ7`PmnGALyX>SGJS|HGN_=#7AowI64$d=&rVj1*JO|2L2E-UWG+$`4Y<@TKXCtZMp zZv*vS3wf?9FHx3QUZ&u^<;fy@s5O{=S*+sz{LJZJVBpg5zWu;+-oyj^CJG41d1&hs zNX`^M5m~N7fELKcFTYarpqo3f=An2>6RjVi*Fjf^Kdwj73%UtfuEEIHB+4uC2rIv?B}Y)kH%$*K8^Lc3C~j}Z6Vje?ThYl3El5=& zf>6hZ;v@`{gV-gnAWCfu;cQ86DlkO}PK=x>Kugv2@OZ2X5t%T1mY7cke2EtUy8jph z`wytmAVxBQmG6#kiQ7bsBp{|#bqLsRS^qz|G6IG0Hh- z2*b@8>3YLz&#f*|Nox~L^&hamO=}HfYj22{aid{QB}eU2q=D=>7c<>gKs%CgL91V} zwA%I+kz*9*DEe>I5v0c)%D2}Hrb_?Lw(+#0F&!>b+cTKaZ8qALetSB&83Zq#`QixL8AUV--zqrok4IISA61Z9+VKr1UbhtE9zILu8$6!Jqdp0KGA__ z=}6cDAxYX!UCT@4r-r0s0T%`=4;QF2Lzoo}!96VYbN}Q%mQ54Y3!OuDb3lx)Zs7x_ zs70O%PVLJ2*{8oRLbnXrZU4%cOIXiYXk?F@j+ED>XL}gt3aO??V#LR-`h}eY9@^-zjGYip& zl$92ecse+2%U6XNDp~habH)%0KJZa+Lwu4gWDuq)o50yW+7Ony-W{c@#69_jzs^By zbhT260*@9dw_Rw%=ZKlBmAFicR@o&FO~Kqvcla?uQ8Pcbu`cm~Qr+e?Mx~JzKHN0f zX0JhpH;67)W@z=Vouk^=Fa2EyIrcwGJ>LxPhy{K=3P!e(H?BZ=m6troVvqW^v9y4D z3*8LIYpRSHmLNQ))K%>7Y)CpeEM=^}{KU}U9E)~t&SabD5)sDDxQL_i;GA>g4z>Lw(1i=oX>Iqsi%*P17&k)^&QBkrx?1cyLvZ#!WYLb}PxN|2pCcE^WTJq*}pZOt#3w zLduHbGJPVY>7l|uqWs>zVfn@D+b*2y`*W$Q-MA^s?Zw<3s|%W=3fp`8HEZ7e>m>eQ z`l{Kp*)NOpuTJn>YAJZ+xkBOa&~<2RZ${RFLC(=pTx(6mbjz}Xw&nb#uS?Z0q{AZ? zwK?74KB^A8JtO>7Rvmq}n}>f<+1{YwT92HFK@;!M!=JFX%ql3=q3OUbQPbPMTR16` uHPZ50)E({ck8C%roN#!A-;TdRWUn1-8vLIKDkr|8sPS0qwMMo&X#fA)xZc Date: Mon, 17 Jun 2024 14:12:38 +0200 Subject: [PATCH 008/372] feat: add listBranchesByRepository method to BitbucketCloudClient Signed-off-by: Benjamin Janssens --- .../src/BitbucketCloudClient.ts | 20 +++++++++++++++++++ .../src/models/index.ts | 11 ++++++++++ 2 files changed, 31 insertions(+) diff --git a/plugins/bitbucket-cloud-common/src/BitbucketCloudClient.ts b/plugins/bitbucket-cloud-common/src/BitbucketCloudClient.ts index f1b7d60e41..86f56dd70d 100644 --- a/plugins/bitbucket-cloud-common/src/BitbucketCloudClient.ts +++ b/plugins/bitbucket-cloud-common/src/BitbucketCloudClient.ts @@ -95,6 +95,26 @@ export class BitbucketCloudClient { ); } + listBranchesByRepository( + repository: string, + workspace: string, + options?: FilterAndSortOptions & PartialResponseOptions, + ): WithPagination { + const workspaceEnc = encodeURIComponent(workspace); + + return new WithPagination( + paginationOptions => + this.createUrl( + `/repositories/${workspaceEnc}/${repository}/refs/branches`, + { + ...paginationOptions, + ...options, + }, + ), + url => this.getTypeMapped(url), + ); + } + private createUrl(endpoint: string, options?: RequestOptions): URL { const request = new URL(this.config.apiBaseUrl + endpoint); for (const key in options) { diff --git a/plugins/bitbucket-cloud-common/src/models/index.ts b/plugins/bitbucket-cloud-common/src/models/index.ts index 2cdc143d06..28b1b45e1b 100644 --- a/plugins/bitbucket-cloud-common/src/models/index.ts +++ b/plugins/bitbucket-cloud-common/src/models/index.ts @@ -275,6 +275,17 @@ export namespace Models { values?: Set; } + /** + * A paginated list of branches. + * @public + */ + export interface PaginatedBranches extends Paginated { + /** + * The values of the current page. + */ + values?: Set; + } + /** * Object describing a user's role on resources like commits or pull requests. * @public From 7ee5682ad467090c3cb99866968a1efddfef1eb9 Mon Sep 17 00:00:00 2001 From: Benjamin Janssens Date: Mon, 17 Jun 2024 14:18:07 +0200 Subject: [PATCH 009/372] feat: add branches resource to autocomplete endpoint for bitbucket Signed-off-by: Benjamin Janssens --- .../src/autocomplete/autocomplete.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/plugins/scaffolder-backend-module-bitbucket-cloud/src/autocomplete/autocomplete.ts b/plugins/scaffolder-backend-module-bitbucket-cloud/src/autocomplete/autocomplete.ts index 31a2103088..70824995ac 100644 --- a/plugins/scaffolder-backend-module-bitbucket-cloud/src/autocomplete/autocomplete.ts +++ b/plugins/scaffolder-backend-module-bitbucket-cloud/src/autocomplete/autocomplete.ts @@ -77,6 +77,23 @@ export async function handleAutocompleteRequest({ return { results: result.map(title => ({ title })) }; } + case 'branches': { + if (!parameters.workspace || !parameters.repository) + throw new InputError( + 'Missing workspace and/or repository query parameter', + ); + + const result: string[] = []; + + for await (const page of client + .listBranchesByRepository(parameters.repository, parameters.workspace) + .iteratePages()) { + const names = [...page.values!].map(p => p.name!); + result.push(...names); + } + + return result; + } default: throw new InputError(`Invalid resource: ${resource}`); } From f6fea341737fd8e1820d882b5c4eeb2c2d4abb25 Mon Sep 17 00:00:00 2001 From: Benjamin Janssens Date: Mon, 17 Jun 2024 16:32:15 +0200 Subject: [PATCH 010/372] feat: add BitbucketRepoBranchPicker Signed-off-by: Benjamin Janssens --- .../BitbucketRepoBranchPicker.tsx | 145 ++++++++++++++++++ .../fields/BitbucketRepoBranchPicker/index.ts | 20 +++ .../BitbucketRepoBranchPicker/schema.ts | 82 ++++++++++ plugins/scaffolder/src/extensions/default.ts | 7 + plugins/scaffolder/src/index.ts | 1 + plugins/scaffolder/src/plugin.tsx | 15 ++ 6 files changed, 270 insertions(+) create mode 100644 plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.tsx create mode 100644 plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/index.ts create mode 100644 plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/schema.ts diff --git a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.tsx b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.tsx new file mode 100644 index 0000000000..df496516af --- /dev/null +++ b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.tsx @@ -0,0 +1,145 @@ +/* + * Copyright 2024 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 { + scaffolderApiRef, + useTemplateSecrets, +} from '@backstage/plugin-scaffolder-react'; +import FormControl from '@material-ui/core/FormControl'; +import React, { useEffect, useMemo, useState } from 'react'; +import TextField from '@material-ui/core/TextField'; +import Autocomplete from '@material-ui/lab/Autocomplete'; +import useDebounce from 'react-use/esm/useDebounce'; +import { useApi } from '@backstage/core-plugin-api'; +import { scmAuthApiRef } from '@backstage/integration-react'; +import { BitbucketRepoBranchPickerProps } from './schema'; + +export const BitbucketRepoBranchPicker = ({ + onChange, + rawErrors, + required, + formData, + formContext: { + formData: { repoUrl }, + }, + uiSchema, +}: BitbucketRepoBranchPickerProps) => { + const { secrets, setSecrets } = useTemplateSecrets(); + + const accessToken = useMemo( + () => + uiSchema?.['ui:options']?.requestUserCredentials?.secretsKey && + secrets[uiSchema['ui:options'].requestUserCredentials.secretsKey], + [secrets, uiSchema], + ); + + const [host, setHost] = useState(); + const [workspace, setWorkspace] = useState(null); + const [repository, setRepository] = useState(null); + const [availableBranches, setAvailableBranches] = useState([]); + + const scmAuthApi = useApi(scmAuthApiRef); + const scaffolderApi = useApi(scaffolderApiRef); + + useEffect(() => { + if (repoUrl) { + const url = new URL(`https://${repoUrl}`); + setHost(url.host); + setWorkspace(url.searchParams.get('workspace')); + setRepository(url.searchParams.get('repo')); + } + }, [repoUrl]); + + useDebounce( + async () => { + const { requestUserCredentials } = uiSchema?.['ui:options'] ?? {}; + + if (!requestUserCredentials || !host) { + return; + } + + // don't show login prompt if secret value is already in state + if (secrets[requestUserCredentials.secretsKey]) { + return; + } + + // user has requested that we use the users credentials + // so lets grab them using the scmAuthApi and pass through + // any additional scopes from the ui:options + const { token } = await scmAuthApi.getCredentials({ + url: `https://${host}`, + additionalScope: { + repoWrite: true, + customScopes: requestUserCredentials.additionalScopes, + }, + }); + + // set the secret using the key provided in the ui:options for use + // in the templating the manifest with ${{ secrets[secretsKey] }} + setSecrets({ [requestUserCredentials.secretsKey]: token }); + }, + 500, + [host, uiSchema], + ); + + useDebounce( + () => { + const updateAvailableBranches = async () => { + if ( + host === 'bitbucket.org' && + accessToken && + workspace && + repository + ) { + const result = await scaffolderApi.autocomplete( + accessToken, + 'bitbucketCloud', + 'branches', + { workspace, repository }, + ); + + setAvailableBranches(result); + } else { + setAvailableBranches([]); + } + }; + + updateAvailableBranches().catch(() => setAvailableBranches([])); + }, + 500, + [host, accessToken, workspace, repository], + ); + + return ( + 0 && !formData} + > + { + onChange(newValue || ''); + }} + options={availableBranches} + renderInput={params => ( + + )} + freeSolo + autoSelect + /> + + ); +}; diff --git a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/index.ts b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/index.ts new file mode 100644 index 0000000000..df9acbd8b9 --- /dev/null +++ b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/index.ts @@ -0,0 +1,20 @@ +/* + * Copyright 2024 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 { + BitbucketRepoBranchPickerFieldSchema, + type BitbucketRepoBranchPickerUiOptions, +} from './schema'; diff --git a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/schema.ts b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/schema.ts new file mode 100644 index 0000000000..3e14888ed5 --- /dev/null +++ b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/schema.ts @@ -0,0 +1,82 @@ +/* + * Copyright 2024 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 { z } from 'zod'; +import { makeFieldSchemaFromZod } from '../utils'; + +/** + * @public + */ +export const BitbucketRepoBranchPickerFieldSchema = makeFieldSchemaFromZod( + z.string(), + z.object({ + requestUserCredentials: z + .object({ + secretsKey: z + .string() + .describe( + 'Key used within the template secrets context to store the credential', + ), + additionalScopes: z + .object({ + gitea: z + .array(z.string()) + .optional() + .describe('Additional Gitea scopes to request'), + gerrit: z + .array(z.string()) + .optional() + .describe('Additional Gerrit scopes to request'), + github: z + .array(z.string()) + .optional() + .describe('Additional GitHub scopes to request'), + gitlab: z + .array(z.string()) + .optional() + .describe('Additional GitLab scopes to request'), + bitbucket: z + .array(z.string()) + .optional() + .describe('Additional BitBucket scopes to request'), + azure: z + .array(z.string()) + .optional() + .describe('Additional Azure scopes to request'), + }) + .optional() + .describe('Additional permission scopes to request'), + }) + .optional() + .describe( + 'If defined will request user credentials to auth against the given SCM platform', + ), + }), +); + +/** + * The input props that can be specified under `ui:options` for the + * `BitbucketRepoBranchPicker` field extension. + * + * @public + */ +export type BitbucketRepoBranchPickerUiOptions = + typeof BitbucketRepoBranchPickerFieldSchema.uiOptionsType; + +export type BitbucketRepoBranchPickerProps = + typeof BitbucketRepoBranchPickerFieldSchema.type; + +export const BitbucketRepoBranchPickerSchema = + BitbucketRepoBranchPickerFieldSchema.schema; diff --git a/plugins/scaffolder/src/extensions/default.ts b/plugins/scaffolder/src/extensions/default.ts index a59f3e08e3..13a719e9f9 100644 --- a/plugins/scaffolder/src/extensions/default.ts +++ b/plugins/scaffolder/src/extensions/default.ts @@ -50,6 +50,8 @@ import { MultiEntityPickerSchema, validateMultiEntityPickerValidation, } from '../components/fields/MultiEntityPicker/MultiEntityPicker'; +import { BitbucketRepoBranchPicker } from '../components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker'; +import { BitbucketRepoBranchPickerSchema } from '../components/fields/BitbucketRepoBranchPicker/schema'; export const DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS = [ { @@ -99,4 +101,9 @@ export const DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS = [ schema: MultiEntityPickerSchema, validation: validateMultiEntityPickerValidation, }, + { + component: BitbucketRepoBranchPicker, + name: 'BitbucketRepoBranchPicker', + schema: BitbucketRepoBranchPickerSchema, + }, ]; diff --git a/plugins/scaffolder/src/index.ts b/plugins/scaffolder/src/index.ts index d809ec00f9..d343311db9 100644 --- a/plugins/scaffolder/src/index.ts +++ b/plugins/scaffolder/src/index.ts @@ -30,6 +30,7 @@ export { MyGroupsPickerFieldExtension, RepoUrlPickerFieldExtension, MultiEntityPickerFieldExtension, + BitbucketRepoBranchPickerFieldExtension, ScaffolderPage, scaffolderPlugin, } from './plugin'; diff --git a/plugins/scaffolder/src/plugin.tsx b/plugins/scaffolder/src/plugin.tsx index c053bfacd9..453e5ea63a 100644 --- a/plugins/scaffolder/src/plugin.tsx +++ b/plugins/scaffolder/src/plugin.tsx @@ -73,6 +73,8 @@ import { MyGroupsPicker, MyGroupsPickerSchema, } from './components/fields/MyGroupsPicker/MyGroupsPicker'; +import { BitbucketRepoBranchPicker } from './components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker'; +import { BitbucketRepoBranchPickerSchema } from './components/fields/BitbucketRepoBranchPicker/schema'; /** * The main plugin export for the scaffolder. @@ -231,3 +233,16 @@ export const EntityTagsPickerFieldExtension = scaffolderPlugin.provide( schema: EntityTagsPickerSchema, }), ); + +/** + * A field extension to select a branch from a repository. + * + * @public + */ +export const BitbucketRepoBranchPickerFieldExtension = scaffolderPlugin.provide( + createScaffolderFieldExtension({ + component: BitbucketRepoBranchPicker, + name: 'BitbucketRepoBranchPicker', + schema: BitbucketRepoBranchPickerSchema, + }), +); From 741837a560f16369b3aadce4294e02726e5732e8 Mon Sep 17 00:00:00 2001 From: Benjamin Janssens Date: Tue, 18 Jun 2024 11:42:20 +0200 Subject: [PATCH 011/372] refactor: add generic RepoBranchPicker Signed-off-by: Benjamin Janssens --- .../BitbucketRepoBranchPicker.tsx | 109 ++++----------- .../RepoBranchPicker.tsx | 125 ++++++++++++++++++ .../fields/BitbucketRepoBranchPicker/index.ts | 4 +- .../BitbucketRepoBranchPicker/schema.ts | 14 +- .../fields/BitbucketRepoBranchPicker/types.ts | 23 ++++ plugins/scaffolder/src/extensions/default.ts | 10 +- plugins/scaffolder/src/index.ts | 2 +- plugins/scaffolder/src/plugin.tsx | 12 +- 8 files changed, 194 insertions(+), 105 deletions(-) create mode 100644 plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/RepoBranchPicker.tsx create mode 100644 plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/types.ts diff --git a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.tsx b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.tsx index df496516af..736841b7a6 100644 --- a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.tsx +++ b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.tsx @@ -14,128 +14,71 @@ * limitations under the License. */ -import { - scaffolderApiRef, - useTemplateSecrets, -} from '@backstage/plugin-scaffolder-react'; +import { scaffolderApiRef } from '@backstage/plugin-scaffolder-react'; import FormControl from '@material-ui/core/FormControl'; -import React, { useEffect, useMemo, useState } from 'react'; +import React from 'react'; import TextField from '@material-ui/core/TextField'; import Autocomplete from '@material-ui/lab/Autocomplete'; import useDebounce from 'react-use/esm/useDebounce'; import { useApi } from '@backstage/core-plugin-api'; -import { scmAuthApiRef } from '@backstage/integration-react'; -import { BitbucketRepoBranchPickerProps } from './schema'; +import { RepoBranchPickerState } from './types'; export const BitbucketRepoBranchPicker = ({ onChange, + state, rawErrors, - required, - formData, - formContext: { - formData: { repoUrl }, - }, - uiSchema, -}: BitbucketRepoBranchPickerProps) => { - const { secrets, setSecrets } = useTemplateSecrets(); - - const accessToken = useMemo( - () => - uiSchema?.['ui:options']?.requestUserCredentials?.secretsKey && - secrets[uiSchema['ui:options'].requestUserCredentials.secretsKey], - [secrets, uiSchema], - ); - - const [host, setHost] = useState(); - const [workspace, setWorkspace] = useState(null); - const [repository, setRepository] = useState(null); - const [availableBranches, setAvailableBranches] = useState([]); - - const scmAuthApi = useApi(scmAuthApiRef); + accessToken, +}: { + onChange: (state: RepoBranchPickerState) => void; + state: RepoBranchPickerState; + rawErrors: string[]; + accessToken?: string; +}) => { const scaffolderApi = useApi(scaffolderApiRef); - useEffect(() => { - if (repoUrl) { - const url = new URL(`https://${repoUrl}`); - setHost(url.host); - setWorkspace(url.searchParams.get('workspace')); - setRepository(url.searchParams.get('repo')); - } - }, [repoUrl]); - - useDebounce( - async () => { - const { requestUserCredentials } = uiSchema?.['ui:options'] ?? {}; - - if (!requestUserCredentials || !host) { - return; - } - - // don't show login prompt if secret value is already in state - if (secrets[requestUserCredentials.secretsKey]) { - return; - } - - // user has requested that we use the users credentials - // so lets grab them using the scmAuthApi and pass through - // any additional scopes from the ui:options - const { token } = await scmAuthApi.getCredentials({ - url: `https://${host}`, - additionalScope: { - repoWrite: true, - customScopes: requestUserCredentials.additionalScopes, - }, - }); - - // set the secret using the key provided in the ui:options for use - // in the templating the manifest with ${{ secrets[secretsKey] }} - setSecrets({ [requestUserCredentials.secretsKey]: token }); - }, - 500, - [host, uiSchema], - ); - useDebounce( () => { const updateAvailableBranches = async () => { if ( - host === 'bitbucket.org' && + state.host === 'bitbucket.org' && accessToken && - workspace && - repository + state.workspace && + state.repository ) { const result = await scaffolderApi.autocomplete( accessToken, 'bitbucketCloud', 'branches', - { workspace, repository }, + { workspace: state.workspace, repository: state.repository }, ); - setAvailableBranches(result); + onChange({ availableBranches: result }); } else { - setAvailableBranches([]); + onChange({ availableBranches: [] }); } }; - updateAvailableBranches().catch(() => setAvailableBranches([])); + updateAvailableBranches().catch(() => + onChange({ availableBranches: [] }), + ); }, 500, - [host, accessToken, workspace, repository], + [state, accessToken], ); return ( 0 && !formData} + required + error={rawErrors?.length > 0 && !state.branch} > { - onChange(newValue || ''); + onChange({ branch: newValue || undefined }); }} - options={availableBranches} + options={state.availableBranches || []} renderInput={params => ( - + )} freeSolo autoSelect diff --git a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/RepoBranchPicker.tsx b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/RepoBranchPicker.tsx new file mode 100644 index 0000000000..1f75090e3b --- /dev/null +++ b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/RepoBranchPicker.tsx @@ -0,0 +1,125 @@ +/* + * Copyright 2024 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 { useApi } from '@backstage/core-plugin-api'; +import { + scmIntegrationsApiRef, + scmAuthApiRef, +} from '@backstage/integration-react'; +import React, { useEffect, useState, useCallback } from 'react'; +import { RepoBranchPickerProps } from './schema'; +import { RepoBranchPickerState } from './types'; +import useDebounce from 'react-use/esm/useDebounce'; +import { useTemplateSecrets } from '@backstage/plugin-scaffolder-react'; +import Box from '@material-ui/core/Box'; +import Divider from '@material-ui/core/Divider'; +import Typography from '@material-ui/core/Typography'; +import { BitbucketRepoBranchPicker } from './BitbucketRepoBranchPicker'; + +/** + * The underlying component that is rendered in the form for the `RepoBranchPicker` + * field extension. + * + * @public + */ +export const RepoBranchPicker = (props: RepoBranchPickerProps) => { + const { uiSchema, onChange, rawErrors, schema, formContext } = props; + const [state, setState] = useState({}); + const integrationApi = useApi(scmIntegrationsApiRef); + const scmAuthApi = useApi(scmAuthApiRef); + const { secrets, setSecrets } = useTemplateSecrets(); + + useEffect(() => { + if (formContext.formData.repoUrl) { + const url = new URL(`https://${formContext.formData.repoUrl}`); + + setState({ + host: url.host, + workspace: url.searchParams.get('workspace') || undefined, + repository: url.searchParams.get('repo') || undefined, + }); + } + }, [formContext]); + + useEffect(() => { + onChange(state.branch); + }, [state, onChange]); + + const updateLocalState = useCallback( + (newState: RepoBranchPickerState) => { + setState(prevState => ({ ...prevState, ...newState })); + }, + [setState], + ); + + useDebounce( + async () => { + const { requestUserCredentials } = uiSchema?.['ui:options'] ?? {}; + + if (!requestUserCredentials || !state.host) { + return; + } + + // don't show login prompt if secret value is already in state + if (secrets[requestUserCredentials.secretsKey]) { + return; + } + + // user has requested that we use the users credentials + // so lets grab them using the scmAuthApi and pass through + // any additional scopes from the ui:options + const { token } = await scmAuthApi.getCredentials({ + url: `https://${state.host}`, + additionalScope: { + repoWrite: true, + customScopes: requestUserCredentials.additionalScopes, + }, + }); + + // set the secret using the key provided in the ui:options for use + // in the templating the manifest with ${{ secrets[secretsKey] }} + setSecrets({ [requestUserCredentials.secretsKey]: token }); + }, + 500, + [state, uiSchema], + ); + + const hostType = + (state.host && integrationApi.byHost(state.host)?.type) ?? null; + return ( + <> + {schema.title && ( + + {schema.title} + + + )} + {schema.description && ( + {schema.description} + )} + {hostType === 'bitbucket' && ( + + )} + + ); +}; diff --git a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/index.ts b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/index.ts index df9acbd8b9..2b87b62ebd 100644 --- a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/index.ts +++ b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/index.ts @@ -15,6 +15,6 @@ */ export { - BitbucketRepoBranchPickerFieldSchema, - type BitbucketRepoBranchPickerUiOptions, + RepoBranchPickerFieldSchema, + type RepoBranchPickerUiOptions, } from './schema'; diff --git a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/schema.ts b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/schema.ts index 3e14888ed5..12ed07fd80 100644 --- a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/schema.ts +++ b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/schema.ts @@ -19,7 +19,7 @@ import { makeFieldSchemaFromZod } from '../utils'; /** * @public */ -export const BitbucketRepoBranchPickerFieldSchema = makeFieldSchemaFromZod( +export const RepoBranchPickerFieldSchema = makeFieldSchemaFromZod( z.string(), z.object({ requestUserCredentials: z @@ -68,15 +68,13 @@ export const BitbucketRepoBranchPickerFieldSchema = makeFieldSchemaFromZod( /** * The input props that can be specified under `ui:options` for the - * `BitbucketRepoBranchPicker` field extension. + * `RepoBranchPicker` field extension. * * @public */ -export type BitbucketRepoBranchPickerUiOptions = - typeof BitbucketRepoBranchPickerFieldSchema.uiOptionsType; +export type RepoBranchPickerUiOptions = + typeof RepoBranchPickerFieldSchema.uiOptionsType; -export type BitbucketRepoBranchPickerProps = - typeof BitbucketRepoBranchPickerFieldSchema.type; +export type RepoBranchPickerProps = typeof RepoBranchPickerFieldSchema.type; -export const BitbucketRepoBranchPickerSchema = - BitbucketRepoBranchPickerFieldSchema.schema; +export const RepoBranchPickerSchema = RepoBranchPickerFieldSchema.schema; diff --git a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/types.ts b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/types.ts new file mode 100644 index 0000000000..4843ff767e --- /dev/null +++ b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/types.ts @@ -0,0 +1,23 @@ +/* + * Copyright 2024 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 interface RepoBranchPickerState { + host?: string; + workspace?: string; + repository?: string; + branch?: string; + availableBranches?: string[]; +} diff --git a/plugins/scaffolder/src/extensions/default.ts b/plugins/scaffolder/src/extensions/default.ts index 13a719e9f9..409372e421 100644 --- a/plugins/scaffolder/src/extensions/default.ts +++ b/plugins/scaffolder/src/extensions/default.ts @@ -50,8 +50,8 @@ import { MultiEntityPickerSchema, validateMultiEntityPickerValidation, } from '../components/fields/MultiEntityPicker/MultiEntityPicker'; -import { BitbucketRepoBranchPicker } from '../components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker'; -import { BitbucketRepoBranchPickerSchema } from '../components/fields/BitbucketRepoBranchPicker/schema'; +import { RepoBranchPicker } from '../components/fields/BitbucketRepoBranchPicker/RepoBranchPicker'; +import { RepoBranchPickerSchema } from '../components/fields/BitbucketRepoBranchPicker/schema'; export const DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS = [ { @@ -102,8 +102,8 @@ export const DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS = [ validation: validateMultiEntityPickerValidation, }, { - component: BitbucketRepoBranchPicker, - name: 'BitbucketRepoBranchPicker', - schema: BitbucketRepoBranchPickerSchema, + component: RepoBranchPicker, + name: 'RepoBranchPicker', + schema: RepoBranchPickerSchema, }, ]; diff --git a/plugins/scaffolder/src/index.ts b/plugins/scaffolder/src/index.ts index d343311db9..c5709f1080 100644 --- a/plugins/scaffolder/src/index.ts +++ b/plugins/scaffolder/src/index.ts @@ -30,7 +30,7 @@ export { MyGroupsPickerFieldExtension, RepoUrlPickerFieldExtension, MultiEntityPickerFieldExtension, - BitbucketRepoBranchPickerFieldExtension, + RepoBranchPickerFieldExtension, ScaffolderPage, scaffolderPlugin, } from './plugin'; diff --git a/plugins/scaffolder/src/plugin.tsx b/plugins/scaffolder/src/plugin.tsx index 453e5ea63a..6f4e28c9b0 100644 --- a/plugins/scaffolder/src/plugin.tsx +++ b/plugins/scaffolder/src/plugin.tsx @@ -73,8 +73,8 @@ import { MyGroupsPicker, MyGroupsPickerSchema, } from './components/fields/MyGroupsPicker/MyGroupsPicker'; -import { BitbucketRepoBranchPicker } from './components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker'; -import { BitbucketRepoBranchPickerSchema } from './components/fields/BitbucketRepoBranchPicker/schema'; +import { RepoBranchPicker } from './components/fields/BitbucketRepoBranchPicker/RepoBranchPicker'; +import { RepoBranchPickerSchema } from './components/fields/BitbucketRepoBranchPicker/schema'; /** * The main plugin export for the scaffolder. @@ -239,10 +239,10 @@ export const EntityTagsPickerFieldExtension = scaffolderPlugin.provide( * * @public */ -export const BitbucketRepoBranchPickerFieldExtension = scaffolderPlugin.provide( +export const RepoBranchPickerFieldExtension = scaffolderPlugin.provide( createScaffolderFieldExtension({ - component: BitbucketRepoBranchPicker, - name: 'BitbucketRepoBranchPicker', - schema: BitbucketRepoBranchPickerSchema, + component: RepoBranchPicker, + name: 'RepoBranchPicker', + schema: RepoBranchPickerSchema, }), ); From 3a272ac051baf5be2417be598a591859f4ef30b3 Mon Sep 17 00:00:00 2001 From: Benjamin Janssens Date: Tue, 18 Jun 2024 11:54:00 +0200 Subject: [PATCH 012/372] chore: code cleanup Signed-off-by: Benjamin Janssens --- .../BitbucketRepoBranchPicker.tsx | 14 ++--- .../RepoBranchPicker.tsx | 54 ++++++++++--------- 2 files changed, 37 insertions(+), 31 deletions(-) diff --git a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.tsx b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.tsx index 736841b7a6..70f4ea8c36 100644 --- a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.tsx +++ b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.tsx @@ -34,22 +34,24 @@ export const BitbucketRepoBranchPicker = ({ rawErrors: string[]; accessToken?: string; }) => { + const { host, workspace, repository, branch, availableBranches } = state; + const scaffolderApi = useApi(scaffolderApiRef); useDebounce( () => { const updateAvailableBranches = async () => { if ( - state.host === 'bitbucket.org' && + host === 'bitbucket.org' && accessToken && - state.workspace && - state.repository + workspace && + repository ) { const result = await scaffolderApi.autocomplete( accessToken, 'bitbucketCloud', 'branches', - { workspace: state.workspace, repository: state.repository }, + { workspace, repository }, ); onChange({ availableBranches: result }); @@ -70,13 +72,13 @@ export const BitbucketRepoBranchPicker = ({ 0 && !state.branch} + error={rawErrors?.length > 0 && !branch} > { onChange({ branch: newValue || undefined }); }} - options={state.availableBranches || []} + options={availableBranches || []} renderInput={params => ( )} diff --git a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/RepoBranchPicker.tsx b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/RepoBranchPicker.tsx index 1f75090e3b..c690a58f4a 100644 --- a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/RepoBranchPicker.tsx +++ b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/RepoBranchPicker.tsx @@ -36,34 +36,15 @@ import { BitbucketRepoBranchPicker } from './BitbucketRepoBranchPicker'; */ export const RepoBranchPicker = (props: RepoBranchPickerProps) => { const { uiSchema, onChange, rawErrors, schema, formContext } = props; + const [state, setState] = useState({}); + const { host, branch } = state; + const integrationApi = useApi(scmIntegrationsApiRef); const scmAuthApi = useApi(scmAuthApiRef); + const { secrets, setSecrets } = useTemplateSecrets(); - useEffect(() => { - if (formContext.formData.repoUrl) { - const url = new URL(`https://${formContext.formData.repoUrl}`); - - setState({ - host: url.host, - workspace: url.searchParams.get('workspace') || undefined, - repository: url.searchParams.get('repo') || undefined, - }); - } - }, [formContext]); - - useEffect(() => { - onChange(state.branch); - }, [state, onChange]); - - const updateLocalState = useCallback( - (newState: RepoBranchPickerState) => { - setState(prevState => ({ ...prevState, ...newState })); - }, - [setState], - ); - useDebounce( async () => { const { requestUserCredentials } = uiSchema?.['ui:options'] ?? {}; @@ -96,8 +77,31 @@ export const RepoBranchPicker = (props: RepoBranchPickerProps) => { [state, uiSchema], ); - const hostType = - (state.host && integrationApi.byHost(state.host)?.type) ?? null; + useEffect(() => { + if (formContext.formData.repoUrl) { + const url = new URL(`https://${formContext.formData.repoUrl}`); + + setState({ + host: url.host, + workspace: url.searchParams.get('workspace') || undefined, + repository: url.searchParams.get('repo') || undefined, + }); + } + }, [formContext]); + + useEffect(() => { + onChange(branch); + }, [branch, onChange]); + + const updateLocalState = useCallback( + (newState: RepoBranchPickerState) => { + setState(prevState => ({ ...prevState, ...newState })); + }, + [setState], + ); + + const hostType = (host && integrationApi.byHost(host)?.type) ?? null; + return ( <> {schema.title && ( From 4e3ba7ca74ed3e675e607ceb88d0c1759b65442d Mon Sep 17 00:00:00 2001 From: Benjamin Janssens Date: Tue, 18 Jun 2024 13:37:38 +0200 Subject: [PATCH 013/372] chore: code cleanup Signed-off-by: Benjamin Janssens --- .../BitbucketRepoBranchPicker.tsx | 7 ++-- .../RepoBranchPicker.tsx | 32 ++++++++++++------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.tsx b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.tsx index 70f4ea8c36..27a0b5c027 100644 --- a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.tsx +++ b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.tsx @@ -22,6 +22,7 @@ import Autocomplete from '@material-ui/lab/Autocomplete'; import useDebounce from 'react-use/esm/useDebounce'; import { useApi } from '@backstage/core-plugin-api'; import { RepoBranchPickerState } from './types'; +import FormHelperText from '@material-ui/core/FormHelperText'; export const BitbucketRepoBranchPicker = ({ onChange, @@ -65,7 +66,7 @@ export const BitbucketRepoBranchPicker = ({ ); }, 500, - [state, accessToken], + [host, workspace, repository, accessToken], ); return ( @@ -75,8 +76,9 @@ export const BitbucketRepoBranchPicker = ({ error={rawErrors?.length > 0 && !branch} > { - onChange({ branch: newValue || undefined }); + onChange({ branch: newValue || '' }); }} options={availableBranches || []} renderInput={params => ( @@ -85,6 +87,7 @@ export const BitbucketRepoBranchPicker = ({ freeSolo autoSelect /> + The branch of the repository ); }; diff --git a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/RepoBranchPicker.tsx b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/RepoBranchPicker.tsx index c690a58f4a..2ba1eddbfc 100644 --- a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/RepoBranchPicker.tsx +++ b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/RepoBranchPicker.tsx @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import { useApi } from '@backstage/core-plugin-api'; import { scmIntegrationsApiRef, @@ -35,9 +36,15 @@ import { BitbucketRepoBranchPicker } from './BitbucketRepoBranchPicker'; * @public */ export const RepoBranchPicker = (props: RepoBranchPickerProps) => { - const { uiSchema, onChange, rawErrors, schema, formContext } = props; + const { uiSchema, onChange, rawErrors, formData, schema, formContext } = + props; + const { + formData: { repoUrl }, + } = formContext; - const [state, setState] = useState({}); + const [state, setState] = useState({ + branch: formData || '', + }); const { host, branch } = state; const integrationApi = useApi(scmIntegrationsApiRef); @@ -49,7 +56,7 @@ export const RepoBranchPicker = (props: RepoBranchPickerProps) => { async () => { const { requestUserCredentials } = uiSchema?.['ui:options'] ?? {}; - if (!requestUserCredentials || !state.host) { + if (!requestUserCredentials || !host) { return; } @@ -62,7 +69,7 @@ export const RepoBranchPicker = (props: RepoBranchPickerProps) => { // so lets grab them using the scmAuthApi and pass through // any additional scopes from the ui:options const { token } = await scmAuthApi.getCredentials({ - url: `https://${state.host}`, + url: `https://${host}`, additionalScope: { repoWrite: true, customScopes: requestUserCredentials.additionalScopes, @@ -74,20 +81,21 @@ export const RepoBranchPicker = (props: RepoBranchPickerProps) => { setSecrets({ [requestUserCredentials.secretsKey]: token }); }, 500, - [state, uiSchema], + [host, uiSchema], ); useEffect(() => { - if (formContext.formData.repoUrl) { - const url = new URL(`https://${formContext.formData.repoUrl}`); + if (repoUrl) { + const url = new URL(`https://${repoUrl}`); - setState({ + setState(prevState => ({ + ...prevState, host: url.host, - workspace: url.searchParams.get('workspace') || undefined, - repository: url.searchParams.get('repo') || undefined, - }); + workspace: url.searchParams.get('workspace') || '', + repository: url.searchParams.get('repo') || '', + })); } - }, [formContext]); + }, [repoUrl]); useEffect(() => { onChange(branch); From fb528a9196450b09667950fa293108ce7f83dca4 Mon Sep 17 00:00:00 2001 From: Benjamin Janssens Date: Tue, 18 Jun 2024 14:44:12 +0200 Subject: [PATCH 014/372] refactor: move availableBranches from RepoBranchPickerState to BitbucketRepoBranchPicker; add tests for BitbucketRepoBranchPicker Signed-off-by: Benjamin Janssens --- .../BitbucketRepoBranchPicker.test.tsx | 105 ++++++++++++++++++ .../BitbucketRepoBranchPicker.tsx | 16 +-- .../fields/BitbucketRepoBranchPicker/types.ts | 1 - 3 files changed, 113 insertions(+), 9 deletions(-) create mode 100644 plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.test.tsx diff --git a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.test.tsx b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.test.tsx new file mode 100644 index 0000000000..6cbc561bc9 --- /dev/null +++ b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.test.tsx @@ -0,0 +1,105 @@ +/* + * Copyright 2024 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 { + ScaffolderApi, + scaffolderApiRef, +} from '@backstage/plugin-scaffolder-react'; +import { BitbucketRepoBranchPicker } from './BitbucketRepoBranchPicker'; +import { act, fireEvent, render, waitFor } from '@testing-library/react'; +import { TestApiProvider } from '@backstage/test-utils'; +import userEvent from '@testing-library/user-event'; + +describe('BitbucketRepoBranchPicker', () => { + const scaffolderApiMock: Partial = { + autocomplete: jest.fn().mockResolvedValue(['branch1']), + }; + + it('renders an input field', () => { + const { getByRole } = render( + + + , + ); + + expect(getByRole('textbox')).toBeInTheDocument(); + expect(getByRole('textbox')).toHaveValue('main'); + }); + + it('calls onChange when the input field changes', () => { + const onChange = jest.fn(); + + const { getByRole } = render( + + + , + ); + + const input = getByRole('textbox'); + + act(() => { + input.focus(); + fireEvent.change(input, { + target: { value: 'develop' }, + }); + input.blur(); + }); + + expect(onChange).toHaveBeenCalledWith({ branch: 'develop' }); + }); + + it('should populate branches', async () => { + const onChange = jest.fn(); + + const { getByRole, getByText } = render( + + + , + ); + + // Open the Autcomplete dropdown + const input = getByRole('textbox'); + await userEvent.click(input); + + // Verify that the available workspaces are shown + await waitFor(() => expect(getByText('branch1')).toBeInTheDocument()); + + // Verify that selecting an option calls onChange + await userEvent.click(getByText('branch1')); + expect(onChange).toHaveBeenCalledWith({ + branch: 'branch1', + }); + }); +}); diff --git a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.tsx b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.tsx index 27a0b5c027..3af7eb7e2c 100644 --- a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.tsx +++ b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.tsx @@ -16,7 +16,7 @@ import { scaffolderApiRef } from '@backstage/plugin-scaffolder-react'; import FormControl from '@material-ui/core/FormControl'; -import React from 'react'; +import React, { useState } from 'react'; import TextField from '@material-ui/core/TextField'; import Autocomplete from '@material-ui/lab/Autocomplete'; import useDebounce from 'react-use/esm/useDebounce'; @@ -35,7 +35,9 @@ export const BitbucketRepoBranchPicker = ({ rawErrors: string[]; accessToken?: string; }) => { - const { host, workspace, repository, branch, availableBranches } = state; + const { host, workspace, repository, branch } = state; + + const [availableBranches, setAvailableBranches] = useState([]); const scaffolderApi = useApi(scaffolderApiRef); @@ -55,15 +57,13 @@ export const BitbucketRepoBranchPicker = ({ { workspace, repository }, ); - onChange({ availableBranches: result }); + setAvailableBranches(result); } else { - onChange({ availableBranches: [] }); + setAvailableBranches([]); } }; - updateAvailableBranches().catch(() => - onChange({ availableBranches: [] }), - ); + updateAvailableBranches().catch(() => setAvailableBranches([])); }, 500, [host, workspace, repository, accessToken], @@ -80,7 +80,7 @@ export const BitbucketRepoBranchPicker = ({ onChange={(_, newValue) => { onChange({ branch: newValue || '' }); }} - options={availableBranches || []} + options={availableBranches} renderInput={params => ( )} diff --git a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/types.ts b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/types.ts index 4843ff767e..1d54ea7e8b 100644 --- a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/types.ts +++ b/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/types.ts @@ -19,5 +19,4 @@ export interface RepoBranchPickerState { workspace?: string; repository?: string; branch?: string; - availableBranches?: string[]; } From a781cd8513b9ec3a86bcb2379be7fbc5b5a49d2c Mon Sep 17 00:00:00 2001 From: Benjamin Janssens Date: Tue, 18 Jun 2024 14:46:20 +0200 Subject: [PATCH 015/372] chore: rename BitbucketRepoBranchPicker folder to RepoBranchPicker Signed-off-by: Benjamin Janssens --- .../BitbucketRepoBranchPicker.test.tsx | 0 .../BitbucketRepoBranchPicker.tsx | 0 .../RepoBranchPicker.tsx | 0 .../{BitbucketRepoBranchPicker => RepoBranchPicker}/index.ts | 0 .../{BitbucketRepoBranchPicker => RepoBranchPicker}/schema.ts | 0 .../{BitbucketRepoBranchPicker => RepoBranchPicker}/types.ts | 0 plugins/scaffolder/src/extensions/default.ts | 4 ++-- plugins/scaffolder/src/plugin.tsx | 4 ++-- 8 files changed, 4 insertions(+), 4 deletions(-) rename plugins/scaffolder/src/components/fields/{BitbucketRepoBranchPicker => RepoBranchPicker}/BitbucketRepoBranchPicker.test.tsx (100%) rename plugins/scaffolder/src/components/fields/{BitbucketRepoBranchPicker => RepoBranchPicker}/BitbucketRepoBranchPicker.tsx (100%) rename plugins/scaffolder/src/components/fields/{BitbucketRepoBranchPicker => RepoBranchPicker}/RepoBranchPicker.tsx (100%) rename plugins/scaffolder/src/components/fields/{BitbucketRepoBranchPicker => RepoBranchPicker}/index.ts (100%) rename plugins/scaffolder/src/components/fields/{BitbucketRepoBranchPicker => RepoBranchPicker}/schema.ts (100%) rename plugins/scaffolder/src/components/fields/{BitbucketRepoBranchPicker => RepoBranchPicker}/types.ts (100%) diff --git a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.test.tsx b/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.test.tsx similarity index 100% rename from plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.test.tsx rename to plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.test.tsx diff --git a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.tsx b/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx similarity index 100% rename from plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/BitbucketRepoBranchPicker.tsx rename to plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx diff --git a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/RepoBranchPicker.tsx b/plugins/scaffolder/src/components/fields/RepoBranchPicker/RepoBranchPicker.tsx similarity index 100% rename from plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/RepoBranchPicker.tsx rename to plugins/scaffolder/src/components/fields/RepoBranchPicker/RepoBranchPicker.tsx diff --git a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/index.ts b/plugins/scaffolder/src/components/fields/RepoBranchPicker/index.ts similarity index 100% rename from plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/index.ts rename to plugins/scaffolder/src/components/fields/RepoBranchPicker/index.ts diff --git a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/schema.ts b/plugins/scaffolder/src/components/fields/RepoBranchPicker/schema.ts similarity index 100% rename from plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/schema.ts rename to plugins/scaffolder/src/components/fields/RepoBranchPicker/schema.ts diff --git a/plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/types.ts b/plugins/scaffolder/src/components/fields/RepoBranchPicker/types.ts similarity index 100% rename from plugins/scaffolder/src/components/fields/BitbucketRepoBranchPicker/types.ts rename to plugins/scaffolder/src/components/fields/RepoBranchPicker/types.ts diff --git a/plugins/scaffolder/src/extensions/default.ts b/plugins/scaffolder/src/extensions/default.ts index 409372e421..e77d968c80 100644 --- a/plugins/scaffolder/src/extensions/default.ts +++ b/plugins/scaffolder/src/extensions/default.ts @@ -50,8 +50,8 @@ import { MultiEntityPickerSchema, validateMultiEntityPickerValidation, } from '../components/fields/MultiEntityPicker/MultiEntityPicker'; -import { RepoBranchPicker } from '../components/fields/BitbucketRepoBranchPicker/RepoBranchPicker'; -import { RepoBranchPickerSchema } from '../components/fields/BitbucketRepoBranchPicker/schema'; +import { RepoBranchPicker } from '../components/fields/RepoBranchPicker/RepoBranchPicker'; +import { RepoBranchPickerSchema } from '../components/fields/RepoBranchPicker/schema'; export const DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS = [ { diff --git a/plugins/scaffolder/src/plugin.tsx b/plugins/scaffolder/src/plugin.tsx index 6f4e28c9b0..c6c858f6b1 100644 --- a/plugins/scaffolder/src/plugin.tsx +++ b/plugins/scaffolder/src/plugin.tsx @@ -73,8 +73,8 @@ import { MyGroupsPicker, MyGroupsPickerSchema, } from './components/fields/MyGroupsPicker/MyGroupsPicker'; -import { RepoBranchPicker } from './components/fields/BitbucketRepoBranchPicker/RepoBranchPicker'; -import { RepoBranchPickerSchema } from './components/fields/BitbucketRepoBranchPicker/schema'; +import { RepoBranchPicker } from './components/fields/RepoBranchPicker/RepoBranchPicker'; +import { RepoBranchPickerSchema } from './components/fields/RepoBranchPicker/schema'; /** * The main plugin export for the scaffolder. From 426bd26366c0f649a36a89f70acd0e97e9da428b Mon Sep 17 00:00:00 2001 From: Benjamin Janssens Date: Tue, 18 Jun 2024 15:00:14 +0200 Subject: [PATCH 016/372] test: add tests for listBranchesByRepository to BitbucketCloudClient Signed-off-by: Benjamin Janssens --- .../src/BitbucketCloudClient.test.ts | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/plugins/bitbucket-cloud-common/src/BitbucketCloudClient.test.ts b/plugins/bitbucket-cloud-common/src/BitbucketCloudClient.test.ts index f625f0daf8..7558c92138 100644 --- a/plugins/bitbucket-cloud-common/src/BitbucketCloudClient.test.ts +++ b/plugins/bitbucket-cloud-common/src/BitbucketCloudClient.test.ts @@ -162,4 +162,33 @@ describe('BitbucketCloudClient', () => { expect(results).toHaveLength(1); expect(results[0].slug).toEqual('workspace1'); }); + + it('listBranchesByRepository', async () => { + server.use( + rest.get( + 'https://api.bitbucket.org/2.0/repositories/workspace1/repo1/refs/branches', + (_, res, ctx) => { + const response = { + values: [ + { + type: 'branch', + name: 'branch1', + } as Models.Branch, + ], + }; + return res(ctx.json(response)); + }, + ), + ); + + const pagination = client.listBranchesByRepository('repo1', 'workspace1'); + + const results = []; + for await (const result of pagination.iterateResults()) { + results.push(result); + } + + expect(results).toHaveLength(1); + expect(results[0].name).toEqual('branch1'); + }); }); From 5588a64e80e324ab97cb9647b477cee2793cff49 Mon Sep 17 00:00:00 2001 From: Benjamin Janssens Date: Tue, 18 Jun 2024 15:09:46 +0200 Subject: [PATCH 017/372] test: add tests for branches for handleBitbucketCloudRequest Signed-off-by: Benjamin Janssens --- .../src/autocomplete/autocomplete.test.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/plugins/scaffolder-backend-module-bitbucket-cloud/src/autocomplete/autocomplete.test.ts b/plugins/scaffolder-backend-module-bitbucket-cloud/src/autocomplete/autocomplete.test.ts index 0447ff2d28..b124c65f78 100644 --- a/plugins/scaffolder-backend-module-bitbucket-cloud/src/autocomplete/autocomplete.test.ts +++ b/plugins/scaffolder-backend-module-bitbucket-cloud/src/autocomplete/autocomplete.test.ts @@ -35,6 +35,11 @@ describe('handleAutocompleteRequest', () => { .fn() .mockReturnValue([{ values: [{ slug: 'repository1' }] }]), }), + listBranchesByRepository: jest.fn().mockReturnValue({ + iteratePages: jest + .fn() + .mockReturnValue([{ values: [{ name: 'branch1' }] }]), + }), }; const fromConfig = jest @@ -89,6 +94,15 @@ describe('handleAutocompleteRequest', () => { expect(result).toEqual({ results: [{ title: 'repository1' }] }); }); + it('should return branches', async () => { + const result = await handleBitbucketCloudRequest('foo', 'branches', { + workspace: 'workspace1', + repository: 'repository1', + }); + + expect(result).toEqual(['branch1']); + }); + it('should throw an error when passing an invalid resource', async () => { await expect( handleAutocompleteRequest({ From 8329e930c6f7e7f0b3654b2e7af8d098d246527a Mon Sep 17 00:00:00 2001 From: Benjamin Janssens Date: Wed, 19 Jun 2024 09:52:17 +0200 Subject: [PATCH 018/372] test: add tests for RepoBranchPicker Signed-off-by: Benjamin Janssens --- .../RepoBranchPicker.test.tsx | 324 ++++++++++++++++++ .../RepoBranchPicker/RepoBranchPicker.tsx | 5 +- 2 files changed, 327 insertions(+), 2 deletions(-) create mode 100644 plugins/scaffolder/src/components/fields/RepoBranchPicker/RepoBranchPicker.test.tsx diff --git a/plugins/scaffolder/src/components/fields/RepoBranchPicker/RepoBranchPicker.test.tsx b/plugins/scaffolder/src/components/fields/RepoBranchPicker/RepoBranchPicker.test.tsx new file mode 100644 index 0000000000..eb5ebd1730 --- /dev/null +++ b/plugins/scaffolder/src/components/fields/RepoBranchPicker/RepoBranchPicker.test.tsx @@ -0,0 +1,324 @@ +/* + * Copyright 2024 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 { Form } from '@backstage/plugin-scaffolder-react/alpha'; +import validator from '@rjsf/validator-ajv8'; +import { renderInTestApp, TestApiProvider } from '@backstage/test-utils'; +import { + scmIntegrationsApiRef, + ScmIntegrationsApi, + scmAuthApiRef, + ScmAuthApi, +} from '@backstage/integration-react'; + +import { + SecretsContextProvider, + scaffolderApiRef, + useTemplateSecrets, + ScaffolderRJSFField, +} from '@backstage/plugin-scaffolder-react'; +import { act, fireEvent } from '@testing-library/react'; +import { RepoBranchPicker } from './RepoBranchPicker'; + +describe('RepoBranchPicker', () => { + const mockIntegrationsApi: Partial = { + byHost: () => ({ type: 'bitbucket' }), + }; + + let mockScmAuthApi: Partial; + + beforeEach(() => { + mockScmAuthApi = { + getCredentials: jest.fn().mockResolvedValue({ token: 'abc123' }), + }; + }); + + describe('happy path rendering', () => { + it('should render the repo branch picker with minimal props', async () => { + const onSubmit = jest.fn(); + + const { getByRole } = await renderInTestApp( + + +

, + }} + onSubmit={onSubmit} + formContext={{ + formData: { + repoUrl: 'bitbucket.org', + }, + }} + /> + + , + ); + + const input = getByRole('textbox'); + const submitButton = getByRole('button'); + + act(() => { + input.focus(); + fireEvent.change(input, { target: { value: 'branch1' } }); + input.blur(); + }); + + fireEvent.click(submitButton); + + expect(onSubmit).toHaveBeenCalledWith( + expect.objectContaining({ + formData: 'branch1', + }), + expect.anything(), + ); + }); + + it('should render properly with title and description', async () => { + const { getByText } = await renderInTestApp( + + + , + }} + formContext={{ + formData: { + repoUrl: 'bitbucket.org', + }, + }} + /> + + , + ); + + expect(getByText('test title')).toBeInTheDocument(); + expect(getByText('test description')).toBeInTheDocument(); + }); + }); + + describe('requestUserCredentials', () => { + it('should call the scmAuthApi with the correct params', async () => { + const SecretsComponent = () => { + const { secrets } = useTemplateSecrets(); + return ( +
{JSON.stringify({ secrets })}
+ ); + }; + const { getByTestId } = await renderInTestApp( + + + , + }} + formContext={{ + formData: { + repoUrl: 'github.com', + }, + }} + /> + + + , + ); + + await act(async () => { + // need to wait for the debounce to finish + await new Promise(resolve => setTimeout(resolve, 600)); + }); + + expect(mockScmAuthApi.getCredentials).toHaveBeenCalledWith({ + url: 'https://github.com', + additionalScope: { + repoWrite: true, + customScopes: { + github: ['workflow'], + }, + }, + }); + + const currentSecrets = JSON.parse( + getByTestId('current-secrets').textContent!, + ); + + expect(currentSecrets).toEqual({ + secrets: { testKey: 'abc123' }, + }); + }); + + it('should call the scmAuthApi with the correct params if workspace is nested', async () => { + const SecretsComponent = () => { + const { secrets } = useTemplateSecrets(); + return ( +
{JSON.stringify({ secrets })}
+ ); + }; + await renderInTestApp( + + + , + }} + formContext={{ + formData: { + repoUrl: 'gitlab.example.com', + }, + }} + /> + + + , + ); + + await act(async () => { + // need to wait for the debounce to finish + await new Promise(resolve => setTimeout(resolve, 600)); + }); + + expect(mockScmAuthApi.getCredentials).toHaveBeenCalledWith({ + url: 'https://gitlab.example.com', + additionalScope: { + repoWrite: true, + }, + }); + }); + + it('should not call the scmAuthApi if secret is available in the state', async () => { + const SecretsComponent = () => { + const { secrets } = useTemplateSecrets(); + return ( +
{JSON.stringify({ secrets })}
+ ); + }; + const { getByTestId } = await renderInTestApp( + + + , + }} + formContext={{ + formData: { + repoUrl: 'github.com', + }, + }} + /> + + + , + ); + + await act(async () => { + // need to wait for the debounce to finish + await new Promise(resolve => setTimeout(resolve, 600)); + }); + + // as we already have a secret in the state, getCredentials should not be called again. + expect(mockScmAuthApi.getCredentials).toHaveBeenCalledTimes(0); + + const currentSecrets = JSON.parse( + getByTestId('current-secrets').textContent!, + ); + + expect(currentSecrets).toEqual({ + secrets: { testKey: 'abc123' }, + }); + }); + }); +}); diff --git a/plugins/scaffolder/src/components/fields/RepoBranchPicker/RepoBranchPicker.tsx b/plugins/scaffolder/src/components/fields/RepoBranchPicker/RepoBranchPicker.tsx index 2ba1eddbfc..8ab83bd717 100644 --- a/plugins/scaffolder/src/components/fields/RepoBranchPicker/RepoBranchPicker.tsx +++ b/plugins/scaffolder/src/components/fields/RepoBranchPicker/RepoBranchPicker.tsx @@ -20,8 +20,6 @@ import { scmAuthApiRef, } from '@backstage/integration-react'; import React, { useEffect, useState, useCallback } from 'react'; -import { RepoBranchPickerProps } from './schema'; -import { RepoBranchPickerState } from './types'; import useDebounce from 'react-use/esm/useDebounce'; import { useTemplateSecrets } from '@backstage/plugin-scaffolder-react'; import Box from '@material-ui/core/Box'; @@ -29,6 +27,9 @@ import Divider from '@material-ui/core/Divider'; import Typography from '@material-ui/core/Typography'; import { BitbucketRepoBranchPicker } from './BitbucketRepoBranchPicker'; +import { RepoBranchPickerProps } from './schema'; +import { RepoBranchPickerState } from './types'; + /** * The underlying component that is rendered in the form for the `RepoBranchPicker` * field extension. From 80738256c37e4ace961dbf31fe0e02b04371075d Mon Sep 17 00:00:00 2001 From: Benjamin Janssens Date: Wed, 19 Jun 2024 13:48:49 +0200 Subject: [PATCH 019/372] chore: copy comments from RepoUrlPicker to stay consistent Signed-off-by: Benjamin Janssens --- .../fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx | 7 +++++++ .../src/components/fields/RepoBranchPicker/schema.ts | 3 +++ 2 files changed, 10 insertions(+) diff --git a/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx b/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx index 3af7eb7e2c..23e8f01617 100644 --- a/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx +++ b/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx @@ -24,6 +24,13 @@ import { useApi } from '@backstage/core-plugin-api'; import { RepoBranchPickerState } from './types'; import FormHelperText from '@material-ui/core/FormHelperText'; +/** + * The underlying component that is rendered in the form for the `BitbucketRepoBranchPicker` + * field extension. + * + * @public + * + */ export const BitbucketRepoBranchPicker = ({ onChange, state, diff --git a/plugins/scaffolder/src/components/fields/RepoBranchPicker/schema.ts b/plugins/scaffolder/src/components/fields/RepoBranchPicker/schema.ts index 12ed07fd80..6ee67bd1c7 100644 --- a/plugins/scaffolder/src/components/fields/RepoBranchPicker/schema.ts +++ b/plugins/scaffolder/src/components/fields/RepoBranchPicker/schema.ts @@ -77,4 +77,7 @@ export type RepoBranchPickerUiOptions = export type RepoBranchPickerProps = typeof RepoBranchPickerFieldSchema.type; +// NOTE: There is a bug with this failing validation in the custom field explorer due +// to https://github.com/rjsf-team/react-jsonschema-form/issues/675 even if +// requestUserCredentials is not defined export const RepoBranchPickerSchema = RepoBranchPickerFieldSchema.schema; From 37d52e4f2830ff15af55a60bfd5d8afd7ea36c2b Mon Sep 17 00:00:00 2001 From: Benjamin Janssens Date: Wed, 19 Jun 2024 16:37:33 +0200 Subject: [PATCH 020/372] feat: fall back on DefaultRepoBranchPicker if host is not bitbucket Signed-off-by: Benjamin Janssens --- .../BitbucketRepoBranchPicker.tsx | 6 +- .../DefaultRepoBranchPicker.test.tsx | 55 +++++++++++++++++ .../DefaultRepoBranchPicker.tsx | 60 +++++++++++++++++++ .../RepoBranchPicker.test.tsx | 10 +--- .../RepoBranchPicker/RepoBranchPicker.tsx | 53 +++++++++++----- 5 files changed, 160 insertions(+), 24 deletions(-) create mode 100644 plugins/scaffolder/src/components/fields/RepoBranchPicker/DefaultRepoBranchPicker.test.tsx create mode 100644 plugins/scaffolder/src/components/fields/RepoBranchPicker/DefaultRepoBranchPicker.tsx diff --git a/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx b/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx index 23e8f01617..76de25dba0 100644 --- a/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx +++ b/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx @@ -36,11 +36,13 @@ export const BitbucketRepoBranchPicker = ({ state, rawErrors, accessToken, + required, }: { onChange: (state: RepoBranchPickerState) => void; state: RepoBranchPickerState; rawErrors: string[]; accessToken?: string; + required?: boolean; }) => { const { host, workspace, repository, branch } = state; @@ -79,7 +81,7 @@ export const BitbucketRepoBranchPicker = ({ return ( 0 && !branch} > ( - + )} freeSolo autoSelect diff --git a/plugins/scaffolder/src/components/fields/RepoBranchPicker/DefaultRepoBranchPicker.test.tsx b/plugins/scaffolder/src/components/fields/RepoBranchPicker/DefaultRepoBranchPicker.test.tsx new file mode 100644 index 0000000000..77589e4478 --- /dev/null +++ b/plugins/scaffolder/src/components/fields/RepoBranchPicker/DefaultRepoBranchPicker.test.tsx @@ -0,0 +1,55 @@ +/* + * Copyright 2024 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 { fireEvent, render } from '@testing-library/react'; + +import { DefaultRepoBranchPicker } from './DefaultRepoBranchPicker'; + +describe('DefaultRepoBranchPicker', () => { + it('renders an input field', () => { + const { getByRole } = render( + , + ); + + expect(getByRole('textbox')).toBeInTheDocument(); + expect(getByRole('textbox')).toHaveValue('main'); + }); + + it('calls onChange when the input field changes', () => { + const onChange = jest.fn(); + + const { getByRole } = render( + , + ); + + const input = getByRole('textbox'); + + fireEvent.change(input, { + target: { value: 'develop' }, + }); + + expect(onChange).toHaveBeenCalledWith({ branch: 'develop' }); + }); +}); diff --git a/plugins/scaffolder/src/components/fields/RepoBranchPicker/DefaultRepoBranchPicker.tsx b/plugins/scaffolder/src/components/fields/RepoBranchPicker/DefaultRepoBranchPicker.tsx new file mode 100644 index 0000000000..52a4a15e23 --- /dev/null +++ b/plugins/scaffolder/src/components/fields/RepoBranchPicker/DefaultRepoBranchPicker.tsx @@ -0,0 +1,60 @@ +/* + * Copyright 2024 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 FormControl from '@material-ui/core/FormControl'; +import React from 'react'; +import FormHelperText from '@material-ui/core/FormHelperText'; +import Input from '@material-ui/core/Input'; +import InputLabel from '@material-ui/core/InputLabel'; + +import { RepoBranchPickerState } from './types'; + +/** + * The underlying component that is rendered in the form for the `DefaultRepoBranchPicker` + * field extension. + * + * @public + * + */ +export const DefaultRepoBranchPicker = ({ + onChange, + state, + rawErrors, + required, +}: { + onChange: (state: RepoBranchPickerState) => void; + state: RepoBranchPickerState; + rawErrors: string[]; + required?: boolean; +}) => { + const { branch } = state; + + return ( + 0 && !branch} + > + Branch + onChange({ branch: e.target.value })} + value={branch} + /> + The branch of the repository + + ); +}; diff --git a/plugins/scaffolder/src/components/fields/RepoBranchPicker/RepoBranchPicker.test.tsx b/plugins/scaffolder/src/components/fields/RepoBranchPicker/RepoBranchPicker.test.tsx index eb5ebd1730..ece73670f6 100644 --- a/plugins/scaffolder/src/components/fields/RepoBranchPicker/RepoBranchPicker.test.tsx +++ b/plugins/scaffolder/src/components/fields/RepoBranchPicker/RepoBranchPicker.test.tsx @@ -70,9 +70,7 @@ describe('RepoBranchPicker', () => { }} onSubmit={onSubmit} formContext={{ - formData: { - repoUrl: 'bitbucket.org', - }, + formData: {}, }} /> @@ -82,11 +80,7 @@ describe('RepoBranchPicker', () => { const input = getByRole('textbox'); const submitButton = getByRole('button'); - act(() => { - input.focus(); - fireEvent.change(input, { target: { value: 'branch1' } }); - input.blur(); - }); + fireEvent.change(input, { target: { value: 'branch1' } }); fireEvent.click(submitButton); diff --git a/plugins/scaffolder/src/components/fields/RepoBranchPicker/RepoBranchPicker.tsx b/plugins/scaffolder/src/components/fields/RepoBranchPicker/RepoBranchPicker.tsx index 8ab83bd717..4ca22c8f80 100644 --- a/plugins/scaffolder/src/components/fields/RepoBranchPicker/RepoBranchPicker.tsx +++ b/plugins/scaffolder/src/components/fields/RepoBranchPicker/RepoBranchPicker.tsx @@ -25,10 +25,11 @@ import { useTemplateSecrets } from '@backstage/plugin-scaffolder-react'; import Box from '@material-ui/core/Box'; import Divider from '@material-ui/core/Divider'; import Typography from '@material-ui/core/Typography'; -import { BitbucketRepoBranchPicker } from './BitbucketRepoBranchPicker'; import { RepoBranchPickerProps } from './schema'; import { RepoBranchPickerState } from './types'; +import { BitbucketRepoBranchPicker } from './BitbucketRepoBranchPicker'; +import { DefaultRepoBranchPicker } from './DefaultRepoBranchPicker'; /** * The underlying component that is rendered in the form for the `RepoBranchPicker` @@ -37,8 +38,15 @@ import { RepoBranchPickerState } from './types'; * @public */ export const RepoBranchPicker = (props: RepoBranchPickerProps) => { - const { uiSchema, onChange, rawErrors, formData, schema, formContext } = - props; + const { + uiSchema, + onChange, + rawErrors, + formData, + schema, + formContext, + required, + } = props; const { formData: { repoUrl }, } = formContext; @@ -111,6 +119,33 @@ export const RepoBranchPicker = (props: RepoBranchPickerProps) => { const hostType = (host && integrationApi.byHost(host)?.type) ?? null; + const renderRepoBranchPicker = () => { + switch (hostType) { + case 'bitbucket': + return ( + + ); + default: + return ( + + ); + } + }; + return ( <> {schema.title && ( @@ -122,17 +157,7 @@ export const RepoBranchPicker = (props: RepoBranchPickerProps) => { {schema.description && ( {schema.description} )} - {hostType === 'bitbucket' && ( - - )} + {renderRepoBranchPicker()} ); }; From 7d82969f10086d0d062af813476df906b278e438 Mon Sep 17 00:00:00 2001 From: Benjamin Janssens Date: Fri, 28 Jun 2024 11:56:51 +0200 Subject: [PATCH 021/372] chore: update BitbucketRepoBranchPicker and handleAutocompleteRequest Signed-off-by: Benjamin Janssens --- .../src/autocomplete/autocomplete.test.ts | 12 ++++++++---- .../src/autocomplete/autocomplete.ts | 8 ++++---- .../BitbucketRepoBranchPicker.test.tsx | 4 +++- .../BitbucketRepoBranchPicker.tsx | 17 +++++++++-------- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/plugins/scaffolder-backend-module-bitbucket-cloud/src/autocomplete/autocomplete.test.ts b/plugins/scaffolder-backend-module-bitbucket-cloud/src/autocomplete/autocomplete.test.ts index b124c65f78..d99a8358b9 100644 --- a/plugins/scaffolder-backend-module-bitbucket-cloud/src/autocomplete/autocomplete.test.ts +++ b/plugins/scaffolder-backend-module-bitbucket-cloud/src/autocomplete/autocomplete.test.ts @@ -95,12 +95,16 @@ describe('handleAutocompleteRequest', () => { }); it('should return branches', async () => { - const result = await handleBitbucketCloudRequest('foo', 'branches', { - workspace: 'workspace1', - repository: 'repository1', + const result = await handleAutocompleteRequest({ + token: 'foo', + resource: 'branches', + context: { + workspace: 'workspace1', + repository: 'repository1', + }, }); - expect(result).toEqual(['branch1']); + expect(result).toEqual({ results: [{ title: 'branch1' }] }); }); it('should throw an error when passing an invalid resource', async () => { diff --git a/plugins/scaffolder-backend-module-bitbucket-cloud/src/autocomplete/autocomplete.ts b/plugins/scaffolder-backend-module-bitbucket-cloud/src/autocomplete/autocomplete.ts index 70824995ac..58d2bc9c6d 100644 --- a/plugins/scaffolder-backend-module-bitbucket-cloud/src/autocomplete/autocomplete.ts +++ b/plugins/scaffolder-backend-module-bitbucket-cloud/src/autocomplete/autocomplete.ts @@ -78,21 +78,21 @@ export async function handleAutocompleteRequest({ return { results: result.map(title => ({ title })) }; } case 'branches': { - if (!parameters.workspace || !parameters.repository) + if (!context.workspace || !context.repository) throw new InputError( - 'Missing workspace and/or repository query parameter', + 'Missing workspace and/or repository context parameter', ); const result: string[] = []; for await (const page of client - .listBranchesByRepository(parameters.repository, parameters.workspace) + .listBranchesByRepository(context.repository, context.workspace) .iteratePages()) { const names = [...page.values!].map(p => p.name!); result.push(...names); } - return result; + return { results: result.map(title => ({ title })) }; } default: throw new InputError(`Invalid resource: ${resource}`); diff --git a/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.test.tsx b/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.test.tsx index 6cbc561bc9..638a05b4ce 100644 --- a/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.test.tsx +++ b/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.test.tsx @@ -26,7 +26,9 @@ import userEvent from '@testing-library/user-event'; describe('BitbucketRepoBranchPicker', () => { const scaffolderApiMock: Partial = { - autocomplete: jest.fn().mockResolvedValue(['branch1']), + autocomplete: jest + .fn() + .mockResolvedValue({ results: [{ title: 'branch1' }] }), }; it('renders an input field', () => { diff --git a/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx b/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx index 76de25dba0..ed54cddc5e 100644 --- a/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx +++ b/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx @@ -57,16 +57,17 @@ export const BitbucketRepoBranchPicker = ({ host === 'bitbucket.org' && accessToken && workspace && - repository + repository && + scaffolderApi.autocomplete ) { - const result = await scaffolderApi.autocomplete( - accessToken, - 'bitbucketCloud', - 'branches', - { workspace, repository }, - ); + const { results } = await scaffolderApi.autocomplete({ + token: accessToken, + resource: 'branches', + context: { workspace, repository }, + provider: 'bitbucket-cloud', + }); - setAvailableBranches(result); + setAvailableBranches(results.map(r => r.title)); } else { setAvailableBranches([]); } From caf7fc23c3f172a9744b9bbf72ff9a92f8094e10 Mon Sep 17 00:00:00 2001 From: Benjamin Janssens Date: Fri, 28 Jun 2024 13:16:50 +0200 Subject: [PATCH 022/372] docs: extend documentation Signed-off-by: Benjamin Janssens --- .../software-templates/ui-options-examples.md | 27 ++++++++++++++++++ .../software-templates/writing-templates.md | 28 +++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/docs/features/software-templates/ui-options-examples.md b/docs/features/software-templates/ui-options-examples.md index 7f0e5b225f..1a024569a6 100644 --- a/docs/features/software-templates/ui-options-examples.md +++ b/docs/features/software-templates/ui-options-examples.md @@ -441,3 +441,30 @@ repoUrl: `secretsKey` is the key used within the template secrets context to store the credential and `additionalScopes` is any additional permission scopes to request. The supported `additionalScopes` values are `gerrit`, `github`, `gitlab`, `bitbucket`, and `azure`. + +## RepoBranchPicker + +The input props that can be specified under `ui:options` for the `RepoBranchPicker` field extension. + +### `requestUserCredentials` + +If defined will request user credentials to auth against the given SCM platform. + +```yaml +repoUrl: + title: Repository Branch + type: string + ui:field: RepoBranchPicker + ui:options: + requestUserCredentials: + secretsKey: USER_OAUTH_TOKEN + additionalScopes: + github: + - workflow:write +``` + +`secretsKey` is the key used within the template secrets context to store the credential and `additionalScopes` is any additional permission scopes to request. + +The supported `additionalScopes` values are `gerrit`, `github`, `gitlab`, `bitbucket`, and `azure`. + +If you're also using the `RepoUrlPicker` field extension, you should simply duplicate this part from there. diff --git a/docs/features/software-templates/writing-templates.md b/docs/features/software-templates/writing-templates.md index 15591eeb67..12bf65765a 100644 --- a/docs/features/software-templates/writing-templates.md +++ b/docs/features/software-templates/writing-templates.md @@ -477,6 +477,34 @@ template can be published to multiple providers. Note, that you will need to configure an [authentication provider](../../auth/index.md#configuring-authentication-providers), alongside the [`ScmAuthApi`](../../auth/index.md#scaffolder-configuration-software-templates) for your source code management (SCM) service to make this feature work. +### The Repository Branch Picker + +Similar to the repository picker, there is a picker for branches to support autocompletion. A full example could look like this: + +```yaml +- title: Choose a branch + required: + - repoBranch + properties: + repoBranch: + title: Repository Branch + type: string + ui:field: RepoBranchPicker + ui:options: + requestUserCredentials: + secretsKey: USER_OAUTH_TOKEN +``` + +Passing the `requestUserCredentials` object is required for autocompletion to work. +If you're also using the repository picker, you should simply duplicate this part from there. +For more information regarding the `requestUserCredentials` object, please refer to the [Using the Users `oauth` token](#using-the-users-oauth-token) section under [The Repository Picker](#the-repository-picker). + +For a list of all possible `ui:options` input props for `RepoBranchPicker`, please visit [here](./ui-options-examples.md#repobranchpicker). + +The `RepoBranchPicker` is a custom field that we provide part of the +`plugin-scaffolder`. You can provide your own custom fields by +[writing your own Custom Field Extensions](./writing-custom-field-extensions.md) + ### Accessing the signed-in users details Sometimes when authoring templates, you'll want to access the user that is running the template, and get details from the profile or the users `Entity` in the Catalog. From 3fca64320d18d8093557ccc666a3c3769b8d9535 Mon Sep 17 00:00:00 2001 From: Benjamin Janssens Date: Fri, 28 Jun 2024 13:24:57 +0200 Subject: [PATCH 023/372] chore: add changesets Signed-off-by: Benjamin Janssens --- .changeset/fast-bulldogs-relax.md | 5 +++++ .changeset/tough-goats-hang.md | 5 +++++ .changeset/witty-timers-marry.md | 5 +++++ 3 files changed, 15 insertions(+) create mode 100644 .changeset/fast-bulldogs-relax.md create mode 100644 .changeset/tough-goats-hang.md create mode 100644 .changeset/witty-timers-marry.md diff --git a/.changeset/fast-bulldogs-relax.md b/.changeset/fast-bulldogs-relax.md new file mode 100644 index 0000000000..65895345e9 --- /dev/null +++ b/.changeset/fast-bulldogs-relax.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend-module-bitbucket-cloud': patch +--- + +Added autocompletion support for resource `branches` diff --git a/.changeset/tough-goats-hang.md b/.changeset/tough-goats-hang.md new file mode 100644 index 0000000000..6090c582d0 --- /dev/null +++ b/.changeset/tough-goats-hang.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder': minor +--- + +Added field extension `RepoBranchPicker` diff --git a/.changeset/witty-timers-marry.md b/.changeset/witty-timers-marry.md new file mode 100644 index 0000000000..4193acb6fc --- /dev/null +++ b/.changeset/witty-timers-marry.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-bitbucket-cloud-common': patch +--- + +Added method `listBranchesByRepository` to `BitbucketCloudClient` From 1ae05800608f8e39c2b1e4eaec8efeeff724ff5c Mon Sep 17 00:00:00 2001 From: Benjamin Janssens Date: Fri, 28 Jun 2024 13:26:31 +0200 Subject: [PATCH 024/372] chore: update API reports Signed-off-by: Benjamin Janssens --- plugins/bitbucket-cloud-common/api-report.md | 9 ++++++++ plugins/scaffolder/api-report.md | 22 ++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/plugins/bitbucket-cloud-common/api-report.md b/plugins/bitbucket-cloud-common/api-report.md index 34c245facc..833a367c03 100644 --- a/plugins/bitbucket-cloud-common/api-report.md +++ b/plugins/bitbucket-cloud-common/api-report.md @@ -12,6 +12,12 @@ export class BitbucketCloudClient { config: BitbucketCloudIntegrationConfig, ): BitbucketCloudClient; // (undocumented) + listBranchesByRepository( + repository: string, + workspace: string, + options?: FilterAndSortOptions & PartialResponseOptions, + ): WithPagination; + // (undocumented) listProjectsByWorkspace( workspace: string, options?: FilterAndSortOptions & PartialResponseOptions, @@ -209,6 +215,9 @@ export namespace Models { size?: number; values?: Array | Set; } + export interface PaginatedBranches extends Paginated { + values?: Set; + } export interface PaginatedProjects extends Paginated { values?: Set; } diff --git a/plugins/scaffolder/api-report.md b/plugins/scaffolder/api-report.md index f479b13ec4..6641cda26b 100644 --- a/plugins/scaffolder/api-report.md +++ b/plugins/scaffolder/api-report.md @@ -384,6 +384,28 @@ export const OwnerPickerFieldSchema: FieldSchema< // @public export type OwnerPickerUiOptions = typeof OwnerPickerFieldSchema.uiOptionsType; +// @public +export const RepoBranchPickerFieldExtension: FieldExtensionComponent_2< + string, + { + requestUserCredentials?: + | { + secretsKey: string; + additionalScopes?: + | { + azure?: string[] | undefined; + github?: string[] | undefined; + gitlab?: string[] | undefined; + bitbucket?: string[] | undefined; + gerrit?: string[] | undefined; + gitea?: string[] | undefined; + } + | undefined; + } + | undefined; + } +>; + // @public export const repoPickerValidation: ( value: string, From 362ae34cb4b9a87a8a3e41f5a7c94bcbee7eb346 Mon Sep 17 00:00:00 2001 From: Benjamin Janssens Date: Thu, 4 Jul 2024 13:53:18 +0200 Subject: [PATCH 025/372] refactor: extract BaseRepoBranchPickerProps Signed-off-by: Benjamin Janssens --- .../RepoBranchPicker/BitbucketRepoBranchPicker.tsx | 10 +++------- .../RepoBranchPicker/DefaultRepoBranchPicker.tsx | 9 ++------- .../src/components/fields/RepoBranchPicker/types.ts | 7 +++++++ 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx b/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx index ed54cddc5e..f6e6634ed8 100644 --- a/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx +++ b/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx @@ -21,7 +21,7 @@ import TextField from '@material-ui/core/TextField'; import Autocomplete from '@material-ui/lab/Autocomplete'; import useDebounce from 'react-use/esm/useDebounce'; import { useApi } from '@backstage/core-plugin-api'; -import { RepoBranchPickerState } from './types'; +import { BaseRepoBranchPickerProps } from './types'; import FormHelperText from '@material-ui/core/FormHelperText'; /** @@ -37,13 +37,9 @@ export const BitbucketRepoBranchPicker = ({ rawErrors, accessToken, required, -}: { - onChange: (state: RepoBranchPickerState) => void; - state: RepoBranchPickerState; - rawErrors: string[]; +}: BaseRepoBranchPickerProps<{ accessToken?: string; - required?: boolean; -}) => { +}>) => { const { host, workspace, repository, branch } = state; const [availableBranches, setAvailableBranches] = useState([]); diff --git a/plugins/scaffolder/src/components/fields/RepoBranchPicker/DefaultRepoBranchPicker.tsx b/plugins/scaffolder/src/components/fields/RepoBranchPicker/DefaultRepoBranchPicker.tsx index 52a4a15e23..9350e232f8 100644 --- a/plugins/scaffolder/src/components/fields/RepoBranchPicker/DefaultRepoBranchPicker.tsx +++ b/plugins/scaffolder/src/components/fields/RepoBranchPicker/DefaultRepoBranchPicker.tsx @@ -20,7 +20,7 @@ import FormHelperText from '@material-ui/core/FormHelperText'; import Input from '@material-ui/core/Input'; import InputLabel from '@material-ui/core/InputLabel'; -import { RepoBranchPickerState } from './types'; +import { BaseRepoBranchPickerProps } from './types'; /** * The underlying component that is rendered in the form for the `DefaultRepoBranchPicker` @@ -34,12 +34,7 @@ export const DefaultRepoBranchPicker = ({ state, rawErrors, required, -}: { - onChange: (state: RepoBranchPickerState) => void; - state: RepoBranchPickerState; - rawErrors: string[]; - required?: boolean; -}) => { +}: BaseRepoBranchPickerProps) => { const { branch } = state; return ( diff --git a/plugins/scaffolder/src/components/fields/RepoBranchPicker/types.ts b/plugins/scaffolder/src/components/fields/RepoBranchPicker/types.ts index 1d54ea7e8b..bd218d9e28 100644 --- a/plugins/scaffolder/src/components/fields/RepoBranchPicker/types.ts +++ b/plugins/scaffolder/src/components/fields/RepoBranchPicker/types.ts @@ -20,3 +20,10 @@ export interface RepoBranchPickerState { repository?: string; branch?: string; } + +export type BaseRepoBranchPickerProps = T & { + onChange: (state: RepoBranchPickerState) => void; + state: RepoBranchPickerState; + rawErrors: string[]; + required?: boolean; +}; From 3cea09fcf2c9cb8a990ff7ddd9be42174e8958c6 Mon Sep 17 00:00:00 2001 From: Benjamin Janssens Date: Thu, 4 Jul 2024 14:09:27 +0200 Subject: [PATCH 026/372] chore: remove unnecessary mapping from handleAutocompleteRequest Signed-off-by: Benjamin Janssens --- .../src/autocomplete/autocomplete.ts | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/plugins/scaffolder-backend-module-bitbucket-cloud/src/autocomplete/autocomplete.ts b/plugins/scaffolder-backend-module-bitbucket-cloud/src/autocomplete/autocomplete.ts index 58d2bc9c6d..75cc170a30 100644 --- a/plugins/scaffolder-backend-module-bitbucket-cloud/src/autocomplete/autocomplete.ts +++ b/plugins/scaffolder-backend-module-bitbucket-cloud/src/autocomplete/autocomplete.ts @@ -34,29 +34,29 @@ export async function handleAutocompleteRequest({ switch (resource) { case 'workspaces': { - const result: string[] = []; + const results: { title: string }[] = []; for await (const page of client.listWorkspaces().iteratePages()) { - const slugs = [...page.values!].map(p => p.slug!); - result.push(...slugs); + const slugs = [...page.values!].map(p => ({ title: p.slug! })); + results.push(...slugs); } - return { results: result.map(title => ({ title })) }; + return { results }; } case 'projects': { if (!context.workspace) throw new InputError('Missing workspace context parameter'); - const result: string[] = []; + const results: { title: string }[] = []; for await (const page of client .listProjectsByWorkspace(context.workspace) .iteratePages()) { - const keys = [...page.values!].map(p => p.key!); - result.push(...keys); + const keys = [...page.values!].map(p => ({ title: p.key! })); + results.push(...keys); } - return { results: result.map(title => ({ title })) }; + return { results }; } case 'repositories': { if (!context.workspace || !context.project) @@ -64,18 +64,18 @@ export async function handleAutocompleteRequest({ 'Missing workspace and/or project context parameter', ); - const result: string[] = []; + const results: { title: string }[] = []; for await (const page of client .listRepositoriesByWorkspace(context.workspace, { q: `project.key="${context.project}"`, }) .iteratePages()) { - const slugs = [...page.values!].map(p => p.slug!); - result.push(...slugs); + const slugs = [...page.values!].map(p => ({ title: p.slug! })); + results.push(...slugs); } - return { results: result.map(title => ({ title })) }; + return { results }; } case 'branches': { if (!context.workspace || !context.repository) @@ -83,16 +83,16 @@ export async function handleAutocompleteRequest({ 'Missing workspace and/or repository context parameter', ); - const result: string[] = []; + const results: { title: string }[] = []; for await (const page of client .listBranchesByRepository(context.repository, context.workspace) .iteratePages()) { - const names = [...page.values!].map(p => p.name!); - result.push(...names); + const names = [...page.values!].map(p => ({ title: p.name! })); + results.push(...names); } - return { results: result.map(title => ({ title })) }; + return { results }; } default: throw new InputError(`Invalid resource: ${resource}`); From 618aa1454890c9c2c499f3a2c178993978308a95 Mon Sep 17 00:00:00 2001 From: Benjamin Janssens Date: Thu, 4 Jul 2024 14:14:20 +0200 Subject: [PATCH 027/372] refactor: use useCallback for updateAvailableBranches Co-authored-by: Camila Belo Signed-off-by: Benjamin Janssens --- .../BitbucketRepoBranchPicker.tsx | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx b/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx index f6e6634ed8..76b8d071ea 100644 --- a/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx +++ b/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx @@ -46,34 +46,34 @@ export const BitbucketRepoBranchPicker = ({ const scaffolderApi = useApi(scaffolderApiRef); - useDebounce( - () => { - const updateAvailableBranches = async () => { - if ( - host === 'bitbucket.org' && - accessToken && - workspace && - repository && - scaffolderApi.autocomplete - ) { - const { results } = await scaffolderApi.autocomplete({ - token: accessToken, - resource: 'branches', - context: { workspace, repository }, - provider: 'bitbucket-cloud', - }); + const updateAvailableBranches = useCallback(() => { + if ( + !scaffolderApi.autocomplete || + !workspace || + !repository || + !accessToken || + host !== 'bitbucket.org' + ) { + setAvailableBranches([]); + return; + } - setAvailableBranches(results.map(r => r.title)); - } else { - setAvailableBranches([]); - } - }; + scaffolderApi + .autocomplete({ + token: accessToken, + resource: 'branches', + context: { workspace, repository }, + provider: 'bitbucket-cloud', + }) + .then(({ results }) => { + setAvailableBranches(results.map(r => r.title)); + }) + .catch(() => { + setAvailableBranches([]); + }); + }, [host, workspace, repository, accessToken, scaffolderApi]); - updateAvailableBranches().catch(() => setAvailableBranches([])); - }, - 500, - [host, workspace, repository, accessToken], - ); + useDebounce(updateAvailableBranches, 500, [updateAvailableBranches]); return ( Date: Thu, 4 Jul 2024 16:08:13 +0200 Subject: [PATCH 028/372] test: simplify checking for the secret in the document; remove SecretsComponent from test that didn't use it Signed-off-by: Benjamin Janssens --- .../RepoBranchPicker.test.tsx | 49 +++++++------------ 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/plugins/scaffolder/src/components/fields/RepoBranchPicker/RepoBranchPicker.test.tsx b/plugins/scaffolder/src/components/fields/RepoBranchPicker/RepoBranchPicker.test.tsx index ece73670f6..f9c23be407 100644 --- a/plugins/scaffolder/src/components/fields/RepoBranchPicker/RepoBranchPicker.test.tsx +++ b/plugins/scaffolder/src/components/fields/RepoBranchPicker/RepoBranchPicker.test.tsx @@ -133,13 +133,15 @@ describe('RepoBranchPicker', () => { describe('requestUserCredentials', () => { it('should call the scmAuthApi with the correct params', async () => { + const secretsKey = 'testKey'; + const SecretsComponent = () => { const { secrets } = useTemplateSecrets(); - return ( -
{JSON.stringify({ secrets })}
- ); + const secret = secrets[secretsKey]; + return secret ?
{secret}
: null; }; - const { getByTestId } = await renderInTestApp( + + const { getByText } = await renderInTestApp( { 'ui:field': 'RepoBranchPicker', 'ui:options': { requestUserCredentials: { - secretsKey: 'testKey', + secretsKey, additionalScopes: { github: ['workflow'] }, }, }, @@ -190,22 +192,10 @@ describe('RepoBranchPicker', () => { }, }); - const currentSecrets = JSON.parse( - getByTestId('current-secrets').textContent!, - ); - - expect(currentSecrets).toEqual({ - secrets: { testKey: 'abc123' }, - }); + expect(getByText('abc123')).toBeInTheDocument(); }); it('should call the scmAuthApi with the correct params if workspace is nested', async () => { - const SecretsComponent = () => { - const { secrets } = useTemplateSecrets(); - return ( -
{JSON.stringify({ secrets })}
- ); - }; await renderInTestApp( { }, }} /> - , ); @@ -256,13 +245,15 @@ describe('RepoBranchPicker', () => { }); it('should not call the scmAuthApi if secret is available in the state', async () => { + const secretsKey = 'testKey'; + const SecretsComponent = () => { const { secrets } = useTemplateSecrets(); - return ( -
{JSON.stringify({ secrets })}
- ); + const secret = secrets[secretsKey]; + return secret ?
{secret}
: null; }; - const { getByTestId } = await renderInTestApp( + + const { getByText } = await renderInTestApp( { [scaffolderApiRef, {}], ]} > - + { 'ui:field': 'RepoBranchPicker', 'ui:options': { requestUserCredentials: { - secretsKey: 'testKey', + secretsKey, additionalScopes: { github: ['workflow'] }, }, }, @@ -306,13 +297,7 @@ describe('RepoBranchPicker', () => { // as we already have a secret in the state, getCredentials should not be called again. expect(mockScmAuthApi.getCredentials).toHaveBeenCalledTimes(0); - const currentSecrets = JSON.parse( - getByTestId('current-secrets').textContent!, - ); - - expect(currentSecrets).toEqual({ - secrets: { testKey: 'abc123' }, - }); + expect(getByText('abc123')).toBeInTheDocument(); }); }); }); From 3956205ad85fb808386edfac1dab7ff273216225 Mon Sep 17 00:00:00 2001 From: Benjamin Janssens Date: Thu, 4 Jul 2024 16:31:01 +0200 Subject: [PATCH 029/372] fix: import useCallback in BitbucketRepoBranchPicker Signed-off-by: Benjamin Janssens --- .../fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx b/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx index 76b8d071ea..26853d6d05 100644 --- a/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx +++ b/plugins/scaffolder/src/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.tsx @@ -16,7 +16,7 @@ import { scaffolderApiRef } from '@backstage/plugin-scaffolder-react'; import FormControl from '@material-ui/core/FormControl'; -import React, { useState } from 'react'; +import React, { useCallback, useState } from 'react'; import TextField from '@material-ui/core/TextField'; import Autocomplete from '@material-ui/lab/Autocomplete'; import useDebounce from 'react-use/esm/useDebounce'; From e2d34cfcdcf41900d2351b20dcc370082e2cfb88 Mon Sep 17 00:00:00 2001 From: Marek Libra Date: Mon, 8 Jul 2024 13:04:33 +0200 Subject: [PATCH 030/372] Prioritize user documentation over README (notifications, signals) Selected content of notifications and signals README files has been moved upwards to the user documentation. Signed-off-by: Marek Libra --- docs/notifications/getting-started.md | 80 ++++++++++++++++++++----- plugins/notifications-backend/README.md | 58 ++---------------- plugins/notifications/README.md | 8 ++- 3 files changed, 78 insertions(+), 68 deletions(-) diff --git a/docs/notifications/getting-started.md b/docs/notifications/getting-started.md index 6a7ea6314e..583be64cc8 100644 --- a/docs/notifications/getting-started.md +++ b/docs/notifications/getting-started.md @@ -51,6 +51,8 @@ All parametrization is done through component properties, such as the `Notificat ![Notifications Page](notificationsPage.png) +In the `packages/app/src/components/Root/Root.tsx`, tweak the [properties](https://backstage.io/docs/reference/plugin-notifications.notificationssidebaritem) of the `` per specific needs. + ## Use New notifications can be sent either by a backend plugin or an external service through the REST API. @@ -134,12 +136,70 @@ notificationsApi.getNotification(yourId); notificationsApi.getNotification(lastSignal.notification_id); ``` +### Extending Notifications via Processors + +The notifications can be extended with `NotificationProcessor`. These processors allow to decorate notifications before they are sent or/and send the notifications to external services. + +Depending on the needs, a processor can modify the content of a notification or route it to different systems like email, Slack, or other services. + +A good example of how to write a processor is the [Email Processor](https://github.com/backstage/backstage/tree/master/plugins/notifications-backend-module-email). + +Start off by creating a notification processor: + +```ts +import { Notification } from '@backstage/plugin-notifications-common'; +import { NotificationProcessor } from '@backstage/plugin-notifications-node'; + +class MyNotificationProcessor implements NotificationProcessor { + async decorate(notification: Notification): Promise { + if (notification.origin === 'plugin-my-plugin') { + notification.payload.icon = 'my-icon'; + } + return notification; + } + + async send(notification: Notification): Promise { + nodemailer.sendEmail({ + from: 'backstage', + to: 'user', + subject: notification.payload.title, + text: notification.payload.description, + }); + } +} +``` + +Both of the processing functions are optional, and you can implement only one of them. + +Add the notification processor to the notification system by: + +```ts +import { notificationsProcessingExtensionPoint } from '@backstage/plugin-notifications-node'; +import { Notification } from '@backstage/plugin-notifications-common'; + +export const myPlugin = createBackendPlugin({ + pluginId: 'myPlugin', + register(env) { + env.registerInit({ + deps: { + notifications: notificationsProcessingExtensionPoint, + // ... + }, + async init({ notifications }) { + // ... + notifications.addProcessor(new MyNotificationProcessor()); + }, + }); + }, +}); +``` + ### External Services When the emitter of a notification is a Backstage backend plugin, it is mandatory to use the integration via `@backstage/plugin-notifications-node` as described above. If the emitter is a service external to Backstage, an HTTP POST request can be issued directly to the API, assuming that authentication is properly configured. -Refer to the service-to-service auth documentation for more details, focusing on the Static Tokens section for the simplest setup option. +Refer to the [service-to-service auth documentation](https://backstage.io/docs/auth/service-to-service-auth) for more details, focusing on the Static Tokens section for the simplest setup option. An example request for creating a broadcast notification might look like: @@ -149,20 +209,12 @@ curl -X POST https://[BACKSTAGE_BACKEND]/api/notifications -H "Content-Type: app ## Additional info -Up-to-date documentation can be found in the plugins' README files: +Additional details can be found in the plugins' implementation: -- https://github.com/backstage/backstage/blob/master/plugins/notifications/README.md +- https://github.com/backstage/backstage/blob/master/plugins/notifications -- https://github.com/backstage/backstage/blob/master/plugins/notifications-backend/README.md +- https://github.com/backstage/backstage/blob/master/plugins/notifications-backend -- https://github.com/backstage/backstage/blob/master/plugins/notifications-node/README.md +- https://github.com/backstage/backstage/blob/master/plugins/notifications-node -- https://github.com/backstage/backstage/blob/master/plugins/signals-react/README.md - -## Processors - -The default backend behavior when emitting a new notification can be tweaked using processors. - -Depending on the needs, a processor can modify the content of a notification or route it to different systems like email, Slack, or other services. - -A good example of how to write a processor is the [Email Processor](https://github.com/backstage/backstage/tree/master/plugins/notifications-backend-module-email). +- https://github.com/backstage/backstage/blob/master/plugins/signals-react diff --git a/plugins/notifications-backend/README.md b/plugins/notifications-backend/README.md index 60c9a4e078..ebd129f572 100644 --- a/plugins/notifications-backend/README.md +++ b/plugins/notifications-backend/README.md @@ -4,6 +4,10 @@ Welcome to the notifications backend plugin! ## Getting started +```bash +yarn workspace backend add @backstage/notifications-backend +``` + Add the notifications to your backend: ```ts @@ -18,58 +22,8 @@ the signals plugin (`@backstage/plugin-signals-node`, `@backstage/plugin-signals ## Extending Notifications -The notifications can be extended with `NotificationProcessor`. These processors allow to decorate notifications -before they are sent or/and send the notifications to external services. - -Start off by creating a notification processor: - -```ts -import { Notification } from '@backstage/plugin-notifications-common'; -import { NotificationProcessor } from '@backstage/plugin-notifications-node'; - -class MyNotificationProcessor implements NotificationProcessor { - async decorate(notification: Notification): Promise { - if (notification.origin === 'plugin-my-plugin') { - notification.payload.icon = 'my-icon'; - } - return notification; - } - - async send(notification: Notification): Promise { - nodemailer.sendEmail({ - from: 'backstage', - to: 'user', - subject: notification.payload.title, - text: notification.payload.description, - }); - } -} -``` - -Both of the processing functions are optional, and you can implement only one of them. - -Add the notification processor to the notification system by: - -```ts -import { notificationsProcessingExtensionPoint } from '@backstage/plugin-notifications-node'; -import { Notification } from '@backstage/plugin-notifications-common'; - -export const myPlugin = createBackendPlugin({ - pluginId: 'myPlugin', - register(env) { - env.registerInit({ - deps: { - notifications: notificationsProcessingExtensionPoint, - // ... - }, - async init({ notifications }) { - // ... - notifications.addProcessor(new MyNotificationProcessor()); - }, - }); - }, -}); -``` +When a notification is created, it's processing can be customized via `processors`. +Please refer [Backstage documentation](https://backstage.io/docs/notifications) for further details. ## Sending Notifications By Backend Plugins diff --git a/plugins/notifications/README.md b/plugins/notifications/README.md index 63212d2c16..32fbb8c701 100644 --- a/plugins/notifications/README.md +++ b/plugins/notifications/README.md @@ -2,13 +2,17 @@ Welcome to the notifications plugin! -_This plugin was created through the Backstage CLI_ - ## Getting started First, install the `@backstage/plugin-notifications-backend` and `@backstage/plugin-notifications-node` packages. See the documentation for installation instructions. +Then add this frontend package: + +```bash +yarn workspace app add @backstage/notifications +``` + To add the notifications main menu, add the following to your `packages/app/src/components/Root/Root.tsx`: ```tsx From db7a31b1d722928dab7cd8d41e0c71cdc8f4997d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Jul 2024 16:18:20 +0000 Subject: [PATCH 031/372] chore(deps): bump fast-loops from 1.1.3 to 1.1.4 Bumps [fast-loops](https://github.com/robinweser/fast-loops) from 1.1.3 to 1.1.4. - [Commits](https://github.com/robinweser/fast-loops/commits) --- updated-dependencies: - dependency-name: fast-loops dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index f50727e805..78f28154d3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -27122,9 +27122,9 @@ __metadata: linkType: hard "fast-loops@npm:^1.1.3": - version: 1.1.3 - resolution: "fast-loops@npm:1.1.3" - checksum: b674378ba2ed8364ca1a00768636e88b22201c8d010fa62a8588a4cace04f90bac46714c13cf638be82b03438d2fe813600da32291fb47297a1bd7fa6cef0cee + version: 1.1.4 + resolution: "fast-loops@npm:1.1.4" + checksum: 8031a20f465ef35ac4ad98258470250636112d34f7e4efcb4ef21f3ced99df95a1ef1f0d6943df729a1e3e12a9df9319f3019df8cc1a0e0ed5a118bd72e505f9 languageName: node linkType: hard From ba9abf4fbac58b94508ce7360a318313832e1cfd Mon Sep 17 00:00:00 2001 From: Tim Hansen Date: Fri, 12 Jul 2024 15:24:05 -0600 Subject: [PATCH 032/372] Allow manual trigger frequency in backend-tasks Signed-off-by: Tim Hansen --- .changeset/hip-fishes-guess.md | 6 +++ .changeset/metal-planes-nail.md | 5 +++ .../20240712211735_nullable_next_run.js | 37 +++++++++++++++++++ .../lib/PluginTaskSchedulerImpl.test.ts | 3 ++ .../scheduler/lib/PluginTaskSchedulerImpl.ts | 3 ++ .../scheduler/lib/TaskWorker.test.ts | 28 ++++++++++++++ .../entrypoints/scheduler/lib/TaskWorker.ts | 17 +++++++-- .../src/entrypoints/scheduler/lib/types.ts | 9 +++++ .../services/definitions/SchedulerService.ts | 22 ++++++++--- .../src/tasks/PluginTaskSchedulerImpl.ts | 3 ++ .../src/tasks/TaskWorker.test.ts | 28 ++++++++++++++ .../backend-tasks/src/tasks/TaskWorker.ts | 17 +++++++-- .../readTaskScheduleDefinitionFromConfig.ts | 12 ++++-- packages/backend-tasks/src/tasks/types.ts | 7 +++- 14 files changed, 180 insertions(+), 17 deletions(-) create mode 100644 .changeset/hip-fishes-guess.md create mode 100644 .changeset/metal-planes-nail.md create mode 100644 packages/backend-defaults/migrations/scheduler/20240712211735_nullable_next_run.js diff --git a/.changeset/hip-fishes-guess.md b/.changeset/hip-fishes-guess.md new file mode 100644 index 0000000000..909448c673 --- /dev/null +++ b/.changeset/hip-fishes-guess.md @@ -0,0 +1,6 @@ +--- +'@backstage/backend-plugin-api': patch +'@backstage/backend-defaults': patch +--- + +The `SchedulerService` now allows tasks with `frequency: { trigger: 'manual' }`. This means that the task will not be scheduled, but rather run only when manually triggered with `SchedulerService.triggerTask`. diff --git a/.changeset/metal-planes-nail.md b/.changeset/metal-planes-nail.md new file mode 100644 index 0000000000..2cfa12a435 --- /dev/null +++ b/.changeset/metal-planes-nail.md @@ -0,0 +1,5 @@ +--- +'@backstage/backend-tasks': patch +--- + +The `PluginTaskScheduler` now allows tasks with `frequency: { trigger: 'manual' }`. This means that the task will not be scheduled, but rather run only when manually triggered with `PluginTaskScheduler.triggerTask`. diff --git a/packages/backend-defaults/migrations/scheduler/20240712211735_nullable_next_run.js b/packages/backend-defaults/migrations/scheduler/20240712211735_nullable_next_run.js new file mode 100644 index 0000000000..b636df35d7 --- /dev/null +++ b/packages/backend-defaults/migrations/scheduler/20240712211735_nullable_next_run.js @@ -0,0 +1,37 @@ +/* + * Copyright 2024 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. + */ + +// @ts-check + +/** + * @param { import("knex").Knex } knex + * @returns { Promise } + */ +exports.up = async function up(knex) { + await knex.schema.alterTable('backstage_backend_tasks__tasks', table => { + table.setNullable('next_run_start_at'); + }); +}; + +/** + * @param { import("knex").Knex } knex + * @returns { Promise } + */ +exports.down = async function down(knex) { + await knex.schema.alterTable('backstage_backend_tasks__tasks', table => { + table.dropNullable('next_run_start_at'); + }); +}; diff --git a/packages/backend-defaults/src/entrypoints/scheduler/lib/PluginTaskSchedulerImpl.test.ts b/packages/backend-defaults/src/entrypoints/scheduler/lib/PluginTaskSchedulerImpl.test.ts index c5c4c8708a..0c9219e98e 100644 --- a/packages/backend-defaults/src/entrypoints/scheduler/lib/PluginTaskSchedulerImpl.test.ts +++ b/packages/backend-defaults/src/entrypoints/scheduler/lib/PluginTaskSchedulerImpl.test.ts @@ -347,6 +347,9 @@ describe('PluginTaskManagerImpl', () => { expect(parseDuration({ milliseconds: 5000 })).toEqual('PT5S'); expect(parseDuration(Duration.fromMillis(5000))).toEqual('PT5S'); expect(parseDuration({ cron: '1 * * * *' })).toEqual('1 * * * *'); + expect(parseDuration({ trigger: 'manual' })).toEqual({ + trigger: 'manual', + }); }); }); }); diff --git a/packages/backend-defaults/src/entrypoints/scheduler/lib/PluginTaskSchedulerImpl.ts b/packages/backend-defaults/src/entrypoints/scheduler/lib/PluginTaskSchedulerImpl.ts index 40aa9d521c..f8d06baf56 100644 --- a/packages/backend-defaults/src/entrypoints/scheduler/lib/PluginTaskSchedulerImpl.ts +++ b/packages/backend-defaults/src/entrypoints/scheduler/lib/PluginTaskSchedulerImpl.ts @@ -155,6 +155,9 @@ export function parseDuration( if (typeof frequency === 'object' && 'cron' in frequency) { return frequency.cron; } + if (typeof frequency === 'object' && 'trigger' in frequency) { + return frequency.trigger; + } const parsed = Duration.isDuration(frequency) ? frequency diff --git a/packages/backend-defaults/src/entrypoints/scheduler/lib/TaskWorker.test.ts b/packages/backend-defaults/src/entrypoints/scheduler/lib/TaskWorker.test.ts index 1cafe00670..5db82f3ece 100644 --- a/packages/backend-defaults/src/entrypoints/scheduler/lib/TaskWorker.test.ts +++ b/packages/backend-defaults/src/entrypoints/scheduler/lib/TaskWorker.test.ts @@ -503,4 +503,32 @@ describe('TaskWorker', () => { await knex.destroy(); }, ); + + it.each(databases.eachSupportedId())( + 'next_run_start_at is not set for manually-triggered tasks, %p', + async databaseId => { + const knex = await databases.init(databaseId); + await migrateBackendTasks(knex); + + const fn = jest.fn( + async () => new Promise(resolve => setTimeout(resolve, 50)), + ); + + const initialSettings: TaskSettingsV2 = { + version: 2, + cadence: 'manual', + timeoutAfterDuration: 'PT1M', + }; + + const worker = new TaskWorker('task99', fn, knex, logger); + await worker.persistTask(initialSettings); + await worker.tryClaimTask('ticket', initialSettings); + await worker.tryReleaseTask('ticket', initialSettings); + + const row = (await knex(DB_TASKS_TABLE))[0]; + expect(row.next_run_start_at).toBeNull(); + + await knex.destroy(); + }, + ); }); diff --git a/packages/backend-defaults/src/entrypoints/scheduler/lib/TaskWorker.ts b/packages/backend-defaults/src/entrypoints/scheduler/lib/TaskWorker.ts index a1c4ec44fd..c5570a8e30 100644 --- a/packages/backend-defaults/src/entrypoints/scheduler/lib/TaskWorker.ts +++ b/packages/backend-defaults/src/entrypoints/scheduler/lib/TaskWorker.ts @@ -53,8 +53,8 @@ export class TaskWorker { ); let workCheckFrequency = this.workCheckFrequency; - const isCron = !settings?.cadence.startsWith('P'); - if (!isCron) { + const isDuration = settings?.cadence.startsWith('P'); + if (isDuration) { const cadence = Duration.fromISO(settings.cadence); if (cadence < workCheckFrequency) { workCheckFrequency = cadence; @@ -175,7 +175,9 @@ export class TaskWorker { // read it back again. taskSettingsV2Schema.parse(settings); - const isCron = !settings?.cadence.startsWith('P'); + const isManual = settings?.cadence === 'manual'; + const isDuration = settings?.cadence.startsWith('P'); + const isCron = !isManual && !isDuration; let startAt: Knex.Raw | undefined; let nextStartAt: Knex.Raw | undefined; @@ -194,6 +196,9 @@ export class TaskWorker { nextStartAt = this.nextRunAtRaw(time); startAt ||= nextStartAt; + } else if (isManual) { + nextStartAt = this.knex.raw('null'); + startAt ||= nextStartAt; } else { startAt ||= this.knex.fn.now(); nextStartAt = nowPlus(Duration.fromISO(settings.cadence), this.knex); @@ -317,7 +322,9 @@ export class TaskWorker { ticket: string, settings: TaskSettingsV2, ): Promise { - const isCron = !settings?.cadence.startsWith('P'); + const isManual = settings?.cadence === 'manual'; + const isDuration = settings?.cadence.startsWith('P'); + const isCron = !isManual && !isDuration; let nextRun: Knex.Raw; if (isCron) { @@ -325,6 +332,8 @@ export class TaskWorker { this.logger.debug(`task: ${this.taskId} will next occur around ${time}`); nextRun = this.nextRunAtRaw(time); + } else if (isManual) { + nextRun = this.knex.raw('null'); } else { const dt = Duration.fromISO(settings.cadence).as('seconds'); this.logger.debug( diff --git a/packages/backend-defaults/src/entrypoints/scheduler/lib/types.ts b/packages/backend-defaults/src/entrypoints/scheduler/lib/types.ts index 61e6c1d9a8..173c989543 100644 --- a/packages/backend-defaults/src/entrypoints/scheduler/lib/types.ts +++ b/packages/backend-defaults/src/entrypoints/scheduler/lib/types.ts @@ -40,6 +40,10 @@ function isValidCronFormat(c: string | undefined): boolean { } } +function isValidTrigger(t: string): boolean { + return t === 'manual'; +} + export const taskSettingsV1Schema = z.object({ version: z.literal(1), initialDelayDuration: z @@ -68,6 +72,11 @@ export const taskSettingsV2Schema = z.object({ cadence: z .string() .refine(isValidCronFormat, { message: 'Invalid cron' }) + .or( + z.string().refine(isValidTrigger, { + message: "Invalid trigger, expecting 'manual'", + }), + ) .or( z.string().refine(isValidOptionalDurationString, { message: 'Invalid duration, expecting ISO Period', diff --git a/packages/backend-plugin-api/src/services/definitions/SchedulerService.ts b/packages/backend-plugin-api/src/services/definitions/SchedulerService.ts index a7ec79a336..a8b84b9084 100644 --- a/packages/backend-plugin-api/src/services/definitions/SchedulerService.ts +++ b/packages/backend-plugin-api/src/services/definitions/SchedulerService.ts @@ -96,7 +96,8 @@ export interface SchedulerServiceTaskScheduleDefinition { cron: string; } | Duration - | HumanDuration; + | HumanDuration + | { trigger: 'manual' }; /** * The maximum amount of time that a single task invocation can take, before @@ -193,7 +194,12 @@ export interface SchedulerServiceTaskScheduleDefinitionConfig { cron: string; } | string - | HumanDuration; + | HumanDuration + /** + * This task will only run when manually triggered with the `triggerTask` method; no automatic + * scheduling. This is useful for locking of global tasks that should not be run concurrently. + */ + | { trigger: 'manual' }; /** * The maximum amount of time that a single task invocation can take, before @@ -361,14 +367,20 @@ function readDuration(config: Config, key: string): HumanDuration { return readDurationFromConfig(config, { key }); } -function readCronOrDuration( +function readFrequency( config: Config, key: string, -): { cron: string } | HumanDuration { +): { cron: string } | HumanDuration | { trigger: 'manual' } { const value = config.get(key); if (typeof value === 'object' && (value as { cron?: string }).cron) { return value as { cron: string }; } + if ( + typeof value === 'object' && + (value as { trigger?: string }).trigger === 'manual' + ) { + return { trigger: 'manual' }; + } return readDuration(config, key); } @@ -383,7 +395,7 @@ function readCronOrDuration( export function readSchedulerServiceTaskScheduleDefinitionFromConfig( config: Config, ): SchedulerServiceTaskScheduleDefinition { - const frequency = readCronOrDuration(config, 'frequency'); + const frequency = readFrequency(config, 'frequency'); const timeout = readDuration(config, 'timeout'); const initialDelay = config.has('initialDelay') diff --git a/packages/backend-tasks/src/tasks/PluginTaskSchedulerImpl.ts b/packages/backend-tasks/src/tasks/PluginTaskSchedulerImpl.ts index b1647f4edf..0ccc77a6c1 100644 --- a/packages/backend-tasks/src/tasks/PluginTaskSchedulerImpl.ts +++ b/packages/backend-tasks/src/tasks/PluginTaskSchedulerImpl.ts @@ -152,6 +152,9 @@ export function parseDuration( if ('cron' in frequency) { return frequency.cron; } + if ('trigger' in frequency) { + return frequency.trigger; + } const parsed = Duration.isDuration(frequency) ? frequency diff --git a/packages/backend-tasks/src/tasks/TaskWorker.test.ts b/packages/backend-tasks/src/tasks/TaskWorker.test.ts index 10ebfde5b4..829d7754f8 100644 --- a/packages/backend-tasks/src/tasks/TaskWorker.test.ts +++ b/packages/backend-tasks/src/tasks/TaskWorker.test.ts @@ -503,4 +503,32 @@ describe('TaskWorker', () => { await knex.destroy(); }, ); + + it.each(databases.eachSupportedId())( + 'next_run_start_at is not set for manually-triggered tasks, %p', + async databaseId => { + const knex = await databases.init(databaseId); + await migrateBackendTasks(knex); + + const fn = jest.fn( + async () => new Promise(resolve => setTimeout(resolve, 50)), + ); + + const initialSettings: TaskSettingsV2 = { + version: 2, + cadence: 'manual', + timeoutAfterDuration: 'PT1M', + }; + + const worker = new TaskWorker('task99', fn, knex, logger); + await worker.persistTask(initialSettings); + await worker.tryClaimTask('ticket', initialSettings); + await worker.tryReleaseTask('ticket', initialSettings); + + const row = (await knex(DB_TASKS_TABLE))[0]; + expect(row.next_run_start_at).toBeNull(); + + await knex.destroy(); + }, + ); }); diff --git a/packages/backend-tasks/src/tasks/TaskWorker.ts b/packages/backend-tasks/src/tasks/TaskWorker.ts index 57cbf2203e..a50b988522 100644 --- a/packages/backend-tasks/src/tasks/TaskWorker.ts +++ b/packages/backend-tasks/src/tasks/TaskWorker.ts @@ -52,8 +52,8 @@ export class TaskWorker { ); let workCheckFrequency = this.workCheckFrequency; - const isCron = !settings?.cadence.startsWith('P'); - if (!isCron) { + const isDuration = settings?.cadence.startsWith('P'); + if (isDuration) { const cadence = Duration.fromISO(settings.cadence); if (cadence < workCheckFrequency) { workCheckFrequency = cadence; @@ -174,7 +174,9 @@ export class TaskWorker { // read it back again. taskSettingsV2Schema.parse(settings); - const isCron = !settings?.cadence.startsWith('P'); + const isManual = settings?.cadence === 'manual'; + const isDuration = settings?.cadence.startsWith('P'); + const isCron = !isManual && !isDuration; let startAt: Knex.Raw | undefined; let nextStartAt: Knex.Raw | undefined; @@ -193,6 +195,9 @@ export class TaskWorker { nextStartAt = this.nextRunAtRaw(time); startAt ||= nextStartAt; + } else if (isManual) { + nextStartAt = this.knex.raw('null'); + startAt ||= nextStartAt; } else { startAt ||= this.knex.fn.now(); nextStartAt = nowPlus(Duration.fromISO(settings.cadence), this.knex); @@ -316,7 +321,9 @@ export class TaskWorker { ticket: string, settings: TaskSettingsV2, ): Promise { - const isCron = !settings?.cadence.startsWith('P'); + const isManual = settings?.cadence === 'manual'; + const isDuration = settings?.cadence.startsWith('P'); + const isCron = !isManual && !isDuration; let nextRun: Knex.Raw; if (isCron) { @@ -324,6 +331,8 @@ export class TaskWorker { this.logger.debug(`task: ${this.taskId} will next occur around ${time}`); nextRun = this.nextRunAtRaw(time); + } else if (isManual) { + nextRun = this.knex.raw('null'); } else { const dt = Duration.fromISO(settings.cadence).as('seconds'); this.logger.debug( diff --git a/packages/backend-tasks/src/tasks/readTaskScheduleDefinitionFromConfig.ts b/packages/backend-tasks/src/tasks/readTaskScheduleDefinitionFromConfig.ts index e94d06d5c3..85099d82db 100644 --- a/packages/backend-tasks/src/tasks/readTaskScheduleDefinitionFromConfig.ts +++ b/packages/backend-tasks/src/tasks/readTaskScheduleDefinitionFromConfig.ts @@ -32,14 +32,20 @@ function readDuration(config: Config, key: string): HumanDuration { return readDurationFromConfig(config, { key }); } -function readCronOrDuration( +function readFrequency( config: Config, key: string, -): { cron: string } | Duration | HumanDuration { +): { cron: string } | Duration | HumanDuration | { trigger: 'manual' } { const value = config.get(key); if (typeof value === 'object' && (value as { cron?: string }).cron) { return value as { cron: string }; } + if ( + typeof value === 'object' && + (value as { trigger?: string }).trigger === 'manual' + ) { + return { trigger: 'manual' }; + } return readDuration(config, key); } @@ -56,7 +62,7 @@ function readCronOrDuration( export function readTaskScheduleDefinitionFromConfig( config: Config, ): TaskScheduleDefinition { - const frequency = readCronOrDuration(config, 'frequency'); + const frequency = readFrequency(config, 'frequency'); const timeout = readDuration(config, 'timeout'); const initialDelay = config.has('initialDelay') diff --git a/packages/backend-tasks/src/tasks/types.ts b/packages/backend-tasks/src/tasks/types.ts index e6a31873be..aaa6ca8bd2 100644 --- a/packages/backend-tasks/src/tasks/types.ts +++ b/packages/backend-tasks/src/tasks/types.ts @@ -100,7 +100,12 @@ export interface TaskScheduleDefinition { cron: string; } | Duration - | HumanDuration; + | HumanDuration + /** + * This task will only run when manually triggered with the `triggerTask` method; no automatic + * scheduling. This is useful for locking of global tasks that should not be run concurrently. + */ + | { trigger: 'manual' }; /** * The maximum amount of time that a single task invocation can take, before From be632623e5e3978660099002bc0f12dac4bf8ec3 Mon Sep 17 00:00:00 2001 From: Benjamin Janssens Date: Mon, 15 Jul 2024 09:50:42 +0200 Subject: [PATCH 033/372] chore: improve changeset for @backstage/plugin-scaffolder Signed-off-by: Benjamin Janssens --- .changeset/tough-goats-hang.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/tough-goats-hang.md b/.changeset/tough-goats-hang.md index 6090c582d0..2608c03b2e 100644 --- a/.changeset/tough-goats-hang.md +++ b/.changeset/tough-goats-hang.md @@ -2,4 +2,4 @@ '@backstage/plugin-scaffolder': minor --- -Added field extension `RepoBranchPicker` +Added field extension `RepoBranchPicker` that supports autocompletion for Bitbucket From 5436d971d92dd9d60645e4bdcc4869de5405bb5f Mon Sep 17 00:00:00 2001 From: Benjamin Janssens Date: Mon, 15 Jul 2024 09:51:52 +0200 Subject: [PATCH 034/372] chore: add comment to schema to link duplicated comments together Signed-off-by: Benjamin Janssens --- .../scaffolder/src/components/fields/RepoBranchPicker/schema.ts | 1 + plugins/scaffolder/src/components/fields/RepoUrlPicker/schema.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/plugins/scaffolder/src/components/fields/RepoBranchPicker/schema.ts b/plugins/scaffolder/src/components/fields/RepoBranchPicker/schema.ts index 6ee67bd1c7..fae5e6435e 100644 --- a/plugins/scaffolder/src/components/fields/RepoBranchPicker/schema.ts +++ b/plugins/scaffolder/src/components/fields/RepoBranchPicker/schema.ts @@ -77,6 +77,7 @@ export type RepoBranchPickerUiOptions = export type RepoBranchPickerProps = typeof RepoBranchPickerFieldSchema.type; +// This has been duplicated from /plugins/scaffolder/src/components/fields/RepoUrlPicker/schema.ts // NOTE: There is a bug with this failing validation in the custom field explorer due // to https://github.com/rjsf-team/react-jsonschema-form/issues/675 even if // requestUserCredentials is not defined diff --git a/plugins/scaffolder/src/components/fields/RepoUrlPicker/schema.ts b/plugins/scaffolder/src/components/fields/RepoUrlPicker/schema.ts index 2a4691380f..2ec72bc5a6 100644 --- a/plugins/scaffolder/src/components/fields/RepoUrlPicker/schema.ts +++ b/plugins/scaffolder/src/components/fields/RepoUrlPicker/schema.ts @@ -97,6 +97,7 @@ export type RepoUrlPickerUiOptions = export type RepoUrlPickerProps = typeof RepoUrlPickerFieldSchema.type; +// This has been duplicated to /plugins/scaffolder/src/components/fields/RepoBranchPicker/schema.ts // NOTE: There is a bug with this failing validation in the custom field explorer due // to https://github.com/rjsf-team/react-jsonschema-form/issues/675 even if // requestUserCredentials is not defined From 668fe02828dac3b9d640ec3ecfe0de632e381501 Mon Sep 17 00:00:00 2001 From: Andre Wanlin Date: Sat, 13 Jul 2024 16:30:03 -0500 Subject: [PATCH 035/372] [NBS] Updated Search Docs Signed-off-by: Andre Wanlin --- docs/features/search/collators.md | 108 ++++++++++++++ docs/features/search/getting-started.md | 79 +++------- docs/features/search/how-to-guides.md | 104 ------------- docs/features/search/search-engines.md | 188 +++++++++--------------- microsite/sidebars.json | 3 +- mkdocs.yml | 1 + 6 files changed, 200 insertions(+), 283 deletions(-) create mode 100644 docs/features/search/collators.md diff --git a/docs/features/search/collators.md b/docs/features/search/collators.md new file mode 100644 index 0000000000..9d68f71c32 --- /dev/null +++ b/docs/features/search/collators.md @@ -0,0 +1,108 @@ +--- +id: collators +title: Collators +description: Indexing you Backstage content with Collators +--- + +You need to be able to search something! Collators are the way to define what +can be searched. Backstage includes 2 collators out of the box for the [Catalog](#catalog) and [TechDocs](#techdocs). There's also some from the [Backstage Community](#community-collators) too! + +## Catalog + +The Catalog collator will index all the Entities in your Catalog. It is installed by default but if you need to add it manually here's how. + +First we add the plugin into your backend app: + +```bash title="From your Backstage root directory" +yarn --cwd packages/backend add @backstage/plugin-search-backend-module-catalog +``` + +Then add the following line: + +```ts title="packages/backend/src/index.ts" +const backend = createBackend(); + +// Other plugins... + +// search plugin +backend.add(import('@backstage/plugin-search-backend/alpha')); + +/* highlight-add-start */ +backend.add(import('@backstage/plugin-search-backend-module-catalog/alpha')); +/* highlight-add-end */ + +backend.start(); +``` + +### Configuring the Catalog Collator + +The default schedule for the Catalog Collator is to run every 10 minutes, you can provide your own schedule by adding it to your config: + +```yaml title="app-config.yaml +search: + collators: + catalog: + schedule: # same options as in TaskScheduleDefinition + # supports cron, ISO duration, "human duration" as used in code + initialDelay: { seconds: 90 } + # supports cron, ISO duration, "human duration" as used in code + frequency: { hours: 6 } + # supports ISO duration, "human duration" as used in code + timeout: { minutes: 3 } +``` + +## TechDocs + +The TechDocs collator will index all the TechDocs in your Catalog. It is installed by default but if you need to add it manually here's how. + +First we add the plugin into your backend app: + +```bash title="From your Backstage root directory" +yarn --cwd packages/backend add @backstage/plugin-search-backend-module-techdocs +``` + +Then add the following line: + +```ts title="packages/backend/src/index.ts" +const backend = createBackend(); + +// Other plugins... + +// search plugin +backend.add(import('@backstage/plugin-search-backend/alpha')); + +/* highlight-add-start */ +backend.add(import('@backstage/plugin-search-backend-module-techdocs/alpha')); +/* highlight-add-end */ + +backend.start(); +``` + +### Configuring the TechDocs Collator + +The default schedule for the TechDocs Collator is to run every 10 minutes, you can provide your own schedule by adding it to your config: + +```yaml title="app-config.yaml +search: + collators: + techdocs: + schedule: # same options as in TaskScheduleDefinition + # supports cron, ISO duration, "human duration" as used in code + initialDelay: { seconds: 90 } + # supports cron, ISO duration, "human duration" as used in code + frequency: { hours: 6 } + # supports ISO duration, "human duration" as used in code + timeout: { minutes: 3 } +``` + +## Community Collators + +Here are some of the known Search Collators available in from the Backstage Community: + +- [`@backstage/plugin-search-backend-module-explore`](https://github.com/backstage/backstage/tree/master/plugins/search-backend-module-explore): will index content from the [Explore plugin](https://github.com/backstage/community-plugins/tree/main/workspaces/explore/plugins/explore). +- [`@backstage/plugin-search-backend-module-stack-overflow-collator`](https://github.com/backstage/backstage/tree/master/plugins/search-backend-module-stack-overflow-collator): will index content from Stack Overflow. +- [`@backstage-community/search-backend-module-adr`](https://github.com/backstage/community-plugins/tree/main/workspaces/adr/plugins/search-backend-module-adr): will index content from the [ADR plugin](https://github.com/backstage/community-plugins/tree/main/workspaces/adr/plugins/adr). + +## Custom Collators + +To create your own collators/decorators modules, please use the [searchModuleCatalogCollator](https://github.com/backstage/backstage/blob/d7f955f300893f50c4882ea8f5c09aa42dfaacfd/plugins/search-backend-module-catalog/src/alpha.ts#L49) as an example, we recommend that modules are separated by plugin packages (e.g. `search-backend-module-`). You can also find the available search engines and collator/decorator modules documentation in the Alpha API reports. diff --git a/docs/features/search/getting-started.md b/docs/features/search/getting-started.md index b2a074974f..c2ca2e1dce 100644 --- a/docs/features/search/getting-started.md +++ b/docs/features/search/getting-started.md @@ -133,79 +133,34 @@ For more information about using `Root.tsx`, please see Add the following plugins into your backend app: ```bash title="From your Backstage root directory" -yarn --cwd packages/backend add @backstage/plugin-search-backend @backstage/plugin-search-backend-node +yarn --cwd packages/backend add @backstage/plugin-search-backend @backstage/plugin-search-backend-module-pg @backstage/plugin-search-backend-module-catalog @backstage/plugin-search-backend-module-techdocs ``` -Create a `packages/backend/src/plugins/search.ts` file containing the following -code: +Then add the following lines: -```typescript -import { useHotCleanup } from '@backstage/backend-common'; -import { createRouter } from '@backstage/plugin-search-backend'; -import { - IndexBuilder, - LunrSearchEngine, -} from '@backstage/plugin-search-backend-node'; -import { PluginEnvironment } from '../types'; -import { DefaultCatalogCollator } from '@backstage/plugin-catalog-backend'; -import { Router } from 'express'; +```ts title="packages/backend/src/index.ts" +const backend = createBackend(); -export default async function createPlugin( - env: PluginEnvironment, -): Promise { - const searchEngine = new LunrSearchEngine({ - logger: env.logger, - }); - const indexBuilder = new IndexBuilder({ - logger: env.logger, - searchEngine, - }); +// Other plugins... - const every10MinutesSchedule = env.scheduler.createScheduledTaskRunner({ - frequency: { minutes: 10 }, - timeout: { minutes: 15 }, - initialDelay: { seconds: 3 }, - }); +/* highlight-add-start */ +// search plugin +backend.add(import('@backstage/plugin-search-backend/alpha')); - indexBuilder.addCollator({ - schedule: every10MinutesSchedule, - factory: DefaultCatalogCollatorFactory.fromConfig(env.config, { - discovery: env.discovery, - tokenManager: env.tokenManager, - }), - }); +// search engines +backend.add(import('@backstage/plugin-search-backend-module-pg/alpha')); - const { scheduler } = await indexBuilder.build(); +// search collators +backend.add(import('@backstage/plugin-search-backend-module-catalog/alpha')); +backend.add(import('@backstage/plugin-search-backend-module-techdocs/alpha')); +/* highlight-add-end */ - scheduler.start(); - useHotCleanup(module, () => scheduler.stop()); - - return await createRouter({ - engine: indexBuilder.getSearchEngine(), - logger: env.logger, - }); -} +backend.start(); ``` -Make the following modifications to your `packages/backend/src/index.ts` file: +With the above setup Search will use the [Lunr](https://github.com/olivernn/lunr.js) in-memory Search Engine but if your have Postgres setup as your database then it will use Postgres as your Search Engine. Learn more in the [Search Engines](./search-engines.md) documentation. -Import the `plugins/search` file you created above: - -```typescript -import search from './plugins/search'; -``` - -Set up an environment for search: - -```typescript -const searchEnv = useHotMemoize(module, () => createEnv('search')); -``` - -Register the search service with the router: - -```typescript -apiRouter.use('/search', await search(searchEnv)); -``` +The above also sets up two Collators for you - Catalog and TechDocs - which will index content from these two locations so that you can easily search them. Learn more in the [Collators documentation](./collators.md). ## Customizing Search diff --git a/docs/features/search/how-to-guides.md b/docs/features/search/how-to-guides.md index 9ce30da556..b0df9440f3 100644 --- a/docs/features/search/how-to-guides.md +++ b/docs/features/search/how-to-guides.md @@ -45,75 +45,6 @@ to do that in two steps. }); ``` -## How to index TechDocs documents - -The TechDocs plugin has supported integrations to Search, meaning that it -provides a default collator factory ready to be used. - -The purpose of this guide is to walk you through how to register the -[DefaultTechDocsCollatorFactory](https://github.com/backstage/backstage/blob/1adc2c7/plugins/search-backend-module-techdocs/src/collators/DefaultTechDocsCollatorFactory.ts) -in your App, so that you can get TechDocs documents indexed. - -If you have been through the -[Getting Started with Search guide](https://backstage.io/docs/features/search/getting-started), -you should have the `packages/backend/src/plugins/search.ts` file available. If -so, you can go ahead and follow this guide - if not, start by going through the -getting started guide. - -1. Import the `DefaultTechDocsCollatorFactory` from - `@backstage/plugin-search-backend-module-techdocs`. - - ```typescript - import { DefaultTechDocsCollatorFactory } from '@backstage/plugin-search-backend-module-techdocs'; - ``` - -2. If there isn't an existing schedule you'd like to run the collator on, be - sure to create it first. Something like... - - ```typescript - import { Duration } from 'luxon'; - - const every10MinutesSchedule = env.scheduler.createScheduledTaskRunner({ - frequency: Duration.fromObject({ seconds: 600 }), - timeout: Duration.fromObject({ seconds: 900 }), - initialDelay: Duration.fromObject({ seconds: 3 }), - }); - ``` - -3. Register the `DefaultTechDocsCollatorFactory` with the IndexBuilder. - - ```typescript - indexBuilder.addCollator({ - schedule: every10MinutesSchedule, - factory: DefaultTechDocsCollatorFactory.fromConfig(env.config, { - discovery: env.discovery, - logger: env.logger, - tokenManager: env.tokenManager, - }), - }); - ``` - -You should now have your TechDocs documents indexed to your search engine of -choice! - -If you want your users to be able to filter down to the techdocs type when -searching, you can update your `SearchPage.tsx` file in -`packages/app/src/components/search` by adding `techdocs` to the list of values -of the `SearchType` component. - -```tsx title="packages/app/src/components/search/SearchPage.tsx" - - - {/* ... */} - -``` - -> Check out the documentation around [integrating search into plugins](../../plugins/integrating-search-into-plugins.md#create-a-collator) for how to create your own collator. - ## How to customize fields in the Software Catalog or TechDocs index Sometimes, you might want to have the ability to control which data passes into the search index @@ -388,38 +319,3 @@ export const SearchModal = ({ toggleModal }: { toggleModal: () => void }) => ( ``` There are other more specific search results layout components that also accept result item extensions, check their documentation: [SearchResultList](https://backstage.io/storybook/?path=/story/plugins-search-searchresultlist--with-result-item-extensions) and [SearchResultGroup](https://backstage.io/storybook/?path=/story/plugins-search-searchresultgroup--with-result-item-extensions). - -## How to migrate your backend installation to use Search together with the new backend system - -Recently, the Backstage maintainers [announced the new Backend System](https://backstage.io/blog/2023/02/15/backend-system-alpha). The search plugins are now migrated to support the new backend system. In this guide you will learn how to update your backend set up. - -In "packages/backend/index.ts", install the search plugin [1], the search engine [2], and the search collators/decorators modules [3]: - -```ts -const backend = createBackend(); -// [1] adding the search plugin to the backend -backend.add(import('@backstage/plugin-search-backend/alpha')); -// [2] (optional) the default search engine is Lunr, if you want to extend the search backend with another search engine. -backend.add( - import('@backstage/plugin-search-backend-module-elasticsearch/alpha'), -); -// [3] extending search with collator modules to start index documents, take in optional schedule parameters. -backend.add(import('@backstage/plugin-search-backend-module-catalog/alpha')); -backend.add(import('@backstage/plugin-search-backend-module-techdocs/alpha')); -backend.add(import('@backstage/plugin-search-backend-module-explore/alpha')); - -backend.start(); -``` - -To create your own collators/decorators modules, please use the [searchModuleCatalogCollator](https://github.com/backstage/backstage/blob/d7f955f300893f50c4882ea8f5c09aa42dfaacfd/plugins/search-backend-module-catalog/src/alpha.ts#L49) as an example, we recommend that modules are separated by plugin packages (e.g. `search-backend-module-`). You can also find the available search engines and collator/decorator modules documentation in the Alpha API reports: - -**Search engine modules** - -- Postgres [module](https://github.com/backstage/backstage/blob/d7f955f300893f50c4882ea8f5c09aa42dfaacfd/plugins/search-backend-module-pg/alpha-api-report.md); -- Elasticsearch [module](https://github.com/backstage/backstage/blob/d7f955f300893f50c4882ea8f5c09aa42dfaacfd/plugins/search-backend-module-elasticsearch/alpha-api-report.md). - -**Search collator/decorator modules** - -- Catalog [module](https://github.com/backstage/backstage/blob/d7f955f300893f50c4882ea8f5c09aa42dfaacfd/plugins/search-backend-module-catalog/alpha-api-report.md); -- Explore [module](https://github.com/backstage/backstage/blob/d7f955f300893f50c4882ea8f5c09aa42dfaacfd/plugins/search-backend-module-explore/alpha-api-report.md); -- TechDocs [module](https://github.com/backstage/backstage/blob/d7f955f300893f50c4882ea8f5c09aa42dfaacfd/plugins/search-backend-module-techdocs/alpha-api-report.md). diff --git a/docs/features/search/search-engines.md b/docs/features/search/search-engines.md index 86b6244fb6..f768a9bde8 100644 --- a/docs/features/search/search-engines.md +++ b/docs/features/search/search-engines.md @@ -4,34 +4,31 @@ title: Search Engines description: Choosing and configuring your search engine for Backstage --- -Backstage supports 3 search engines by default, an in-memory engine called Lunr, -Elasticsearch and Postgres. You can configure your own search engines by -implementing the provided interface as mentioned in the -[search backend documentation.](./getting-started.md#Backend) - -Provided search engine implementations have their own way of constructing -queries, which may be something you want to modify. Alterations to the querying -logic of a search engine can be made by providing your own implementation of a -QueryTranslator interface. This modification can be done without touching -provided search engines by using the exposed setter to set the modified query -translator into the instance. - -```typescript -const searchEngine = new LunrSearchEngine({ logger: env.logger }); -searchEngine.setTranslator(new MyNewAndBetterQueryTranslator()); -``` +Backstage supports 3 search engines by default, an in-memory engine called [Lunr](#lunr), [Postgres](#postgres) +and [Elasticsearch](#elasticsearch). ## Lunr -Lunr search engine is enabled by default for your backstage instance if you have -not done additional changes to the scaffolded app. +Lunr search engine is enabled by default for your Backstage instance if you have not done additional changes to the scaffolded app. -Lunr can be instantiated like this: +As Lunr is built into the Search backend plugin it can be added like this: -```typescript -// app/backend/src/plugins/search.ts -const searchEngine = new LunrSearchEngine({ logger: env.logger }); -const indexBuilder = new IndexBuilder({ logger: env.logger, searchEngine }); +```bash title="From your Backstage root directory" +yarn --cwd packages/backend add @backstage/plugin-search-backend +``` + +Then add the following line: + +```ts title="packages/backend/src/index.ts" +const backend = createBackend(); + +// Other plugins... + +/* highlight-add-start */ +backend.add(import('@backstage/plugin-search-backend/alpha')); +/* highlight-add-end */ + +backend.start(); ``` :::note Note @@ -45,34 +42,39 @@ other search engines instead. ## Postgres -The Postgres based search engine only requires that postgres being configured as +The Postgres based search engine only requires that Postgres being configured as the database engine for Backstage. Therefore it targets setups that want to avoid maintaining another external service like Elasticsearch. The search provides decent results and performs well with ten thousands of indexed -documents. The connection to postgres is established via the database manager +documents. The connection to Postgres is established via the database manager also used by other plugins. > **Important**: The search plugin requires at least Postgres 12! -To use the `PgSearchEngine`, make sure that you have a Postgres database -configured and make the following changes to your backend: +First we need to add the plugin: -1. Add a dependency on `@backstage/plugin-search-backend-module-pg` to your - backend's `package.json`. -2. Initialize the search engine. It is recommended to initialize it with a - fallback to the lunr search engine if you are running Backstage for - development locally with SQLite: - -```typescript -// In packages/backend/src/plugins/search.ts - -// Initialize a connection to a search engine. -const searchEngine = (await PgSearchEngine.supported(env.database)) - ? await PgSearchEngine.fromConfig(env.config, { database: env.database }) - : new LunrSearchEngine({ logger: env.logger }); +```bash title="From your Backstage root directory" +yarn --cwd packages/backend add @backstage/plugin-search-backend-module-pg ``` -## Optional Configuration +Then add the following line: + +```ts title="packages/backend/src/index.ts" +const backend = createBackend(); + +// Other plugins... + +// search plugin +backend.add(import('@backstage/plugin-search-backend/alpha')); + +/* highlight-add-start */ +backend.add(import('@backstage/plugin-search-backend-module-pg/alpha')); +/* highlight-add-end */ + +backend.start(); +``` + +### Optional Configuration The following is an example of the optional configuration that can be applied when using Postgres as the search backend. Currently this is mostly for just the highlight feature: @@ -106,19 +108,32 @@ Backstage supports Elasticsearch (and OpenSearch) search engine connections, indexing and querying out of the box. Available configuration options enable usage of either AWS or Elastic.co hosted solutions, or a custom self-hosted solution. -Similarly to Lunr above, Elasticsearch can be set up like this: +Similarly to Postgres above, Elasticsearch can be set up as follows. -```typescript -// app/backend/src/plugins/search.ts -const searchEngine = await ElasticSearchSearchEngine.fromConfig({ - logger: env.logger, - config: env.config, -}); -const indexBuilder = new IndexBuilder({ logger: env.logger, searchEngine }); +First we need to add the plugin: + +```bash title="From your Backstage root directory" +yarn --cwd packages/backend add @backstage/plugin-search-backend-module-elasticsearch ``` -For the engine to be available, your backend package needs a dependency on -package `@backstage/plugin-search-backend-module-elasticsearch`. +Then add the following line: + +```ts title="packages/backend/src/index.ts" +const backend = createBackend(); + +// Other plugins... + +// search plugin +backend.add(import('@backstage/plugin-search-backend/alpha')); + +/* highlight-add-start */ +backend.add( + import('@backstage/plugin-search-backend-module-elasticsearch/alpha'), +); +/* highlight-add-end */ + +backend.start(); +``` Elasticsearch needs some additional configuration before it is ready to use within your instance. The configuration options are documented in the @@ -126,67 +141,12 @@ within your instance. The configuration options are documented in the The underlying functionality uses either the official Elasticsearch client version 7.x (meaning that Elasticsearch version 7 is the only one confirmed to -be supported), or the OpenSearch client, when the `aws` or `opensearch `provider +be supported), or the OpenSearch client, when the `aws` or `opensearch` provider is configured. -Should you need to create your own bespoke search experiences that require more -than just a query translator (such as faceted search or Relay pagination), you -can access the configuration of the search engine in order to create new -Elasticsearch clients. The version of the client need not be the same as one -used internally by the Elasticsearch engine plugin. For example: +### Example configurations -```typescript -import { isOpenSearchCompatible } from '@backstage/plugin-search-backend-module-elasticsearch'; -import { Client as ElasticClient } from '@elastic/elasticsearch'; -import { Client as OpenSearchClient } from '@opensearch-project/opensearch'; - -// Return an Elasticsearch client -const esClient = searchEngine.newClient(options => { - if (!isOpenSearchCompatible(options)) { - return new ElasticClient(options); - } - - throw new Error('Incompatible options'); -}); - -// Return an OpenSearch client -const osClient = searchEngine.newClient(options => { - if (isOpenSearchCompatible(options)) { - return new OpenSearchClient(options); - } - - throw new Error('Incompatible options'); -}); -``` - -#### Set custom index template - -The Elasticsearch engine gives you the ability to set a custom index template if needed. - -> Index templates define settings, mappings, and aliases that can be applied automatically to new indices. - -```typescript -// app/backend/src/plugins/search.ts -const searchEngine = await ElasticSearchSearchEngine.initialize({ - logger: env.logger, - config: env.config, -}); - -searchEngine.setIndexTemplate({ - name: '', - body: { - index_patterns: [''], - template: { - mappings: {}, - settings: {}, - }, - }, -}); -``` - -## Example configurations - -### AWS +#### AWS Using AWS hosted Elasticsearch the only configuration option needed is the URL to the Elasticsearch service. The implementation assumes that environment @@ -201,7 +161,7 @@ search: node: https://my-backstage-search-asdfqwerty.eu-west-1.es.amazonaws.com ``` -### Elastic.co +#### Elastic.co Elastic Cloud hosted Elasticsearch uses a Cloud ID to determine the instance of hosted Elasticsearch to connect to. Additionally, username and password needs to @@ -218,7 +178,7 @@ search: password: changeme ``` -### OpenSearch +#### OpenSearch OpenSearch can be self hosted for example with the [official docker image](https://hub.docker.com/r/opensearchproject/opensearch). The configuration requires only the node and authentication. @@ -232,7 +192,7 @@ search: password: changeme ``` -### Others +#### Others Other Elasticsearch instances can be connected to by using standard Elasticsearch authentication methods and exposed URL, provided that the cluster @@ -242,8 +202,6 @@ username/password or an API key. For more information how to create an API key, see [Elastic documentation on API keys](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html). -#### Configuration examples - ##### With username and password ```yaml @@ -273,8 +231,6 @@ you may get an error caused by limited `thread_pool` configuration. ( `429 Too M In this case you need to decrease the batch size to index the resources to prevent this kind of error. You can easily decrease or increase the batch size in your `app-config.yaml` using the `batchSize` option provided for Elasticsearch configuration. -#### Configuration example - **Set batch size to 100** ```yaml diff --git a/microsite/sidebars.json b/microsite/sidebars.json index 075025afbb..2d533912f3 100644 --- a/microsite/sidebars.json +++ b/microsite/sidebars.json @@ -132,7 +132,8 @@ "features/search/concepts", "features/search/architecture", "features/search/search-engines", - "features/search/how-to-guides" + "features/search/how-to-guides", + "features/search/collators" ] }, { diff --git a/mkdocs.yml b/mkdocs.yml index f163005377..d9bbb94db5 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -70,6 +70,7 @@ nav: - Concepts: 'features/search/concepts.md' - Search Architecture: 'features/search/architecture.md' - Search Engines: 'features/search/search-engines.md' + - Collators: 'features/search/collators.md' - HOW TO guides: 'features/search/how-to-guides.md' - TechDocs: - Overview: 'features/techdocs/README.md' From 1e6c3ac445c32330cc25f52234ad007daa8842a7 Mon Sep 17 00:00:00 2001 From: Tim Hansen Date: Tue, 16 Jul 2024 08:30:02 -0400 Subject: [PATCH 036/372] Move migration tests Signed-off-by: Tim Hansen --- packages/backend-defaults/migrations.test.ts | 128 ++++++++++++++++++ .../20240712211735_nullable_next_run.js | 37 +++++ packages/backend-tasks/src/migrations.test.ts | 44 ++++++ 3 files changed, 209 insertions(+) create mode 100644 packages/backend-defaults/migrations.test.ts create mode 100644 packages/backend-tasks/migrations/20240712211735_nullable_next_run.js diff --git a/packages/backend-defaults/migrations.test.ts b/packages/backend-defaults/migrations.test.ts new file mode 100644 index 0000000000..98f4e41706 --- /dev/null +++ b/packages/backend-defaults/migrations.test.ts @@ -0,0 +1,128 @@ +/* + * Copyright 2024 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 { Knex } from 'knex'; +import { TestDatabases } from '@backstage/backend-test-utils'; +import fs from 'fs'; + +const migrationsDir = `${__dirname}/../migrations`; +const migrationsFiles = fs.readdirSync(migrationsDir).sort(); + +async function migrateUpOnce(knex: Knex): Promise { + await knex.migrate.up({ directory: migrationsDir }); +} + +async function migrateDownOnce(knex: Knex): Promise { + await knex.migrate.down({ directory: migrationsDir }); +} + +async function migrateUntilBefore(knex: Knex, target: string): Promise { + const index = migrationsFiles.indexOf(target); + if (index === -1) { + throw new Error(`Migration ${target} not found`); + } + for (let i = 0; i < index; i++) { + await migrateUpOnce(knex); + } +} + +jest.setTimeout(60_000); + +describe('migrations', () => { + const databases = TestDatabases.create(); + + it.each(databases.eachSupportedId())( + '20210928160613_init.js, %p', + async databaseId => { + const knex = await databases.init(databaseId); + + await migrateUntilBefore(knex, '20210928160613_init.js'); + await migrateUpOnce(knex); + + await knex('backstage_backend_tasks__tasks').insert({ + id: 'test', + settings_json: '{}', + next_run_start_at: knex.fn.now(), + }); + + await expect(knex('backstage_backend_tasks__tasks')).resolves.toEqual([ + { + id: 'test', + settings_json: '{}', + next_run_start_at: expect.anything(), + current_run_ticket: null, + current_run_started_at: null, + current_run_expires_at: null, + }, + ]); + + await migrateDownOnce(knex); + + // This looks odd - you might expect a .toThrow at the end but that + // actually is flaky for some reason specifically on sqlite when + // performing multiple runs in sequence + await expect(knex('backstage_backend_tasks__tasks')).rejects.toEqual( + expect.anything(), + ); + + await knex.destroy(); + }, + ); + + it.each(databases.eachSupportedId())( + '20240712211735_nullable_next_run.js, %p', + async databaseId => { + const knex = await databases.init(databaseId); + + await migrateUntilBefore(knex, '20240712211735_nullable_next_run.js'); + await migrateUpOnce(knex); + + await knex('backstage_backend_tasks__tasks').insert({ + id: 'test', + settings_json: '{}', + next_run_start_at: knex.raw('null'), + }); + + await expect(knex('backstage_backend_tasks__tasks')).resolves.toEqual([ + { + id: 'test', + settings_json: '{}', + next_run_start_at: null, + current_run_ticket: null, + current_run_started_at: null, + current_run_expires_at: null, + }, + ]); + + await knex + .delete() + .from('backstage_backend_tasks__tasks') + .where({ next_run_start_at: null }); + + await migrateDownOnce(knex); + + await expect( + knex('backstage_backend_tasks__tasks').insert({ + id: 'test', + settings_json: '{}', + next_run_start_at: knex.raw('null'), + }), + ).rejects.toEqual(expect.anything()); + + await knex.destroy(); + }, + ); +}); diff --git a/packages/backend-tasks/migrations/20240712211735_nullable_next_run.js b/packages/backend-tasks/migrations/20240712211735_nullable_next_run.js new file mode 100644 index 0000000000..b636df35d7 --- /dev/null +++ b/packages/backend-tasks/migrations/20240712211735_nullable_next_run.js @@ -0,0 +1,37 @@ +/* + * Copyright 2024 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. + */ + +// @ts-check + +/** + * @param { import("knex").Knex } knex + * @returns { Promise } + */ +exports.up = async function up(knex) { + await knex.schema.alterTable('backstage_backend_tasks__tasks', table => { + table.setNullable('next_run_start_at'); + }); +}; + +/** + * @param { import("knex").Knex } knex + * @returns { Promise } + */ +exports.down = async function down(knex) { + await knex.schema.alterTable('backstage_backend_tasks__tasks', table => { + table.dropNullable('next_run_start_at'); + }); +}; diff --git a/packages/backend-tasks/src/migrations.test.ts b/packages/backend-tasks/src/migrations.test.ts index 82208da975..49576d8a58 100644 --- a/packages/backend-tasks/src/migrations.test.ts +++ b/packages/backend-tasks/src/migrations.test.ts @@ -81,4 +81,48 @@ describe('migrations', () => { await knex.destroy(); }, ); + + it.each(databases.eachSupportedId())( + '20240712211735_nullable_next_run.js, %p', + async databaseId => { + const knex = await databases.init(databaseId); + + await migrateUntilBefore(knex, '20240712211735_nullable_next_run.js'); + await migrateUpOnce(knex); + + await knex('backstage_backend_tasks__tasks').insert({ + id: 'test', + settings_json: '{}', + next_run_start_at: knex.raw('null'), + }); + + await expect(knex('backstage_backend_tasks__tasks')).resolves.toEqual([ + { + id: 'test', + settings_json: '{}', + next_run_start_at: null, + current_run_ticket: null, + current_run_started_at: null, + current_run_expires_at: null, + }, + ]); + + await knex + .delete() + .from('backstage_backend_tasks__tasks') + .where({ next_run_start_at: null }); + + await migrateDownOnce(knex); + + await expect( + knex('backstage_backend_tasks__tasks').insert({ + id: 'test', + settings_json: '{}', + next_run_start_at: knex.raw('null'), + }), + ).rejects.toEqual(expect.anything()); + + await knex.destroy(); + }, + ); }); From 03692ff5396e5ca8c071320deca3bf446ad85880 Mon Sep 17 00:00:00 2001 From: Tim Hansen Date: Tue, 16 Jul 2024 09:34:27 -0400 Subject: [PATCH 037/372] api-reports Signed-off-by: Tim Hansen --- packages/backend-plugin-api/api-report.md | 14 ++++++++++++-- packages/backend-tasks/api-report.md | 9 ++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/backend-plugin-api/api-report.md b/packages/backend-plugin-api/api-report.md index 7b1e6ef2d3..0938ae4e7e 100644 --- a/packages/backend-plugin-api/api-report.md +++ b/packages/backend-plugin-api/api-report.md @@ -608,7 +608,10 @@ export interface SchedulerServiceTaskScheduleDefinition { cron: string; } | Duration - | HumanDuration; + | HumanDuration + | { + trigger: 'manual'; + }; initialDelay?: Duration | HumanDuration; scope?: 'global' | 'local'; timeout: Duration | HumanDuration; @@ -621,7 +624,14 @@ export interface SchedulerServiceTaskScheduleDefinitionConfig { cron: string; } | string - | HumanDuration; + | HumanDuration + /** + * This task will only run when manually triggered with the `triggerTask` method; no automatic + * scheduling. This is useful for locking of global tasks that should not be run concurrently. + */ + | { + trigger: 'manual'; + }; initialDelay?: string | HumanDuration; scope?: 'global' | 'local'; timeout: string | HumanDuration; diff --git a/packages/backend-tasks/api-report.md b/packages/backend-tasks/api-report.md index 0d5ced044a..c0f9da3a01 100644 --- a/packages/backend-tasks/api-report.md +++ b/packages/backend-tasks/api-report.md @@ -62,7 +62,14 @@ export interface TaskScheduleDefinition { cron: string; } | Duration - | HumanDuration_2; + | HumanDuration_2 + /** + * This task will only run when manually triggered with the `triggerTask` method; no automatic + * scheduling. This is useful for locking of global tasks that should not be run concurrently. + */ + | { + trigger: 'manual'; + }; initialDelay?: Duration | HumanDuration_2; scope?: 'global' | 'local'; timeout: Duration | HumanDuration_2; From c8b0732b5cf798b703181adaf1ce70a0ea367d5c Mon Sep 17 00:00:00 2001 From: Tim Hansen Date: Tue, 16 Jul 2024 09:59:15 -0400 Subject: [PATCH 038/372] Fix parseDuration test Signed-off-by: Tim Hansen --- .../entrypoints/scheduler/lib/PluginTaskSchedulerImpl.test.ts | 4 +--- .../backend-tasks/src/tasks/PluginTaskSchedulerImpl.test.ts | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/backend-defaults/src/entrypoints/scheduler/lib/PluginTaskSchedulerImpl.test.ts b/packages/backend-defaults/src/entrypoints/scheduler/lib/PluginTaskSchedulerImpl.test.ts index 0c9219e98e..3e0782d4a3 100644 --- a/packages/backend-defaults/src/entrypoints/scheduler/lib/PluginTaskSchedulerImpl.test.ts +++ b/packages/backend-defaults/src/entrypoints/scheduler/lib/PluginTaskSchedulerImpl.test.ts @@ -347,9 +347,7 @@ describe('PluginTaskManagerImpl', () => { expect(parseDuration({ milliseconds: 5000 })).toEqual('PT5S'); expect(parseDuration(Duration.fromMillis(5000))).toEqual('PT5S'); expect(parseDuration({ cron: '1 * * * *' })).toEqual('1 * * * *'); - expect(parseDuration({ trigger: 'manual' })).toEqual({ - trigger: 'manual', - }); + expect(parseDuration({ trigger: 'manual' })).toEqual('manual'); }); }); }); diff --git a/packages/backend-tasks/src/tasks/PluginTaskSchedulerImpl.test.ts b/packages/backend-tasks/src/tasks/PluginTaskSchedulerImpl.test.ts index 77965632e9..eca899098f 100644 --- a/packages/backend-tasks/src/tasks/PluginTaskSchedulerImpl.test.ts +++ b/packages/backend-tasks/src/tasks/PluginTaskSchedulerImpl.test.ts @@ -345,6 +345,7 @@ describe('PluginTaskManagerImpl', () => { expect(parseDuration({ milliseconds: 5000 })).toEqual('PT5S'); expect(parseDuration(Duration.fromMillis(5000))).toEqual('PT5S'); expect(parseDuration({ cron: '1 * * * *' })).toEqual('1 * * * *'); + expect(parseDuration({ trigger: 'manual' })).toEqual('manual'); }); }); }); From 11aaaa496a97a740ef52f080cc06e82b3625752b Mon Sep 17 00:00:00 2001 From: Camila Belo Date: Mon, 8 Jul 2024 16:08:04 +0200 Subject: [PATCH 039/372] feat: start implementing multiple service factories Co-authored-by: Patrik Oldsberg Signed-off-by: Camila Belo --- packages/backend-app-api/api-report-alpha.md | 1 + packages/backend-app-api/api-report.md | 21 +- .../src/wiring/ServiceRegistry.ts | 265 +++++++++++------- packages/backend-defaults/api-report-auth.md | 1 + packages/backend-defaults/api-report-cache.md | 1 + .../backend-defaults/api-report-database.md | 1 + .../backend-defaults/api-report-discovery.md | 1 + .../backend-defaults/api-report-httpAuth.md | 1 + .../backend-defaults/api-report-httpRouter.md | 1 + .../backend-defaults/api-report-lifecycle.md | 1 + .../backend-defaults/api-report-logger.md | 1 + .../api-report-permissions.md | 1 + .../backend-defaults/api-report-rootConfig.md | 4 +- .../backend-defaults/api-report-rootHealth.md | 1 + .../api-report-rootHttpRouter.md | 4 +- .../api-report-rootLifecycle.md | 1 + .../backend-defaults/api-report-rootLogger.md | 1 + .../backend-defaults/api-report-scheduler.md | 1 + .../backend-defaults/api-report-urlReader.md | 1 + .../backend-defaults/api-report-userInfo.md | 1 + .../urlReader/urlReaderServiceFactory.ts | 29 +- .../api-report.md | 7 +- .../backend-plugin-api/api-report-alpha.md | 3 +- packages/backend-plugin-api/api-report.md | 125 ++++++--- packages/backend-plugin-api/src/deprecated.ts | 9 +- .../src/services/system/types.ts | 149 +++++++--- packages/backend-test-utils/api-report.md | 123 +++++--- .../src/next/wiring/ServiceFactoryTester.ts | 37 ++- plugins/catalog-node/api-report-alpha.md | 2 +- plugins/events-node/api-report.md | 3 +- plugins/notifications-node/api-report.md | 6 +- .../search-backend-node/api-report-alpha.md | 6 +- plugins/signals-node/api-report.md | 4 +- 33 files changed, 563 insertions(+), 250 deletions(-) diff --git a/packages/backend-app-api/api-report-alpha.md b/packages/backend-app-api/api-report-alpha.md index e4769f4e72..b811208845 100644 --- a/packages/backend-app-api/api-report-alpha.md +++ b/packages/backend-app-api/api-report-alpha.md @@ -10,6 +10,7 @@ import { ServiceFactoryCompat } from '@backstage/backend-plugin-api'; export const featureDiscoveryServiceFactory: ServiceFactoryCompat< FeatureDiscoveryService, 'root', + true, undefined >; diff --git a/packages/backend-app-api/api-report.md b/packages/backend-app-api/api-report.md index 7f9b54dd8f..4019ad3086 100644 --- a/packages/backend-app-api/api-report.md +++ b/packages/backend-app-api/api-report.md @@ -49,6 +49,7 @@ import { UserInfoService } from '@backstage/backend-plugin-api'; export const authServiceFactory: ServiceFactoryCompat< AuthService, 'plugin', + true, undefined >; @@ -80,6 +81,7 @@ export interface Backend { export const cacheServiceFactory: ServiceFactoryCompat< CacheService, 'plugin', + true, undefined >; @@ -113,6 +115,7 @@ export interface CreateSpecializedBackendOptions { export const databaseServiceFactory: ServiceFactoryCompat< DatabaseService, 'plugin', + true, undefined >; @@ -135,6 +138,7 @@ export type DefaultRootHttpRouterOptions = DefaultRootHttpRouterOptions_2; export const discoveryServiceFactory: ServiceFactoryCompat< DiscoveryService, 'plugin', + true, undefined >; @@ -161,6 +165,7 @@ export class HostDiscovery implements DiscoveryService { export const httpAuthServiceFactory: ServiceFactoryCompat< HttpAuthService, 'plugin', + true, undefined >; @@ -168,6 +173,7 @@ export const httpAuthServiceFactory: ServiceFactoryCompat< export const httpRouterServiceFactory: ServiceFactoryCompat< HttpRouterService, 'plugin', + true, undefined >; @@ -191,6 +197,7 @@ export type IdentityFactoryOptions = { export const identityServiceFactory: ServiceFactoryCompat< IdentityService, 'plugin', + true, IdentityFactoryOptions >; @@ -203,6 +210,7 @@ export type LifecycleMiddlewareOptions = LifecycleMiddlewareOptions_2; export const lifecycleServiceFactory: ServiceFactoryCompat< LifecycleService, 'plugin', + true, undefined >; @@ -220,6 +228,7 @@ export function loadBackendConfig(options: { export const loggerServiceFactory: ServiceFactoryCompat< LoggerService, 'plugin', + true, undefined >; @@ -248,6 +257,7 @@ export type MiddlewareFactoryOptions = MiddlewareFactoryOptions_2; export const permissionsServiceFactory: ServiceFactoryCompat< PermissionsService, 'plugin', + true, undefined >; @@ -278,6 +288,7 @@ export interface RootConfigFactoryOptions { export const rootConfigServiceFactory: ServiceFactoryCompat< RootConfigService, 'root', + true, RootConfigFactoryOptions >; @@ -294,13 +305,14 @@ export type RootHttpRouterFactoryOptions = RootHttpRouterFactoryOptions_2; // @public @deprecated (undocumented) export const rootHttpRouterServiceFactory: (( options?: RootHttpRouterFactoryOptions_2 | undefined, -) => ServiceFactory) & - ServiceFactory; +) => ServiceFactory) & + ServiceFactory; // @public @deprecated export const rootLifecycleServiceFactory: ServiceFactoryCompat< RootLifecycleService, 'root', + true, undefined >; @@ -308,6 +320,7 @@ export const rootLifecycleServiceFactory: ServiceFactoryCompat< export const rootLoggerServiceFactory: ServiceFactoryCompat< RootLoggerService, 'root', + true, undefined >; @@ -315,6 +328,7 @@ export const rootLoggerServiceFactory: ServiceFactoryCompat< export const schedulerServiceFactory: ServiceFactoryCompat< SchedulerService, 'plugin', + true, undefined >; @@ -322,6 +336,7 @@ export const schedulerServiceFactory: ServiceFactoryCompat< export const tokenManagerServiceFactory: ServiceFactoryCompat< TokenManagerService, 'plugin', + true, undefined >; @@ -329,6 +344,7 @@ export const tokenManagerServiceFactory: ServiceFactoryCompat< export const urlReaderServiceFactory: ServiceFactoryCompat< UrlReaderService, 'plugin', + true, undefined >; @@ -336,6 +352,7 @@ export const urlReaderServiceFactory: ServiceFactoryCompat< export const userInfoServiceFactory: ServiceFactoryCompat< UserInfoService, 'plugin', + true, undefined >; diff --git a/packages/backend-app-api/src/wiring/ServiceRegistry.ts b/packages/backend-app-api/src/wiring/ServiceRegistry.ts index 56d8d611bb..e1644dad89 100644 --- a/packages/backend-app-api/src/wiring/ServiceRegistry.ts +++ b/packages/backend-app-api/src/wiring/ServiceRegistry.ts @@ -58,12 +58,24 @@ function createPluginMetadataServiceFactory(pluginId: string) { export class ServiceRegistry { static create(factories: Array): ServiceRegistry { - const registry = new ServiceRegistry(factories); + const factoryMap = new Map(); + for (const factory of factories) { + if (factory.service.singleton) { + factoryMap.set(factory.service.id, [toInternalServiceFactory(factory)]); + } else { + const existing = factoryMap.get(factory.service.id) ?? []; + factoryMap.set( + factory.service.id, + existing.concat(toInternalServiceFactory(factory)), + ); + } + } + const registry = new ServiceRegistry(factoryMap); registry.checkForCircularDeps(); return registry; } - readonly #providedFactories: Map; + readonly #providedFactories: Map; readonly #loadedDefaultFactories: Map< Function, Promise @@ -82,10 +94,8 @@ export class ServiceRegistry { readonly #addedFactoryIds = new Set(); readonly #instantiatedFactories = new Set(); - private constructor(factories: Array) { - this.#providedFactories = new Map( - factories.map(sf => [sf.service.id, toInternalServiceFactory(sf)]), - ); + private constructor(factories: Map) { + this.#providedFactories = factories; this.#loadedDefaultFactories = new Map(); this.#implementations = new Map(); } @@ -93,17 +103,17 @@ export class ServiceRegistry { #resolveFactory( ref: ServiceRef, pluginId: string, - ): Promise | undefined { + ): Promise | undefined { // Special case handling of the plugin metadata service, generating a custom factory for it each time if (ref.id === coreServices.pluginMetadata.id) { - return Promise.resolve( + return Promise.resolve([ toInternalServiceFactory(createPluginMetadataServiceFactory(pluginId)), - ); + ]); } let resolvedFactory: - | Promise - | InternalServiceFactory + | Promise + | InternalServiceFactory[] | undefined = this.#providedFactories.get(ref.id); const { __defaultFactory: defaultFactory } = ref as InternalServiceRef; if (!resolvedFactory && !defaultFactory) { @@ -120,15 +130,18 @@ export class ServiceRegistry { ); this.#loadedDefaultFactories.set(defaultFactory!, loadedFactory); } - resolvedFactory = loadedFactory.catch(error => { - throw new Error( - `Failed to instantiate service '${ - ref.id - }' because the default factory loader threw an error, ${stringifyError( - error, - )}`, - ); - }); + resolvedFactory = loadedFactory.then( + factory => [factory], + error => { + throw new Error( + `Failed to instantiate service '${ + ref.id + }' because the default factory loader threw an error, ${stringifyError( + error, + )}`, + ); + }, + ); } return Promise.resolve(resolvedFactory); @@ -142,6 +155,9 @@ export class ServiceRegistry { if (this.#providedFactories.get(ref.id)) { return false; } + if (!ref.singleton) { + return false; + } return !(ref as InternalServiceRef).__defaultFactory; }); @@ -156,13 +172,13 @@ export class ServiceRegistry { checkForCircularDeps(): void { const graph = DependencyGraph.fromIterable( - Array.from(this.#providedFactories).map( - ([serviceId, serviceFactory]) => ({ - value: serviceId, - provides: [serviceId], - consumes: Object.values(serviceFactory.deps).map(d => d.id), - }), - ), + Array.from(this.#providedFactories).map(([serviceId, factories]) => ({ + value: serviceId, + provides: [serviceId], + consumes: factories.flatMap(factory => + Object.values(factory.deps).map(d => d.id), + ), + })), ); const circularDependencies = Array.from(graph.detectCircularDependencies()); @@ -183,27 +199,36 @@ export class ServiceRegistry { ); } - if (this.#addedFactoryIds.has(factoryId)) { - throw new Error( - `Duplicate service implementations provided for ${factoryId}`, - ); - } - if (this.#instantiatedFactories.has(factoryId)) { throw new Error( `Unable to set service factory with id ${factoryId}, service has already been instantiated`, ); } - this.#addedFactoryIds.add(factoryId); - this.#providedFactories.set(factoryId, toInternalServiceFactory(factory)); + if (factory.service.singleton) { + if (this.#addedFactoryIds.has(factoryId)) { + throw new Error( + `Duplicate service implementations provided for ${factoryId}`, + ); + } + + this.#addedFactoryIds.add(factoryId); + this.#providedFactories.set(factoryId, [ + toInternalServiceFactory(factory), + ]); + } else { + const newFactories = ( + this.#providedFactories.get(factoryId) ?? [] + ).concat(toInternalServiceFactory(factory)); + this.#providedFactories.set(factoryId, newFactories); + } } async initializeEagerServicesWithScope( scope: 'root' | 'plugin', pluginId: string = 'root', ) { - for (const factory of this.#providedFactories.values()) { + for (const [factory] of this.#providedFactories.values()) { if (factory.service.scope === scope) { // Root-scoped services are eager by default, plugin-scoped are lazy by default if (scope === 'root' && factory.initialization !== 'lazy') { @@ -215,88 +240,112 @@ export class ServiceRegistry { } } - get(ref: ServiceRef, pluginId: string): Promise | undefined { + get( + ref: ServiceRef, + pluginId: string, + ): Promise | undefined { this.#instantiatedFactories.add(ref.id); - return this.#resolveFactory(ref, pluginId)?.then(factory => { - if (factory.service.scope === 'root') { - let existing = this.#rootServiceImplementations.get(factory); - if (!existing) { - this.#checkForMissingDeps(factory, pluginId); - const rootDeps = new Array>(); + const resolvedFactory = this.#resolveFactory(ref, pluginId); - for (const [name, serviceRef] of Object.entries(factory.deps)) { - if (serviceRef.scope !== 'root') { - throw new Error( - `Failed to instantiate 'root' scoped service '${ref.id}' because it depends on '${serviceRef.scope}' scoped service '${serviceRef.id}'.`, - ); + if (!resolvedFactory) { + return ref.singleton + ? undefined + : (Promise.resolve([]) as + | Promise + | undefined); + } + + return resolvedFactory + .then(factories => { + return Promise.all( + factories.map(factory => { + if (factory.service.scope === 'root') { + let existing = this.#rootServiceImplementations.get(factory); + if (!existing) { + this.#checkForMissingDeps(factory, pluginId); + const rootDeps = new Array< + Promise<[name: string, impl: unknown]> + >(); + + for (const [name, serviceRef] of Object.entries(factory.deps)) { + if (serviceRef.scope !== 'root') { + throw new Error( + `Failed to instantiate 'root' scoped service '${ref.id}' because it depends on '${serviceRef.scope}' scoped service '${serviceRef.id}'.`, + ); + } + const target = this.get(serviceRef, pluginId)!; + rootDeps.push(target.then(impl => [name, impl])); + } + + existing = Promise.all(rootDeps).then(entries => + factory.factory(Object.fromEntries(entries), undefined), + ); + this.#rootServiceImplementations.set(factory, existing); + } + return existing as Promise; } - const target = this.get(serviceRef, pluginId)!; - rootDeps.push(target.then(impl => [name, impl])); - } - existing = Promise.all(rootDeps).then(entries => - factory.factory(Object.fromEntries(entries), undefined), - ); - this.#rootServiceImplementations.set(factory, existing); - } - return existing as Promise; - } + let implementation = this.#implementations.get(factory); + if (!implementation) { + this.#checkForMissingDeps(factory, pluginId); + const rootDeps = new Array< + Promise<[name: string, impl: unknown]> + >(); - let implementation = this.#implementations.get(factory); - if (!implementation) { - this.#checkForMissingDeps(factory, pluginId); - const rootDeps = new Array>(); + for (const [name, serviceRef] of Object.entries(factory.deps)) { + if (serviceRef.scope === 'root') { + const target = this.get(serviceRef, pluginId)!; + rootDeps.push(target.then(impl => [name, impl])); + } + } - for (const [name, serviceRef] of Object.entries(factory.deps)) { - if (serviceRef.scope === 'root') { - const target = this.get(serviceRef, pluginId)!; - rootDeps.push(target.then(impl => [name, impl])); - } - } + implementation = { + context: Promise.all(rootDeps) + .then(entries => + factory.createRootContext?.(Object.fromEntries(entries)), + ) + .catch(error => { + const cause = stringifyError(error); + throw new Error( + `Failed to instantiate service '${ref.id}' because createRootContext threw an error, ${cause}`, + ); + }), + byPlugin: new Map(), + }; - implementation = { - context: Promise.all(rootDeps) - .then(entries => - factory.createRootContext?.(Object.fromEntries(entries)), - ) - .catch(error => { - const cause = stringifyError(error); - throw new Error( - `Failed to instantiate service '${ref.id}' because createRootContext threw an error, ${cause}`, - ); - }), - byPlugin: new Map(), - }; + this.#implementations.set(factory, implementation); + } - this.#implementations.set(factory, implementation); - } + let result = implementation.byPlugin.get(pluginId) as Promise; + if (!result) { + const allDeps = new Array< + Promise<[name: string, impl: unknown]> + >(); - let result = implementation.byPlugin.get(pluginId) as Promise; - if (!result) { - const allDeps = new Array>(); + for (const [name, serviceRef] of Object.entries(factory.deps)) { + const target = this.get(serviceRef, pluginId)!; + allDeps.push(target.then(impl => [name, impl])); + } - for (const [name, serviceRef] of Object.entries(factory.deps)) { - const target = this.get(serviceRef, pluginId)!; - allDeps.push(target.then(impl => [name, impl])); - } - - result = implementation.context - .then(context => - Promise.all(allDeps).then(entries => - factory.factory(Object.fromEntries(entries), context), - ), - ) - .catch(error => { - const cause = stringifyError(error); - throw new Error( - `Failed to instantiate service '${ref.id}' for '${pluginId}' because the factory function threw an error, ${cause}`, - ); - }); - implementation.byPlugin.set(pluginId, result); - } - - return result; - }); + result = implementation.context + .then(context => + Promise.all(allDeps).then(entries => + factory.factory(Object.fromEntries(entries), context), + ), + ) + .catch(error => { + const cause = stringifyError(error); + throw new Error( + `Failed to instantiate service '${ref.id}' for '${pluginId}' because the factory function threw an error, ${cause}`, + ); + }); + implementation.byPlugin.set(pluginId, result); + } + return result; + }), + ); + }) + .then(results => (ref.singleton ? results[0] : results)); } } diff --git a/packages/backend-defaults/api-report-auth.md b/packages/backend-defaults/api-report-auth.md index 7df0b394e3..85287c524e 100644 --- a/packages/backend-defaults/api-report-auth.md +++ b/packages/backend-defaults/api-report-auth.md @@ -10,6 +10,7 @@ import { ServiceFactoryCompat } from '@backstage/backend-plugin-api'; export const authServiceFactory: ServiceFactoryCompat< AuthService, 'plugin', + true, undefined >; diff --git a/packages/backend-defaults/api-report-cache.md b/packages/backend-defaults/api-report-cache.md index 0b2d8706df..c6debd6a2b 100644 --- a/packages/backend-defaults/api-report-cache.md +++ b/packages/backend-defaults/api-report-cache.md @@ -28,6 +28,7 @@ export type CacheManagerOptions = { export const cacheServiceFactory: ServiceFactoryCompat< CacheService, 'plugin', + true, undefined >; diff --git a/packages/backend-defaults/api-report-database.md b/packages/backend-defaults/api-report-database.md index 0d54b43777..d7585cc791 100644 --- a/packages/backend-defaults/api-report-database.md +++ b/packages/backend-defaults/api-report-database.md @@ -35,6 +35,7 @@ export type DatabaseManagerOptions = { export const databaseServiceFactory: ServiceFactoryCompat< DatabaseService, 'plugin', + true, undefined >; diff --git a/packages/backend-defaults/api-report-discovery.md b/packages/backend-defaults/api-report-discovery.md index dbb469f758..dc0d9b2bbe 100644 --- a/packages/backend-defaults/api-report-discovery.md +++ b/packages/backend-defaults/api-report-discovery.md @@ -11,6 +11,7 @@ import { ServiceFactoryCompat } from '@backstage/backend-plugin-api'; export const discoveryServiceFactory: ServiceFactoryCompat< DiscoveryService, 'plugin', + true, undefined >; diff --git a/packages/backend-defaults/api-report-httpAuth.md b/packages/backend-defaults/api-report-httpAuth.md index 613e6a4452..d8d283c01e 100644 --- a/packages/backend-defaults/api-report-httpAuth.md +++ b/packages/backend-defaults/api-report-httpAuth.md @@ -10,6 +10,7 @@ import { ServiceFactoryCompat } from '@backstage/backend-plugin-api'; export const httpAuthServiceFactory: ServiceFactoryCompat< HttpAuthService, 'plugin', + true, undefined >; diff --git a/packages/backend-defaults/api-report-httpRouter.md b/packages/backend-defaults/api-report-httpRouter.md index a2bf1cd39b..7673367f18 100644 --- a/packages/backend-defaults/api-report-httpRouter.md +++ b/packages/backend-defaults/api-report-httpRouter.md @@ -18,6 +18,7 @@ export function createLifecycleMiddleware( export const httpRouterServiceFactory: ServiceFactoryCompat< HttpRouterService, 'plugin', + true, undefined >; diff --git a/packages/backend-defaults/api-report-lifecycle.md b/packages/backend-defaults/api-report-lifecycle.md index 36adbbf6e7..ad41fd4fcb 100644 --- a/packages/backend-defaults/api-report-lifecycle.md +++ b/packages/backend-defaults/api-report-lifecycle.md @@ -10,6 +10,7 @@ import { ServiceFactoryCompat } from '@backstage/backend-plugin-api'; export const lifecycleServiceFactory: ServiceFactoryCompat< LifecycleService, 'plugin', + true, undefined >; diff --git a/packages/backend-defaults/api-report-logger.md b/packages/backend-defaults/api-report-logger.md index c66f886bf4..c881d20344 100644 --- a/packages/backend-defaults/api-report-logger.md +++ b/packages/backend-defaults/api-report-logger.md @@ -10,6 +10,7 @@ import { ServiceFactoryCompat } from '@backstage/backend-plugin-api'; export const loggerServiceFactory: ServiceFactoryCompat< LoggerService, 'plugin', + true, undefined >; diff --git a/packages/backend-defaults/api-report-permissions.md b/packages/backend-defaults/api-report-permissions.md index 86b9605606..92e3feaeaf 100644 --- a/packages/backend-defaults/api-report-permissions.md +++ b/packages/backend-defaults/api-report-permissions.md @@ -10,6 +10,7 @@ import { ServiceFactoryCompat } from '@backstage/backend-plugin-api'; export const permissionsServiceFactory: ServiceFactoryCompat< PermissionsService, 'plugin', + true, undefined >; diff --git a/packages/backend-defaults/api-report-rootConfig.md b/packages/backend-defaults/api-report-rootConfig.md index 61f5c9dc9d..60fed5734b 100644 --- a/packages/backend-defaults/api-report-rootConfig.md +++ b/packages/backend-defaults/api-report-rootConfig.md @@ -28,8 +28,8 @@ export interface RootConfigFactoryOptions { // @public (undocumented) export const rootConfigServiceFactory: (( options?: RootConfigFactoryOptions, -) => ServiceFactory) & - ServiceFactory; +) => ServiceFactory) & + ServiceFactory; // (No @packageDocumentation comment for this package) ``` diff --git a/packages/backend-defaults/api-report-rootHealth.md b/packages/backend-defaults/api-report-rootHealth.md index c69f66e747..ca104ecf37 100644 --- a/packages/backend-defaults/api-report-rootHealth.md +++ b/packages/backend-defaults/api-report-rootHealth.md @@ -10,6 +10,7 @@ import { ServiceFactoryCompat } from '@backstage/backend-plugin-api'; export const rootHealthServiceFactory: ServiceFactoryCompat< RootHealthService, 'root', + true, undefined >; diff --git a/packages/backend-defaults/api-report-rootHttpRouter.md b/packages/backend-defaults/api-report-rootHttpRouter.md index 329398a7b8..a6e5a31428 100644 --- a/packages/backend-defaults/api-report-rootHttpRouter.md +++ b/packages/backend-defaults/api-report-rootHttpRouter.md @@ -143,8 +143,8 @@ export type RootHttpRouterFactoryOptions = { // @public (undocumented) export const rootHttpRouterServiceFactory: (( options?: RootHttpRouterFactoryOptions, -) => ServiceFactory) & - ServiceFactory; +) => ServiceFactory) & + ServiceFactory; // (No @packageDocumentation comment for this package) ``` diff --git a/packages/backend-defaults/api-report-rootLifecycle.md b/packages/backend-defaults/api-report-rootLifecycle.md index faa83706a7..52eaa3fe0e 100644 --- a/packages/backend-defaults/api-report-rootLifecycle.md +++ b/packages/backend-defaults/api-report-rootLifecycle.md @@ -10,6 +10,7 @@ import { ServiceFactoryCompat } from '@backstage/backend-plugin-api'; export const rootLifecycleServiceFactory: ServiceFactoryCompat< RootLifecycleService, 'root', + true, undefined >; diff --git a/packages/backend-defaults/api-report-rootLogger.md b/packages/backend-defaults/api-report-rootLogger.md index 075a8b4aa9..d91aaf0ae8 100644 --- a/packages/backend-defaults/api-report-rootLogger.md +++ b/packages/backend-defaults/api-report-rootLogger.md @@ -14,6 +14,7 @@ import { transport } from 'winston'; export const rootLoggerServiceFactory: ServiceFactoryCompat< RootLoggerService, 'root', + true, undefined >; diff --git a/packages/backend-defaults/api-report-scheduler.md b/packages/backend-defaults/api-report-scheduler.md index a3467b97de..7d8706def2 100644 --- a/packages/backend-defaults/api-report-scheduler.md +++ b/packages/backend-defaults/api-report-scheduler.md @@ -21,6 +21,7 @@ export class DefaultSchedulerService { export const schedulerServiceFactory: ServiceFactoryCompat< SchedulerService, 'plugin', + true, undefined >; diff --git a/packages/backend-defaults/api-report-urlReader.md b/packages/backend-defaults/api-report-urlReader.md index 0980e3cd67..431e2af701 100644 --- a/packages/backend-defaults/api-report-urlReader.md +++ b/packages/backend-defaults/api-report-urlReader.md @@ -429,6 +429,7 @@ export class UrlReaders { export const urlReaderServiceFactory: ServiceFactoryCompat< UrlReaderService, 'plugin', + true, undefined >; diff --git a/packages/backend-defaults/api-report-userInfo.md b/packages/backend-defaults/api-report-userInfo.md index b77878ff34..31ae1dd8bb 100644 --- a/packages/backend-defaults/api-report-userInfo.md +++ b/packages/backend-defaults/api-report-userInfo.md @@ -10,6 +10,7 @@ import { UserInfoService } from '@backstage/backend-plugin-api'; export const userInfoServiceFactory: ServiceFactoryCompat< UserInfoService, 'plugin', + true, undefined >; diff --git a/packages/backend-defaults/src/entrypoints/urlReader/urlReaderServiceFactory.ts b/packages/backend-defaults/src/entrypoints/urlReader/urlReaderServiceFactory.ts index 810882edf8..9859166ba0 100644 --- a/packages/backend-defaults/src/entrypoints/urlReader/urlReaderServiceFactory.ts +++ b/packages/backend-defaults/src/entrypoints/urlReader/urlReaderServiceFactory.ts @@ -14,12 +14,37 @@ * limitations under the License. */ +import { ReaderFactory } from './lib'; import { UrlReaders } from './lib/UrlReaders'; import { coreServices, createServiceFactory, + createServiceRef, } from '@backstage/backend-plugin-api'; +/** + * @public + * A non-singleton reference to URL Reader factory services. + * + * @example + * Creating a service factory implementation for a Custom URL Reader. + * ```ts + * createServiceFactory({ + * service: urlReaderProviderFactoriesServiceRef, + * deps: {}, + * async factory() { + * return CustomUrlReader.factory; + * }, + * }); + * ``` + */ +export const urlReaderProviderFactoriesServiceRef = + createServiceRef({ + id: 'core.urlReader.factories', + scope: 'plugin', + singleton: false, + }); + /** * Reading content from external systems. * @@ -34,11 +59,13 @@ export const urlReaderServiceFactory = createServiceFactory({ deps: { config: coreServices.rootConfig, logger: coreServices.logger, + factories: urlReaderProviderFactoriesServiceRef, }, - async factory({ config, logger }) { + async factory({ config, logger, factories }) { return UrlReaders.default({ config, logger, + factories, }); }, }); diff --git a/packages/backend-dynamic-feature-service/api-report.md b/packages/backend-dynamic-feature-service/api-report.md index 39aa60b09b..b74bbcdc95 100644 --- a/packages/backend-dynamic-feature-service/api-report.md +++ b/packages/backend-dynamic-feature-service/api-report.md @@ -117,6 +117,7 @@ export interface DynamicPluginsFactoryOptions { export const dynamicPluginsFeatureDiscoveryServiceFactory: ServiceFactoryCompat< FeatureDiscoveryService, 'root', + true, undefined >; @@ -127,6 +128,7 @@ export const dynamicPluginsFrontendSchemas: BackendFeatureCompat; export const dynamicPluginsRootLoggerServiceFactory: ServiceFactoryCompat< RootLoggerService, 'root', + true, undefined >; @@ -147,6 +149,7 @@ export interface DynamicPluginsSchemasService { export const dynamicPluginsSchemasServiceFactory: ServiceFactoryCompat< DynamicPluginsSchemasService, 'root', + true, DynamicPluginsSchemasOptions >; @@ -154,13 +157,15 @@ export const dynamicPluginsSchemasServiceFactory: ServiceFactoryCompat< export const dynamicPluginsServiceFactory: ServiceFactoryCompat< DynamicPluginProvider, 'root', + true, DynamicPluginsFactoryOptions >; // @public (undocumented) export const dynamicPluginsServiceRef: ServiceRef< DynamicPluginProvider, - 'root' + 'root', + true >; // @public (undocumented) diff --git a/packages/backend-plugin-api/api-report-alpha.md b/packages/backend-plugin-api/api-report-alpha.md index 81b378a671..9a82d3adbe 100644 --- a/packages/backend-plugin-api/api-report-alpha.md +++ b/packages/backend-plugin-api/api-report-alpha.md @@ -17,7 +17,8 @@ export interface FeatureDiscoveryService { // @alpha export const featureDiscoveryServiceRef: ServiceRef< FeatureDiscoveryService, - 'root' + 'root', + true >; // (No @packageDocumentation comment for this package) diff --git a/packages/backend-plugin-api/api-report.md b/packages/backend-plugin-api/api-report.md index b3c35d3699..3925d3b2f4 100644 --- a/packages/backend-plugin-api/api-report.md +++ b/packages/backend-plugin-api/api-report.md @@ -189,28 +189,28 @@ export type CacheServiceSetOptions = { // @public export namespace coreServices { - const auth: ServiceRef; - const userInfo: ServiceRef; - const cache: ServiceRef; - const rootConfig: ServiceRef; - const database: ServiceRef; - const discovery: ServiceRef; - const rootHealth: ServiceRef; - const httpAuth: ServiceRef; - const httpRouter: ServiceRef; - const lifecycle: ServiceRef; - const logger: ServiceRef; - const permissions: ServiceRef; - const pluginMetadata: ServiceRef; - const rootHttpRouter: ServiceRef; - const rootLifecycle: ServiceRef; - const rootLogger: ServiceRef; - const scheduler: ServiceRef; + const auth: ServiceRef; + const userInfo: ServiceRef; + const cache: ServiceRef; + const rootConfig: ServiceRef; + const database: ServiceRef; + const discovery: ServiceRef; + const rootHealth: ServiceRef; + const httpAuth: ServiceRef; + const httpRouter: ServiceRef; + const lifecycle: ServiceRef; + const logger: ServiceRef; + const permissions: ServiceRef; + const pluginMetadata: ServiceRef; + const rootHttpRouter: ServiceRef; + const rootLifecycle: ServiceRef; + const rootLogger: ServiceRef; + const scheduler: ServiceRef; const // @deprecated - tokenManager: ServiceRef; - const urlReader: ServiceRef; + tokenManager: ServiceRef; + const urlReader: ServiceRef; const // @deprecated - identity: ServiceRef; + identity: ServiceRef; } // @public @@ -251,18 +251,20 @@ export interface CreateExtensionPointOptions { // @public export function createServiceFactory< TService, + TSingleton extends boolean, TImpl extends TService, TDeps extends { [name in string]: ServiceRef; }, TOpts extends object | undefined = undefined, >( - options: RootServiceFactoryOptions, -): ServiceFactoryCompat; + options: RootServiceFactoryOptions, +): ServiceFactoryCompat; // @public @deprecated export function createServiceFactory< TService, + TSingleton extends boolean, TImpl extends TService, TDeps extends { [name in string]: ServiceRef; @@ -271,12 +273,13 @@ export function createServiceFactory< >( options: ( options?: TOpts, - ) => RootServiceFactoryOptions, -): ServiceFactoryCompat; + ) => RootServiceFactoryOptions, +): ServiceFactoryCompat; // @public export function createServiceFactory< TService, + TSingleton extends boolean, TImpl extends TService, TDeps extends { [name in string]: ServiceRef; @@ -284,12 +287,19 @@ export function createServiceFactory< TContext = undefined, TOpts extends object | undefined = undefined, >( - options: PluginServiceFactoryOptions, -): ServiceFactoryCompat; + options: PluginServiceFactoryOptions< + TService, + TSingleton, + TContext, + TImpl, + TDeps + >, +): ServiceFactoryCompat; // @public @deprecated export function createServiceFactory< TService, + TSingleton extends boolean, TImpl extends TService, TDeps extends { [name in string]: ServiceRef; @@ -299,18 +309,34 @@ export function createServiceFactory< >( options: ( options?: TOpts, - ) => PluginServiceFactoryOptions, -): ServiceFactoryCompat; + ) => PluginServiceFactoryOptions< + TService, + TSingleton, + TContext, + TImpl, + TDeps + >, +): ServiceFactoryCompat; // @public export function createServiceRef( - options: ServiceRefOptions, -): ServiceRef; + options: ServiceRefOptions, +): ServiceRef; // @public export function createServiceRef( - options: ServiceRefOptions, -): ServiceRef; + options: ServiceRefOptions, +): ServiceRef; + +// @public +export function createServiceRef( + options: ServiceRefOptions, +): ServiceRef; + +// @public +export function createServiceRef( + options: ServiceRefOptions, +): ServiceRef; // @public export interface DatabaseService { @@ -447,16 +473,18 @@ export interface PluginMetadataService { // @public @deprecated (undocumented) export type PluginServiceFactoryConfig< TService, + TSingleton extends boolean, TContext, TImpl extends TService, TDeps extends { [name in string]: ServiceRef; }, -> = PluginServiceFactoryOptions; +> = PluginServiceFactoryOptions; // @public (undocumented) export interface PluginServiceFactoryOptions< TService, + TSingleton extends boolean, TContext, TImpl extends TService, TDeps extends { @@ -476,7 +504,7 @@ export interface PluginServiceFactoryOptions< ): TImpl | Promise; initialization?: 'always' | 'lazy'; // (undocumented) - service: ServiceRef; + service: ServiceRef; } // @public @@ -538,15 +566,17 @@ export interface RootLoggerService extends LoggerService {} // @public @deprecated (undocumented) export type RootServiceFactoryConfig< TService, + TSingleton extends boolean, TImpl extends TService, TDeps extends { [name in string]: ServiceRef; }, -> = RootServiceFactoryOptions; +> = RootServiceFactoryOptions; // @public (undocumented) export interface RootServiceFactoryOptions< - TService, + TService, // TODO(Rugvip): Can we forward the entire service ref type here instead of forwarding each type arg once the callback form is gone? + TSingleton extends boolean, TImpl extends TService, TDeps extends { [name in string]: ServiceRef; @@ -558,7 +588,7 @@ export interface RootServiceFactoryOptions< factory(deps: ServiceRefsToInstances): TImpl | Promise; initialization?: 'always' | 'lazy'; // (undocumented) - service: ServiceRef; + service: ServiceRef; } // @public @@ -639,21 +669,23 @@ export type SearchResponseFile = UrlReaderServiceSearchResponseFile; export interface ServiceFactory< TService = unknown, TScope extends 'plugin' | 'root' = 'plugin' | 'root', + TSingleton extends boolean = boolean, > extends BackendFeature { // (undocumented) - service: ServiceRef; + service: ServiceRef; } // @public @deprecated (undocumented) export interface ServiceFactoryCompat< TService = unknown, TScope extends 'plugin' | 'root' = 'plugin' | 'root', + TSingleton extends boolean = boolean, TOpts extends object | undefined = undefined, -> extends ServiceFactory { +> extends ServiceFactory { // @deprecated (undocumented) ( ...options: undefined extends TOpts ? [] : [options?: TOpts] - ): ServiceFactory; + ): ServiceFactory; } // @public @deprecated @@ -663,9 +695,11 @@ export type ServiceFactoryOrFunction = ServiceFactory | (() => ServiceFactory); export type ServiceRef< TService, TScope extends 'root' | 'plugin' = 'root' | 'plugin', + TSingleton extends boolean = boolean, > = { id: string; scope: TScope; + singleton: TSingleton; T: TService; $$type: '@backstage/ServiceRef'; }; @@ -674,10 +708,15 @@ export type ServiceRef< export type ServiceRefConfig< TService, TScope extends 'root' | 'plugin', -> = ServiceRefOptions; + TSingleton extends boolean, +> = ServiceRefOptions; // @public (undocumented) -export interface ServiceRefOptions { +export interface ServiceRefOptions< + TService, + TScope extends 'root' | 'plugin', + TSingleton extends boolean, +> { // (undocumented) defaultFactory?( service: ServiceRef, @@ -690,6 +729,8 @@ export interface ServiceRefOptions { id: string; // (undocumented) scope?: TScope; + // (undocumented) + singleton?: TSingleton; } // @public @deprecated diff --git a/packages/backend-plugin-api/src/deprecated.ts b/packages/backend-plugin-api/src/deprecated.ts index 17ccccf320..e68affa0fa 100644 --- a/packages/backend-plugin-api/src/deprecated.ts +++ b/packages/backend-plugin-api/src/deprecated.ts @@ -28,7 +28,8 @@ import { export type ServiceRefConfig< TService, TScope extends 'root' | 'plugin', -> = ServiceRefOptions; + TSingleton extends boolean, +> = ServiceRefOptions; /** * @public @@ -36,9 +37,10 @@ export type ServiceRefConfig< */ export type RootServiceFactoryConfig< TService, + TSingleton extends boolean, TImpl extends TService, TDeps extends { [name in string]: ServiceRef }, -> = RootServiceFactoryOptions; +> = RootServiceFactoryOptions; /** * @public @@ -46,7 +48,8 @@ export type RootServiceFactoryConfig< */ export type PluginServiceFactoryConfig< TService, + TSingleton extends boolean, TContext, TImpl extends TService, TDeps extends { [name in string]: ServiceRef }, -> = PluginServiceFactoryOptions; +> = PluginServiceFactoryOptions; diff --git a/packages/backend-plugin-api/src/services/system/types.ts b/packages/backend-plugin-api/src/services/system/types.ts index d31350806d..e856136ddc 100644 --- a/packages/backend-plugin-api/src/services/system/types.ts +++ b/packages/backend-plugin-api/src/services/system/types.ts @@ -24,6 +24,7 @@ import { BackendFeature } from '../../types'; export type ServiceRef< TService, TScope extends 'root' | 'plugin' = 'root' | 'plugin', + TSingleton extends boolean = boolean, > = { id: string; @@ -38,6 +39,8 @@ export type ServiceRef< */ scope: TScope; + singleton: TSingleton; + /** * Utility for getting the type of the service, using `typeof serviceRef.T`. * Attempting to actually read this value will result in an exception. @@ -51,8 +54,9 @@ export type ServiceRef< export interface ServiceFactory< TService = unknown, TScope extends 'plugin' | 'root' = 'plugin' | 'root', + TSingleton extends boolean = boolean, > extends BackendFeature { - service: ServiceRef; + service: ServiceRef; } /** @@ -62,21 +66,23 @@ export interface ServiceFactory< export interface ServiceFactoryCompat< TService = unknown, TScope extends 'plugin' | 'root' = 'plugin' | 'root', + TSingleton extends boolean = boolean, TOpts extends object | undefined = undefined, -> extends ServiceFactory { +> extends ServiceFactory { /** * @deprecated Callable service factories will be removed in a future release, please re-implement the service factory using the available APIs instead. If no options are being passed, you can simply remove the trailing `()`. */ ( ...options: undefined extends TOpts ? [] : [options?: TOpts] - ): ServiceFactory; + ): ServiceFactory; } /** @internal */ export interface InternalServiceFactory< TService = unknown, TScope extends 'plugin' | 'root' = 'plugin' | 'root', -> extends ServiceFactory { + TSingleton extends boolean = boolean, +> extends ServiceFactory { version: 'v1'; initialization?: 'always' | 'lazy'; deps: { [key in string]: ServiceRef }; @@ -96,9 +102,14 @@ export interface InternalServiceFactory< export type ServiceFactoryOrFunction = ServiceFactory | (() => ServiceFactory); /** @public */ -export interface ServiceRefOptions { +export interface ServiceRefOptions< + TService, + TScope extends 'root' | 'plugin', + TSingleton extends boolean, +> { id: string; scope?: TScope; + singleton?: TSingleton; defaultFactory?( service: ServiceRef, ): Promise; @@ -116,8 +127,8 @@ export interface ServiceRefOptions { * @public */ export function createServiceRef( - options: ServiceRefOptions, -): ServiceRef; + options: ServiceRefOptions, +): ServiceRef; /** * Creates a new service definition. This overload is used to create root scoped services. @@ -125,16 +136,34 @@ export function createServiceRef( * @public */ export function createServiceRef( - options: ServiceRefOptions, -): ServiceRef; + options: ServiceRefOptions, +): ServiceRef; +/** + * Creates a new service definition. This overload is used to create plugin scoped services. + * + * @public + */ export function createServiceRef( - options: ServiceRefOptions, -): ServiceRef { - const { id, scope = 'plugin', defaultFactory } = options; + options: ServiceRefOptions, +): ServiceRef; + +/** + * Creates a new service definition. This overload is used to create root scoped services. + * + * @public + */ +export function createServiceRef( + options: ServiceRefOptions, +): ServiceRef; +export function createServiceRef( + options: ServiceRefOptions, +): ServiceRef { + const { id, scope = 'plugin', singleton = true, defaultFactory } = options; return { id, scope, + singleton, get T(): TService { throw new Error(`tried to read ServiceRef.T of ${this}`); }, @@ -143,7 +172,7 @@ export function createServiceRef( }, $$type: '@backstage/ServiceRef', __defaultFactory: defaultFactory, - } as ServiceRef & { + } as ServiceRef & { __defaultFactory?: ( service: ServiceRef, ) => Promise | (() => ServiceFactory)>; @@ -155,12 +184,17 @@ type ServiceRefsToInstances< T extends { [key in string]: ServiceRef }, TScope extends 'root' | 'plugin' = 'root' | 'plugin', > = { - [key in keyof T as T[key]['scope'] extends TScope ? key : never]: T[key]['T']; + [key in keyof T as T[key]['scope'] extends TScope + ? key + : never]: T[key]['singleton'] extends true + ? T[key]['T'] + : Array; }; /** @public */ export interface RootServiceFactoryOptions< - TService, + TService, // TODO(Rugvip): Can we forward the entire service ref type here instead of forwarding each type arg once the callback form is gone? + TSingleton extends boolean, TImpl extends TService, TDeps extends { [name in string]: ServiceRef }, > { @@ -175,7 +209,7 @@ export interface RootServiceFactoryOptions< * Service factories for root scoped services use `always` as the default, while plugin scoped services use `lazy`. */ initialization?: 'always' | 'lazy'; - service: ServiceRef; + service: ServiceRef; deps: TDeps; factory(deps: ServiceRefsToInstances): TImpl | Promise; } @@ -183,6 +217,7 @@ export interface RootServiceFactoryOptions< /** @public */ export interface PluginServiceFactoryOptions< TService, + TSingleton extends boolean, TContext, TImpl extends TService, TDeps extends { [name in string]: ServiceRef }, @@ -198,7 +233,7 @@ export interface PluginServiceFactoryOptions< * Service factories for root scoped services use `always` as the default, while plugin scoped services use `lazy`. */ initialization?: 'always' | 'lazy'; - service: ServiceRef; + service: ServiceRef; deps: TDeps; createRootContext?( deps: ServiceRefsToInstances, @@ -217,12 +252,13 @@ export interface PluginServiceFactoryOptions< */ export function createServiceFactory< TService, + TSingleton extends boolean, TImpl extends TService, TDeps extends { [name in string]: ServiceRef }, TOpts extends object | undefined = undefined, >( - options: RootServiceFactoryOptions, -): ServiceFactoryCompat; + options: RootServiceFactoryOptions, +): ServiceFactoryCompat; /** * Creates a root scoped service factory with optional options. * @@ -235,14 +271,15 @@ export function createServiceFactory< */ export function createServiceFactory< TService, + TSingleton extends boolean, TImpl extends TService, TDeps extends { [name in string]: ServiceRef }, TOpts extends object | undefined = undefined, >( options: ( options?: TOpts, - ) => RootServiceFactoryOptions, -): ServiceFactoryCompat; + ) => RootServiceFactoryOptions, +): ServiceFactoryCompat; /** * Creates a plugin scoped service factory without options. * @@ -251,13 +288,20 @@ export function createServiceFactory< */ export function createServiceFactory< TService, + TSingleton extends boolean, TImpl extends TService, TDeps extends { [name in string]: ServiceRef }, TContext = undefined, TOpts extends object | undefined = undefined, >( - options: PluginServiceFactoryOptions, -): ServiceFactoryCompat; + options: PluginServiceFactoryOptions< + TService, + TSingleton, + TContext, + TImpl, + TDeps + >, +): ServiceFactoryCompat; /** * Creates a plugin scoped service factory with optional options. * @@ -270,6 +314,7 @@ export function createServiceFactory< */ export function createServiceFactory< TService, + TSingleton extends boolean, TImpl extends TService, TDeps extends { [name in string]: ServiceRef }, TContext = undefined, @@ -277,25 +322,46 @@ export function createServiceFactory< >( options: ( options?: TOpts, - ) => PluginServiceFactoryOptions, -): ServiceFactoryCompat; + ) => PluginServiceFactoryOptions< + TService, + TSingleton, + TContext, + TImpl, + TDeps + >, +): ServiceFactoryCompat; export function createServiceFactory< TService, + TSingleton extends boolean, TImpl extends TService, TDeps extends { [name in string]: ServiceRef }, TContext, TOpts extends object | undefined = undefined, >( options: - | RootServiceFactoryOptions - | PluginServiceFactoryOptions - | ((options: TOpts) => RootServiceFactoryOptions) + | RootServiceFactoryOptions + | PluginServiceFactoryOptions | (( options: TOpts, - ) => PluginServiceFactoryOptions) - | (() => RootServiceFactoryOptions) - | (() => PluginServiceFactoryOptions), -): ServiceFactoryCompat { + ) => RootServiceFactoryOptions) + | (( + options: TOpts, + ) => PluginServiceFactoryOptions< + TService, + TSingleton, + TContext, + TImpl, + TDeps + >) + | (() => RootServiceFactoryOptions) + | (() => PluginServiceFactoryOptions< + TService, + TSingleton, + TContext, + TImpl, + TDeps + >), +): ServiceFactoryCompat { const configCallback = typeof options === 'function' ? options : () => options; const factory = ( @@ -303,18 +369,25 @@ export function createServiceFactory< ): InternalServiceFactory => { const anyConf = configCallback(o!); if (anyConf.service.scope === 'root') { - const c = anyConf as RootServiceFactoryOptions; + const c = anyConf as RootServiceFactoryOptions< + TService, + TSingleton, + TImpl, + TDeps + >; return { $$type: '@backstage/BackendFeature', version: 'v1', service: c.service, initialization: c.initialization, deps: c.deps, - factory: async (deps: TDeps) => c.factory(deps), + factory: async (deps: ServiceRefsToInstances) => + c.factory(deps), }; } const c = anyConf as PluginServiceFactoryOptions< TService, + TSingleton, TContext, TImpl, TDeps @@ -326,12 +399,14 @@ export function createServiceFactory< initialization: c.initialization, ...('createRootContext' in c ? { - createRootContext: async (deps: TDeps) => - c?.createRootContext?.(deps), + createRootContext: async ( + deps: ServiceRefsToInstances, + ) => c?.createRootContext?.(deps), } : {}), deps: c.deps, - factory: async (deps: TDeps, ctx: TContext) => c.factory(deps, ctx), + factory: async (deps: ServiceRefsToInstances, ctx: TContext) => + c.factory(deps, ctx), }; }; diff --git a/packages/backend-test-utils/api-report.md b/packages/backend-test-utils/api-report.md index 1f93573564..5a9e016dcd 100644 --- a/packages/backend-test-utils/api-report.md +++ b/packages/backend-test-utils/api-report.md @@ -156,7 +156,7 @@ export namespace mockServices { // (undocumented) export namespace auth { const // (undocumented) - factory: ServiceFactoryCompat; + factory: ServiceFactoryCompat; const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -165,7 +165,7 @@ export namespace mockServices { // (undocumented) export namespace cache { const // (undocumented) - factory: ServiceFactoryCompat; + factory: ServiceFactoryCompat; const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -174,7 +174,7 @@ export namespace mockServices { // (undocumented) export namespace database { const // (undocumented) - factory: ServiceFactoryCompat; + factory: ServiceFactoryCompat; const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -185,7 +185,12 @@ export namespace mockServices { // (undocumented) export namespace discovery { const // (undocumented) - factory: ServiceFactoryCompat; + factory: ServiceFactoryCompat< + DiscoveryService, + 'plugin', + true, + undefined + >; const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -194,7 +199,7 @@ export namespace mockServices { // (undocumented) export namespace events { const // (undocumented) - factory: ServiceFactoryCompat; + factory: ServiceFactoryCompat; const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -208,8 +213,8 @@ export namespace mockServices { export namespace httpAuth { const factory: ((options?: { defaultCredentials?: BackstageCredentials; - }) => ServiceFactory) & - ServiceFactory; + }) => ServiceFactory) & + ServiceFactory; const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -218,7 +223,12 @@ export namespace mockServices { // (undocumented) export namespace httpRouter { const // (undocumented) - factory: ServiceFactoryCompat; + factory: ServiceFactoryCompat< + HttpRouterService, + 'plugin', + true, + undefined + >; const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -229,7 +239,7 @@ export namespace mockServices { // (undocumented) export namespace identity { const // (undocumented) - factory: ServiceFactoryCompat; + factory: ServiceFactoryCompat; const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -238,7 +248,12 @@ export namespace mockServices { // (undocumented) export namespace lifecycle { const // (undocumented) - factory: ServiceFactoryCompat; + factory: ServiceFactoryCompat< + LifecycleService, + 'plugin', + true, + undefined + >; const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -247,7 +262,7 @@ export namespace mockServices { // (undocumented) export namespace logger { const // (undocumented) - factory: ServiceFactoryCompat; + factory: ServiceFactoryCompat; const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -256,7 +271,12 @@ export namespace mockServices { // (undocumented) export namespace permissions { const // (undocumented) - factory: ServiceFactoryCompat; + factory: ServiceFactoryCompat< + PermissionsService, + 'plugin', + true, + undefined + >; const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -271,15 +291,15 @@ export namespace mockServices { data?: JsonObject; }; const // (undocumented) - factory: ServiceFactory & + factory: ServiceFactory & (( options?: Options | undefined, - ) => ServiceFactory); + ) => ServiceFactory); } // (undocumented) export namespace rootHealth { const // (undocumented) - factory: ServiceFactoryCompat; + factory: ServiceFactoryCompat; const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -290,8 +310,8 @@ export namespace mockServices { const // (undocumented) factory: (( options?: RootHttpRouterFactoryOptions | undefined, - ) => ServiceFactory) & - ServiceFactory; + ) => ServiceFactory) & + ServiceFactory; const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -300,7 +320,12 @@ export namespace mockServices { // (undocumented) export namespace rootLifecycle { const // (undocumented) - factory: ServiceFactoryCompat; + factory: ServiceFactoryCompat< + RootLifecycleService, + 'root', + true, + undefined + >; const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -315,10 +340,10 @@ export namespace mockServices { level?: 'none' | 'error' | 'warn' | 'info' | 'debug'; }; const // (undocumented) - factory: ServiceFactory & + factory: ServiceFactory & (( options?: Options | undefined, - ) => ServiceFactory); + ) => ServiceFactory); const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -327,7 +352,12 @@ export namespace mockServices { // (undocumented) export namespace scheduler { const // (undocumented) - factory: ServiceFactoryCompat; + factory: ServiceFactoryCompat< + SchedulerService, + 'plugin', + true, + undefined + >; const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -338,7 +368,12 @@ export namespace mockServices { // (undocumented) export namespace tokenManager { const // (undocumented) - factory: ServiceFactoryCompat; + factory: ServiceFactoryCompat< + TokenManagerService, + 'plugin', + true, + undefined + >; const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -347,7 +382,12 @@ export namespace mockServices { // (undocumented) export namespace urlReader { const // (undocumented) - factory: ServiceFactoryCompat; + factory: ServiceFactoryCompat< + UrlReaderService, + 'plugin', + true, + undefined + >; const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -358,7 +398,12 @@ export namespace mockServices { ): UserInfoService; // (undocumented) export namespace userInfo { - const factory: ServiceFactoryCompat; + const factory: ServiceFactoryCompat< + UserInfoService, + 'plugin', + true, + undefined + >; const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -374,22 +419,34 @@ export function registerMswTestHooks(worker: { }): void; // @public -export class ServiceFactoryTester { - static from( - subject: ServiceFactory, +export class ServiceFactoryTester< + TService, + TScope extends 'root' | 'plugin', + TSingleton extends boolean = true, +> { + static from< + TService, + TScope extends 'root' | 'plugin', + TSingleton extends boolean = true, + >( + subject: ServiceFactory, options?: ServiceFactoryTesterOptions, - ): ServiceFactoryTester; + ): ServiceFactoryTester; // @deprecated get( ...args: 'root' extends TScope ? [] : [pluginId?: string] - ): Promise; - getService( - service: ServiceRef, + ): Promise; + getService< + TGetService, + TGetScope extends 'root' | 'plugin', + TGetSingleton extends boolean, + >( + service: ServiceRef, ...args: 'root' extends TGetScope ? [] : [pluginId?: string] - ): Promise; + ): Promise; getSubject( ...args: 'root' extends TScope ? [] : [pluginId?: string] - ): Promise; + ): Promise; } // @public diff --git a/packages/backend-test-utils/src/next/wiring/ServiceFactoryTester.ts b/packages/backend-test-utils/src/next/wiring/ServiceFactoryTester.ts index aea0d9d270..94092aff68 100644 --- a/packages/backend-test-utils/src/next/wiring/ServiceFactoryTester.ts +++ b/packages/backend-test-utils/src/next/wiring/ServiceFactoryTester.ts @@ -43,8 +43,12 @@ export interface ServiceFactoryTesterOptions { * * @public */ -export class ServiceFactoryTester { - readonly #subject: ServiceRef; +export class ServiceFactoryTester< + TService, + TScope extends 'root' | 'plugin', + TSingleton extends boolean = true, +> { + readonly #subject: ServiceRef; readonly #registry: ServiceRegistry; /** @@ -54,10 +58,14 @@ export class ServiceFactoryTester { * @param options - Additional options * @returns A new tester instance for the provided subject. */ - static from( - subject: ServiceFactory, + static from< + TService, + TScope extends 'root' | 'plugin', + TSingleton extends boolean = true, + >( + subject: ServiceFactory, options?: ServiceFactoryTesterOptions, - ) { + ): ServiceFactoryTester { const registry = ServiceRegistry.create([ ...defaultServiceFactories, ...(options?.dependencies ?? []), @@ -67,7 +75,7 @@ export class ServiceFactoryTester { } private constructor( - subject: ServiceRef, + subject: ServiceRef, registry: ServiceRegistry, ) { this.#subject = subject; @@ -81,7 +89,7 @@ export class ServiceFactoryTester { */ async get( ...args: 'root' extends TScope ? [] : [pluginId?: string] - ): Promise { + ): Promise { return this.getSubject(...args); } @@ -97,9 +105,10 @@ export class ServiceFactoryTester { */ async getSubject( ...args: 'root' extends TScope ? [] : [pluginId?: string] - ): Promise { + ): Promise { const [pluginId] = args; - return this.#registry.get(this.#subject, pluginId ?? 'test')!; + const instance = this.#registry.get(this.#subject, pluginId ?? 'test')!; + return instance; } /** @@ -109,10 +118,14 @@ export class ServiceFactoryTester { * * A plugin ID can optionally be provided for plugin scoped services, otherwise the plugin ID 'test' is used. */ - async getService( - service: ServiceRef, + async getService< + TGetService, + TGetScope extends 'root' | 'plugin', + TGetSingleton extends boolean, + >( + service: ServiceRef, ...args: 'root' extends TGetScope ? [] : [pluginId?: string] - ): Promise { + ): Promise { const [pluginId] = args; const instance = await this.#registry.get(service, pluginId ?? 'test'); if (instance === undefined) { diff --git a/plugins/catalog-node/api-report-alpha.md b/plugins/catalog-node/api-report-alpha.md index b61d1b1d27..a2579e29f4 100644 --- a/plugins/catalog-node/api-report-alpha.md +++ b/plugins/catalog-node/api-report-alpha.md @@ -88,7 +88,7 @@ export interface CatalogProcessingExtensionPoint { export const catalogProcessingExtensionPoint: ExtensionPoint; // @alpha -export const catalogServiceRef: ServiceRef; +export const catalogServiceRef: ServiceRef; // (No @packageDocumentation comment for this package) ``` diff --git a/plugins/events-node/api-report.md b/plugins/events-node/api-report.md index 5b45b4419e..e159446103 100644 --- a/plugins/events-node/api-report.md +++ b/plugins/events-node/api-report.md @@ -66,11 +66,12 @@ export type EventsServiceEventHandler = (params: EventParams) => Promise; export const eventsServiceFactory: ServiceFactoryCompat< EventsService, 'plugin', + true, undefined >; // @public -export const eventsServiceRef: ServiceRef; +export const eventsServiceRef: ServiceRef; // @public (undocumented) export type EventsServiceSubscribeOptions = { diff --git a/plugins/notifications-node/api-report.md b/plugins/notifications-node/api-report.md index 37f28fec35..fd356131ee 100644 --- a/plugins/notifications-node/api-report.md +++ b/plugins/notifications-node/api-report.md @@ -65,7 +65,11 @@ export interface NotificationService { } // @public (undocumented) -export const notificationService: ServiceRef; +export const notificationService: ServiceRef< + NotificationService, + 'plugin', + true +>; // @public (undocumented) export type NotificationServiceOptions = { diff --git a/plugins/search-backend-node/api-report-alpha.md b/plugins/search-backend-node/api-report-alpha.md index 4f3015a0e4..dc41fa6400 100644 --- a/plugins/search-backend-node/api-report-alpha.md +++ b/plugins/search-backend-node/api-report-alpha.md @@ -46,7 +46,11 @@ export type SearchIndexServiceInitOptions = { }; // @alpha -export const searchIndexServiceRef: ServiceRef; +export const searchIndexServiceRef: ServiceRef< + SearchIndexService, + 'plugin', + true +>; // (No @packageDocumentation comment for this package) ``` diff --git a/plugins/signals-node/api-report.md b/plugins/signals-node/api-report.md index cf4ab84aff..b2d5a2b210 100644 --- a/plugins/signals-node/api-report.md +++ b/plugins/signals-node/api-report.md @@ -37,7 +37,7 @@ export type SignalPayload = { export interface SignalService extends SignalsService {} // @public @deprecated (undocumented) -export const signalService: ServiceRef; +export const signalService: ServiceRef; // @public (undocumented) export interface SignalsService { @@ -52,7 +52,7 @@ export type SignalsServiceOptions = { }; // @public (undocumented) -export const signalsServiceRef: ServiceRef; +export const signalsServiceRef: ServiceRef; // (No @packageDocumentation comment for this package) ``` From 7c5f3b02972b1ce53e39f0dd04f6fce4e5511c43 Mon Sep 17 00:00:00 2001 From: Camila Belo Date: Fri, 12 Jul 2024 11:22:31 +0200 Subject: [PATCH 040/372] refactor: use string types for service instance occurrences Signed-off-by: Camila Belo --- .changeset/mighty-apricots-taste.md | 5 + .changeset/purple-carrots-crash.md | 5 + .changeset/shy-waves-share.md | 5 + .changeset/small-bottles-cough.md | 58 ++++++++ .changeset/thirty-adults-grab.md | 6 + packages/backend-app-api/api-report-alpha.md | 2 +- packages/backend-app-api/api-report.md | 38 +++--- .../src/wiring/ServiceRegistry.ts | 38 +++--- packages/backend-defaults/api-report-auth.md | 2 +- packages/backend-defaults/api-report-cache.md | 2 +- .../backend-defaults/api-report-database.md | 2 +- .../backend-defaults/api-report-discovery.md | 2 +- .../backend-defaults/api-report-httpAuth.md | 2 +- .../backend-defaults/api-report-httpRouter.md | 2 +- .../backend-defaults/api-report-lifecycle.md | 2 +- .../backend-defaults/api-report-logger.md | 2 +- .../api-report-permissions.md | 2 +- .../backend-defaults/api-report-rootConfig.md | 4 +- .../backend-defaults/api-report-rootHealth.md | 2 +- .../api-report-rootHttpRouter.md | 4 +- .../api-report-rootLifecycle.md | 2 +- .../backend-defaults/api-report-rootLogger.md | 2 +- .../backend-defaults/api-report-scheduler.md | 2 +- .../backend-defaults/api-report-urlReader.md | 2 +- .../backend-defaults/api-report-userInfo.md | 2 +- .../urlReader/urlReaderServiceFactory.ts | 2 +- .../api-report.md | 10 +- .../backend-plugin-api/api-report-alpha.md | 2 +- packages/backend-plugin-api/api-report.md | 124 +++++++++--------- packages/backend-plugin-api/src/deprecated.ts | 12 +- .../src/services/system/types.ts | 116 ++++++++-------- packages/backend-test-utils/api-report.md | 109 ++++++++++----- .../src/next/wiring/ServiceFactoryTester.ts | 22 ++-- plugins/catalog-node/api-report-alpha.md | 2 +- plugins/events-node/api-report.md | 4 +- plugins/notifications-node/api-report.md | 2 +- .../search-backend-node/api-report-alpha.md | 2 +- plugins/signals-node/api-report.md | 8 +- 38 files changed, 374 insertions(+), 236 deletions(-) create mode 100644 .changeset/mighty-apricots-taste.md create mode 100644 .changeset/purple-carrots-crash.md create mode 100644 .changeset/shy-waves-share.md create mode 100644 .changeset/small-bottles-cough.md create mode 100644 .changeset/thirty-adults-grab.md diff --git a/.changeset/mighty-apricots-taste.md b/.changeset/mighty-apricots-taste.md new file mode 100644 index 0000000000..80b70020cb --- /dev/null +++ b/.changeset/mighty-apricots-taste.md @@ -0,0 +1,5 @@ +--- +'@backstage/backend-app-api': patch +--- + +Update the `ServiceRegister` implementation to enable registering multiple service implementations for a given service ref. diff --git a/.changeset/purple-carrots-crash.md b/.changeset/purple-carrots-crash.md new file mode 100644 index 0000000000..62f90677b8 --- /dev/null +++ b/.changeset/purple-carrots-crash.md @@ -0,0 +1,5 @@ +--- +'@backstage/backend-test-utils': patch +--- + +Update the `ServiceFactoryTester` to be able to test services that enables multi implementation installation. diff --git a/.changeset/shy-waves-share.md b/.changeset/shy-waves-share.md new file mode 100644 index 0000000000..861590fd01 --- /dev/null +++ b/.changeset/shy-waves-share.md @@ -0,0 +1,5 @@ +--- +'@backstage/backend-defaults': patch +--- + +Update the `UrlReader` service to depends on multiple instances of `UrlReaderFactoryProvider` service. diff --git a/.changeset/small-bottles-cough.md b/.changeset/small-bottles-cough.md new file mode 100644 index 0000000000..40098a84c7 --- /dev/null +++ b/.changeset/small-bottles-cough.md @@ -0,0 +1,58 @@ +--- +'@backstage/backend-plugin-api': minor +--- + +The `createServiceRef` function now accepts a new boolean `multiple` option. The `multiple` option defaults to `false` and when set to `true`, it enables that multiple implementation are installed for the created service ref. + +We're looking for ways to make it possible to augment services without the need to replace the entire service. + +Typical example of that being the ability to install support for additional targets for the `UrlReader` service without replacing the service itself. This achieves that by allowing us to define services that can have multiple simultaneous implementation, allowing the `UrlReader` implementation to depend on such a service to collect all possible implementation of support for external targets: + +```diff +// @backstage/backend-defaults + ++ export const urlReaderFactoriesServiceRef = createServiceRef({ ++ id: 'core.urlReader.factories', ++ scope: 'plugin', ++ multiton: true, ++ }); + +... + +export const urlReaderServiceFactory = createServiceFactory({ + service: coreServices.urlReader, + deps: { + config: coreServices.rootConfig, + logger: coreServices.logger, ++ factories: urlReaderFactoriesServiceRef, + }, +- async factory({ config, logger }) { ++ async factory({ config, logger, factories }) { + return UrlReaders.default({ + config, + logger, ++ factories, + }); + }, +}); +``` + +With that, you can then add more custom `UrlReader` factories by installing more implementations of the `urlReaderFactoriesServiceRef` in your backend instance. Something like: + +```ts +// packages/backend/index.ts +import { createServiceFactory } from '@backstage/backend-plugin-api'; +import { urlReaderFactoriesServiceRef } from '@backstage/backend-defaults'; +... + +backend.add(createServiceFactory({ + service: urlReaderFactoriesServiceRef, + deps: {}, + async factory() { + return CustomUrlReader.factory; + }, +})); + +... + +``` diff --git a/.changeset/thirty-adults-grab.md b/.changeset/thirty-adults-grab.md new file mode 100644 index 0000000000..391e7a39bb --- /dev/null +++ b/.changeset/thirty-adults-grab.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-search-backend-node': patch +'@backstage/plugin-catalog-node': patch +--- + +Explicit declare if the service ref accepts `single` ou `multiple` implementations. diff --git a/packages/backend-app-api/api-report-alpha.md b/packages/backend-app-api/api-report-alpha.md index b811208845..8616eec29a 100644 --- a/packages/backend-app-api/api-report-alpha.md +++ b/packages/backend-app-api/api-report-alpha.md @@ -10,7 +10,7 @@ import { ServiceFactoryCompat } from '@backstage/backend-plugin-api'; export const featureDiscoveryServiceFactory: ServiceFactoryCompat< FeatureDiscoveryService, 'root', - true, + 'singleton', undefined >; diff --git a/packages/backend-app-api/api-report.md b/packages/backend-app-api/api-report.md index 4019ad3086..dea309ebb0 100644 --- a/packages/backend-app-api/api-report.md +++ b/packages/backend-app-api/api-report.md @@ -49,7 +49,7 @@ import { UserInfoService } from '@backstage/backend-plugin-api'; export const authServiceFactory: ServiceFactoryCompat< AuthService, 'plugin', - true, + 'singleton', undefined >; @@ -81,7 +81,7 @@ export interface Backend { export const cacheServiceFactory: ServiceFactoryCompat< CacheService, 'plugin', - true, + 'singleton', undefined >; @@ -115,7 +115,7 @@ export interface CreateSpecializedBackendOptions { export const databaseServiceFactory: ServiceFactoryCompat< DatabaseService, 'plugin', - true, + 'singleton', undefined >; @@ -138,7 +138,7 @@ export type DefaultRootHttpRouterOptions = DefaultRootHttpRouterOptions_2; export const discoveryServiceFactory: ServiceFactoryCompat< DiscoveryService, 'plugin', - true, + 'singleton', undefined >; @@ -165,7 +165,7 @@ export class HostDiscovery implements DiscoveryService { export const httpAuthServiceFactory: ServiceFactoryCompat< HttpAuthService, 'plugin', - true, + 'singleton', undefined >; @@ -173,7 +173,7 @@ export const httpAuthServiceFactory: ServiceFactoryCompat< export const httpRouterServiceFactory: ServiceFactoryCompat< HttpRouterService, 'plugin', - true, + 'singleton', undefined >; @@ -197,7 +197,7 @@ export type IdentityFactoryOptions = { export const identityServiceFactory: ServiceFactoryCompat< IdentityService, 'plugin', - true, + 'singleton', IdentityFactoryOptions >; @@ -210,7 +210,7 @@ export type LifecycleMiddlewareOptions = LifecycleMiddlewareOptions_2; export const lifecycleServiceFactory: ServiceFactoryCompat< LifecycleService, 'plugin', - true, + 'singleton', undefined >; @@ -228,7 +228,7 @@ export function loadBackendConfig(options: { export const loggerServiceFactory: ServiceFactoryCompat< LoggerService, 'plugin', - true, + 'singleton', undefined >; @@ -257,7 +257,7 @@ export type MiddlewareFactoryOptions = MiddlewareFactoryOptions_2; export const permissionsServiceFactory: ServiceFactoryCompat< PermissionsService, 'plugin', - true, + 'singleton', undefined >; @@ -288,7 +288,7 @@ export interface RootConfigFactoryOptions { export const rootConfigServiceFactory: ServiceFactoryCompat< RootConfigService, 'root', - true, + 'singleton', RootConfigFactoryOptions >; @@ -305,14 +305,14 @@ export type RootHttpRouterFactoryOptions = RootHttpRouterFactoryOptions_2; // @public @deprecated (undocumented) export const rootHttpRouterServiceFactory: (( options?: RootHttpRouterFactoryOptions_2 | undefined, -) => ServiceFactory) & - ServiceFactory; +) => ServiceFactory) & + ServiceFactory; // @public @deprecated export const rootLifecycleServiceFactory: ServiceFactoryCompat< RootLifecycleService, 'root', - true, + 'singleton', undefined >; @@ -320,7 +320,7 @@ export const rootLifecycleServiceFactory: ServiceFactoryCompat< export const rootLoggerServiceFactory: ServiceFactoryCompat< RootLoggerService, 'root', - true, + 'singleton', undefined >; @@ -328,7 +328,7 @@ export const rootLoggerServiceFactory: ServiceFactoryCompat< export const schedulerServiceFactory: ServiceFactoryCompat< SchedulerService, 'plugin', - true, + 'singleton', undefined >; @@ -336,7 +336,7 @@ export const schedulerServiceFactory: ServiceFactoryCompat< export const tokenManagerServiceFactory: ServiceFactoryCompat< TokenManagerService, 'plugin', - true, + 'singleton', undefined >; @@ -344,7 +344,7 @@ export const tokenManagerServiceFactory: ServiceFactoryCompat< export const urlReaderServiceFactory: ServiceFactoryCompat< UrlReaderService, 'plugin', - true, + 'singleton', undefined >; @@ -352,7 +352,7 @@ export const urlReaderServiceFactory: ServiceFactoryCompat< export const userInfoServiceFactory: ServiceFactoryCompat< UserInfoService, 'plugin', - true, + 'singleton', undefined >; diff --git a/packages/backend-app-api/src/wiring/ServiceRegistry.ts b/packages/backend-app-api/src/wiring/ServiceRegistry.ts index e1644dad89..0abd5605ae 100644 --- a/packages/backend-app-api/src/wiring/ServiceRegistry.ts +++ b/packages/backend-app-api/src/wiring/ServiceRegistry.ts @@ -60,14 +60,14 @@ export class ServiceRegistry { static create(factories: Array): ServiceRegistry { const factoryMap = new Map(); for (const factory of factories) { - if (factory.service.singleton) { - factoryMap.set(factory.service.id, [toInternalServiceFactory(factory)]); - } else { + if (factory.service.multiton) { const existing = factoryMap.get(factory.service.id) ?? []; factoryMap.set( factory.service.id, existing.concat(toInternalServiceFactory(factory)), ); + } else { + factoryMap.set(factory.service.id, [toInternalServiceFactory(factory)]); } } const registry = new ServiceRegistry(factoryMap); @@ -155,7 +155,7 @@ export class ServiceRegistry { if (this.#providedFactories.get(ref.id)) { return false; } - if (!ref.singleton) { + if (ref.multiton) { return false; } @@ -205,7 +205,12 @@ export class ServiceRegistry { ); } - if (factory.service.singleton) { + if (factory.service.multiton) { + const newFactories = ( + this.#providedFactories.get(factoryId) ?? [] + ).concat(toInternalServiceFactory(factory)); + this.#providedFactories.set(factoryId, newFactories); + } else { if (this.#addedFactoryIds.has(factoryId)) { throw new Error( `Duplicate service implementations provided for ${factoryId}`, @@ -216,11 +221,6 @@ export class ServiceRegistry { this.#providedFactories.set(factoryId, [ toInternalServiceFactory(factory), ]); - } else { - const newFactories = ( - this.#providedFactories.get(factoryId) ?? [] - ).concat(toInternalServiceFactory(factory)); - this.#providedFactories.set(factoryId, newFactories); } } @@ -240,20 +240,20 @@ export class ServiceRegistry { } } - get( - ref: ServiceRef, + get( + ref: ServiceRef, pluginId: string, - ): Promise | undefined { + ): Promise | undefined { this.#instantiatedFactories.add(ref.id); const resolvedFactory = this.#resolveFactory(ref, pluginId); if (!resolvedFactory) { - return ref.singleton - ? undefined - : (Promise.resolve([]) as - | Promise - | undefined); + return ref.multiton + ? (Promise.resolve([]) as + | Promise + | undefined) + : undefined; } return resolvedFactory @@ -346,6 +346,6 @@ export class ServiceRegistry { }), ); }) - .then(results => (ref.singleton ? results[0] : results)); + .then(results => (ref.multiton ? results : results[0])); } } diff --git a/packages/backend-defaults/api-report-auth.md b/packages/backend-defaults/api-report-auth.md index 85287c524e..5ceca7f72e 100644 --- a/packages/backend-defaults/api-report-auth.md +++ b/packages/backend-defaults/api-report-auth.md @@ -10,7 +10,7 @@ import { ServiceFactoryCompat } from '@backstage/backend-plugin-api'; export const authServiceFactory: ServiceFactoryCompat< AuthService, 'plugin', - true, + 'singleton', undefined >; diff --git a/packages/backend-defaults/api-report-cache.md b/packages/backend-defaults/api-report-cache.md index c6debd6a2b..e8b6f075ab 100644 --- a/packages/backend-defaults/api-report-cache.md +++ b/packages/backend-defaults/api-report-cache.md @@ -28,7 +28,7 @@ export type CacheManagerOptions = { export const cacheServiceFactory: ServiceFactoryCompat< CacheService, 'plugin', - true, + 'singleton', undefined >; diff --git a/packages/backend-defaults/api-report-database.md b/packages/backend-defaults/api-report-database.md index d7585cc791..8d204db025 100644 --- a/packages/backend-defaults/api-report-database.md +++ b/packages/backend-defaults/api-report-database.md @@ -35,7 +35,7 @@ export type DatabaseManagerOptions = { export const databaseServiceFactory: ServiceFactoryCompat< DatabaseService, 'plugin', - true, + 'singleton', undefined >; diff --git a/packages/backend-defaults/api-report-discovery.md b/packages/backend-defaults/api-report-discovery.md index dc0d9b2bbe..1b19a42aa5 100644 --- a/packages/backend-defaults/api-report-discovery.md +++ b/packages/backend-defaults/api-report-discovery.md @@ -11,7 +11,7 @@ import { ServiceFactoryCompat } from '@backstage/backend-plugin-api'; export const discoveryServiceFactory: ServiceFactoryCompat< DiscoveryService, 'plugin', - true, + 'singleton', undefined >; diff --git a/packages/backend-defaults/api-report-httpAuth.md b/packages/backend-defaults/api-report-httpAuth.md index d8d283c01e..a65a6e157d 100644 --- a/packages/backend-defaults/api-report-httpAuth.md +++ b/packages/backend-defaults/api-report-httpAuth.md @@ -10,7 +10,7 @@ import { ServiceFactoryCompat } from '@backstage/backend-plugin-api'; export const httpAuthServiceFactory: ServiceFactoryCompat< HttpAuthService, 'plugin', - true, + 'singleton', undefined >; diff --git a/packages/backend-defaults/api-report-httpRouter.md b/packages/backend-defaults/api-report-httpRouter.md index 7673367f18..300e75a44d 100644 --- a/packages/backend-defaults/api-report-httpRouter.md +++ b/packages/backend-defaults/api-report-httpRouter.md @@ -18,7 +18,7 @@ export function createLifecycleMiddleware( export const httpRouterServiceFactory: ServiceFactoryCompat< HttpRouterService, 'plugin', - true, + 'singleton', undefined >; diff --git a/packages/backend-defaults/api-report-lifecycle.md b/packages/backend-defaults/api-report-lifecycle.md index ad41fd4fcb..54ffb77fed 100644 --- a/packages/backend-defaults/api-report-lifecycle.md +++ b/packages/backend-defaults/api-report-lifecycle.md @@ -10,7 +10,7 @@ import { ServiceFactoryCompat } from '@backstage/backend-plugin-api'; export const lifecycleServiceFactory: ServiceFactoryCompat< LifecycleService, 'plugin', - true, + 'singleton', undefined >; diff --git a/packages/backend-defaults/api-report-logger.md b/packages/backend-defaults/api-report-logger.md index c881d20344..40ca4e21b4 100644 --- a/packages/backend-defaults/api-report-logger.md +++ b/packages/backend-defaults/api-report-logger.md @@ -10,7 +10,7 @@ import { ServiceFactoryCompat } from '@backstage/backend-plugin-api'; export const loggerServiceFactory: ServiceFactoryCompat< LoggerService, 'plugin', - true, + 'singleton', undefined >; diff --git a/packages/backend-defaults/api-report-permissions.md b/packages/backend-defaults/api-report-permissions.md index 92e3feaeaf..eea11ed7c9 100644 --- a/packages/backend-defaults/api-report-permissions.md +++ b/packages/backend-defaults/api-report-permissions.md @@ -10,7 +10,7 @@ import { ServiceFactoryCompat } from '@backstage/backend-plugin-api'; export const permissionsServiceFactory: ServiceFactoryCompat< PermissionsService, 'plugin', - true, + 'singleton', undefined >; diff --git a/packages/backend-defaults/api-report-rootConfig.md b/packages/backend-defaults/api-report-rootConfig.md index 60fed5734b..2935ad1128 100644 --- a/packages/backend-defaults/api-report-rootConfig.md +++ b/packages/backend-defaults/api-report-rootConfig.md @@ -28,8 +28,8 @@ export interface RootConfigFactoryOptions { // @public (undocumented) export const rootConfigServiceFactory: (( options?: RootConfigFactoryOptions, -) => ServiceFactory) & - ServiceFactory; +) => ServiceFactory) & + ServiceFactory; // (No @packageDocumentation comment for this package) ``` diff --git a/packages/backend-defaults/api-report-rootHealth.md b/packages/backend-defaults/api-report-rootHealth.md index ca104ecf37..c7580cacd6 100644 --- a/packages/backend-defaults/api-report-rootHealth.md +++ b/packages/backend-defaults/api-report-rootHealth.md @@ -10,7 +10,7 @@ import { ServiceFactoryCompat } from '@backstage/backend-plugin-api'; export const rootHealthServiceFactory: ServiceFactoryCompat< RootHealthService, 'root', - true, + 'singleton', undefined >; diff --git a/packages/backend-defaults/api-report-rootHttpRouter.md b/packages/backend-defaults/api-report-rootHttpRouter.md index a6e5a31428..94c22960ef 100644 --- a/packages/backend-defaults/api-report-rootHttpRouter.md +++ b/packages/backend-defaults/api-report-rootHttpRouter.md @@ -143,8 +143,8 @@ export type RootHttpRouterFactoryOptions = { // @public (undocumented) export const rootHttpRouterServiceFactory: (( options?: RootHttpRouterFactoryOptions, -) => ServiceFactory) & - ServiceFactory; +) => ServiceFactory) & + ServiceFactory; // (No @packageDocumentation comment for this package) ``` diff --git a/packages/backend-defaults/api-report-rootLifecycle.md b/packages/backend-defaults/api-report-rootLifecycle.md index 52eaa3fe0e..e522471d04 100644 --- a/packages/backend-defaults/api-report-rootLifecycle.md +++ b/packages/backend-defaults/api-report-rootLifecycle.md @@ -10,7 +10,7 @@ import { ServiceFactoryCompat } from '@backstage/backend-plugin-api'; export const rootLifecycleServiceFactory: ServiceFactoryCompat< RootLifecycleService, 'root', - true, + 'singleton', undefined >; diff --git a/packages/backend-defaults/api-report-rootLogger.md b/packages/backend-defaults/api-report-rootLogger.md index d91aaf0ae8..3878420192 100644 --- a/packages/backend-defaults/api-report-rootLogger.md +++ b/packages/backend-defaults/api-report-rootLogger.md @@ -14,7 +14,7 @@ import { transport } from 'winston'; export const rootLoggerServiceFactory: ServiceFactoryCompat< RootLoggerService, 'root', - true, + 'singleton', undefined >; diff --git a/packages/backend-defaults/api-report-scheduler.md b/packages/backend-defaults/api-report-scheduler.md index 7d8706def2..9953518e09 100644 --- a/packages/backend-defaults/api-report-scheduler.md +++ b/packages/backend-defaults/api-report-scheduler.md @@ -21,7 +21,7 @@ export class DefaultSchedulerService { export const schedulerServiceFactory: ServiceFactoryCompat< SchedulerService, 'plugin', - true, + 'singleton', undefined >; diff --git a/packages/backend-defaults/api-report-urlReader.md b/packages/backend-defaults/api-report-urlReader.md index 431e2af701..ad732101dd 100644 --- a/packages/backend-defaults/api-report-urlReader.md +++ b/packages/backend-defaults/api-report-urlReader.md @@ -429,7 +429,7 @@ export class UrlReaders { export const urlReaderServiceFactory: ServiceFactoryCompat< UrlReaderService, 'plugin', - true, + 'singleton', undefined >; diff --git a/packages/backend-defaults/api-report-userInfo.md b/packages/backend-defaults/api-report-userInfo.md index 31ae1dd8bb..27f73d06e1 100644 --- a/packages/backend-defaults/api-report-userInfo.md +++ b/packages/backend-defaults/api-report-userInfo.md @@ -10,7 +10,7 @@ import { UserInfoService } from '@backstage/backend-plugin-api'; export const userInfoServiceFactory: ServiceFactoryCompat< UserInfoService, 'plugin', - true, + 'singleton', undefined >; diff --git a/packages/backend-defaults/src/entrypoints/urlReader/urlReaderServiceFactory.ts b/packages/backend-defaults/src/entrypoints/urlReader/urlReaderServiceFactory.ts index 9859166ba0..b5c22402ff 100644 --- a/packages/backend-defaults/src/entrypoints/urlReader/urlReaderServiceFactory.ts +++ b/packages/backend-defaults/src/entrypoints/urlReader/urlReaderServiceFactory.ts @@ -42,7 +42,7 @@ export const urlReaderProviderFactoriesServiceRef = createServiceRef({ id: 'core.urlReader.factories', scope: 'plugin', - singleton: false, + multiton: true, }); /** diff --git a/packages/backend-dynamic-feature-service/api-report.md b/packages/backend-dynamic-feature-service/api-report.md index b74bbcdc95..97dea60170 100644 --- a/packages/backend-dynamic-feature-service/api-report.md +++ b/packages/backend-dynamic-feature-service/api-report.md @@ -117,7 +117,7 @@ export interface DynamicPluginsFactoryOptions { export const dynamicPluginsFeatureDiscoveryServiceFactory: ServiceFactoryCompat< FeatureDiscoveryService, 'root', - true, + 'singleton', undefined >; @@ -128,7 +128,7 @@ export const dynamicPluginsFrontendSchemas: BackendFeatureCompat; export const dynamicPluginsRootLoggerServiceFactory: ServiceFactoryCompat< RootLoggerService, 'root', - true, + 'singleton', undefined >; @@ -149,7 +149,7 @@ export interface DynamicPluginsSchemasService { export const dynamicPluginsSchemasServiceFactory: ServiceFactoryCompat< DynamicPluginsSchemasService, 'root', - true, + 'singleton', DynamicPluginsSchemasOptions >; @@ -157,7 +157,7 @@ export const dynamicPluginsSchemasServiceFactory: ServiceFactoryCompat< export const dynamicPluginsServiceFactory: ServiceFactoryCompat< DynamicPluginProvider, 'root', - true, + 'singleton', DynamicPluginsFactoryOptions >; @@ -165,7 +165,7 @@ export const dynamicPluginsServiceFactory: ServiceFactoryCompat< export const dynamicPluginsServiceRef: ServiceRef< DynamicPluginProvider, 'root', - true + 'singleton' >; // @public (undocumented) diff --git a/packages/backend-plugin-api/api-report-alpha.md b/packages/backend-plugin-api/api-report-alpha.md index 9a82d3adbe..0f4348336a 100644 --- a/packages/backend-plugin-api/api-report-alpha.md +++ b/packages/backend-plugin-api/api-report-alpha.md @@ -18,7 +18,7 @@ export interface FeatureDiscoveryService { export const featureDiscoveryServiceRef: ServiceRef< FeatureDiscoveryService, 'root', - true + 'singleton' >; // (No @packageDocumentation comment for this package) diff --git a/packages/backend-plugin-api/api-report.md b/packages/backend-plugin-api/api-report.md index 3925d3b2f4..99c7b1b9fc 100644 --- a/packages/backend-plugin-api/api-report.md +++ b/packages/backend-plugin-api/api-report.md @@ -189,28 +189,32 @@ export type CacheServiceSetOptions = { // @public export namespace coreServices { - const auth: ServiceRef; - const userInfo: ServiceRef; - const cache: ServiceRef; - const rootConfig: ServiceRef; - const database: ServiceRef; - const discovery: ServiceRef; - const rootHealth: ServiceRef; - const httpAuth: ServiceRef; - const httpRouter: ServiceRef; - const lifecycle: ServiceRef; - const logger: ServiceRef; - const permissions: ServiceRef; - const pluginMetadata: ServiceRef; - const rootHttpRouter: ServiceRef; - const rootLifecycle: ServiceRef; - const rootLogger: ServiceRef; - const scheduler: ServiceRef; + const auth: ServiceRef; + const userInfo: ServiceRef; + const cache: ServiceRef; + const rootConfig: ServiceRef; + const database: ServiceRef; + const discovery: ServiceRef; + const rootHealth: ServiceRef; + const httpAuth: ServiceRef; + const httpRouter: ServiceRef; + const lifecycle: ServiceRef; + const logger: ServiceRef; + const permissions: ServiceRef; + const pluginMetadata: ServiceRef< + PluginMetadataService, + 'plugin', + 'singleton' + >; + const rootHttpRouter: ServiceRef; + const rootLifecycle: ServiceRef; + const rootLogger: ServiceRef; + const scheduler: ServiceRef; const // @deprecated - tokenManager: ServiceRef; - const urlReader: ServiceRef; + tokenManager: ServiceRef; + const urlReader: ServiceRef; const // @deprecated - identity: ServiceRef; + identity: ServiceRef; } // @public @@ -251,20 +255,20 @@ export interface CreateExtensionPointOptions { // @public export function createServiceFactory< TService, - TSingleton extends boolean, + TInstances extends 'singleton' | 'multiton', TImpl extends TService, TDeps extends { [name in string]: ServiceRef; }, TOpts extends object | undefined = undefined, >( - options: RootServiceFactoryOptions, -): ServiceFactoryCompat; + options: RootServiceFactoryOptions, +): ServiceFactoryCompat; // @public @deprecated export function createServiceFactory< TService, - TSingleton extends boolean, + TInstances extends 'singleton' | 'multiton', TImpl extends TService, TDeps extends { [name in string]: ServiceRef; @@ -273,13 +277,13 @@ export function createServiceFactory< >( options: ( options?: TOpts, - ) => RootServiceFactoryOptions, -): ServiceFactoryCompat; + ) => RootServiceFactoryOptions, +): ServiceFactoryCompat; // @public export function createServiceFactory< TService, - TSingleton extends boolean, + TInstances extends 'singleton' | 'multiton', TImpl extends TService, TDeps extends { [name in string]: ServiceRef; @@ -289,17 +293,17 @@ export function createServiceFactory< >( options: PluginServiceFactoryOptions< TService, - TSingleton, + TInstances, TContext, TImpl, TDeps >, -): ServiceFactoryCompat; +): ServiceFactoryCompat; // @public @deprecated export function createServiceFactory< TService, - TSingleton extends boolean, + TInstances extends 'singleton' | 'multiton', TImpl extends TService, TDeps extends { [name in string]: ServiceRef; @@ -311,32 +315,32 @@ export function createServiceFactory< options?: TOpts, ) => PluginServiceFactoryOptions< TService, - TSingleton, + TInstances, TContext, TImpl, TDeps >, -): ServiceFactoryCompat; +): ServiceFactoryCompat; // @public export function createServiceRef( - options: ServiceRefOptions, -): ServiceRef; + options: ServiceRefOptions, +): ServiceRef; // @public export function createServiceRef( - options: ServiceRefOptions, -): ServiceRef; + options: ServiceRefOptions, +): ServiceRef; // @public export function createServiceRef( - options: ServiceRefOptions, -): ServiceRef; + options: ServiceRefOptions, +): ServiceRef; // @public export function createServiceRef( - options: ServiceRefOptions, -): ServiceRef; + options: ServiceRefOptions, +): ServiceRef; // @public export interface DatabaseService { @@ -473,18 +477,18 @@ export interface PluginMetadataService { // @public @deprecated (undocumented) export type PluginServiceFactoryConfig< TService, - TSingleton extends boolean, + TInstances extends 'singleton' | 'multiton', TContext, TImpl extends TService, TDeps extends { [name in string]: ServiceRef; }, -> = PluginServiceFactoryOptions; +> = PluginServiceFactoryOptions; // @public (undocumented) export interface PluginServiceFactoryOptions< TService, - TSingleton extends boolean, + TInstances extends 'singleton' | 'multiton', TContext, TImpl extends TService, TDeps extends { @@ -504,7 +508,7 @@ export interface PluginServiceFactoryOptions< ): TImpl | Promise; initialization?: 'always' | 'lazy'; // (undocumented) - service: ServiceRef; + service: ServiceRef; } // @public @@ -566,17 +570,17 @@ export interface RootLoggerService extends LoggerService {} // @public @deprecated (undocumented) export type RootServiceFactoryConfig< TService, - TSingleton extends boolean, + TInstances extends 'singleton' | 'multiton', TImpl extends TService, TDeps extends { [name in string]: ServiceRef; }, -> = RootServiceFactoryOptions; +> = RootServiceFactoryOptions; // @public (undocumented) export interface RootServiceFactoryOptions< TService, // TODO(Rugvip): Can we forward the entire service ref type here instead of forwarding each type arg once the callback form is gone? - TSingleton extends boolean, + TInstances extends 'singleton' | 'multiton', TImpl extends TService, TDeps extends { [name in string]: ServiceRef; @@ -588,7 +592,7 @@ export interface RootServiceFactoryOptions< factory(deps: ServiceRefsToInstances): TImpl | Promise; initialization?: 'always' | 'lazy'; // (undocumented) - service: ServiceRef; + service: ServiceRef; } // @public @@ -669,23 +673,23 @@ export type SearchResponseFile = UrlReaderServiceSearchResponseFile; export interface ServiceFactory< TService = unknown, TScope extends 'plugin' | 'root' = 'plugin' | 'root', - TSingleton extends boolean = boolean, + TInstances extends 'singleton' | 'multiton' = 'singleton' | 'multiton', > extends BackendFeature { // (undocumented) - service: ServiceRef; + service: ServiceRef; } // @public @deprecated (undocumented) export interface ServiceFactoryCompat< TService = unknown, TScope extends 'plugin' | 'root' = 'plugin' | 'root', - TSingleton extends boolean = boolean, + TInstances extends 'singleton' | 'multiton' = 'singleton' | 'multiton', TOpts extends object | undefined = undefined, -> extends ServiceFactory { +> extends ServiceFactory { // @deprecated (undocumented) ( ...options: undefined extends TOpts ? [] : [options?: TOpts] - ): ServiceFactory; + ): ServiceFactory; } // @public @deprecated @@ -695,11 +699,11 @@ export type ServiceFactoryOrFunction = ServiceFactory | (() => ServiceFactory); export type ServiceRef< TService, TScope extends 'root' | 'plugin' = 'root' | 'plugin', - TSingleton extends boolean = boolean, + TInstances extends 'singleton' | 'multiton' = 'singleton' | 'multiton', > = { id: string; scope: TScope; - singleton: TSingleton; + multiton: TInstances extends 'multiton' ? true : false; T: TService; $$type: '@backstage/ServiceRef'; }; @@ -708,14 +712,14 @@ export type ServiceRef< export type ServiceRefConfig< TService, TScope extends 'root' | 'plugin', - TSingleton extends boolean, -> = ServiceRefOptions; + TInstances extends 'singleton' | 'multiton', +> = ServiceRefOptions; // @public (undocumented) export interface ServiceRefOptions< TService, TScope extends 'root' | 'plugin', - TSingleton extends boolean, + TInstances extends 'singleton' | 'multiton', > { // (undocumented) defaultFactory?( @@ -728,9 +732,9 @@ export interface ServiceRefOptions< // (undocumented) id: string; // (undocumented) - scope?: TScope; + multiton?: TInstances extends 'multiton' ? true : false; // (undocumented) - singleton?: TSingleton; + scope?: TScope; } // @public @deprecated diff --git a/packages/backend-plugin-api/src/deprecated.ts b/packages/backend-plugin-api/src/deprecated.ts index e68affa0fa..0d02f9ed7e 100644 --- a/packages/backend-plugin-api/src/deprecated.ts +++ b/packages/backend-plugin-api/src/deprecated.ts @@ -28,8 +28,8 @@ import { export type ServiceRefConfig< TService, TScope extends 'root' | 'plugin', - TSingleton extends boolean, -> = ServiceRefOptions; + TInstances extends 'singleton' | 'multiton', +> = ServiceRefOptions; /** * @public @@ -37,10 +37,10 @@ export type ServiceRefConfig< */ export type RootServiceFactoryConfig< TService, - TSingleton extends boolean, + TInstances extends 'singleton' | 'multiton', TImpl extends TService, TDeps extends { [name in string]: ServiceRef }, -> = RootServiceFactoryOptions; +> = RootServiceFactoryOptions; /** * @public @@ -48,8 +48,8 @@ export type RootServiceFactoryConfig< */ export type PluginServiceFactoryConfig< TService, - TSingleton extends boolean, + TInstances extends 'singleton' | 'multiton', TContext, TImpl extends TService, TDeps extends { [name in string]: ServiceRef }, -> = PluginServiceFactoryOptions; +> = PluginServiceFactoryOptions; diff --git a/packages/backend-plugin-api/src/services/system/types.ts b/packages/backend-plugin-api/src/services/system/types.ts index e856136ddc..7cd18da4d2 100644 --- a/packages/backend-plugin-api/src/services/system/types.ts +++ b/packages/backend-plugin-api/src/services/system/types.ts @@ -24,7 +24,7 @@ import { BackendFeature } from '../../types'; export type ServiceRef< TService, TScope extends 'root' | 'plugin' = 'root' | 'plugin', - TSingleton extends boolean = boolean, + TInstances extends 'singleton' | 'multiton' = 'singleton' | 'multiton', > = { id: string; @@ -39,7 +39,7 @@ export type ServiceRef< */ scope: TScope; - singleton: TSingleton; + multiton: TInstances extends 'multiton' ? true : false; /** * Utility for getting the type of the service, using `typeof serviceRef.T`. @@ -54,9 +54,9 @@ export type ServiceRef< export interface ServiceFactory< TService = unknown, TScope extends 'plugin' | 'root' = 'plugin' | 'root', - TSingleton extends boolean = boolean, + TInstances extends 'singleton' | 'multiton' = 'singleton' | 'multiton', > extends BackendFeature { - service: ServiceRef; + service: ServiceRef; } /** @@ -66,23 +66,23 @@ export interface ServiceFactory< export interface ServiceFactoryCompat< TService = unknown, TScope extends 'plugin' | 'root' = 'plugin' | 'root', - TSingleton extends boolean = boolean, + TInstances extends 'singleton' | 'multiton' = 'singleton' | 'multiton', TOpts extends object | undefined = undefined, -> extends ServiceFactory { +> extends ServiceFactory { /** * @deprecated Callable service factories will be removed in a future release, please re-implement the service factory using the available APIs instead. If no options are being passed, you can simply remove the trailing `()`. */ ( ...options: undefined extends TOpts ? [] : [options?: TOpts] - ): ServiceFactory; + ): ServiceFactory; } /** @internal */ export interface InternalServiceFactory< TService = unknown, TScope extends 'plugin' | 'root' = 'plugin' | 'root', - TSingleton extends boolean = boolean, -> extends ServiceFactory { + TInstances extends 'singleton' | 'multiton' = 'singleton' | 'multiton', +> extends ServiceFactory { version: 'v1'; initialization?: 'always' | 'lazy'; deps: { [key in string]: ServiceRef }; @@ -105,11 +105,11 @@ export type ServiceFactoryOrFunction = ServiceFactory | (() => ServiceFactory); export interface ServiceRefOptions< TService, TScope extends 'root' | 'plugin', - TSingleton extends boolean, + TInstances extends 'singleton' | 'multiton', > { id: string; scope?: TScope; - singleton?: TSingleton; + multiton?: TInstances extends 'multiton' ? true : false; defaultFactory?( service: ServiceRef, ): Promise; @@ -127,8 +127,8 @@ export interface ServiceRefOptions< * @public */ export function createServiceRef( - options: ServiceRefOptions, -): ServiceRef; + options: ServiceRefOptions, +): ServiceRef; /** * Creates a new service definition. This overload is used to create root scoped services. @@ -136,8 +136,8 @@ export function createServiceRef( * @public */ export function createServiceRef( - options: ServiceRefOptions, -): ServiceRef; + options: ServiceRefOptions, +): ServiceRef; /** * Creates a new service definition. This overload is used to create plugin scoped services. @@ -145,8 +145,8 @@ export function createServiceRef( * @public */ export function createServiceRef( - options: ServiceRefOptions, -): ServiceRef; + options: ServiceRefOptions, +): ServiceRef; /** * Creates a new service definition. This overload is used to create root scoped services. @@ -154,16 +154,19 @@ export function createServiceRef( * @public */ export function createServiceRef( - options: ServiceRefOptions, -): ServiceRef; -export function createServiceRef( - options: ServiceRefOptions, -): ServiceRef { - const { id, scope = 'plugin', singleton = true, defaultFactory } = options; + options: ServiceRefOptions, +): ServiceRef; +export function createServiceRef< + TService, + TInstances extends 'singleton' | 'multiton', +>( + options: ServiceRefOptions, +): ServiceRef { + const { id, scope = 'plugin', multiton = false, defaultFactory } = options; return { id, scope, - singleton, + multiton, get T(): TService { throw new Error(`tried to read ServiceRef.T of ${this}`); }, @@ -172,7 +175,7 @@ export function createServiceRef( }, $$type: '@backstage/ServiceRef', __defaultFactory: defaultFactory, - } as ServiceRef & { + } as ServiceRef & { __defaultFactory?: ( service: ServiceRef, ) => Promise | (() => ServiceFactory)>; @@ -186,15 +189,15 @@ type ServiceRefsToInstances< > = { [key in keyof T as T[key]['scope'] extends TScope ? key - : never]: T[key]['singleton'] extends true - ? T[key]['T'] - : Array; + : never]: T[key]['multiton'] extends true + ? Array + : T[key]['T']; }; /** @public */ export interface RootServiceFactoryOptions< TService, // TODO(Rugvip): Can we forward the entire service ref type here instead of forwarding each type arg once the callback form is gone? - TSingleton extends boolean, + TInstances extends 'singleton' | 'multiton', TImpl extends TService, TDeps extends { [name in string]: ServiceRef }, > { @@ -209,7 +212,7 @@ export interface RootServiceFactoryOptions< * Service factories for root scoped services use `always` as the default, while plugin scoped services use `lazy`. */ initialization?: 'always' | 'lazy'; - service: ServiceRef; + service: ServiceRef; deps: TDeps; factory(deps: ServiceRefsToInstances): TImpl | Promise; } @@ -217,7 +220,7 @@ export interface RootServiceFactoryOptions< /** @public */ export interface PluginServiceFactoryOptions< TService, - TSingleton extends boolean, + TInstances extends 'singleton' | 'multiton', TContext, TImpl extends TService, TDeps extends { [name in string]: ServiceRef }, @@ -233,7 +236,7 @@ export interface PluginServiceFactoryOptions< * Service factories for root scoped services use `always` as the default, while plugin scoped services use `lazy`. */ initialization?: 'always' | 'lazy'; - service: ServiceRef; + service: ServiceRef; deps: TDeps; createRootContext?( deps: ServiceRefsToInstances, @@ -252,13 +255,13 @@ export interface PluginServiceFactoryOptions< */ export function createServiceFactory< TService, - TSingleton extends boolean, + TInstances extends 'singleton' | 'multiton', TImpl extends TService, TDeps extends { [name in string]: ServiceRef }, TOpts extends object | undefined = undefined, >( - options: RootServiceFactoryOptions, -): ServiceFactoryCompat; + options: RootServiceFactoryOptions, +): ServiceFactoryCompat; /** * Creates a root scoped service factory with optional options. * @@ -271,15 +274,15 @@ export function createServiceFactory< */ export function createServiceFactory< TService, - TSingleton extends boolean, + TInstances extends 'singleton' | 'multiton', TImpl extends TService, TDeps extends { [name in string]: ServiceRef }, TOpts extends object | undefined = undefined, >( options: ( options?: TOpts, - ) => RootServiceFactoryOptions, -): ServiceFactoryCompat; + ) => RootServiceFactoryOptions, +): ServiceFactoryCompat; /** * Creates a plugin scoped service factory without options. * @@ -288,7 +291,7 @@ export function createServiceFactory< */ export function createServiceFactory< TService, - TSingleton extends boolean, + TInstances extends 'singleton' | 'multiton', TImpl extends TService, TDeps extends { [name in string]: ServiceRef }, TContext = undefined, @@ -296,12 +299,12 @@ export function createServiceFactory< >( options: PluginServiceFactoryOptions< TService, - TSingleton, + TInstances, TContext, TImpl, TDeps >, -): ServiceFactoryCompat; +): ServiceFactoryCompat; /** * Creates a plugin scoped service factory with optional options. * @@ -314,7 +317,7 @@ export function createServiceFactory< */ export function createServiceFactory< TService, - TSingleton extends boolean, + TInstances extends 'singleton' | 'multiton', TImpl extends TService, TDeps extends { [name in string]: ServiceRef }, TContext = undefined, @@ -324,44 +327,49 @@ export function createServiceFactory< options?: TOpts, ) => PluginServiceFactoryOptions< TService, - TSingleton, + TInstances, TContext, TImpl, TDeps >, -): ServiceFactoryCompat; +): ServiceFactoryCompat; export function createServiceFactory< TService, - TSingleton extends boolean, + TInstances extends 'singleton' | 'multiton', TImpl extends TService, TDeps extends { [name in string]: ServiceRef }, TContext, TOpts extends object | undefined = undefined, >( options: - | RootServiceFactoryOptions - | PluginServiceFactoryOptions + | RootServiceFactoryOptions + | PluginServiceFactoryOptions | (( options: TOpts, - ) => RootServiceFactoryOptions) + ) => RootServiceFactoryOptions) | (( options: TOpts, ) => PluginServiceFactoryOptions< TService, - TSingleton, + TInstances, TContext, TImpl, TDeps >) - | (() => RootServiceFactoryOptions) + | (() => RootServiceFactoryOptions) | (() => PluginServiceFactoryOptions< TService, - TSingleton, + TInstances, TContext, TImpl, TDeps >), -): ServiceFactoryCompat { +): ServiceFactoryCompat< + TService, + 'root' | 'plugin', + 'singleton' | 'multiton', + TOpts +> { const configCallback = typeof options === 'function' ? options : () => options; const factory = ( @@ -371,7 +379,7 @@ export function createServiceFactory< if (anyConf.service.scope === 'root') { const c = anyConf as RootServiceFactoryOptions< TService, - TSingleton, + TInstances, TImpl, TDeps >; @@ -387,7 +395,7 @@ export function createServiceFactory< } const c = anyConf as PluginServiceFactoryOptions< TService, - TSingleton, + TInstances, TContext, TImpl, TDeps diff --git a/packages/backend-test-utils/api-report.md b/packages/backend-test-utils/api-report.md index 5a9e016dcd..584fedb1f5 100644 --- a/packages/backend-test-utils/api-report.md +++ b/packages/backend-test-utils/api-report.md @@ -156,7 +156,12 @@ export namespace mockServices { // (undocumented) export namespace auth { const // (undocumented) - factory: ServiceFactoryCompat; + factory: ServiceFactoryCompat< + AuthService, + 'plugin', + 'singleton', + undefined + >; const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -165,7 +170,12 @@ export namespace mockServices { // (undocumented) export namespace cache { const // (undocumented) - factory: ServiceFactoryCompat; + factory: ServiceFactoryCompat< + CacheService, + 'plugin', + 'singleton', + undefined + >; const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -174,7 +184,12 @@ export namespace mockServices { // (undocumented) export namespace database { const // (undocumented) - factory: ServiceFactoryCompat; + factory: ServiceFactoryCompat< + DatabaseService, + 'plugin', + 'singleton', + undefined + >; const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -188,7 +203,7 @@ export namespace mockServices { factory: ServiceFactoryCompat< DiscoveryService, 'plugin', - true, + 'singleton', undefined >; const // (undocumented) @@ -199,7 +214,12 @@ export namespace mockServices { // (undocumented) export namespace events { const // (undocumented) - factory: ServiceFactoryCompat; + factory: ServiceFactoryCompat< + EventsService, + 'plugin', + 'singleton', + undefined + >; const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -213,8 +233,8 @@ export namespace mockServices { export namespace httpAuth { const factory: ((options?: { defaultCredentials?: BackstageCredentials; - }) => ServiceFactory) & - ServiceFactory; + }) => ServiceFactory) & + ServiceFactory; const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -226,7 +246,7 @@ export namespace mockServices { factory: ServiceFactoryCompat< HttpRouterService, 'plugin', - true, + 'singleton', undefined >; const // (undocumented) @@ -239,7 +259,12 @@ export namespace mockServices { // (undocumented) export namespace identity { const // (undocumented) - factory: ServiceFactoryCompat; + factory: ServiceFactoryCompat< + IdentityService, + 'plugin', + 'singleton', + undefined + >; const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -251,7 +276,7 @@ export namespace mockServices { factory: ServiceFactoryCompat< LifecycleService, 'plugin', - true, + 'singleton', undefined >; const // (undocumented) @@ -262,7 +287,12 @@ export namespace mockServices { // (undocumented) export namespace logger { const // (undocumented) - factory: ServiceFactoryCompat; + factory: ServiceFactoryCompat< + LoggerService, + 'plugin', + 'singleton', + undefined + >; const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -274,7 +304,7 @@ export namespace mockServices { factory: ServiceFactoryCompat< PermissionsService, 'plugin', - true, + 'singleton', undefined >; const // (undocumented) @@ -291,15 +321,28 @@ export namespace mockServices { data?: JsonObject; }; const // (undocumented) - factory: ServiceFactory & + factory: ServiceFactory< + RootConfigService, + 'root', + 'singleton' | 'multiton' + > & (( options?: Options | undefined, - ) => ServiceFactory); + ) => ServiceFactory< + RootConfigService, + 'root', + 'singleton' | 'multiton' + >); } // (undocumented) export namespace rootHealth { const // (undocumented) - factory: ServiceFactoryCompat; + factory: ServiceFactoryCompat< + RootHealthService, + 'root', + 'singleton', + undefined + >; const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -310,8 +353,8 @@ export namespace mockServices { const // (undocumented) factory: (( options?: RootHttpRouterFactoryOptions | undefined, - ) => ServiceFactory) & - ServiceFactory; + ) => ServiceFactory) & + ServiceFactory; const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -323,7 +366,7 @@ export namespace mockServices { factory: ServiceFactoryCompat< RootLifecycleService, 'root', - true, + 'singleton', undefined >; const // (undocumented) @@ -340,10 +383,10 @@ export namespace mockServices { level?: 'none' | 'error' | 'warn' | 'info' | 'debug'; }; const // (undocumented) - factory: ServiceFactory & + factory: ServiceFactory & (( options?: Options | undefined, - ) => ServiceFactory); + ) => ServiceFactory); const // (undocumented) mock: ( partialImpl?: Partial | undefined, @@ -355,7 +398,7 @@ export namespace mockServices { factory: ServiceFactoryCompat< SchedulerService, 'plugin', - true, + 'singleton', undefined >; const // (undocumented) @@ -371,7 +414,7 @@ export namespace mockServices { factory: ServiceFactoryCompat< TokenManagerService, 'plugin', - true, + 'singleton', undefined >; const // (undocumented) @@ -385,7 +428,7 @@ export namespace mockServices { factory: ServiceFactoryCompat< UrlReaderService, 'plugin', - true, + 'singleton', undefined >; const // (undocumented) @@ -401,7 +444,7 @@ export namespace mockServices { const factory: ServiceFactoryCompat< UserInfoService, 'plugin', - true, + 'singleton', undefined >; const // (undocumented) @@ -422,31 +465,31 @@ export function registerMswTestHooks(worker: { export class ServiceFactoryTester< TService, TScope extends 'root' | 'plugin', - TSingleton extends boolean = true, + TInstances extends 'singleton' | 'multiton' = 'singleton', > { static from< TService, TScope extends 'root' | 'plugin', - TSingleton extends boolean = true, + TInstances extends 'singleton' | 'multiton' = 'singleton', >( - subject: ServiceFactory, + subject: ServiceFactory, options?: ServiceFactoryTesterOptions, - ): ServiceFactoryTester; + ): ServiceFactoryTester; // @deprecated get( ...args: 'root' extends TScope ? [] : [pluginId?: string] - ): Promise; + ): Promise; getService< TGetService, TGetScope extends 'root' | 'plugin', - TGetSingleton extends boolean, + TGetInstances extends 'singleton' | 'multiton' = 'singleton', >( - service: ServiceRef, + service: ServiceRef, ...args: 'root' extends TGetScope ? [] : [pluginId?: string] - ): Promise; + ): Promise; getSubject( ...args: 'root' extends TScope ? [] : [pluginId?: string] - ): Promise; + ): Promise; } // @public diff --git a/packages/backend-test-utils/src/next/wiring/ServiceFactoryTester.ts b/packages/backend-test-utils/src/next/wiring/ServiceFactoryTester.ts index 94092aff68..e8530f89bf 100644 --- a/packages/backend-test-utils/src/next/wiring/ServiceFactoryTester.ts +++ b/packages/backend-test-utils/src/next/wiring/ServiceFactoryTester.ts @@ -46,9 +46,9 @@ export interface ServiceFactoryTesterOptions { export class ServiceFactoryTester< TService, TScope extends 'root' | 'plugin', - TSingleton extends boolean = true, + TInstances extends 'singleton' | 'multiton' = 'singleton', > { - readonly #subject: ServiceRef; + readonly #subject: ServiceRef; readonly #registry: ServiceRegistry; /** @@ -61,11 +61,11 @@ export class ServiceFactoryTester< static from< TService, TScope extends 'root' | 'plugin', - TSingleton extends boolean = true, + TInstances extends 'singleton' | 'multiton' = 'singleton', >( - subject: ServiceFactory, + subject: ServiceFactory, options?: ServiceFactoryTesterOptions, - ): ServiceFactoryTester { + ): ServiceFactoryTester { const registry = ServiceRegistry.create([ ...defaultServiceFactories, ...(options?.dependencies ?? []), @@ -75,7 +75,7 @@ export class ServiceFactoryTester< } private constructor( - subject: ServiceRef, + subject: ServiceRef, registry: ServiceRegistry, ) { this.#subject = subject; @@ -89,7 +89,7 @@ export class ServiceFactoryTester< */ async get( ...args: 'root' extends TScope ? [] : [pluginId?: string] - ): Promise { + ): Promise { return this.getSubject(...args); } @@ -105,7 +105,7 @@ export class ServiceFactoryTester< */ async getSubject( ...args: 'root' extends TScope ? [] : [pluginId?: string] - ): Promise { + ): Promise { const [pluginId] = args; const instance = this.#registry.get(this.#subject, pluginId ?? 'test')!; return instance; @@ -121,11 +121,11 @@ export class ServiceFactoryTester< async getService< TGetService, TGetScope extends 'root' | 'plugin', - TGetSingleton extends boolean, + TGetInstances extends 'singleton' | 'multiton' = 'singleton', >( - service: ServiceRef, + service: ServiceRef, ...args: 'root' extends TGetScope ? [] : [pluginId?: string] - ): Promise { + ): Promise { const [pluginId] = args; const instance = await this.#registry.get(service, pluginId ?? 'test'); if (instance === undefined) { diff --git a/plugins/catalog-node/api-report-alpha.md b/plugins/catalog-node/api-report-alpha.md index a2579e29f4..daa388d5e3 100644 --- a/plugins/catalog-node/api-report-alpha.md +++ b/plugins/catalog-node/api-report-alpha.md @@ -88,7 +88,7 @@ export interface CatalogProcessingExtensionPoint { export const catalogProcessingExtensionPoint: ExtensionPoint; // @alpha -export const catalogServiceRef: ServiceRef; +export const catalogServiceRef: ServiceRef; // (No @packageDocumentation comment for this package) ``` diff --git a/plugins/events-node/api-report.md b/plugins/events-node/api-report.md index e159446103..729f526dee 100644 --- a/plugins/events-node/api-report.md +++ b/plugins/events-node/api-report.md @@ -66,12 +66,12 @@ export type EventsServiceEventHandler = (params: EventParams) => Promise; export const eventsServiceFactory: ServiceFactoryCompat< EventsService, 'plugin', - true, + 'singleton', undefined >; // @public -export const eventsServiceRef: ServiceRef; +export const eventsServiceRef: ServiceRef; // @public (undocumented) export type EventsServiceSubscribeOptions = { diff --git a/plugins/notifications-node/api-report.md b/plugins/notifications-node/api-report.md index fd356131ee..995b98bc21 100644 --- a/plugins/notifications-node/api-report.md +++ b/plugins/notifications-node/api-report.md @@ -68,7 +68,7 @@ export interface NotificationService { export const notificationService: ServiceRef< NotificationService, 'plugin', - true + 'singleton' >; // @public (undocumented) diff --git a/plugins/search-backend-node/api-report-alpha.md b/plugins/search-backend-node/api-report-alpha.md index dc41fa6400..e1d5bd024d 100644 --- a/plugins/search-backend-node/api-report-alpha.md +++ b/plugins/search-backend-node/api-report-alpha.md @@ -49,7 +49,7 @@ export type SearchIndexServiceInitOptions = { export const searchIndexServiceRef: ServiceRef< SearchIndexService, 'plugin', - true + 'singleton' >; // (No @packageDocumentation comment for this package) diff --git a/plugins/signals-node/api-report.md b/plugins/signals-node/api-report.md index b2d5a2b210..a368dd2ece 100644 --- a/plugins/signals-node/api-report.md +++ b/plugins/signals-node/api-report.md @@ -37,7 +37,7 @@ export type SignalPayload = { export interface SignalService extends SignalsService {} // @public @deprecated (undocumented) -export const signalService: ServiceRef; +export const signalService: ServiceRef; // @public (undocumented) export interface SignalsService { @@ -52,7 +52,11 @@ export type SignalsServiceOptions = { }; // @public (undocumented) -export const signalsServiceRef: ServiceRef; +export const signalsServiceRef: ServiceRef< + SignalsService, + 'plugin', + 'singleton' +>; // (No @packageDocumentation comment for this package) ``` From d160ce8925c3d67fa711fa7d2de707237eb3dbd9 Mon Sep 17 00:00:00 2001 From: Tim Hansen Date: Tue, 16 Jul 2024 14:49:20 -0400 Subject: [PATCH 041/372] Add trigger to backend-tasks schema Signed-off-by: Tim Hansen --- packages/backend-tasks/src/tasks/types.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/backend-tasks/src/tasks/types.ts b/packages/backend-tasks/src/tasks/types.ts index aaa6ca8bd2..a0bdbbaa64 100644 --- a/packages/backend-tasks/src/tasks/types.ts +++ b/packages/backend-tasks/src/tasks/types.ts @@ -378,6 +378,10 @@ function isValidCronFormat(c: string | undefined): boolean { } } +function isValidTrigger(t: string): boolean { + return t === 'manual'; +} + export const taskSettingsV1Schema = z.object({ version: z.literal(1), initialDelayDuration: z @@ -406,6 +410,11 @@ export const taskSettingsV2Schema = z.object({ cadence: z .string() .refine(isValidCronFormat, { message: 'Invalid cron' }) + .or( + z.string().refine(isValidTrigger, { + message: "Invalid trigger, expecting 'manual'", + }), + ) .or( z.string().refine(isValidOptionalDurationString, { message: 'Invalid duration, expecting ISO Period', From df17af74d61c4422a546ac63afe568cd70b5ffe4 Mon Sep 17 00:00:00 2001 From: Tim Hansen Date: Tue, 16 Jul 2024 17:41:09 -0400 Subject: [PATCH 042/372] Update migration, move test file Signed-off-by: Tim Hansen --- .../migrations/scheduler/20240712211735_nullable_next_run.js | 4 ++++ packages/backend-defaults/{ => src}/migrations.test.ts | 5 ----- .../migrations/20240712211735_nullable_next_run.js | 4 ++++ packages/backend-tasks/src/migrations.test.ts | 5 ----- 4 files changed, 8 insertions(+), 10 deletions(-) rename packages/backend-defaults/{ => src}/migrations.test.ts (96%) diff --git a/packages/backend-defaults/migrations/scheduler/20240712211735_nullable_next_run.js b/packages/backend-defaults/migrations/scheduler/20240712211735_nullable_next_run.js index b636df35d7..efbef1c76f 100644 --- a/packages/backend-defaults/migrations/scheduler/20240712211735_nullable_next_run.js +++ b/packages/backend-defaults/migrations/scheduler/20240712211735_nullable_next_run.js @@ -31,6 +31,10 @@ exports.up = async function up(knex) { * @returns { Promise } */ exports.down = async function down(knex) { + await knex + .delete() + .from('backstage_backend_tasks__tasks') + .where({ next_run_start_at: null }); await knex.schema.alterTable('backstage_backend_tasks__tasks', table => { table.dropNullable('next_run_start_at'); }); diff --git a/packages/backend-defaults/migrations.test.ts b/packages/backend-defaults/src/migrations.test.ts similarity index 96% rename from packages/backend-defaults/migrations.test.ts rename to packages/backend-defaults/src/migrations.test.ts index 98f4e41706..cae127442b 100644 --- a/packages/backend-defaults/migrations.test.ts +++ b/packages/backend-defaults/src/migrations.test.ts @@ -107,11 +107,6 @@ describe('migrations', () => { }, ]); - await knex - .delete() - .from('backstage_backend_tasks__tasks') - .where({ next_run_start_at: null }); - await migrateDownOnce(knex); await expect( diff --git a/packages/backend-tasks/migrations/20240712211735_nullable_next_run.js b/packages/backend-tasks/migrations/20240712211735_nullable_next_run.js index b636df35d7..efbef1c76f 100644 --- a/packages/backend-tasks/migrations/20240712211735_nullable_next_run.js +++ b/packages/backend-tasks/migrations/20240712211735_nullable_next_run.js @@ -31,6 +31,10 @@ exports.up = async function up(knex) { * @returns { Promise } */ exports.down = async function down(knex) { + await knex + .delete() + .from('backstage_backend_tasks__tasks') + .where({ next_run_start_at: null }); await knex.schema.alterTable('backstage_backend_tasks__tasks', table => { table.dropNullable('next_run_start_at'); }); diff --git a/packages/backend-tasks/src/migrations.test.ts b/packages/backend-tasks/src/migrations.test.ts index 49576d8a58..7583948f71 100644 --- a/packages/backend-tasks/src/migrations.test.ts +++ b/packages/backend-tasks/src/migrations.test.ts @@ -107,11 +107,6 @@ describe('migrations', () => { }, ]); - await knex - .delete() - .from('backstage_backend_tasks__tasks') - .where({ next_run_start_at: null }); - await migrateDownOnce(knex); await expect( From fff1f50a7fbceb1245fd9c519a893a34994ab6b5 Mon Sep 17 00:00:00 2001 From: Tim Hansen Date: Tue, 16 Jul 2024 19:43:03 -0400 Subject: [PATCH 043/372] Fix migration path Signed-off-by: Tim Hansen --- packages/backend-defaults/src/migrations.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend-defaults/src/migrations.test.ts b/packages/backend-defaults/src/migrations.test.ts index cae127442b..579c32e626 100644 --- a/packages/backend-defaults/src/migrations.test.ts +++ b/packages/backend-defaults/src/migrations.test.ts @@ -18,7 +18,7 @@ import { Knex } from 'knex'; import { TestDatabases } from '@backstage/backend-test-utils'; import fs from 'fs'; -const migrationsDir = `${__dirname}/../migrations`; +const migrationsDir = `${__dirname}/../migrations/scheduler`; const migrationsFiles = fs.readdirSync(migrationsDir).sort(); async function migrateUpOnce(knex: Knex): Promise { From 2322291216aaa131eaa20dc29b554d5d04e5ab16 Mon Sep 17 00:00:00 2001 From: JounQin Date: Thu, 18 Jul 2024 19:32:43 +0800 Subject: [PATCH 044/372] fix: consider broadcast union with user close #25682 Signed-off-by: JounQin --- .../database/DatabaseNotificationsStore.ts | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/plugins/notifications-backend/src/database/DatabaseNotificationsStore.ts b/plugins/notifications-backend/src/database/DatabaseNotificationsStore.ts index 3d027128ec..b23f5254f4 100644 --- a/plugins/notifications-backend/src/database/DatabaseNotificationsStore.ts +++ b/plugins/notifications-backend/src/database/DatabaseNotificationsStore.ts @@ -138,14 +138,14 @@ export class DatabaseNotificationsStore implements NotificationsStore { }; }; - private getBroadcastUnion = () => { + private getBroadcastUnion = (user?: string | null) => { return this.db('broadcast') - .leftJoin( - 'broadcast_user_status', - 'id', - '=', - 'broadcast_user_status.broadcast_id', - ) + .leftJoin('broadcast_user_status', function clause() { + const join = this.on('id', '=', 'broadcast_user_status.broadcast_id'); + if (user !== null && user !== undefined) { + join.andOnVal('user', '=', user); + } + }) .select(NOTIFICATION_COLUMNS); }; @@ -156,7 +156,7 @@ export class DatabaseNotificationsStore implements NotificationsStore { const subQuery = this.db('notification') .select(NOTIFICATION_COLUMNS) - .unionAll([this.getBroadcastUnion()]) + .unionAll([this.getBroadcastUnion(user)]) .as('notifications'); const query = this.db.from(subQuery).where(q => { @@ -345,16 +345,19 @@ export class DatabaseNotificationsStore implements NotificationsStore { broadcastQuery.update({ ...updateColumns, read: undefined }), ]); - return await this.getNotification({ id }); + return await this.getNotification({ id, user: notification.user }); } - async getNotification(options: { id: string }): Promise { + async getNotification(options: { + id: string; + user?: string | null; + }): Promise { const rows = await this.db .select('*') .from( this.db('notification') .select(NOTIFICATION_COLUMNS) - .unionAll([this.getBroadcastUnion()]) + .unionAll([this.getBroadcastUnion(options.user)]) .as('notifications'), ) .where('id', options.id) From 0ce75e308d0a1913efeeb2d8add6f08067ca1709 Mon Sep 17 00:00:00 2001 From: JounQin Date: Thu, 18 Jul 2024 20:24:54 +0800 Subject: [PATCH 045/372] test: add related test cases Signed-off-by: JounQin --- .../DatabaseNotificationsStore.test.ts | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/plugins/notifications-backend/src/database/DatabaseNotificationsStore.test.ts b/plugins/notifications-backend/src/database/DatabaseNotificationsStore.test.ts index c6df60c56e..d4e678c8f1 100644 --- a/plugins/notifications-backend/src/database/DatabaseNotificationsStore.test.ts +++ b/plugins/notifications-backend/src/database/DatabaseNotificationsStore.test.ts @@ -42,6 +42,7 @@ async function createStore(databaseId: TestDatabaseId) { const idOnly = (notification: Notification) => notification.id; const user = 'user:default/john.doe'; +const otherUser = 'user:default/jane.doe'; const id0 = '08e0871e-e60a-4f68-8110-5ae3513f992e'; const id1 = '01e0871e-e60a-4f68-8110-5ae3513f992e'; @@ -140,7 +141,7 @@ const testNotification7: Notification = { }; const otherUserNotification: Notification = { id: id0, - user: 'user:default/jane.doe', + user: otherUser, created: new Date(now), origin: 'plugin-test', payload: { @@ -246,6 +247,34 @@ describe.each(databases.eachSupportedId())( expect(notifications.map(idOnly)).toEqual([id2, id3, id1]); }); + it('should return correct broadcast notifications for different users', async () => { + await storage.saveNotification(testNotification1); + await storage.saveBroadcast(testNotification2); + await storage.saveNotification(testNotification3); + await storage.saveNotification(otherUserNotification); + + await storage.markRead({ ids: [id1, id2], user }); + + const notifications = await storage.getNotifications({ + user, + }); + expect(notifications.map(idOnly)).toEqual([id2, id3, id1]); + expect(notifications[1].user).toBe(user); + + let otherUserNotifications = await storage.getNotifications({ + user: otherUser, + }); + expect(otherUserNotifications.map(idOnly)).toEqual([id0, id2]); + expect(otherUserNotifications[1].user).toBeNull(); + + await storage.markRead({ ids: [id0, id2], user: otherUser }); + otherUserNotifications = await storage.getNotifications({ + user: otherUser, + }); + expect(otherUserNotifications.map(idOnly)).toEqual([id0, id2]); + expect(otherUserNotifications[1].user).toBe(otherUser); + }); + it('should allow searching for notifications', async () => { await storage.saveNotification(testNotification2); await storage.saveBroadcast(testNotification1); @@ -571,6 +600,23 @@ describe.each(databases.eachSupportedId())( const notification = await storage.getNotification({ id: id2 }); expect(notification?.id).toEqual(id2); }); + + it('should consider user for broadcast by id', async () => { + await storage.saveBroadcast(testNotification1); + + let notification = await storage.getNotification({ id: id1, user }); + expect(notification?.id).toEqual(id1); + expect(notification?.user).toBeNull(); + await storage.markRead({ ids: [id1], user }); + notification = await storage.getNotification({ id: id1, user }); + expect(notification?.user).toBe(user); + + const otherNotification = await storage.getNotification({ + id: id1, + user: otherUser, + }); + expect(otherNotification?.user).toBeNull(); + }); }); describe('markRead', () => { From 8013044b0c41f99f5d280c5fec804b66c143cd40 Mon Sep 17 00:00:00 2001 From: JounQin Date: Thu, 18 Jul 2024 20:25:35 +0800 Subject: [PATCH 046/372] docs: add changeset Signed-off-by: JounQin --- .changeset/lovely-planes-shop.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/lovely-planes-shop.md diff --git a/.changeset/lovely-planes-shop.md b/.changeset/lovely-planes-shop.md new file mode 100644 index 0000000000..3ee5a57e75 --- /dev/null +++ b/.changeset/lovely-planes-shop.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-notifications-backend': patch +--- + +fix: consider broadcast union with user From 0f9e910d23739913ea9ea58c746791a9a3ef16ab Mon Sep 17 00:00:00 2001 From: "Jason Diaz G." Date: Wed, 3 Jul 2024 20:46:51 -0600 Subject: [PATCH 047/372] feat(cloudflare-auth-access-provider): Add support for cloudflare custom headers and cookie auth name Signed-off-by: Jason Diaz G. --- .../config.d.ts | 2 + .../src/helpers.test.ts | 79 +++++++++++++++++++ .../src/helpers.ts | 19 +++-- 3 files changed, 93 insertions(+), 7 deletions(-) diff --git a/plugins/auth-backend-module-cloudflare-access-provider/config.d.ts b/plugins/auth-backend-module-cloudflare-access-provider/config.d.ts index ff7d722d48..235cac8446 100644 --- a/plugins/auth-backend-module-cloudflare-access-provider/config.d.ts +++ b/plugins/auth-backend-module-cloudflare-access-provider/config.d.ts @@ -27,6 +27,8 @@ export interface Config { token: string; subject: string; }>; + customHeader?: string; + customCookieAuthName?: string; }; /** * The backstage token expiration. diff --git a/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.test.ts b/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.test.ts index 9efab07ba5..be91583e16 100644 --- a/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.test.ts +++ b/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.test.ts @@ -239,4 +239,83 @@ describe('helpers', () => { token: token, }); }); + + it('works for regular tokens, through custom header auth', async () => { + jest.useFakeTimers({ + now: 1600000004000, + }); + + const helper = AuthHelper.fromConfig( + new ConfigReader({ teamName: 'mock-team', customHeader: 'X-Auth-Token' }), + { cache }, + ); + const token = await tokenFactory.userToken(); + const request = createRequest({ + headers: { ['X-Auth-Token']: token }, + }); + + const expected = { + cfIdentity: { + email: 'hello@example.com', + groups: [{ id: '123', email: 'foo@bar.com', name: 'foo' }], + id: '1234567890', + name: 'User Name', + }, + claims: { + iss: `https://mock-team.cloudflareaccess.com`, + sub: '1234567890', + name: 'User Name', + iat: 1600000000, + exp: 1600000005, + }, + expiresInSeconds: 5, + }; + + await expect(helper.authenticate(request)).resolves.toEqual({ + ...expected, + token: token, + }); + expect(cache.set).toHaveBeenCalledTimes(1); + expect(cache.set.mock.calls[0][0]).toBe( + 'providers/cloudflare-access/profile-v1/1234567890', + ); + expect(JSON.parse(cache.set.mock.calls[0][1] as string)).toEqual(expected); + }); + + it('works for regular tokens, through custom cookie auth name', async () => { + jest.useFakeTimers({ + now: 1600000004000, + }); + + const helper = AuthHelper.fromConfig( + new ConfigReader({ teamName: 'mock-team', customCookieAuthName: 'CF_Custom_Auth' }), + { cache }, + ); + const token = await tokenFactory.userToken(); + const request = createRequest({ + cookies: { 'CF_Custom_Auth': token }, + }); + + const expected = { + cfIdentity: { + email: 'hello@example.com', + groups: [{ id: '123', email: 'foo@bar.com', name: 'foo' }], + id: '1234567890', + name: 'User Name', + }, + claims: { + iss: `https://mock-team.cloudflareaccess.com`, + sub: '1234567890', + name: 'User Name', + iat: 1600000000, + exp: 1600000005, + }, + expiresInSeconds: 5, + }; + + await expect(helper.authenticate(request)).resolves.toEqual({ + ...expected, + token: token, + }); + }); }); diff --git a/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.ts b/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.ts index c1a14ae6b4..298fd82a89 100644 --- a/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.ts +++ b/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.ts @@ -40,6 +40,8 @@ export class AuthHelper { options?: { cache?: CacheService }, ): AuthHelper { const teamName = config.getString('teamName'); + const customHeader = config.getString('customHeader'); + const customCookieAuthName = config.getString('customCookieAuthName'); const serviceTokens = ( config.getOptionalConfigArray('serviceTokens') ?? [] )?.map(cfg => { @@ -53,7 +55,7 @@ export class AuthHelper { new URL(`https://${teamName}.cloudflareaccess.com/cdn-cgi/access/certs`), ); - return new AuthHelper(teamName, serviceTokens, keySet, options?.cache); + return new AuthHelper(teamName, serviceTokens, keySet, options?.cache, customHeader, customCookieAuthName); } private constructor( @@ -61,20 +63,23 @@ export class AuthHelper { private readonly serviceTokens: ServiceToken[], private readonly keySet: ReturnType, private readonly cache?: CacheService, - ) {} + private readonly customHeader?: string, + private readonly customCookieAuthName?: string, + ) { } async authenticate(req: express.Request): Promise { // JWTs generated by Access are available in a request header as // Cf-Access-Jwt-Assertion and as cookies as CF_Authorization. - let jwt = req.header(CF_JWT_HEADER); + let jwt = req.header(this.customHeader || CF_JWT_HEADER); if (!jwt) { - jwt = req.cookies.CF_Authorization; + jwt = req.cookies[this.customCookieAuthName || COOKIE_AUTH_NAME]; } if (!jwt) { // Only throw if both are not provided by Cloudflare Access since either // can be used. throw new AuthenticationError( - `Missing ${CF_JWT_HEADER} from Cloudflare Access`, + `Missing ${this.customHeader || CF_JWT_HEADER} and + ${this.customCookieAuthName || COOKIE_AUTH_NAME} from Cloudflare Access`, ); } @@ -155,8 +160,8 @@ export class AuthHelper { ): Promise { const headers = new Headers(); // set both headers just the way inbound responses are set - headers.set(CF_JWT_HEADER, jwt); - headers.set('cookie', `${COOKIE_AUTH_NAME}=${jwt}`); + headers.set(this.customHeader || CF_JWT_HEADER, jwt); + headers.set('cookie', `${this.customCookieAuthName || COOKIE_AUTH_NAME}=${jwt}`); try { const res = await fetch( `https://${this.teamName}.cloudflareaccess.com/cdn-cgi/access/get-identity`, From 75d026ab1f9587a3498b23be9cd5ef63c7e5e777 Mon Sep 17 00:00:00 2001 From: "Jason Diaz G." Date: Wed, 3 Jul 2024 21:11:53 -0600 Subject: [PATCH 048/372] chore(cloudflare-auth-access-provider): Add changeset for the PR Signed-off-by: Jason Diaz G. --- .changeset/strong-chicken-kiss.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/strong-chicken-kiss.md diff --git a/.changeset/strong-chicken-kiss.md b/.changeset/strong-chicken-kiss.md new file mode 100644 index 0000000000..26f667c5ab --- /dev/null +++ b/.changeset/strong-chicken-kiss.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-auth-backend-module-cloudflare-access-provider': minor +--- + +Support for Cloudflare Custom Headers and Custom Cookie Auth Name From eeadefbb09b2f1a8b5aa0a77d92400d0680c9054 Mon Sep 17 00:00:00 2001 From: "Jason Diaz G." Date: Thu, 4 Jul 2024 11:15:44 -0600 Subject: [PATCH 049/372] fix(cloudflare-auth-access-provider): broken tests fix Signed-off-by: Jason Diaz G. --- .../src/helpers.ts | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.ts b/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.ts index 298fd82a89..45718ffab1 100644 --- a/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.ts +++ b/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.ts @@ -40,8 +40,10 @@ export class AuthHelper { options?: { cache?: CacheService }, ): AuthHelper { const teamName = config.getString('teamName'); - const customHeader = config.getString('customHeader'); - const customCookieAuthName = config.getString('customCookieAuthName'); + const customHeader = config.getOptionalString('customHeader'); + const customCookieAuthName = config.getOptionalString( + 'customCookieAuthName', + ); const serviceTokens = ( config.getOptionalConfigArray('serviceTokens') ?? [] )?.map(cfg => { @@ -55,7 +57,14 @@ export class AuthHelper { new URL(`https://${teamName}.cloudflareaccess.com/cdn-cgi/access/certs`), ); - return new AuthHelper(teamName, serviceTokens, keySet, options?.cache, customHeader, customCookieAuthName); + return new AuthHelper( + teamName, + serviceTokens, + keySet, + options?.cache, + customHeader, + customCookieAuthName, + ); } private constructor( @@ -65,7 +74,7 @@ export class AuthHelper { private readonly cache?: CacheService, private readonly customHeader?: string, private readonly customCookieAuthName?: string, - ) { } + ) {} async authenticate(req: express.Request): Promise { // JWTs generated by Access are available in a request header as @@ -79,7 +88,9 @@ export class AuthHelper { // can be used. throw new AuthenticationError( `Missing ${this.customHeader || CF_JWT_HEADER} and - ${this.customCookieAuthName || COOKIE_AUTH_NAME} from Cloudflare Access`, + ${ + this.customCookieAuthName || COOKIE_AUTH_NAME + } from Cloudflare Access`, ); } @@ -161,7 +172,10 @@ export class AuthHelper { const headers = new Headers(); // set both headers just the way inbound responses are set headers.set(this.customHeader || CF_JWT_HEADER, jwt); - headers.set('cookie', `${this.customCookieAuthName || COOKIE_AUTH_NAME}=${jwt}`); + headers.set( + 'cookie', + `${this.customCookieAuthName || COOKIE_AUTH_NAME}=${jwt}`, + ); try { const res = await fetch( `https://${this.teamName}.cloudflareaccess.com/cdn-cgi/access/get-identity`, From 8a7db0dd15954f0ce50e18495f46352188625d18 Mon Sep 17 00:00:00 2001 From: "Jason Diaz G." Date: Thu, 4 Jul 2024 20:03:06 -0600 Subject: [PATCH 050/372] fix(cloudflare-auth-access-provider): change default names for custom variables Signed-off-by: Jason Diaz G. --- .../config.d.ts | 4 +-- .../src/helpers.test.ts | 16 ++++++++---- .../src/helpers.ts | 26 +++++++++---------- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/plugins/auth-backend-module-cloudflare-access-provider/config.d.ts b/plugins/auth-backend-module-cloudflare-access-provider/config.d.ts index 235cac8446..9715eb3a39 100644 --- a/plugins/auth-backend-module-cloudflare-access-provider/config.d.ts +++ b/plugins/auth-backend-module-cloudflare-access-provider/config.d.ts @@ -27,8 +27,8 @@ export interface Config { token: string; subject: string; }>; - customHeader?: string; - customCookieAuthName?: string; + jwtHeaderName?: string; + authorizationCookieName?: string; }; /** * The backstage token expiration. diff --git a/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.test.ts b/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.test.ts index be91583e16..d5a1c8be0f 100644 --- a/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.test.ts +++ b/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.test.ts @@ -240,13 +240,16 @@ describe('helpers', () => { }); }); - it('works for regular tokens, through custom header auth', async () => { + it('works for regular tokens, through jwtHeaderName header', async () => { jest.useFakeTimers({ now: 1600000004000, }); const helper = AuthHelper.fromConfig( - new ConfigReader({ teamName: 'mock-team', customHeader: 'X-Auth-Token' }), + new ConfigReader({ + teamName: 'mock-team', + jwtHeaderName: 'X-Auth-Token', + }), { cache }, ); const token = await tokenFactory.userToken(); @@ -282,18 +285,21 @@ describe('helpers', () => { expect(JSON.parse(cache.set.mock.calls[0][1] as string)).toEqual(expected); }); - it('works for regular tokens, through custom cookie auth name', async () => { + it('works for regular tokens, through authorizationCookieName cookie name', async () => { jest.useFakeTimers({ now: 1600000004000, }); const helper = AuthHelper.fromConfig( - new ConfigReader({ teamName: 'mock-team', customCookieAuthName: 'CF_Custom_Auth' }), + new ConfigReader({ + teamName: 'mock-team', + authorizationCookieName: 'CF_Auth', + }), { cache }, ); const token = await tokenFactory.userToken(); const request = createRequest({ - cookies: { 'CF_Custom_Auth': token }, + cookies: { CF_Custom_Auth: token }, }); const expected = { diff --git a/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.ts b/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.ts index 45718ffab1..b3fefb8789 100644 --- a/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.ts +++ b/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.ts @@ -40,9 +40,9 @@ export class AuthHelper { options?: { cache?: CacheService }, ): AuthHelper { const teamName = config.getString('teamName'); - const customHeader = config.getOptionalString('customHeader'); - const customCookieAuthName = config.getOptionalString( - 'customCookieAuthName', + const jwtHeaderName = config.getOptionalString('jwtHeaderName'); + const authorizationCookieName = config.getOptionalString( + 'authorizationCookieName', ); const serviceTokens = ( config.getOptionalConfigArray('serviceTokens') ?? [] @@ -62,8 +62,8 @@ export class AuthHelper { serviceTokens, keySet, options?.cache, - customHeader, - customCookieAuthName, + jwtHeaderName, + authorizationCookieName, ); } @@ -72,24 +72,24 @@ export class AuthHelper { private readonly serviceTokens: ServiceToken[], private readonly keySet: ReturnType, private readonly cache?: CacheService, - private readonly customHeader?: string, - private readonly customCookieAuthName?: string, + private readonly jwtHeaderName?: string, + private readonly authorizationCookieName?: string, ) {} async authenticate(req: express.Request): Promise { // JWTs generated by Access are available in a request header as // Cf-Access-Jwt-Assertion and as cookies as CF_Authorization. - let jwt = req.header(this.customHeader || CF_JWT_HEADER); + let jwt = req.header(this.jwtHeaderName || CF_JWT_HEADER); if (!jwt) { - jwt = req.cookies[this.customCookieAuthName || COOKIE_AUTH_NAME]; + jwt = req.cookies[this.authorizationCookieName || COOKIE_AUTH_NAME]; } if (!jwt) { // Only throw if both are not provided by Cloudflare Access since either // can be used. throw new AuthenticationError( - `Missing ${this.customHeader || CF_JWT_HEADER} and + `Missing ${this.jwtHeaderName || CF_JWT_HEADER} and ${ - this.customCookieAuthName || COOKIE_AUTH_NAME + this.authorizationCookieName || COOKIE_AUTH_NAME } from Cloudflare Access`, ); } @@ -171,10 +171,10 @@ export class AuthHelper { ): Promise { const headers = new Headers(); // set both headers just the way inbound responses are set - headers.set(this.customHeader || CF_JWT_HEADER, jwt); + headers.set(this.jwtHeaderName || CF_JWT_HEADER, jwt); headers.set( 'cookie', - `${this.customCookieAuthName || COOKIE_AUTH_NAME}=${jwt}`, + `${this.authorizationCookieName || COOKIE_AUTH_NAME}=${jwt}`, ); try { const res = await fetch( From 9614e649ed63b9fdcd29c474aa2d09f96520e834 Mon Sep 17 00:00:00 2001 From: "Jason Diaz G." Date: Fri, 5 Jul 2024 08:36:01 -0600 Subject: [PATCH 051/372] fix(cloudflare-auth-access-provider): fix broken unit tests Signed-off-by: Jason Diaz G. --- .../src/helpers.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.test.ts b/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.test.ts index d5a1c8be0f..07e9860d98 100644 --- a/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.test.ts +++ b/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.test.ts @@ -299,7 +299,7 @@ describe('helpers', () => { ); const token = await tokenFactory.userToken(); const request = createRequest({ - cookies: { CF_Custom_Auth: token }, + cookies: { CF_Auth: token }, }); const expected = { From 034c0b3cb29e73b9cf3598a0d65c0d216ab7ed96 Mon Sep 17 00:00:00 2001 From: "Jason Diaz G." Date: Thu, 18 Jul 2024 16:45:13 -0600 Subject: [PATCH 052/372] feat(cloudflare-auth-access-provider): Change defaults and add provider docs Signed-off-by: Jason Diaz G. --- docs/auth/cloudflare/provider.md | 6 ++++ .../src/helpers.ts | 33 ++++++++----------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/docs/auth/cloudflare/provider.md b/docs/auth/cloudflare/provider.md index 516ea9d647..a1946580a7 100644 --- a/docs/auth/cloudflare/provider.md +++ b/docs/auth/cloudflare/provider.md @@ -32,6 +32,12 @@ auth: serviceTokens: - token: '1uh2fh19efvfh129f1f919u21f2f19jf2.access' subject: 'bot-user@your-company.com' + # You can customize the header name that contains the jwt token, by default + # cf-access-jwt-assertion is used + jwtHeaderName: + # You can customize the authorization cookie name, by default + # CF_Authorization is used + authorizationCookieName: # This picks what sign in resolver(s) you want to use. signIn: resolvers: diff --git a/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.ts b/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.ts index b3fefb8789..3077258dd6 100644 --- a/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.ts +++ b/plugins/auth-backend-module-cloudflare-access-provider/src/helpers.ts @@ -40,10 +40,10 @@ export class AuthHelper { options?: { cache?: CacheService }, ): AuthHelper { const teamName = config.getString('teamName'); - const jwtHeaderName = config.getOptionalString('jwtHeaderName'); - const authorizationCookieName = config.getOptionalString( - 'authorizationCookieName', - ); + const jwtHeaderName = + config.getOptionalString('jwtHeaderName') ?? CF_JWT_HEADER; + const authorizationCookieName = + config.getOptionalString('authorizationCookieName') ?? COOKIE_AUTH_NAME; const serviceTokens = ( config.getOptionalConfigArray('serviceTokens') ?? [] )?.map(cfg => { @@ -60,37 +60,35 @@ export class AuthHelper { return new AuthHelper( teamName, serviceTokens, - keySet, - options?.cache, jwtHeaderName, authorizationCookieName, + keySet, + options?.cache, ); } private constructor( private readonly teamName: string, private readonly serviceTokens: ServiceToken[], + private readonly jwtHeaderName: string, + private readonly authorizationCookieName: string, private readonly keySet: ReturnType, private readonly cache?: CacheService, - private readonly jwtHeaderName?: string, - private readonly authorizationCookieName?: string, ) {} async authenticate(req: express.Request): Promise { // JWTs generated by Access are available in a request header as // Cf-Access-Jwt-Assertion and as cookies as CF_Authorization. - let jwt = req.header(this.jwtHeaderName || CF_JWT_HEADER); + let jwt = req.header(this.jwtHeaderName); if (!jwt) { - jwt = req.cookies[this.authorizationCookieName || COOKIE_AUTH_NAME]; + jwt = req.cookies[this.authorizationCookieName]; } if (!jwt) { // Only throw if both are not provided by Cloudflare Access since either // can be used. throw new AuthenticationError( - `Missing ${this.jwtHeaderName || CF_JWT_HEADER} and - ${ - this.authorizationCookieName || COOKIE_AUTH_NAME - } from Cloudflare Access`, + `Missing ${this.jwtHeaderName} and + ${this.authorizationCookieName} from Cloudflare Access`, ); } @@ -171,11 +169,8 @@ export class AuthHelper { ): Promise { const headers = new Headers(); // set both headers just the way inbound responses are set - headers.set(this.jwtHeaderName || CF_JWT_HEADER, jwt); - headers.set( - 'cookie', - `${this.authorizationCookieName || COOKIE_AUTH_NAME}=${jwt}`, - ); + headers.set(this.jwtHeaderName, jwt); + headers.set('cookie', `${this.authorizationCookieName}=${jwt}`); try { const res = await fetch( `https://${this.teamName}.cloudflareaccess.com/cdn-cgi/access/get-identity`, From da971316ae3412c2b0b98f9c0c94fcd8ade65bdb Mon Sep 17 00:00:00 2001 From: parmar-abhinav Date: Sun, 21 Jul 2024 14:01:44 +0530 Subject: [PATCH 053/372] Added test cases for gitlab:issues:create examples Signed-off-by: parmar-abhinav --- .changeset/funny-wolves-learn.md | 5 + .../gitlabIssueCreate.examples.test.ts | 711 ++++++++++++++++++ .../src/actions/gitlabIssueCreate.examples.ts | 168 ++++- 3 files changed, 879 insertions(+), 5 deletions(-) create mode 100644 .changeset/funny-wolves-learn.md create mode 100644 plugins/scaffolder-backend-module-gitlab/src/actions/gitlabIssueCreate.examples.test.ts diff --git a/.changeset/funny-wolves-learn.md b/.changeset/funny-wolves-learn.md new file mode 100644 index 0000000000..2010ccd68b --- /dev/null +++ b/.changeset/funny-wolves-learn.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend-module-gitlab': patch +--- + +Added test cases for gitlab:issues:create examples diff --git a/plugins/scaffolder-backend-module-gitlab/src/actions/gitlabIssueCreate.examples.test.ts b/plugins/scaffolder-backend-module-gitlab/src/actions/gitlabIssueCreate.examples.test.ts new file mode 100644 index 0000000000..917ba61d91 --- /dev/null +++ b/plugins/scaffolder-backend-module-gitlab/src/actions/gitlabIssueCreate.examples.test.ts @@ -0,0 +1,711 @@ +/* + * Copyright 2024 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 { ConfigReader } from '@backstage/core-app-api'; +import { ScmIntegrations } from '@backstage/integration'; +import { createMockActionContext } from '@backstage/plugin-scaffolder-node-test-utils'; +import { createGitlabIssueAction } from './gitlabIssueCreate'; +import { examples } from './gitlabIssueCreate.examples'; +import yaml from 'yaml'; + +const mockGitlabClient = { + Issues: { + create: jest.fn(), + }, +}; +jest.mock('@gitbeaker/rest', () => ({ + Gitlab: class { + constructor() { + return mockGitlabClient; + } + }, +})); + +describe('gitlab:issues:create', () => { + beforeEach(() => { + jest.clearAllMocks(); + jest.useFakeTimers({ + now: new Date(2005, 6, 4, 11, 0, 0), + }); + }); + + afterEach(() => { + jest.useRealTimers(); + }); + + const config = new ConfigReader({ + integrations: { + gitlab: [ + { + host: 'gitlab.com', + token: 'sample-token', + apiBaseUrl: 'https://gitlab.com/api/v1', + }, + ], + }, + }); + const integrations = ScmIntegrations.fromConfig(config); + + const action = createGitlabIssueAction({ integrations }); + + it(`should ${examples[0].description}`, async () => { + let input; + try { + input = yaml.parse(examples[0].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + + const mockContext = createMockActionContext({ + input: { + repoUrl: 'gitlab.com?repo=repo&owner=owner', + projectId: 234, + title: 'Computer banks to rule the world', + }, + workspacePath: 'seen2much', + }); + + mockGitlabClient.Issues.create.mockResolvedValue({ + id: 12, + iid: 4, + web_url: 'https://gitlab.com/hangar18-/issues/42', + }); + + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockGitlabClient.Issues.create).toHaveBeenCalledWith( + 12, + input.title, + { + issueType: undefined, + description: input.description, + assigneeIds: [], + confidential: false, + epicId: undefined, + labels: '', + createdAt: new Date().toISOString(), + dueDate: undefined, + discussionToResolve: '', + mergeRequestToResolveDiscussionsOf: undefined, + milestoneId: undefined, + weight: undefined, + }, + ); + + expect(mockContext.output).toHaveBeenCalledWith('issueId', 12); + expect(mockContext.output).toHaveBeenCalledWith('issueIid', 4); + expect(mockContext.output).toHaveBeenCalledWith( + 'issueUrl', + 'https://gitlab.com/hangar18-/issues/42', + ); + }); + + it(`should ${examples[1].description}`, async () => { + let input; + try { + input = yaml.parse(examples[1].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + + const mockContext = createMockActionContext({ + input: { + repoUrl: 'gitlab.com?repo=repo&owner=owner', + projectId: 234, + title: 'Computer banks to rule the world', + }, + workspacePath: 'seen2much', + }); + + mockGitlabClient.Issues.create.mockResolvedValue({ + id: 12, + iid: 4, + web_url: 'https://gitlab.com/hangar18-/issues/42', + }); + + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockGitlabClient.Issues.create).toHaveBeenCalledWith( + 12, + input.title, + { + issueType: undefined, + description: input.description, + assigneeIds: [18], + confidential: false, + epicId: undefined, + labels: '', + createdAt: input.createdAt, + dueDate: input.dueDate, + discussionToResolve: '', + mergeRequestToResolveDiscussionsOf: undefined, + milestoneId: undefined, + weight: undefined, + }, + ); + + expect(mockContext.output).toHaveBeenCalledWith('issueId', 12); + expect(mockContext.output).toHaveBeenCalledWith('issueIid', 4); + expect(mockContext.output).toHaveBeenCalledWith( + 'issueUrl', + 'https://gitlab.com/hangar18-/issues/42', + ); + }); + + it(`should ${examples[2].description}`, async () => { + let input; + try { + input = yaml.parse(examples[2].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + + const mockContext = createMockActionContext({ + input: { + repoUrl: 'gitlab.com?repo=repo&owner=owner', + projectId: 234, + title: 'Computer banks to rule the world', + }, + workspacePath: 'seen2much', + }); + + mockGitlabClient.Issues.create.mockResolvedValue({ + id: 12, + iid: 4, + web_url: 'https://gitlab.com/hangar18-/issues/42', + }); + + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + epicId: undefined, + }, + }); + + expect(mockGitlabClient.Issues.create).toHaveBeenCalledWith( + 12, + input.title, + { + issueType: undefined, + description: input.description, + assigneeIds: [18, 15], + confidential: input.confidential, + epicId: undefined, + labels: input.labels, + createdAt: input.createdAt, + dueDate: input.dueDate, + discussionToResolve: input.discussionToResolve, + mergeRequestToResolveDiscussionsOf: undefined, + milestoneId: undefined, + weight: undefined, + }, + ); + + expect(mockContext.output).toHaveBeenCalledWith('issueId', 12); + expect(mockContext.output).toHaveBeenCalledWith('issueIid', 4); + expect(mockContext.output).toHaveBeenCalledWith( + 'issueUrl', + 'https://gitlab.com/hangar18-/issues/42', + ); + }); + + it(`should ${examples[3].description}`, async () => { + let input; + try { + input = yaml.parse(examples[3].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + + const mockContext = createMockActionContext({ + input: { + repoUrl: 'gitlab.com?repo=repo&owner=owner', + projectId: 234, + title: 'Computer banks to rule the world', + token: 'myAwesomeToken', + }, + workspacePath: 'seen2much', + }); + + mockGitlabClient.Issues.create.mockResolvedValue({ + id: 12, + iid: 4, + web_url: 'https://gitlab.com/hangar18-/issues/42', + }); + + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockGitlabClient.Issues.create).toHaveBeenCalledWith( + 12, + input.title, + { + issueType: undefined, + description: input.description, + assigneeIds: [], + confidential: false, + epicId: undefined, + labels: '', + createdAt: new Date().toISOString(), + dueDate: undefined, + discussionToResolve: '', + mergeRequestToResolveDiscussionsOf: undefined, + milestoneId: undefined, + weight: undefined, + }, + ); + + expect(mockContext.output).toHaveBeenCalledWith('issueId', 12); + expect(mockContext.output).toHaveBeenCalledWith('issueIid', 4); + expect(mockContext.output).toHaveBeenCalledWith( + 'issueUrl', + 'https://gitlab.com/hangar18-/issues/42', + ); + }); + + it(`should ${examples[4].description}`, async () => { + let input; + try { + input = yaml.parse(examples[4].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + + const mockContext = createMockActionContext({ + input: { + repoUrl: 'gitlab.com?repo=repo&owner=owner', + projectId: 234, + title: 'Computer banks to rule the world', + token: 'myAwesomeToken', + }, + workspacePath: 'seen2much', + }); + + mockGitlabClient.Issues.create.mockResolvedValue({ + id: 12, + iid: 4, + web_url: 'https://gitlab.com/hangar18-/issues/42', + }); + + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockGitlabClient.Issues.create).toHaveBeenCalledWith( + 12, + input.title, + { + issueType: undefined, + description: input.description, + assigneeIds: [], + confidential: false, + epicId: undefined, + labels: '', + createdAt: new Date().toISOString(), + dueDate: undefined, + discussionToResolve: '', + mergeRequestToResolveDiscussionsOf: undefined, + milestoneId: input.milestoneId, + weight: input.weight, + }, + ); + + expect(mockContext.output).toHaveBeenCalledWith('issueId', 12); + expect(mockContext.output).toHaveBeenCalledWith('issueIid', 4); + expect(mockContext.output).toHaveBeenCalledWith( + 'issueUrl', + 'https://gitlab.com/hangar18-/issues/42', + ); + }); + + it(`should ${examples[5].description}`, async () => { + let input; + try { + input = yaml.parse(examples[5].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + + const mockContext = createMockActionContext({ + input: { + repoUrl: 'gitlab.com?repo=repo&owner=owner', + projectId: 234, + title: 'Computer banks to rule the world', + token: 'myAwesomeToken', + }, + workspacePath: 'seen2much', + }); + + mockGitlabClient.Issues.create.mockResolvedValue({ + id: 12, + iid: 4, + web_url: 'https://gitlab.com/hangar18-/issues/42', + }); + + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockGitlabClient.Issues.create).toHaveBeenCalledWith( + 12, + input.title, + { + issueType: input.issueType, + description: input.description, + assigneeIds: [], + confidential: false, + epicId: undefined, + labels: '', + createdAt: new Date().toISOString(), + dueDate: undefined, + discussionToResolve: '', + mergeRequestToResolveDiscussionsOf: undefined, + milestoneId: input.milestoneId, + weight: input.weight, + }, + ); + + expect(mockContext.output).toHaveBeenCalledWith('issueId', 12); + expect(mockContext.output).toHaveBeenCalledWith('issueIid', 4); + expect(mockContext.output).toHaveBeenCalledWith( + 'issueUrl', + 'https://gitlab.com/hangar18-/issues/42', + ); + }); + + it(`should ${examples[6].description}`, async () => { + let input; + try { + input = yaml.parse(examples[6].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + + const mockContext = createMockActionContext({ + input: { + repoUrl: 'gitlab.com?repo=repo&owner=owner', + projectId: 234, + title: 'Computer banks to rule the world', + token: 'myAwesomeToken', + }, + workspacePath: 'seen2much', + }); + + mockGitlabClient.Issues.create.mockResolvedValue({ + id: 12, + iid: 4, + web_url: 'https://gitlab.com/hangar18-/issues/42', + }); + + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockGitlabClient.Issues.create).toHaveBeenCalledWith( + 12, + input.title, + { + issueType: input.issueType, + description: input.description, + assigneeIds: [], + confidential: false, + epicId: undefined, + labels: '', + createdAt: new Date().toISOString(), + dueDate: undefined, + discussionToResolve: '', + mergeRequestToResolveDiscussionsOf: undefined, + milestoneId: input.milestoneId, + weight: input.weight, + }, + ); + + expect(mockContext.output).toHaveBeenCalledWith('issueId', 12); + expect(mockContext.output).toHaveBeenCalledWith('issueIid', 4); + expect(mockContext.output).toHaveBeenCalledWith( + 'issueUrl', + 'https://gitlab.com/hangar18-/issues/42', + ); + }); + + it(`should ${examples[7].description}`, async () => { + let input; + try { + input = yaml.parse(examples[7].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + + const mockContext = createMockActionContext({ + input: { + repoUrl: 'gitlab.com?repo=repo&owner=owner', + projectId: 234, + title: 'Computer banks to rule the world', + token: 'myAwesomeToken', + }, + workspacePath: 'seen2much', + }); + + mockGitlabClient.Issues.create.mockResolvedValue({ + id: 12, + iid: 4, + web_url: 'https://gitlab.com/hangar18-/issues/42', + }); + + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockGitlabClient.Issues.create).toHaveBeenCalledWith( + 12, + input.title, + { + issueType: input.issueType, + description: input.description, + assigneeIds: [18, 22], + confidential: false, + epicId: undefined, + labels: '', + createdAt: new Date().toISOString(), + dueDate: undefined, + discussionToResolve: '', + mergeRequestToResolveDiscussionsOf: undefined, + milestoneId: input.milestoneId, + weight: input.weight, + }, + ); + + expect(mockContext.output).toHaveBeenCalledWith('issueId', 12); + expect(mockContext.output).toHaveBeenCalledWith('issueIid', 4); + expect(mockContext.output).toHaveBeenCalledWith( + 'issueUrl', + 'https://gitlab.com/hangar18-/issues/42', + ); + }); + + it(`should ${examples[8].description}`, async () => { + let input; + try { + input = yaml.parse(examples[8].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + + const mockContext = createMockActionContext({ + input: { + repoUrl: 'gitlab.com?repo=repo&owner=owner', + projectId: 234, + title: 'Computer banks to rule the world', + token: 'myAwesomeToken', + }, + workspacePath: 'seen2much', + }); + + mockGitlabClient.Issues.create.mockResolvedValue({ + id: 12, + iid: 4, + web_url: 'https://gitlab.com/hangar18-/issues/42', + }); + + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockGitlabClient.Issues.create).toHaveBeenCalledWith( + 12, + input.title, + { + issueType: input.issueType, + description: input.description, + assigneeIds: [], + confidential: false, + epicId: undefined, + labels: '', + createdAt: new Date().toISOString(), + dueDate: undefined, + discussionToResolve: '', + mergeRequestToResolveDiscussionsOf: undefined, + milestoneId: input.milestoneId, + weight: input.weight, + }, + ); + + expect(mockContext.output).toHaveBeenCalledWith('issueId', 12); + expect(mockContext.output).toHaveBeenCalledWith('issueIid', 4); + expect(mockContext.output).toHaveBeenCalledWith( + 'issueUrl', + 'https://gitlab.com/hangar18-/issues/42', + ); + }); + + it(`should ${examples[9].description}`, async () => { + let input; + try { + input = yaml.parse(examples[9].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + + const mockContext = createMockActionContext({ + input: { + repoUrl: 'gitlab.com?repo=repo&owner=owner', + projectId: 234, + title: 'Computer banks to rule the world', + token: 'myAwesomeToken', + }, + workspacePath: 'seen2much', + }); + + mockGitlabClient.Issues.create.mockResolvedValue({ + id: 12, + iid: 4, + web_url: 'https://gitlab.com/hangar18-/issues/42', + }); + + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockGitlabClient.Issues.create).toHaveBeenCalledWith( + 12, + input.title, + { + issueType: input.issueType, + description: input.description, + assigneeIds: [], + confidential: false, + epicId: undefined, + labels: '', + createdAt: new Date().toISOString(), + dueDate: undefined, + discussionToResolve: '', + mergeRequestToResolveDiscussionsOf: undefined, + milestoneId: input.milestoneId, + weight: input.weight, + }, + ); + + expect(mockContext.output).toHaveBeenCalledWith('issueId', 12); + expect(mockContext.output).toHaveBeenCalledWith('issueIid', 4); + expect(mockContext.output).toHaveBeenCalledWith( + 'issueUrl', + 'https://gitlab.com/hangar18-/issues/42', + ); + }); + + it(`should ${examples[10].description}`, async () => { + let input; + try { + input = yaml.parse(examples[10].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + + const mockContext = createMockActionContext({ + input: { + repoUrl: 'gitlab.com?repo=repo&owner=owner', + projectId: 234, + title: 'Computer banks to rule the world', + token: 'myAwesomeToken', + }, + workspacePath: 'seen2much', + }); + + mockGitlabClient.Issues.create.mockResolvedValue({ + id: 12, + iid: 4, + web_url: 'https://gitlab.com/hangar18-/issues/42', + }); + + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockGitlabClient.Issues.create).toHaveBeenCalledWith( + 12, + input.title, + { + issueType: input.issueType, + description: input.description, + assigneeIds: [], + confidential: false, + epicId: undefined, + labels: '', + createdAt: new Date().toISOString(), + dueDate: undefined, + discussionToResolve: 'abc123', + mergeRequestToResolveDiscussionsOf: + input.mergeRequestToResolveDiscussionsOf, + milestoneId: input.milestoneId, + weight: input.weight, + }, + ); + + expect(mockContext.output).toHaveBeenCalledWith('issueId', 12); + expect(mockContext.output).toHaveBeenCalledWith('issueIid', 4); + expect(mockContext.output).toHaveBeenCalledWith( + 'issueUrl', + 'https://gitlab.com/hangar18-/issues/42', + ); + }); +}); diff --git a/plugins/scaffolder-backend-module-gitlab/src/actions/gitlabIssueCreate.examples.ts b/plugins/scaffolder-backend-module-gitlab/src/actions/gitlabIssueCreate.examples.ts index 760caf0f9f..04fdeba46d 100644 --- a/plugins/scaffolder-backend-module-gitlab/src/actions/gitlabIssueCreate.examples.ts +++ b/plugins/scaffolder-backend-module-gitlab/src/actions/gitlabIssueCreate.examples.ts @@ -50,8 +50,8 @@ export const examples: TemplateExample[] = [ title: 'Test Issue', assignees: [18], description: 'This is the description of the issue', - createdAt: '2022-09-27 18:00:00.000', - dueDate: '2022-09-28 12:00:00.000', + createdAt: '2022-09-27T18:00:00.000Z', + dueDate: '2022-09-28T12:00:00.000Z', }, }, ], @@ -72,9 +72,9 @@ export const examples: TemplateExample[] = [ assignees: [18, 15], description: 'This is the description of the issue', confidential: false, - createdAt: '2022-09-27 18:00:00.000', - dueDate: '2022-09-28 12:00:00.000', - discussionToResolve: 1, + createdAt: '2022-09-27T18:00:00.000Z', + dueDate: '2022-09-28T12:00:00.000Z', + discussionToResolve: '1', epicId: 1, labels: 'phase1:label1,phase2:label2', }, @@ -82,4 +82,162 @@ export const examples: TemplateExample[] = [ ], }), }, + { + description: 'Create a GitLab issue with token', + example: yaml.stringify({ + steps: [ + { + id: 'gitlabIssue', + name: 'Issues', + action: 'gitlab:issues:create', + input: { + ...commonGitlabConfigExample, + projectId: 12, + title: 'Test Issue', + description: 'This is the description of the issue', + token: 'sample token', + }, + }, + ], + }), + }, + { + description: 'Create a GitLab issue with a specific milestone and weight', + example: yaml.stringify({ + steps: [ + { + id: 'gitlabIssue', + name: 'Issues', + action: 'gitlab:issues:create', + input: { + ...commonGitlabConfigExample, + projectId: 12, + title: 'Test Issue with Milestone', + description: 'This is the description of the issue', + milestoneId: 5, + weight: 3, + }, + }, + ], + }), + }, + { + description: 'Create a GitLab issue of type INCIDENT', + example: yaml.stringify({ + steps: [ + { + id: 'gitlabIssue', + name: 'Issues', + action: 'gitlab:issues:create', + input: { + ...commonGitlabConfigExample, + projectId: 12, + title: 'Confidential Test Issue', + description: 'This is the description of the issue', + issueType: 'incident', + }, + }, + ], + }), + }, + { + description: 'Create a GitLab issue of type TEST', + example: yaml.stringify({ + steps: [ + { + id: 'gitlabIssue', + name: 'Issues', + action: 'gitlab:issues:create', + input: { + ...commonGitlabConfigExample, + projectId: 12, + title: 'Confidential Test Issue', + description: 'This is the description of the issue', + issueType: 'test_case', + }, + }, + ], + }), + }, + { + description: 'Create a GitLab issue of type TASK with assignees', + example: yaml.stringify({ + steps: [ + { + id: 'gitlabIssue', + name: 'Issues', + action: 'gitlab:issues:create', + input: { + ...commonGitlabConfigExample, + projectId: 12, + title: 'Confidential Test Issue', + description: 'This is the description of the issue', + issueType: 'task', + assignees: [18, 22], + }, + }, + ], + }), + }, + { + description: 'Create a GitLab issue of type ISSUE and close it', + example: yaml.stringify({ + steps: [ + { + id: 'gitlabIssue', + name: 'Issues', + action: 'gitlab:issues:create', + input: { + ...commonGitlabConfigExample, + projectId: 12, + title: 'Confidential Test Issue', + description: 'This is the description of the issue', + issueType: 'issue', + stateEvent: 'close', + }, + }, + ], + }), + }, + { + description: 'Create a GitLab issue of type INCIDENT and reopen it', + example: yaml.stringify({ + steps: [ + { + id: 'gitlabIssue', + name: 'Issues', + action: 'gitlab:issues:create', + input: { + ...commonGitlabConfigExample, + projectId: 12, + title: 'Confidential Test Issue', + description: 'This is the description of the issue', + issueType: 'incident', + stateEvent: 'reopen', + }, + }, + ], + }), + }, + { + description: + 'Create a GitLab issue to resolve a discussion in a merge request', + example: yaml.stringify({ + steps: [ + { + id: 'gitlabIssue', + name: 'Issues', + action: 'gitlab:issues:create', + input: { + ...commonGitlabConfigExample, + projectId: 12, + title: 'Test Issue for MR Discussion', + description: 'This is the description of the issue', + mergeRequestToResolveDiscussionsOf: 42, + discussionToResolve: 'abc123', + }, + }, + ], + }), + }, ]; From 382e868473ec01a6a493fe33b633b799f4a057dd Mon Sep 17 00:00:00 2001 From: parmar-abhinav Date: Mon, 22 Jul 2024 10:17:35 +0530 Subject: [PATCH 054/372] Added test cases for sentry:project:create examples Signed-off-by: parmar-abhinav --- .changeset/warm-monkeys-marry.md | 5 + .../actions/createProject.examples.test.ts | 232 ++++++++++++++++++ .../src/actions/createProject.examples.ts | 37 +++ 3 files changed, 274 insertions(+) create mode 100644 .changeset/warm-monkeys-marry.md create mode 100644 plugins/scaffolder-backend-module-sentry/src/actions/createProject.examples.test.ts diff --git a/.changeset/warm-monkeys-marry.md b/.changeset/warm-monkeys-marry.md new file mode 100644 index 0000000000..5ea8deae01 --- /dev/null +++ b/.changeset/warm-monkeys-marry.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend-module-sentry': patch +--- + +Added test cases for sentry:project:create examples diff --git a/plugins/scaffolder-backend-module-sentry/src/actions/createProject.examples.test.ts b/plugins/scaffolder-backend-module-sentry/src/actions/createProject.examples.test.ts new file mode 100644 index 0000000000..3e31aef3bc --- /dev/null +++ b/plugins/scaffolder-backend-module-sentry/src/actions/createProject.examples.test.ts @@ -0,0 +1,232 @@ +/* + * Copyright 2024 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 { registerMswTestHooks } from '@backstage/backend-test-utils'; +import { createMockActionContext } from '@backstage/plugin-scaffolder-node-test-utils'; +import { ConfigReader } from '@backstage/config'; +import { ActionContext } from '@backstage/plugin-scaffolder-node'; +import { JsonObject } from '@backstage/types'; +import { randomBytes } from 'crypto'; +import { setupServer } from 'msw/node'; +import { HttpResponse, http } from 'msw'; +import { createSentryCreateProjectAction } from './createProject'; +import yaml from 'yaml'; +import { examples } from './createProject.examples'; + +describe('sentry:project:create action', () => { + const worker = setupServer(); + registerMswTestHooks(worker); + + const createScaffolderConfig = (configData: JsonObject = {}) => ({ + config: new ConfigReader({ + scaffolder: { + ...configData, + }, + }), + }); + + const getActionContext = (): ActionContext<{ + organizationSlug: string; + teamSlug: string; + name: string; + slug?: string; + authToken?: string; + }> => + createMockActionContext({ + workspacePath: './dev/proj', + logger: jest.createMockFromModule('winston'), + input: { + organizationSlug: 'org', + teamSlug: 'team', + name: 'test project', + authToken: randomBytes(5).toString('hex'), + }, + }); + + it(`should ${examples[0].description}`, async () => { + expect.assertions(3); + + let input; + try { + input = yaml.parse(examples[0].example).steps[1].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + + const action = createSentryCreateProjectAction(createScaffolderConfig()); + const actionContext = getActionContext(); + + worker.use( + http.post( + `https://sentry.io/api/0/teams/${input.organizationSlug}/${input.teamSlug}/projects/`, + async ({ request }) => { + expect(request.headers.get('Authorization')).toBe( + `Bearer b15711beb516e1e910d2ede554dc1bf725654ef3c75e5a9106de9aec13d4gf93`, + ); + expect(request.headers.get('Content-Type')).toBe(`application/json`); + await expect(request.json()).resolves.toEqual({ + name: 'Scaffolded project B', + }); + return HttpResponse.json( + { detail: 'project creation mocked result' }, + { status: 201 }, + ); + }, + ), + ); + + await action.handler({ + ...actionContext, + input: { + ...actionContext.input, + ...input, + }, + }); + }); + + it(`should ${examples[0].description}`, async () => { + expect.assertions(3); + + let input; + try { + input = yaml.parse(examples[0].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + + const action = createSentryCreateProjectAction(createScaffolderConfig()); + const actionContext = getActionContext(); + actionContext.input = { ...actionContext.input, slug: 'project-slug' }; + + worker.use( + http.post( + `https://sentry.io/api/0/teams/${input.organizationSlug}/${input.teamSlug}/projects/`, + async ({ request }) => { + expect(request.headers.get('Authorization')).toBe( + `Bearer a14711beb516e1e910d2ede554dc1bf725654ef3c75e5a9106de9aec13d5df96`, + ); + expect(request.headers.get('Content-Type')).toBe(`application/json`); + await expect(request.json()).resolves.toEqual({ + name: 'Scaffolded project A', + slug: 'scaff-proj-a', + }); + return HttpResponse.json( + { detail: 'project creation mocked result' }, + { status: 201 }, + ); + }, + ), + ); + + await action.handler({ + ...actionContext, + input: { + ...actionContext.input, + ...input, + }, + }); + }); + + it(`should ${examples[1].description}`, async () => { + expect.assertions(3); + + let input; + try { + input = yaml.parse(examples[1].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + + const sentryScaffolderConfigToken = randomBytes(5).toString('hex'); + const action = createSentryCreateProjectAction( + createScaffolderConfig({ + sentry: { + token: sentryScaffolderConfigToken, + }, + }), + ); + const actionContext = getActionContext(); + actionContext.input.authToken = undefined; + + worker.use( + http.post( + `https://sentry.io/api/0/teams/${input.organizationSlug}/${input.teamSlug}/projects/`, + async ({ request }) => { + expect(request.headers.get('Authorization')).toBe( + `Bearer ${sentryScaffolderConfigToken}`, + ); + expect(request.headers.get('Content-Type')).toBe(`application/json`); + await expect(request.json()).resolves.toEqual({ + name: 'Scaffolded project A', + }); + return HttpResponse.json( + { detail: 'project creation mocked result' }, + { status: 201 }, + ); + }, + ), + ); + + await action.handler({ + ...actionContext, + input: { + ...actionContext.input, + ...input, + }, + }); + }); + + it(`should ${examples[2].description}`, async () => { + expect.assertions(3); + + let input; + try { + input = yaml.parse(examples[2].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + + const action = createSentryCreateProjectAction(createScaffolderConfig()); + const actionContext = getActionContext(); + + worker.use( + http.post( + `https://sentry.io/api/0/teams/${input.organizationSlug}/${input.teamSlug}/projects/`, + async ({ request }) => { + expect(request.headers.get('Authorization')).toBe( + `Bearer c16711beb516e1e910d2ede554dc1bf725654ef3c75e5a9106de9aec13d6gf94`, + ); + expect(request.headers.get('Content-Type')).toBe(`application/json`); + await expect(request.json()).resolves.toEqual({ + name: 'A very long name for the scaffolded project C that will generate a slug', + }); + return HttpResponse.json( + { detail: 'project creation mocked result' }, + { status: 201 }, + ); + }, + ), + ); + + await action.handler({ + ...actionContext, + input: { + ...actionContext.input, + ...input, + }, + }); + }); +}); diff --git a/plugins/scaffolder-backend-module-sentry/src/actions/createProject.examples.ts b/plugins/scaffolder-backend-module-sentry/src/actions/createProject.examples.ts index 9d4551c1b5..3af88a4663 100644 --- a/plugins/scaffolder-backend-module-sentry/src/actions/createProject.examples.ts +++ b/plugins/scaffolder-backend-module-sentry/src/actions/createProject.examples.ts @@ -50,4 +50,41 @@ export const examples: TemplateExample[] = [ ], }), }, + { + description: 'Creates a Sentry project when no auth token is passed', + example: yaml.stringify({ + steps: [ + { + id: 'create-sentry-project', + action: 'sentry:project:create', + name: 'Create a Sentry project with provided project slug.', + input: { + organizationSlug: 'my-org', + teamSlug: 'team-a', + name: 'Scaffolded project A', + }, + }, + ], + }), + }, + { + description: + 'Creates a Sentry project with a long project name and automatically generated slug.', + example: yaml.stringify({ + steps: [ + { + id: 'create-sentry-project', + action: 'sentry:project:create', + name: 'Create a Sentry project with a long name and no slug provided.', + input: { + organizationSlug: 'my-org', + teamSlug: 'team-c', + name: 'A very long name for the scaffolded project C that will generate a slug', + authToken: + 'c16711beb516e1e910d2ede554dc1bf725654ef3c75e5a9106de9aec13d6gf94', + }, + }, + ], + }), + }, ]; From ff69e3c901d82fc8367df7bfaed1a83e0b12a202 Mon Sep 17 00:00:00 2001 From: AmbrishRamachandiran Date: Mon, 22 Jul 2024 12:16:32 +0530 Subject: [PATCH 055/372] Updated writing a policy docs Signed-off-by: AmbrishRamachandiran --- docs/permissions/writing-a-policy.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/permissions/writing-a-policy.md b/docs/permissions/writing-a-policy.md index 0f2d4fe091..0762f6b0c6 100644 --- a/docs/permissions/writing-a-policy.md +++ b/docs/permissions/writing-a-policy.md @@ -141,4 +141,8 @@ class TestPermissionPolicy implements PermissionPolicy { In this example, we use [`isResourcePermission`](https://backstage.io/docs/reference/plugin-permission-common.isresourcepermission) to match all permissions with a resource type of `catalog-entity`. Just like `isPermission`, this helper will "narrow" the type of `request.permission` and enable the use of `createCatalogConditionalDecision`. In addition to the behavior you observed before, you should also see that catalog entities are no longer visible unless you are the owner - success! -_Note:_ Some catalog permissions do not have the `'catalog-entity'` resource type, such as [`catalogEntityCreatePermission`](https://github.com/backstage/backstage/blob/1e5e9fb9de9856a49e60fc70c38a4e4e94c69570/plugins/catalog-common/src/permissions.ts#L49). In those cases, a definitive decision is required because conditions can't be applied to an entity that does not exist yet. +:::note Note + +Some catalog permissions do not have the `'catalog-entity'` resource type, such as [`catalogEntityCreatePermission`](https://github.com/backstage/backstage/blob/1e5e9fb9de9856a49e60fc70c38a4e4e94c69570/plugins/catalog-common/src/permissions.ts#L49). In those cases, a definitive decision is required because conditions can't be applied to an entity that does not exist yet. + +::: From 187f583ba2961dfbce660f224073d049a4bb726e Mon Sep 17 00:00:00 2001 From: parmar-abhinav Date: Mon, 22 Jul 2024 16:58:50 +0530 Subject: [PATCH 056/372] Added examples for publish:azure action and updated its test cases Signed-off-by: parmar-abhinav --- .changeset/flat-papayas-push.md | 5 + .../src/actions/azure.examples.test.ts | 177 +++++++++++++++++- .../src/actions/azure.examples.ts | 90 +++++++++ 3 files changed, 271 insertions(+), 1 deletion(-) create mode 100644 .changeset/flat-papayas-push.md diff --git a/.changeset/flat-papayas-push.md b/.changeset/flat-papayas-push.md new file mode 100644 index 0000000000..191dad8550 --- /dev/null +++ b/.changeset/flat-papayas-push.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend-module-azure': minor +--- + +Added examples for publish:azure action and updated its test cases diff --git a/plugins/scaffolder-backend-module-azure/src/actions/azure.examples.test.ts b/plugins/scaffolder-backend-module-azure/src/actions/azure.examples.test.ts index 35868274fd..dda65a76ea 100644 --- a/plugins/scaffolder-backend-module-azure/src/actions/azure.examples.test.ts +++ b/plugins/scaffolder-backend-module-azure/src/actions/azure.examples.test.ts @@ -19,7 +19,10 @@ import { ConfigReader } from '@backstage/config'; import { createPublishAzureAction } from './azure'; import { ScmIntegrations } from '@backstage/integration'; import { WebApi } from 'azure-devops-node-api'; -import { initRepoAndPush } from '@backstage/plugin-scaffolder-node'; +import { + getRepoSourceDirectory, + initRepoAndPush, +} from '@backstage/plugin-scaffolder-node'; import { examples } from './azure.examples'; import { createMockActionContext } from '@backstage/plugin-scaffolder-node-test-utils'; @@ -48,6 +51,10 @@ describe('publish:azure examples', () => { host: 'dev.azure.com', credentials: [{ personalAccessToken: 'tokenlols' }], }, + { + host: 'test.azure.com', + credentials: [{ personalAccessToken: 'tokenlols' }], + }, ], }, }); @@ -114,4 +121,172 @@ describe('publish:azure examples', () => { gitAuthorInfo: {}, }); }); + + it(`should ${examples[3].description}`, async () => { + mockGitClient.createRepository.mockResolvedValue({ + remoteUrl: 'https://dev.azure.com/organization/project/_git/repo', + webUrl: 'https://dev.azure.com/organization/project/_git/repo', + id: '709e891c-dee7-4f91-b963-534713c0737f', + }); + + let input; + try { + input = yaml.parse(examples[3].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(initRepoAndPush).toHaveBeenCalledWith({ + dir: mockContext.workspacePath, + remoteUrl: 'https://dev.azure.com/organization/project/_git/repo', + defaultBranch: 'master', + auth: { username: 'notempty', password: 'tokenlols' }, + logger: mockContext.logger, + commitMessage: input.gitCommitMessage, + gitAuthorInfo: {}, + }); + }); + + it(`should ${examples[4].description}`, async () => { + mockGitClient.createRepository.mockResolvedValue({ + remoteUrl: 'https://dev.azure.com/organization/project/_git/repo', + webUrl: 'https://dev.azure.com/organization/project/_git/repo', + id: '709e891c-dee7-4f91-b963-534713c0737f', + }); + + let input; + try { + input = yaml.parse(examples[4].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(initRepoAndPush).toHaveBeenCalledWith({ + dir: mockContext.workspacePath, + remoteUrl: 'https://dev.azure.com/organization/project/_git/repo', + defaultBranch: 'master', + auth: { username: 'notempty', password: 'tokenlols' }, + logger: mockContext.logger, + commitMessage: 'initial commit', + gitAuthorInfo: { + name: input.gitAuthorName, + email: input.gitAuthorEmail, + }, + }); + }); + + it(`should ${examples[5].description}`, async () => { + mockGitClient.createRepository.mockResolvedValue({ + remoteUrl: 'https://dev.azure.com/organization/project/_git/repo', + webUrl: 'https://dev.azure.com/organization/project/_git/repo', + id: '709e891c-dee7-4f91-b963-534713c0737f', + }); + + let input; + try { + input = yaml.parse(examples[5].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(initRepoAndPush).toHaveBeenCalledWith({ + dir: getRepoSourceDirectory(mockContext.workspacePath, input.sourcePath), + remoteUrl: 'https://dev.azure.com/organization/project/_git/repo', + defaultBranch: 'master', + auth: { username: 'notempty', password: 'tokenlols' }, + logger: mockContext.logger, + commitMessage: 'initial commit', + gitAuthorInfo: {}, + }); + }); + + it(`should ${examples[6].description}`, async () => { + mockGitClient.createRepository.mockResolvedValue({ + remoteUrl: 'https://dev.azure.com/organization/project/_git/repo', + webUrl: 'https://dev.azure.com/organization/project/_git/repo', + id: '709e891c-dee7-4f91-b963-534713c0737f', + }); + + let input; + try { + input = yaml.parse(examples[6].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(initRepoAndPush).toHaveBeenCalledWith({ + dir: mockContext.workspacePath, + remoteUrl: 'https://dev.azure.com/organization/project/_git/repo', + defaultBranch: 'master', + auth: { username: 'notempty', password: input.token }, + logger: mockContext.logger, + commitMessage: 'initial commit', + gitAuthorInfo: {}, + }); + }); + + it(`should ${examples[7].description}`, async () => { + mockGitClient.createRepository.mockResolvedValue({ + remoteUrl: 'https://test.azure.com/organization/project/_git/repo', + webUrl: 'https://test.azure.com/organization/project/_git/repo', + id: '709e891c-dee7-4f91-b963-534713c0737f', + }); + + let input; + try { + input = yaml.parse(examples[7].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(initRepoAndPush).toHaveBeenCalledWith({ + dir: mockContext.workspacePath, + remoteUrl: 'https://test.azure.com/organization/project/_git/repo', + defaultBranch: 'master', + auth: { username: 'notempty', password: 'tokenlols' }, + logger: mockContext.logger, + commitMessage: 'initial commit', + gitAuthorInfo: {}, + }); + }); }); diff --git a/plugins/scaffolder-backend-module-azure/src/actions/azure.examples.ts b/plugins/scaffolder-backend-module-azure/src/actions/azure.examples.ts index 22c2299b30..ae5bfece2b 100644 --- a/plugins/scaffolder-backend-module-azure/src/actions/azure.examples.ts +++ b/plugins/scaffolder-backend-module-azure/src/actions/azure.examples.ts @@ -70,4 +70,94 @@ export const examples: TemplateExample[] = [ ], }), }, + { + description: + 'Initializes an Azure DevOps repository with a custom commit message', + example: yaml.stringify({ + steps: [ + { + id: 'publish', + action: 'publish:azure', + name: 'Publish to Azure', + input: { + repoUrl: + 'dev.azure.com?organization=organization&project=project&repo=repo', + gitCommitMessage: 'Initial setup and configuration', + }, + }, + ], + }), + }, + { + description: + 'Initializes an Azure DevOps repository with a custom author name and email', + example: yaml.stringify({ + steps: [ + { + id: 'publish', + action: 'publish:azure', + name: 'Publish to Azure', + input: { + repoUrl: + 'dev.azure.com?organization=organization&project=project&repo=repo', + gitAuthorName: 'John Doe', + gitAuthorEmail: 'john.doe@example.com', + }, + }, + ], + }), + }, + { + description: + 'Initializes an Azure DevOps repository using a specific source path', + example: yaml.stringify({ + steps: [ + { + id: 'publish', + action: 'publish:azure', + name: 'Publish to Azure', + input: { + repoUrl: + 'dev.azure.com?organization=organization&project=project&repo=repo', + sourcePath: 'path/to/source', + }, + }, + ], + }), + }, + { + description: + 'Initializes an Azure DevOps repository using an authentication token', + example: yaml.stringify({ + steps: [ + { + id: 'publish', + action: 'publish:azure', + name: 'Publish to Azure', + input: { + repoUrl: + 'dev.azure.com?organization=organization&project=project&repo=repo', + token: 'personal-access-token', + }, + }, + ], + }), + }, + { + description: + 'Initializes an Azure DevOps repository using an custom repo url', + example: yaml.stringify({ + steps: [ + { + id: 'publish', + action: 'publish:azure', + name: 'Publish to Azure', + input: { + repoUrl: + 'test.azure.com?organization=organization&project=project&repo=repo', + }, + }, + ], + }), + }, ]; From 612d552e1c5543657621e913466708e68c86d0c3 Mon Sep 17 00:00:00 2001 From: Tavi Nolan Date: Tue, 23 Jul 2024 11:45:56 +0100 Subject: [PATCH 057/372] Updating changes based on review comments Signed-off-by: Tavi Nolan --- .../software-templates}/dry-run-testing.md | 12 +++++------- microsite/sidebars.json | 3 ++- mkdocs.yml | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) rename docs/{plugins => features/software-templates}/dry-run-testing.md (87%) diff --git a/docs/plugins/dry-run-testing.md b/docs/features/software-templates/dry-run-testing.md similarity index 87% rename from docs/plugins/dry-run-testing.md rename to docs/features/software-templates/dry-run-testing.md index 18b7343920..fb2de0f672 100644 --- a/docs/plugins/dry-run-testing.md +++ b/docs/features/software-templates/dry-run-testing.md @@ -1,14 +1,14 @@ --- id: dry run testing title: Dry Run Testing -description: Documentation on how to enable and implement dry run testing in actions +description: How to enable and implement dry run testing in actions --- Scaffolder templates can be tested using the dry run feature of scaffolder actions. This allows you to simulate the effects of running a scaffolder action without making any actual changes to your environment, for example creating a webhook in Github. Once dry run is enabled in the scaffolder action, you can add handling to actions you use in your scaffolder templates to define how an action should operate in a dry run scenario. ## Enabling dry run testing -To enable dry run for your scaffolder action you need to add 'supportsDryRun: true' to the configuration object of 'createTemplateAction' in the function where the behavior of your action is defined: +To enable dry run for your scaffolder action you need to add `supportsDryRun: true` to the configuration object of `createTemplateAction` in the function where the behavior of your action is defined: ```typescript export function exampleAction() { @@ -38,7 +38,7 @@ export function exampleAction() { ## Adding handling for dry run -To add handling for dry run functionality you need to add a check for 'ctx.isDryRun' inside the handler of the configuration object which is being passed into 'createTemplateAction' in the function where the behavior of your action is defined. Once the check is successful, you can perform the desired actions expected in a dry run, e.g. outputting non-sensitive inputs. +To add handling for dry run functionality you need to add a check for `ctx.isDryRun` inside the handler of the configuration object which is being passed into `createTemplateAction` in the function where the behavior of your action is defined. Once the check is successful, you can perform the desired actions expected in a dry run, e.g. outputting non-sensitive inputs. ```typescript async handler(ctx) { @@ -91,9 +91,7 @@ If you're using backend permissions, pass a front-end auth token from a current You can also query the dry run endpoint directly in code, for example: -`dry-run.js` - -```javascript +```javascript title="dry-run.js" const template = yaml.load( await fs.readFile('path/to/templates/template.yaml', 'utf-8'), ); @@ -115,7 +113,7 @@ const response = await fetch( method: 'POST', headers: { 'Content-Type': 'application/json', - Authorization: 'Bearer ', // replace 'YOUR_API_KEY' with your actual API key + Authorization: 'Bearer ', // replace 'FRONT_END_TOKEN' with your actual front-end auth token }, body: JSON.stringify(body), }, diff --git a/microsite/sidebars.json b/microsite/sidebars.json index 075025afbb..2e1d74f739 100644 --- a/microsite/sidebars.json +++ b/microsite/sidebars.json @@ -120,7 +120,8 @@ "features/software-templates/writing-custom-step-layouts", "features/software-templates/authorizing-scaffolder-template-details", "features/software-templates/migrating-to-rjsf-v5", - "features/software-templates/migrating-from-v1beta2-to-v1beta3" + "features/software-templates/migrating-from-v1beta2-to-v1beta3", + "features/software-templates/dry-run-testing" ] }, { diff --git a/mkdocs.yml b/mkdocs.yml index 045238e97e..3e8c7864c3 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -64,6 +64,7 @@ nav: - Writing Custom Actions: 'features/software-templates/writing-custom-actions.md' - Writing Custom Step Layouts: 'features/software-templates/writing-custom-step-layouts.md' - Migrating from v1beta2 to v1beta3 templates: 'features/software-templates/migrating-from-v1beta2-to-v1beta3.md' + - Dry Run Testing: 'plugins/dry-run-testing.md' - Backstage Search: - Overview: 'features/search/README.md' - Getting Started: 'features/search/getting-started.md' @@ -139,7 +140,6 @@ nav: - URL Reader: 'plugins/url-reader.md' - Testing: - Testing with Jest: 'plugins/testing.md' - - Dry Run Testing: 'plugins/dry-run-testing.md' - Publishing: - Publish private: 'plugins/publish-private.md' - Add to Directory: 'plugins/add-to-directory.md' From e5e7d0501b538933b432384ab0725226ec50ce0d Mon Sep 17 00:00:00 2001 From: "Nolan, Tavi" Date: Tue, 23 Jul 2024 12:43:43 +0100 Subject: [PATCH 058/372] Update mkdocs.yml Signed-off-by: Nolan, Tavi --- mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdocs.yml b/mkdocs.yml index 3e8c7864c3..707929d132 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -64,7 +64,7 @@ nav: - Writing Custom Actions: 'features/software-templates/writing-custom-actions.md' - Writing Custom Step Layouts: 'features/software-templates/writing-custom-step-layouts.md' - Migrating from v1beta2 to v1beta3 templates: 'features/software-templates/migrating-from-v1beta2-to-v1beta3.md' - - Dry Run Testing: 'plugins/dry-run-testing.md' + - Dry Run Testing: 'feature/software-templates/dry-run-testing.md' - Backstage Search: - Overview: 'features/search/README.md' - Getting Started: 'features/search/getting-started.md' From 7681b1746e14d900d7f0e383e64c86f513f59075 Mon Sep 17 00:00:00 2001 From: Frank Kong Date: Thu, 27 Jun 2024 16:56:57 -0400 Subject: [PATCH 059/372] chore: remove PII from logs Signed-off-by: Frank Kong --- .changeset/funny-tips-push.md | 5 +++++ .github/vale/config/vocabularies/Backstage/accept.txt | 1 + .../src/entrypoints/rootHttpRouter/http/MiddlewareFactory.ts | 5 +++-- 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changeset/funny-tips-push.md diff --git a/.changeset/funny-tips-push.md b/.changeset/funny-tips-push.md new file mode 100644 index 0000000000..224e6a073a --- /dev/null +++ b/.changeset/funny-tips-push.md @@ -0,0 +1,5 @@ +--- +'@backstage/backend-defaults': patch +--- + +update the `morgan` middleware to use a custom format to prevent PII from being logged diff --git a/.github/vale/config/vocabularies/Backstage/accept.txt b/.github/vale/config/vocabularies/Backstage/accept.txt index 42b0e4895c..50da5fc20f 100644 --- a/.github/vale/config/vocabularies/Backstage/accept.txt +++ b/.github/vale/config/vocabularies/Backstage/accept.txt @@ -243,6 +243,7 @@ Mkdocs monorepo Monorepo monorepos +morgan msgraph msw mutex diff --git a/packages/backend-defaults/src/entrypoints/rootHttpRouter/http/MiddlewareFactory.ts b/packages/backend-defaults/src/entrypoints/rootHttpRouter/http/MiddlewareFactory.ts index 77136fd7e5..f38c10820a 100644 --- a/packages/backend-defaults/src/entrypoints/rootHttpRouter/http/MiddlewareFactory.ts +++ b/packages/backend-defaults/src/entrypoints/rootHttpRouter/http/MiddlewareFactory.ts @@ -140,8 +140,9 @@ export class MiddlewareFactory { const logger = this.#logger.child({ type: 'incomingRequest', }); - - return morgan('combined', { + const customMorganFormat = + '[:date[clf]] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent"'; + return morgan(customMorganFormat, { stream: { write(message: string) { logger.info(message.trimEnd()); From 53d7e4fa2c837f9a810091c83755fb5e3a371939 Mon Sep 17 00:00:00 2001 From: Frank Kong Date: Mon, 22 Jul 2024 11:35:18 -0400 Subject: [PATCH 060/372] docs: add custom logging docs Signed-off-by: Frank Kong --- .../core-services/root-http-router.md | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/docs/backend-system/core-services/root-http-router.md b/docs/backend-system/core-services/root-http-router.md index b3522e1752..88a10455f5 100644 --- a/docs/backend-system/core-services/root-http-router.md +++ b/docs/backend-system/core-services/root-http-router.md @@ -52,19 +52,49 @@ You can configure the root HTTP Router service by passing the options to the `cr ```ts import { rootHttpRouterServiceFactory } from '@backstage/backend-app-api'; +import { RequestHandler } from 'express'; +import morgan from 'morgan'; const backend = createBackend(); backend.add( rootHttpRouterServiceFactory({ configure: ({ app, middleware, routes, config, logger, lifecycle }) => { + // Refer to https://expressjs.com/en/guide/writing-middleware.html on how to write express middleware + const customMiddleware = { + logging(): RequestHandler { + const middlewareLogger = logger.child({ + type: 'incomingRequest', + }); + return (req, res, next) => { + // Custom Logging Implementation + next(); + }; + }, + // Default logging middleware uses the [morgan](https://github.com/expressjs/morgan) middleware which you can configure with custom formats. + morganLogging(): RequestHandler { + const middlewareLogger = logger.child({ + type: 'incomingRequest', + }); + const customMorganFormat = + '[:date[clf]] ":method :url HTTP/:http-version" :status ":user-agent"'; + return morgan(customMorganFormat, { + stream: { + write(message: string) { + logger.info(message.trimEnd()); + }, + }, + }); + }, + }; + // the built in middleware is provided through an option in the configure function app.use(middleware.helmet()); app.use(middleware.cors()); app.use(middleware.compression()); // you can add you your own middleware in here - app.use(custom.logging()); + app.use(customMiddleware.logging()); // here the routes that are registered by other plugins app.use(routes); From 776eb56523b29920592f4ca688d0613481f0bd72 Mon Sep 17 00:00:00 2001 From: Thomas Cardonne Date: Thu, 25 Jul 2024 00:52:49 +0200 Subject: [PATCH 061/372] fix(catalog-backend): error if metadata.annotations isn't a valid object Signed-off-by: Thomas Cardonne --- .changeset/cuddly-penguins-glow.md | 7 ++++ .../processing/ProcessorOutputCollector.ts | 35 ++++++++++--------- 2 files changed, 26 insertions(+), 16 deletions(-) create mode 100644 .changeset/cuddly-penguins-glow.md diff --git a/.changeset/cuddly-penguins-glow.md b/.changeset/cuddly-penguins-glow.md new file mode 100644 index 0000000000..b00422cf8b --- /dev/null +++ b/.changeset/cuddly-penguins-glow.md @@ -0,0 +1,7 @@ +--- +'@backstage/plugin-catalog-backend': patch +--- + +`ProcessorOutputCollector` returns an error when receiving deferred entities that have an invalid `metadata.annotations` format. + +This allows to return an error on an actual validation issue instead of reporting that the location annotations are missing afterwards, which is misleading for the users. diff --git a/plugins/catalog-backend/src/processing/ProcessorOutputCollector.ts b/plugins/catalog-backend/src/processing/ProcessorOutputCollector.ts index eb8cbcc81a..0de6b12b90 100644 --- a/plugins/catalog-backend/src/processing/ProcessorOutputCollector.ts +++ b/plugins/catalog-backend/src/processing/ProcessorOutputCollector.ts @@ -115,24 +115,27 @@ export class ProcessorOutputCollector { // Note that at this point, we have only validated the envelope part of // the entity data. Annotations are not part of that, so we have to be - // defensive. If the annotations were malformed (e.g. were not a valid - // object), we just skip over this step and let the full entity - // validation at the next step of processing catch that. + // defensive and report an error if the annotations isn't a valid object, to avoid + // hiding errors when adding location annotations. const annotations = entity.metadata.annotations || {}; - if (typeof annotations === 'object' && !Array.isArray(annotations)) { - const originLocation = getEntityOriginLocationRef(this.parentEntity); - entity = { - ...entity, - metadata: { - ...entity.metadata, - annotations: { - ...annotations, - [ANNOTATION_ORIGIN_LOCATION]: originLocation, - [ANNOTATION_LOCATION]: location, - }, - }, - }; + if (typeof annotations !== 'object' || Array.isArray(annotations)) { + this.errors.push( + new Error('metadata.annotations must be a valid object'), + ); + return; } + const originLocation = getEntityOriginLocationRef(this.parentEntity); + entity = { + ...entity, + metadata: { + ...entity.metadata, + annotations: { + ...annotations, + [ANNOTATION_ORIGIN_LOCATION]: originLocation, + [ANNOTATION_LOCATION]: location, + }, + }, + }; this.deferredEntities.push({ entity, locationKey: location }); } else if (i.type === 'location') { From b0bee161ee1213af097865281f1ec01b3100cd82 Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 25 Jul 2024 11:44:43 +0200 Subject: [PATCH 062/372] feat(MyGroupsPicker): use entityPresentationApi for consistent display Signed-off-by: Julien --- .../MyGroupsPicker/MyGroupsPicker.test.tsx | 22 ++++- .../fields/MyGroupsPicker/MyGroupsPicker.tsx | 83 +++++++++++++------ .../components/fields/VirtualizedListbox.tsx | 33 +++++--- 3 files changed, 100 insertions(+), 38 deletions(-) diff --git a/plugins/scaffolder/src/components/fields/MyGroupsPicker/MyGroupsPicker.test.tsx b/plugins/scaffolder/src/components/fields/MyGroupsPicker/MyGroupsPicker.test.tsx index 94261ce0e4..4e54ee99ad 100644 --- a/plugins/scaffolder/src/components/fields/MyGroupsPicker/MyGroupsPicker.test.tsx +++ b/plugins/scaffolder/src/components/fields/MyGroupsPicker/MyGroupsPicker.test.tsx @@ -19,7 +19,10 @@ import { render, waitFor } from '@testing-library/react'; import { CatalogApi } from '@backstage/catalog-client'; import { MyGroupsPicker } from './MyGroupsPicker'; import { TestApiProvider } from '@backstage/test-utils'; -import { catalogApiRef } from '@backstage/plugin-catalog-react'; +import { + catalogApiRef, + entityPresentationApiRef, +} from '@backstage/plugin-catalog-react'; import { Entity } from '@backstage/catalog-model'; import { ErrorApi, @@ -29,6 +32,7 @@ import { } from '@backstage/core-plugin-api'; import userEvent from '@testing-library/user-event'; import { ScaffolderRJSFFieldProps as FieldProps } from '@backstage/plugin-scaffolder-react'; +import { DefaultEntityPresentationApi } from '@backstage/plugin-catalog'; // Create a mock IdentityApi const mockIdentityApi: IdentityApi = { @@ -117,6 +121,10 @@ describe('', () => { [identityApiRef, mockIdentityApi], [catalogApiRef, catalogApi], [errorApiRef, mockErrorApi], + [ + entityPresentationApiRef, + DefaultEntityPresentationApi.create({ catalogApi }), + ], ]} > @@ -189,6 +197,10 @@ describe('', () => { [identityApiRef, mockIdentityApi], [catalogApiRef, catalogApi], [errorApiRef, mockErrorApi], + [ + entityPresentationApiRef, + DefaultEntityPresentationApi.create({ catalogApi }), + ], ]} > @@ -246,6 +258,10 @@ describe('', () => { [identityApiRef, mockIdentityApi], [catalogApiRef, catalogApi], [errorApiRef, mockErrorApi], + [ + entityPresentationApiRef, + DefaultEntityPresentationApi.create({ catalogApi }), + ], ]} > @@ -306,6 +322,10 @@ describe('', () => { [identityApiRef, mockIdentityApi], [catalogApiRef, catalogApi], [errorApiRef, mockErrorApi], + [ + entityPresentationApiRef, + DefaultEntityPresentationApi.create({ catalogApi }), + ], ]} > diff --git a/plugins/scaffolder/src/components/fields/MyGroupsPicker/MyGroupsPicker.tsx b/plugins/scaffolder/src/components/fields/MyGroupsPicker/MyGroupsPicker.tsx index 1e78fa45a1..dcb4be4c44 100644 --- a/plugins/scaffolder/src/components/fields/MyGroupsPicker/MyGroupsPicker.tsx +++ b/plugins/scaffolder/src/components/fields/MyGroupsPicker/MyGroupsPicker.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ -import React, { useState } from 'react'; +import React, { useEffect } from 'react'; import { errorApiRef, identityApiRef, @@ -23,11 +23,19 @@ import { import TextField from '@material-ui/core/TextField'; import FormControl from '@material-ui/core/FormControl'; import { MyGroupsPickerProps, MyGroupsPickerSchema } from './schema'; -import Autocomplete from '@material-ui/lab/Autocomplete'; -import { catalogApiRef } from '@backstage/plugin-catalog-react'; +import Autocomplete, { + createFilterOptions, +} from '@material-ui/lab/Autocomplete'; +import { + catalogApiRef, + EntityDisplayName, + entityPresentationApiRef, + EntityRefPresentationSnapshot, +} from '@backstage/plugin-catalog-react'; import { NotFoundError } from '@backstage/errors'; import useAsync from 'react-use/esm/useAsync'; import { Entity, stringifyEntityRef } from '@backstage/catalog-model'; +import { VirtualizedListbox } from '../VirtualizedListbox'; export { MyGroupsPickerSchema }; @@ -43,19 +51,14 @@ export const MyGroupsPicker = (props: MyGroupsPickerProps) => { const identityApi = useApi(identityApiRef); const catalogApi = useApi(catalogApiRef); const errorApi = useApi(errorApiRef); - const [groups, setGroups] = useState< - { - label: string; - ref: string; - }[] - >([]); + const entityPresentationApi = useApi(entityPresentationApiRef); - useAsync(async () => { + const { value: groups, loading } = useAsync(async () => { const { userEntityRef } = await identityApi.getBackstageIdentity(); if (!userEntityRef) { errorApi.post(new NotFoundError('No user entity ref found')); - return; + return { catalogEntities: [], entityRefToPresentation: new Map() }; } const { items } = await catalogApi.getEntities({ @@ -65,24 +68,38 @@ export const MyGroupsPicker = (props: MyGroupsPickerProps) => { }, }); - const groupValues = items - .filter((e): e is Entity => Boolean(e)) - .map(item => ({ - label: item.metadata.title ?? item.metadata.name, - ref: stringifyEntityRef(item), - })); + const entityRefToPresentation = new Map< + string, + EntityRefPresentationSnapshot + >( + await Promise.all( + items.map(async item => { + const presentation = await entityPresentationApi.forEntity(item) + .promise; + return [stringifyEntityRef(item), presentation] as [ + string, + EntityRefPresentationSnapshot, + ]; + }), + ), + ); - setGroups(groupValues); + return { catalogEntities: items, entityRefToPresentation }; }); - const updateChange = ( - _: React.ChangeEvent<{}>, - value: { label: string; ref: string } | null, - ) => { - onChange(value?.ref ?? ''); + const updateChange = (_: React.ChangeEvent<{}>, value: Entity | null) => { + onChange(value ? stringifyEntityRef(value) : ''); }; - const selectedEntity = groups?.find(e => e.ref === formData) || null; + const selectedEntity = + groups?.catalogEntities.find(e => stringifyEntityRef(e) === formData) || + null; + + useEffect(() => { + if (groups?.catalogEntities.length === 1 && !selectedEntity) { + onChange(stringifyEntityRef(groups.catalogEntities[0])); + } + }, [groups, onChange, selectedEntity]); return ( { error={rawErrors?.length > 0} > group.label} + getOptionLabel={option => + groups?.entityRefToPresentation.get(stringifyEntityRef(option)) + ?.primaryTitle! + } + autoSelect renderInput={params => ( { FormHelperTextProps={{ margin: 'dense', style: { marginLeft: 0 } }} variant="outlined" required={required} + InputProps={params.InputProps} /> )} + renderOption={option => } + filterOptions={createFilterOptions({ + stringify: option => + groups?.entityRefToPresentation.get(stringifyEntityRef(option)) + ?.primaryTitle!, + })} + ListboxComponent={VirtualizedListbox} /> ); diff --git a/plugins/scaffolder/src/components/fields/VirtualizedListbox.tsx b/plugins/scaffolder/src/components/fields/VirtualizedListbox.tsx index b0920b626a..b2bd611cec 100644 --- a/plugins/scaffolder/src/components/fields/VirtualizedListbox.tsx +++ b/plugins/scaffolder/src/components/fields/VirtualizedListbox.tsx @@ -22,29 +22,40 @@ const renderRow = (props: ListChildComponentProps) => { return React.cloneElement(data[index], { style }); }; +const OuterElementContext = React.createContext({}); + +const OuterElementType = React.forwardRef((props, ref) => { + const outerProps = React.useContext(OuterElementContext); + return
; +}); + export const VirtualizedListbox = React.forwardRef< HTMLDivElement, { children?: React.ReactNode } >((props, ref) => { - const itemData = React.Children.toArray(props.children); + const { children, ...other } = props; + const itemData = React.Children.toArray(children); const itemCount = itemData.length; const itemSize = 36; const itemsToShow = Math.min(10, itemCount); - const height = Math.max(itemSize, itemsToShow * itemSize - 0.5 * itemSize); + const height = itemsToShow * itemSize; return (
- - {renderRow} - + + + {renderRow} + +
); }); From 1552c334bab3e4ddcc45e77f7a45ed967d84e98e Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 25 Jul 2024 11:51:45 +0200 Subject: [PATCH 063/372] chore: add changeset Signed-off-by: Julien --- .changeset/perfect-cars-jam.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/perfect-cars-jam.md diff --git a/.changeset/perfect-cars-jam.md b/.changeset/perfect-cars-jam.md new file mode 100644 index 0000000000..a22791034a --- /dev/null +++ b/.changeset/perfect-cars-jam.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder': minor +--- + +Changed the way to display entities in `MyGroupsPicker` to use entityPresentationApi and make it consistent across scaffolder pickers From 7a05f509084f487972c276e3018589b51b1fea03 Mon Sep 17 00:00:00 2001 From: Heikki Hellgren Date: Thu, 25 Jul 2024 12:48:06 +0300 Subject: [PATCH 064/372] fix: allow using notifications without users in catalog additionally refactored and added tests for the notification receiver logic fixes #25768 Signed-off-by: Heikki Hellgren --- .changeset/modern-poems-mate.md | 5 + .../src/service/getUsersForEntityRef.test.ts | 175 ++++++++++++++++++ .../src/service/getUsersForEntityRef.ts | 161 ++++++++++++++++ .../src/service/router.ts | 96 +--------- 4 files changed, 343 insertions(+), 94 deletions(-) create mode 100644 .changeset/modern-poems-mate.md create mode 100644 plugins/notifications-backend/src/service/getUsersForEntityRef.test.ts create mode 100644 plugins/notifications-backend/src/service/getUsersForEntityRef.ts diff --git a/.changeset/modern-poems-mate.md b/.changeset/modern-poems-mate.md new file mode 100644 index 0000000000..06926daac9 --- /dev/null +++ b/.changeset/modern-poems-mate.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-notifications-backend': patch +--- + +Allow using notifications without users in the catalog diff --git a/plugins/notifications-backend/src/service/getUsersForEntityRef.test.ts b/plugins/notifications-backend/src/service/getUsersForEntityRef.test.ts new file mode 100644 index 0000000000..b06d6f203b --- /dev/null +++ b/plugins/notifications-backend/src/service/getUsersForEntityRef.test.ts @@ -0,0 +1,175 @@ +/* + * Copyright 2024 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 { mockServices } from '@backstage/backend-test-utils'; +import { getUsersForEntityRef } from './getUsersForEntityRef'; +import { CatalogApi } from '@backstage/catalog-client'; +import { + RELATION_HAS_MEMBER, + RELATION_OWNED_BY, + RELATION_PARENT_OF, +} from '@backstage/catalog-model'; + +describe('getUsersForEntityRef', () => { + const catalogApiMock = { + getEntitiesByRefs: jest.fn(), + getEntityByRef: jest.fn(), + }; + const authMock = mockServices.auth(); + + it('should return empty array if entityRef is null', async () => { + await expect( + getUsersForEntityRef(null, [], { + auth: authMock, + catalogClient: catalogApiMock as unknown as CatalogApi, + }), + ).resolves.toEqual([]); + }); + + it('should resolve users without calling catalog', async () => { + await expect( + getUsersForEntityRef(['user:foo', 'user:ignored'], ['user:ignored'], { + auth: authMock, + catalogClient: catalogApiMock as unknown as CatalogApi, + }), + ).resolves.toEqual(['user:foo']); + expect(catalogApiMock.getEntitiesByRefs).not.toHaveBeenCalled(); + }); + + it('should resolve group entities to users', async () => { + catalogApiMock.getEntitiesByRefs.mockResolvedValueOnce({ + items: [ + { + apiVersion: 'backstage.io/v1alpha1', + kind: 'Group', + metadata: { + name: 'parent_group', + }, + relations: [ + { + type: RELATION_HAS_MEMBER, + targetRef: 'user:default/foo', + }, + { + type: RELATION_PARENT_OF, + targetRef: 'group:default/child_group', + }, + ], + }, + ], + }); + + catalogApiMock.getEntitiesByRefs.mockResolvedValueOnce({ + items: [ + { + apiVersion: 'backstage.io/v1alpha1', + kind: 'Group', + metadata: { + name: 'child_group', + }, + relations: [ + { + type: RELATION_HAS_MEMBER, + targetRef: 'user:default/bar', + }, + { + type: RELATION_HAS_MEMBER, + targetRef: 'user:default/ignored', + }, + ], + }, + ], + }); + + await expect( + getUsersForEntityRef( + 'group:default/parent_group', + ['user:default/ignored'], + { + auth: authMock, + catalogClient: catalogApiMock as unknown as CatalogApi, + }, + ), + ).resolves.toEqual(['user:default/foo', 'user:default/bar']); + }); + + it('should resolve user owner of entity from entity ref', async () => { + catalogApiMock.getEntitiesByRefs.mockResolvedValueOnce({ + items: [ + { + apiVersion: 'backstage.io/v1alpha1', + kind: 'Component', + metadata: { + name: 'test_component', + }, + relations: [ + { + type: RELATION_OWNED_BY, + targetRef: 'user:default/foo', + }, + ], + }, + ], + }); + + await expect( + getUsersForEntityRef('component:default/test_component', [], { + auth: authMock, + catalogClient: catalogApiMock as unknown as CatalogApi, + }), + ).resolves.toEqual(['user:default/foo']); + }); + + it('should resolve group owner of entity from entity ref', async () => { + catalogApiMock.getEntitiesByRefs.mockResolvedValueOnce({ + items: [ + { + apiVersion: 'backstage.io/v1alpha1', + kind: 'Component', + metadata: { + name: 'test_component', + }, + relations: [ + { + type: RELATION_OWNED_BY, + targetRef: 'group:default/owner_group', + }, + ], + }, + ], + }); + + catalogApiMock.getEntityByRef.mockResolvedValueOnce({ + apiVersion: 'backstage.io/v1alpha1', + kind: 'Group', + metadata: { + name: 'owner_group', + }, + relations: [ + { + type: RELATION_HAS_MEMBER, + targetRef: 'user:default/foo', + }, + ], + }); + + await expect( + getUsersForEntityRef('component:default/test_component', [], { + auth: authMock, + catalogClient: catalogApiMock as unknown as CatalogApi, + }), + ).resolves.toEqual(['user:default/foo']); + }); +}); diff --git a/plugins/notifications-backend/src/service/getUsersForEntityRef.ts b/plugins/notifications-backend/src/service/getUsersForEntityRef.ts new file mode 100644 index 0000000000..fd564d6528 --- /dev/null +++ b/plugins/notifications-backend/src/service/getUsersForEntityRef.ts @@ -0,0 +1,161 @@ +/* + * Copyright 2024 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 { + Entity, + isGroupEntity, + isUserEntity, + parseEntityRef, + RELATION_HAS_MEMBER, + RELATION_OWNED_BY, + RELATION_PARENT_OF, + stringifyEntityRef, +} from '@backstage/catalog-model'; +import { AuthService } from '@backstage/backend-plugin-api'; +import { CatalogApi } from '@backstage/catalog-client'; + +const isUserEntityRef = (ref: string) => + parseEntityRef(ref).kind.toLocaleLowerCase() === 'user'; + +// Partitions array of entity references to two arrays; user entity refs and other entity refs +const partitionEntityRefs = (refs: string[]): string[][] => + refs.reduce( + ([userEntityRefs, otherEntityRefs]: string[][], ref: string) => { + return isUserEntityRef(ref) + ? [[...userEntityRefs, ref], otherEntityRefs] + : [userEntityRefs, [...otherEntityRefs, ref]]; + }, + [[], []], + ); + +export const getUsersForEntityRef = async ( + entityRef: string | string[] | null, + excludeEntityRefs: string | string[], + options: { + auth: AuthService; + catalogClient: CatalogApi; + }, +): Promise => { + const { auth, catalogClient } = options; + + if (entityRef === null) { + return []; + } + + const { token } = await auth.getPluginRequestToken({ + onBehalfOf: await auth.getOwnServiceCredentials(), + targetPluginId: 'catalog', + }); + + const excluded = Array.isArray(excludeEntityRefs) + ? excludeEntityRefs + : [excludeEntityRefs]; + + const refsArr = Array.isArray(entityRef) ? entityRef : [entityRef]; + const [userEntityRefs, otherEntityRefs] = partitionEntityRefs(refsArr); + const users: string[] = userEntityRefs.filter(ref => !excluded.includes(ref)); + const entityRefs = otherEntityRefs.filter(ref => !excluded.includes(ref)); + + const fields = ['kind', 'metadata.name', 'metadata.namespace', 'relations']; + let entities: Array = []; + if (entityRefs.length > 0) { + const fetchedEntities = await catalogClient.getEntitiesByRefs( + { + entityRefs, + fields, + }, + { token }, + ); + entities = fetchedEntities.items; + } + + const mapEntity = async (entity: Entity | undefined): Promise => { + if (!entity) { + return []; + } + + const currentEntityRef = stringifyEntityRef(entity); + if (excluded.includes(currentEntityRef)) { + return []; + } + + if (isUserEntity(entity)) { + return [currentEntityRef]; + } + + if (isGroupEntity(entity)) { + if (!entity.relations?.length) { + return []; + } + + const groupUsers = entity.relations + .filter( + relation => + relation.type === RELATION_HAS_MEMBER && + isUserEntityRef(relation.targetRef), + ) + .map(r => r.targetRef); + + const childGroupRefs = entity.relations + .filter(relation => relation.type === RELATION_PARENT_OF) + .map(r => r.targetRef); + + let childGroupUsers: string[][] = []; + if (childGroupRefs.length > 0) { + const childGroups = await catalogClient.getEntitiesByRefs( + { + entityRefs: childGroupRefs, + fields, + }, + { token }, + ); + childGroupUsers = await Promise.all(childGroups.items.map(mapEntity)); + } + + return [...groupUsers, ...childGroupUsers.flat(2)].filter( + ref => !excluded.includes(ref), + ); + } + + if (entity.relations?.length) { + const ownerRef = entity.relations.find( + relation => relation.type === RELATION_OWNED_BY, + )?.targetRef; + + if (!ownerRef) { + return []; + } + + if (isUserEntityRef(ownerRef)) { + if (excluded.includes(ownerRef)) { + return []; + } + return [ownerRef]; + } + + const owner = await catalogClient.getEntityByRef(ownerRef, { token }); + return mapEntity(owner); + } + + return []; + }; + + for (const entity of entities) { + const u = await mapEntity(entity); + users.push(...u); + } + + return [...new Set(users)]; +}; diff --git a/plugins/notifications-backend/src/service/router.ts b/plugins/notifications-backend/src/service/router.ts index 3ca3ce46bc..abd7e2dc13 100644 --- a/plugins/notifications-backend/src/service/router.ts +++ b/plugins/notifications-backend/src/service/router.ts @@ -23,15 +23,6 @@ import { } from '../database'; import { v4 as uuid } from 'uuid'; import { CatalogApi, CatalogClient } from '@backstage/catalog-client'; -import { - Entity, - isGroupEntity, - isUserEntity, - RELATION_HAS_MEMBER, - RELATION_OWNED_BY, - RELATION_PARENT_OF, - stringifyEntityRef, -} from '@backstage/catalog-model'; import { NotificationProcessor, NotificationSendOptions, @@ -54,6 +45,7 @@ import { NotificationStatus, } from '@backstage/plugin-notifications-common'; import { parseEntityOrderFieldParams } from './parseEntityOrderFieldParams'; +import { getUsersForEntityRef } from './getUsersForEntityRef'; /** @internal */ export interface RouterOptions { @@ -94,91 +86,6 @@ export async function createRouter( return info.userEntityRef; }; - const getUsersForEntityRef = async ( - entityRef: string | string[] | null, - excludeEntityRefs: string | string[], - ): Promise => { - const { token } = await auth.getPluginRequestToken({ - onBehalfOf: await auth.getOwnServiceCredentials(), - targetPluginId: 'catalog', - }); - - if (entityRef === null) { - return []; - } - - const fields = ['kind', 'metadata.name', 'metadata.namespace', 'relations']; - - const refs = Array.isArray(entityRef) ? entityRef : [entityRef]; - const entities = await catalogClient.getEntitiesByRefs( - { - entityRefs: refs, - fields, - }, - { token }, - ); - - const excluded = Array.isArray(excludeEntityRefs) - ? excludeEntityRefs - : [excludeEntityRefs]; - - const mapEntity = async (entity: Entity | undefined): Promise => { - if (!entity) { - return []; - } - - const currentEntityRef = stringifyEntityRef(entity); - if (excluded.includes(currentEntityRef)) { - return []; - } - - if (isUserEntity(entity)) { - return [currentEntityRef]; - } else if (isGroupEntity(entity) && entity.relations) { - const users = entity.relations - .filter(relation => relation.type === RELATION_HAS_MEMBER) - .map(r => r.targetRef); - - const childGroupRefs = entity.relations - .filter(relation => relation.type === RELATION_PARENT_OF) - .map(r => r.targetRef); - - const childGroups = await catalogClient.getEntitiesByRefs( - { - entityRefs: childGroupRefs, - fields, - }, - { token }, - ); - const childGroupUsers = await Promise.all( - childGroups.items.map(mapEntity), - ); - return [...users, ...childGroupUsers.flat(2)]; - } else if (entity.relations) { - const ownerRef = entity.relations.find( - relation => relation.type === RELATION_OWNED_BY, - )?.targetRef; - - if (ownerRef) { - const owner = await catalogClient.getEntityByRef(ownerRef, { token }); - if (owner) { - return mapEntity(owner); - } - } - } - - return []; - }; - - const users: string[] = []; - for (const entity of entities.items) { - const u = await mapEntity(entity); - users.push(...u); - } - - return users; - }; - const filterProcessors = (payload: NotificationPayload) => { const result: NotificationProcessor[] = []; @@ -543,6 +450,7 @@ export async function createRouter( users = await getUsersForEntityRef( entityRef, recipients.excludeEntityRef ?? [], + { auth, catalogClient }, ); } catch (e) { logger.error(`Failed to resolve notification receivers: ${e}`); From 0bb72c38f0ac8a19c26c0dee9af0ddc56fd610e6 Mon Sep 17 00:00:00 2001 From: "Nolan, Tavi" Date: Fri, 26 Jul 2024 12:00:06 +0100 Subject: [PATCH 065/372] Update dry-run-testing.md based on comments Signed-off-by: Nolan, Tavi --- .../software-templates/dry-run-testing.md | 56 +------------------ 1 file changed, 1 insertion(+), 55 deletions(-) diff --git a/docs/features/software-templates/dry-run-testing.md b/docs/features/software-templates/dry-run-testing.md index fb2de0f672..dfabad265e 100644 --- a/docs/features/software-templates/dry-run-testing.md +++ b/docs/features/software-templates/dry-run-testing.md @@ -1,5 +1,5 @@ --- -id: dry run testing +id: dry-run-testing title: Dry Run Testing description: How to enable and implement dry run testing in actions --- @@ -77,57 +77,3 @@ You will also need to add tests for the dry run handling, for example: expect(...); }); ``` - -## Dry run via API call - -Dry run can be performed using the dry-run API, which allows the dry run to be completed in code. -This [command line script](https://github.com/backstage/backstage/blob/master/contrib/scaffolder/template-testing-dry-run.md) offers a way for you to do work with dry-run API. You run it against a running instance, either locally or remote, and use it like: - -```bash -scaffolder-dry http://localhost:7007/ template-directory values.yml output-directory -``` - -If you're using backend permissions, pass a front-end auth token from a current browser session via --token $FRONTEND_TOKEN. - -You can also query the dry run endpoint directly in code, for example: - -```javascript title="dry-run.js" -const template = yaml.load( - await fs.readFile('path/to/templates/template.yaml', 'utf-8'), -); -const values = JSON.parse( - await fs.readFile('path/to/templates/template_values.json', 'utf-8'), -); - -// Prepare the request body -const body = { - template, - values, - directoryContents, -}; - -// Send the request to the dry-run endpoint -const response = await fetch( - 'http://localhost:7000/api/scaffolder/v2/dry-run', - { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer ', // replace 'FRONT_END_TOKEN' with your actual front-end auth token - }, - body: JSON.stringify(body), - }, -); -``` - -`template_values.json` - -```json -{ - "example": "test", - "name": "helloworld" -} -``` - -In this example `template.yaml` is your template yaml file, `template_values.json` would be a json file containing key value pairs for your template inputs, and `directoryContents` is an array that is populated with objects representing the contents of a specified directory (e.g. the same directory where you have your template yaml). Each object in the array corresponds to a file within the directory and contains two properties; the name of the file and the content of the file, encoded in Base64. -This is needed if any other files were required by the actions your template is using. From cd203f12502c08030c44f3b7d02cbbfdce8e0339 Mon Sep 17 00:00:00 2001 From: parmar-abhinav Date: Sat, 27 Jul 2024 15:27:20 +0530 Subject: [PATCH 066/372] Added examples for action github:pages and improved test cases Signed-off-by: parmar-abhinav --- .changeset/thin-carrots-eat.md | 5 + .../githubPagesEnable.examples.test.ts | 364 +++++++++++++++++- .../src/actions/githubPagesEnable.examples.ts | 205 ++++++++++ 3 files changed, 570 insertions(+), 4 deletions(-) create mode 100644 .changeset/thin-carrots-eat.md diff --git a/.changeset/thin-carrots-eat.md b/.changeset/thin-carrots-eat.md new file mode 100644 index 0000000000..570f21f83d --- /dev/null +++ b/.changeset/thin-carrots-eat.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend-module-github': patch +--- + +Added examples for action github:pages and improved its test cases diff --git a/plugins/scaffolder-backend-module-github/src/actions/githubPagesEnable.examples.test.ts b/plugins/scaffolder-backend-module-github/src/actions/githubPagesEnable.examples.test.ts index ee7b5caa65..f0aa0ea5a2 100644 --- a/plugins/scaffolder-backend-module-github/src/actions/githubPagesEnable.examples.test.ts +++ b/plugins/scaffolder-backend-module-github/src/actions/githubPagesEnable.examples.test.ts @@ -52,9 +52,14 @@ describe('github:pages', () => { let githubCredentialsProvider: GithubCredentialsProvider; let action: TemplateAction; - const input = yaml.parse(examples[0].example).steps[0].input; const mockContext = createMockActionContext({ - input, + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + buildType: 'workflow', + sourceBranch: 'main', + sourcePath: '/', + token: 'gph_YourGitHubToken', + }, }); beforeEach(() => { @@ -68,8 +73,20 @@ describe('github:pages', () => { afterEach(jest.resetAllMocks); - it('should work with example input', async () => { - await action.handler(mockContext); + it(`Should ${examples[0].description}`, async () => { + let input; + try { + input = yaml.parse(examples[0].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); expect(mockOctokit.request).toHaveBeenCalledWith( 'POST /repos/{owner}/{repo}/pages', @@ -87,4 +104,343 @@ describe('github:pages', () => { }, ); }); + it(`Should ${examples[1].description}`, async () => { + let input; + try { + input = yaml.parse(examples[1].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.request).toHaveBeenCalledWith( + 'POST /repos/{owner}/{repo}/pages', + { + owner: 'customOwner', + repo: 'customPathRepo', + build_type: 'workflow', + source: { + branch: 'main', + path: '/docs', + }, + headers: { + 'X-GitHub-Api-Version': '2022-11-28', + }, + }, + ); + }); + + it(`Should ${examples[2].description}`, async () => { + let input; + try { + input = yaml.parse(examples[2].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + expect(mockOctokit.request).toHaveBeenCalledWith( + 'POST /repos/{owner}/{repo}/pages', + { + owner: 'legacyOwner', + repo: 'legacyRepo', + build_type: 'legacy', + source: { + branch: 'main', + path: '/', + }, + headers: { + 'X-GitHub-Api-Version': '2022-11-28', + }, + }, + ); + }); + + it(`Should ${examples[3].description}`, async () => { + let input; + try { + input = yaml.parse(examples[3].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + expect(mockOctokit.request).toHaveBeenCalledWith( + 'POST /repos/{owner}/{repo}/pages', + { + owner: 'branchOwner', + repo: 'customBranchRepo', + build_type: 'workflow', + source: { + branch: 'develop', + path: '/', + }, + headers: { + 'X-GitHub-Api-Version': '2022-11-28', + }, + }, + ); + }); + it(`Should ${examples[4].description}`, async () => { + let input; + try { + input = yaml.parse(examples[4].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + expect(mockOctokit.request).toHaveBeenCalledWith( + 'POST /repos/{owner}/{repo}/pages', + { + owner: 'customOwner', + repo: 'fullCustomRepo', + build_type: 'workflow', + source: { + branch: 'main', + path: '/docs', + }, + headers: { + 'X-GitHub-Api-Version': '2022-11-28', + }, + }, + ); + }); + + it(`Should ${examples[5].description}`, async () => { + let input; + try { + input = yaml.parse(examples[5].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + expect(mockOctokit.request).toHaveBeenCalledWith( + 'POST /repos/{owner}/{repo}/pages', + { + owner: 'minimalOwner', + repo: 'minimalRepo', + build_type: 'workflow', + source: { + branch: 'main', + path: '/', + }, + headers: { + 'X-GitHub-Api-Version': '2022-11-28', + }, + }, + ); + }); + it(`Should ${examples[6].description}`, async () => { + let input; + try { + input = yaml.parse(examples[6].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + expect(mockOctokit.request).toHaveBeenCalledWith( + 'POST /repos/{owner}/{repo}/pages', + { + owner: 'customOwner', + repo: 'customBuildPathRepo', + build_type: 'legacy', + source: { + branch: 'main', + path: '/custom-path', + }, + headers: { + 'X-GitHub-Api-Version': '2022-11-28', + }, + }, + ); + }); + + it(`Should ${examples[7].description}`, async () => { + let input; + try { + input = yaml.parse(examples[7].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + expect(mockOctokit.request).toHaveBeenCalledWith( + 'POST /repos/{owner}/{repo}/pages', + { + owner: 'branchPathOwner', + repo: 'customBranchPathRepo', + build_type: 'workflow', + source: { + branch: 'feature-branch', + path: '/project-docs', + }, + headers: { + 'X-GitHub-Api-Version': '2022-11-28', + }, + }, + ); + }); + + it(`Should ${examples[8].description}`, async () => { + let input; + try { + input = yaml.parse(examples[8].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + expect(mockOctokit.request).toHaveBeenCalledWith( + 'POST /repos/{owner}/{repo}/pages', + { + owner: 'customOwnerName', + repo: 'customRepoName', + build_type: 'workflow', + source: { + branch: 'main', + path: '/', + }, + headers: { + 'X-GitHub-Api-Version': '2022-11-28', + }, + }, + ); + }); + + it(`Should ${examples[9].description}`, async () => { + let input; + try { + input = yaml.parse(examples[9].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + expect(mockOctokit.request).toHaveBeenCalledWith( + 'POST /repos/{owner}/{repo}/pages', + { + owner: 'tokenOwner', + repo: 'customTokenRepo', + build_type: 'workflow', + source: { + branch: 'main', + path: '/site', + }, + headers: { + 'X-GitHub-Api-Version': '2022-11-28', + }, + }, + ); + }); + + it(`Should ${examples[10].description}`, async () => { + let input; + try { + input = yaml.parse(examples[10].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + expect(mockOctokit.request).toHaveBeenCalledWith( + 'POST /repos/{owner}/{repo}/pages', + { + owner: 'tokenOwner', + repo: 'specificTokenRepo', + build_type: 'workflow', + source: { + branch: 'main', + path: '/', + }, + headers: { + 'X-GitHub-Api-Version': '2022-11-28', + }, + }, + ); + }); + + it(`Should ${examples[11].description}`, async () => { + let input; + try { + input = yaml.parse(examples[11].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + expect(mockOctokit.request).toHaveBeenCalledWith( + 'POST /repos/{owner}/{repo}/pages', + { + owner: 'docsOwner', + repo: 'docSiteRepo', + build_type: 'workflow', + source: { + branch: 'docs-branch', + path: '/docs-site', + }, + headers: { + 'X-GitHub-Api-Version': '2022-11-28', + }, + }, + ); + }); }); diff --git a/plugins/scaffolder-backend-module-github/src/actions/githubPagesEnable.examples.ts b/plugins/scaffolder-backend-module-github/src/actions/githubPagesEnable.examples.ts index be4a33e5df..57102c4b92 100644 --- a/plugins/scaffolder-backend-module-github/src/actions/githubPagesEnable.examples.ts +++ b/plugins/scaffolder-backend-module-github/src/actions/githubPagesEnable.examples.ts @@ -37,4 +37,209 @@ export const examples: TemplateExample[] = [ ], }), }, + { + description: + 'Enables GitHub Pages for a repository with a custom source path.', + example: yaml.stringify({ + steps: [ + { + action: 'github:pages', + id: 'github-pages-custom-path', + name: 'Enable GitHub Pages with Custom Source Path', + input: { + repoUrl: 'github.com?repo=customPathRepo&owner=customOwner', + sourcePath: '/docs', + token: 'gph_YourGitHubToken', + }, + }, + ], + }), + }, + { + description: + 'Enables GitHub Pages for a repository using legacy build type.', + example: yaml.stringify({ + steps: [ + { + action: 'github:pages', + id: 'github-pages-legacy', + name: 'Enable GitHub Pages with Legacy Build Type', + input: { + repoUrl: 'github.com?repo=legacyRepo&owner=legacyOwner', + buildType: 'legacy', + token: 'gph_YourGitHubToken', + }, + }, + ], + }), + }, + { + description: + 'Enables GitHub Pages for a repository with a custom source branch.', + example: yaml.stringify({ + steps: [ + { + action: 'github:pages', + id: 'github-pages-custom-branch', + name: 'Enable GitHub Pages with Custom Source Branch', + input: { + repoUrl: 'github.com?repo=customBranchRepo&owner=branchOwner', + sourceBranch: 'develop', + token: 'gph_YourGitHubToken', + }, + }, + ], + }), + }, + + { + description: + 'Enables GitHub Pages for a repository with full customization.', + example: yaml.stringify({ + steps: [ + { + action: 'github:pages', + id: 'github-pages-full-custom', + name: 'Enable GitHub Pages with Full Customization', + input: { + repoUrl: 'github.com?repo=fullCustomRepo&owner=customOwner', + buildType: 'workflow', + sourceBranch: 'main', + sourcePath: '/docs', + token: 'gph_YourGitHubToken', + }, + }, + ], + }), + }, + { + description: + 'Enables GitHub Pages for a repository with minimal configuration.', + example: yaml.stringify({ + steps: [ + { + action: 'github:pages', + id: 'github-pages-minimal', + name: 'Enable GitHub Pages with Minimal Configuration', + input: { + repoUrl: 'github.com?repo=minimalRepo&owner=minimalOwner', + token: 'gph_YourGitHubToken', + }, + }, + ], + }), + }, + { + description: + 'Enables GitHub Pages for a repository with custom build type and source path.', + example: yaml.stringify({ + steps: [ + { + action: 'github:pages', + id: 'github-pages-custom-build-path', + name: 'Enable GitHub Pages with Custom Build Type and Source Path', + input: { + repoUrl: 'github.com?repo=customBuildPathRepo&owner=customOwner', + buildType: 'legacy', + sourcePath: '/custom-path', + token: 'gph_YourGitHubToken', + }, + }, + ], + }), + }, + { + description: + 'Enables GitHub Pages for a repository with custom source branch and path.', + example: yaml.stringify({ + steps: [ + { + action: 'github:pages', + id: 'github-pages-custom-branch-path', + name: 'Enable GitHub Pages with Custom Source Branch and Path', + input: { + repoUrl: + 'github.com?repo=customBranchPathRepo&owner=branchPathOwner', + sourceBranch: 'feature-branch', + sourcePath: '/project-docs', + token: 'gph_YourGitHubToken', + }, + }, + ], + }), + }, + { + description: + 'Enables GitHub Pages for a repository with a custom owner and repository name.', + example: yaml.stringify({ + steps: [ + { + action: 'github:pages', + id: 'github-pages-custom-owner-repo', + name: 'Enable GitHub Pages with Custom Owner and Repository Name', + input: { + repoUrl: 'github.com?repo=customRepoName&owner=customOwnerName', + token: 'gph_YourGitHubToken', + }, + }, + ], + }), + }, + { + description: + 'Enables GitHub Pages for a repository with full customization and a different token.', + example: yaml.stringify({ + steps: [ + { + action: 'github:pages', + id: 'github-pages-full-custom-diff-token', + name: 'Enable GitHub Pages with Full Customization and Different Token', + input: { + repoUrl: 'github.com?repo=customTokenRepo&owner=tokenOwner', + buildType: 'workflow', + sourceBranch: 'main', + sourcePath: '/site', + token: 'gph_DifferentGitHubToken', + }, + }, + ], + }), + }, + { + description: + 'Enables GitHub Pages for a repository with a specific token for authorization.', + example: yaml.stringify({ + steps: [ + { + action: 'github:pages', + id: 'github-pages-specific-token', + name: 'Enable GitHub Pages with Specific Token', + input: { + repoUrl: 'github.com?repo=specificTokenRepo&owner=tokenOwner', + token: 'gph_SpecificGitHubToken', + }, + }, + ], + }), + }, + { + description: + 'Enables GitHub Pages for a documentation site with custom configuration.', + example: yaml.stringify({ + steps: [ + { + action: 'github:pages', + id: 'github-pages-doc-site', + name: 'Enable GitHub Pages for Documentation Site', + input: { + repoUrl: 'github.com?repo=docSiteRepo&owner=docsOwner', + buildType: 'workflow', + sourceBranch: 'docs-branch', + sourcePath: '/docs-site', + token: 'gph_DocsGitHubToken', + }, + }, + ], + }), + }, ]; From 9e2918640a05130650f1899f380a546691ebd926 Mon Sep 17 00:00:00 2001 From: MT Lewis Date: Sat, 27 Jul 2024 14:28:55 +0100 Subject: [PATCH 067/372] yarn-plugin: implement BackstageResolver#getSatisfying It turns out this method is called for `backstage:` descriptors during `yarn dedupe`, so we need to implement it. Signed-off-by: MT Lewis --- .../src/resolver/BackstageResolver.test.ts | 83 +++++++++++++++++++ .../src/resolver/BackstageResolver.ts | 31 +++++-- 2 files changed, 106 insertions(+), 8 deletions(-) diff --git a/packages/yarn-plugin/src/resolver/BackstageResolver.test.ts b/packages/yarn-plugin/src/resolver/BackstageResolver.test.ts index 4cc0c1c9f2..e404970b23 100644 --- a/packages/yarn-plugin/src/resolver/BackstageResolver.test.ts +++ b/packages/yarn-plugin/src/resolver/BackstageResolver.test.ts @@ -178,4 +178,87 @@ describe('BackstageResolver', () => { ).rejects.toThrow(/invalid backstage version/i); }); }); + + describe('getSatisfying', () => { + it('filters out locators for other packages', async () => { + await expect( + backstageResolver.getSatisfying( + structUtils.makeDescriptor( + structUtils.makeIdent('backstage', 'core'), + 'backstage:1.23.45', + ), + {}, + [ + structUtils.makeLocator( + structUtils.makeIdent('backstage', 'foo'), + 'npm:1.2.3', + ), + structUtils.makeLocator( + structUtils.makeIdent('backstage', 'core'), + 'npm:6.7.8', + ), + structUtils.makeLocator( + structUtils.makeIdent('backstage', 'bar'), + 'npm:1.2.3', + ), + ], + ), + ).resolves.toEqual({ + locators: [ + structUtils.makeLocator( + structUtils.makeIdent('backstage', 'core'), + 'npm:6.7.8', + ), + ], + sorted: true, + }); + }); + + it('filters out locators for other package versions', async () => { + await expect( + backstageResolver.getSatisfying( + structUtils.makeDescriptor( + structUtils.makeIdent('backstage', 'core'), + 'backstage:1.23.45', + ), + {}, + [ + structUtils.makeLocator( + structUtils.makeIdent('backstage', 'core'), + 'npm:5.6.7', + ), + structUtils.makeLocator( + structUtils.makeIdent('backstage', 'core'), + 'npm:6.7.8', + ), + structUtils.makeLocator( + structUtils.makeIdent('backstage', 'bar'), + 'npm:7.8.9', + ), + ], + ), + ).resolves.toEqual({ + locators: [ + structUtils.makeLocator( + structUtils.makeIdent('backstage', 'core'), + 'npm:6.7.8', + ), + ], + sorted: true, + }); + }); + + it('throws for non `backstage:` descriptors', async () => { + await expect( + backstageResolver.getSatisfying( + structUtils.makeDescriptor( + structUtils.makeIdent('backstage', 'core'), + 'npm:1.2.3', + ), + {}, + [], + ), + ).rejects.toThrow(/unexpected npm: range/i); + }); + }); }); diff --git a/packages/yarn-plugin/src/resolver/BackstageResolver.ts b/packages/yarn-plugin/src/resolver/BackstageResolver.ts index 33bba5df53..82e6c013a3 100644 --- a/packages/yarn-plugin/src/resolver/BackstageResolver.ts +++ b/packages/yarn-plugin/src/resolver/BackstageResolver.ts @@ -92,6 +92,29 @@ export class BackstageResolver implements Resolver { ]; } + /** + * Given a descriptor and a list of possible locators, return a filtered list + * containing only locators that satisfy the descriptor. Since each Backstage + * release version corresponds to a single version for each package, we just + * need to filter that array for locators with that exact version. + */ + async getSatisfying( + descriptor: Descriptor, + _dependencies: Record, + locators: Array, + ): Promise<{ locators: Locator[]; sorted: boolean }> { + const packageVersion = await getPackageVersion(descriptor); + + return { + locators: locators.filter( + locator => + structUtils.areIdentsEqual(descriptor, locator) && + locator.reference === `npm:${packageVersion}`, + ), + sorted: true, + }; + } + /** * This plugin does not need to support any locators itself, since the * `getCandidates` method will always convert `backstage:` versions into @@ -106,14 +129,6 @@ export class BackstageResolver implements Resolver { */ getResolutionDependencies = () => ({}); - /** - * Candidate versions produced by this resolver always use the `npm:` - * protocol, so this function will never be called. - */ - async getSatisfying(): Promise<{ locators: Locator[]; sorted: boolean }> { - throw new Error('Unreachable'); - } - /** * Once transformed into locators (through getCandidates), the versions are * resolved by the NpmSemverResolver From bfeba46d96275da65c2fc5c5427f61558c96d4ee Mon Sep 17 00:00:00 2001 From: Andre Wanlin Date: Sun, 28 Jul 2024 13:22:40 -0500 Subject: [PATCH 068/372] Included permission config Signed-off-by: Andre Wanlin --- .changeset/silly-scissors-turn.md | 5 +++++ .../create-app/templates/default-app/app-config.yaml.hbs | 4 ++++ .../templates/default-app/packages/backend/src/index.ts | 1 + 3 files changed, 10 insertions(+) create mode 100644 .changeset/silly-scissors-turn.md diff --git a/.changeset/silly-scissors-turn.md b/.changeset/silly-scissors-turn.md new file mode 100644 index 0000000000..985a6fb4fd --- /dev/null +++ b/.changeset/silly-scissors-turn.md @@ -0,0 +1,5 @@ +--- +'@backstage/create-app': patch +--- + +Included permission config and enabled it out of the box diff --git a/packages/create-app/templates/default-app/app-config.yaml.hbs b/packages/create-app/templates/default-app/app-config.yaml.hbs index f784d5ba88..b16bdb758d 100644 --- a/packages/create-app/templates/default-app/app-config.yaml.hbs +++ b/packages/create-app/templates/default-app/app-config.yaml.hbs @@ -106,3 +106,7 @@ catalog: kubernetes: # see https://backstage.io/docs/features/kubernetes/configuration for kubernetes configuration options + + +permission: + enabled: true \ No newline at end of file diff --git a/packages/create-app/templates/default-app/packages/backend/src/index.ts b/packages/create-app/templates/default-app/packages/backend/src/index.ts index cf2caae72b..f57d4c5f87 100644 --- a/packages/create-app/templates/default-app/packages/backend/src/index.ts +++ b/packages/create-app/templates/default-app/packages/backend/src/index.ts @@ -32,6 +32,7 @@ backend.add(import('@backstage/plugin-catalog-backend-module-logs')); // permission plugin backend.add(import('@backstage/plugin-permission-backend/alpha')); +// See https://backstage.io/docs/permissions/getting-started for how to create your own permission policy backend.add( import('@backstage/plugin-permission-backend-module-allow-all-policy'), ); From 7a6b05f4c93550ae80ffb68f8c2ed7c7275bc02d Mon Sep 17 00:00:00 2001 From: Andre Wanlin Date: Sun, 28 Jul 2024 13:24:01 -0500 Subject: [PATCH 069/372] Added new line Signed-off-by: Andre Wanlin --- packages/create-app/templates/default-app/app-config.yaml.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-app/templates/default-app/app-config.yaml.hbs b/packages/create-app/templates/default-app/app-config.yaml.hbs index b16bdb758d..e4fa1e6f03 100644 --- a/packages/create-app/templates/default-app/app-config.yaml.hbs +++ b/packages/create-app/templates/default-app/app-config.yaml.hbs @@ -109,4 +109,4 @@ kubernetes: permission: - enabled: true \ No newline at end of file + enabled: true From a837ab0d1e14482baa23ab32bdb94f767df1caee Mon Sep 17 00:00:00 2001 From: Andre Wanlin Date: Sun, 28 Jul 2024 13:45:11 -0500 Subject: [PATCH 070/372] Removed extra line Signed-off-by: Andre Wanlin --- packages/create-app/templates/default-app/app-config.yaml.hbs | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/create-app/templates/default-app/app-config.yaml.hbs b/packages/create-app/templates/default-app/app-config.yaml.hbs index e4fa1e6f03..c5aa5fafdb 100644 --- a/packages/create-app/templates/default-app/app-config.yaml.hbs +++ b/packages/create-app/templates/default-app/app-config.yaml.hbs @@ -107,6 +107,5 @@ catalog: kubernetes: # see https://backstage.io/docs/features/kubernetes/configuration for kubernetes configuration options - permission: enabled: true From 496b8a9fd3c8187e4ae0f525a187c60ad0a5b694 Mon Sep 17 00:00:00 2001 From: David Weber Date: Tue, 16 Apr 2024 18:53:13 +0200 Subject: [PATCH 071/372] fix: export `RelatedEntitiesCard` presets Signed-off-by: David Weber Signed-off-by: David Weber --- .changeset/angry-mice-juggle.md | 5 ++++ .../RelatedEntitiesCard.tsx | 27 ++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 .changeset/angry-mice-juggle.md diff --git a/.changeset/angry-mice-juggle.md b/.changeset/angry-mice-juggle.md new file mode 100644 index 0000000000..c5c90b7365 --- /dev/null +++ b/.changeset/angry-mice-juggle.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog': patch +--- + +Export `RelatedEntitiesCard` presets to be reused. diff --git a/plugins/catalog/src/components/RelatedEntitiesCard/RelatedEntitiesCard.tsx b/plugins/catalog/src/components/RelatedEntitiesCard/RelatedEntitiesCard.tsx index dd1359482d..e6e375646d 100644 --- a/plugins/catalog/src/components/RelatedEntitiesCard/RelatedEntitiesCard.tsx +++ b/plugins/catalog/src/components/RelatedEntitiesCard/RelatedEntitiesCard.tsx @@ -31,6 +31,17 @@ import { TableColumn, TableOptions, } from '@backstage/core-components'; +import { + asComponentEntities, + asResourceEntities, + asSystemEntities, + componentEntityColumns, + componentEntityHelpLink, + resourceEntityColumns, + resourceEntityHelpLink, + systemEntityColumns, + systemEntityHelpLink, +} from './presets'; import { catalogTranslationRef } from '../../translation'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; @@ -59,9 +70,9 @@ export type RelatedEntitiesCardProps = { * * @public */ -export function RelatedEntitiesCard( +export const RelatedEntitiesCard = ( props: RelatedEntitiesCardProps, -) { +) => { const { variant = 'gridItem', title, @@ -116,4 +127,14 @@ export function RelatedEntitiesCard( tableOptions={tableOptions} /> ); -} +}; + +RelatedEntitiesCard.componentEntityColumns = componentEntityColumns; +RelatedEntitiesCard.componentEntityHelpLink = componentEntityHelpLink; +RelatedEntitiesCard.asComponentEntities = asComponentEntities; +RelatedEntitiesCard.resourceEntityColumns = resourceEntityColumns; +RelatedEntitiesCard.resourceEntityHelpLink = resourceEntityHelpLink; +RelatedEntitiesCard.asResourceEntities = asResourceEntities; +RelatedEntitiesCard.systemEntityColumns = systemEntityColumns; +RelatedEntitiesCard.systemEntityHelpLink = systemEntityHelpLink; +RelatedEntitiesCard.asSystemEntities = asSystemEntities; From 658279973ecc56b36df752c3afebde698c04e485 Mon Sep 17 00:00:00 2001 From: David Weber Date: Mon, 8 Jul 2024 17:35:59 +0200 Subject: [PATCH 072/372] feat: provide table options everywhere and add title to api tables Signed-off-by: David Weber Signed-off-by: David Weber --- .changeset/weak-jobs-joke.md | 6 ++++++ plugins/api-docs/api-report.md | 13 ++++++++++++ .../components/ApisCards/ConsumedApisCard.tsx | 17 ++++++++++++---- .../src/components/ApisCards/HasApisCard.tsx | 17 ++++++++++++---- .../components/ApisCards/ProvidedApisCard.tsx | 17 ++++++++++++---- plugins/catalog/api-report.md | 19 ++++++++++++++++++ .../DependencyOfComponentsCard.tsx | 18 ++++++++++++++--- .../HasComponentsCard/HasComponentsCard.tsx | 20 +++++++++++++++---- .../HasResourcesCard/HasResourcesCard.tsx | 20 +++++++++++++++---- .../HasSubcomponentsCard.tsx | 16 ++++++++++----- .../HasSystemsCard/HasSystemsCard.tsx | 20 +++++++++++++++---- 11 files changed, 151 insertions(+), 32 deletions(-) create mode 100644 .changeset/weak-jobs-joke.md diff --git a/.changeset/weak-jobs-joke.md b/.changeset/weak-jobs-joke.md new file mode 100644 index 0000000000..8127605f07 --- /dev/null +++ b/.changeset/weak-jobs-joke.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-api-docs': patch +'@backstage/plugin-catalog': patch +--- + +Add `tableOptions` to all tables and additionally `title` to API tables. diff --git a/plugins/api-docs/api-report.md b/plugins/api-docs/api-report.md index 2fc852777b..0fd35bdaa0 100644 --- a/plugins/api-docs/api-report.md +++ b/plugins/api-docs/api-report.md @@ -16,6 +16,7 @@ import { JSX as JSX_2 } from 'react'; import { default as React_2 } from 'react'; import { RouteRef } from '@backstage/core-plugin-api'; import { TableColumn } from '@backstage/core-components'; +import { TableOptions } from '@backstage/core-components'; import { TableProps } from '@backstage/core-components'; import { UserListFilterKind } from '@backstage/plugin-catalog-react'; @@ -88,7 +89,9 @@ export type AsyncApiDefinitionWidgetProps = { // @public (undocumented) export const ConsumedApisCard: (props: { variant?: InfoCardVariants; + title?: string; columns?: TableColumn[]; + tableOptions?: TableOptions; }) => React_2.JSX.Element; // @public (undocumented) @@ -118,7 +121,9 @@ export const EntityApiDefinitionCard: () => JSX_2.Element; // @public (undocumented) export const EntityConsumedApisCard: (props: { variant?: InfoCardVariants | undefined; + title?: string | undefined; columns?: TableColumn[] | undefined; + tableOptions?: TableOptions<{}> | undefined; }) => JSX_2.Element; // @public (undocumented) @@ -129,13 +134,17 @@ export const EntityConsumingComponentsCard: (props: { // @public (undocumented) export const EntityHasApisCard: (props: { variant?: InfoCardVariants | undefined; + title?: string | undefined; columns?: TableColumn[] | undefined; + tableOptions?: TableOptions<{}> | undefined; }) => JSX_2.Element; // @public (undocumented) export const EntityProvidedApisCard: (props: { variant?: InfoCardVariants | undefined; + title?: string | undefined; columns?: TableColumn[] | undefined; + tableOptions?: TableOptions<{}> | undefined; }) => JSX_2.Element; // @public (undocumented) @@ -156,7 +165,9 @@ export type GraphQlDefinitionWidgetProps = { // @public (undocumented) export const HasApisCard: (props: { variant?: InfoCardVariants; + title?: string; columns?: TableColumn[]; + tableOptions?: TableOptions; }) => React_2.JSX.Element; // @public (undocumented) @@ -185,7 +196,9 @@ export type PlainApiDefinitionWidgetProps = { // @public (undocumented) export const ProvidedApisCard: (props: { variant?: InfoCardVariants; + title?: string; columns?: TableColumn[]; + tableOptions?: TableOptions; }) => React_2.JSX.Element; // @public (undocumented) diff --git a/plugins/api-docs/src/components/ApisCards/ConsumedApisCard.tsx b/plugins/api-docs/src/components/ApisCards/ConsumedApisCard.tsx index d5494d1818..f68e6dcb40 100644 --- a/plugins/api-docs/src/components/ApisCards/ConsumedApisCard.tsx +++ b/plugins/api-docs/src/components/ApisCards/ConsumedApisCard.tsx @@ -30,6 +30,7 @@ import { Link, Progress, TableColumn, + TableOptions, WarningPanel, } from '@backstage/core-components'; @@ -38,9 +39,16 @@ import { */ export const ConsumedApisCard = (props: { variant?: InfoCardVariants; + title?: string; columns?: TableColumn[]; + tableOptions?: TableOptions; }) => { - const { variant = 'gridItem', columns = apiEntityColumns } = props; + const { + variant = 'gridItem', + title = 'Consumed APIs', + columns = apiEntityColumns, + tableOptions = {}, + } = props; const { entity } = useEntity(); const { entities, loading, error } = useRelatedEntities(entity, { type: RELATION_CONSUMES_API, @@ -48,7 +56,7 @@ export const ConsumedApisCard = (props: { if (loading) { return ( - + ); @@ -56,7 +64,7 @@ export const ConsumedApisCard = (props: { if (error || !entities) { return ( - + @@ -84,6 +92,7 @@ export const ConsumedApisCard = (props: {
} columns={columns} + tableOptions={tableOptions} entities={entities as ApiEntity[]} /> ); diff --git a/plugins/api-docs/src/components/ApisCards/HasApisCard.tsx b/plugins/api-docs/src/components/ApisCards/HasApisCard.tsx index d58a654176..6810d9d2ba 100644 --- a/plugins/api-docs/src/components/ApisCards/HasApisCard.tsx +++ b/plugins/api-docs/src/components/ApisCards/HasApisCard.tsx @@ -30,6 +30,7 @@ import { Link, Progress, TableColumn, + TableOptions, WarningPanel, } from '@backstage/core-components'; @@ -46,9 +47,16 @@ const presetColumns: TableColumn[] = [ */ export const HasApisCard = (props: { variant?: InfoCardVariants; + title?: string; columns?: TableColumn[]; + tableOptions?: TableOptions; }) => { - const { variant = 'gridItem', columns = presetColumns } = props; + const { + variant = 'gridItem', + title = 'APIs', + columns = presetColumns, + tableOptions = {}, + } = props; const { entity } = useEntity(); const { entities, loading, error } = useRelatedEntities(entity, { type: RELATION_HAS_PART, @@ -57,7 +65,7 @@ export const HasApisCard = (props: { if (loading) { return ( - + ); @@ -65,7 +73,7 @@ export const HasApisCard = (props: { if (error || !entities) { return ( - + @@ -93,6 +101,7 @@ export const HasApisCard = (props: { } columns={columns} + tableOptions={tableOptions} entities={entities as ApiEntity[]} /> ); diff --git a/plugins/api-docs/src/components/ApisCards/ProvidedApisCard.tsx b/plugins/api-docs/src/components/ApisCards/ProvidedApisCard.tsx index 97d0a00b0a..48099df375 100644 --- a/plugins/api-docs/src/components/ApisCards/ProvidedApisCard.tsx +++ b/plugins/api-docs/src/components/ApisCards/ProvidedApisCard.tsx @@ -30,6 +30,7 @@ import { Link, Progress, TableColumn, + TableOptions, WarningPanel, } from '@backstage/core-components'; @@ -38,9 +39,16 @@ import { */ export const ProvidedApisCard = (props: { variant?: InfoCardVariants; + title?: string; columns?: TableColumn[]; + tableOptions?: TableOptions; }) => { - const { variant = 'gridItem', columns = apiEntityColumns } = props; + const { + variant = 'gridItem', + title = 'Provided APIs', + columns = apiEntityColumns, + tableOptions = {}, + } = props; const { entity } = useEntity(); const { entities, loading, error } = useRelatedEntities(entity, { type: RELATION_PROVIDES_API, @@ -48,7 +56,7 @@ export const ProvidedApisCard = (props: { if (loading) { return ( - + ); @@ -56,7 +64,7 @@ export const ProvidedApisCard = (props: { if (error || !entities) { return ( - + @@ -84,6 +92,7 @@ export const ProvidedApisCard = (props: { } columns={columns} + tableOptions={tableOptions} entities={entities as ApiEntity[]} /> ); diff --git a/plugins/catalog/api-report.md b/plugins/catalog/api-report.md index c1fb52fb94..e705126b7d 100644 --- a/plugins/catalog/api-report.md +++ b/plugins/catalog/api-report.md @@ -33,6 +33,7 @@ import { SearchResultListItemExtensionProps } from '@backstage/plugin-search-rea import { StarredEntitiesApi } from '@backstage/plugin-catalog-react'; import { StorageApi } from '@backstage/core-plugin-api'; import { StyleRules } from '@material-ui/core/styles/withStyles'; +import { SystemEntity } from '@backstage/catalog-model'; import { TableColumn } from '@backstage/core-components'; import { TableOptions } from '@backstage/core-components'; import { TableProps } from '@backstage/core-components'; @@ -304,6 +305,10 @@ export class DefaultStarredEntitiesApi implements StarredEntitiesApi { // @public (undocumented) export interface DependencyOfComponentsCardProps { + // (undocumented) + columns?: TableColumn[]; + // (undocumented) + tableOptions?: TableOptions; // (undocumented) title?: string; // (undocumented) @@ -516,6 +521,10 @@ export function hasCatalogProcessingErrors( // @public (undocumented) export interface HasComponentsCardProps { + // (undocumented) + columns?: TableColumn[]; + // (undocumented) + tableOptions?: TableOptions; // (undocumented) title?: string; // (undocumented) @@ -535,6 +544,10 @@ export function hasRelationWarnings( // @public (undocumented) export interface HasResourcesCardProps { + // (undocumented) + columns?: TableColumn[]; + // (undocumented) + tableOptions?: TableOptions; // (undocumented) title?: string; // (undocumented) @@ -543,6 +556,8 @@ export interface HasResourcesCardProps { // @public (undocumented) export interface HasSubcomponentsCardProps { + // (undocumented) + columns?: TableColumn[]; // (undocumented) tableOptions?: TableOptions; // (undocumented) @@ -553,6 +568,10 @@ export interface HasSubcomponentsCardProps { // @public (undocumented) export interface HasSystemsCardProps { + // (undocumented) + columns?: TableColumn[]; + // (undocumented) + tableOptions?: TableOptions; // (undocumented) title?: string; // (undocumented) diff --git a/plugins/catalog/src/components/DependencyOfComponentsCard/DependencyOfComponentsCard.tsx b/plugins/catalog/src/components/DependencyOfComponentsCard/DependencyOfComponentsCard.tsx index 617d009d4f..2f0557d11e 100644 --- a/plugins/catalog/src/components/DependencyOfComponentsCard/DependencyOfComponentsCard.tsx +++ b/plugins/catalog/src/components/DependencyOfComponentsCard/DependencyOfComponentsCard.tsx @@ -14,8 +14,15 @@ * limitations under the License. */ -import { RELATION_DEPENDENCY_OF } from '@backstage/catalog-model'; -import { InfoCardVariants } from '@backstage/core-components'; +import { + ComponentEntity, + RELATION_DEPENDENCY_OF, +} from '@backstage/catalog-model'; +import { + InfoCardVariants, + TableColumn, + TableOptions, +} from '@backstage/core-components'; import React from 'react'; import { asComponentEntities, @@ -30,6 +37,8 @@ import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; export interface DependencyOfComponentsCardProps { variant?: InfoCardVariants; title?: string; + columns?: TableColumn[]; + tableOptions?: TableOptions; } export function DependencyOfComponentsCard( @@ -39,6 +48,8 @@ export function DependencyOfComponentsCard( const { variant = 'gridItem', title = t('dependencyOfComponentsCard.title'), + columns = componentEntityColumns, + tableOptions = {}, } = props; return ( ); } diff --git a/plugins/catalog/src/components/HasComponentsCard/HasComponentsCard.tsx b/plugins/catalog/src/components/HasComponentsCard/HasComponentsCard.tsx index 917543dd12..13a9e75928 100644 --- a/plugins/catalog/src/components/HasComponentsCard/HasComponentsCard.tsx +++ b/plugins/catalog/src/components/HasComponentsCard/HasComponentsCard.tsx @@ -14,8 +14,12 @@ * limitations under the License. */ -import { RELATION_HAS_PART } from '@backstage/catalog-model'; -import { InfoCardVariants } from '@backstage/core-components'; +import { ComponentEntity, RELATION_HAS_PART } from '@backstage/catalog-model'; +import { + InfoCardVariants, + TableColumn, + TableOptions, +} from '@backstage/core-components'; import React from 'react'; import { asComponentEntities, @@ -30,21 +34,29 @@ import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; export interface HasComponentsCardProps { variant?: InfoCardVariants; title?: string; + columns?: TableColumn[]; + tableOptions?: TableOptions; } export function HasComponentsCard(props: HasComponentsCardProps) { const { t } = useTranslationRef(catalogTranslationRef); - const { variant = 'gridItem', title = t('hasComponentsCard.title') } = props; + const { + variant = 'gridItem', + title = t('hasComponentsCard.title'), + columns = componentEntityColumns, + tableOptions = {}, + } = props; return ( ); } diff --git a/plugins/catalog/src/components/HasResourcesCard/HasResourcesCard.tsx b/plugins/catalog/src/components/HasResourcesCard/HasResourcesCard.tsx index d11f10c882..b99bca1716 100644 --- a/plugins/catalog/src/components/HasResourcesCard/HasResourcesCard.tsx +++ b/plugins/catalog/src/components/HasResourcesCard/HasResourcesCard.tsx @@ -14,8 +14,12 @@ * limitations under the License. */ -import { RELATION_HAS_PART } from '@backstage/catalog-model'; -import { InfoCardVariants } from '@backstage/core-components'; +import { RELATION_HAS_PART, ResourceEntity } from '@backstage/catalog-model'; +import { + InfoCardVariants, + TableColumn, + TableOptions, +} from '@backstage/core-components'; import React from 'react'; import { asResourceEntities, @@ -30,21 +34,29 @@ import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; export interface HasResourcesCardProps { variant?: InfoCardVariants; title?: string; + columns?: TableColumn[]; + tableOptions?: TableOptions; } export function HasResourcesCard(props: HasResourcesCardProps) { const { t } = useTranslationRef(catalogTranslationRef); - const { variant = 'gridItem', title = t('hasResourcesCard.title') } = props; + const { + variant = 'gridItem', + title = t('hasResourcesCard.title'), + columns = resourceEntityColumns, + tableOptions = {}, + } = props; return ( ); } diff --git a/plugins/catalog/src/components/HasSubcomponentsCard/HasSubcomponentsCard.tsx b/plugins/catalog/src/components/HasSubcomponentsCard/HasSubcomponentsCard.tsx index d81349794a..ceea839ef4 100644 --- a/plugins/catalog/src/components/HasSubcomponentsCard/HasSubcomponentsCard.tsx +++ b/plugins/catalog/src/components/HasSubcomponentsCard/HasSubcomponentsCard.tsx @@ -14,8 +14,12 @@ * limitations under the License. */ -import { RELATION_HAS_PART } from '@backstage/catalog-model'; -import { InfoCardVariants, TableOptions } from '@backstage/core-components'; +import { ComponentEntity, RELATION_HAS_PART } from '@backstage/catalog-model'; +import { + InfoCardVariants, + TableColumn, + TableOptions, +} from '@backstage/core-components'; import React from 'react'; import { asComponentEntities, @@ -28,16 +32,18 @@ import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; /** @public */ export interface HasSubcomponentsCardProps { variant?: InfoCardVariants; - tableOptions?: TableOptions; title?: string; + columns?: TableColumn[]; + tableOptions?: TableOptions; } export function HasSubcomponentsCard(props: HasSubcomponentsCardProps) { const { t } = useTranslationRef(catalogTranslationRef); const { variant = 'gridItem', - tableOptions = {}, title = t('hasSubcomponentsCard.title'), + columns = componentEntityColumns, + tableOptions = {}, } = props; return ( []; + tableOptions?: TableOptions; } export function HasSystemsCard(props: HasSystemsCardProps) { const { t } = useTranslationRef(catalogTranslationRef); - const { variant = 'gridItem', title = t('hasSystemsCard.title') } = props; + const { + variant = 'gridItem', + title = t('hasSystemsCard.title'), + columns = systemEntityColumns, + tableOptions = {}, + } = props; return ( ); } From a7504f40673723625daf4ed38b818ea5be36a3c2 Mon Sep 17 00:00:00 2001 From: David Weber Date: Mon, 29 Jul 2024 02:20:29 +0200 Subject: [PATCH 073/372] chore: add simple icons plugin Signed-off-by: David Weber Signed-off-by: David Weber --- microsite/data/plugins/simple-icons.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 microsite/data/plugins/simple-icons.yaml diff --git a/microsite/data/plugins/simple-icons.yaml b/microsite/data/plugins/simple-icons.yaml new file mode 100644 index 0000000000..45722ab421 --- /dev/null +++ b/microsite/data/plugins/simple-icons.yaml @@ -0,0 +1,10 @@ +--- +title: Simple Icons +author: dweber019 +authorUrl: https://github.com/dweber019 +category: Visualization +description: The Simple Icons plugin will add additional icons to be used as link icons. +documentation: https://github.com/dweber019/backstage-plugins/tree/main/plugins/simple-icons +iconUrl: https://raw.githubusercontent.com/dweber019/backstage-plugins/main/plugins/simple-icons/docs/pluginIcon.png +npmPackageName: '@dweber019/backstage-plugin-simple-icons' +addedDate: '2024-07-30' From b76e877bcf2de9ffcea62d5b49183587ce6b0aed Mon Sep 17 00:00:00 2001 From: Evan Kelly Date: Tue, 18 Jun 2024 14:40:41 +0100 Subject: [PATCH 074/372] added script for datadog script to docs Signed-off-by: Evan Kelly --- docs/integrations/datadog-rum/installation.md | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/docs/integrations/datadog-rum/installation.md b/docs/integrations/datadog-rum/installation.md index 4dc6c24134..b5f2a494c9 100644 --- a/docs/integrations/datadog-rum/installation.md +++ b/docs/integrations/datadog-rum/installation.md @@ -36,3 +36,48 @@ There are two optional arguments: - `site`: The Datadog site of your organization; defaults to `datadoghq.com` - `env`: The application environment for Datadog events (no default) + +## Script to fix Datadog RUM not Publishing Issue + +Copy and paste this section to your `packages/app/public/index.html` + +``` +<% if (config.has('app.datadogRum')) { %> + + <% } %> +``` From 09d7e3f1d9d813655b286c280bb80044946d870a Mon Sep 17 00:00:00 2001 From: Evan Kelly Date: Wed, 26 Jun 2024 14:14:09 +0100 Subject: [PATCH 075/372] run prettier check Signed-off-by: Evan Kelly --- docs/integrations/datadog-rum/installation.md | 76 +++++++++---------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/docs/integrations/datadog-rum/installation.md b/docs/integrations/datadog-rum/installation.md index b5f2a494c9..1301f111f7 100644 --- a/docs/integrations/datadog-rum/installation.md +++ b/docs/integrations/datadog-rum/installation.md @@ -42,42 +42,42 @@ There are two optional arguments: Copy and paste this section to your `packages/app/public/index.html` ``` -<% if (config.has('app.datadogRum')) { %> - - <% } %> +<% if (config.has('app.datadogRum')) { %> + + <% } %> ``` From 51bf5fa47d87b8ca76c5fa9469b1362c065bb8d0 Mon Sep 17 00:00:00 2001 From: Evan Kelly Date: Tue, 2 Jul 2024 10:53:39 +0100 Subject: [PATCH 076/372] make change suggested in pr Signed-off-by: Evan Kelly --- docs/integrations/datadog-rum/installation.md | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/docs/integrations/datadog-rum/installation.md b/docs/integrations/datadog-rum/installation.md index 1301f111f7..f636b100a1 100644 --- a/docs/integrations/datadog-rum/installation.md +++ b/docs/integrations/datadog-rum/installation.md @@ -26,20 +26,7 @@ app: # sessionReplaySampleRate: 0 ``` -If your [`app-config.yaml`](https://github.com/backstage/backstage/blob/e0506af8fc54074a160fb91c83d6cae8172d3bb3/app-config.yaml#L5) file does not have this configuration, you may have to adjust your [`packages/app/public/index.html`](https://github.com/backstage/backstage/blob/e0506af8fc54074a160fb91c83d6cae8172d3bb3/packages/app/public/index.html#L69) to include the Datadog RUM `init()` section manually. - -The `clientToken` and `applicationId` are generated from the Datadog RUM page -following -[these instructions](https://docs.datadoghq.com/real_user_monitoring/browser/). - -There are two optional arguments: - -- `site`: The Datadog site of your organization; defaults to `datadoghq.com` -- `env`: The application environment for Datadog events (no default) - -## Script to fix Datadog RUM not Publishing Issue - -Copy and paste this section to your `packages/app/public/index.html` +If your [`app-config.yaml`](https://github.com/backstage/backstage/blob/e0506af8fc54074a160fb91c83d6cae8172d3bb3/app-config.yaml#L5) file does not have this configuration, you may have to adjust your [`packages/app/public/index.html`](https://github.com/backstage/backstage/blob/e0506af8fc54074a160fb91c83d6cae8172d3bb3/packages/app/public/index.html#L69) to include the Datadog RUM `init()` section manually. If you a Datadog not publishing issue copy and paste this section in to your `packages/app/public/index.html` ``` <% if (config.has('app.datadogRum')) { %> @@ -81,3 +68,12 @@ Copy and paste this section to your `packages/app/public/index.html` <% } %> ``` + +The `clientToken` and `applicationId` are generated from the Datadog RUM page +following +[these instructions](https://docs.datadoghq.com/real_user_monitoring/browser/). + +There are two optional arguments: + +- `site`: The Datadog site of your organization; defaults to `datadoghq.com` +- `env`: The application environment for Datadog events (no default) From 100ecdcb947e18d015ce26312da55c48b9196f53 Mon Sep 17 00:00:00 2001 From: Evan Kelly Date: Wed, 10 Jul 2024 08:07:38 +0100 Subject: [PATCH 077/372] changes for comments on pr Signed-off-by: Evan Kelly --- docs/integrations/datadog-rum/installation.md | 80 ++++++++++--------- 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/docs/integrations/datadog-rum/installation.md b/docs/integrations/datadog-rum/installation.md index f636b100a1..5afd05d6cb 100644 --- a/docs/integrations/datadog-rum/installation.md +++ b/docs/integrations/datadog-rum/installation.md @@ -26,47 +26,49 @@ app: # sessionReplaySampleRate: 0 ``` -If your [`app-config.yaml`](https://github.com/backstage/backstage/blob/e0506af8fc54074a160fb91c83d6cae8172d3bb3/app-config.yaml#L5) file does not have this configuration, you may have to adjust your [`packages/app/public/index.html`](https://github.com/backstage/backstage/blob/e0506af8fc54074a160fb91c83d6cae8172d3bb3/packages/app/public/index.html#L69) to include the Datadog RUM `init()` section manually. If you a Datadog not publishing issue copy and paste this section in to your `packages/app/public/index.html` +If your [`app-config.yaml`](https://github.com/backstage/backstage/blob/e0506af8fc54074a160fb91c83d6cae8172d3bb3/app-config.yaml#L5) file does not have this configuration, you may have to adjust your [`packages/app/public/index.html`](https://github.com/backstage/backstage/blob/e0506af8fc54074a160fb91c83d6cae8172d3bb3/packages/app/public/index.html#L69) to include the Datadog RUM `init()` section manually. -``` +:::note +In case after a proper configuration, the events still arent being capture copy and paste this section in to your `packages/app/public/index.html` under the `` tag. + +```html <% if (config.has('app.datadogRum')) { %> - - <% } %> + +<% } %> ``` The `clientToken` and `applicationId` are generated from the Datadog RUM page From 3f88be264f8fe1027a438d96772fdbb987b84b54 Mon Sep 17 00:00:00 2001 From: "Kelly, Evan" Date: Fri, 12 Jul 2024 09:31:01 +0100 Subject: [PATCH 078/372] Update installation.md Signed-off-by: Kelly, Evan Signed-off-by: Evan Kelly --- docs/integrations/datadog-rum/installation.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/integrations/datadog-rum/installation.md b/docs/integrations/datadog-rum/installation.md index 5afd05d6cb..414317d593 100644 --- a/docs/integrations/datadog-rum/installation.md +++ b/docs/integrations/datadog-rum/installation.md @@ -28,6 +28,8 @@ app: If your [`app-config.yaml`](https://github.com/backstage/backstage/blob/e0506af8fc54074a160fb91c83d6cae8172d3bb3/app-config.yaml#L5) file does not have this configuration, you may have to adjust your [`packages/app/public/index.html`](https://github.com/backstage/backstage/blob/e0506af8fc54074a160fb91c83d6cae8172d3bb3/packages/app/public/index.html#L69) to include the Datadog RUM `init()` section manually. +Please note, there's a bug where env value MUST be specified at build time + :::note In case after a proper configuration, the events still arent being capture copy and paste this section in to your `packages/app/public/index.html` under the `` tag. From 612817b0ce5cd945cc7a9ca16a73f478d8aa296c Mon Sep 17 00:00:00 2001 From: Andre Wanlin Date: Mon, 29 Jul 2024 07:23:59 -0500 Subject: [PATCH 079/372] Added notes based on feedback Signed-off-by: Andre Wanlin --- packages/create-app/templates/default-app/app-config.yaml.hbs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/create-app/templates/default-app/app-config.yaml.hbs b/packages/create-app/templates/default-app/app-config.yaml.hbs index c5aa5fafdb..ca52ec530c 100644 --- a/packages/create-app/templates/default-app/app-config.yaml.hbs +++ b/packages/create-app/templates/default-app/app-config.yaml.hbs @@ -107,5 +107,7 @@ catalog: kubernetes: # see https://backstage.io/docs/features/kubernetes/configuration for kubernetes configuration options +# see https://backstage.io/docs/permissions/getting-started for more on the permission framework permission: + # setting this to `false` will disable permissions enabled: true From 6d4cb97f071c17ccd285d83c6a34e938ec77c745 Mon Sep 17 00:00:00 2001 From: parmar-abhinav Date: Tue, 30 Jul 2024 12:41:44 +0530 Subject: [PATCH 080/372] Added examples for github:repo:create action and improved test cases Signed-off-by: parmar-abhinav --- .changeset/itchy-experts-tie.md | 5 + .../actions/githubRepoCreate.examples.test.ts | 2215 +++++++++++++++++ .../src/actions/githubRepoCreate.examples.ts | 928 +++++++ 3 files changed, 3148 insertions(+) create mode 100644 .changeset/itchy-experts-tie.md diff --git a/.changeset/itchy-experts-tie.md b/.changeset/itchy-experts-tie.md new file mode 100644 index 0000000000..c5bf99ecaf --- /dev/null +++ b/.changeset/itchy-experts-tie.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend-module-github': patch +--- + +Added examples for github:repo:create action and improved test cases diff --git a/plugins/scaffolder-backend-module-github/src/actions/githubRepoCreate.examples.test.ts b/plugins/scaffolder-backend-module-github/src/actions/githubRepoCreate.examples.test.ts index 843a32f758..1a81a54c64 100644 --- a/plugins/scaffolder-backend-module-github/src/actions/githubRepoCreate.examples.test.ts +++ b/plugins/scaffolder-backend-module-github/src/actions/githubRepoCreate.examples.test.ts @@ -58,6 +58,7 @@ const mockOctokit = { getRepoPublicKey: jest.fn(), }, }, + request: jest.fn().mockResolvedValue({}), }; jest.mock('octokit', () => ({ Octokit: class { @@ -188,4 +189,2218 @@ describe('github:repo:create examples', () => { has_wiki: false, // disable wiki }); }); + + it(`Should ${examples[3].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[3].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: 'https://example.com', + }); + }); + + it(`Should ${examples[4].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[4].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[5].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[5].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[6].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[6].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[7].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[7].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: false, + allow_rebase_merge: false, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[8].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[8].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'pull_request_title', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[9].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[9].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'blank', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[10].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[10].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: true, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[11].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[11].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[12].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[12].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[13].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[13].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[14].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[14].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[15].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[15].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[16].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[16].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[17].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[17].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: true, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[18].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[18].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[19].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[19].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[20].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[20].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: false, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'internal', + has_issues: undefined, + description: 'A repository for project XYZ', + has_projects: undefined, + has_wiki: undefined, + homepage: 'https://project-xyz.com', + }); + }); + + it(`Should ${examples[21].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[21].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[22].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[22].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[23].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[23].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: true, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[24].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[24].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: false, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[25].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[25].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: false, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'internal', + has_issues: false, + description: undefined, + has_projects: false, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[26].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[26].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[27].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[27].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[28].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[28].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: 'Repository for project ABC', + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[29].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[29].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: false, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'public', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[30].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[30].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[31].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[31].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[32].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[32].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[33].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[33].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[34].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[34].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: false, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'internal', + has_issues: undefined, + description: 'Internal repository for team collaboration', + has_projects: undefined, + has_wiki: undefined, + homepage: 'https://internal.example.com', + }); + }); + + it(`Should ${examples[35].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[35].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[36].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[36].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: true, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[37].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[37].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[38].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[38].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[39].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[39].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: false, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'internal', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[40].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[40].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: 'Repository for web application project', + has_projects: undefined, + has_wiki: undefined, + homepage: 'https://webapp.example.com', + }); + }); + + it(`Should ${examples[41].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[41].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'pull_request_description', + allow_merge_commit: false, + allow_rebase_merge: false, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[42].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[42].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: false, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: false, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[43].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[43].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[44].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[44].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[45].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[45].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: false, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'public', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[46].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[46].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: false, + description: 'Repository for backend service', + has_projects: undefined, + has_wiki: false, + homepage: undefined, + }); + }); + + it(`Should ${examples[47].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[47].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[48].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[48].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[49].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[49].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[50].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[50].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: false, + allow_rebase_merge: true, + allow_auto_merge: true, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[51].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[51].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: 'https://example.com', + }); + }); + + it(`Should ${examples[52].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[52].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: 'Repository for microservice development', + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[53].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[53].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[54].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[54].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: true, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[55].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[55].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); + + it(`Should ${examples[56].description}`, async () => { + mockOctokit.rest.users.getByUsername.mockResolvedValue({ + data: { type: 'Organization' }, + }); + + mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} }); + + let input; + try { + input = yaml.parse(examples[56].example).steps[0].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + ...input, + }, + }); + + expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({ + name: 'repo', + org: 'owner', + private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + squash_merge_commit_title: 'COMMIT_OR_PR_TITLE', + squash_merge_commit_message: 'COMMIT_MESSAGES', + allow_merge_commit: true, + allow_rebase_merge: true, + allow_auto_merge: false, + visibility: 'private', + has_issues: undefined, + description: undefined, + has_projects: undefined, + has_wiki: undefined, + homepage: undefined, + }); + }); }); diff --git a/plugins/scaffolder-backend-module-github/src/actions/githubRepoCreate.examples.ts b/plugins/scaffolder-backend-module-github/src/actions/githubRepoCreate.examples.ts index a58da1ee29..1c1f1ca5d2 100644 --- a/plugins/scaffolder-backend-module-github/src/actions/githubRepoCreate.examples.ts +++ b/plugins/scaffolder-backend-module-github/src/actions/githubRepoCreate.examples.ts @@ -63,4 +63,932 @@ export const examples: TemplateExample[] = [ ], }), }, + { + description: 'Set repository homepage.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with homepage', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + homepage: 'https://example.com', + }, + }, + ], + }), + }, + { + description: 'Create a private repository.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new private GitHub repository', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + repoVisibility: 'private', + }, + }, + ], + }), + }, + { + description: 'Enable required code owner reviews.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with required code owner reviews', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + requireCodeOwnerReviews: true, + }, + }, + ], + }), + }, + { + description: 'Set required approving review count to 2.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with required approving review count', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + requiredApprovingReviewCount: 2, + }, + }, + ], + }), + }, + { + description: 'Allow squash merge only.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository allowing only squash merge', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + allowMergeCommit: false, + allowSquashMerge: true, + allowRebaseMerge: false, + }, + }, + ], + }), + }, + { + description: 'Set squash merge commit title to pull request title.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with squash merge commit title set to pull request title', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + squashMergeCommitTitle: 'pull_request_title', + }, + }, + ], + }), + }, + { + description: 'Set squash merge commit message to blank.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with squash merge commit message set to blank', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + squashMergeCommitMessage: 'blank', + }, + }, + ], + }), + }, + { + description: 'Allow auto-merge.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository allowing auto-merge', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + allowAutoMerge: true, + }, + }, + ], + }), + }, + { + description: 'Set collaborators with push access.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with collaborators having push access', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + collaborators: [ + { username: 'user1', permission: 'push' }, + { username: 'user2', permission: 'push' }, + ], + }, + }, + ], + }), + }, + { + description: 'Add topics to repository.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with topics', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + topics: ['devops', 'kubernetes', 'ci-cd'], + }, + }, + ], + }), + }, + { + description: 'Add secret variables to repository.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with secret variables', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + secrets: [ + { name: 'SECRET_KEY', value: 'supersecretkey' }, + { name: 'API_TOKEN', value: 'tokenvalue' }, + ], + }, + }, + ], + }), + }, + { + description: 'Enable branch protection requiring status checks.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with branch protection requiring status checks', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + requiredStatusCheckContexts: ['ci/circleci: build'], + }, + }, + ], + }), + }, + { + description: 'Require branches to be up-to-date before merging.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository requiring branches to be up-to-date before merging', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + requireBranchesToBeUpToDate: true, + }, + }, + ], + }), + }, + { + description: 'Require conversation resolution before merging.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository requiring conversation resolution before merging', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + requiredConversationResolution: true, + }, + }, + ], + }), + }, + { + description: 'Delete branch on merge.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with branch deletion on merge', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + deleteBranchOnMerge: true, + }, + }, + ], + }), + }, + { + description: 'Customize OIDC token.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with OIDC token customization', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + oidcCustomization: { + sub: 'repo:owner/repo', + aud: 'https://github.com', + }, + }, + }, + ], + }), + }, + { + description: 'Require commit signing.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository requiring commit signing', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + requiredCommitSigning: true, + }, + }, + ], + }), + }, + { + description: + 'Set multiple properties including description, homepage, and visibility.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with multiple properties', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + description: 'A repository for project XYZ', + homepage: 'https://project-xyz.com', + repoVisibility: 'internal', + }, + }, + ], + }), + }, + { + description: 'Configure branch protection with multiple settings.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with branch protection settings', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + requiredStatusCheckContexts: [ + 'ci/circleci: build', + 'ci/circleci: test', + ], + requireBranchesToBeUpToDate: true, + requiredConversationResolution: true, + requiredApprovingReviewCount: 2, + }, + }, + ], + }), + }, + { + description: + 'Set repository access to private and add collaborators with admin access.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new private GitHub repository with collaborators', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + repoVisibility: 'private', + collaborators: [ + { username: 'admin1', permission: 'admin' }, + { username: 'admin2', permission: 'admin' }, + ], + }, + }, + ], + }), + }, + { + description: 'Enable GitHub Projects for the repository.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with GitHub Projects enabled', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + hasProjects: true, + }, + }, + ], + }), + }, + { + description: + 'Disable merge commits and allow only rebase and squash merges.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository allowing only rebase and squash merges', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + allowMergeCommit: false, + allowRebaseMerge: true, + allowSquashMerge: true, + }, + }, + ], + }), + }, + { + description: + 'Set repository access to internal with no projects and issues.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new internal GitHub repository without projects and issues', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + repoVisibility: 'internal', + hasProjects: false, + hasIssues: false, + }, + }, + ], + }), + }, + { + description: + 'Create repository with OIDC customization for specific audience.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with OIDC customization for specific audience', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + oidcCustomization: { + sub: 'repo:owner/repo', + aud: 'https://specific-audience.com', + }, + }, + }, + ], + }), + }, + { + description: 'Require all branches to be up-to-date before merging.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository requiring all branches to be up-to-date', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + requireBranchesToBeUpToDate: true, + }, + }, + ], + }), + }, + { + description: 'Set description and topics for the repository.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with description and topics', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + description: 'Repository for project ABC', + topics: ['python', 'machine-learning', 'data-science'], + }, + }, + ], + }), + }, + { + description: + 'Set repository visibility to public and enable commit signing.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new public GitHub repository with commit signing required', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + repoVisibility: 'public', + requiredCommitSigning: true, + }, + }, + ], + }), + }, + { + description: + 'Create a repository with collaborators and default branch protection.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with collaborators and branch protection', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + collaborators: [ + { username: 'contributor1', permission: 'write' }, + { username: 'contributor2', permission: 'write' }, + ], + requiredStatusCheckContexts: ['ci/travis: build'], + }, + }, + ], + }), + }, + { + description: 'Add multiple secret variables.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with multiple secret variables', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + secrets: [ + { name: 'SECRET_KEY_1', value: 'value1' }, + { name: 'SECRET_KEY_2', value: 'value2' }, + ], + }, + }, + ], + }), + }, + { + description: 'Require a minimum of 2 approving reviews for merging.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with 2 required approving reviews', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + requiredApprovingReviewCount: 2, + }, + }, + ], + }), + }, + { + description: + 'Enable branch protection with conversation resolution required.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with branch protection and conversation resolution required', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + requiredConversationResolution: true, + }, + }, + ], + }), + }, + { + description: + 'Set repository visibility to internal with description and homepage.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new internal GitHub repository with description and homepage', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + repoVisibility: 'internal', + description: 'Internal repository for team collaboration', + homepage: 'https://internal.example.com', + }, + }, + ], + }), + }, + { + description: 'Disable auto-merge.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with auto-merge disabled', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + allowAutoMerge: false, + }, + }, + ], + }), + }, + { + description: 'Set repository topics and enable GitHub Projects.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with topics and GitHub Projects enabled', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + topics: ['opensource', 'nodejs', 'api'], + hasProjects: true, + }, + }, + ], + }), + }, + { + description: + 'Create a private repository with collaborators having admin and write access.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new private GitHub repository with multiple collaborators', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + repoVisibility: 'private', + collaborators: [ + { username: 'admin1', permission: 'admin' }, + { username: 'writer1', permission: 'write' }, + ], + }, + }, + ], + }), + }, + { + description: 'Disable branch deletion on merge.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with branch deletion on merge disabled', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + deleteBranchOnMerge: false, + }, + }, + ], + }), + }, + { + description: + 'Set repository visibility to internal and enable commit signing.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new internal GitHub repository with commit signing required', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + repoVisibility: 'internal', + requiredCommitSigning: true, + }, + }, + ], + }), + }, + { + description: + 'Create repository with description, homepage, and required status checks.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with description, homepage, and status checks', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + description: 'Repository for web application project', + homepage: 'https://webapp.example.com', + requiredStatusCheckContexts: [ + 'ci/travis: build', + 'ci/travis: lint', + ], + }, + }, + ], + }), + }, + { + description: + 'Enable squash merges only and set commit message to pull request description.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository allowing only squash merges with commit message set to pull request description', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + allowMergeCommit: false, + allowSquashMerge: true, + allowRebaseMerge: false, + squashMergeCommitMessage: 'pull_request_description', + }, + }, + ], + }), + }, + { + description: 'Enable rebase merges only and require commit signing.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository allowing only rebase merges with commit signing required', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + allowMergeCommit: false, + allowRebaseMerge: true, + allowSquashMerge: false, + requiredCommitSigning: true, + }, + }, + ], + }), + }, + { + description: + 'Create repository with OIDC customization for multiple audiences.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with OIDC customization for multiple audiences', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + oidcCustomization: { + sub: 'repo:owner/repo', + aud: ['https://audience1.com', 'https://audience2.com'], + }, + }, + }, + ], + }), + }, + { + description: + 'Enable branch protection with required approving reviews and status checks.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with branch protection requiring approving reviews and status checks', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + requiredApprovingReviewCount: 2, + requiredStatusCheckContexts: [ + 'ci/circleci: build', + 'ci/circleci: test', + ], + }, + }, + ], + }), + }, + { + description: 'Create a public repository with topics and secret variables.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new public GitHub repository with topics and secret variables', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + repoVisibility: 'public', + topics: ['javascript', 'react', 'frontend'], + secrets: [ + { name: 'API_KEY', value: 'apikeyvalue' }, + { name: 'DB_PASSWORD', value: 'dbpasswordvalue' }, + ], + }, + }, + ], + }), + }, + { + description: 'Set repository description and disable issues and wiki.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with description, and disable issues and wiki', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + description: 'Repository for backend service', + hasIssues: false, + hasWiki: false, + }, + }, + ], + }), + }, + { + description: 'Enable required conversation resolution and commit signing.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with required conversation resolution and commit signing', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + requiredConversationResolution: true, + requiredCommitSigning: true, + }, + }, + ], + }), + }, + { + description: + 'Set repository visibility to private and require branches to be up-to-date.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new private GitHub repository requiring branches to be up-to-date', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + repoVisibility: 'private', + requireBranchesToBeUpToDate: true, + }, + }, + ], + }), + }, + { + description: + 'Create a repository with default settings and add multiple topics.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with default settings and topics', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + topics: ['devops', 'ci-cd', 'automation'], + }, + }, + ], + }), + }, + { + description: + 'Disable merge commits, enable auto-merge, and require commit signing.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository disabling merge commits, enabling auto-merge, and requiring commit signing', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + allowMergeCommit: false, + allowAutoMerge: true, + requiredCommitSigning: true, + }, + }, + ], + }), + }, + { + description: + 'Create a repository with homepage, collaborators, and topics.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with homepage, collaborators, and topics', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + homepage: 'https://example.com', + collaborators: [ + { username: 'user1', permission: 'push' }, + { username: 'user2', permission: 'admin' }, + ], + topics: ['opensource', 'contribution'], + }, + }, + ], + }), + }, + { + description: 'Create a repository with branch protection and description.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with branch protection and description', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + requiredStatusCheckContexts: ['ci/travis: build'], + requiredApprovingReviewCount: 1, + description: 'Repository for microservice development', + }, + }, + ], + }), + }, + { + description: 'Create a repository with OIDC customization and topics.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with OIDC customization and topics', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + oidcCustomization: { + sub: 'repo:owner/repo', + aud: 'https://api.example.com', + }, + topics: ['api', 'security'], + }, + }, + ], + }), + }, + { + description: + 'Enable required code owner reviews and branch deletion on merge.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with required code owner reviews and branch deletion on merge', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + requireCodeOwnerReviews: true, + deleteBranchOnMerge: true, + }, + }, + ], + }), + }, + { + description: + 'Create a repository with multiple secret variables and collaborators.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with multiple secret variables and collaborators', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + secrets: [ + { name: 'API_SECRET', value: 'secretvalue' }, + { name: 'DB_USER', value: 'dbuser' }, + ], + collaborators: [ + { username: 'dev1', permission: 'write' }, + { username: 'dev2', permission: 'push' }, + ], + }, + }, + ], + }), + }, + { + description: + 'Enable branch protection requiring status checks and conversation resolution.', + example: yaml.stringify({ + steps: [ + { + action: 'github:repo:create', + name: 'Create a new GitHub repository with branch protection requiring status checks and conversation resolution', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + requiredStatusCheckContexts: ['ci/build'], + requiredConversationResolution: true, + }, + }, + ], + }), + }, ]; From a65ccea1ffdc13387b9ac54ad2a54ad36d11924c Mon Sep 17 00:00:00 2001 From: Ben Lambert Date: Tue, 30 Jul 2024 09:35:44 +0200 Subject: [PATCH 081/372] Update flat-papayas-push.md Signed-off-by: Ben Lambert --- .changeset/flat-papayas-push.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/flat-papayas-push.md b/.changeset/flat-papayas-push.md index 191dad8550..f9e20613fd 100644 --- a/.changeset/flat-papayas-push.md +++ b/.changeset/flat-papayas-push.md @@ -1,5 +1,5 @@ --- -'@backstage/plugin-scaffolder-backend-module-azure': minor +'@backstage/plugin-scaffolder-backend-module-azure': patch --- Added examples for publish:azure action and updated its test cases From c544f811b83af6693f4b0078d525c089c7904bce Mon Sep 17 00:00:00 2001 From: Heikki Hellgren Date: Tue, 30 Jul 2024 11:14:29 +0300 Subject: [PATCH 082/372] feat: add support for status filtering in scaffolder endpoint Signed-off-by: Heikki Hellgren --- .changeset/eighty-jokes-deny.md | 6 +++++ plugins/scaffolder-backend/api-report.md | 4 +-- .../tasks/DatabaseTaskStore.test.ts | 27 +++++++++++++++++++ .../src/scaffolder/tasks/DatabaseTaskStore.ts | 15 +++++++---- .../src/scaffolder/tasks/StorageTaskBroker.ts | 9 +++++-- .../src/scaffolder/tasks/types.ts | 23 +++++++++------- .../src/service/router.test.ts | 3 ++- .../scaffolder-backend/src/service/router.ts | 18 ++++++++++--- plugins/scaffolder-node/api-report.md | 2 +- plugins/scaffolder-node/src/tasks/types.ts | 5 +++- 10 files changed, 86 insertions(+), 26 deletions(-) create mode 100644 .changeset/eighty-jokes-deny.md diff --git a/.changeset/eighty-jokes-deny.md b/.changeset/eighty-jokes-deny.md new file mode 100644 index 0000000000..58944252f4 --- /dev/null +++ b/.changeset/eighty-jokes-deny.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-scaffolder-backend': patch +'@backstage/plugin-scaffolder-node': patch +--- + +Add support for status filtering in scaffolder tasks endpoint diff --git a/plugins/scaffolder-backend/api-report.md b/plugins/scaffolder-backend/api-report.md index a3beee2b53..2b0661ab59 100644 --- a/plugins/scaffolder-backend/api-report.md +++ b/plugins/scaffolder-backend/api-report.md @@ -427,7 +427,7 @@ export class DatabaseTaskStore implements TaskStore { // (undocumented) heartbeatTask(taskId: string): Promise; // (undocumented) - list(options: { createdBy?: string }): Promise<{ + list(options: { createdBy?: string; status?: TaskStatus_2 }): Promise<{ tasks: SerializedTask_2[]; }>; // (undocumented) @@ -646,7 +646,7 @@ export interface TaskStore { // (undocumented) heartbeatTask(taskId: string): Promise; // (undocumented) - list?(options: { createdBy?: string }): Promise<{ + list?(options: { createdBy?: string; status?: TaskStatus }): Promise<{ tasks: SerializedTask[]; }>; // (undocumented) diff --git a/plugins/scaffolder-backend/src/scaffolder/tasks/DatabaseTaskStore.test.ts b/plugins/scaffolder-backend/src/scaffolder/tasks/DatabaseTaskStore.test.ts index f4fae0715b..78a362b5c7 100644 --- a/plugins/scaffolder-backend/src/scaffolder/tasks/DatabaseTaskStore.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/tasks/DatabaseTaskStore.test.ts @@ -95,6 +95,33 @@ describe('DatabaseTaskStore', () => { expect(tasks[0].id).toBeDefined(); }); + it('should list filtered created tasks by status', async () => { + const { store } = await createStore(); + + const { taskId } = await store.createTask({ + spec: {} as TaskSpec, + createdBy: 'me', + }); + + await store.createTask({ + spec: {} as TaskSpec, + createdBy: 'him', + }); + + const message = `This task was marked as stale as it exceeded its timeout`; + await store.completeTask({ + taskId, + status: 'cancelled', + eventBody: { message }, + }); + + const { tasks } = await store.list({ status: 'open' }); + expect(tasks.length).toBe(1); + expect(tasks[0].createdBy).toBe('him'); + expect(tasks[0].status).toBe('open'); + expect(tasks[0].id).toBeDefined(); + }); + it('should sent an event to start cancelling the task', async () => { const { store } = await createStore(); diff --git a/plugins/scaffolder-backend/src/scaffolder/tasks/DatabaseTaskStore.ts b/plugins/scaffolder-backend/src/scaffolder/tasks/DatabaseTaskStore.ts index fe62572af9..ba675b2cc7 100644 --- a/plugins/scaffolder-backend/src/scaffolder/tasks/DatabaseTaskStore.ts +++ b/plugins/scaffolder-backend/src/scaffolder/tasks/DatabaseTaskStore.ts @@ -22,19 +22,19 @@ import { Knex } from 'knex'; import { v4 as uuid } from 'uuid'; import { TaskStore, - TaskStoreEmitOptions, - TaskStoreListEventsOptions, TaskStoreCreateTaskOptions, TaskStoreCreateTaskResult, - TaskStoreShutDownTaskOptions, + TaskStoreEmitOptions, + TaskStoreListEventsOptions, TaskStoreRecoverTaskOptions, + TaskStoreShutDownTaskOptions, } from './types'; import { - SerializedTaskEvent, SerializedTask, - TaskStatus, + SerializedTaskEvent, TaskEventType, TaskSecrets, + TaskStatus, } from '@backstage/plugin-scaffolder-node'; import { DateTime, Duration } from 'luxon'; import { TaskRecovery, TaskSpec } from '@backstage/plugin-scaffolder-common'; @@ -182,6 +182,7 @@ export class DatabaseTaskStore implements TaskStore { async list(options: { createdBy?: string; + status?: TaskStatus; }): Promise<{ tasks: SerializedTask[] }> { const queryBuilder = this.db('tasks'); @@ -191,6 +192,10 @@ export class DatabaseTaskStore implements TaskStore { }); } + if (options.status) { + queryBuilder.where({ status: options.status }); + } + const results = await queryBuilder.orderBy('created_at', 'desc').select(); const tasks = results.map(result => ({ diff --git a/plugins/scaffolder-backend/src/scaffolder/tasks/StorageTaskBroker.ts b/plugins/scaffolder-backend/src/scaffolder/tasks/StorageTaskBroker.ts index f4946e6652..d17fb33b3b 100644 --- a/plugins/scaffolder-backend/src/scaffolder/tasks/StorageTaskBroker.ts +++ b/plugins/scaffolder-backend/src/scaffolder/tasks/StorageTaskBroker.ts @@ -20,13 +20,14 @@ import { JsonObject, JsonValue, Observable } from '@backstage/types'; import { Logger } from 'winston'; import ObservableImpl from 'zen-observable'; import { - TaskSecrets, SerializedTask, SerializedTaskEvent, TaskBroker, TaskBrokerDispatchOptions, TaskCompletionState, TaskContext, + TaskSecrets, + TaskStatus, } from '@backstage/plugin-scaffolder-node'; import { InternalTaskSecrets, TaskStore } from './types'; import { readDuration } from './helper'; @@ -279,13 +280,17 @@ export class StorageTaskBroker implements TaskBroker { async list(options?: { createdBy?: string; + status?: TaskStatus; }): Promise<{ tasks: SerializedTask[] }> { if (!this.storage.list) { throw new Error( 'TaskStore does not implement the list method. Please implement the list method to be able to list tasks', ); } - return await this.storage.list({ createdBy: options?.createdBy }); + return await this.storage.list({ + createdBy: options?.createdBy, + status: options?.status, + }); } private deferredDispatch = defer(); diff --git a/plugins/scaffolder-backend/src/scaffolder/tasks/types.ts b/plugins/scaffolder-backend/src/scaffolder/tasks/types.ts index 0e0ebd706b..89bcce3cc9 100644 --- a/plugins/scaffolder-backend/src/scaffolder/tasks/types.ts +++ b/plugins/scaffolder-backend/src/scaffolder/tasks/types.ts @@ -14,20 +14,20 @@ * limitations under the License. */ -import { JsonValue, JsonObject, HumanDuration } from '@backstage/types'; +import { HumanDuration, JsonObject, JsonValue } from '@backstage/types'; import { TaskSpec, TaskStep } from '@backstage/plugin-scaffolder-common'; -import { TaskSecrets } from '@backstage/plugin-scaffolder-node'; import { - TemplateAction, - TaskStatus as _TaskStatus, - TaskCompletionState as _TaskCompletionState, SerializedTask as _SerializedTask, - TaskEventType as _TaskEventType, SerializedTaskEvent as _SerializedTaskEvent, - TaskBrokerDispatchResult as _TaskBrokerDispatchResult, - TaskBrokerDispatchOptions as _TaskBrokerDispatchOptions, - TaskContext as _TaskContext, TaskBroker as _TaskBroker, + TaskBrokerDispatchOptions as _TaskBrokerDispatchOptions, + TaskBrokerDispatchResult as _TaskBrokerDispatchResult, + TaskCompletionState as _TaskCompletionState, + TaskContext as _TaskContext, + TaskEventType as _TaskEventType, + TaskSecrets, + TaskStatus as _TaskStatus, + TemplateAction, } from '@backstage/plugin-scaffolder-node'; /** @@ -190,7 +190,10 @@ export interface TaskStore { tasks: { taskId: string }[]; }>; - list?(options: { createdBy?: string }): Promise<{ tasks: SerializedTask[] }>; + list?(options: { + createdBy?: string; + status?: TaskStatus; + }): Promise<{ tasks: SerializedTask[] }>; emitLogEvent(options: TaskStoreEmitOptions): Promise; diff --git a/plugins/scaffolder-backend/src/service/router.test.ts b/plugins/scaffolder-backend/src/service/router.test.ts index af06fc4034..01a2fba6e8 100644 --- a/plugins/scaffolder-backend/src/service/router.test.ts +++ b/plugins/scaffolder-backend/src/service/router.test.ts @@ -432,10 +432,11 @@ describe('createRouter', () => { }); const response = await request(app).get( - `/v2/tasks?createdBy=user:default/foo`, + `/v2/tasks?createdBy=user:default/foo&status=completed`, ); expect(taskBroker.list).toHaveBeenCalledWith({ createdBy: 'user:default/foo', + status: 'completed', }); expect(response.status).toEqual(200); diff --git a/plugins/scaffolder-backend/src/service/router.ts b/plugins/scaffolder-backend/src/service/router.ts index 769a042a78..a25731ce45 100644 --- a/plugins/scaffolder-backend/src/service/router.ts +++ b/plugins/scaffolder-backend/src/service/router.ts @@ -15,10 +15,10 @@ */ import { + createLegacyAuthAdapters, HostDiscovery, PluginDatabaseManager, UrlReader, - createLegacyAuthAdapters, } from '@backstage/backend-common'; import { PluginTaskScheduler } from '@backstage/backend-tasks'; import { CatalogApi } from '@backstage/catalog-client'; @@ -35,22 +35,22 @@ import { ScmIntegrations } from '@backstage/integration'; import { HumanDuration, JsonObject, JsonValue } from '@backstage/types'; import { TaskSpec, + TemplateEntityStepV1beta3, TemplateEntityV1beta3, templateEntityV1beta3Validator, TemplateParametersV1beta3, - TemplateEntityStepV1beta3, } from '@backstage/plugin-scaffolder-common'; import { RESOURCE_TYPE_SCAFFOLDER_ACTION, RESOURCE_TYPE_SCAFFOLDER_TEMPLATE, scaffolderActionPermissions, + scaffolderTaskPermissions, scaffolderTemplatePermissions, taskCancelPermission, taskCreatePermission, taskReadPermission, templateParameterReadPermission, templateStepReadPermission, - scaffolderTaskPermissions, } from '@backstage/plugin-scaffolder-common/alpha'; import express from 'express'; import Router from 'express-promise-router'; @@ -58,8 +58,9 @@ import { validate } from 'jsonschema'; import { Logger } from 'winston'; import { z } from 'zod'; import { - TemplateAction, TaskBroker, + TaskStatus, + TemplateAction, TemplateFilter, TemplateGlobal, } from '@backstage/plugin-scaffolder-node'; @@ -587,8 +588,17 @@ export async function createRouter( ); } + const [statusQuery] = [req.query.status].flat(); + if ( + typeof statusQuery !== 'string' && + typeof statusQuery !== 'undefined' + ) { + throw new InputError('status query parameter must be a string'); + } + const tasks = await taskBroker.list({ createdBy: userEntityRef, + status: statusQuery ? (statusQuery as TaskStatus) : undefined, }); res.status(200).json(tasks); diff --git a/plugins/scaffolder-node/api-report.md b/plugins/scaffolder-node/api-report.md index 66e8ccd678..515a169cb2 100644 --- a/plugins/scaffolder-node/api-report.md +++ b/plugins/scaffolder-node/api-report.md @@ -315,7 +315,7 @@ export interface TaskBroker { // (undocumented) get(taskId: string): Promise; // (undocumented) - list?(options?: { createdBy?: string }): Promise<{ + list?(options?: { createdBy?: string; status?: TaskStatus }): Promise<{ tasks: SerializedTask[]; }>; // (undocumented) diff --git a/plugins/scaffolder-node/src/tasks/types.ts b/plugins/scaffolder-node/src/tasks/types.ts index a2adb97b9c..8324e352f2 100644 --- a/plugins/scaffolder-node/src/tasks/types.ts +++ b/plugins/scaffolder-node/src/tasks/types.ts @@ -180,5 +180,8 @@ export interface TaskBroker { get(taskId: string): Promise; - list?(options?: { createdBy?: string }): Promise<{ tasks: SerializedTask[] }>; + list?(options?: { + createdBy?: string; + status?: TaskStatus; + }): Promise<{ tasks: SerializedTask[] }>; } From 4fdb1f4eee2ffd5d2835ae216d02068e4c80f9fb Mon Sep 17 00:00:00 2001 From: Andre Wanlin Date: Tue, 30 Jul 2024 06:59:50 -0500 Subject: [PATCH 083/372] Conditionally Render Sign In Provider Example Signed-off-by: Andre Wanlin --- docs/auth/index.md | 60 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 6 deletions(-) diff --git a/docs/auth/index.md b/docs/auth/index.md index 5188d7e2a4..de579d039a 100644 --- a/docs/auth/index.md +++ b/docs/auth/index.md @@ -112,9 +112,16 @@ const app = createApp({ }); ``` -You can also use the `providers` prop to enable multiple sign-in methods, for example +:::note Note -- allowing guest access: +You can configure sign-in to use a redirect flow with no pop-up by adding +`enableExperimentalRedirectFlow: true` to the root of your `app-config.yaml` + +::: + +### Using Multiple Providers + +You can also use the `providers` prop to enable multiple sign-in methods, for example to allow guest access: ```tsx title="packages/app/src/App.tsx" const app = createApp({ @@ -140,12 +147,53 @@ const app = createApp({ }); ``` -:::note Note +### Conditionally Render Sign In Provider -You can configure sign-in to use a redirect flow with no pop-up by adding -`enableExperimentalRedirectFlow: true` to the root of your `app-config.yaml` +In the above example you have both Guest and GitHub sign-in options, this is helpful for non-production but in Production you will most likely not want to offer Guest access. You can easily use information from your config to help conditionally render the provider: -::: +```tsx title="packages/app/src/App.tsx" +import { + configApiRef, + githubAuthApiRef, + useApi, +} from '@backstage/core-plugin-api'; + +const app = createApp({ + components: { + SignInPage: props => { + const configApi = useApi(configApiRef); + if (configApi.getString('auth.environment') === 'development') { + return ( + + ); + } + return ( + + ); + }, + }, + // .. +}); +``` ## Sign-In with Proxy Providers From 9d6ad1eeb628f93029a1a97510068361490c5a8b Mon Sep 17 00:00:00 2001 From: "Nolan, Tavi" Date: Tue, 30 Jul 2024 14:26:33 +0100 Subject: [PATCH 084/372] Update mkdocs.yml file path Signed-off-by: Nolan, Tavi --- mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdocs.yml b/mkdocs.yml index 707929d132..38b03fbbea 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -64,7 +64,7 @@ nav: - Writing Custom Actions: 'features/software-templates/writing-custom-actions.md' - Writing Custom Step Layouts: 'features/software-templates/writing-custom-step-layouts.md' - Migrating from v1beta2 to v1beta3 templates: 'features/software-templates/migrating-from-v1beta2-to-v1beta3.md' - - Dry Run Testing: 'feature/software-templates/dry-run-testing.md' + - Dry Run Testing: 'features/software-templates/dry-run-testing.md' - Backstage Search: - Overview: 'features/search/README.md' - Getting Started: 'features/search/getting-started.md' From a16632cf740a6180a62183d1544b57142ae88ec0 Mon Sep 17 00:00:00 2001 From: Thomas Cardonne Date: Wed, 31 Jul 2024 00:01:45 +0200 Subject: [PATCH 085/372] fix(techdocs-backend): update config.d.ts Signed-off-by: Thomas Cardonne --- .changeset/shaggy-mugs-return.md | 5 +++++ plugins/techdocs-backend/config.d.ts | 32 +++++++++++++--------------- 2 files changed, 20 insertions(+), 17 deletions(-) create mode 100644 .changeset/shaggy-mugs-return.md diff --git a/.changeset/shaggy-mugs-return.md b/.changeset/shaggy-mugs-return.md new file mode 100644 index 0000000000..6af5d1d18f --- /dev/null +++ b/.changeset/shaggy-mugs-return.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs-backend': patch +--- + +Update configuration schema to match actual behavior diff --git a/plugins/techdocs-backend/config.d.ts b/plugins/techdocs-backend/config.d.ts index 9d1cd9e170..e22fc549d9 100644 --- a/plugins/techdocs-backend/config.d.ts +++ b/plugins/techdocs-backend/config.d.ts @@ -68,22 +68,14 @@ export interface Config { /** * Techdocs publisher information */ - publisher?: - | { - type: - | 'local' - | 'googleGcs' - | 'awsS3' - | 'azureBlobStorage' - | 'openStackSwift'; - - local?: { - /** - * Directory to store generated static files. - */ - publishDirectory?: string; - }; - } + publisher?: { + local?: { + /** + * Directory to store generated static files. + */ + publishDirectory?: string; + }; + } & ( | { type: 'awsS3'; @@ -132,6 +124,11 @@ export interface Config { * (Required) Cloud Storage Bucket Name */ bucketName: string; + /** + * (Optional) Location in storage bucket to save files + * If not set, the default location will be the root of the storage bucket + */ + bucketRootPath?: string; /** * (Optional) AWS Region. * If not set, AWS_REGION environment variable or aws config file will be used. @@ -261,7 +258,8 @@ export interface Config { */ projectId?: string; }; - }; + } + ); /** * @example http://localhost:7007/api/techdocs From 83faf24b3367b5daf84d47c374c7dcae85ab5071 Mon Sep 17 00:00:00 2001 From: Heikki Hellgren Date: Wed, 31 Jul 2024 07:46:33 +0300 Subject: [PATCH 086/372] feat: add possibility to allow and deny specific email addresses Notification email processor config to support allowing and denying specific email addresses who can receive notifications in email. This is required to be able to test this in test environments with real production data and not send unnecessary notifications. Signed-off-by: Heikki Hellgren --- .changeset/witty-queens-run.md | 5 ++++ .../config.d.ts | 8 ++++++ .../processor/NotificationsEmailProcessor.ts | 27 +++++++++++++++++-- 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 .changeset/witty-queens-run.md diff --git a/.changeset/witty-queens-run.md b/.changeset/witty-queens-run.md new file mode 100644 index 0000000000..2d869caa91 --- /dev/null +++ b/.changeset/witty-queens-run.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-notifications-backend-module-email': patch +--- + +Notification email processor supports allowing or denying specific email addresses from receiving notifications diff --git a/plugins/notifications-backend-module-email/config.d.ts b/plugins/notifications-backend-module-email/config.d.ts index 92f3385d1b..e4ce5ede53 100644 --- a/plugins/notifications-backend-module-email/config.d.ts +++ b/plugins/notifications-backend-module-email/config.d.ts @@ -132,6 +132,14 @@ export interface Config { */ excludedTopics?: string[]; }; + /** + * White list of addresses to send email to + */ + allowlistEmailAddresses?: string[]; + /** + * Black list of addresses to not send email to + */ + denylistEmailAddresses?: string[]; }; }; }; diff --git a/plugins/notifications-backend-module-email/src/processor/NotificationsEmailProcessor.ts b/plugins/notifications-backend-module-email/src/processor/NotificationsEmailProcessor.ts index 3bfccfcc90..f3d9f59b8c 100644 --- a/plugins/notifications-backend-module-email/src/processor/NotificationsEmailProcessor.ts +++ b/plugins/notifications-backend-module-email/src/processor/NotificationsEmailProcessor.ts @@ -56,6 +56,8 @@ export class NotificationsEmailProcessor implements NotificationProcessor { private readonly throttleInterval: number; private readonly frontendBaseUrl: string; private readonly filter: NotificationProcessorFilters; + private readonly allowlistEmailAddresses?: string[]; + private readonly denylistEmailAddresses?: string[]; constructor( private readonly logger: LoggerService, @@ -85,6 +87,12 @@ export class NotificationsEmailProcessor implements NotificationProcessor { ? durationToMilliseconds(readDurationFromConfig(cacheConfig)) : 3_600_000; this.frontendBaseUrl = config.getString('app.baseUrl'); + this.allowlistEmailAddresses = emailProcessorConfig.getOptionalStringArray( + 'allowlistEmailAddresses', + ); + this.denylistEmailAddresses = emailProcessorConfig.getOptionalStringArray( + 'denylistEmailAddresses', + ); this.filter = getProcessorFiltersFromConfig(emailProcessorConfig); } @@ -197,10 +205,25 @@ export class NotificationsEmailProcessor implements NotificationProcessor { notification: Notification, options: NotificationSendOptions, ) { + let emails: string[]; if (options.recipients.type === 'broadcast' || notification.user === null) { - return await this.getBroadcastEmails(); + emails = await this.getBroadcastEmails(); + } else { + emails = await this.getUserEmail(notification.user); } - return await this.getUserEmail(notification.user); + + if (this.allowlistEmailAddresses) { + emails = emails.filter(email => + this.allowlistEmailAddresses?.includes(email), + ); + } + + if (this.denylistEmailAddresses) { + emails = emails.filter( + email => !this.denylistEmailAddresses?.includes(email), + ); + } + return emails; } private async sendMail(options: Mail.Options) { From ff6a0a381892dddab9dbfe28fdac83c36202e084 Mon Sep 17 00:00:00 2001 From: Valber Junior <84424883+ValberJunior@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:25:48 -0300 Subject: [PATCH 087/372] Create kubernetes-gpt-analyzer.yaml Signed-off-by: Valber Junior <84424883+ValberJunior@users.noreply.github.com> --- .../data/plugins/kubernetes-gpt-analyzer.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 microsite/data/plugins/kubernetes-gpt-analyzer.yaml diff --git a/microsite/data/plugins/kubernetes-gpt-analyzer.yaml b/microsite/data/plugins/kubernetes-gpt-analyzer.yaml new file mode 100644 index 0000000000..78bd0fe4c4 --- /dev/null +++ b/microsite/data/plugins/kubernetes-gpt-analyzer.yaml @@ -0,0 +1,16 @@ +--- +title: VeeCode Kubernetes GPT Analyzer +author: VeeCode Platform +authorUrl: https://platform.vee.codes/ +category: Monitoring +description: The Kubernetes GPT Analyzer plug-in uses artificial intelligence with the help of k8s-operator to analyze and optimize your Kubernetes entities, improving the management and performance of your cluster. It makes it easier to detect anomalies and suggest best practices. +documentation: https://platform.vee.codes/plugin/Kubernetes%20GPT%20Analyzer/ +iconUrl: https://veecode-platform.github.io/support/imgs/logo_4.svg +npmPackageName: '@veecode-platform/backstage-plugin-kubernetes-gpt-analyzer' +tags: + - monitor + - ai + - kubernetes + - k8soperator + - gpt +addedDate: '2024-07-31' From 58f764e97e1fe4d4a4779c21479e20eb0fb2664d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 31 Jul 2024 21:37:38 +0000 Subject: [PATCH 088/372] chore(deps): update chromaui/action digest to fdbe775 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/verify_storybook.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify_storybook.yml b/.github/workflows/verify_storybook.yml index 2f93b67616..e9da9f0398 100644 --- a/.github/workflows/verify_storybook.yml +++ b/.github/workflows/verify_storybook.yml @@ -51,7 +51,7 @@ jobs: - run: yarn build-storybook - - uses: chromaui/action@5991575112b472a4fa85429f29cc17e2fb83a2a2 # v11 + - uses: chromaui/action@fdbe7756d4dbf493e2fbb822df73be7accd07e1c # v11 with: token: ${{ secrets.GITHUB_TOKEN }} # projectToken intentionally shared to allow collaborators to run Chromatic on forks From 4b6d2cb74c7fcfd9913c9cc0d383384130296596 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 1 Aug 2024 12:12:19 +0000 Subject: [PATCH 089/372] fix(deps): update dependency @graphiql/react to ^0.23.0 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .changeset/renovate-147ac48.md | 5 ++ plugins/api-docs/package.json | 2 +- yarn.lock | 111 ++++++++++++++++++++++++++++----- 3 files changed, 102 insertions(+), 16 deletions(-) create mode 100644 .changeset/renovate-147ac48.md diff --git a/.changeset/renovate-147ac48.md b/.changeset/renovate-147ac48.md new file mode 100644 index 0000000000..257255dff1 --- /dev/null +++ b/.changeset/renovate-147ac48.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-api-docs': patch +--- + +Updated dependency `@graphiql/react` to `^0.23.0`. diff --git a/plugins/api-docs/package.json b/plugins/api-docs/package.json index 4f88e8874a..3633471588 100644 --- a/plugins/api-docs/package.json +++ b/plugins/api-docs/package.json @@ -63,7 +63,7 @@ "@backstage/plugin-catalog-common": "workspace:^", "@backstage/plugin-catalog-react": "workspace:^", "@backstage/plugin-permission-react": "workspace:^", - "@graphiql/react": "^0.20.0", + "@graphiql/react": "^0.23.0", "@material-ui/core": "^4.12.2", "@material-ui/icons": "^4.9.1", "@material-ui/lab": "4.0.0-alpha.61", diff --git a/yarn.lock b/yarn.lock index e65851a7ba..e1cebfb537 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4696,7 +4696,7 @@ __metadata: "@backstage/plugin-catalog-react": "workspace:^" "@backstage/plugin-permission-react": "workspace:^" "@backstage/test-utils": "workspace:^" - "@graphiql/react": ^0.20.0 + "@graphiql/react": ^0.23.0 "@material-ui/core": ^4.12.2 "@material-ui/icons": ^4.9.1 "@material-ui/lab": 4.0.0-alpha.61 @@ -9612,7 +9612,7 @@ __metadata: languageName: node linkType: hard -"@graphiql/react@npm:^0.20.0, @graphiql/react@npm:^0.20.3": +"@graphiql/react@npm:^0.20.3": version: 0.20.3 resolution: "@graphiql/react@npm:0.20.3" dependencies: @@ -9639,9 +9639,36 @@ __metadata: languageName: node linkType: hard -"@graphiql/toolkit@npm:^0.9.1": - version: 0.9.1 - resolution: "@graphiql/toolkit@npm:0.9.1" +"@graphiql/react@npm:^0.23.0": + version: 0.23.0 + resolution: "@graphiql/react@npm:0.23.0" + dependencies: + "@graphiql/toolkit": ^0.9.2 + "@headlessui/react": ^1.7.15 + "@radix-ui/react-dialog": ^1.0.4 + "@radix-ui/react-dropdown-menu": ^2.0.5 + "@radix-ui/react-tooltip": ^1.0.6 + "@radix-ui/react-visually-hidden": ^1.0.3 + "@types/codemirror": ^5.60.8 + clsx: ^1.2.1 + codemirror: ^5.65.3 + codemirror-graphql: ^2.0.13 + copy-to-clipboard: ^3.2.0 + framer-motion: ^6.5.1 + graphql-language-service: ^5.2.2 + markdown-it: ^14.1.0 + set-value: ^4.1.0 + peerDependencies: + graphql: ^15.5.0 || ^16.0.0 + react: ^16.8.0 || ^17 || ^18 + react-dom: ^16.8.0 || ^17 || ^18 + checksum: a62ee7d763d410f5ff8c5670596194069e97f11b906762c4e38c74797e4e34c33cd91e06aae24d5118e0fa05dc6c1ffa6c3d3d8ff5bc2b6af0b689088236f613 + languageName: node + linkType: hard + +"@graphiql/toolkit@npm:^0.9.1, @graphiql/toolkit@npm:^0.9.2": + version: 0.9.2 + resolution: "@graphiql/toolkit@npm:0.9.2" dependencies: "@n1ru4l/push-pull-async-iterable-iterator": ^3.1.0 meros: ^1.1.4 @@ -9651,7 +9678,7 @@ __metadata: peerDependenciesMeta: graphql-ws: optional: true - checksum: 5328426051b7f9a9ffbd569c950d1a103ce0e2ee7b5d7a57f3d899488ad43d1a5101e8aeced7416e106c7687d67bb7981aa7e87dea5b0f17b77569aa738bf3b5 + checksum: 4474a998a948d0df5cef8371245b0e895be40803a07e49231ab91798aa761880e6e4a684478a44b723c013f0e8206dab3d86e5b0fc9b688df035fa9f1fa29734 languageName: node linkType: hard @@ -23202,17 +23229,17 @@ __metadata: languageName: node linkType: hard -"codemirror-graphql@npm:^2.0.10": - version: 2.0.11 - resolution: "codemirror-graphql@npm:2.0.11" +"codemirror-graphql@npm:^2.0.10, codemirror-graphql@npm:^2.0.13": + version: 2.0.13 + resolution: "codemirror-graphql@npm:2.0.13" dependencies: "@types/codemirror": ^0.0.90 - graphql-language-service: 5.2.0 + graphql-language-service: 5.2.2 peerDependencies: "@codemirror/language": 6.0.0 codemirror: ^5.65.3 graphql: ^15.5.0 || ^16.0.0 - checksum: cdbeb713af63a069c5526f864edf4f71dd811437e44dba7967164ea2d380c52dfe51d3ea3fde06c94ffeb596b93af737767923d6fc434c628fa4241621684950 + checksum: 7ecb2ba2716448b3c10ccc6168dbe4c636d2d82695beea40cda6f4938b4821e9abcf6446c99412bf59558340f10b45e5b74dce5f80ae4be4409b8a6b7bfcc5ec languageName: node linkType: hard @@ -24719,6 +24746,13 @@ __metadata: languageName: node linkType: hard +"debounce-promise@npm:^3.1.2": + version: 3.1.2 + resolution: "debounce-promise@npm:3.1.2" + checksum: 29bac4524c423cc852319d7455363909ea3d933a3b9e3eb1149d963cffc34c475fe37219d0bafc61af566500b5d663cba579bbad7ee4023bef06f8394ed900ad + languageName: node + linkType: hard + "debounce@npm:^1.2.0": version: 1.2.1 resolution: "debounce@npm:1.2.1" @@ -28887,17 +28921,18 @@ __metadata: languageName: node linkType: hard -"graphql-language-service@npm:5.2.0, graphql-language-service@npm:^5.2.0": - version: 5.2.0 - resolution: "graphql-language-service@npm:5.2.0" +"graphql-language-service@npm:5.2.2, graphql-language-service@npm:^5.2.0, graphql-language-service@npm:^5.2.2": + version: 5.2.2 + resolution: "graphql-language-service@npm:5.2.2" dependencies: + debounce-promise: ^3.1.2 nullthrows: ^1.0.0 vscode-languageserver-types: ^3.17.1 peerDependencies: graphql: ^15.5.0 || ^16.0.0 bin: graphql: dist/temp-bin.js - checksum: b053c6b7158d0ee7a3e55391bfd8be956fc5380211ca586b3a252007845e119540fb40efcc438975eaebc5ef25f46973f7ff4d9543c66e14ebd992957e0299b7 + checksum: 3f112ba67ae10096ac4a415e946cddad019ce9bd5467e29730fdfe08b4470f5b4126412edd6bfcdf6cfbd816c65e295da21134ae501e577540b319f521bc032d languageName: node linkType: hard @@ -32742,6 +32777,15 @@ __metadata: languageName: node linkType: hard +"linkify-it@npm:^5.0.0": + version: 5.0.0 + resolution: "linkify-it@npm:5.0.0" + dependencies: + uc.micro: ^2.0.0 + checksum: b0b86cadaf816b64c947a83994ceaad1c15f9fe7e079776ab88699fb71afd7b8fc3fd3d0ae5ebec8c92c1d347be9ba257b8aef338c0ebf81b0d27dcf429a765a + languageName: node + linkType: hard + "linkify-react@npm:4.1.3": version: 4.1.3 resolution: "linkify-react@npm:4.1.3" @@ -33524,6 +33568,22 @@ __metadata: languageName: node linkType: hard +"markdown-it@npm:^14.1.0": + version: 14.1.0 + resolution: "markdown-it@npm:14.1.0" + dependencies: + argparse: ^2.0.1 + entities: ^4.4.0 + linkify-it: ^5.0.0 + mdurl: ^2.0.0 + punycode.js: ^2.3.1 + uc.micro: ^2.1.0 + bin: + markdown-it: bin/markdown-it.mjs + checksum: 07296b45ebd0b13a55611a24d1b1ad002c6729ec54f558f597846994b0b7b1de79d13cd99ff3e7b6e9e027f36b63125cdcf69174da294ecabdd4e6b9fff39e5d + languageName: node + linkType: hard + "markdown-table@npm:^3.0.0": version: 3.0.1 resolution: "markdown-table@npm:3.0.1" @@ -33768,6 +33828,13 @@ __metadata: languageName: node linkType: hard +"mdurl@npm:^2.0.0": + version: 2.0.0 + resolution: "mdurl@npm:2.0.0" + checksum: 880bc289ef668df0bb34c5b2b5aaa7b6ea755052108cdaf4a5e5968ad01cf27e74927334acc9ebcc50a8628b65272ae6b1fd51fae1330c130e261c0466e1a3b2 + languageName: node + linkType: hard + "media-typer@npm:0.3.0": version: 0.3.0 resolution: "media-typer@npm:0.3.0" @@ -38136,6 +38203,13 @@ __metadata: languageName: node linkType: hard +"punycode.js@npm:^2.3.1": + version: 2.3.1 + resolution: "punycode.js@npm:2.3.1" + checksum: 13466d7ed5e8dacdab8c4cc03837e7dd14218a59a40eb14a837f1f53ca396e18ef2c4ee6d7766b8ed2fc391d6a3ac489eebf2de83b3596f5a54e86df4a251b72 + languageName: node + linkType: hard + "punycode@npm:1.3.2": version: 1.3.2 resolution: "punycode@npm:1.3.2" @@ -43422,6 +43496,13 @@ __metadata: languageName: node linkType: hard +"uc.micro@npm:^2.0.0, uc.micro@npm:^2.1.0": + version: 2.1.0 + resolution: "uc.micro@npm:2.1.0" + checksum: 37197358242eb9afe367502d4638ac8c5838b78792ab218eafe48287b0ed28aaca268ec0392cc5729f6c90266744de32c06ae938549aee041fc93b0f9672d6b2 + languageName: node + linkType: hard + "uglify-js@npm:^3.1.4": version: 3.17.0 resolution: "uglify-js@npm:3.17.0" From 8897f3c442db12366ce28efb328c56fe51af5295 Mon Sep 17 00:00:00 2001 From: Andre Wanlin Date: Thu, 1 Aug 2024 07:16:55 -0500 Subject: [PATCH 090/372] Changes based on feedback Signed-off-by: Andre Wanlin --- docs/features/search/collators.md | 3 +-- microsite/sidebars.json | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/features/search/collators.md b/docs/features/search/collators.md index 9d68f71c32..4054ec1212 100644 --- a/docs/features/search/collators.md +++ b/docs/features/search/collators.md @@ -4,8 +4,7 @@ title: Collators description: Indexing you Backstage content with Collators --- -You need to be able to search something! Collators are the way to define what -can be searched. Backstage includes 2 collators out of the box for the [Catalog](#catalog) and [TechDocs](#techdocs). There's also some from the [Backstage Community](#community-collators) too! +Backstage includes 2 [collators](./concepts.md#collators) out of the box for the [Catalog](#catalog) and [TechDocs](#techdocs). There's also some from the [Backstage Community](#community-collators) too! ## Catalog diff --git a/microsite/sidebars.json b/microsite/sidebars.json index 2d533912f3..782b39e810 100644 --- a/microsite/sidebars.json +++ b/microsite/sidebars.json @@ -132,8 +132,8 @@ "features/search/concepts", "features/search/architecture", "features/search/search-engines", - "features/search/how-to-guides", - "features/search/collators" + "features/search/collators", + "features/search/how-to-guides" ] }, { From ea4ed1e0a03494786daa52bd539f8282078ec783 Mon Sep 17 00:00:00 2001 From: Rogerio Angeliski Date: Thu, 1 Aug 2024 11:28:40 -0300 Subject: [PATCH 091/372] add catalog-backend-module-gcp plugin Signed-off-by: Rogerio Angeliski --- .../data/plugins/catalog-backend-module-gcp.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 microsite/data/plugins/catalog-backend-module-gcp.yaml diff --git a/microsite/data/plugins/catalog-backend-module-gcp.yaml b/microsite/data/plugins/catalog-backend-module-gcp.yaml new file mode 100644 index 0000000000..b5df858862 --- /dev/null +++ b/microsite/data/plugins/catalog-backend-module-gcp.yaml @@ -0,0 +1,16 @@ +--- +title: GCP Entity Providers +author: BackToStage +authorUrl: https://backtostage.app/?utm_source=backstage.io&utm_medium=marketplace&utm_campaign=catalog-backend-module-gcp +category: Catalog +description: Import your Infrastructure from GCP into Backstage as Resource Entities +documentation: https://github.com/backtostage/backstage-plugins/blob/main/plugins/catalog-backend-module-gcp/README.md +iconUrl: https://avatars1.githubusercontent.com/u/2810941?s=280&v=4 +npmPackageName: '@backtostage/plugin-catalog-backend-module-gcp' +tags: + - cloud + - project + - resources + - gcp + - cloudsql +addedDate: '2024-08-01' From fff0b82cd7dd8437bf19c275e512b9f6ae2e2bc5 Mon Sep 17 00:00:00 2001 From: solimant Date: Thu, 1 Aug 2024 20:51:34 -0400 Subject: [PATCH 092/372] Fix highlight typo in 05-frontend-authorization.md Signed-off-by: solimant --- docs/permissions/plugin-authors/05-frontend-authorization.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/permissions/plugin-authors/05-frontend-authorization.md b/docs/permissions/plugin-authors/05-frontend-authorization.md index 60458aaf4d..4d673e3b4f 100644 --- a/docs/permissions/plugin-authors/05-frontend-authorization.md +++ b/docs/permissions/plugin-authors/05-frontend-authorization.md @@ -199,7 +199,8 @@ const routes = ( - {/* highlight-add-end */}} + {/* highlight-add-end */} + }> {/* ... */} From 24310a7e250307315333cf0fb8171c544a96a453 Mon Sep 17 00:00:00 2001 From: Deepankumar Loganathan Date: Fri, 2 Aug 2024 09:15:46 +0200 Subject: [PATCH 093/372] microsite: Azure Storage Explorer plugin updated Signed-off-by: Deepankumar Loganathan --- microsite/data/plugins/azure-storage.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/microsite/data/plugins/azure-storage.yaml b/microsite/data/plugins/azure-storage.yaml index 655a6421ed..6e723c0eeb 100644 --- a/microsite/data/plugins/azure-storage.yaml +++ b/microsite/data/plugins/azure-storage.yaml @@ -4,9 +4,9 @@ author: Deepankumar authorUrl: https://github.com/deepan10 category: Infrastructure description: Explore Azure Storage Blobs in Backstage. -documentation: https://github.com/deepan10/backstage-plugins/tree/main/plugins/azure-storage +documentation: https://github.com/backstage/community-plugins/tree/main/workspaces/azure-storage-explorer/plugins/azure-storage iconUrl: /img/azure-storage-folder.png -npmPackageName: 'backstage-plugin-azure-storage' +npmPackageName: '@backstage-community/plugin-azure-storage-explorer' tags: - Azure - Azure Storage From 5020910446d6e8cbc0124ab3149daf8653c12154 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 2 Aug 2024 14:56:17 +0200 Subject: [PATCH 094/372] frontend-plugin-api: add tests for generator factories + error on undeclared output Signed-off-by: Patrik Oldsberg --- .../src/tree/instantiateAppNodeTree.test.ts | 5 +- .../src/wiring/createExtension.test.ts | 99 +++++++++++++++++++ .../src/wiring/createExtension.ts | 11 ++- .../wiring/createExtensionBlueprint.test.tsx | 39 ++++++++ 4 files changed, 150 insertions(+), 4 deletions(-) diff --git a/packages/frontend-app-api/src/tree/instantiateAppNodeTree.test.ts b/packages/frontend-app-api/src/tree/instantiateAppNodeTree.test.ts index b4090185a3..de8889daf0 100644 --- a/packages/frontend-app-api/src/tree/instantiateAppNodeTree.test.ts +++ b/packages/frontend-app-api/src/tree/instantiateAppNodeTree.test.ts @@ -914,7 +914,7 @@ describe('instantiateAppNodeTree', () => { namespace: 'app', name: 'test', attachTo: { id: 'ignored', input: 'ignored' }, - output: [], + output: [testDataRef], factory() { const error = new Error('NOPE'); error.name = 'NopeError'; @@ -981,11 +981,12 @@ describe('instantiateAppNodeTree', () => { createAppNodeInstance({ node: makeNode( resolveExtensionDefinition( + // @ts-expect-error createExtension({ namespace: 'app', name: 'test', attachTo: { id: 'ignored', input: 'ignored' }, - output: [], + output: [], // Output not declared factory({}) { return [testDataRef('test')] as any; }, diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts index 327639af37..ab6a6c19a5 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts @@ -394,6 +394,18 @@ describe('createExtension', () => { }), ).toMatchObject({ version: 'v2' }); + expect( + // @ts-expect-error + createExtension({ + namespace: 'test', + attachTo: { id: 'root', input: 'default' }, + output: [stringDataRef], + factory() { + return [stringDataRef('hello'), numberDataRef(4)]; + }, + }), + ).toMatchObject({ version: 'v2' }); + expect( createExtension({ namespace: 'test', @@ -428,6 +440,93 @@ describe('createExtension', () => { ).toMatchObject({ version: 'v2' }); }); + it('should support new form of outputs with a generator', () => { + expect( + // @ts-expect-error + createExtension({ + namespace: 'test', + attachTo: { id: 'root', input: 'default' }, + output: [stringDataRef, numberDataRef], + *factory() { + // Missing all outputs + }, + }), + ).toMatchObject({ version: 'v2' }); + + expect( + // @ts-expect-error + createExtension({ + namespace: 'test', + attachTo: { id: 'root', input: 'default' }, + output: [stringDataRef, numberDataRef], + *factory() { + yield stringDataRef('hello'); // Missing number output + }, + }), + ).toMatchObject({ version: 'v2' }); + + // Duplicate output, we won't attempt to handle this a compile time and instead error out at runtime + expect( + createExtension({ + namespace: 'test', + attachTo: { id: 'root', input: 'default' }, + output: [stringDataRef], + *factory() { + yield stringDataRef('hello'); + yield stringDataRef('hello'); + }, + }), + ).toMatchObject({ version: 'v2' }); + + expect( + // @ts-expect-error + createExtension({ + namespace: 'test', + attachTo: { id: 'root', input: 'default' }, + output: [stringDataRef], + *factory() { + yield stringDataRef('hello'); + yield numberDataRef(4); // No declared output + }, + }), + ).toMatchObject({ version: 'v2' }); + + expect( + createExtension({ + namespace: 'test', + attachTo: { id: 'root', input: 'default' }, + output: [stringDataRef, numberDataRef], + *factory() { + yield stringDataRef('hello'); + yield numberDataRef(4); + }, + }), + ).toMatchObject({ version: 'v2' }); + + expect( + createExtension({ + namespace: 'test', + attachTo: { id: 'root', input: 'default' }, + output: [stringDataRef, numberDataRef.optional()], + *factory() { + yield stringDataRef('hello'); + yield numberDataRef(4); + }, + }), + ).toMatchObject({ version: 'v2' }); + + expect( + createExtension({ + namespace: 'test', + attachTo: { id: 'root', input: 'default' }, + output: [stringDataRef, numberDataRef.optional()], + *factory() { + yield stringDataRef('hello'); // Missing number output, but it's optional so that's allowed + }, + }), + ).toMatchObject({ version: 'v2' }); + }); + it('should support new form of inputs', () => { expect( createExtension({ diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.ts b/packages/frontend-plugin-api/src/wiring/createExtension.ts index 4d31982ed3..a8bf4ef17c 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.ts @@ -157,9 +157,16 @@ export type VerifyExtensionFactoryOutput< : never ) extends infer IRequiredOutputIds ? [IRequiredOutputIds] extends [UFactoryOutput['id']] - ? {} + ? [UFactoryOutput['id']] extends [UDeclaredOutput['id']] + ? {} + : { + 'Error: The extension factory has undeclared output(s)': Exclude< + UFactoryOutput['id'], + UDeclaredOutput['id'] + >; + } : { - 'Error: The extension factory is missing the following outputs': Exclude< + 'Error: The extension factory is missing the following output(s)': Exclude< IRequiredOutputIds, UFactoryOutput['id'] >; diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx index f57cc2b70e..6cf10d7f08 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx @@ -64,6 +64,45 @@ describe('createExtensionBlueprint', () => { expect(container.querySelector('h1')).toHaveTextContent('Hello, world!'); }); + it('should allow creation of extension blueprints with a generator', () => { + const TestExtensionBlueprint = createExtensionBlueprint({ + kind: 'test-extension', + attachTo: { id: 'test', input: 'default' }, + output: [coreExtensionData.reactElement], + *factory(params: { text: string }) { + yield coreExtensionData.reactElement(

{params.text}

); + }, + }); + + const extension = TestExtensionBlueprint.make({ + name: 'my-extension', + params: { + text: 'Hello, world!', + }, + }); + + expect(extension).toEqual({ + $$type: '@backstage/ExtensionDefinition', + attachTo: { + id: 'test', + input: 'default', + }, + configSchema: undefined, + disabled: false, + inputs: {}, + kind: 'test-extension', + name: 'my-extension', + namespace: undefined, + output: [coreExtensionData.reactElement], + factory: expect.any(Function), + toString: expect.any(Function), + version: 'v2', + }); + + const { container } = createExtensionTester(extension).render(); + expect(container.querySelector('h1')).toHaveTextContent('Hello, world!'); + }); + it('should allow overriding of the default factory', () => { const TestExtensionBlueprint = createExtensionBlueprint({ kind: 'test-extension', From 67e76f2bb93509145ce625e7e85336c7a42c890c Mon Sep 17 00:00:00 2001 From: Sydney Achinger <78113809+squid-ney@users.noreply.github.com> Date: Sat, 3 Aug 2024 20:36:13 -0400 Subject: [PATCH 095/372] Transform meta redirect tags (#25766) * Add TechDocs support for the mkdocs-redirects plugin. --------- Signed-off-by: Sydney Achinger --- .changeset/silly-candles-sin.md | 5 ++ .../TechDocsReaderPageContent/dom.tsx | 4 +- .../transformers/handleMetaRedirects.test.ts | 86 +++++++++++++++++++ .../transformers/handleMetaRedirects.ts | 59 +++++++++++++ .../transformers/html/transformer.test.tsx | 40 +++++++++ .../reader/transformers/html/transformer.ts | 24 +++++- 6 files changed, 216 insertions(+), 2 deletions(-) create mode 100644 .changeset/silly-candles-sin.md create mode 100644 plugins/techdocs/src/reader/transformers/handleMetaRedirects.test.ts create mode 100644 plugins/techdocs/src/reader/transformers/handleMetaRedirects.ts diff --git a/.changeset/silly-candles-sin.md b/.changeset/silly-candles-sin.md new file mode 100644 index 0000000000..b1d55113fd --- /dev/null +++ b/.changeset/silly-candles-sin.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs': patch +--- + +TechDocs now supports the `mkdocs-redirects` plugin. Redirects defined using the `mkdocs-redirect` plugin will be handled automatically in TechDocs. Redirecting to external urls is not supported. In the case that an external redirect url is provided, TechDocs will redirect to the current documentation site home. diff --git a/plugins/techdocs/src/reader/components/TechDocsReaderPageContent/dom.tsx b/plugins/techdocs/src/reader/components/TechDocsReaderPageContent/dom.tsx index de2460a543..c686827255 100644 --- a/plugins/techdocs/src/reader/components/TechDocsReaderPageContent/dom.tsx +++ b/plugins/techdocs/src/reader/components/TechDocsReaderPageContent/dom.tsx @@ -46,6 +46,7 @@ import { useStylesTransformer, } from '../../transformers'; import { useNavigateUrl } from './useNavigateUrl'; +import { handleMetaRedirects } from '../../transformers/handleMetaRedirects'; const MOBILE_MEDIA_QUERY = 'screen and (max-width: 76.1875em)'; @@ -186,6 +187,7 @@ export const useTechDocsReaderDom = ( const postRender = useCallback( async (transformedElement: Element) => transformer(transformedElement, [ + handleMetaRedirects(navigate, entityRef.name), scrollIntoNavigation(), copyToClipboard(theme), addLinkClickListener({ @@ -243,7 +245,7 @@ export const useTechDocsReaderDom = ( onLoaded: () => {}, }), ]), - [theme, navigate, analytics], + [theme, navigate, analytics, entityRef.name], ); useEffect(() => { diff --git a/plugins/techdocs/src/reader/transformers/handleMetaRedirects.test.ts b/plugins/techdocs/src/reader/transformers/handleMetaRedirects.test.ts new file mode 100644 index 0000000000..8fbd63428d --- /dev/null +++ b/plugins/techdocs/src/reader/transformers/handleMetaRedirects.test.ts @@ -0,0 +1,86 @@ +/* + * Copyright 2024 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 { handleMetaRedirects } from './handleMetaRedirects'; +import { createTestShadowDom } from '../../test-utils'; + +describe('handleMetaRedirects', () => { + const navigate = jest.fn(); + + const setUpNewTestShadowDom = async ( + html: string, + rootHref: string, + rootPath: string, + ) => { + const entityName = 'testEntity'; + // Mock window.location.href for each test + Object.defineProperty(window, 'location', { + value: { + href: rootHref, + pathname: rootPath, + hostname: 'localhost', + }, + writable: true, + }); + + return await createTestShadowDom(html, { + preTransformers: [], + postTransformers: [handleMetaRedirects(navigate, entityName)], + }); + }; + + afterEach(() => { + jest.clearAllMocks(); + }); + + it('should navigate to relative URL if meta redirect tag is present', async () => { + await setUpNewTestShadowDom( + ``, + 'http://localhost/docs/default/component/testEntity/subpath', + '/docs/default/component/testEntity/subpath', + ); + expect(navigate).toHaveBeenCalledWith( + 'http://localhost/docs/default/component/testEntity/anotherPage', + ); + }); + + it('should navigate to site home if meta redirect tag is present and external', async () => { + await setUpNewTestShadowDom( + ``, + 'http://localhost/docs/default/component/testEntity/subpath', + '/docs/default/component/testEntity/subpath', + ); + expect(navigate).toHaveBeenCalledWith('/docs/default/component/testEntity'); + }); + + it('should navigate to absolute URL if meta redirect tag is present and not external', async () => { + await setUpNewTestShadowDom( + ``, + 'http://localhost/docs/default/component/testEntity/subpath', + '/docs/default/component/testEntity/subpath', + ); + expect(navigate).toHaveBeenCalledWith('http://localhost/test'); + }); + + it('should not navigate if meta redirect tag is not present', async () => { + await setUpNewTestShadowDom( + ``, + 'http://localhost/docs/default/component/testEntity/subpath', + '/docs/default/component/testEntity/subpath', + ); + expect(navigate).not.toHaveBeenCalled(); + }); +}); diff --git a/plugins/techdocs/src/reader/transformers/handleMetaRedirects.ts b/plugins/techdocs/src/reader/transformers/handleMetaRedirects.ts new file mode 100644 index 0000000000..4c56d4d363 --- /dev/null +++ b/plugins/techdocs/src/reader/transformers/handleMetaRedirects.ts @@ -0,0 +1,59 @@ +/* + * Copyright 2024 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 { Transformer } from './transformer'; +import { normalizeUrl } from './rewriteDocLinks'; + +export const handleMetaRedirects = ( + navigate: (to: string) => void, + entityName: string, +): Transformer => { + return dom => { + for (const elem of Array.from(dom.querySelectorAll('meta'))) { + if (elem.getAttribute('http-equiv') === 'refresh') { + const metaContentParameters = elem + .getAttribute('content') + ?.split('url='); + if (!metaContentParameters || metaContentParameters.length < 2) { + continue; + } + + const metaUrl = metaContentParameters[1]; + const normalizedCurrentUrl = normalizeUrl(window.location.href); + // If metaUrl is relative, it will be resolved with base href. If it is absolute, it will replace the base href when creating URL object. + const absoluteRedirectObj = new URL(metaUrl, normalizedCurrentUrl); + const isExternalRedirect = + absoluteRedirectObj.hostname !== window.location.hostname; + + if (isExternalRedirect) { + // If the redirect is external, navigate to the documentation site home instead of the external url. + const currentTechDocPath = window.location.pathname; + const indexOfSiteHome = currentTechDocPath.indexOf(entityName); + const siteHomePath = currentTechDocPath.slice( + 0, + indexOfSiteHome + entityName.length, + ); + navigate(siteHomePath); + } else { + // The navigate function from dom.tsx is a wrapper around react-router navigate function that helps absolute url redirects. + navigate(absoluteRedirectObj.href); + } + return dom; + } + } + return dom; + }; +}; diff --git a/plugins/techdocs/src/reader/transformers/html/transformer.test.tsx b/plugins/techdocs/src/reader/transformers/html/transformer.test.tsx index ed5fbba085..e45d66c676 100644 --- a/plugins/techdocs/src/reader/transformers/html/transformer.test.tsx +++ b/plugins/techdocs/src/reader/transformers/html/transformer.test.tsx @@ -81,4 +81,44 @@ describe('Transformers > Html', () => { expect(iframes).toHaveLength(1); expect(iframes[0].src).toMatch('docs.google.com'); }); + + it('should return a function that allows refresh meta tags', async () => { + const { result } = renderHook(() => useSanitizerTransformer(), { wrapper }); + + const dirtyDom = document.createElement('html'); + dirtyDom.innerHTML = ` + + + + `; + const cleanDom = await result.current(dirtyDom); // calling html transformer + + const metaTags = Array.from( + cleanDom.querySelectorAll('meta'), + ); + + expect(metaTags).toHaveLength(1); + expect(metaTags[0].getAttribute('http-equiv')).toEqual('refresh'); + expect(metaTags[0].getAttribute('content')).toEqual( + '0;url=https://test.com', + ); + }); + + it('should return a function that does not allow non-refresh meta tags', async () => { + const { result } = renderHook(() => useSanitizerTransformer(), { wrapper }); + + const dirtyDom = document.createElement('html'); + dirtyDom.innerHTML = ` + + + + `; + const cleanDom = await result.current(dirtyDom); // calling html transformer + + const metaTags = Array.from( + cleanDom.querySelectorAll('meta'), + ); + + expect(metaTags).toHaveLength(0); + }); }); diff --git a/plugins/techdocs/src/reader/transformers/html/transformer.ts b/plugins/techdocs/src/reader/transformers/html/transformer.ts index 61498a37b0..4938a36648 100644 --- a/plugins/techdocs/src/reader/transformers/html/transformer.ts +++ b/plugins/techdocs/src/reader/transformers/html/transformer.ts @@ -44,17 +44,39 @@ export const useSanitizerTransformer = (): Transformer => { const hosts = config?.getOptionalStringArray('allowedIframeHosts'); DOMPurify.addHook('beforeSanitizeElements', removeUnsafeLinks); - const tags = ['link']; + const tags = ['link', 'meta']; if (hosts) { tags.push('iframe'); DOMPurify.addHook('beforeSanitizeElements', removeUnsafeIframes(hosts)); } + // Only allow meta tags if they are used for refreshing the page. They are required for the redirect feature. + DOMPurify.addHook('uponSanitizeElement', (currNode, data) => { + if (data.tagName === 'meta') { + const isMetaRefreshTag = + currNode.getAttribute('http-equiv') === 'refresh' && + currNode.getAttribute('content')?.includes('url='); + if (!isMetaRefreshTag) { + currNode.parentNode?.removeChild(currNode); + } + } + }); + + // Only allow http-equiv and content attributes on meta tags. They are required for the redirect feature. + DOMPurify.addHook('uponSanitizeAttribute', (currNode, data) => { + if (currNode.tagName !== 'meta') { + if (data.attrName === 'http-equiv' || data.attrName === 'content') { + currNode.removeAttribute(data.attrName); + } + } + }); + // using outerHTML as we want to preserve the html tag attributes (lang) return DOMPurify.sanitize(dom.outerHTML, { ADD_TAGS: tags, FORBID_TAGS: ['style'], + ADD_ATTR: ['http-equiv', 'content'], WHOLE_DOCUMENT: true, RETURN_DOM: true, }); From 08528670dc83cfa13678f0784bbd3a4024cd3fbe Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sat, 3 Aug 2024 12:42:46 +0200 Subject: [PATCH 096/372] core-compat-api: add forwards compat for app context Signed-off-by: Patrik Oldsberg --- packages/core-compat-api/package.json | 1 + .../compatWrapper/BackwardsCompatProvider.tsx | 4 +- .../compatWrapper/ForwardsCompatProvider.tsx | 102 +++++++++++++++++- .../src/compatWrapper/compatWrapper.test.tsx | 47 ++++++-- yarn.lock | 1 + 5 files changed, 145 insertions(+), 10 deletions(-) diff --git a/packages/core-compat-api/package.json b/packages/core-compat-api/package.json index a76f7878dd..4a143a50c7 100644 --- a/packages/core-compat-api/package.json +++ b/packages/core-compat-api/package.json @@ -44,6 +44,7 @@ "@backstage/frontend-app-api": "workspace:^", "@backstage/frontend-test-utils": "workspace:^", "@backstage/plugin-catalog": "workspace:^", + "@backstage/test-utils": "workspace:^", "@oriflame/backstage-plugin-score-card": "^0.8.0", "@testing-library/jest-dom": "^6.0.0", "@testing-library/react": "^15.0.0" diff --git a/packages/core-compat-api/src/compatWrapper/BackwardsCompatProvider.tsx b/packages/core-compat-api/src/compatWrapper/BackwardsCompatProvider.tsx index 288f3f900b..4f9ba3a836 100644 --- a/packages/core-compat-api/src/compatWrapper/BackwardsCompatProvider.tsx +++ b/packages/core-compat-api/src/compatWrapper/BackwardsCompatProvider.tsx @@ -50,7 +50,9 @@ const legacyPluginStore = getOrCreateGlobalSingleton( () => new WeakMap(), ); -function toLegacyPlugin(plugin: NewBackstagePlugin): LegacyBackstagePlugin { +export function toLegacyPlugin( + plugin: NewBackstagePlugin, +): LegacyBackstagePlugin { let legacy = legacyPluginStore.get(plugin); if (legacy) { return legacy; diff --git a/packages/core-compat-api/src/compatWrapper/ForwardsCompatProvider.tsx b/packages/core-compat-api/src/compatWrapper/ForwardsCompatProvider.tsx index 5544862aee..182b774cca 100644 --- a/packages/core-compat-api/src/compatWrapper/ForwardsCompatProvider.tsx +++ b/packages/core-compat-api/src/compatWrapper/ForwardsCompatProvider.tsx @@ -14,10 +14,106 @@ * limitations under the License. */ -import React from 'react'; +import { + ApiHolder, + ApiRef, + AppContext, + useApp, +} from '@backstage/core-plugin-api'; +import { + ComponentRef, + ComponentsApi, + CoreErrorBoundaryFallbackProps, + CoreNotFoundErrorPageProps, + CoreProgressProps, + IconComponent, + IconsApi, + componentsApiRef, + coreComponentRefs, + iconsApiRef, +} from '@backstage/frontend-plugin-api'; +import React, { ComponentType, useMemo } from 'react'; import { ReactNode } from 'react'; +import { toLegacyPlugin } from './BackwardsCompatProvider'; +// eslint-disable-next-line @backstage/no-relative-monorepo-imports +import { ApiProvider } from '../../../core-app-api/src/apis/system/ApiProvider'; + +class CompatComponentsApi implements ComponentsApi { + readonly #Progress: ComponentType; + readonly #NotFoundErrorPage: ComponentType; + readonly #ErrorBoundaryFallback: ComponentType; + + constructor(app: AppContext) { + const components = app.getComponents(); + const ErrorBoundaryFallback = (props: CoreErrorBoundaryFallbackProps) => ( + + ); + this.#Progress = components.Progress; + this.#NotFoundErrorPage = components.NotFoundErrorPage; + this.#ErrorBoundaryFallback = ErrorBoundaryFallback; + } + + getComponent(ref: ComponentRef): ComponentType { + switch (ref.id) { + case coreComponentRefs.progress.id: + return this.#Progress as ComponentType; + case coreComponentRefs.notFoundErrorPage.id: + return this.#NotFoundErrorPage as ComponentType; + case coreComponentRefs.errorBoundaryFallback.id: + return this.#ErrorBoundaryFallback as ComponentType; + default: + throw new Error( + `No backwards compatible component is available for ref '${ref.id}'`, + ); + } + } +} + +class CompatIconsApi implements IconsApi { + readonly #app: AppContext; + + constructor(app: AppContext) { + this.#app = app; + } + + getIcon(key: string): IconComponent | undefined { + return this.#app.getSystemIcon(key); + } + + listIconKeys(): string[] { + return Object.keys(this.#app.getSystemIcons()); + } +} + +class AppFallbackApis implements ApiHolder { + readonly #componentsApi: ComponentsApi; + readonly #iconsApi: IconsApi; + + constructor(app: AppContext) { + this.#componentsApi = new CompatComponentsApi(app); + this.#iconsApi = new CompatIconsApi(app); + } + + get(ref: ApiRef): T | undefined { + if (ref.id === componentsApiRef.id) { + return this.#componentsApi as T; + } else if (ref.id === iconsApiRef.id) { + return this.#iconsApi as T; + } + return undefined; + } +} + +function NewAppApisProvider(props: { children: ReactNode }) { + const app = useApp(); + const appFallbackApis = useMemo(() => new AppFallbackApis(app), [app]); + + return {props.children}; +} export function ForwardsCompatProvider(props: { children: ReactNode }) { - // TODO(Rugvip): Implement - return <>{props.children}; + return {props.children}; } diff --git a/packages/core-compat-api/src/compatWrapper/compatWrapper.test.tsx b/packages/core-compat-api/src/compatWrapper/compatWrapper.test.tsx index 74b9f209eb..b17ca2d508 100644 --- a/packages/core-compat-api/src/compatWrapper/compatWrapper.test.tsx +++ b/packages/core-compat-api/src/compatWrapper/compatWrapper.test.tsx @@ -16,21 +16,27 @@ import React from 'react'; import { + componentsApiRef, + coreComponentRefs, coreExtensionData, createExtension, + iconsApiRef, + useRouteRef as useNewRouteRef, + useApi, } from '@backstage/frontend-plugin-api'; import { createExtensionTester, - renderInTestApp, + renderInTestApp as renderInNewTestApp, } from '@backstage/frontend-test-utils'; import { screen } from '@testing-library/react'; import { compatWrapper } from './compatWrapper'; import { - createRouteRef, useApp, - useRouteRef, + useRouteRef as useOldRouteRef, + createRouteRef as createOldRouteRef, } from '@backstage/core-plugin-api'; import { convertLegacyRouteRef } from '../convertLegacyRouteRef'; +import { renderInTestApp as renderInOldTestApp } from '@backstage/test-utils'; describe('BackwardsCompatProvider', () => { it('should convert the app context', () => { @@ -74,17 +80,46 @@ describe('BackwardsCompatProvider', () => { }); it('should convert the routing context', () => { - const routeRef = createRouteRef({ id: 'test' }); + const routeRef = createOldRouteRef({ id: 'test' }); function Component() { - const link = useRouteRef(routeRef); + const link = useOldRouteRef(routeRef); return
link: {link()}
; } - renderInTestApp(compatWrapper(), { + renderInNewTestApp(compatWrapper(), { mountedRoutes: { '/test': convertLegacyRouteRef(routeRef) }, }); expect(screen.getByText('link: /test')).toBeInTheDocument(); }); }); + +describe('ForwardsCompatProvider', () => { + it('should convert the app context', async () => { + function Component() { + const components = useApi(componentsApiRef); + const icons = useApi(iconsApiRef); + return ( +
+ components:{' '} + {Object.entries(coreComponentRefs) + .map( + ([name, ref]) => + `${name}=${Boolean(components.getComponent(ref))}`, + ) + .join(', ')} + {'\n'} + icons: {icons.listIconKeys().join(', ')} +
+ ); + } + + await renderInOldTestApp(compatWrapper()); + + expect(screen.getByTestId('ctx').textContent).toMatchInlineSnapshot(` + "components: progress=true, notFoundErrorPage=true, errorBoundaryFallback=true + icons: kind:api, kind:component, kind:domain, kind:group, kind:location, kind:system, kind:user, kind:resource, kind:template, brokenImage, catalog, scaffolder, techdocs, search, chat, dashboard, docs, email, github, group, help, user, warning" + `); + }); +}); diff --git a/yarn.lock b/yarn.lock index c1dc608e87..e26ceb0aa6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4171,6 +4171,7 @@ __metadata: "@backstage/frontend-plugin-api": "workspace:^" "@backstage/frontend-test-utils": "workspace:^" "@backstage/plugin-catalog": "workspace:^" + "@backstage/test-utils": "workspace:^" "@backstage/version-bridge": "workspace:^" "@oriflame/backstage-plugin-score-card": ^0.8.0 "@testing-library/jest-dom": ^6.0.0 From 9ade0f99e5277113a8628eaef21cd90d138d8d62 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sat, 3 Aug 2024 16:01:32 +0200 Subject: [PATCH 097/372] core-compat-api: add test for convertLegacyRouteRef Signed-off-by: Patrik Oldsberg --- .../src/convertLegacyRouteRef.test.ts | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 packages/core-compat-api/src/convertLegacyRouteRef.test.ts diff --git a/packages/core-compat-api/src/convertLegacyRouteRef.test.ts b/packages/core-compat-api/src/convertLegacyRouteRef.test.ts new file mode 100644 index 0000000000..3681d0d2d9 --- /dev/null +++ b/packages/core-compat-api/src/convertLegacyRouteRef.test.ts @@ -0,0 +1,119 @@ +/* + * 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 { + createRouteRef as createOldRouteRef, + createSubRouteRef as createOldSubRouteRef, + createExternalRouteRef as createOldExternalRouteRef, +} from '@backstage/core-plugin-api'; +import { + RouteRef as NewRouteRef, + SubRouteRef as NewSubRouteRef, + ExternalRouteRef as NewExternalRouteRef, +} from '@backstage/frontend-plugin-api'; +import { convertLegacyRouteRef } from './convertLegacyRouteRef'; + +// eslint-disable-next-line @backstage/no-relative-monorepo-imports +import { toInternalRouteRef as toInternalNewRouteRef } from '../../frontend-plugin-api/src/routing/RouteRef'; +// eslint-disable-next-line @backstage/no-relative-monorepo-imports +import { toInternalSubRouteRef as toInternalNewSubRouteRef } from '../../frontend-plugin-api/src/routing/SubRouteRef'; +// eslint-disable-next-line @backstage/no-relative-monorepo-imports +import { toInternalExternalRouteRef as toInternalNewExternalRouteRef } from '../../frontend-plugin-api/src/routing/ExternalRouteRef'; + +describe('convertLegacyRouteRef', () => { + it('converts old to new', () => { + const ref1 = createOldRouteRef({ id: 'ref1' }); + const ref2 = createOldRouteRef({ id: 'ref2', params: ['p1', 'p2'] }); + const ref1sub1 = createOldSubRouteRef({ + id: 'sub1', + parent: ref1, + path: '/sub1', + }); + const ref1sub2 = createOldSubRouteRef({ + id: 'sub2', + parent: ref1, + path: '/sub2/:p3', + }); + const ref2sub1 = createOldSubRouteRef({ + id: 'sub1', + parent: ref2, + path: '/sub1/:p3', + }); + const ref3 = createOldExternalRouteRef({ + id: 'ref3', + }); + const ref4 = createOldExternalRouteRef({ + id: 'ref4', + optional: true, + defaultTarget: 'ref2', + params: ['p1', 'p2'], + }); + + const ref1Converted: NewRouteRef = convertLegacyRouteRef(ref1); + const ref2Converted: NewRouteRef = convertLegacyRouteRef(ref2); + const ref1sub1Converted: NewSubRouteRef = convertLegacyRouteRef(ref1sub1); + const ref1sub2Converted: NewSubRouteRef = convertLegacyRouteRef(ref1sub2); + const ref2sub1Converted: NewSubRouteRef = convertLegacyRouteRef(ref2sub1); + const ref3Converted: NewExternalRouteRef = convertLegacyRouteRef(ref3); + const ref4Converted: NewExternalRouteRef = convertLegacyRouteRef(ref4); + + const ref1Internal = toInternalNewRouteRef(ref1Converted); + const ref2Internal = toInternalNewRouteRef(ref2Converted); + const ref1sub1Internal = toInternalNewSubRouteRef(ref1sub1Converted); + const ref1sub2Internal = toInternalNewSubRouteRef(ref1sub2Converted); + const ref2sub1Internal = toInternalNewSubRouteRef(ref2sub1Converted); + const ref3Internal = toInternalNewExternalRouteRef(ref3Converted); + const ref4Internal = toInternalNewExternalRouteRef(ref4Converted); + + expect(ref1Internal.getDescription()).toBe( + 'routeRef{type=absolute,id=ref1}', + ); + expect(ref1Internal.getParams()).toEqual([]); + expect(ref2Internal.getDescription()).toBe( + 'routeRef{type=absolute,id=ref2}', + ); + expect(ref2Internal.getParams()).toEqual(['p1', 'p2']); + + expect(ref1sub1Internal.getDescription()).toBe( + 'routeRef{type=sub,id=sub1}', + ); + expect(ref1sub1Internal.getParams()).toEqual([]); + expect(ref1sub1Internal.getParent()).toBe(ref1); + expect(ref1sub2Internal.getDescription()).toBe( + 'routeRef{type=sub,id=sub2}', + ); + expect(ref1sub2Internal.getParams()).toEqual(['p3']); + expect(ref1sub2Internal.getParent()).toBe(ref1); + expect(ref2sub1Internal.getDescription()).toBe( + 'routeRef{type=sub,id=sub1}', + ); + expect(ref2sub1Internal.getParams()).toEqual(['p1', 'p2', 'p3']); + expect(ref2sub1Internal.getParent()).toBe(ref2); + + expect(ref3Internal.getDefaultTarget()).toBe(undefined); + expect(ref3Internal.getDescription()).toBe( + 'routeRef{type=external,id=ref3}', + ); + expect(ref3Internal.getParams()).toEqual([]); + expect(ref3Internal.optional).toBe(false); + expect(ref4Internal.getDefaultTarget()).toBe('ref2'); + expect(ref4Internal.getDescription()).toBe( + 'routeRef{type=external,id=ref4}', + ); + expect(ref4Internal.getParams()).toEqual(['p1', 'p2']); + expect(ref4Internal.optional).toBe(true); + }); +}); From ef1b2f4033058c0a0842bbbfa865121e584fba9d Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sun, 4 Aug 2024 11:28:38 +0200 Subject: [PATCH 098/372] core-compat-api: add support for converting new route refs to legacy Signed-off-by: Patrik Oldsberg --- packages/core-compat-api/api-report.md | 18 +++ .../src/convertLegacyRouteRef.test.ts | 87 ++++++++++++++ .../src/convertLegacyRouteRef.ts | 107 +++++++++++++++++- 3 files changed, 207 insertions(+), 5 deletions(-) diff --git a/packages/core-compat-api/api-report.md b/packages/core-compat-api/api-report.md index be80ca50e9..3cd78e6f30 100644 --- a/packages/core-compat-api/api-report.md +++ b/packages/core-compat-api/api-report.md @@ -44,6 +44,24 @@ export function convertLegacyRouteRef< ref: ExternalRouteRef, ): ExternalRouteRef_2; +// @public +export function convertLegacyRouteRef( + ref: RouteRef_2, +): RouteRef; + +// @public +export function convertLegacyRouteRef( + ref: SubRouteRef_2, +): SubRouteRef; + +// @public +export function convertLegacyRouteRef< + TParams extends AnyRouteRefParams, + TOptional extends boolean, +>( + ref: ExternalRouteRef_2, +): ExternalRouteRef; + // @public export function convertLegacyRouteRefs< TRefs extends { diff --git a/packages/core-compat-api/src/convertLegacyRouteRef.test.ts b/packages/core-compat-api/src/convertLegacyRouteRef.test.ts index 3681d0d2d9..bf82d1e034 100644 --- a/packages/core-compat-api/src/convertLegacyRouteRef.test.ts +++ b/packages/core-compat-api/src/convertLegacyRouteRef.test.ts @@ -15,6 +15,9 @@ */ import { + RouteRef as OldRouteRef, + SubRouteRef as OldSubRouteRef, + ExternalRouteRef as OldExternalRouteRef, createRouteRef as createOldRouteRef, createSubRouteRef as createOldSubRouteRef, createExternalRouteRef as createOldExternalRouteRef, @@ -23,6 +26,9 @@ import { RouteRef as NewRouteRef, SubRouteRef as NewSubRouteRef, ExternalRouteRef as NewExternalRouteRef, + createRouteRef as createNewRouteRef, + createSubRouteRef as createNewSubRouteRef, + createExternalRouteRef as createNewExternalRouteRef, } from '@backstage/frontend-plugin-api'; import { convertLegacyRouteRef } from './convertLegacyRouteRef'; @@ -70,6 +76,15 @@ describe('convertLegacyRouteRef', () => { const ref3Converted: NewExternalRouteRef = convertLegacyRouteRef(ref3); const ref4Converted: NewExternalRouteRef = convertLegacyRouteRef(ref4); + // Check for reference equality + expect(ref1).toBe(ref1Converted); + expect(ref2).toBe(ref2Converted); + expect(ref1sub1).toBe(ref1sub1Converted); + expect(ref1sub2).toBe(ref1sub2Converted); + expect(ref2sub1).toBe(ref2sub1Converted); + expect(ref3).toBe(ref3Converted); + expect(ref4).toBe(ref4Converted); + const ref1Internal = toInternalNewRouteRef(ref1Converted); const ref2Internal = toInternalNewRouteRef(ref2Converted); const ref1sub1Internal = toInternalNewSubRouteRef(ref1sub1Converted); @@ -116,4 +131,76 @@ describe('convertLegacyRouteRef', () => { expect(ref4Internal.getParams()).toEqual(['p1', 'p2']); expect(ref4Internal.optional).toBe(true); }); + + it('converts new to old', () => { + const ref1 = createNewRouteRef(); + const ref2 = createNewRouteRef({ params: ['p1', 'p2'] }); + const ref1sub1 = createNewSubRouteRef({ + parent: ref1, + path: '/sub1', + }); + const ref1sub2 = createNewSubRouteRef({ + parent: ref1, + path: '/sub2/:p3', + }); + const ref2sub1 = createNewSubRouteRef({ + parent: ref2, + path: '/sub1/:p3', + }); + const ref3 = createNewExternalRouteRef(); + const ref4 = createNewExternalRouteRef({ + optional: true, + defaultTarget: 'ref2', + params: ['p1', 'p2'], + }); + + const ref1Converted: OldRouteRef = convertLegacyRouteRef(ref1); + const ref2Converted: OldRouteRef = convertLegacyRouteRef(ref2); + const ref1sub1Converted: OldSubRouteRef = convertLegacyRouteRef(ref1sub1); + const ref1sub2Converted: OldSubRouteRef = convertLegacyRouteRef(ref1sub2); + const ref2sub1Converted: OldSubRouteRef = convertLegacyRouteRef(ref2sub1); + const ref3Converted: OldExternalRouteRef = convertLegacyRouteRef(ref3); + const ref4Converted: OldExternalRouteRef = convertLegacyRouteRef(ref4); + + // Check for reference equality + expect(ref1).toBe(ref1Converted); + expect(ref2).toBe(ref2Converted); + expect(ref1sub1).toBe(ref1sub1Converted); + expect(ref1sub2).toBe(ref1sub2Converted); + expect(ref2sub1).toBe(ref2sub1Converted); + expect(ref3).toBe(ref3Converted); + expect(ref4).toBe(ref4Converted); + + expect(String(ref1Converted)).toMatch(/^RouteRef\{created at '.*'\}$/); + expect(ref1Converted.params).toEqual([]); + expect(String(ref2Converted)).toMatch(/^RouteRef\{created at '.*'\}$/); + expect(ref2Converted.params).toEqual(['p1', 'p2']); + + expect(String(ref1sub1Converted)).toMatch( + /^SubRouteRef\{at \/sub1 with parent created at '.*'\}$/, + ); + expect(ref1sub1Converted.params).toEqual([]); + expect(ref1sub1Converted.parent).toBe(ref1); + expect(String(ref1sub2Converted)).toMatch( + /^SubRouteRef\{at \/sub2\/:p3 with parent created at '.*'\}$/, + ); + expect(ref1sub2Converted.params).toEqual(['p3']); + expect(ref1sub2Converted.parent).toBe(ref1); + expect(String(ref2sub1Converted)).toMatch( + /^SubRouteRef\{at \/sub1\/:p3 with parent created at '.*'\}$/, + ); + expect(ref2sub1Converted.params).toEqual(['p1', 'p2', 'p3']); + expect(ref2sub1Converted.parent).toBe(ref2); + + expect(String(ref3Converted)).toMatch( + /^ExternalRouteRef\{created at '.*'\}$/, + ); + expect(ref3Converted.params).toEqual([]); + expect(ref3Converted.optional).toBe(false); + expect(String(ref4Converted)).toMatch( + /^ExternalRouteRef\{created at '.*'\}$/, + ); + expect(ref4Converted.params).toEqual(['p1', 'p2']); + expect(ref4Converted.optional).toBe(true); + }); }); diff --git a/packages/core-compat-api/src/convertLegacyRouteRef.ts b/packages/core-compat-api/src/convertLegacyRouteRef.ts index c967f9e9b5..24c589bb87 100644 --- a/packages/core-compat-api/src/convertLegacyRouteRef.ts +++ b/packages/core-compat-api/src/convertLegacyRouteRef.ts @@ -116,16 +116,113 @@ export function convertLegacyRouteRef< ref: LegacyExternalRouteRef, ): ExternalRouteRef; +/** + * A temporary helper to convert a new route ref to the legacy system. + * + * @public + * @remarks + * + * In the future the legacy createRouteRef will instead create refs compatible with both systems. + */ +export function convertLegacyRouteRef( + ref: RouteRef, +): LegacyRouteRef; + +/** + * A temporary helper to convert a new sub route ref to the legacy system. + * + * @public + * @remarks + * + * In the future the legacy createSubRouteRef will instead create refs compatible with both systems. + */ +export function convertLegacyRouteRef( + ref: SubRouteRef, +): LegacySubRouteRef; + +/** + * A temporary helper to convert a new external route ref to the legacy system. + * + * @public + * @remarks + * + * In the future the legacy createExternalRouteRef will instead create refs compatible with both systems. + */ +export function convertLegacyRouteRef< + TParams extends AnyRouteRefParams, + TOptional extends boolean, +>( + ref: ExternalRouteRef, +): LegacyExternalRouteRef; export function convertLegacyRouteRef( - ref: LegacyRouteRef | LegacySubRouteRef | LegacyExternalRouteRef, -): RouteRef | SubRouteRef | ExternalRouteRef { + ref: + | LegacyRouteRef + | LegacySubRouteRef + | LegacyExternalRouteRef + | RouteRef + | SubRouteRef + | ExternalRouteRef, +): + | RouteRef + | SubRouteRef + | ExternalRouteRef + | LegacyRouteRef + | LegacySubRouteRef + | LegacyExternalRouteRef { + const isNew = '$$type' in ref; + const oldType = (ref as unknown as { [routeRefType]: unknown })[routeRefType]; + // Ref has already been converted - if ('$$type' in ref) { - return ref as unknown as RouteRef | SubRouteRef | ExternalRouteRef; + if (isNew && oldType) { + return ref as any; } - const type = (ref as unknown as { [routeRefType]: unknown })[routeRefType]; + if (isNew) { + return convertNewToOld( + ref as unknown as RouteRef | SubRouteRef | ExternalRouteRef, + ); + } + return convertOldToNew(ref, oldType); +} + +function convertNewToOld( + ref: RouteRef | SubRouteRef | ExternalRouteRef, +): LegacyRouteRef | LegacySubRouteRef | LegacyExternalRouteRef { + if (ref.$$type === '@backstage/RouteRef') { + const newRef = toInternalRouteRef(ref); + return Object.assign(ref, { + [routeRefType]: 'absolute', + params: newRef.getParams(), + title: newRef.getDescription(), + } as Omit) as unknown as LegacyRouteRef; + } + if (ref.$$type === '@backstage/SubRouteRef') { + const newRef = toInternalSubRouteRef(ref); + return Object.assign(ref, { + [routeRefType]: 'sub', + parent: convertLegacyRouteRef(newRef.getParent()), + params: newRef.getParams(), + } as Omit) as unknown as LegacySubRouteRef; + } + if (ref.$$type === '@backstage/ExternalRouteRef') { + const newRef = toInternalExternalRouteRef(ref); + return Object.assign(ref, { + [routeRefType]: 'external', + params: newRef.getParams(), + defaultTarget: newRef.getDefaultTarget(), + } as Omit) as unknown as LegacyExternalRouteRef; + } + + throw new Error( + `Failed to convert route ref, unknown type '${(ref as any).$$type}'`, + ); +} + +function convertOldToNew( + ref: LegacyRouteRef | LegacySubRouteRef | LegacyExternalRouteRef, + type: unknown, +): RouteRef | SubRouteRef | ExternalRouteRef { if (type === 'absolute') { const legacyRef = ref as LegacyRouteRef; const legacyRefStr = String(legacyRef); From f8e2383016dc5d42719d4d8d67f573b604897388 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sun, 4 Aug 2024 11:40:32 +0200 Subject: [PATCH 099/372] core-compat-api: add forwards compat for routing context Signed-off-by: Patrik Oldsberg --- .../compatWrapper/ForwardsCompatProvider.tsx | 55 ++++++++++++++++++- .../src/compatWrapper/compatWrapper.test.tsx | 16 ++++++ 2 files changed, 68 insertions(+), 3 deletions(-) diff --git a/packages/core-compat-api/src/compatWrapper/ForwardsCompatProvider.tsx b/packages/core-compat-api/src/compatWrapper/ForwardsCompatProvider.tsx index 182b774cca..b2200387cc 100644 --- a/packages/core-compat-api/src/compatWrapper/ForwardsCompatProvider.tsx +++ b/packages/core-compat-api/src/compatWrapper/ForwardsCompatProvider.tsx @@ -21,22 +21,34 @@ import { useApp, } from '@backstage/core-plugin-api'; import { + AnyRouteRefParams, ComponentRef, ComponentsApi, CoreErrorBoundaryFallbackProps, CoreNotFoundErrorPageProps, CoreProgressProps, + ExternalRouteRef, IconComponent, IconsApi, + RouteFunc, + RouteRef, + RouteResolutionApi, + RouteResolutionApiResolveOptions, + SubRouteRef, componentsApiRef, coreComponentRefs, iconsApiRef, + routeResolutionApiRef, } from '@backstage/frontend-plugin-api'; import React, { ComponentType, useMemo } from 'react'; import { ReactNode } from 'react'; import { toLegacyPlugin } from './BackwardsCompatProvider'; // eslint-disable-next-line @backstage/no-relative-monorepo-imports import { ApiProvider } from '../../../core-app-api/src/apis/system/ApiProvider'; +import { useVersionedContext } from '@backstage/version-bridge'; +// eslint-disable-next-line @backstage/no-relative-monorepo-imports +import { type RouteResolver } from '../../../core-plugin-api/src/routing/useRouteRef'; +import { convertLegacyRouteRef } from '../convertLegacyRouteRef'; class CompatComponentsApi implements ComponentsApi { readonly #Progress: ComponentType; @@ -88,13 +100,34 @@ class CompatIconsApi implements IconsApi { } } -class AppFallbackApis implements ApiHolder { +class CompatRouteResolutionApi implements RouteResolutionApi { + readonly #routeResolver: RouteResolver; + + constructor(routeResolver: RouteResolver) { + this.#routeResolver = routeResolver; + } + + resolve( + anyRouteRef: + | RouteRef + | SubRouteRef + | ExternalRouteRef, + options?: RouteResolutionApiResolveOptions | undefined, + ): RouteFunc | undefined { + const legacyRef = convertLegacyRouteRef(anyRouteRef as RouteRef); + return this.#routeResolver.resolve(legacyRef, options?.sourcePath ?? '/'); + } +} + +class ForwardsCompatApis implements ApiHolder { readonly #componentsApi: ComponentsApi; readonly #iconsApi: IconsApi; + readonly #routeResolutionApi: RouteResolutionApi; - constructor(app: AppContext) { + constructor(app: AppContext, routeResolver: RouteResolver) { this.#componentsApi = new CompatComponentsApi(app); this.#iconsApi = new CompatIconsApi(app); + this.#routeResolutionApi = new CompatRouteResolutionApi(routeResolver); } get(ref: ApiRef): T | undefined { @@ -102,6 +135,8 @@ class AppFallbackApis implements ApiHolder { return this.#componentsApi as T; } else if (ref.id === iconsApiRef.id) { return this.#iconsApi as T; + } else if (ref.id === routeResolutionApiRef.id) { + return this.#routeResolutionApi as T; } return undefined; } @@ -109,7 +144,21 @@ class AppFallbackApis implements ApiHolder { function NewAppApisProvider(props: { children: ReactNode }) { const app = useApp(); - const appFallbackApis = useMemo(() => new AppFallbackApis(app), [app]); + const versionedRouteResolverContext = useVersionedContext<{ + 1: RouteResolver; + }>('routing-context'); + if (!versionedRouteResolverContext) { + throw new Error('Routing context is not available'); + } + const routeResolver = versionedRouteResolverContext.atVersion(1); + if (!routeResolver) { + throw new Error('RoutingContext v1 not available'); + } + + const appFallbackApis = useMemo( + () => new ForwardsCompatApis(app, routeResolver), + [app, routeResolver], + ); return {props.children}; } diff --git a/packages/core-compat-api/src/compatWrapper/compatWrapper.test.tsx b/packages/core-compat-api/src/compatWrapper/compatWrapper.test.tsx index b17ca2d508..6a27bf19e8 100644 --- a/packages/core-compat-api/src/compatWrapper/compatWrapper.test.tsx +++ b/packages/core-compat-api/src/compatWrapper/compatWrapper.test.tsx @@ -22,6 +22,7 @@ import { createExtension, iconsApiRef, useRouteRef as useNewRouteRef, + createRouteRef as createNewRouteRef, useApi, } from '@backstage/frontend-plugin-api'; import { @@ -122,4 +123,19 @@ describe('ForwardsCompatProvider', () => { icons: kind:api, kind:component, kind:domain, kind:group, kind:location, kind:system, kind:user, kind:resource, kind:template, brokenImage, catalog, scaffolder, techdocs, search, chat, dashboard, docs, email, github, group, help, user, warning" `); }); + + it('should convert the routing context', async () => { + const routeRef = createNewRouteRef(); + + function Component() { + const link = useNewRouteRef(routeRef); + return
link: {link()}
; + } + + await renderInOldTestApp(compatWrapper(), { + mountedRoutes: { '/test': convertLegacyRouteRef(routeRef) }, + }); + + expect(screen.getByText('link: /test')).toBeInTheDocument(); + }); }); From 16cf96c28a5cccc5b0446f7a20efd9004c86e1d8 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sun, 4 Aug 2024 11:48:55 +0200 Subject: [PATCH 100/372] changesets: add changeset for new -> old compat Signed-off-by: Patrik Oldsberg --- .changeset/slow-ducks-rush.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/slow-ducks-rush.md diff --git a/.changeset/slow-ducks-rush.md b/.changeset/slow-ducks-rush.md new file mode 100644 index 0000000000..c09f883e9c --- /dev/null +++ b/.changeset/slow-ducks-rush.md @@ -0,0 +1,5 @@ +--- +'@backstage/core-compat-api': patch +--- + +Both `compatWrapper` and `convertLegacyRouteRef` now support converting from the new system to the old. From 8b45adcadd32fa70eee7c9c4a967b6764ec61a4f Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sun, 4 Aug 2024 17:37:38 +0200 Subject: [PATCH 101/372] backend-plugin-api: internal refactor to split creators Signed-off-by: Patrik Oldsberg --- ...es.test.ts => createBackendModule.test.ts} | 53 +--- .../src/wiring/createBackendModule.ts | 107 ++++++++ .../src/wiring/createBackendPlugin.test.ts | 55 +++++ .../src/wiring/createBackendPlugin.ts | 100 ++++++++ .../src/wiring/createExtensionPoint.test.ts | 27 +++ .../src/wiring/createExtensionPoint.ts | 58 +++++ .../src/wiring/factories.ts | 229 ------------------ .../backend-plugin-api/src/wiring/index.ts | 16 +- 8 files changed, 354 insertions(+), 291 deletions(-) rename packages/backend-plugin-api/src/wiring/{factories.test.ts => createBackendModule.test.ts} (53%) create mode 100644 packages/backend-plugin-api/src/wiring/createBackendModule.ts create mode 100644 packages/backend-plugin-api/src/wiring/createBackendPlugin.test.ts create mode 100644 packages/backend-plugin-api/src/wiring/createBackendPlugin.ts create mode 100644 packages/backend-plugin-api/src/wiring/createExtensionPoint.test.ts create mode 100644 packages/backend-plugin-api/src/wiring/createExtensionPoint.ts delete mode 100644 packages/backend-plugin-api/src/wiring/factories.ts diff --git a/packages/backend-plugin-api/src/wiring/factories.test.ts b/packages/backend-plugin-api/src/wiring/createBackendModule.test.ts similarity index 53% rename from packages/backend-plugin-api/src/wiring/factories.test.ts rename to packages/backend-plugin-api/src/wiring/createBackendModule.test.ts index 6d5c1f39cd..31496020bf 100644 --- a/packages/backend-plugin-api/src/wiring/factories.test.ts +++ b/packages/backend-plugin-api/src/wiring/createBackendModule.test.ts @@ -14,60 +14,9 @@ * limitations under the License. */ -import { - createBackendModule, - createBackendPlugin, - createExtensionPoint, -} from './factories'; +import { createBackendModule } from './createBackendModule'; import { InternalBackendFeature } from './types'; -describe('createExtensionPoint', () => { - it('should create an ExtensionPoint', () => { - const extensionPoint = createExtensionPoint({ id: 'x' }); - expect(extensionPoint).toBeDefined(); - expect(extensionPoint.id).toBe('x'); - expect(() => extensionPoint.T).not.toThrow(); - expect(String(extensionPoint)).toBe('extensionPoint{x}'); - }); -}); - -describe('createBackendPlugin', () => { - it('should create a BackendPlugin', () => { - const result = createBackendPlugin({ - pluginId: 'x', - register(r) { - r.registerInit({ deps: {}, async init() {} }); - }, - }); - - // legacy form - const legacy = result() as unknown as InternalBackendFeature; - expect(legacy.$$type).toEqual('@backstage/BackendFeature'); - expect(legacy.version).toEqual('v1'); - expect(legacy.getRegistrations).toEqual(expect.any(Function)); - - // new form - const plugin = result as unknown as InternalBackendFeature; - expect(plugin.$$type).toEqual('@backstage/BackendFeature'); - expect(plugin.version).toEqual('v1'); - expect(plugin.getRegistrations).toEqual(expect.any(Function)); - expect(plugin.getRegistrations()).toEqual([ - { - type: 'plugin', - pluginId: 'x', - extensionPoints: [], - init: { - deps: expect.any(Object), - func: expect.any(Function), - }, - }, - ]); - - // @ts-expect-error - expect(plugin({ a: 'a' })).toBeDefined(); - }); -}); - describe('createBackendModule', () => { it('should create a BackendModule', () => { const result = createBackendModule({ diff --git a/packages/backend-plugin-api/src/wiring/createBackendModule.ts b/packages/backend-plugin-api/src/wiring/createBackendModule.ts new file mode 100644 index 0000000000..56f041606e --- /dev/null +++ b/packages/backend-plugin-api/src/wiring/createBackendModule.ts @@ -0,0 +1,107 @@ +/* + * Copyright 2022 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 { BackendFeatureCompat } from '../types'; +import { + BackendModuleRegistrationPoints, + InternalBackendModuleRegistration, + InternalBackendPluginRegistration, +} from './types'; + +/** + * The configuration options passed to {@link createBackendModule}. + * + * @public + * @see {@link https://backstage.io/docs/backend-system/architecture/modules | The architecture of modules} + * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns} + */ +export interface CreateBackendModuleOptions { + /** + * Should exactly match the `id` of the plugin that the module extends. + * + * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns} + */ + pluginId: string; + + /** + * The ID of this module, used to identify the module and ensure that it is not installed twice. + */ + moduleId: string; + register(reg: BackendModuleRegistrationPoints): void; +} + +/** + * Creates a new backend module for a given plugin. + * + * @public + * @see {@link https://backstage.io/docs/backend-system/architecture/modules | The architecture of modules} + * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns} + */ +export function createBackendModule( + options: CreateBackendModuleOptions, +): BackendFeatureCompat { + function getRegistrations() { + const extensionPoints: InternalBackendPluginRegistration['extensionPoints'] = + []; + let init: InternalBackendModuleRegistration['init'] | undefined = undefined; + + options.register({ + registerExtensionPoint(ext, impl) { + if (init) { + throw new Error('registerExtensionPoint called after registerInit'); + } + extensionPoints.push([ext, impl]); + }, + registerInit(regInit) { + if (init) { + throw new Error('registerInit must only be called once'); + } + init = { + deps: regInit.deps, + func: regInit.init, + }; + }, + }); + + if (!init) { + throw new Error( + `registerInit was not called by register in ${options.moduleId} module for ${options.pluginId}`, + ); + } + + return [ + { + type: 'module', + pluginId: options.pluginId, + moduleId: options.moduleId, + extensionPoints, + init, + }, + ]; + } + + function backendFeatureCompatWrapper() { + return backendFeatureCompatWrapper; + } + + Object.assign(backendFeatureCompatWrapper, { + $$type: '@backstage/BackendFeature' as const, + version: 'v1', + getRegistrations, + }); + + return backendFeatureCompatWrapper as BackendFeatureCompat; +} diff --git a/packages/backend-plugin-api/src/wiring/createBackendPlugin.test.ts b/packages/backend-plugin-api/src/wiring/createBackendPlugin.test.ts new file mode 100644 index 0000000000..cd1ce164bf --- /dev/null +++ b/packages/backend-plugin-api/src/wiring/createBackendPlugin.test.ts @@ -0,0 +1,55 @@ +/* + * Copyright 2022 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 { createBackendPlugin } from './createBackendPlugin'; +import { InternalBackendFeature } from './types'; + +describe('createBackendPlugin', () => { + it('should create a BackendPlugin', () => { + const result = createBackendPlugin({ + pluginId: 'x', + register(r) { + r.registerInit({ deps: {}, async init() {} }); + }, + }); + + // legacy form + const legacy = result() as unknown as InternalBackendFeature; + expect(legacy.$$type).toEqual('@backstage/BackendFeature'); + expect(legacy.version).toEqual('v1'); + expect(legacy.getRegistrations).toEqual(expect.any(Function)); + + // new form + const plugin = result as unknown as InternalBackendFeature; + expect(plugin.$$type).toEqual('@backstage/BackendFeature'); + expect(plugin.version).toEqual('v1'); + expect(plugin.getRegistrations).toEqual(expect.any(Function)); + expect(plugin.getRegistrations()).toEqual([ + { + type: 'plugin', + pluginId: 'x', + extensionPoints: [], + init: { + deps: expect.any(Object), + func: expect.any(Function), + }, + }, + ]); + + // @ts-expect-error + expect(plugin({ a: 'a' })).toBeDefined(); + }); +}); diff --git a/packages/backend-plugin-api/src/wiring/createBackendPlugin.ts b/packages/backend-plugin-api/src/wiring/createBackendPlugin.ts new file mode 100644 index 0000000000..f5984ef24b --- /dev/null +++ b/packages/backend-plugin-api/src/wiring/createBackendPlugin.ts @@ -0,0 +1,100 @@ +/* + * Copyright 2022 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 { BackendFeatureCompat } from '../types'; +import { + BackendPluginRegistrationPoints, + InternalBackendPluginRegistration, +} from './types'; + +/** + * The configuration options passed to {@link createBackendPlugin}. + * + * @public + * @see {@link https://backstage.io/docs/backend-system/architecture/plugins | The architecture of plugins} + * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns} + */ +export interface CreateBackendPluginOptions { + /** + * The ID of this plugin. + * + * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns} + */ + pluginId: string; + register(reg: BackendPluginRegistrationPoints): void; +} + +/** + * Creates a new backend plugin. + * + * @public + * @see {@link https://backstage.io/docs/backend-system/architecture/plugins | The architecture of plugins} + * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns} + */ +export function createBackendPlugin( + options: CreateBackendPluginOptions, +): BackendFeatureCompat { + function getRegistrations() { + const extensionPoints: InternalBackendPluginRegistration['extensionPoints'] = + []; + let init: InternalBackendPluginRegistration['init'] | undefined = undefined; + + options.register({ + registerExtensionPoint(ext, impl) { + if (init) { + throw new Error('registerExtensionPoint called after registerInit'); + } + extensionPoints.push([ext, impl]); + }, + registerInit(regInit) { + if (init) { + throw new Error('registerInit must only be called once'); + } + init = { + deps: regInit.deps, + func: regInit.init, + }; + }, + }); + + if (!init) { + throw new Error( + `registerInit was not called by register in ${options.pluginId}`, + ); + } + + return [ + { + type: 'plugin', + pluginId: options.pluginId, + extensionPoints, + init, + }, + ]; + } + + function backendFeatureCompatWrapper() { + return backendFeatureCompatWrapper; + } + + Object.assign(backendFeatureCompatWrapper, { + $$type: '@backstage/BackendFeature' as const, + version: 'v1', + getRegistrations, + }); + + return backendFeatureCompatWrapper as BackendFeatureCompat; +} diff --git a/packages/backend-plugin-api/src/wiring/createExtensionPoint.test.ts b/packages/backend-plugin-api/src/wiring/createExtensionPoint.test.ts new file mode 100644 index 0000000000..825063e845 --- /dev/null +++ b/packages/backend-plugin-api/src/wiring/createExtensionPoint.test.ts @@ -0,0 +1,27 @@ +/* + * Copyright 2022 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 { createExtensionPoint } from './createExtensionPoint'; + +describe('createExtensionPoint', () => { + it('should create an ExtensionPoint', () => { + const extensionPoint = createExtensionPoint({ id: 'x' }); + expect(extensionPoint).toBeDefined(); + expect(extensionPoint.id).toBe('x'); + expect(() => extensionPoint.T).not.toThrow(); + expect(String(extensionPoint)).toBe('extensionPoint{x}'); + }); +}); diff --git a/packages/backend-plugin-api/src/wiring/createExtensionPoint.ts b/packages/backend-plugin-api/src/wiring/createExtensionPoint.ts new file mode 100644 index 0000000000..9dbae249ea --- /dev/null +++ b/packages/backend-plugin-api/src/wiring/createExtensionPoint.ts @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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 { ExtensionPoint } from './types'; + +/** + * The configuration options passed to {@link createExtensionPoint}. + * + * @public + * @see {@link https://backstage.io/docs/backend-system/architecture/extension-points | The architecture of extension points} + * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns} + */ +export interface CreateExtensionPointOptions { + /** + * The ID of this extension point. + * + * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns} + */ + id: string; +} + +/** + * Creates a new backend extension point. + * + * @public + * @see {@link https://backstage.io/docs/backend-system/architecture/extension-points | The architecture of extension points} + */ +export function createExtensionPoint( + options: CreateExtensionPointOptions, +): ExtensionPoint { + return { + id: options.id, + get T(): T { + if (process.env.NODE_ENV === 'test') { + // Avoid throwing errors so tests asserting extensions' properties cannot be easily broken + return null as T; + } + throw new Error(`tried to read ExtensionPoint.T of ${this}`); + }, + toString() { + return `extensionPoint{${options.id}}`; + }, + $$type: '@backstage/ExtensionPoint', + }; +} diff --git a/packages/backend-plugin-api/src/wiring/factories.ts b/packages/backend-plugin-api/src/wiring/factories.ts deleted file mode 100644 index 81e2247152..0000000000 --- a/packages/backend-plugin-api/src/wiring/factories.ts +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright 2022 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 { BackendFeatureCompat } from '../types'; -import { - BackendModuleRegistrationPoints, - BackendPluginRegistrationPoints, - ExtensionPoint, - InternalBackendModuleRegistration, - InternalBackendPluginRegistration, -} from './types'; - -/** - * The configuration options passed to {@link createExtensionPoint}. - * - * @public - * @see {@link https://backstage.io/docs/backend-system/architecture/extension-points | The architecture of extension points} - * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns} - */ -export interface CreateExtensionPointOptions { - /** - * The ID of this extension point. - * - * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns} - */ - id: string; -} - -/** - * Creates a new backend extension point. - * - * @public - * @see {@link https://backstage.io/docs/backend-system/architecture/extension-points | The architecture of extension points} - */ -export function createExtensionPoint( - options: CreateExtensionPointOptions, -): ExtensionPoint { - return { - id: options.id, - get T(): T { - if (process.env.NODE_ENV === 'test') { - // Avoid throwing errors so tests asserting extensions' properties cannot be easily broken - return null as T; - } - throw new Error(`tried to read ExtensionPoint.T of ${this}`); - }, - toString() { - return `extensionPoint{${options.id}}`; - }, - $$type: '@backstage/ExtensionPoint', - }; -} - -/** - * The configuration options passed to {@link createBackendPlugin}. - * - * @public - * @see {@link https://backstage.io/docs/backend-system/architecture/plugins | The architecture of plugins} - * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns} - */ -export interface CreateBackendPluginOptions { - /** - * The ID of this plugin. - * - * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns} - */ - pluginId: string; - register(reg: BackendPluginRegistrationPoints): void; -} - -/** - * Creates a new backend plugin. - * - * @public - * @see {@link https://backstage.io/docs/backend-system/architecture/plugins | The architecture of plugins} - * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns} - */ -export function createBackendPlugin( - options: CreateBackendPluginOptions, -): BackendFeatureCompat { - function getRegistrations() { - const extensionPoints: InternalBackendPluginRegistration['extensionPoints'] = - []; - let init: InternalBackendPluginRegistration['init'] | undefined = undefined; - - options.register({ - registerExtensionPoint(ext, impl) { - if (init) { - throw new Error('registerExtensionPoint called after registerInit'); - } - extensionPoints.push([ext, impl]); - }, - registerInit(regInit) { - if (init) { - throw new Error('registerInit must only be called once'); - } - init = { - deps: regInit.deps, - func: regInit.init, - }; - }, - }); - - if (!init) { - throw new Error( - `registerInit was not called by register in ${options.pluginId}`, - ); - } - - return [ - { - type: 'plugin', - pluginId: options.pluginId, - extensionPoints, - init, - }, - ]; - } - - function backendFeatureCompatWrapper() { - return backendFeatureCompatWrapper; - } - - Object.assign(backendFeatureCompatWrapper, { - $$type: '@backstage/BackendFeature' as const, - version: 'v1', - getRegistrations, - }); - - return backendFeatureCompatWrapper as BackendFeatureCompat; -} - -/** - * The configuration options passed to {@link createBackendModule}. - * - * @public - * @see {@link https://backstage.io/docs/backend-system/architecture/modules | The architecture of modules} - * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns} - */ -export interface CreateBackendModuleOptions { - /** - * Should exactly match the `id` of the plugin that the module extends. - * - * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns} - */ - pluginId: string; - - /** - * The ID of this module, used to identify the module and ensure that it is not installed twice. - */ - moduleId: string; - register(reg: BackendModuleRegistrationPoints): void; -} - -/** - * Creates a new backend module for a given plugin. - * - * @public - * @see {@link https://backstage.io/docs/backend-system/architecture/modules | The architecture of modules} - * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns} - */ -export function createBackendModule( - options: CreateBackendModuleOptions, -): BackendFeatureCompat { - function getRegistrations() { - const extensionPoints: InternalBackendPluginRegistration['extensionPoints'] = - []; - let init: InternalBackendModuleRegistration['init'] | undefined = undefined; - - options.register({ - registerExtensionPoint(ext, impl) { - if (init) { - throw new Error('registerExtensionPoint called after registerInit'); - } - extensionPoints.push([ext, impl]); - }, - registerInit(regInit) { - if (init) { - throw new Error('registerInit must only be called once'); - } - init = { - deps: regInit.deps, - func: regInit.init, - }; - }, - }); - - if (!init) { - throw new Error( - `registerInit was not called by register in ${options.moduleId} module for ${options.pluginId}`, - ); - } - - return [ - { - type: 'module', - pluginId: options.pluginId, - moduleId: options.moduleId, - extensionPoints, - init, - }, - ]; - } - - function backendFeatureCompatWrapper() { - return backendFeatureCompatWrapper; - } - - Object.assign(backendFeatureCompatWrapper, { - $$type: '@backstage/BackendFeature' as const, - version: 'v1', - getRegistrations, - }); - - return backendFeatureCompatWrapper as BackendFeatureCompat; -} diff --git a/packages/backend-plugin-api/src/wiring/index.ts b/packages/backend-plugin-api/src/wiring/index.ts index 5197cec050..5f7960e9cd 100644 --- a/packages/backend-plugin-api/src/wiring/index.ts +++ b/packages/backend-plugin-api/src/wiring/index.ts @@ -14,17 +14,13 @@ * limitations under the License. */ -import type { - CreateBackendPluginOptions, - CreateBackendModuleOptions, - CreateExtensionPointOptions, -} from './factories'; +import { type CreateBackendModuleOptions } from './createBackendModule'; +import { type CreateBackendPluginOptions } from './createBackendPlugin'; +import { type CreateExtensionPointOptions } from './createExtensionPoint'; -export { - createBackendModule, - createBackendPlugin, - createExtensionPoint, -} from './factories'; +export { createBackendModule } from './createBackendModule'; +export { createBackendPlugin } from './createBackendPlugin'; +export { createExtensionPoint } from './createExtensionPoint'; export type { BackendModuleRegistrationPoints, From 6061061a818900224275c157d275621c32c53bf0 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 5 Aug 2024 01:26:08 +0200 Subject: [PATCH 102/372] backend-plugin-api: add createBackendFeatureLoader Signed-off-by: Patrik Oldsberg --- .changeset/calm-crabs-drop.md | 5 + packages/backend-plugin-api/api-report.md | 41 ++++ .../wiring/createBackendFeatureLoader.test.ts | 213 ++++++++++++++++++ .../src/wiring/createBackendFeatureLoader.ts | 73 ++++++ .../backend-plugin-api/src/wiring/index.ts | 4 + .../backend-plugin-api/src/wiring/types.ts | 14 +- 6 files changed, 349 insertions(+), 1 deletion(-) create mode 100644 .changeset/calm-crabs-drop.md create mode 100644 packages/backend-plugin-api/src/wiring/createBackendFeatureLoader.test.ts create mode 100644 packages/backend-plugin-api/src/wiring/createBackendFeatureLoader.ts diff --git a/.changeset/calm-crabs-drop.md b/.changeset/calm-crabs-drop.md new file mode 100644 index 0000000000..09bed7c091 --- /dev/null +++ b/.changeset/calm-crabs-drop.md @@ -0,0 +1,5 @@ +--- +'@backstage/backend-plugin-api': patch +--- + +Added `createBackendFeatureLoader`, which can be used to create an installable backend feature that can in turn load in additional backend features in a dynamic way. diff --git a/packages/backend-plugin-api/api-report.md b/packages/backend-plugin-api/api-report.md index b3c35d3699..3bd112682a 100644 --- a/packages/backend-plugin-api/api-report.md +++ b/packages/backend-plugin-api/api-report.md @@ -213,6 +213,47 @@ export namespace coreServices { identity: ServiceRef; } +// @public +export function createBackendFeatureLoader< + TDeps extends { + [name in string]: unknown; + }, +>(options: CreateBackendFeatureLoaderOptions): BackendFeature; + +// @public +export interface CreateBackendFeatureLoaderOptions< + TDeps extends { + [name in string]: unknown; + }, +> { + // (undocumented) + deps?: { + [name in keyof TDeps]: ServiceRef; + }; + // (undocumented) + loader(deps: TDeps): + | Iterable< + | BackendFeature + | Promise<{ + default: BackendFeature; + }> + > + | Promise< + Iterable< + | BackendFeature + | Promise<{ + default: BackendFeature; + }> + > + > + | AsyncIterable< + | BackendFeature + | { + default: BackendFeature; + } + >; +} + // @public export function createBackendModule( options: CreateBackendModuleOptions, diff --git a/packages/backend-plugin-api/src/wiring/createBackendFeatureLoader.test.ts b/packages/backend-plugin-api/src/wiring/createBackendFeatureLoader.test.ts new file mode 100644 index 0000000000..98471bef4c --- /dev/null +++ b/packages/backend-plugin-api/src/wiring/createBackendFeatureLoader.test.ts @@ -0,0 +1,213 @@ +/* + * Copyright 2022 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 { coreServices, createServiceFactory } from '../services'; +import { BackendFeature } from '../types'; +import { createBackendFeatureLoader } from './createBackendFeatureLoader'; +import { createBackendPlugin } from './createBackendPlugin'; +import { + InternalBackendFeature, + InternalBackendFeatureLoaderRegistration, +} from './types'; + +describe('createBackendFeatureLoader', () => { + it('should create an empty feature loader', () => { + const result = createBackendFeatureLoader({ + deps: {}, + loader: () => [], + }); + + const plugin = result as unknown as InternalBackendFeature; + expect(plugin.$$type).toEqual('@backstage/BackendFeature'); + expect(plugin.version).toEqual('v1'); + expect(plugin.getRegistrations).toEqual(expect.any(Function)); + expect(plugin.getRegistrations()).toEqual([ + { + type: 'loader', + description: expect.stringMatching(/^created at '.*'$/), + deps: expect.any(Object), + loader: expect.any(Function), + }, + ]); + }); + + it('should create a feature loader that loads a few features', async () => { + const result = createBackendFeatureLoader({ + deps: { + config: coreServices.rootConfig, + }, + loader({ config: _unused }) { + return [ + createBackendPlugin({ + pluginId: 'x', + register() {}, + })(), + createServiceFactory({ + service: coreServices.pluginMetadata, + deps: {}, + factory: () => ({ getId: () => 'fake-id' }), + })(), + // Dynamic import format + Promise.resolve({ + default: createBackendPlugin({ + pluginId: 'y', + register() {}, + })(), + }), + ]; + }, + }) as InternalBackendFeature; + + expect(result.$$type).toEqual('@backstage/BackendFeature'); + expect(result.version).toEqual('v1'); + expect(result.getRegistrations).toEqual(expect.any(Function)); + + const registrations = result.getRegistrations(); + expect(registrations).toEqual([ + { + type: 'loader', + description: expect.stringMatching(/^created at '.*'$/), + deps: expect.any(Object), + loader: expect.any(Function), + }, + ]); + + const results = await (registrations[0] as any).loader({ config: {} }); + expect(results.length).toBe(3); + const [pluginX, serviceFactory, pluginY] = results; + expect(pluginX.$$type).toBe('@backstage/BackendFeature'); + expect(serviceFactory.$$type).toBe('@backstage/BackendFeature'); + expect(pluginY.$$type).toBe('@backstage/BackendFeature'); + expect(serviceFactory.service.id).toBe(coreServices.pluginMetadata.id); + }); + + it('should support multiple output formats', async () => { + const feature = createBackendPlugin({ pluginId: 'x', register() {} })(); + const dynamicFeature = Promise.resolve({ default: feature }); + + async function extractResult(f: BackendFeature) { + const internal = f as InternalBackendFeature; + const reg = + internal.getRegistrations()[0] as InternalBackendFeatureLoaderRegistration; + return reg.loader({}); + } + + await expect( + extractResult( + createBackendFeatureLoader({ + loader() { + return [feature]; + }, + }), + ), + ).resolves.toEqual([feature]); + + await expect( + extractResult( + createBackendFeatureLoader({ + async loader() { + return [feature]; + }, + }), + ), + ).resolves.toEqual([feature]); + + await expect( + extractResult( + createBackendFeatureLoader({ + *loader() { + yield feature; + }, + }), + ), + ).resolves.toEqual([feature]); + + await expect( + extractResult( + createBackendFeatureLoader({ + async *loader() { + yield feature; + }, + }), + ), + ).resolves.toEqual([feature]); + + await expect( + extractResult( + createBackendFeatureLoader({ + loader() { + return [dynamicFeature]; + }, + }), + ), + ).resolves.toEqual([feature]); + + await expect( + extractResult( + createBackendFeatureLoader({ + async loader() { + return [dynamicFeature]; + }, + }), + ), + ).resolves.toEqual([feature]); + + await expect( + extractResult( + createBackendFeatureLoader({ + *loader() { + yield dynamicFeature; + }, + }), + ), + ).resolves.toEqual([feature]); + + await expect( + extractResult( + createBackendFeatureLoader({ + async *loader() { + yield dynamicFeature; + }, + }), + ), + ).resolves.toEqual([feature]); + }); + + it('should only allow dependencies on root scoped services', () => { + createBackendFeatureLoader({ + deps: { + rootLogger: coreServices.rootLogger, + }, + loader: () => [], + }); + createBackendFeatureLoader({ + deps: { + // @ts-expect-error + logger: coreServices.logger, + }, + loader: () => [], + }); + createBackendFeatureLoader({ + deps: { + rootLogger: coreServices.rootLogger, + // @ts-expect-error + logger: coreServices.logger, + }, + loader: () => [], + }); + expect('test').toBe('test'); + }); +}); diff --git a/packages/backend-plugin-api/src/wiring/createBackendFeatureLoader.ts b/packages/backend-plugin-api/src/wiring/createBackendFeatureLoader.ts new file mode 100644 index 0000000000..9722cc534f --- /dev/null +++ b/packages/backend-plugin-api/src/wiring/createBackendFeatureLoader.ts @@ -0,0 +1,73 @@ +/* + * Copyright 2024 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 { ServiceRef } from '../services'; +import { BackendFeature } from '../types'; +import { InternalBackendFeature } from './types'; + +/** + * @public + * Options for creating a new backend feature loader. + */ +export interface CreateBackendFeatureLoaderOptions< + TDeps extends { [name in string]: unknown }, +> { + deps?: { + [name in keyof TDeps]: ServiceRef; + }; + loader( + deps: TDeps, + ): + | Iterable> + | Promise>> + | AsyncIterable; +} + +/** + * @public + * Creates a new backend feature loader. + */ +export function createBackendFeatureLoader< + TDeps extends { [name in string]: unknown }, +>(options: CreateBackendFeatureLoaderOptions): BackendFeature { + const registrations = [ + { + type: 'loader', + description: `created at '${new Date().toISOString()}'`, + deps: options.deps, + async loader(deps: TDeps) { + const it = await options.loader(deps); + const result = new Array(); + for await (const item of it) { + if ('$$type' in item && item.$$type === '@backstage/BackendFeature') { + result.push(item); + } else if ('default' in item) { + result.push(item.default); + } else { + throw new Error(`Invalid item "${item}"`); + } + } + return result; + }, + }, + ]; + + return { + $$type: '@backstage/BackendFeature', + version: 'v1', + getRegistrations: () => registrations, + } as InternalBackendFeature; +} diff --git a/packages/backend-plugin-api/src/wiring/index.ts b/packages/backend-plugin-api/src/wiring/index.ts index 5f7960e9cd..95eea6c3d4 100644 --- a/packages/backend-plugin-api/src/wiring/index.ts +++ b/packages/backend-plugin-api/src/wiring/index.ts @@ -21,6 +21,10 @@ import { type CreateExtensionPointOptions } from './createExtensionPoint'; export { createBackendModule } from './createBackendModule'; export { createBackendPlugin } from './createBackendPlugin'; export { createExtensionPoint } from './createExtensionPoint'; +export { + createBackendFeatureLoader, + type CreateBackendFeatureLoaderOptions, +} from './createBackendFeatureLoader'; export type { BackendModuleRegistrationPoints, diff --git a/packages/backend-plugin-api/src/wiring/types.ts b/packages/backend-plugin-api/src/wiring/types.ts index 55d43ccb7c..7569cc2b41 100644 --- a/packages/backend-plugin-api/src/wiring/types.ts +++ b/packages/backend-plugin-api/src/wiring/types.ts @@ -76,7 +76,9 @@ export interface BackendModuleRegistrationPoints { export interface InternalBackendFeature extends BackendFeature { version: 'v1'; getRegistrations(): Array< - InternalBackendPluginRegistration | InternalBackendModuleRegistration + | InternalBackendPluginRegistration + | InternalBackendModuleRegistration + | InternalBackendFeatureLoaderRegistration >; } @@ -102,3 +104,13 @@ export interface InternalBackendModuleRegistration { func(deps: Record): Promise; }; } + +/** + * @public + */ +export interface InternalBackendFeatureLoaderRegistration { + type: 'loader'; + description: string; + deps: Record>; + loader(deps: Record): Promise; +} From 8f70547ea54ccf19b071312cd2894cc10c423fd7 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 5 Aug 2024 01:43:06 +0200 Subject: [PATCH 103/372] backend-plugin-api: refactor to flatten internal backend feature loader Signed-off-by: Patrik Oldsberg --- .../src/services/system/types.test.ts | 10 +++- .../src/services/system/types.ts | 3 ++ .../wiring/createBackendFeatureLoader.test.ts | 52 ++++++------------- .../src/wiring/createBackendFeatureLoader.ts | 44 +++++++--------- .../backend-plugin-api/src/wiring/types.ts | 10 ++-- 5 files changed, 53 insertions(+), 66 deletions(-) diff --git a/packages/backend-plugin-api/src/services/system/types.test.ts b/packages/backend-plugin-api/src/services/system/types.test.ts index adf097761b..32c1774455 100644 --- a/packages/backend-plugin-api/src/services/system/types.test.ts +++ b/packages/backend-plugin-api/src/services/system/types.test.ts @@ -14,7 +14,11 @@ * limitations under the License. */ -import { createServiceFactory, createServiceRef } from './types'; +import { + InternalServiceFactory, + createServiceFactory, + createServiceRef, +} from './types'; const ref = createServiceRef({ id: 'x' }); const rootDep = createServiceRef({ id: 'y', scope: 'root' }); @@ -36,6 +40,10 @@ describe('createServiceFactory', () => { }, }); expect(metaFactory).toEqual(expect.any(Function)); + expect(metaFactory().$$type).toBe('@backstage/BackendFeature'); + expect((metaFactory() as InternalServiceFactory).featureType).toBe( + 'service', + ); expect(metaFactory().service).toBe(ref); // @ts-expect-error diff --git a/packages/backend-plugin-api/src/services/system/types.ts b/packages/backend-plugin-api/src/services/system/types.ts index d31350806d..ccec36e39a 100644 --- a/packages/backend-plugin-api/src/services/system/types.ts +++ b/packages/backend-plugin-api/src/services/system/types.ts @@ -78,6 +78,7 @@ export interface InternalServiceFactory< TScope extends 'plugin' | 'root' = 'plugin' | 'root', > extends ServiceFactory { version: 'v1'; + featureType: 'service'; initialization?: 'always' | 'lazy'; deps: { [key in string]: ServiceRef }; createRootContext?(deps: { [key in string]: unknown }): Promise; @@ -307,6 +308,7 @@ export function createServiceFactory< return { $$type: '@backstage/BackendFeature', version: 'v1', + featureType: 'service', service: c.service, initialization: c.initialization, deps: c.deps, @@ -322,6 +324,7 @@ export function createServiceFactory< return { $$type: '@backstage/BackendFeature', version: 'v1', + featureType: 'service', service: c.service, initialization: c.initialization, ...('createRootContext' in c diff --git a/packages/backend-plugin-api/src/wiring/createBackendFeatureLoader.test.ts b/packages/backend-plugin-api/src/wiring/createBackendFeatureLoader.test.ts index 98471bef4c..37fc079551 100644 --- a/packages/backend-plugin-api/src/wiring/createBackendFeatureLoader.test.ts +++ b/packages/backend-plugin-api/src/wiring/createBackendFeatureLoader.test.ts @@ -15,33 +15,25 @@ */ import { coreServices, createServiceFactory } from '../services'; +import { InternalServiceFactory } from '../services/system/types'; import { BackendFeature } from '../types'; import { createBackendFeatureLoader } from './createBackendFeatureLoader'; import { createBackendPlugin } from './createBackendPlugin'; -import { - InternalBackendFeature, - InternalBackendFeatureLoaderRegistration, -} from './types'; +import { InternalBackendFeatureLoader } from './types'; describe('createBackendFeatureLoader', () => { it('should create an empty feature loader', () => { const result = createBackendFeatureLoader({ deps: {}, loader: () => [], - }); + }) as InternalBackendFeatureLoader; - const plugin = result as unknown as InternalBackendFeature; - expect(plugin.$$type).toEqual('@backstage/BackendFeature'); - expect(plugin.version).toEqual('v1'); - expect(plugin.getRegistrations).toEqual(expect.any(Function)); - expect(plugin.getRegistrations()).toEqual([ - { - type: 'loader', - description: expect.stringMatching(/^created at '.*'$/), - deps: expect.any(Object), - loader: expect.any(Function), - }, - ]); + expect(result.$$type).toEqual('@backstage/BackendFeature'); + expect(result.version).toEqual('v1'); + expect(result.featureType).toEqual('loader'); + expect(result.deps).toEqual({}); + expect(result.loader).toEqual(expect.any(Function)); + expect(result.description).toMatch(/^created at '.*'$/); }); it('should create a feature loader that loads a few features', async () => { @@ -69,29 +61,21 @@ describe('createBackendFeatureLoader', () => { }), ]; }, - }) as InternalBackendFeature; + }) as InternalBackendFeatureLoader; expect(result.$$type).toEqual('@backstage/BackendFeature'); expect(result.version).toEqual('v1'); - expect(result.getRegistrations).toEqual(expect.any(Function)); + expect(result.featureType).toEqual('loader'); - const registrations = result.getRegistrations(); - expect(registrations).toEqual([ - { - type: 'loader', - description: expect.stringMatching(/^created at '.*'$/), - deps: expect.any(Object), - loader: expect.any(Function), - }, - ]); - - const results = await (registrations[0] as any).loader({ config: {} }); + const results = await result.loader({ config: {} }); expect(results.length).toBe(3); const [pluginX, serviceFactory, pluginY] = results; expect(pluginX.$$type).toBe('@backstage/BackendFeature'); expect(serviceFactory.$$type).toBe('@backstage/BackendFeature'); expect(pluginY.$$type).toBe('@backstage/BackendFeature'); - expect(serviceFactory.service.id).toBe(coreServices.pluginMetadata.id); + expect((serviceFactory as InternalServiceFactory).service.id).toBe( + coreServices.pluginMetadata.id, + ); }); it('should support multiple output formats', async () => { @@ -99,10 +83,8 @@ describe('createBackendFeatureLoader', () => { const dynamicFeature = Promise.resolve({ default: feature }); async function extractResult(f: BackendFeature) { - const internal = f as InternalBackendFeature; - const reg = - internal.getRegistrations()[0] as InternalBackendFeatureLoaderRegistration; - return reg.loader({}); + const internal = f as InternalBackendFeatureLoader; + return internal.loader({}); } await expect( diff --git a/packages/backend-plugin-api/src/wiring/createBackendFeatureLoader.ts b/packages/backend-plugin-api/src/wiring/createBackendFeatureLoader.ts index 9722cc534f..de26b5154d 100644 --- a/packages/backend-plugin-api/src/wiring/createBackendFeatureLoader.ts +++ b/packages/backend-plugin-api/src/wiring/createBackendFeatureLoader.ts @@ -16,7 +16,7 @@ import { ServiceRef } from '../services'; import { BackendFeature } from '../types'; -import { InternalBackendFeature } from './types'; +import { InternalBackendFeatureLoader } from './types'; /** * @public @@ -43,31 +43,25 @@ export interface CreateBackendFeatureLoaderOptions< export function createBackendFeatureLoader< TDeps extends { [name in string]: unknown }, >(options: CreateBackendFeatureLoaderOptions): BackendFeature { - const registrations = [ - { - type: 'loader', - description: `created at '${new Date().toISOString()}'`, - deps: options.deps, - async loader(deps: TDeps) { - const it = await options.loader(deps); - const result = new Array(); - for await (const item of it) { - if ('$$type' in item && item.$$type === '@backstage/BackendFeature') { - result.push(item); - } else if ('default' in item) { - result.push(item.default); - } else { - throw new Error(`Invalid item "${item}"`); - } - } - return result; - }, - }, - ]; - return { $$type: '@backstage/BackendFeature', version: 'v1', - getRegistrations: () => registrations, - } as InternalBackendFeature; + featureType: 'loader', + description: `created at '${new Date().toISOString()}'`, + deps: options.deps, + async loader(deps: TDeps) { + const it = await options.loader(deps); + const result = new Array(); + for await (const item of it) { + if ('$$type' in item && item.$$type === '@backstage/BackendFeature') { + result.push(item); + } else if ('default' in item) { + result.push(item.default); + } else { + throw new Error(`Invalid item "${item}"`); + } + } + return result; + }, + } as InternalBackendFeatureLoader; } diff --git a/packages/backend-plugin-api/src/wiring/types.ts b/packages/backend-plugin-api/src/wiring/types.ts index 7569cc2b41..df0ca93089 100644 --- a/packages/backend-plugin-api/src/wiring/types.ts +++ b/packages/backend-plugin-api/src/wiring/types.ts @@ -75,10 +75,9 @@ export interface BackendModuleRegistrationPoints { /** @internal */ export interface InternalBackendFeature extends BackendFeature { version: 'v1'; + featureType: 'registrations'; getRegistrations(): Array< - | InternalBackendPluginRegistration - | InternalBackendModuleRegistration - | InternalBackendFeatureLoaderRegistration + InternalBackendPluginRegistration | InternalBackendModuleRegistration >; } @@ -108,8 +107,9 @@ export interface InternalBackendModuleRegistration { /** * @public */ -export interface InternalBackendFeatureLoaderRegistration { - type: 'loader'; +export interface InternalBackendFeatureLoader extends BackendFeature { + version: 'v1'; + featureType: 'loader'; description: string; deps: Record>; loader(deps: Record): Promise; From 765d91aa0b75cbf8fac5c4b4331de2af4cda5b04 Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 5 Aug 2024 09:20:02 +0200 Subject: [PATCH 104/372] chore: added failing test for callback form Signed-off-by: blam --- .../wiring/createExtensionBlueprint.test.tsx | 56 +++++++++++++++++++ .../src/wiring/createExtensionBlueprint.ts | 7 ++- 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx index 6cf10d7f08..38e92fc26a 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx @@ -326,4 +326,60 @@ describe('createExtensionBlueprint', () => { expect(true).toBe(true); }); + + it('should allow providing callback for properties to set with params', () => { + const Blueprint = createExtensionBlueprint({ + kind: 'test-extension', + attachTo: { id: 'test', input: 'default' }, + output: [coreExtensionData.reactElement], + namespace: props => props.test, + name: props => `${props.test}-name`, + config: { + schema: props => ({ + test: z => z.string().default(props.test), + }), + }, + factory(params: { test: string }) { + return [coreExtensionData.reactElement(
{params.test}
)]; + }, + }); + + expect(Blueprint.make({ params: { test: 'hello' } })) + .toMatchInlineSnapshot(` + { + "$$type": "@backstage/ExtensionDefinition", + "attachTo": { + "id": "test", + "input": "default", + }, + "configSchema": { + "parse": [Function], + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "additionalProperties": false, + "properties": { + "test": { + "default": "test", + "type": "string", + }, + }, + "type": "object", + }, + }, + "disabled": false, + "factory": [Function], + "inputs": {}, + "kind": "test-extension", + "name": "hello-name", + "namespace": "hello", + "output": [ + [Function], + ], + "toString": [Function], + "version": "v2", + } + `); + + expect(true).toBe(true); + }); }); diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts index b579cc207a..4a8f4a7c46 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts @@ -47,14 +47,14 @@ export type CreateExtensionBlueprintOptions< UFactoryOutput extends ExtensionDataValue, TDataRefs extends { [name in string]: AnyExtensionDataRef }, > = { - kind: string; - namespace?: string; + kind: string | ((params: TParams) => string); + namespace?: string | ((params: TParams) => string); attachTo: { id: string; input: string }; disabled?: boolean; inputs?: TInputs; output: Array; config?: { - schema: TConfigSchema; + schema: TConfigSchema | ((params: TParams) => TConfigSchema); }; factory( params: TParams, @@ -254,6 +254,7 @@ class ExtensionBlueprintImpl< ...this.options.config?.schema, ...args.config?.schema, } as TConfigSchema & TExtensionConfigSchema; + return createExtension({ kind: this.options.kind, namespace: args.namespace ?? this.options.namespace, From dc0d284419732fde05aa4c1dbecf71a1bb3ec3ca Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 5 Aug 2024 09:53:54 +0200 Subject: [PATCH 105/372] backend-plugin-api: fix feature loader description Signed-off-by: Patrik Oldsberg --- .../src/wiring/createBackendFeatureLoader.ts | 3 ++- .../src/wiring/describeParentCallSite.ts | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 packages/backend-plugin-api/src/wiring/describeParentCallSite.ts diff --git a/packages/backend-plugin-api/src/wiring/createBackendFeatureLoader.ts b/packages/backend-plugin-api/src/wiring/createBackendFeatureLoader.ts index de26b5154d..cfa3e96c65 100644 --- a/packages/backend-plugin-api/src/wiring/createBackendFeatureLoader.ts +++ b/packages/backend-plugin-api/src/wiring/createBackendFeatureLoader.ts @@ -16,6 +16,7 @@ import { ServiceRef } from '../services'; import { BackendFeature } from '../types'; +import { describeParentCallSite } from './describeParentCallSite'; import { InternalBackendFeatureLoader } from './types'; /** @@ -47,7 +48,7 @@ export function createBackendFeatureLoader< $$type: '@backstage/BackendFeature', version: 'v1', featureType: 'loader', - description: `created at '${new Date().toISOString()}'`, + description: `created at '${describeParentCallSite()}'`, deps: options.deps, async loader(deps: TDeps) { const it = await options.loader(deps); diff --git a/packages/backend-plugin-api/src/wiring/describeParentCallSite.ts b/packages/backend-plugin-api/src/wiring/describeParentCallSite.ts new file mode 100644 index 0000000000..35603e33b0 --- /dev/null +++ b/packages/backend-plugin-api/src/wiring/describeParentCallSite.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. + */ + +// Single re-export to avoid doing this import in multiple places, but still +// avoid duplicate declarations because this one is a bit tricky. +// eslint-disable-next-line @backstage/no-relative-monorepo-imports +export { describeParentCallSite } from '../../../frontend-plugin-api/src/routing/describeParentCallSite'; From d4d048b3fffb61d76f47efb065919d7ff80da635 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 5 Aug 2024 12:16:19 +0200 Subject: [PATCH 106/372] backend-*-api: refactor for more explicit internal feature types Signed-off-by: Patrik Oldsberg --- .../src/wiring/BackendInitializer.ts | 73 ++++++++++++++----- .../src/wiring/createBackendModule.test.ts | 6 +- .../src/wiring/createBackendPlugin.test.ts | 6 +- .../backend-plugin-api/src/wiring/types.ts | 10 ++- .../src/next/wiring/TestBackend.ts | 48 +++++++----- 5 files changed, 96 insertions(+), 47 deletions(-) diff --git a/packages/backend-app-api/src/wiring/BackendInitializer.ts b/packages/backend-app-api/src/wiring/BackendInitializer.ts index ddad94de14..902258b9b0 100644 --- a/packages/backend-app-api/src/wiring/BackendInitializer.ts +++ b/packages/backend-app-api/src/wiring/BackendInitializer.ts @@ -26,7 +26,13 @@ import { import { ServiceOrExtensionPoint } from './types'; // Direct internal import to avoid duplication // eslint-disable-next-line @backstage/no-forbidden-package-imports -import { InternalBackendFeature } from '@backstage/backend-plugin-api/src/wiring/types'; +import type { + InternalBackendFeature, + InternalBackendFeatureLoader, + InternalBackendRegistrations, +} from '@backstage/backend-plugin-api/src/wiring/types'; +// eslint-disable-next-line @backstage/no-forbidden-package-imports +import type { InternalServiceFactory } from '@backstage/backend-plugin-api/src/services/system/types'; import { ForwardedError, ConflictError } from '@backstage/errors'; import { featureDiscoveryServiceRef } from '@backstage/backend-plugin-api/alpha'; import { DependencyGraph } from '../lib/DependencyGraph'; @@ -44,7 +50,7 @@ export interface BackendRegisterInit { export class BackendInitializer { #startPromise?: Promise; - #features = new Array(); + #registrations = new Array(); #extensionPoints = new Map(); #serviceRegistry: ServiceRegistry; #registeredFeatures = new Array>(); @@ -101,21 +107,15 @@ export class BackendInitializer { } #addFeature(feature: BackendFeature) { - if (feature.$$type !== '@backstage/BackendFeature') { - throw new Error( - `Failed to add feature, invalid type '${feature.$$type}'`, - ); - } - if (isServiceFactory(feature)) { this.#serviceRegistry.add(feature); - } else if (isInternalBackendFeature(feature)) { + } else if (isBackendRegistrations(feature)) { if (feature.version !== 'v1') { throw new Error( `Failed to add feature, invalid version '${feature.version}'`, ); } - this.#features.push(feature); + this.#registrations.push(feature); } else { throw new Error( `Failed to add feature, invalid feature ${JSON.stringify(feature)}`, @@ -176,8 +176,8 @@ export class BackendInitializer { const pluginInits = new Map(); const moduleInits = new Map>(); - // Enumerate all features - for (const feature of this.#features) { + // Enumerate all registrations + for (const feature of this.#registrations) { for (const r of feature.getRegistrations()) { const provides = new Set>(); @@ -205,7 +205,7 @@ export class BackendInitializer { consumes: new Set(Object.values(r.init.deps)), init: r.init, }); - } else { + } else if (r.type === 'module') { let modules = moduleInits.get(r.pluginId); if (!modules) { modules = new Map(); @@ -221,6 +221,8 @@ export class BackendInitializer { consumes: new Set(Object.values(r.init.deps)), init: r.init, }); + } else { + throw new Error(`Invalid registration type '${(r as any).type}'`); } } } @@ -385,14 +387,45 @@ export class BackendInitializer { } } -function isServiceFactory(feature: BackendFeature): feature is ServiceFactory { - return !!(feature as ServiceFactory).service; +function toInternalBackendFeature( + feature: BackendFeature, +): InternalBackendFeature { + if (feature.$$type !== '@backstage/BackendFeature') { + throw new Error(`Invalid BackendFeature, bad type '${feature.$$type}'`); + } + const internal = feature as InternalBackendFeature; + if (internal.version !== 'v1') { + throw new Error( + `Invalid BackendFeature, bad version '${internal.version}'`, + ); + } + return internal; } -function isInternalBackendFeature( +function isServiceFactory( feature: BackendFeature, -): feature is InternalBackendFeature { - return ( - typeof (feature as InternalBackendFeature).getRegistrations === 'function' - ); +): feature is InternalServiceFactory { + const internal = toInternalBackendFeature(feature); + if (internal.featureType === 'service') { + return true; + } + // Backwards compatibility for v1 registrations that use duck typing + if ('service' in internal) { + return true; + } + return false; +} + +function isBackendRegistrations( + feature: BackendFeature, +): feature is InternalBackendRegistrations { + const internal = toInternalBackendFeature(feature); + if (internal.featureType === 'registrations') { + return true; + } + // Backwards compatibility for v1 registrations that use duck typing + if ('getRegistrations' in internal) { + return true; + } + return false; } diff --git a/packages/backend-plugin-api/src/wiring/createBackendModule.test.ts b/packages/backend-plugin-api/src/wiring/createBackendModule.test.ts index 31496020bf..e3c9f9007a 100644 --- a/packages/backend-plugin-api/src/wiring/createBackendModule.test.ts +++ b/packages/backend-plugin-api/src/wiring/createBackendModule.test.ts @@ -15,7 +15,7 @@ */ import { createBackendModule } from './createBackendModule'; -import { InternalBackendFeature } from './types'; +import { InternalBackendRegistrations } from './types'; describe('createBackendModule', () => { it('should create a BackendModule', () => { @@ -28,13 +28,13 @@ describe('createBackendModule', () => { }); // legacy form - const legacy = result() as unknown as InternalBackendFeature; + const legacy = result() as unknown as InternalBackendRegistrations; expect(legacy.$$type).toEqual('@backstage/BackendFeature'); expect(legacy.version).toEqual('v1'); expect(legacy.getRegistrations).toEqual(expect.any(Function)); // new form - const module = result as unknown as InternalBackendFeature; + const module = result as unknown as InternalBackendRegistrations; expect(module.$$type).toEqual('@backstage/BackendFeature'); expect(module.version).toEqual('v1'); expect(module.getRegistrations).toEqual(expect.any(Function)); diff --git a/packages/backend-plugin-api/src/wiring/createBackendPlugin.test.ts b/packages/backend-plugin-api/src/wiring/createBackendPlugin.test.ts index cd1ce164bf..db4d60ee19 100644 --- a/packages/backend-plugin-api/src/wiring/createBackendPlugin.test.ts +++ b/packages/backend-plugin-api/src/wiring/createBackendPlugin.test.ts @@ -15,7 +15,7 @@ */ import { createBackendPlugin } from './createBackendPlugin'; -import { InternalBackendFeature } from './types'; +import { InternalBackendRegistrations } from './types'; describe('createBackendPlugin', () => { it('should create a BackendPlugin', () => { @@ -27,13 +27,13 @@ describe('createBackendPlugin', () => { }); // legacy form - const legacy = result() as unknown as InternalBackendFeature; + const legacy = result() as unknown as InternalBackendRegistrations; expect(legacy.$$type).toEqual('@backstage/BackendFeature'); expect(legacy.version).toEqual('v1'); expect(legacy.getRegistrations).toEqual(expect.any(Function)); // new form - const plugin = result as unknown as InternalBackendFeature; + const plugin = result as unknown as InternalBackendRegistrations; expect(plugin.$$type).toEqual('@backstage/BackendFeature'); expect(plugin.version).toEqual('v1'); expect(plugin.getRegistrations).toEqual(expect.any(Function)); diff --git a/packages/backend-plugin-api/src/wiring/types.ts b/packages/backend-plugin-api/src/wiring/types.ts index df0ca93089..01ab8c2e3e 100644 --- a/packages/backend-plugin-api/src/wiring/types.ts +++ b/packages/backend-plugin-api/src/wiring/types.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { ServiceRef } from '../services/system/types'; +import { InternalServiceFactory, ServiceRef } from '../services/system/types'; import { BackendFeature } from '../types'; /** @@ -73,7 +73,7 @@ export interface BackendModuleRegistrationPoints { } /** @internal */ -export interface InternalBackendFeature extends BackendFeature { +export interface InternalBackendRegistrations extends BackendFeature { version: 'v1'; featureType: 'registrations'; getRegistrations(): Array< @@ -114,3 +114,9 @@ export interface InternalBackendFeatureLoader extends BackendFeature { deps: Record>; loader(deps: Record): Promise; } + +/** @internal */ +export type InternalBackendFeature = + | InternalBackendRegistrations + | InternalBackendFeatureLoader + | InternalServiceFactory; diff --git a/packages/backend-test-utils/src/next/wiring/TestBackend.ts b/packages/backend-test-utils/src/next/wiring/TestBackend.ts index 3d662a8c12..cf98c25e4a 100644 --- a/packages/backend-test-utils/src/next/wiring/TestBackend.ts +++ b/packages/backend-test-utils/src/next/wiring/TestBackend.ts @@ -36,7 +36,10 @@ import { ConfigReader } from '@backstage/config'; import express from 'express'; // Direct internal import to avoid duplication // eslint-disable-next-line @backstage/no-forbidden-package-imports -import { InternalBackendFeature } from '@backstage/backend-plugin-api/src/wiring/types'; +import { + InternalBackendFeature, + InternalBackendRegistrations, +} from '@backstage/backend-plugin-api/src/wiring/types'; import { createHealthRouter } from '@backstage/backend-defaults/rootHttpRouter'; /** @public */ @@ -94,7 +97,7 @@ function createPluginsForOrphanModules(features: Array) { const modulePluginIds = new Set(); for (const feature of features) { - if (isInternalBackendFeature(feature)) { + if (isInternalBackendRegistrations(feature)) { const registrations = feature.getRegistrations(); for (const registration of registrations) { if (registration.type === 'plugin') { @@ -137,18 +140,7 @@ function createExtensionPointTestModules( } const registrations = features.flatMap(feature => { - if (feature.$$type !== '@backstage/BackendFeature') { - throw new Error( - `Failed to add feature, invalid type '${feature.$$type}'`, - ); - } - - if (isInternalBackendFeature(feature)) { - if (feature.version !== 'v1') { - throw new Error( - `Failed to add feature, invalid version '${feature.version}'`, - ); - } + if (isInternalBackendRegistrations(feature)) { return feature.getRegistrations(); } return []; @@ -361,10 +353,28 @@ function registerTestHooks() { registerTestHooks(); -function isInternalBackendFeature( +function toInternalBackendFeature( feature: BackendFeature, -): feature is InternalBackendFeature { - return ( - typeof (feature as InternalBackendFeature).getRegistrations === 'function' - ); +): InternalBackendFeature { + if (feature.$$type !== '@backstage/BackendFeature') { + throw new Error(`Invalid BackendFeature, bad type '${feature.$$type}'`); + } + const internal = feature as InternalBackendFeature; + if (internal.version !== 'v1') { + throw new Error( + `Invalid BackendFeature, bad version '${internal.version}'`, + ); + } + return internal; +} + +function isInternalBackendRegistrations( + feature: BackendFeature, +): feature is InternalBackendRegistrations { + const internal = toInternalBackendFeature(feature); + if (internal.featureType === 'registrations') { + return true; + } + // Backwards compatibility for v1 registrations that use duck typing + return 'getRegistrations' in internal; } From d3b49a60f2f96e33b04362f1d5f6dd89501cb8bd Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 5 Aug 2024 13:03:16 +0200 Subject: [PATCH 107/372] backend-app-api: add support for feature loaders Signed-off-by: Patrik Oldsberg --- .../src/wiring/BackendInitializer.test.ts | 123 ++++++++++++++++++ .../src/wiring/BackendInitializer.ts | 89 +++++++++++-- 2 files changed, 199 insertions(+), 13 deletions(-) diff --git a/packages/backend-app-api/src/wiring/BackendInitializer.test.ts b/packages/backend-app-api/src/wiring/BackendInitializer.test.ts index 3bbef5a4c0..6f60d65861 100644 --- a/packages/backend-app-api/src/wiring/BackendInitializer.test.ts +++ b/packages/backend-app-api/src/wiring/BackendInitializer.test.ts @@ -24,6 +24,7 @@ import { createBackendPlugin, createBackendModule, createExtensionPoint, + createBackendFeatureLoader, } from '@backstage/backend-plugin-api'; import { BackendInitializer } from './BackendInitializer'; @@ -105,6 +106,128 @@ describe('BackendInitializer', () => { expect(factory3).not.toHaveBeenCalled(); }); + it('should discover features from feature loader', async () => { + const ref1 = createServiceRef<{ x: number }>({ + id: '1', + scope: 'root', + }); + const ref2 = createServiceRef<{ x: number }>({ + id: '2', + scope: 'plugin', + }); + const factory1 = jest.fn(); + const factory2 = jest.fn(); + + const pluginInit = jest.fn(async () => {}); + const moduleInit = jest.fn(async () => {}); + + const init = new BackendInitializer(baseFactories); + init.add( + createBackendFeatureLoader({ + *loader() { + yield createServiceFactory({ + service: ref1, + deps: {}, + factory: factory1, + }); + yield createServiceFactory({ + service: ref2, + initialization: 'always', + deps: {}, + factory: factory2, + }); + yield createBackendPlugin({ + pluginId: 'test', + register(reg) { + reg.registerInit({ + deps: {}, + init: pluginInit, + }); + }, + }); + yield createBackendModule({ + pluginId: 'test', + moduleId: 'tester', + register(reg) { + reg.registerInit({ + deps: {}, + init: moduleInit, + }); + }, + }); + }, + }), + ); + await init.start(); + + expect(factory1).toHaveBeenCalled(); + expect(factory2).toHaveBeenCalled(); + expect(pluginInit).toHaveBeenCalled(); + expect(moduleInit).toHaveBeenCalled(); + }); + + it('should refuse to override already initialized services through loaded features', async () => { + const ref1 = createServiceRef<{ x: number }>({ + id: '1', + scope: 'root', + }); + + const init = new BackendInitializer([ + ...baseFactories, + createServiceFactory({ + service: ref1, + deps: {}, + factory: () => ({ x: 1 }), + }), + ]); + init.add( + createBackendFeatureLoader({ + deps: { service1: ref1 }, + *loader() { + yield createServiceFactory({ + service: ref1, + deps: {}, + factory: jest.fn(), + }); + }, + }), + ); + await expect(init.start()).rejects.toThrow( + 'Unable to set service factory with id 1, service has already been instantiated', + ); + }); + + it('should refuse feature loader that depends on a plugin scoped service', async () => { + const ref1 = createServiceRef<{ x: number }>({ + id: '1', + }); + + const init = new BackendInitializer([ + ...baseFactories, + createServiceFactory({ + service: ref1, + deps: {}, + factory: () => ({ x: 1 }), + }), + ]); + init.add( + createBackendFeatureLoader({ + // @ts-expect-error + deps: { service1: ref1 }, + *loader() { + yield createServiceFactory({ + service: ref1, + deps: {}, + factory: jest.fn(), + }); + }, + }), + ); + await expect(init.start()).rejects.toThrow( + /^Feature loaders can only depend on root scoped services, but 'service1' is scoped to 'plugin'. Offending loader is created at '.*'$/, + ); + }); + it('should initialize plugin scoped services with eager initialization', async () => { const ref1 = createServiceRef<{ x: number }>({ id: '1', diff --git a/packages/backend-app-api/src/wiring/BackendInitializer.ts b/packages/backend-app-api/src/wiring/BackendInitializer.ts index 902258b9b0..4bfbf6244f 100644 --- a/packages/backend-app-api/src/wiring/BackendInitializer.ts +++ b/packages/backend-app-api/src/wiring/BackendInitializer.ts @@ -54,6 +54,7 @@ export class BackendInitializer { #extensionPoints = new Map(); #serviceRegistry: ServiceRegistry; #registeredFeatures = new Array>(); + #registeredFeatureLoaders = new Array(); constructor(defaultApiFactories: ServiceFactory[]) { this.#serviceRegistry = ServiceRegistry.create([...defaultApiFactories]); @@ -109,12 +110,9 @@ export class BackendInitializer { #addFeature(feature: BackendFeature) { if (isServiceFactory(feature)) { this.#serviceRegistry.add(feature); + } else if (isBackendFeatureLoader(feature)) { + this.#registeredFeatureLoaders.push(feature); } else if (isBackendRegistrations(feature)) { - if (feature.version !== 'v1') { - throw new Error( - `Failed to add feature, invalid version '${feature.version}'`, - ); - } this.#registrations.push(feature); } else { throw new Error( @@ -170,6 +168,8 @@ export class BackendInitializer { this.#serviceRegistry.checkForCircularDeps(); } + await this.#applyBackendFeatureLoaders(this.#registeredFeatureLoaders); + // Initialize all root scoped services await this.#serviceRegistry.initializeEagerServicesWithScope('root'); @@ -385,6 +385,69 @@ export class BackendInitializer { throw new Error('Unexpected plugin lifecycle service implementation'); } + + async #applyBackendFeatureLoaders(loaders: InternalBackendFeatureLoader[]) { + for (const loader of loaders) { + const deps = new Map(); + const missingRefs = new Set(); + + for (const [name, ref] of Object.entries(loader.deps ?? {})) { + if (ref.scope !== 'root') { + throw new Error( + `Feature loaders can only depend on root scoped services, but '${name}' is scoped to '${ref.scope}'. Offending loader is ${loader.description}`, + ); + } + const impl = await this.#serviceRegistry.get( + ref as ServiceRef, + 'root', + ); + if (impl) { + deps.set(name, impl); + } else { + missingRefs.add(ref); + } + } + + if (missingRefs.size > 0) { + const missing = Array.from(missingRefs).join(', '); + throw new Error( + `No service available for the following ref(s): ${missing}, depended on by feature loader ${loader.description}`, + ); + } + + const result = await loader + .loader(Object.fromEntries(deps)) + .catch(error => { + throw new ForwardedError( + `Feature loader ${loader.description} failed`, + error, + ); + }); + + let didAddServiceFactory = false; + const newLoaders = new Array(); + + for await (const feature of result) { + if (isBackendFeatureLoader(feature)) { + newLoaders.push(feature); + } else { + didAddServiceFactory = + didAddServiceFactory || isServiceFactory(feature); + this.#addFeature(feature); + } + } + + // Every time we add a new service factory we need to make sure that we don't have circular dependencies + if (didAddServiceFactory) { + this.#serviceRegistry.checkForCircularDeps(); + } + + // Apply loaders recursively, depth-first + if (newLoaders.length > 0) { + await this.#applyBackendFeatureLoaders(newLoaders); + } + } + } } function toInternalBackendFeature( @@ -410,10 +473,7 @@ function isServiceFactory( return true; } // Backwards compatibility for v1 registrations that use duck typing - if ('service' in internal) { - return true; - } - return false; + return 'service' in internal; } function isBackendRegistrations( @@ -424,8 +484,11 @@ function isBackendRegistrations( return true; } // Backwards compatibility for v1 registrations that use duck typing - if ('getRegistrations' in internal) { - return true; - } - return false; + return 'getRegistrations' in internal; +} + +function isBackendFeatureLoader( + feature: BackendFeature, +): feature is InternalBackendFeatureLoader { + return toInternalBackendFeature(feature).featureType === 'loader'; } From 072c00c0735bd44382f4d08343ae661a7511a780 Mon Sep 17 00:00:00 2001 From: Heidi Puotiniemi Date: Mon, 5 Aug 2024 14:59:18 +0300 Subject: [PATCH 108/372] fix output element overlappig w/ flex-wrap Signed-off-by: Heidi Puotiniemi --- .changeset/breezy-rings-fly.md | 5 +++++ .../components/TemplateOutputs/DefaultTemplateOutputs.tsx | 1 + 2 files changed, 6 insertions(+) create mode 100644 .changeset/breezy-rings-fly.md diff --git a/.changeset/breezy-rings-fly.md b/.changeset/breezy-rings-fly.md new file mode 100644 index 0000000000..315da5f950 --- /dev/null +++ b/.changeset/breezy-rings-fly.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-react': patch +--- + +Fixed bug in DefaultTableOutputs where output elements overlapped in below approx. 800 px wide screens diff --git a/plugins/scaffolder-react/src/next/components/TemplateOutputs/DefaultTemplateOutputs.tsx b/plugins/scaffolder-react/src/next/components/TemplateOutputs/DefaultTemplateOutputs.tsx index cbc299bf1c..70f3b1fa59 100644 --- a/plugins/scaffolder-react/src/next/components/TemplateOutputs/DefaultTemplateOutputs.tsx +++ b/plugins/scaffolder-react/src/next/components/TemplateOutputs/DefaultTemplateOutputs.tsx @@ -68,6 +68,7 @@ export const DefaultTemplateOutputs = (props: { justifyContent="center" display="flex" gridGap={16} + flexWrap="wrap" > Date: Mon, 5 Aug 2024 14:11:40 +0200 Subject: [PATCH 109/372] avoid excessive error listeners MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/tasty-ads-rescue.md | 5 ++++ .../src/entrypoints/cache/CacheManager.ts | 28 +++++++++---------- 2 files changed, 19 insertions(+), 14 deletions(-) create mode 100644 .changeset/tasty-ads-rescue.md diff --git a/.changeset/tasty-ads-rescue.md b/.changeset/tasty-ads-rescue.md new file mode 100644 index 0000000000..d522856bdd --- /dev/null +++ b/.changeset/tasty-ads-rescue.md @@ -0,0 +1,5 @@ +--- +'@backstage/backend-defaults': patch +--- + +Avoid excessive numbers of error listeners on cache clients diff --git a/packages/backend-defaults/src/entrypoints/cache/CacheManager.ts b/packages/backend-defaults/src/entrypoints/cache/CacheManager.ts index 89fabfe977..873bcf9648 100644 --- a/packages/backend-defaults/src/entrypoints/cache/CacheManager.ts +++ b/packages/backend-defaults/src/entrypoints/cache/CacheManager.ts @@ -111,23 +111,10 @@ export class CacheManager { return { getClient: (defaultOptions = {}) => { const clientFactory = (options: CacheServiceOptions) => { - const concreteClient = this.getClientWithTtl( + return this.getClientWithTtl( pluginId, options.defaultTtl ?? this.defaultTtl, ); - - // Always provide an error handler to avoid stopping the process. - concreteClient.on('error', (err: Error) => { - // In all cases, just log the error. - this.logger?.error('Failed to create cache client', err); - - // Invoke any custom error handler if provided. - if (typeof this.errorHandler === 'function') { - this.errorHandler(err); - } - }); - - return concreteClient; }; return new DefaultCacheClient( @@ -149,11 +136,17 @@ export class CacheManager { return (pluginId, defaultTtl) => { if (!store) { store = new KeyvRedis(this.connection); + // Always provide an error handler to avoid stopping the process + store.on('error', (err: Error) => { + this.logger?.error('Failed to create redis cache client', err); + this.errorHandler?.(err); + }); } return new Keyv({ namespace: pluginId, ttl: defaultTtl, store, + emitErrors: false, useRedisSets: this.useRedisSets, }); }; @@ -165,10 +158,16 @@ export class CacheManager { return (pluginId, defaultTtl) => { if (!store) { store = new KeyvMemcache(this.connection); + // Always provide an error handler to avoid stopping the process + store.on('error', (err: Error) => { + this.logger?.error('Failed to create memcache cache client', err); + this.errorHandler?.(err); + }); } return new Keyv({ namespace: pluginId, ttl: defaultTtl, + emitErrors: false, store, }); }; @@ -180,6 +179,7 @@ export class CacheManager { new Keyv({ namespace: pluginId, ttl: defaultTtl, + emitErrors: false, store, }); } From 6ec1f48baf47f3a529c92698224d4864fd2bb9c6 Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 5 Aug 2024 16:15:07 +0200 Subject: [PATCH 110/372] chore: supporting overriding using a function Signed-off-by: blam --- .../wiring/createExtensionBlueprint.test.tsx | 12 ++++++---- .../src/wiring/createExtensionBlueprint.ts | 24 +++++++++++++++---- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx index 38e92fc26a..dfdbfface6 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx @@ -328,18 +328,20 @@ describe('createExtensionBlueprint', () => { }); it('should allow providing callback for properties to set with params', () => { + type TestParams = { test: string }; + const Blueprint = createExtensionBlueprint({ kind: 'test-extension', attachTo: { id: 'test', input: 'default' }, + name: (params: TestParams) => `${params.test}-name`, output: [coreExtensionData.reactElement], - namespace: props => props.test, - name: props => `${props.test}-name`, + namespace: (props: TestParams) => props.test, config: { - schema: props => ({ + schema: (props: TestParams) => ({ test: z => z.string().default(props.test), }), }, - factory(params: { test: string }) { + factory(params: TestParams) { return [coreExtensionData.reactElement(
{params.test}
)]; }, }); @@ -359,7 +361,7 @@ describe('createExtensionBlueprint', () => { "additionalProperties": false, "properties": { "test": { - "default": "test", + "default": "hello", "type": "string", }, }, diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts index 4a8f4a7c46..46db278bf8 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts @@ -47,12 +47,13 @@ export type CreateExtensionBlueprintOptions< UFactoryOutput extends ExtensionDataValue, TDataRefs extends { [name in string]: AnyExtensionDataRef }, > = { - kind: string | ((params: TParams) => string); + kind: string; namespace?: string | ((params: TParams) => string); attachTo: { id: string; input: string }; disabled?: boolean; inputs?: TInputs; output: Array; + name?: string | ((params: TParams) => string); config?: { schema: TConfigSchema | ((params: TParams) => TConfigSchema); }; @@ -250,15 +251,30 @@ class ExtensionBlueprintImpl< > > > { + const optionsSchema = + typeof this.options.config?.schema === 'function' + ? this.options.config?.schema(args.params!) + : this.options.config?.schema; + const schema = { - ...this.options.config?.schema, + ...optionsSchema, ...args.config?.schema, } as TConfigSchema & TExtensionConfigSchema; + const namespace = + typeof this.options.namespace === 'function' + ? this.options.namespace(args.params!) + : this.options.namespace; + + const name = + typeof this.options.name === 'function' + ? this.options.name(args.params!) + : this.options.name; + return createExtension({ kind: this.options.kind, - namespace: args.namespace ?? this.options.namespace, - name: args.name, + namespace: args.namespace ?? namespace, + name: args.name ?? name, attachTo: args.attachTo ?? this.options.attachTo, disabled: args.disabled ?? this.options.disabled, inputs: args.inputs ?? this.options.inputs, From 210d066af41579732ee9b2862f47bf1b6f36e217 Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 5 Aug 2024 16:16:51 +0200 Subject: [PATCH 111/372] chore: added changeset Signed-off-by: blam --- .changeset/chilly-days-peel.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/chilly-days-peel.md diff --git a/.changeset/chilly-days-peel.md b/.changeset/chilly-days-peel.md new file mode 100644 index 0000000000..d82344d364 --- /dev/null +++ b/.changeset/chilly-days-peel.md @@ -0,0 +1,5 @@ +--- +'@backstage/frontend-plugin-api': patch +--- + +Added support for using the `params` in other properties of the `createExtensionBlueprint` options by providing a callback. From 8025cffc3f2bb95e32beb9debcac91f5b28717b9 Mon Sep 17 00:00:00 2001 From: Ben Lambert Date: Mon, 5 Aug 2024 16:33:06 +0200 Subject: [PATCH 112/372] Update breezy-rings-fly.md Signed-off-by: Ben Lambert --- .changeset/breezy-rings-fly.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/breezy-rings-fly.md b/.changeset/breezy-rings-fly.md index 315da5f950..c3cc1c143d 100644 --- a/.changeset/breezy-rings-fly.md +++ b/.changeset/breezy-rings-fly.md @@ -2,4 +2,4 @@ '@backstage/plugin-scaffolder-react': patch --- -Fixed bug in DefaultTableOutputs where output elements overlapped in below approx. 800 px wide screens +Fixed a bug in `DefaultTableOutputs` where output elements overlapped on smaller screen sizes From cfbffadf638a5758599223afb08fc4ad483ea82e Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 5 Aug 2024 16:33:57 +0200 Subject: [PATCH 113/372] chore: api-reports Signed-off-by: blam --- packages/frontend-plugin-api/api-report.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/frontend-plugin-api/api-report.md b/packages/frontend-plugin-api/api-report.md index d37f0a3a56..8d8dd05bf2 100644 --- a/packages/frontend-plugin-api/api-report.md +++ b/packages/frontend-plugin-api/api-report.md @@ -662,7 +662,7 @@ export type CreateExtensionBlueprintOptions< }, > = { kind: string; - namespace?: string; + namespace?: string | ((params: TParams) => string); attachTo: { id: string; input: string; @@ -670,8 +670,9 @@ export type CreateExtensionBlueprintOptions< disabled?: boolean; inputs?: TInputs; output: Array; + name?: string | ((params: TParams) => string); config?: { - schema: TConfigSchema; + schema: TConfigSchema | ((params: TParams) => TConfigSchema); }; factory( params: TParams, From 604a504328e95a8330e0dec0ada377cd139cbfe4 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 5 Aug 2024 16:38:22 +0200 Subject: [PATCH 114/372] catalog: add more filters for alpha entity cards Signed-off-by: Patrik Oldsberg --- .changeset/bright-donkeys-buy.md | 5 +++++ plugins/catalog/src/alpha/entityCards.tsx | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 .changeset/bright-donkeys-buy.md diff --git a/.changeset/bright-donkeys-buy.md b/.changeset/bright-donkeys-buy.md new file mode 100644 index 0000000000..ded16ccc2c --- /dev/null +++ b/.changeset/bright-donkeys-buy.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog': patch +--- + +The entity relation cards available for the new frontend system via `/alpha` now have more accurate and granular default filters. diff --git a/plugins/catalog/src/alpha/entityCards.tsx b/plugins/catalog/src/alpha/entityCards.tsx index 332bd49c55..8a18efabde 100644 --- a/plugins/catalog/src/alpha/entityCards.tsx +++ b/plugins/catalog/src/alpha/entityCards.tsx @@ -46,6 +46,7 @@ export const catalogLabelsEntityCard = createEntityCardExtension({ export const catalogDependsOnComponentsEntityCard = createEntityCardExtension({ name: 'depends-on-components', + filter: 'kind:component', loader: async () => import('../components/DependsOnComponentsCard').then(m => compatWrapper(), @@ -54,6 +55,7 @@ export const catalogDependsOnComponentsEntityCard = createEntityCardExtension({ export const catalogDependsOnResourcesEntityCard = createEntityCardExtension({ name: 'depends-on-resources', + filter: 'kind:component', loader: async () => import('../components/DependsOnResourcesCard').then(m => compatWrapper(), @@ -62,6 +64,7 @@ export const catalogDependsOnResourcesEntityCard = createEntityCardExtension({ export const catalogHasComponentsEntityCard = createEntityCardExtension({ name: 'has-components', + filter: 'kind:system', loader: async () => import('../components/HasComponentsCard').then(m => compatWrapper(), @@ -70,6 +73,7 @@ export const catalogHasComponentsEntityCard = createEntityCardExtension({ export const catalogHasResourcesEntityCard = createEntityCardExtension({ name: 'has-resources', + filter: 'kind:system', loader: async () => import('../components/HasResourcesCard').then(m => compatWrapper(), @@ -78,6 +82,7 @@ export const catalogHasResourcesEntityCard = createEntityCardExtension({ export const catalogHasSubcomponentsEntityCard = createEntityCardExtension({ name: 'has-subcomponents', + filter: 'kind:component', loader: async () => import('../components/HasSubcomponentsCard').then(m => compatWrapper(), @@ -86,6 +91,7 @@ export const catalogHasSubcomponentsEntityCard = createEntityCardExtension({ export const catalogHasSubdomainsEntityCard = createEntityCardExtension({ name: 'has-subdomains', + filter: 'kind:domain', loader: async () => import('../components/HasSubdomainsCard').then(m => compatWrapper(), @@ -94,6 +100,7 @@ export const catalogHasSubdomainsEntityCard = createEntityCardExtension({ export const catalogHasSystemsEntityCard = createEntityCardExtension({ name: 'has-systems', + filter: 'kind:domain', loader: async () => import('../components/HasSystemsCard').then(m => compatWrapper(), From 012e3ebf715aa78ed183fd4069152db933607c7d Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 5 Aug 2024 16:38:55 +0200 Subject: [PATCH 115/372] catalog-react: enable entity cards and content by default in new system Signed-off-by: Patrik Oldsberg --- .changeset/witty-geese-battle.md | 5 +++++ plugins/catalog-react/src/alpha.tsx | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/witty-geese-battle.md diff --git a/.changeset/witty-geese-battle.md b/.changeset/witty-geese-battle.md new file mode 100644 index 0000000000..082784cc8b --- /dev/null +++ b/.changeset/witty-geese-battle.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-react': patch +--- + +Entity page extensions created for the new frontend system via the `/alpha` exports will now be enabled by default. diff --git a/plugins/catalog-react/src/alpha.tsx b/plugins/catalog-react/src/alpha.tsx index e81b8e5ebf..42d69726b6 100644 --- a/plugins/catalog-react/src/alpha.tsx +++ b/plugins/catalog-react/src/alpha.tsx @@ -83,7 +83,7 @@ export function createEntityCardExtension< id: 'entity-content:catalog/overview', input: 'cards', }, - disabled: options.disabled ?? true, + disabled: options.disabled, output: { element: coreExtensionData.reactElement, filterFunction: catalogExtensionData.entityFilterFunction.optional(), @@ -137,7 +137,7 @@ export function createEntityContentExtension< id: 'page:catalog/entity', input: 'contents', }, - disabled: options.disabled ?? true, + disabled: options.disabled, output: { element: coreExtensionData.reactElement, path: coreExtensionData.routePath, From 5cedd9f828e8b408502ea5d4644c3de06ceaf6ba Mon Sep 17 00:00:00 2001 From: Kamil Markow Date: Mon, 5 Aug 2024 13:19:31 -0400 Subject: [PATCH 116/372] Fix TechDocs Edit URL link when trailing slash not present Signed-off-by: Kamil Markow --- .changeset/tricky-rules-destroy.md | 5 +++++ plugins/techdocs-node/src/stages/generate/helpers.test.ts | 1 + plugins/techdocs-node/src/stages/generate/helpers.ts | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/tricky-rules-destroy.md diff --git a/.changeset/tricky-rules-destroy.md b/.changeset/tricky-rules-destroy.md new file mode 100644 index 0000000000..a709e5b429 --- /dev/null +++ b/.changeset/tricky-rules-destroy.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs-node': patch +--- + +Fix TechDocs Edit URL for nexted docs diff --git a/plugins/techdocs-node/src/stages/generate/helpers.test.ts b/plugins/techdocs-node/src/stages/generate/helpers.test.ts index 6ee3870845..695f5b8f2c 100644 --- a/plugins/techdocs-node/src/stages/generate/helpers.test.ts +++ b/plugins/techdocs-node/src/stages/generate/helpers.test.ts @@ -115,6 +115,7 @@ describe('helpers', () => { url | repo_url | edit_uri ${'https://github.com/backstage/backstage'} | ${'https://github.com/backstage/backstage'} | ${undefined} ${'https://github.com/backstage/backstage/tree/main/examples/techdocs/'} | ${'https://github.com/backstage/backstage/tree/main/examples/techdocs/'} | ${'https://github.com/backstage/backstage/edit/main/examples/techdocs/docs'} + ${'https://github.com/backstage/backstage/tree/main/examples/techdocs'} | ${'https://github.com/backstage/backstage/tree/main/examples/techdocs'} | ${'https://github.com/backstage/backstage/edit/main/examples/techdocs/docs'} ${'https://github.com/backstage/backstage/tree/main/'} | ${'https://github.com/backstage/backstage/tree/main/'} | ${'https://github.com/backstage/backstage/edit/main/docs'} ${'https://gitlab.com/backstage/backstage'} | ${'https://gitlab.com/backstage/backstage'} | ${undefined} ${'https://gitlab.com/backstage/backstage/-/blob/main/examples/techdocs/'} | ${'https://gitlab.com/backstage/backstage/-/blob/main/examples/techdocs/'} | ${'https://gitlab.com/backstage/backstage/-/edit/main/examples/techdocs/docs'} diff --git a/plugins/techdocs-node/src/stages/generate/helpers.ts b/plugins/techdocs-node/src/stages/generate/helpers.ts index 5efe96877f..9c1996a772 100644 --- a/plugins/techdocs-node/src/stages/generate/helpers.ts +++ b/plugins/techdocs-node/src/stages/generate/helpers.ts @@ -117,7 +117,7 @@ export const getRepoUrlFromLocationAnnotation = ( const sourceFolder = integration.resolveUrl({ url: `./${docsFolder}`, - base: target, + base: target.endsWith('/') ? target : `${target}/`, }); return { repo_url: target, From b5679af43cbfe8a78323e9a3a8aa1512d752e9b9 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 5 Aug 2024 19:29:21 +0200 Subject: [PATCH 117/372] backend: add example usage of feature loader Signed-off-by: Patrik Oldsberg --- packages/backend/src/index.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/index.ts b/packages/backend/src/index.ts index 1174b7bf6d..952f3315c4 100644 --- a/packages/backend/src/index.ts +++ b/packages/backend/src/index.ts @@ -15,9 +15,21 @@ */ import { createBackend } from '@backstage/backend-defaults'; +import { createBackendFeatureLoader } from '@backstage/backend-plugin-api'; const backend = createBackend(); +// An example of how to group together and load multiple features. You can also +// access root-scoped services by adding `deps`. +const searchLoader = createBackendFeatureLoader({ + *loader() { + yield import('@backstage/plugin-search-backend/alpha'); + yield import('@backstage/plugin-search-backend-module-catalog/alpha'); + yield import('@backstage/plugin-search-backend-module-explore/alpha'); + yield import('@backstage/plugin-search-backend-module-techdocs/alpha'); + }, +}); + backend.add(import('@backstage/plugin-auth-backend')); backend.add(import('./authModuleGithubProvider')); backend.add(import('@backstage/plugin-auth-backend-module-guest-provider')); @@ -36,13 +48,10 @@ backend.add(import('@backstage/plugin-permission-backend/alpha')); backend.add(import('@backstage/plugin-proxy-backend/alpha')); backend.add(import('@backstage/plugin-scaffolder-backend/alpha')); backend.add(import('@backstage/plugin-scaffolder-backend-module-github')); -backend.add(import('@backstage/plugin-search-backend-module-catalog/alpha')); -backend.add(import('@backstage/plugin-search-backend-module-explore/alpha')); -backend.add(import('@backstage/plugin-search-backend-module-techdocs/alpha')); backend.add( import('@backstage/plugin-catalog-backend-module-backstage-openapi'), ); -backend.add(import('@backstage/plugin-search-backend/alpha')); +backend.add(searchLoader); backend.add(import('@backstage/plugin-techdocs-backend/alpha')); backend.add(import('@backstage/plugin-signals-backend')); backend.add(import('@backstage/plugin-notifications-backend')); From 18916691d7c998989f2e9e69d5a3beba5be74f21 Mon Sep 17 00:00:00 2001 From: Kamil Markow Date: Mon, 5 Aug 2024 13:33:57 -0400 Subject: [PATCH 118/372] Fix typo Signed-off-by: Kamil Markow --- .changeset/tricky-rules-destroy.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/tricky-rules-destroy.md b/.changeset/tricky-rules-destroy.md index a709e5b429..196702f8c4 100644 --- a/.changeset/tricky-rules-destroy.md +++ b/.changeset/tricky-rules-destroy.md @@ -2,4 +2,4 @@ '@backstage/plugin-techdocs-node': patch --- -Fix TechDocs Edit URL for nexted docs +Fix TechDocs Edit URL for nested docs From 8b1318318bda3fd794cbecd0201b6c1424fa4f86 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 5 Aug 2024 19:29:35 +0200 Subject: [PATCH 119/372] changesets: add changesets for feature loaders Signed-off-by: Patrik Oldsberg --- .changeset/curvy-pillows-joke.md | 5 +++++ .changeset/cyan-shrimps-push.md | 5 +++++ .changeset/khaki-lamps-peel.md | 26 ++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 .changeset/curvy-pillows-joke.md create mode 100644 .changeset/cyan-shrimps-push.md create mode 100644 .changeset/khaki-lamps-peel.md diff --git a/.changeset/curvy-pillows-joke.md b/.changeset/curvy-pillows-joke.md new file mode 100644 index 0000000000..25966a51c0 --- /dev/null +++ b/.changeset/curvy-pillows-joke.md @@ -0,0 +1,5 @@ +--- +'@backstage/backend-app-api': patch +--- + +Added support for the latest version of `BackendFeature`s from `@backstage/backend-plugin-api`, including feature loaders. diff --git a/.changeset/cyan-shrimps-push.md b/.changeset/cyan-shrimps-push.md new file mode 100644 index 0000000000..cb326b4da3 --- /dev/null +++ b/.changeset/cyan-shrimps-push.md @@ -0,0 +1,5 @@ +--- +'@backstage/backend-test-utils': patch +--- + +Internal updates to support latest version of `BackendFeauture`s from `@backstage/backend-plugin-api`. diff --git a/.changeset/khaki-lamps-peel.md b/.changeset/khaki-lamps-peel.md new file mode 100644 index 0000000000..82a2cbc9de --- /dev/null +++ b/.changeset/khaki-lamps-peel.md @@ -0,0 +1,26 @@ +--- +'@backstage/backend-plugin-api': patch +--- + +Added `createBackendFeatureLoader`, which can be used to programmatically select and install backend features. + +A feature loader can return an list of features to be installed, for example in the form on an `Array` or other for of iterable, which allows for the loader to be defined as a generator function. Both synchronous and asynchronous loaders are supported. + +Additionally, a loader can depend on services in its implementation, with the restriction that it can only depend on root-scoped services, and it may not override services that have already been instantiated. + +```ts +const searchLoader = createBackendFeatureLoader({ + deps: { + config: coreServices.rootConfig, + }, + *loader({ config }) { + // Example of a custom config flag to enable search + if (config.getOptionalString('customFeatureToggle.search')) { + yield import('@backstage/plugin-search-backend/alpha'); + yield import('@backstage/plugin-search-backend-module-catalog/alpha'); + yield import('@backstage/plugin-search-backend-module-explore/alpha'); + yield import('@backstage/plugin-search-backend-module-techdocs/alpha'); + } + }, +}); +``` From 299791de57fe54e1a037510862a664cebd17fa3e Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 5 Aug 2024 20:27:44 +0200 Subject: [PATCH 120/372] Update docs/permissions/plugin-authors/05-frontend-authorization.md Co-authored-by: Ben Lambert Signed-off-by: Patrik Oldsberg --- docs/permissions/plugin-authors/05-frontend-authorization.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/permissions/plugin-authors/05-frontend-authorization.md b/docs/permissions/plugin-authors/05-frontend-authorization.md index 4d673e3b4f..937730a9be 100644 --- a/docs/permissions/plugin-authors/05-frontend-authorization.md +++ b/docs/permissions/plugin-authors/05-frontend-authorization.md @@ -200,7 +200,6 @@ const routes = ( {/* highlight-add-end */} - }> {/* ... */} From 8d89264eb33e4f6516552efb8762c83047944288 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 5 Aug 2024 20:33:55 +0200 Subject: [PATCH 121/372] Update docs/permissions/plugin-authors/05-frontend-authorization.md Co-authored-by: solimant Signed-off-by: Patrik Oldsberg --- docs/permissions/plugin-authors/05-frontend-authorization.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/permissions/plugin-authors/05-frontend-authorization.md b/docs/permissions/plugin-authors/05-frontend-authorization.md index 937730a9be..4d673e3b4f 100644 --- a/docs/permissions/plugin-authors/05-frontend-authorization.md +++ b/docs/permissions/plugin-authors/05-frontend-authorization.md @@ -200,6 +200,7 @@ const routes = ( {/* highlight-add-end */} + }> {/* ... */} From 115697842b98d4d52964beb22f050943c2010ab9 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 5 Aug 2024 20:48:20 +0200 Subject: [PATCH 122/372] docs/backend-system: move naming pattern docs Signed-off-by: Patrik Oldsberg --- docs/auth/identity-resolver.md | 2 +- docs/backend-system/architecture/03-services.md | 2 +- docs/backend-system/architecture/04-plugins.md | 2 +- .../{07-naming-patterns.md => 08-naming-patterns.md} | 0 docs/backend-system/building-plugins-and-modules/01-index.md | 4 ++-- 5 files changed, 5 insertions(+), 5 deletions(-) rename docs/backend-system/architecture/{07-naming-patterns.md => 08-naming-patterns.md} (100%) diff --git a/docs/auth/identity-resolver.md b/docs/auth/identity-resolver.md index 6eb52e5708..dbebf3056c 100644 --- a/docs/auth/identity-resolver.md +++ b/docs/auth/identity-resolver.md @@ -193,7 +193,7 @@ backend.add(import('@backstage/plugin-auth-backend-module-github-provider')); backend.add(customAuth); ``` -Check out [the naming patterns article](../backend-system/architecture/07-naming-patterns.md) for what rules +Check out [the naming patterns article](../backend-system/architecture/08-naming-patterns.md) for what rules apply regarding how to form valid IDs. In this example we also put the module declaration directly in `packages/backend/src/index.ts` but that's just for simplicity. You can place it anywhere you like, including in other packages, and diff --git a/docs/backend-system/architecture/03-services.md b/docs/backend-system/architecture/03-services.md index 95e3d5305a..57f6b20b73 100644 --- a/docs/backend-system/architecture/03-services.md +++ b/docs/backend-system/architecture/03-services.md @@ -38,7 +38,7 @@ export const fooServiceRef = createServiceRef({ The `fooServiceRef` that we create above should be exported, and can then be used to declare a dependency on the `FooService` interface and receive an implementation of it at runtime. -When creating a service reference you need to give it an ID. This ID needs to be globally unique, and should generally be of the format `'.'`. For more naming patterns surrounding services, see the [naming patterns](./07-naming-patterns.md#services) page. +When creating a service reference you need to give it an ID. This ID needs to be globally unique, and should generally be of the format `'.'`. For more naming patterns surrounding services, see the [naming patterns](./08-naming-patterns.md#services) page. A note on naming: the frontend and backend systems intentionally use the separate names "APIs" and "Services" for concepts that are quite similar. This is to avoid confusion between the two, both in documentation and discussion, but also in code. While the two systems are quite similar, they are not identical, and they can't be used interchangeably. diff --git a/docs/backend-system/architecture/04-plugins.md b/docs/backend-system/architecture/04-plugins.md index af59c2a48a..5aef71e24f 100644 --- a/docs/backend-system/architecture/04-plugins.md +++ b/docs/backend-system/architecture/04-plugins.md @@ -10,7 +10,7 @@ Plugins provide the actual base features of a Backstage backend. Each plugin ope ## Defining a Plugin -Plugins are created using the `createBackendPlugin` function, and should typically be exported from a plugin package. All plugins must have an ID and a `register` method, where the ID matches the plugin ID in the package name, without the `-backend` suffix. See also the [dedicated section](./07-naming-patterns.md) about proper naming patterns. +Plugins are created using the `createBackendPlugin` function, and should typically be exported from a plugin package. All plugins must have an ID and a `register` method, where the ID matches the plugin ID in the package name, without the `-backend` suffix. See also the [dedicated section](./08-naming-patterns.md) about proper naming patterns. ```ts // plugins/example-backend/src/plugin.ts diff --git a/docs/backend-system/architecture/07-naming-patterns.md b/docs/backend-system/architecture/08-naming-patterns.md similarity index 100% rename from docs/backend-system/architecture/07-naming-patterns.md rename to docs/backend-system/architecture/08-naming-patterns.md diff --git a/docs/backend-system/building-plugins-and-modules/01-index.md b/docs/backend-system/building-plugins-and-modules/01-index.md index 379ce19587..4dfca00d4e 100644 --- a/docs/backend-system/building-plugins-and-modules/01-index.md +++ b/docs/backend-system/building-plugins-and-modules/01-index.md @@ -68,7 +68,7 @@ that's specific to your plugin. In the example above, the logger might tag messages with your plugin ID, and the HTTP router might prefix API routes with your plugin ID, depending on the implementation used. -See [the article on naming patterns](../architecture/07-naming-patterns.md) for +See [the article on naming patterns](../architecture/08-naming-patterns.md) for details on how to best choose names/IDs for plugins and related backend system items. @@ -124,7 +124,7 @@ export const catalogModuleExampleCustomProcessor = createBackendModule({ export { catalogModuleExampleCustomProcessor as default } from './module'; ``` -See [the article on naming patterns](../architecture/07-naming-patterns.md) for +See [the article on naming patterns](../architecture/08-naming-patterns.md) for details on how to best choose names/IDs for modules and related backend system items. From a8982b8ff6560556c610ddd580d4ea14df4f5616 Mon Sep 17 00:00:00 2001 From: darylgraham Date: Tue, 6 Aug 2024 00:38:31 +0000 Subject: [PATCH 123/372] Update rootLogger customisation link and new backend health check documentation Signed-off-by: darylgraham --- docs/plugins/observability.md | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/docs/plugins/observability.md b/docs/plugins/observability.md index e13653706f..f58fc4ae3d 100644 --- a/docs/plugins/observability.md +++ b/docs/plugins/observability.md @@ -17,7 +17,12 @@ See how to install Datadog Events in your app ### New Backend -The backend supplies a central logging service, [`rootLogger`](../backend-system/core-services/root-logger.md), as well as a plugin based logger, [`logger`](../backend-system/core-services/logger.md) from `coreServices`. To add additional granularity to your logs, you can create children from the plugin based logger, using the `.child()` method and provide is with JSON data. For example, if you wanted to log items for a specific span in your plugin, you could do +The backend supplies a central logging service, +[`rootLogger`](../backend-system/core-services/root-logger.md), as well as a plugin +based logger, [`logger`](../backend-system/core-services/logger.md) from `coreServices`. +To add additional granularity to your logs, you can create children from the plugin +based logger, using the `.child()` method and provide is with JSON data. For example, +if you wanted to log items for a specific span in your plugin, you could do ```ts export function createRouter({ logger }) { @@ -37,7 +42,9 @@ export function createRouter({ logger }) { } ``` -You can also add additional metadata to all logs for your Backstage instance by overriding the `rootLogger` implementation, you can see an example in [the `logger` docs](../backend-system/core-services/logger.md#configuring-the-service). +You can also add additional metadata to all logs for your Backstage instance by +overriding the `rootLogger` implementation, you can see an example in +[the `rootLogger` docs](../backend-system/core-services/root-logger#configuring-the-service). ### Old Backend @@ -63,9 +70,19 @@ An example log line could look as follows: ## Health Checks -### New Backend +### New Backend (post 1.29.0) -The new backend is moving towards health checks being plugin-based, as such there is no current plugin for providing a health check route. You can add this yourself easily though, +The new backend provides a `RootHealthService` which implements +`/.backstage/health/v1/readiness` and `/.backstage/health/v1/liveness` endpoints +to provide health checks for the entire backend instance. + +You can read more about this new service and how to customize it in the +[Root Health Service documentation](../backend-system/core-services/root-health/). + +### New Backend (pre 1.29.0) + +The new backend is moving towards health checks being plugin-based, as such there is no +current plugin for providing a health check route. You can add this yourself easily though, ```ts import { From c6ef739a165534f076208e17bf4c31e8e10d3303 Mon Sep 17 00:00:00 2001 From: darylgraham Date: Tue, 6 Aug 2024 17:19:38 +1000 Subject: [PATCH 124/372] Update bad links Signed-off-by: darylgraham --- docs/plugins/observability.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/plugins/observability.md b/docs/plugins/observability.md index f58fc4ae3d..324e6751d4 100644 --- a/docs/plugins/observability.md +++ b/docs/plugins/observability.md @@ -44,7 +44,7 @@ export function createRouter({ logger }) { You can also add additional metadata to all logs for your Backstage instance by overriding the `rootLogger` implementation, you can see an example in -[the `rootLogger` docs](../backend-system/core-services/root-logger#configuring-the-service). +[the `rootLogger` docs](../backend-system/core-services/root-logger.md#configuring-the-service). ### Old Backend @@ -77,7 +77,7 @@ The new backend provides a `RootHealthService` which implements to provide health checks for the entire backend instance. You can read more about this new service and how to customize it in the -[Root Health Service documentation](../backend-system/core-services/root-health/). +[Root Health Service documentation](../backend-system/core-services/root-health.md). ### New Backend (pre 1.29.0) From 0d16b529b7b7d8062d2da47dba07ec74896d742f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Tue, 6 Aug 2024 11:50:34 +0200 Subject: [PATCH 125/372] Add access restrictions to the JWKS external access method config schema MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/angry-dolphins-camp.md | 5 ++++ packages/backend-defaults/config.d.ts | 40 +++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 .changeset/angry-dolphins-camp.md diff --git a/.changeset/angry-dolphins-camp.md b/.changeset/angry-dolphins-camp.md new file mode 100644 index 0000000000..3c598f4a66 --- /dev/null +++ b/.changeset/angry-dolphins-camp.md @@ -0,0 +1,5 @@ +--- +'@backstage/backend-defaults': patch +--- + +Add access restrictions to the JWKS external access method config schema diff --git a/packages/backend-defaults/config.d.ts b/packages/backend-defaults/config.d.ts index ab1e443fc2..1c784bce0c 100644 --- a/packages/backend-defaults/config.d.ts +++ b/packages/backend-defaults/config.d.ts @@ -287,6 +287,46 @@ export interface Config { */ subjectPrefix?: string; }; + /** + * Restricts what types of access that are permitted for this access + * method. If no access restrictions are given, it'll have unlimited + * access. This access restriction applies for the framework level; + * individual plugins may have their own access control mechanisms + * on top of this. + */ + accessRestrictions?: Array<{ + /** + * Permit access to make requests to this plugin. + * + * Can be further refined by setting additional fields below. + */ + plugin: string; + /** + * If given, this method is limited to only performing actions + * with these named permissions in this plugin. + * + * Note that this only applies where permissions checks are + * enabled in the first place. Endpoints that are not protected by + * the permissions system at all, are not affected by this + * setting. + */ + permission?: string | Array; + /** + * If given, this method is limited to only performing actions + * whose permissions have these attributes. + * + * Note that this only applies where permissions checks are + * enabled in the first place. Endpoints that are not protected by + * the permissions system at all, are not affected by this + * setting. + */ + permissionAttribute?: { + /** + * One of more of 'create', 'read', 'update', or 'delete'. + */ + action?: string | Array; + }; + }>; } >; }; From 72754db000eea3655aec89761173c835206a81f3 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 6 Aug 2024 10:44:30 +0200 Subject: [PATCH 126/372] frontend-plugin-api: make all route refs optional at all times Signed-off-by: Patrik Oldsberg --- .changeset/friendly-chicken-cry.md | 8 ++ .changeset/small-ears-poke.md | 7 ++ .../frontend-system/architecture/07-routes.md | 87 +++++++------------ .../app-next/src/examples/pagesPlugin.tsx | 14 +-- packages/core-compat-api/api-report.md | 22 ++--- .../compatWrapper/ForwardsCompatProvider.tsx | 2 +- .../src/compatWrapper/compatWrapper.test.tsx | 2 +- .../src/convertLegacyRouteRef.test.ts | 5 +- .../src/convertLegacyRouteRef.ts | 25 ++---- packages/frontend-app-api/api-report.md | 2 +- .../src/extensions/AppNav.tsx | 7 +- .../src/routing/RouteResolver.test.ts | 37 ++------ .../src/routing/RouteResolver.ts | 2 +- .../src/routing/resolveRouteBindings.ts | 10 +-- packages/frontend-plugin-api/api-report.md | 25 ++---- .../apis/definitions/RouteResolutionApi.ts | 2 +- .../src/routing/ExternalRouteRef.test.ts | 67 ++++---------- .../src/routing/ExternalRouteRef.ts | 28 ++---- .../src/routing/useRouteRef.test.tsx | 19 +++- .../src/routing/useRouteRef.tsx | 42 +-------- .../src/app/createExtensionTester.tsx | 7 +- plugins/api-docs/api-report-alpha.md | 2 +- .../AppVisualizerPage/DetailedVisualizer.tsx | 10 +-- plugins/catalog-graph/api-report-alpha.md | 13 ++- plugins/catalog/api-report-alpha.md | 28 +++--- plugins/org/api-report-alpha.md | 2 +- plugins/scaffolder/api-report-alpha.md | 15 ++-- 27 files changed, 172 insertions(+), 318 deletions(-) create mode 100644 .changeset/friendly-chicken-cry.md create mode 100644 .changeset/small-ears-poke.md diff --git a/.changeset/friendly-chicken-cry.md b/.changeset/friendly-chicken-cry.md new file mode 100644 index 0000000000..3eadca8777 --- /dev/null +++ b/.changeset/friendly-chicken-cry.md @@ -0,0 +1,8 @@ +--- +'@backstage/frontend-test-utils': patch +'@backstage/frontend-app-api': patch +'@backstage/core-compat-api': patch +'@backstage/plugin-app-visualizer': patch +--- + +Updated usage of `useRouteRef`, which can now always return `undefined`. diff --git a/.changeset/small-ears-poke.md b/.changeset/small-ears-poke.md new file mode 100644 index 0000000000..de906a8643 --- /dev/null +++ b/.changeset/small-ears-poke.md @@ -0,0 +1,7 @@ +--- +'@backstage/frontend-plugin-api': minor +--- + +**BREAKING**: All types of route refs are always considered optional by `useRouteRef`, which means the caller must always handle a potential `undefined` return value. Related to this change, the `optional` option from `createExternalRouteRef` has been removed, since it is no longer necessary. + +This is released as an immediate breaking change as we expect the usage of the new route refs to be extremely low or zero, since plugins that support the new system will still use route refs and `useRouteRef` from `@backstage/core-plugin-api` in combination with `convertLegacyRouteRef` from `@backstage/core-compat-api`. diff --git a/docs/frontend-system/architecture/07-routes.md b/docs/frontend-system/architecture/07-routes.md index 9c6617a06f..9db4d007b6 100644 --- a/docs/frontend-system/architecture/07-routes.md +++ b/docs/frontend-system/architecture/07-routes.md @@ -101,23 +101,26 @@ export const IndexPage = () => { return (

Index Page

-
- See "Foo" details - + {/* highlight-next-line */} + {getDetailsPath && ( + + See "Foo" details + + )}
); }; ``` -We use the `useRouteRef` hook to create a link generator function that returns the details page path. We then call the link generator, passing it an object with the kind, namespace, and name. These parameters are used to construct a concrete path to the "Foo" details page. +We use the `useRouteRef` hook to create a link generator function that returns the details page path. First we need to check whether the route is available, the link generator function will be `undefined` if it isn't. We then call the link generator, passing it an object with the kind, namespace, and name. These parameters are used to construct a concrete path to the "Foo" details page. Let's see how the details page can get the parameters from the URL: @@ -176,8 +179,11 @@ export const IndexPage = () => { return (

Index Page

- {/* highlight-next-line */} - Create Component + {/* highlight-start */} + {getCreateComponentPath && ( + Create Component + )} + {/* highlight-end */}
); }; @@ -289,42 +295,6 @@ export const createComponentExternalRouteRef = createExternalRouteRef({ }); ``` -### Optional External Route References - -It is possible to define an `ExternalRouteRef` as optional, so it is not required to bind it in the app. - -```tsx title="plugins/catalog/src/routes.ts" -import { createExternalRouteRef } from '@backstage/frontend-plugin-api'; - -export const createComponentExternalRouteRef = createExternalRouteRef({ - // highlight-next-line - optional: true, -}); -``` - -When calling `useRouteRef` with an optional external route, its return signature is changed to `RouteFunc | undefined`, and the returned value can be used to decide whether a certain link should be displayed or if an action should be taken: - -```tsx title="plugins/catalog/src/components/IndexPage.tsx" -import React from 'react'; -import { useRouteRef } from '@backstage/frontend-plugin-api'; -import { createComponentExternalRouteRef } from '../routes'; - -export const IndexPage = () => { - const getCreateComponentPath = useRouteRef(createComponentExternalRouteRef); - return ( -
-

Index Page

- {/* Rendering the link only if the getCreateComponentPath is defined */} - {/* highlight-start */} - {getCreateComponentPath && ( - Create Component - )} - {/* highlight-end */} -
- ); -}; -``` - ## Sub Route References The last kind of route ref that can be created is a `SubRouteRef`, which can be used to create a route ref with a fixed path relative to an absolute `RouteRef`. They are useful if you have a page that internally is mounted at a sub route of a page extension component, and you want other plugins to be able to route to that page. And they can be a useful utility to handle routing within a plugin itself as well. @@ -368,17 +338,21 @@ import { DetailsPage } from './DetailsPage'; export const IndexPage = () => { const { pathname } = useLocation(); + + // highlight-start const getIndexPath = useRouteRef(indexRouteRef); const getDetailsPath = useRouteRef(detailsSubRouteRef); + // highlight-end + return (

Index Page

{/* Linking to the details sub route */} - {pathname === getIndexPath() ? ( - // highlight-start + {/* highlight-start */} + {pathname === getIndexPath?.() ? ( { > Show details - // highlight-end + {/* highlight-end */} ) : ( - // highlight-next-line - Hide details + {/* highlight-next-line */} + Hide details )} {/* Registering the details sub route */} + {/* highlight-next-line */} } />
diff --git a/packages/app-next/src/examples/pagesPlugin.tsx b/packages/app-next/src/examples/pagesPlugin.tsx index 826040a6cb..095c992e18 100644 --- a/packages/app-next/src/examples/pagesPlugin.tsx +++ b/packages/app-next/src/examples/pagesPlugin.tsx @@ -47,9 +47,11 @@ const IndexPage = createPageExtension({ return (
op -
- Page 1 -
+ {page1Link && ( +
+ Page 1 +
+ )}
Home
@@ -82,10 +84,10 @@ const Page1 = createPageExtension({ return (

This is page 1

- Go back + {indexLink && Go back} Page 2 {/* Page 2 */} - Page X + {xLink && Page X}
Sub-page content: @@ -115,7 +117,7 @@ const ExternalPage = createPageExtension({ return (

This is page X

- Go back + {indexLink && Go back}
); }; diff --git a/packages/core-compat-api/api-report.md b/packages/core-compat-api/api-report.md index 3cd78e6f30..8d177b4dab 100644 --- a/packages/core-compat-api/api-report.md +++ b/packages/core-compat-api/api-report.md @@ -37,12 +37,9 @@ export function convertLegacyRouteRef( ): SubRouteRef_2; // @public -export function convertLegacyRouteRef< - TParams extends AnyRouteRefParams, - TOptional extends boolean, ->( - ref: ExternalRouteRef, -): ExternalRouteRef_2; +export function convertLegacyRouteRef( + ref: ExternalRouteRef, +): ExternalRouteRef_2; // @public export function convertLegacyRouteRef( @@ -55,12 +52,9 @@ export function convertLegacyRouteRef( ): SubRouteRef; // @public -export function convertLegacyRouteRef< - TParams extends AnyRouteRefParams, - TOptional extends boolean, ->( - ref: ExternalRouteRef_2, -): ExternalRouteRef; +export function convertLegacyRouteRef( + ref: ExternalRouteRef_2, +): ExternalRouteRef; // @public export function convertLegacyRouteRefs< @@ -93,8 +87,8 @@ export type ToNewRouteRef = ? RouteRef_2 : T extends SubRouteRef ? SubRouteRef_2 - : T extends ExternalRouteRef - ? ExternalRouteRef_2 + : T extends ExternalRouteRef + ? ExternalRouteRef_2 : never; // (No @packageDocumentation comment for this package) diff --git a/packages/core-compat-api/src/compatWrapper/ForwardsCompatProvider.tsx b/packages/core-compat-api/src/compatWrapper/ForwardsCompatProvider.tsx index b2200387cc..9c646d5b00 100644 --- a/packages/core-compat-api/src/compatWrapper/ForwardsCompatProvider.tsx +++ b/packages/core-compat-api/src/compatWrapper/ForwardsCompatProvider.tsx @@ -111,7 +111,7 @@ class CompatRouteResolutionApi implements RouteResolutionApi { anyRouteRef: | RouteRef | SubRouteRef - | ExternalRouteRef, + | ExternalRouteRef, options?: RouteResolutionApiResolveOptions | undefined, ): RouteFunc | undefined { const legacyRef = convertLegacyRouteRef(anyRouteRef as RouteRef); diff --git a/packages/core-compat-api/src/compatWrapper/compatWrapper.test.tsx b/packages/core-compat-api/src/compatWrapper/compatWrapper.test.tsx index 6a27bf19e8..04e2361087 100644 --- a/packages/core-compat-api/src/compatWrapper/compatWrapper.test.tsx +++ b/packages/core-compat-api/src/compatWrapper/compatWrapper.test.tsx @@ -129,7 +129,7 @@ describe('ForwardsCompatProvider', () => { function Component() { const link = useNewRouteRef(routeRef); - return
link: {link()}
; + return
link: {link?.()}
; } await renderInOldTestApp(compatWrapper(), { diff --git a/packages/core-compat-api/src/convertLegacyRouteRef.test.ts b/packages/core-compat-api/src/convertLegacyRouteRef.test.ts index bf82d1e034..f09060212c 100644 --- a/packages/core-compat-api/src/convertLegacyRouteRef.test.ts +++ b/packages/core-compat-api/src/convertLegacyRouteRef.test.ts @@ -123,13 +123,11 @@ describe('convertLegacyRouteRef', () => { 'routeRef{type=external,id=ref3}', ); expect(ref3Internal.getParams()).toEqual([]); - expect(ref3Internal.optional).toBe(false); expect(ref4Internal.getDefaultTarget()).toBe('ref2'); expect(ref4Internal.getDescription()).toBe( 'routeRef{type=external,id=ref4}', ); expect(ref4Internal.getParams()).toEqual(['p1', 'p2']); - expect(ref4Internal.optional).toBe(true); }); it('converts new to old', () => { @@ -149,7 +147,6 @@ describe('convertLegacyRouteRef', () => { }); const ref3 = createNewExternalRouteRef(); const ref4 = createNewExternalRouteRef({ - optional: true, defaultTarget: 'ref2', params: ['p1', 'p2'], }); @@ -196,7 +193,7 @@ describe('convertLegacyRouteRef', () => { /^ExternalRouteRef\{created at '.*'\}$/, ); expect(ref3Converted.params).toEqual([]); - expect(ref3Converted.optional).toBe(false); + expect(ref3Converted.optional).toBe(true); expect(String(ref4Converted)).toMatch( /^ExternalRouteRef\{created at '.*'\}$/, ); diff --git a/packages/core-compat-api/src/convertLegacyRouteRef.ts b/packages/core-compat-api/src/convertLegacyRouteRef.ts index 24c589bb87..40a95a81ff 100644 --- a/packages/core-compat-api/src/convertLegacyRouteRef.ts +++ b/packages/core-compat-api/src/convertLegacyRouteRef.ts @@ -51,8 +51,8 @@ export type ToNewRouteRef< ? RouteRef : T extends LegacySubRouteRef ? SubRouteRef - : T extends LegacyExternalRouteRef - ? ExternalRouteRef + : T extends LegacyExternalRouteRef + ? ExternalRouteRef : never; /** @@ -109,12 +109,9 @@ export function convertLegacyRouteRef( * * In the future the legacy createExternalRouteRef will instead create refs compatible with both systems. */ -export function convertLegacyRouteRef< - TParams extends AnyRouteRefParams, - TOptional extends boolean, ->( - ref: LegacyExternalRouteRef, -): ExternalRouteRef; +export function convertLegacyRouteRef( + ref: LegacyExternalRouteRef, +): ExternalRouteRef; /** * A temporary helper to convert a new route ref to the legacy system. @@ -148,12 +145,9 @@ export function convertLegacyRouteRef( * * In the future the legacy createExternalRouteRef will instead create refs compatible with both systems. */ -export function convertLegacyRouteRef< - TParams extends AnyRouteRefParams, - TOptional extends boolean, ->( - ref: ExternalRouteRef, -): LegacyExternalRouteRef; +export function convertLegacyRouteRef( + ref: ExternalRouteRef, +): LegacyExternalRouteRef; export function convertLegacyRouteRef( ref: | LegacyRouteRef @@ -209,6 +203,7 @@ function convertNewToOld( const newRef = toInternalExternalRouteRef(ref); return Object.assign(ref, { [routeRefType]: 'external', + optional: true, params: newRef.getParams(), defaultTarget: newRef.getDefaultTarget(), } as Omit) as unknown as LegacyExternalRouteRef; @@ -282,7 +277,6 @@ function convertOldToNew( const newRef = toInternalExternalRouteRef( createExternalRouteRef<{ [key in string]: string }>({ params: legacyRef.params as string[], - optional: legacyRef.optional, defaultTarget: 'getDefaultTarget' in legacyRef ? (legacyRef.getDefaultTarget as () => string | undefined)() @@ -293,7 +287,6 @@ function convertOldToNew( $$type: '@backstage/ExternalRouteRef' as const, version: 'v1', T: newRef.T, - optional: newRef.optional, getParams() { return newRef.getParams(); }, diff --git a/packages/frontend-app-api/api-report.md b/packages/frontend-app-api/api-report.md index 0375a67482..27d486b6a8 100644 --- a/packages/frontend-app-api/api-report.md +++ b/packages/frontend-app-api/api-report.md @@ -44,7 +44,7 @@ export type CreateAppRouteBinder = < externalRoutes: TExternalRoutes, targetRoutes: PartialKeys< TargetRouteMap, - KeysWithType> + KeysWithType> >, ) => void; diff --git a/packages/frontend-app-api/src/extensions/AppNav.tsx b/packages/frontend-app-api/src/extensions/AppNav.tsx index 761c6d5a24..ffef1c7c61 100644 --- a/packages/frontend-app-api/src/extensions/AppNav.tsx +++ b/packages/frontend-app-api/src/extensions/AppNav.tsx @@ -73,9 +73,12 @@ const SidebarNavItem = ( props: (typeof createNavItemExtension.targetDataRef)['T'], ) => { const { icon: Icon, title, routeRef } = props; - const to = useRouteRef(routeRef)(); + const link = useRouteRef(routeRef); + if (!link) { + return null; + } // TODO: Support opening modal, for example, the search one - return ; + return ; }; export const AppNav = createExtension({ diff --git a/packages/frontend-app-api/src/routing/RouteResolver.test.ts b/packages/frontend-app-api/src/routing/RouteResolver.test.ts index ba0a66a380..497e7397cb 100644 --- a/packages/frontend-app-api/src/routing/RouteResolver.test.ts +++ b/packages/frontend-app-api/src/routing/RouteResolver.test.ts @@ -41,9 +41,7 @@ const subRef2 = createSubRouteRef({ parent: ref1, path: '/foo/:a' }); const subRef3 = createSubRouteRef({ parent: ref2, path: '/bar' }); const subRef4 = createSubRouteRef({ parent: ref2, path: '/bar/:a' }); const externalRef1 = createExternalRouteRef(); -const externalRef2 = createExternalRouteRef({ optional: true }); -const externalRef3 = createExternalRouteRef({ params: ['x'] }); -const externalRef4 = createExternalRouteRef({ optional: true, params: ['x'] }); +const externalRef2 = createExternalRouteRef({ params: ['x'] }); function src(sourcePath: string) { return { sourcePath }; @@ -62,9 +60,7 @@ describe('RouteResolver', () => { undefined, ); expect(r.resolve(externalRef1, src('/'))?.()).toBe(undefined); - expect(r.resolve(externalRef2, src('/'))?.()).toBe(undefined); - expect(r.resolve(externalRef3, src('/'))?.({ x: '5x' })).toBe(undefined); - expect(r.resolve(externalRef4, src('/'))?.({ x: '6x' })).toBe(undefined); + expect(r.resolve(externalRef2, src('/'))?.({ x: '5x' })).toBe(undefined); }); it('should resolve an absolute route', () => { @@ -87,9 +83,7 @@ describe('RouteResolver', () => { undefined, ); expect(r.resolve(externalRef1, src('/'))?.()).toBe(undefined); - expect(r.resolve(externalRef2, src('/'))?.()).toBe(undefined); - expect(r.resolve(externalRef3, src('/'))?.({ x: '5x' })).toBe(undefined); - expect(r.resolve(externalRef4, src('/'))?.({ x: '6x' })).toBe(undefined); + expect(r.resolve(externalRef2, src('/'))?.({ x: '5x' })).toBe(undefined); }); it('should resolve an absolute route with a param and with a parent', () => { @@ -112,8 +106,7 @@ describe('RouteResolver', () => { ], new Map([ [externalRef1, ref1], - [externalRef3, ref2], - [externalRef4, subRef3], + [externalRef2, subRef3], ]), '', ); @@ -133,11 +126,7 @@ describe('RouteResolver', () => { '/my-route/my-parent/4x/bar/4a', ); expect(r.resolve(externalRef1, src('/'))?.()).toBe('/my-route'); - expect(r.resolve(externalRef2, src('/'))?.()).toBe(undefined); - expect(r.resolve(externalRef3, src('/'))?.({ x: '5x' })).toBe( - '/my-route/my-parent/5x', - ); - expect(r.resolve(externalRef4, src('/'))?.({ x: '6x' })).toBe( + expect(r.resolve(externalRef2, src('/'))?.({ x: '6x' })).toBe( '/my-route/my-parent/6x/bar', ); }); @@ -230,8 +219,7 @@ describe('RouteResolver', () => { ], new Map([ [externalRef1, ref1], - [externalRef3, ref2], - [externalRef4, subRef3], + [externalRef2, subRef3], ]), '', ); @@ -282,17 +270,10 @@ describe('RouteResolver', () => { expect(() => r.resolve(externalRef1, src('/'))?.()).toThrow( /^Cannot route.*with parent.*as it has parameters$/, ); - expect(r.resolve(externalRef2, src(l))?.()).toBe(undefined); - expect(r.resolve(externalRef3, src(l))?.({ x: '5x' })).toBe( - '/my-grandparent/my-y/my-parent/5x', + expect(r.resolve(externalRef2, src(l))?.({ x: '5x' })).toBe( + '/my-grandparent/my-y/my-parent/5x/bar', ); - expect(() => r.resolve(externalRef3, src('/'))?.({ x: '5x' })).toThrow( - /^Cannot route.*with parent.*as it has parameters$/, - ); - expect(r.resolve(externalRef4, src(l))?.({ x: '6x' })).toBe( - '/my-grandparent/my-y/my-parent/6x/bar', - ); - expect(() => r.resolve(externalRef4, src('/'))?.({ x: '6x' })).toThrow( + expect(() => r.resolve(externalRef2, src('/'))?.({ x: '5x' })).toThrow( /^Cannot route.*with parent.*as it has parameters$/, ); }); diff --git a/packages/frontend-app-api/src/routing/RouteResolver.ts b/packages/frontend-app-api/src/routing/RouteResolver.ts index 1ec1822fe9..ff7966c4db 100644 --- a/packages/frontend-app-api/src/routing/RouteResolver.ts +++ b/packages/frontend-app-api/src/routing/RouteResolver.ts @@ -195,7 +195,7 @@ export class RouteResolver implements RouteResolutionApi { anyRouteRef: | RouteRef | SubRouteRef - | ExternalRouteRef, + | ExternalRouteRef, options?: RouteResolutionApiResolveOptions, ): RouteFunc | undefined { // First figure out what our target absolute ref is, as well as our target path. diff --git a/packages/frontend-app-api/src/routing/resolveRouteBindings.ts b/packages/frontend-app-api/src/routing/resolveRouteBindings.ts index 81d9eddef3..a8f641daff 100644 --- a/packages/frontend-app-api/src/routing/resolveRouteBindings.ts +++ b/packages/frontend-app-api/src/routing/resolveRouteBindings.ts @@ -53,8 +53,7 @@ type TargetRouteMap< ExternalRoutes extends { [name: string]: ExternalRouteRef }, > = { [name in keyof ExternalRoutes]: ExternalRoutes[name] extends ExternalRouteRef< - infer Params, - any + infer Params > ? RouteRef | SubRouteRef : never; @@ -72,7 +71,7 @@ export type CreateAppRouteBinder = < externalRoutes: TExternalRoutes, targetRoutes: PartialKeys< TargetRouteMap, - KeysWithType> + KeysWithType> >, ) => void; @@ -95,11 +94,6 @@ export function resolveRouteBindings( if (!externalRoute) { throw new Error(`Key ${key} is not an existing external route`); } - if (!value && !externalRoute.optional) { - throw new Error( - `External route ${key} is required but was undefined`, - ); - } if (value) { result.set(externalRoute, value); } diff --git a/packages/frontend-plugin-api/api-report.md b/packages/frontend-plugin-api/api-report.md index d37f0a3a56..93f300c591 100644 --- a/packages/frontend-plugin-api/api-report.md +++ b/packages/frontend-plugin-api/api-report.md @@ -799,13 +799,11 @@ export function createExternalRouteRef< [param in TParamKeys]: string; } | undefined = undefined, - TOptional extends boolean = false, TParamKeys extends string = string, >(options?: { readonly params?: string extends TParamKeys ? (keyof TParams)[] : TParamKeys[]; - optional?: TOptional; defaultTarget?: string; }): ExternalRouteRef< keyof TParams extends never @@ -814,8 +812,7 @@ export function createExternalRouteRef< ? TParams : { [param in TParamKeys]: string; - }, - TOptional + } >; // @public @@ -1300,13 +1297,10 @@ export interface ExtensionOverridesOptions { // @public export interface ExternalRouteRef< TParams extends AnyRouteRefParams = AnyRouteRefParams, - TOptional extends boolean = boolean, > { // (undocumented) readonly $$type: '@backstage/ExternalRouteRef'; // (undocumented) - readonly optional: TOptional; - // (undocumented) readonly T: TParams; } @@ -1570,7 +1564,7 @@ export interface RouteResolutionApi { anyRouteRef: | RouteRef | SubRouteRef - | ExternalRouteRef, + | ExternalRouteRef, options?: RouteResolutionApiResolveOptions, ): RouteFunc | undefined; } @@ -1631,18 +1625,13 @@ export function useComponentRef( ref: ComponentRef, ): ComponentType; -// @public -export function useRouteRef< - TOptional extends boolean, - TParams extends AnyRouteRefParams, ->( - routeRef: ExternalRouteRef, -): TOptional extends true ? RouteFunc | undefined : RouteFunc; - // @public export function useRouteRef( - routeRef: RouteRef | SubRouteRef, -): RouteFunc; + routeRef: + | RouteRef + | SubRouteRef + | ExternalRouteRef, +): RouteFunc | undefined; // @public export function useRouteRefParams( diff --git a/packages/frontend-plugin-api/src/apis/definitions/RouteResolutionApi.ts b/packages/frontend-plugin-api/src/apis/definitions/RouteResolutionApi.ts index 06388cc966..30569bde15 100644 --- a/packages/frontend-plugin-api/src/apis/definitions/RouteResolutionApi.ts +++ b/packages/frontend-plugin-api/src/apis/definitions/RouteResolutionApi.ts @@ -60,7 +60,7 @@ export interface RouteResolutionApi { anyRouteRef: | RouteRef | SubRouteRef - | ExternalRouteRef, + | ExternalRouteRef, options?: RouteResolutionApiResolveOptions, ): RouteFunc | undefined; } diff --git a/packages/frontend-plugin-api/src/routing/ExternalRouteRef.test.ts b/packages/frontend-plugin-api/src/routing/ExternalRouteRef.test.ts index 727dc1f53e..97d3dd2264 100644 --- a/packages/frontend-plugin-api/src/routing/ExternalRouteRef.test.ts +++ b/packages/frontend-plugin-api/src/routing/ExternalRouteRef.test.ts @@ -26,7 +26,6 @@ describe('ExternalRouteRef', () => { const routeRef: ExternalRouteRef = createExternalRouteRef(); const internal = toInternalExternalRouteRef(routeRef); expect(internal.getParams()).toEqual([]); - expect(internal.optional).toBe(false); expect(String(internal)).toMatch( /^ExternalRouteRef\{created at '.*ExternalRouteRef\.test\.ts.*'\}$/, @@ -35,16 +34,6 @@ describe('ExternalRouteRef', () => { expect(String(internal)).toBe('ExternalRouteRef{some-id}'); }); - it('should be created as optional', () => { - const routeRef: ExternalRouteRef = createExternalRouteRef({ - params: [], - optional: true, - }); - const internal = toInternalExternalRouteRef(routeRef); - expect(internal.getParams()).toEqual([]); - expect(internal.optional).toEqual(true); - }); - it('should be created with params', () => { const routeRef: ExternalRouteRef<{ x: string; @@ -52,63 +41,39 @@ describe('ExternalRouteRef', () => { }> = createExternalRouteRef({ params: ['x', 'y'] }); const internal = toInternalExternalRouteRef(routeRef); expect(internal.getParams()).toEqual(['x', 'y']); - expect(internal.optional).toEqual(false); - }); - - it('should be created as optional with params', () => { - const routeRef: ExternalRouteRef<{ - x: string; - y: string; - }> = createExternalRouteRef({ params: ['x', 'y'], optional: true }); - const internal = toInternalExternalRouteRef(routeRef); - expect(internal.getParams()).toEqual(['x', 'y']); - expect(internal.optional).toEqual(true); }); it('should properly infer and validate parameter types and assignments', () => { - function checkRouteRef< - T extends AnyRouteRefParams, - TOptional extends boolean, - TCheck extends TOptional, - >( - _ref: ExternalRouteRef, + function checkRouteRef( + _ref: ExternalRouteRef, _params: T extends undefined ? undefined : T, - _optional: TCheck, ) {} - const _1 = createExternalRouteRef({ params: ['notX'] }); - checkRouteRef(_1, { notX: '' }, false); + const _1 = createExternalRouteRef(); + checkRouteRef(_1, undefined); // @ts-expect-error - checkRouteRef(_1, { x: '' }, false); + checkRouteRef(_1, { x: '' }); - const _2 = createExternalRouteRef({ params: ['x'], optional: true }); - checkRouteRef(_2, { x: '' }, true); + const _2 = createExternalRouteRef({ params: ['x'] }); + checkRouteRef(_2, { x: '' }); // @ts-expect-error - checkRouteRef(_2, undefined, false); + checkRouteRef(_2, { notX: '' }); + // @ts-expect-error + checkRouteRef(_2, undefined); const _3 = createExternalRouteRef({ params: ['x', 'y'] }); - checkRouteRef(_3, { x: '', y: '' }, false); + checkRouteRef(_3, { x: '', y: '' }); // @ts-expect-error - checkRouteRef(_3, { x: '' }, false); + checkRouteRef(_3, { x: '' }); // @ts-expect-error - checkRouteRef(_3, { x: '', y: '', z: '' }, false); + checkRouteRef(_3, { x: '', y: '', z: '' }); const _4 = createExternalRouteRef({ params: [] }); - checkRouteRef(_4, undefined, false); + checkRouteRef(_4, undefined); // @ts-expect-error - checkRouteRef(_4, { x: '' }); - - const _5 = createExternalRouteRef(); - checkRouteRef(_5, undefined, false); - // @ts-expect-error - checkRouteRef(_5, { x: '' }); - - const _6 = createExternalRouteRef({ optional: true }); - checkRouteRef(_6, undefined, true); - // @ts-expect-error - checkRouteRef(_6, undefined, false); + checkRouteRef(_4, { x: '' }); // To avoid complains about missing expectations and unused vars - expect([_1, _2, _3, _4, _5, _6].join('')).toEqual(expect.any(String)); + expect([_1, _2, _3, _4].join('')).toEqual(expect.any(String)); }); }); diff --git a/packages/frontend-plugin-api/src/routing/ExternalRouteRef.ts b/packages/frontend-plugin-api/src/routing/ExternalRouteRef.ts index 7a754ffa7b..6ce36707c0 100644 --- a/packages/frontend-plugin-api/src/routing/ExternalRouteRef.ts +++ b/packages/frontend-plugin-api/src/routing/ExternalRouteRef.ts @@ -29,18 +29,15 @@ import { AnyRouteRefParams } from './types'; */ export interface ExternalRouteRef< TParams extends AnyRouteRefParams = AnyRouteRefParams, - TOptional extends boolean = boolean, > { readonly $$type: '@backstage/ExternalRouteRef'; readonly T: TParams; - readonly optional: TOptional; } /** @internal */ export interface InternalExternalRouteRef< TParams extends AnyRouteRefParams = AnyRouteRefParams, - TOptional extends boolean = boolean, -> extends ExternalRouteRef { +> extends ExternalRouteRef { readonly version: 'v1'; getParams(): string[]; getDescription(): string; @@ -52,11 +49,8 @@ export interface InternalExternalRouteRef< /** @internal */ export function toInternalExternalRouteRef< TParams extends AnyRouteRefParams = AnyRouteRefParams, - TOptional extends boolean = boolean, ->( - resource: ExternalRouteRef, -): InternalExternalRouteRef { - const r = resource as InternalExternalRouteRef; +>(resource: ExternalRouteRef): InternalExternalRouteRef { + const r = resource as InternalExternalRouteRef; if (r.$$type !== '@backstage/ExternalRouteRef') { throw new Error(`Invalid ExternalRouteRef, bad type '${r.$$type}'`); } @@ -79,7 +73,6 @@ class ExternalRouteRefImpl readonly $$type = '@backstage/ExternalRouteRef' as any; constructor( - readonly optional: boolean, readonly params: string[] = [], readonly defaultTarget: string | undefined, creationSite: string, @@ -104,7 +97,6 @@ class ExternalRouteRefImpl */ export function createExternalRouteRef< TParams extends { [param in TParamKeys]: string } | undefined = undefined, - TOptional extends boolean = false, TParamKeys extends string = string, >(options?: { /** @@ -114,14 +106,6 @@ export function createExternalRouteRef< ? (keyof TParams)[] : TParamKeys[]; - /** - * Whether or not this route is optional, defaults to false. - * - * Optional external routes are not required to be bound in the app, and - * if they aren't, `useExternalRouteRef` will return `undefined`. - */ - optional?: TOptional; - /** * The route (typically in another plugin) that this should map to by default. * @@ -134,13 +118,11 @@ export function createExternalRouteRef< ? undefined : string extends TParamKeys ? TParams - : { [param in TParamKeys]: string }, - TOptional + : { [param in TParamKeys]: string } > { return new ExternalRouteRefImpl( - Boolean(options?.optional), options?.params as string[] | undefined, options?.defaultTarget, describeParentCallSite(), - ) as ExternalRouteRef; + ); } diff --git a/packages/frontend-plugin-api/src/routing/useRouteRef.test.tsx b/packages/frontend-plugin-api/src/routing/useRouteRef.test.tsx index 4f43cf8d01..bdac95a5a0 100644 --- a/packages/frontend-plugin-api/src/routing/useRouteRef.test.tsx +++ b/packages/frontend-plugin-api/src/routing/useRouteRef.test.tsx @@ -45,7 +45,7 @@ describe('v1 consumer', () => { }); const routeFunc = renderedHook.result.current; - expect(routeFunc()).toBe('/hello'); + expect(routeFunc?.()).toBe('/hello'); expect(resolve).toHaveBeenCalledWith( routeRef, expect.objectContaining({ @@ -54,6 +54,23 @@ describe('v1 consumer', () => { ); }); + it('should ignore missing routes', () => { + const routeRef = createRouteRef(); + + const renderedHook = renderHook(() => useRouteRef(routeRef), { + wrapper: ({ children }: React.PropsWithChildren<{}>) => ( + undefined }]]} + > + + + ), + }); + + const routeFunc = renderedHook.result.current; + expect(routeFunc).toBeUndefined(); + }); + it('re-resolves the routeFunc when the search parameters change', () => { const resolve = jest.fn(() => () => '/hello'); diff --git a/packages/frontend-plugin-api/src/routing/useRouteRef.tsx b/packages/frontend-plugin-api/src/routing/useRouteRef.tsx index fdf831953d..2d2b3a5458 100644 --- a/packages/frontend-plugin-api/src/routing/useRouteRef.tsx +++ b/packages/frontend-plugin-api/src/routing/useRouteRef.tsx @@ -30,47 +30,14 @@ import { RouteFunc, routeResolutionApiRef, useApi } from '../apis'; * See {@link https://backstage.io/docs/plugins/composability#routing-system} * * @param routeRef - The ref to route that should be converted to URL. - * @returns A function that will in turn return the concrete URL of the `routeRef`. - * @public - */ -export function useRouteRef< - TOptional extends boolean, - TParams extends AnyRouteRefParams, ->( - routeRef: ExternalRouteRef, -): TOptional extends true ? RouteFunc | undefined : RouteFunc; - -/** - * React hook for constructing URLs to routes. - * - * @remarks - * - * See {@link https://backstage.io/docs/plugins/composability#routing-system} - * - * @param routeRef - The ref to route that should be converted to URL. - * @returns A function that will in turn return the concrete URL of the `routeRef`. - * @public - */ -export function useRouteRef( - routeRef: RouteRef | SubRouteRef, -): RouteFunc; - -/** - * React hook for constructing URLs to routes. - * - * @remarks - * - * See {@link https://backstage.io/docs/plugins/composability#routing-system} - * - * @param routeRef - The ref to route that should be converted to URL. - * @returns A function that will in turn return the concrete URL of the `routeRef`. + * @returns A function that will in turn return the concrete URL of the `routeRef`, or `undefined` if the route is not available. * @public */ export function useRouteRef( routeRef: | RouteRef | SubRouteRef - | ExternalRouteRef, + | ExternalRouteRef, ): RouteFunc | undefined { const { pathname } = useLocation(); const routeResolutionApi = useApi(routeResolutionApiRef); @@ -80,10 +47,5 @@ export function useRouteRef( [routeResolutionApi, routeRef, pathname], ); - const isOptional = 'optional' in routeRef && routeRef.optional; - if (!routeFunc && !isOptional) { - throw new Error(`No path for ${routeRef}`); - } - return routeFunc; } diff --git a/packages/frontend-test-utils/src/app/createExtensionTester.tsx b/packages/frontend-test-utils/src/app/createExtensionTester.tsx index 1d41958a09..bbe52c3fbc 100644 --- a/packages/frontend-test-utils/src/app/createExtensionTester.tsx +++ b/packages/frontend-test-utils/src/app/createExtensionTester.tsx @@ -56,10 +56,13 @@ const NavItem = (props: { icon: IconComponent; }) => { const { routeRef, title, icon: Icon } = props; - const to = useRouteRef(routeRef)(); + const link = useRouteRef(routeRef); + if (!link) { + return null; + } return (
  • - + {title}
  • diff --git a/plugins/api-docs/api-report-alpha.md b/plugins/api-docs/api-report-alpha.md index 1d22283884..f17ba0fa3c 100644 --- a/plugins/api-docs/api-report-alpha.md +++ b/plugins/api-docs/api-report-alpha.md @@ -13,7 +13,7 @@ const _default: BackstagePlugin< root: RouteRef; }, { - registerApi: ExternalRouteRef; + registerApi: ExternalRouteRef; } >; export default _default; diff --git a/plugins/app-visualizer/src/components/AppVisualizerPage/DetailedVisualizer.tsx b/plugins/app-visualizer/src/components/AppVisualizerPage/DetailedVisualizer.tsx index 2356f38cfa..b2c9685bab 100644 --- a/plugins/app-visualizer/src/components/AppVisualizerPage/DetailedVisualizer.tsx +++ b/plugins/app-visualizer/src/components/AppVisualizerPage/DetailedVisualizer.tsx @@ -189,18 +189,12 @@ function OutputLink(props: { }) { const routeRef = props.node?.instance?.getData(coreExtensionData.routeRef); - let link: string | undefined = undefined; - try { - // eslint-disable-next-line react-hooks/rules-of-hooks - link = useRouteRef(routeRef as RouteRef)(); - } catch { - /* ignore */ - } + const link = useRouteRef(routeRef as RouteRef); return ( {props.dataRef.id}}> - {link ? link : null} + {link ? link : null} ); diff --git a/plugins/catalog-graph/api-report-alpha.md b/plugins/catalog-graph/api-report-alpha.md index 3895f12fcf..88b3a38b76 100644 --- a/plugins/catalog-graph/api-report-alpha.md +++ b/plugins/catalog-graph/api-report-alpha.md @@ -13,14 +13,11 @@ const _default: BackstagePlugin< catalogGraph: RouteRef; }, { - catalogEntity: ExternalRouteRef< - { - name: string; - kind: string; - namespace: string; - }, - true - >; + catalogEntity: ExternalRouteRef<{ + name: string; + kind: string; + namespace: string; + }>; } >; export default _default; diff --git a/plugins/catalog/api-report-alpha.md b/plugins/catalog/api-report-alpha.md index f79d65394a..336bf4bc2b 100644 --- a/plugins/catalog/api-report-alpha.md +++ b/plugins/catalog/api-report-alpha.md @@ -121,23 +121,17 @@ const _default: BackstagePlugin< }>; }, { - viewTechDoc: ExternalRouteRef< - { - name: string; - kind: string; - namespace: string; - }, - true - >; - createComponent: ExternalRouteRef; - createFromTemplate: ExternalRouteRef< - { - namespace: string; - templateName: string; - }, - true - >; - unregisterRedirect: ExternalRouteRef; + viewTechDoc: ExternalRouteRef<{ + name: string; + kind: string; + namespace: string; + }>; + createComponent: ExternalRouteRef; + createFromTemplate: ExternalRouteRef<{ + namespace: string; + templateName: string; + }>; + unregisterRedirect: ExternalRouteRef; } >; export default _default; diff --git a/plugins/org/api-report-alpha.md b/plugins/org/api-report-alpha.md index 8c5391d857..e7c4db2c6d 100644 --- a/plugins/org/api-report-alpha.md +++ b/plugins/org/api-report-alpha.md @@ -10,7 +10,7 @@ import { ExternalRouteRef } from '@backstage/frontend-plugin-api'; const _default: BackstagePlugin< {}, { - catalogIndex: ExternalRouteRef; + catalogIndex: ExternalRouteRef; } >; export default _default; diff --git a/plugins/scaffolder/api-report-alpha.md b/plugins/scaffolder/api-report-alpha.md index 3f0b60cd95..4628563be2 100644 --- a/plugins/scaffolder/api-report-alpha.md +++ b/plugins/scaffolder/api-report-alpha.md @@ -30,15 +30,12 @@ const _default: BackstagePlugin< edit: SubRouteRef; }, { - registerComponent: ExternalRouteRef; - viewTechDoc: ExternalRouteRef< - { - name: string; - kind: string; - namespace: string; - }, - true - >; + registerComponent: ExternalRouteRef; + viewTechDoc: ExternalRouteRef<{ + name: string; + kind: string; + namespace: string; + }>; } >; export default _default; From f71e33bc6de94a785048c20d78a86b97b0926f14 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 6 Aug 2024 13:26:28 +0200 Subject: [PATCH 127/372] Update .changeset/neat-socks-cheer.md Signed-off-by: Patrik Oldsberg --- .changeset/neat-socks-cheer.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/neat-socks-cheer.md b/.changeset/neat-socks-cheer.md index 5e2879b0a3..ffc76bec3f 100644 --- a/.changeset/neat-socks-cheer.md +++ b/.changeset/neat-socks-cheer.md @@ -1,5 +1,5 @@ --- -'@backstage/plugin-auth-node': patch +'@backstage/plugin-auth-node': minor --- -allow declarative sign in resolvers declared in `signInResolverFactories` to take precedence over the statically defined sign in resolvers in `signInResolver` for the `createOAuthProviderFactory`. +**BREAKING**: Sign-in resolvers configured via `.signIn.resolvers` now take precedence over sign-in resolvers passed to `signInResolver` option of `createOAuthProviderFactory`. This effectively makes sign-in resolvers passed via the `signInResolver` the default one, which you can then override through configuration. From 0724159d17160e59682e351e2cd33c4c860ab855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Tue, 6 Aug 2024 13:32:32 +0200 Subject: [PATCH 128/372] tech insights has been moved MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- microsite/data/plugins/tech-insights.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsite/data/plugins/tech-insights.yaml b/microsite/data/plugins/tech-insights.yaml index fbf96df3e6..3bd40d576a 100644 --- a/microsite/data/plugins/tech-insights.yaml +++ b/microsite/data/plugins/tech-insights.yaml @@ -6,7 +6,7 @@ category: Discovery description: Visualize, understand and optimize your team's tech health. documentation: https://roadie.io/backstage/plugins/tech-insights/ iconUrl: https://roadie.io/images/logos/tech-insights.png -npmPackageName: '@backstage/plugin-tech-insights' +npmPackageName: '@backstage-community/plugin-tech-insights' tags: - tech-insights - reporting From 25a4c77a2ec11914f61457560dc7b7f4ae417d47 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 5 Aug 2024 20:48:30 +0200 Subject: [PATCH 129/372] docs/backend-system: add feature loader docs Signed-off-by: Patrik Oldsberg --- .../architecture/07-feature-loaders.md | 101 ++++++++++++++++++ microsite/sidebars.json | 1 + 2 files changed, 102 insertions(+) create mode 100644 docs/backend-system/architecture/07-feature-loaders.md diff --git a/docs/backend-system/architecture/07-feature-loaders.md b/docs/backend-system/architecture/07-feature-loaders.md new file mode 100644 index 0000000000..cf52a1feb3 --- /dev/null +++ b/docs/backend-system/architecture/07-feature-loaders.md @@ -0,0 +1,101 @@ +--- +id: feature-loaders +title: Backend Feature Loaders +sidebar_label: Feature Loaders +# prettier-ignore +description: Backend feature loaders +--- + +Backend feature loaders are used to programmatically select and install features in a Backstage backend. They can service a wide range of use cases, such as enabling or disabling features based on static configuration, dynamically load features at runtime, or conditionally load features based on the state of a system. + +Feature loaders are defined using the `createBackendFeatureLoader` function, exported by `@backstage/backend-plugin-api`. It accepts a `loader` function, as well as an optional `deps` object for declaring service dependencies. Unlike plugins and modules, feature loaders are limited to only depending on root-scoped services, but that still allows access to for example the [root config](../core-services/root-config.md) and [root logger](../core-services/root-logger.md) services. + +The `loader` function can be defined in many different ways, with the main requirement being that it returns a list of `BackendFeature`s in some form. A backend feature is the kind of object that you can pass to `backend.add(...)`, for example services factories, plugins, modules, or even other feature loaders. The `loader` function can be synchronous or asynchronous, and can be defined as a generator function to allow for more complex logic. + +## Examples + +The following are a few example of how feature loaders can be used: + +### Simple list of features + +A feature loader can simply return a list of features to be installed: + +```ts +export default createBackendFeatureLoader({ + loader() { + return [ + import('@backstage/plugin-search-backend/alpha'), + import('@backstage/plugin-search-backend-module-catalog/alpha'), + import('@backstage/plugin-search-backend-module-explore/alpha'), + import('@backstage/plugin-search-backend-module-techdocs/alpha'), + ]; + }, +}); +``` + +It can also encapsulate a collection of custom features: + +```ts +export default createBackendFeatureLoader({ + // Async loader is fine too + async loader() { + return [ + createBackendPlugin({ + ... + }), + createBackendModule({ + ... + }), + ] + }, +}); +``` + +### Conditional loading + +A feature loader can access root-scoped services, such as the config service. This allows for conditional loading of features based on configuration. It is often convenient to use a generator function for this purpose: + +```ts +export default createBackendFeatureLoader({ + deps: { + config: coreServices.rootConfig, + }, + // The `*` in front of the function name makes it a generator function + *loader({ config }) { + // Example of a custom config flag to enable search + if (config.getOptionalString('customFeatureToggle.search')) { + yield import('@backstage/plugin-search-backend/alpha'); + yield import('@backstage/plugin-search-backend-module-catalog/alpha'); + yield import('@backstage/plugin-search-backend-module-explore/alpha'); + yield import('@backstage/plugin-search-backend-module-techdocs/alpha'); + } + }, +}); +``` + +### Dynamic logic + +A feature loader can also be asynchronous, and for example fetch data from an external source to determine which features to load: + +```ts +export default createBackendFeatureLoader({ + // The `async *` in front of the function name makes it an async generator function. + async *loader() { + const localMetadata = await readMetadataFromDisk(); + + if (localMetadata.enableSearch) { + yield import('@backstage/plugin-search-backend/alpha'); + yield import('@backstage/plugin-search-backend-module-catalog/alpha'); + + const remoteMetadata = await fetchMetadata(); + + if (remoteMetadata.enableExplore) { + yield import('@backstage/plugin-search-backend-module-explore/alpha'); + } + if (remoteMetadata.enableTechDocs) { + yield import('@backstage/plugin-search-backend-module-techdocs/alpha'); + } + } + }, +}); +``` diff --git a/microsite/sidebars.json b/microsite/sidebars.json index d13ebc71c6..dafd3d1d5e 100644 --- a/microsite/sidebars.json +++ b/microsite/sidebars.json @@ -393,6 +393,7 @@ "backend-system/architecture/plugins", "backend-system/architecture/extension-points", "backend-system/architecture/modules", + "backend-system/architecture/feature-loaders", "backend-system/architecture/naming-patterns" ] }, From c7126d657bfddba371f18f2dc975cc7f73dbd5e6 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 6 Aug 2024 13:42:02 +0200 Subject: [PATCH 130/372] review fixes Signed-off-by: Patrik Oldsberg --- .../backend-app-api/src/wiring/BackendInitializer.ts | 11 +++++------ .../src/routing/describeParentCallSite.ts | 2 ++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/backend-app-api/src/wiring/BackendInitializer.ts b/packages/backend-app-api/src/wiring/BackendInitializer.ts index 4bfbf6244f..c0da9eda62 100644 --- a/packages/backend-app-api/src/wiring/BackendInitializer.ts +++ b/packages/backend-app-api/src/wiring/BackendInitializer.ts @@ -25,14 +25,14 @@ import { } from '@backstage/backend-plugin-api'; import { ServiceOrExtensionPoint } from './types'; // Direct internal import to avoid duplication -// eslint-disable-next-line @backstage/no-forbidden-package-imports +// eslint-disable-next-line @backstage/no-relative-monorepo-imports import type { InternalBackendFeature, InternalBackendFeatureLoader, InternalBackendRegistrations, -} from '@backstage/backend-plugin-api/src/wiring/types'; -// eslint-disable-next-line @backstage/no-forbidden-package-imports -import type { InternalServiceFactory } from '@backstage/backend-plugin-api/src/services/system/types'; +} from '../../../backend-plugin-api/src/wiring/types'; +// eslint-disable-next-line @backstage/no-relative-monorepo-imports +import type { InternalServiceFactory } from '../../../backend-plugin-api/src/services/system/types'; import { ForwardedError, ConflictError } from '@backstage/errors'; import { featureDiscoveryServiceRef } from '@backstage/backend-plugin-api/alpha'; import { DependencyGraph } from '../lib/DependencyGraph'; @@ -431,8 +431,7 @@ export class BackendInitializer { if (isBackendFeatureLoader(feature)) { newLoaders.push(feature); } else { - didAddServiceFactory = - didAddServiceFactory || isServiceFactory(feature); + didAddServiceFactory ||= isServiceFactory(feature); this.#addFeature(feature); } } diff --git a/packages/frontend-plugin-api/src/routing/describeParentCallSite.ts b/packages/frontend-plugin-api/src/routing/describeParentCallSite.ts index 72997e07db..ab5fc2f034 100644 --- a/packages/frontend-plugin-api/src/routing/describeParentCallSite.ts +++ b/packages/frontend-plugin-api/src/routing/describeParentCallSite.ts @@ -16,6 +16,8 @@ const MESSAGE_MARKER = 'eHgtF5hmbrXyiEvo'; +// NOTE: This function is also imported and used in backend code + /** * Internal helper that describes the location of the parent caller. * @internal From 6058a95955643828268d0eac55615d6ecf15cd5b Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 6 Aug 2024 14:13:23 +0200 Subject: [PATCH 131/372] backend-plugin-api: backwards compat for service ref multiton field Signed-off-by: Patrik Oldsberg --- packages/backend-plugin-api/api-report.md | 2 +- .../src/services/system/types.test.ts | 18 ++++++++++++++++++ .../src/services/system/types.ts | 4 ++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/packages/backend-plugin-api/api-report.md b/packages/backend-plugin-api/api-report.md index 99c7b1b9fc..16574ac94e 100644 --- a/packages/backend-plugin-api/api-report.md +++ b/packages/backend-plugin-api/api-report.md @@ -703,7 +703,7 @@ export type ServiceRef< > = { id: string; scope: TScope; - multiton: TInstances extends 'multiton' ? true : false; + multiton?: TInstances extends 'multiton' ? true : false; T: TService; $$type: '@backstage/ServiceRef'; }; diff --git a/packages/backend-plugin-api/src/services/system/types.test.ts b/packages/backend-plugin-api/src/services/system/types.test.ts index adf097761b..70d165fd8d 100644 --- a/packages/backend-plugin-api/src/services/system/types.test.ts +++ b/packages/backend-plugin-api/src/services/system/types.test.ts @@ -324,6 +324,24 @@ describe('createServiceFactory', () => { metaFactory(); }); + it('should support old service refs without a multiton field', () => { + const oldPluginDep = pluginDep as Omit; // Old refs don't have a multiton field + const metaFactory = createServiceFactory({ + service: ref, + deps: { + plugin: oldPluginDep, + }, + async factory({ plugin }) { + const plugin1: boolean = plugin; + // @ts-expect-error + const plugin2: number = plugin; + unused(plugin1, plugin2); + return 'x'; + }, + }); + expect(metaFactory).toEqual(expect.any(Function)); + }); + it('should only allow objects as options', () => { // @ts-expect-error const metaFactory = createServiceFactory((_opts: string) => ({ diff --git a/packages/backend-plugin-api/src/services/system/types.ts b/packages/backend-plugin-api/src/services/system/types.ts index 7cd18da4d2..a6f33d7941 100644 --- a/packages/backend-plugin-api/src/services/system/types.ts +++ b/packages/backend-plugin-api/src/services/system/types.ts @@ -39,7 +39,7 @@ export type ServiceRef< */ scope: TScope; - multiton: TInstances extends 'multiton' ? true : false; + multiton?: TInstances extends 'multiton' ? true : false; /** * Utility for getting the type of the service, using `typeof serviceRef.T`. @@ -189,7 +189,7 @@ type ServiceRefsToInstances< > = { [key in keyof T as T[key]['scope'] extends TScope ? key - : never]: T[key]['multiton'] extends true + : never]: T[key]['multiton'] extends true | undefined ? Array : T[key]['T']; }; From 13d564e44fe94cfb52415435bc36429a5bae7d8a Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 6 Aug 2024 14:21:28 +0200 Subject: [PATCH 132/372] backend-defaults: rename and export urlReaderFactoriesServiceRef Signed-off-by: Patrik Oldsberg --- packages/backend-defaults/api-report-urlReader.md | 8 ++++++++ .../src/entrypoints/urlReader/index.ts | 5 ++++- .../urlReader/urlReaderServiceFactory.ts | 15 +++++++-------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/packages/backend-defaults/api-report-urlReader.md b/packages/backend-defaults/api-report-urlReader.md index ad732101dd..f561c2cbf5 100644 --- a/packages/backend-defaults/api-report-urlReader.md +++ b/packages/backend-defaults/api-report-urlReader.md @@ -22,6 +22,7 @@ import { HarnessIntegration } from '@backstage/integration'; import { LoggerService } from '@backstage/backend-plugin-api'; import { Readable } from 'stream'; import { ServiceFactoryCompat } from '@backstage/backend-plugin-api'; +import { ServiceRef } from '@backstage/backend-plugin-api'; import { UrlReaderService } from '@backstage/backend-plugin-api'; import { UrlReaderServiceReadTreeOptions } from '@backstage/backend-plugin-api'; import { UrlReaderServiceReadTreeResponse } from '@backstage/backend-plugin-api'; @@ -413,6 +414,13 @@ export type ReadUrlResponseFactoryFromStreamOptions = { lastModifiedAt?: Date; }; +// @public +export const urlReaderFactoriesServiceRef: ServiceRef< + ReaderFactory, + 'plugin', + 'multiton' +>; + // @public export type UrlReaderPredicateTuple = { predicate: (url: URL) => boolean; diff --git a/packages/backend-defaults/src/entrypoints/urlReader/index.ts b/packages/backend-defaults/src/entrypoints/urlReader/index.ts index cf927ea031..05271966c9 100644 --- a/packages/backend-defaults/src/entrypoints/urlReader/index.ts +++ b/packages/backend-defaults/src/entrypoints/urlReader/index.ts @@ -15,4 +15,7 @@ */ export * from './lib'; -export { urlReaderServiceFactory } from './urlReaderServiceFactory'; +export { + urlReaderServiceFactory, + urlReaderFactoriesServiceRef, +} from './urlReaderServiceFactory'; diff --git a/packages/backend-defaults/src/entrypoints/urlReader/urlReaderServiceFactory.ts b/packages/backend-defaults/src/entrypoints/urlReader/urlReaderServiceFactory.ts index b5c22402ff..2639e99d83 100644 --- a/packages/backend-defaults/src/entrypoints/urlReader/urlReaderServiceFactory.ts +++ b/packages/backend-defaults/src/entrypoints/urlReader/urlReaderServiceFactory.ts @@ -30,7 +30,7 @@ import { * Creating a service factory implementation for a Custom URL Reader. * ```ts * createServiceFactory({ - * service: urlReaderProviderFactoriesServiceRef, + * service: urlReaderFactoriesServiceRef, * deps: {}, * async factory() { * return CustomUrlReader.factory; @@ -38,12 +38,11 @@ import { * }); * ``` */ -export const urlReaderProviderFactoriesServiceRef = - createServiceRef({ - id: 'core.urlReader.factories', - scope: 'plugin', - multiton: true, - }); +export const urlReaderFactoriesServiceRef = createServiceRef({ + id: 'core.urlReader.factories', + scope: 'plugin', + multiton: true, +}); /** * Reading content from external systems. @@ -59,7 +58,7 @@ export const urlReaderServiceFactory = createServiceFactory({ deps: { config: coreServices.rootConfig, logger: coreServices.logger, - factories: urlReaderProviderFactoriesServiceRef, + factories: urlReaderFactoriesServiceRef, }, async factory({ config, logger, factories }) { return UrlReaders.default({ From 60325c471bc7ffc757de0743b40e5fd884b8d655 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 6 Aug 2024 14:38:51 +0200 Subject: [PATCH 133/372] changesets: fix changeset spelling Signed-off-by: Patrik Oldsberg --- .changeset/thirty-adults-grab.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/thirty-adults-grab.md b/.changeset/thirty-adults-grab.md index 391e7a39bb..ed986a8289 100644 --- a/.changeset/thirty-adults-grab.md +++ b/.changeset/thirty-adults-grab.md @@ -3,4 +3,4 @@ '@backstage/plugin-catalog-node': patch --- -Explicit declare if the service ref accepts `single` ou `multiple` implementations. +Explicit declare if the service ref accepts `single` or `multiple` implementations. From 8f1500e118a75ae40c0fec1802d19a787dcf5fd5 Mon Sep 17 00:00:00 2001 From: Chris Langhout Date: Thu, 4 Jul 2024 11:16:40 +0200 Subject: [PATCH 134/372] fix: use parameterized query Signed-off-by: Chris Langhout --- .../src/entrypoints/database/connectors/postgres.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend-defaults/src/entrypoints/database/connectors/postgres.ts b/packages/backend-defaults/src/entrypoints/database/connectors/postgres.ts index 444bbc0d18..7d9d943fc7 100644 --- a/packages/backend-defaults/src/entrypoints/database/connectors/postgres.ts +++ b/packages/backend-defaults/src/entrypoints/database/connectors/postgres.ts @@ -52,7 +52,7 @@ export function createPgDatabaseClient( database.client.pool.on( 'createSuccess', async (_event: number, pgClient: Client) => { - await pgClient.query(`SET ROLE ${role}`); + await pgClient.query('SET ROLE $1', [role]); }, ); } From 81f930aeed19074adb914c59486b2519e52ec091 Mon Sep 17 00:00:00 2001 From: Chris Langhout Date: Thu, 4 Jul 2024 11:51:58 +0200 Subject: [PATCH 135/372] chore: add changeset Signed-off-by: Chris Langhout --- .changeset/sixty-kiwis-poke.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/sixty-kiwis-poke.md diff --git a/.changeset/sixty-kiwis-poke.md b/.changeset/sixty-kiwis-poke.md new file mode 100644 index 0000000000..d4380cbd88 --- /dev/null +++ b/.changeset/sixty-kiwis-poke.md @@ -0,0 +1,5 @@ +--- +'@backstage/backend-defaults': patch +--- + +use parameterized query to prevent chance of SQL-injection From ed83fcc3e7b94d0d955a093ed48a173ad4c9588a Mon Sep 17 00:00:00 2001 From: Chris Langhout Date: Tue, 6 Aug 2024 15:11:28 +0200 Subject: [PATCH 136/372] fix: use pg-format to allow dynamic identifier Signed-off-by: Chris Langhout --- .changeset/sixty-kiwis-poke.md | 2 +- packages/backend-defaults/package.json | 1 + .../src/entrypoints/database/connectors/postgres.ts | 4 +++- yarn.lock | 8 ++++++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.changeset/sixty-kiwis-poke.md b/.changeset/sixty-kiwis-poke.md index d4380cbd88..5281c6ade0 100644 --- a/.changeset/sixty-kiwis-poke.md +++ b/.changeset/sixty-kiwis-poke.md @@ -2,4 +2,4 @@ '@backstage/backend-defaults': patch --- -use parameterized query to prevent chance of SQL-injection +use formatted query to prevent chance of SQL-injection diff --git a/packages/backend-defaults/package.json b/packages/backend-defaults/package.json index 196c9b188a..3341c96c75 100644 --- a/packages/backend-defaults/package.json +++ b/packages/backend-defaults/package.json @@ -171,6 +171,7 @@ "path-to-regexp": "^6.2.1", "pg": "^8.11.3", "pg-connection-string": "^2.3.0", + "pg-format": "^1.0.4", "raw-body": "^2.4.1", "selfsigned": "^2.0.0", "stoppable": "^1.1.0", diff --git a/packages/backend-defaults/src/entrypoints/database/connectors/postgres.ts b/packages/backend-defaults/src/entrypoints/database/connectors/postgres.ts index 7d9d943fc7..afaa946c05 100644 --- a/packages/backend-defaults/src/entrypoints/database/connectors/postgres.ts +++ b/packages/backend-defaults/src/entrypoints/database/connectors/postgres.ts @@ -29,6 +29,7 @@ import { Connector } from '../types'; import defaultNameOverride from './defaultNameOverride'; import defaultSchemaOverride from './defaultSchemaOverride'; import { mergeDatabaseConfig } from './mergeDatabaseConfig'; +import { format } from 'pg-format'; // Limits the number of concurrent DDL operations to 1 const ddlLimiter = limiterFactory(1); @@ -52,7 +53,8 @@ export function createPgDatabaseClient( database.client.pool.on( 'createSuccess', async (_event: number, pgClient: Client) => { - await pgClient.query('SET ROLE $1', [role]); + const query = format('SET ROLE %I', role); + await pgClient.query(query); }, ); } diff --git a/yarn.lock b/yarn.lock index c14251269c..75552e383b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3683,6 +3683,7 @@ __metadata: path-to-regexp: ^6.2.1 pg: ^8.11.3 pg-connection-string: ^2.3.0 + pg-format: ^1.0.4 raw-body: ^2.4.1 selfsigned: ^2.0.0 stoppable: ^1.1.0 @@ -36955,6 +36956,13 @@ __metadata: languageName: node linkType: hard +"pg-format@npm:^1.0.4": + version: 1.0.4 + resolution: "pg-format@npm:1.0.4" + checksum: 159b43ad57d2f963f1072def86080dd2a6dd42c1a86046e388d47b491e00afe795139520eb01c8dffc43ac0243c77b3c4c5882d0ec5f488bb3281f17458b1b3d + languageName: node + linkType: hard + "pg-int8@npm:1.0.1": version: 1.0.1 resolution: "pg-int8@npm:1.0.1" From 120319d2b573cd2e165573573c71fd8c706af1e1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 6 Aug 2024 13:15:32 +0000 Subject: [PATCH 137/372] Version Packages (next) --- .changeset/pre.json | 39 + docs/releases/v1.30.0-next.3-changelog.md | 2199 +++++++++++++++++ package.json | 2 +- packages/app-defaults/CHANGELOG.md | 11 + packages/app-defaults/package.json | 2 +- packages/app-next-example-plugin/CHANGELOG.md | 8 + packages/app-next-example-plugin/package.json | 2 +- packages/app-next/CHANGELOG.md | 43 + packages/app-next/package.json | 2 +- packages/app/CHANGELOG.md | 41 + packages/app/package.json | 2 +- packages/backend-app-api/CHANGELOG.md | 21 + packages/backend-app-api/package.json | 2 +- packages/backend-common/CHANGELOG.md | 17 + packages/backend-common/package.json | 2 +- packages/backend-defaults/CHANGELOG.md | 25 + packages/backend-defaults/package.json | 2 +- .../CHANGELOG.md | 26 + .../package.json | 2 +- packages/backend-legacy/CHANGELOG.md | 41 + packages/backend-legacy/package.json | 2 +- packages/backend-openapi-utils/CHANGELOG.md | 8 + packages/backend-openapi-utils/package.json | 2 +- packages/backend-plugin-api/CHANGELOG.md | 94 + packages/backend-plugin-api/package.json | 2 +- packages/backend-tasks/CHANGELOG.md | 12 + packages/backend-tasks/package.json | 2 +- packages/backend-test-utils/CHANGELOG.md | 16 + packages/backend-test-utils/package.json | 2 +- packages/backend/CHANGELOG.md | 37 + packages/backend/package.json | 2 +- packages/cli/CHANGELOG.md | 17 + packages/cli/package.json | 2 +- packages/config-loader/CHANGELOG.md | 11 + packages/config-loader/package.json | 2 +- packages/core-compat-api/CHANGELOG.md | 11 + packages/core-compat-api/package.json | 2 +- packages/create-app/CHANGELOG.md | 8 + packages/create-app/package.json | 2 +- packages/dev-utils/CHANGELOG.md | 14 + packages/dev-utils/package.json | 2 +- packages/e2e-test/CHANGELOG.md | 9 + packages/e2e-test/package.json | 2 +- packages/frontend-app-api/CHANGELOG.md | 16 + packages/frontend-app-api/package.json | 2 +- packages/frontend-plugin-api/CHANGELOG.md | 17 + packages/frontend-plugin-api/package.json | 2 +- packages/frontend-test-utils/CHANGELOG.md | 13 + packages/frontend-test-utils/package.json | 2 +- packages/repo-tools/CHANGELOG.md | 12 + packages/repo-tools/package.json | 2 +- .../techdocs-cli-embedded-app/CHANGELOG.md | 19 + .../techdocs-cli-embedded-app/package.json | 2 +- packages/techdocs-cli/CHANGELOG.md | 11 + packages/techdocs-cli/package.json | 2 +- packages/test-utils/CHANGELOG.md | 13 + packages/test-utils/package.json | 2 +- plugins/api-docs/CHANGELOG.md | 16 + plugins/api-docs/package.json | 2 +- plugins/app-backend/CHANGELOG.md | 15 + plugins/app-backend/package.json | 2 +- plugins/app-node/CHANGELOG.md | 8 + plugins/app-node/package.json | 2 +- plugins/app-visualizer/CHANGELOG.md | 10 + plugins/app-visualizer/package.json | 2 +- .../CHANGELOG.md | 8 + .../package.json | 2 +- .../CHANGELOG.md | 12 + .../package.json | 2 +- .../CHANGELOG.md | 10 + .../package.json | 2 +- .../CHANGELOG.md | 8 + .../package.json | 2 +- .../CHANGELOG.md | 11 + .../package.json | 2 +- .../CHANGELOG.md | 10 + .../package.json | 2 +- .../CHANGELOG.md | 8 + .../package.json | 2 +- .../CHANGELOG.md | 8 + .../package.json | 2 +- .../CHANGELOG.md | 8 + .../package.json | 2 +- .../CHANGELOG.md | 11 + .../package.json | 2 +- .../CHANGELOG.md | 9 + .../package.json | 2 +- .../CHANGELOG.md | 8 + .../package.json | 2 +- .../CHANGELOG.md | 9 + .../package.json | 2 +- .../CHANGELOG.md | 10 + .../package.json | 2 +- .../CHANGELOG.md | 8 + .../package.json | 2 +- .../CHANGELOG.md | 8 + .../package.json | 2 +- .../CHANGELOG.md | 9 + .../package.json | 2 +- .../CHANGELOG.md | 9 + .../package.json | 2 +- plugins/auth-backend/CHANGELOG.md | 31 + plugins/auth-backend/package.json | 2 +- plugins/auth-node/CHANGELOG.md | 18 + plugins/auth-node/package.json | 2 +- plugins/bitbucket-cloud-common/CHANGELOG.md | 8 + plugins/bitbucket-cloud-common/package.json | 2 +- .../catalog-backend-module-aws/CHANGELOG.md | 17 + .../catalog-backend-module-aws/package.json | 2 +- .../catalog-backend-module-azure/CHANGELOG.md | 14 + .../catalog-backend-module-azure/package.json | 2 +- .../CHANGELOG.md | 13 + .../package.json | 2 +- .../CHANGELOG.md | 17 + .../package.json | 2 +- .../CHANGELOG.md | 15 + .../package.json | 2 +- .../catalog-backend-module-gcp/CHANGELOG.md | 13 + .../catalog-backend-module-gcp/package.json | 2 +- .../CHANGELOG.md | 14 + .../package.json | 2 +- .../CHANGELOG.md | 13 + .../package.json | 2 +- .../CHANGELOG.md | 18 + .../package.json | 2 +- .../CHANGELOG.md | 11 + .../package.json | 2 +- .../CHANGELOG.md | 16 + .../package.json | 2 +- .../CHANGELOG.md | 16 + .../package.json | 2 +- .../catalog-backend-module-ldap/CHANGELOG.md | 14 + .../catalog-backend-module-ldap/package.json | 2 +- .../catalog-backend-module-logs/CHANGELOG.md | 9 + .../catalog-backend-module-logs/package.json | 2 +- .../CHANGELOG.md | 14 + .../package.json | 2 +- .../CHANGELOG.md | 15 + .../package.json | 2 +- .../CHANGELOG.md | 15 + .../package.json | 2 +- .../CHANGELOG.md | 11 + .../package.json | 2 +- .../CHANGELOG.md | 14 + .../package.json | 2 +- plugins/catalog-backend/CHANGELOG.md | 23 + plugins/catalog-backend/package.json | 2 +- plugins/catalog-common/CHANGELOG.md | 9 + plugins/catalog-common/package.json | 2 +- plugins/catalog-graph/CHANGELOG.md | 14 + plugins/catalog-graph/package.json | 2 +- plugins/catalog-import/CHANGELOG.md | 18 + plugins/catalog-import/package.json | 2 +- plugins/catalog-node/CHANGELOG.md | 15 + plugins/catalog-node/package.json | 2 +- plugins/catalog-react/CHANGELOG.md | 19 + plugins/catalog-react/package.json | 2 +- .../CHANGELOG.md | 7 + .../package.json | 2 +- plugins/catalog/CHANGELOG.md | 26 + plugins/catalog/package.json | 2 +- plugins/devtools-backend/CHANGELOG.md | 17 + plugins/devtools-backend/package.json | 2 +- plugins/devtools-common/CHANGELOG.md | 8 + plugins/devtools-common/package.json | 2 +- plugins/devtools/CHANGELOG.md | 13 + plugins/devtools/package.json | 2 +- .../CHANGELOG.md | 12 + .../package.json | 2 +- .../events-backend-module-azure/CHANGELOG.md | 8 + .../events-backend-module-azure/package.json | 2 +- .../CHANGELOG.md | 8 + .../package.json | 2 +- .../events-backend-module-gerrit/CHANGELOG.md | 8 + .../events-backend-module-gerrit/package.json | 2 +- .../events-backend-module-github/CHANGELOG.md | 9 + .../events-backend-module-github/package.json | 2 +- .../events-backend-module-gitlab/CHANGELOG.md | 9 + .../events-backend-module-gitlab/package.json | 2 +- .../events-backend-test-utils/CHANGELOG.md | 7 + .../events-backend-test-utils/package.json | 2 +- plugins/events-backend/CHANGELOG.md | 10 + plugins/events-backend/package.json | 2 +- plugins/events-node/CHANGELOG.md | 7 + plugins/events-node/package.json | 2 +- .../example-todo-list-backend/CHANGELOG.md | 10 + .../example-todo-list-backend/package.json | 2 +- plugins/example-todo-list-common/CHANGELOG.md | 7 + plugins/example-todo-list-common/package.json | 2 +- plugins/home/CHANGELOG.md | 17 + plugins/home/package.json | 2 +- plugins/kubernetes-backend/CHANGELOG.md | 23 + plugins/kubernetes-backend/package.json | 2 +- plugins/kubernetes-cluster/CHANGELOG.md | 12 + plugins/kubernetes-cluster/package.json | 2 +- plugins/kubernetes-common/CHANGELOG.md | 9 + plugins/kubernetes-common/package.json | 2 +- plugins/kubernetes-node/CHANGELOG.md | 11 + plugins/kubernetes-node/package.json | 2 +- plugins/kubernetes-react/CHANGELOG.md | 12 + plugins/kubernetes-react/package.json | 2 +- plugins/kubernetes/CHANGELOG.md | 14 + plugins/kubernetes/package.json | 2 +- .../CHANGELOG.md | 16 + .../package.json | 2 +- plugins/notifications-backend/CHANGELOG.md | 18 + plugins/notifications-backend/package.json | 2 +- plugins/notifications-node/CHANGELOG.md | 13 + plugins/notifications-node/package.json | 2 +- plugins/org-react/CHANGELOG.md | 11 + plugins/org-react/package.json | 2 +- plugins/org/CHANGELOG.md | 13 + plugins/org/package.json | 2 +- .../CHANGELOG.md | 10 + .../package.json | 2 +- plugins/permission-backend/CHANGELOG.md | 14 + plugins/permission-backend/package.json | 2 +- plugins/permission-common/CHANGELOG.md | 11 + plugins/permission-common/package.json | 2 +- plugins/permission-node/CHANGELOG.md | 17 + plugins/permission-node/package.json | 2 +- plugins/permission-react/CHANGELOG.md | 9 + plugins/permission-react/package.json | 2 +- plugins/proxy-backend/CHANGELOG.md | 11 + plugins/proxy-backend/package.json | 2 +- .../CHANGELOG.md | 11 + .../package.json | 2 +- .../CHANGELOG.md | 14 + .../package.json | 2 +- .../CHANGELOG.md | 12 + .../package.json | 2 +- .../CHANGELOG.md | 14 + .../package.json | 2 +- .../CHANGELOG.md | 13 + .../package.json | 2 +- .../CHANGELOG.md | 13 + .../package.json | 2 +- .../CHANGELOG.md | 11 + .../package.json | 2 +- .../CHANGELOG.md | 12 + .../package.json | 2 +- .../CHANGELOG.md | 12 + .../package.json | 2 +- .../CHANGELOG.md | 12 + .../package.json | 2 +- .../CHANGELOG.md | 12 + .../package.json | 2 +- .../CHANGELOG.md | 11 + .../package.json | 2 +- .../CHANGELOG.md | 13 + .../package.json | 2 +- .../CHANGELOG.md | 12 + .../package.json | 2 +- .../CHANGELOG.md | 10 + .../package.json | 2 +- plugins/scaffolder-backend/CHANGELOG.md | 32 + plugins/scaffolder-backend/package.json | 2 +- plugins/scaffolder-common/CHANGELOG.md | 9 + plugins/scaffolder-common/package.json | 2 +- .../scaffolder-node-test-utils/CHANGELOG.md | 10 + .../scaffolder-node-test-utils/package.json | 2 +- plugins/scaffolder-node/CHANGELOG.md | 14 + plugins/scaffolder-node/package.json | 2 +- plugins/scaffolder-react/CHANGELOG.md | 18 + plugins/scaffolder-react/package.json | 2 +- plugins/scaffolder/CHANGELOG.md | 25 + plugins/scaffolder/package.json | 2 +- .../CHANGELOG.md | 18 + .../package.json | 2 +- .../CHANGELOG.md | 12 + .../package.json | 2 +- .../CHANGELOG.md | 13 + .../package.json | 2 +- plugins/search-backend-module-pg/CHANGELOG.md | 11 + plugins/search-backend-module-pg/package.json | 2 +- .../CHANGELOG.md | 13 + .../package.json | 2 +- .../CHANGELOG.md | 19 + .../package.json | 2 +- plugins/search-backend-node/CHANGELOG.md | 15 + plugins/search-backend-node/package.json | 2 +- plugins/search-backend/CHANGELOG.md | 18 + plugins/search-backend/package.json | 2 +- plugins/search-common/CHANGELOG.md | 9 + plugins/search-common/package.json | 2 +- plugins/search-react/CHANGELOG.md | 14 + plugins/search-react/package.json | 2 +- plugins/search/CHANGELOG.md | 17 + plugins/search/package.json | 2 +- plugins/signals-backend/CHANGELOG.md | 14 + plugins/signals-backend/package.json | 2 +- plugins/signals-node/CHANGELOG.md | 12 + plugins/signals-node/package.json | 2 +- .../techdocs-addons-test-utils/CHANGELOG.md | 15 + .../techdocs-addons-test-utils/package.json | 2 +- plugins/techdocs-backend/CHANGELOG.md | 19 + plugins/techdocs-backend/package.json | 2 +- plugins/techdocs-node/CHANGELOG.md | 15 + plugins/techdocs-node/package.json | 2 +- plugins/techdocs/CHANGELOG.md | 24 + plugins/techdocs/package.json | 2 +- plugins/user-settings-backend/CHANGELOG.md | 14 + plugins/user-settings-backend/package.json | 2 +- plugins/user-settings/CHANGELOG.md | 17 + plugins/user-settings/package.json | 2 +- 305 files changed, 4584 insertions(+), 152 deletions(-) create mode 100644 docs/releases/v1.30.0-next.3-changelog.md diff --git a/.changeset/pre.json b/.changeset/pre.json index 8b33f2b80b..4699170212 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -190,41 +190,62 @@ "@backstage/plugin-techdocs-common": "0.0.0" }, "changesets": [ + "angry-dolphins-camp", "big-eagles-grab", "blue-pumas-cheer", "breezy-jeans-tie", + "breezy-rings-fly", + "bright-donkeys-buy", "bright-trainers-brake", + "calm-crabs-drop", + "chilly-days-peel", "chilly-trains-sleep", + "clever-pans-brake", "cool-insects-remember", "cool-schools-vanish", "create-app-1722413762", "cuddly-zebras-crash", + "curvy-pillows-joke", + "cyan-shrimps-push", "dry-squids-tap", "dull-ghosts-double", "early-trees-dance", "eighty-emus-leave", + "eighty-jokes-deny", "eighty-mirrors-flow", + "fair-hairs-mix", + "fair-pumas-hang", + "fast-bulldogs-relax", "few-wasps-hug", "flat-plums-grow", "forty-ties-agree", "forty-ties-disagree", + "friendly-cherries-applaud", + "friendly-chicken-cry", "friendly-feet-refuse", "gentle-dryers-smile", "good-steaks-report", "green-planets-reflect", "grumpy-owls-suffer", + "healthy-timers-divide", "heavy-numbers-love", + "hip-fishes-guess", "hip-hairs-exist", + "khaki-lamps-peel", "late-games-protect", "light-pianos-exercise", "little-bulldogs-guess", "little-suns-fly", "mean-apricots-perform", + "metal-planes-nail", + "metal-rice-call", + "mighty-apricots-taste", "mighty-dolls-retire", "mighty-geckos-kiss", "modern-parrots-protect", "neat-bears-divide", "neat-gifts-join", + "neat-socks-cheer", "new-scissors-try", "nice-peas-retire", "nine-cherries-decide", @@ -236,16 +257,26 @@ "orange-gifts-protect", "pink-gorillas-brake", "plenty-tools-exist", + "purple-carrots-crash", "quick-roses-juggle", "rare-foxes-compete", "red-radios-promise", + "renovate-147ac48", "renovate-f04beb1", "rich-mugs-dress", "selfish-bees-think", "seven-eggs-admire", "shaggy-dodos-applaud", + "shy-games-poke", + "shy-waves-share", + "silly-candles-sin", + "silly-cycles-tan", "six-rats-kick", + "slow-ducks-rush", + "slow-ligers-drum", "slow-toes-jog", + "small-bottles-cough", + "small-ears-poke", "small-spoons-shout", "smooth-countries-relate", "soft-gorillas-refuse", @@ -258,15 +289,23 @@ "sweet-oranges-buy", "swift-kings-sparkle", "tall-snakes-fix", + "tasty-ads-rescue", "thick-hotels-know", + "thirty-adults-grab", "thirty-paws-hope", "tiny-oranges-pretend", + "tough-goats-hang", "tough-lies-repair", + "tricky-ducks-juggle", "two-emus-work", "violet-jokes-wave", + "warm-monkeys-marry", "wicked-bobcats-teach", "wild-eggs-exist", + "wise-spiders-walk", "witty-bears-behave", + "witty-geese-battle", + "witty-timers-marry", "young-games-visit", "young-peaches-shake" ] diff --git a/docs/releases/v1.30.0-next.3-changelog.md b/docs/releases/v1.30.0-next.3-changelog.md new file mode 100644 index 0000000000..4fa86da821 --- /dev/null +++ b/docs/releases/v1.30.0-next.3-changelog.md @@ -0,0 +1,2199 @@ +# Release v1.30.0-next.3 + +Upgrade Helper: [https://backstage.github.io/upgrade-helper/?to=1.30.0-next.3](https://backstage.github.io/upgrade-helper/?to=1.30.0-next.3) + +## @backstage/backend-plugin-api@0.8.0-next.2 + +### Minor Changes + +- 7c5f3b0: The `createServiceRef` function now accepts a new boolean `multiple` option. The `multiple` option defaults to `false` and when set to `true`, it enables that multiple implementation are installed for the created service ref. + + We're looking for ways to make it possible to augment services without the need to replace the entire service. + + Typical example of that being the ability to install support for additional targets for the `UrlReader` service without replacing the service itself. This achieves that by allowing us to define services that can have multiple simultaneous implementation, allowing the `UrlReader` implementation to depend on such a service to collect all possible implementation of support for external targets: + + ```diff + // @backstage/backend-defaults + + + export const urlReaderFactoriesServiceRef = createServiceRef({ + + id: 'core.urlReader.factories', + + scope: 'plugin', + + multiton: true, + + }); + + ... + + export const urlReaderServiceFactory = createServiceFactory({ + service: coreServices.urlReader, + deps: { + config: coreServices.rootConfig, + logger: coreServices.logger, + + factories: urlReaderFactoriesServiceRef, + }, + - async factory({ config, logger }) { + + async factory({ config, logger, factories }) { + return UrlReaders.default({ + config, + logger, + + factories, + }); + }, + }); + ``` + + With that, you can then add more custom `UrlReader` factories by installing more implementations of the `urlReaderFactoriesServiceRef` in your backend instance. Something like: + + ```ts + // packages/backend/index.ts + import { createServiceFactory } from '@backstage/backend-plugin-api'; + import { urlReaderFactoriesServiceRef } from '@backstage/backend-defaults'; + ... + + backend.add(createServiceFactory({ + service: urlReaderFactoriesServiceRef, + deps: {}, + async factory() { + return CustomUrlReader.factory; + }, + })); + + ... + + ``` + +### Patch Changes + +- 6061061: Added `createBackendFeatureLoader`, which can be used to create an installable backend feature that can in turn load in additional backend features in a dynamic way. + +- ba9abf4: The `SchedulerService` now allows tasks with `frequency: { trigger: 'manual' }`. This means that the task will not be scheduled, but rather run only when manually triggered with `SchedulerService.triggerTask`. + +- 8b13183: Added `createBackendFeatureLoader`, which can be used to programmatically select and install backend features. + + A feature loader can return an list of features to be installed, for example in the form on an `Array` or other for of iterable, which allows for the loader to be defined as a generator function. Both synchronous and asynchronous loaders are supported. + + Additionally, a loader can depend on services in its implementation, with the restriction that it can only depend on root-scoped services, and it may not override services that have already been instantiated. + + ```ts + const searchLoader = createBackendFeatureLoader({ + deps: { + config: coreServices.rootConfig, + }, + *loader({ config }) { + // Example of a custom config flag to enable search + if (config.getOptionalString('customFeatureToggle.search')) { + yield import('@backstage/plugin-search-backend/alpha'); + yield import('@backstage/plugin-search-backend-module-catalog/alpha'); + yield import('@backstage/plugin-search-backend-module-explore/alpha'); + yield import('@backstage/plugin-search-backend-module-techdocs/alpha'); + } + }, + }); + ``` + +- Updated dependencies + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/cli-common@0.1.14 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + +## @backstage/frontend-plugin-api@0.7.0-next.2 + +### Minor Changes + +- 72754db: **BREAKING**: All types of route refs are always considered optional by `useRouteRef`, which means the caller must always handle a potential `undefined` return value. Related to this change, the `optional` option from `createExternalRouteRef` has been removed, since it is no longer necessary. + + This is released as an immediate breaking change as we expect the usage of the new route refs to be extremely low or zero, since plugins that support the new system will still use route refs and `useRouteRef` from `@backstage/core-plugin-api` in combination with `convertLegacyRouteRef` from `@backstage/core-compat-api`. + +### Patch Changes + +- 210d066: Added support for using the `params` in other properties of the `createExtensionBlueprint` options by providing a callback. +- Updated dependencies + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/types@1.1.1 + - @backstage/version-bridge@1.0.8 + +## @backstage/plugin-auth-node@0.5.0-next.2 + +### Minor Changes + +- 579afd0: **BREAKING**: Sign-in resolvers configured via `.signIn.resolvers` now take precedence over sign-in resolvers passed to `signInResolver` option of `createOAuthProviderFactory`. This effectively makes sign-in resolvers passed via the `signInResolver` the default one, which you can then override through configuration. + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + +## @backstage/plugin-catalog@1.22.0-next.2 + +### Minor Changes + +- 6925dcb: Introduces the HasSubdomainsCard component that displays the subdomains of a given domain + +### Patch Changes + +- 604a504: The entity relation cards available for the new frontend system via `/alpha` now have more accurate and granular default filters. +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-compat-api@0.2.8-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/plugin-search-react@1.7.14-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/plugin-permission-react@0.4.25-next.1 + - @backstage/plugin-scaffolder-common@1.5.5-next.1 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/errors@1.2.4 + - @backstage/integration-react@1.1.30-next.0 + - @backstage/types@1.1.1 + +## @backstage/plugin-scaffolder@1.24.0-next.2 + +### Minor Changes + +- 3fca643: Added field extension `RepoBranchPicker` that supports autocompletion for Bitbucket + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-scaffolder-react@1.11.0-next.2 + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-compat-api@0.2.8-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/plugin-permission-react@0.4.25-next.1 + - @backstage/plugin-scaffolder-common@1.5.5-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/errors@1.2.4 + - @backstage/integration-react@1.1.30-next.0 + - @backstage/types@1.1.1 + +## @backstage/app-defaults@1.5.10-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-permission-react@0.4.25-next.1 + - @backstage/core-app-api@1.14.2-next.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/theme@0.5.6 + +## @backstage/backend-app-api@0.8.1-next.2 + +### Patch Changes + +- 8b13183: Added support for the latest version of `BackendFeature`s from `@backstage/backend-plugin-api`, including feature loaders. +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- 7c5f3b0: Update the `ServiceRegister` implementation to enable registering multiple service implementations for a given service ref. +- 80a0737: Added configuration for the `packages` options to config schema +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/config-loader@1.9.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-permission-node@0.8.1-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/cli-node@0.2.7 + - @backstage/cli-common@0.1.14 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + +## @backstage/backend-common@0.23.4-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/config-loader@1.9.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/integration-aws-node@0.1.12 + - @backstage/backend-dev-utils@0.1.4 + - @backstage/cli-common@0.1.14 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + +## @backstage/backend-defaults@0.4.2-next.2 + +### Patch Changes + +- 0d16b52: Add access restrictions to the JWKS external access method config schema +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- ba9abf4: The `SchedulerService` now allows tasks with `frequency: { trigger: 'manual' }`. This means that the task will not be scheduled, but rather run only when manually triggered with `SchedulerService.triggerTask`. +- 7c5f3b0: Update the `UrlReader` service to depends on multiple instances of `UrlReaderFactoryProvider` service. +- 1d5f298: Avoid excessive numbers of error listeners on cache clients +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-app-api@0.8.1-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/config-loader@1.9.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-permission-node@0.8.1-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/integration-aws-node@0.1.12 + - @backstage/backend-dev-utils@0.1.4 + - @backstage/cli-common@0.1.14 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + +## @backstage/backend-dynamic-feature-service@0.2.16-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-app-api@0.8.1-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-catalog-backend@1.24.1-next.2 + - @backstage/config-loader@1.9.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-permission-node@0.8.1-next.2 + - @backstage/plugin-search-backend-node@1.2.28-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-app-node@0.1.23-next.2 + - @backstage/plugin-events-backend@0.3.10-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/cli-node@0.2.7 + - @backstage/cli-common@0.1.14 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + +## @backstage/backend-openapi-utils@0.1.16-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/errors@1.2.4 + +## @backstage/backend-tasks@0.5.28-next.2 + +### Patch Changes + +- ba9abf4: The `PluginTaskScheduler` now allows tasks with `frequency: { trigger: 'manual' }`. This means that the task will not be scheduled, but rather run only when manually triggered with `PluginTaskScheduler.triggerTask`. +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + +## @backstage/backend-test-utils@0.4.5-next.2 + +### Patch Changes + +- 8b13183: Internal updates to support latest version of `BackendFeauture`s from `@backstage/backend-plugin-api`. +- 7c5f3b0: Update the `ServiceFactoryTester` to be able to test services that enables multi implementation installation. +- Updated dependencies + - @backstage/backend-defaults@0.4.2-next.2 + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-app-api@0.8.1-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + +## @backstage/cli@0.27.0-next.3 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/config-loader@1.9.0-next.2 + - @backstage/cli-node@0.2.7 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-model@1.5.0 + - @backstage/cli-common@0.1.14 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/eslint-plugin@0.1.8 + - @backstage/release-manifests@0.0.11 + - @backstage/types@1.1.1 + +## @backstage/config-loader@1.9.0-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/cli-common@0.1.14 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + +## @backstage/core-compat-api@0.2.8-next.2 + +### Patch Changes + +- 72754db: Updated usage of `useRouteRef`, which can now always return `undefined`. +- 16cf96c: Both `compatWrapper` and `convertLegacyRouteRef` now support converting from the new system to the old. +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-plugin-api@1.9.3 + - @backstage/version-bridge@1.0.8 + +## @backstage/create-app@0.5.18-next.3 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/cli-common@0.1.14 + +## @backstage/dev-utils@1.0.37-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/app-defaults@1.5.10-next.2 + - @backstage/catalog-model@1.5.0 + - @backstage/core-app-api@1.14.2-next.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/integration-react@1.1.30-next.0 + - @backstage/theme@0.5.6 + +## @backstage/frontend-app-api@0.7.5-next.2 + +### Patch Changes + +- 72754db: Updated usage of `useRouteRef`, which can now always return `undefined`. +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/config@1.2.0 + - @backstage/core-app-api@1.14.2-next.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/errors@1.2.4 + - @backstage/theme@0.5.6 + - @backstage/types@1.1.1 + - @backstage/version-bridge@1.0.8 + +## @backstage/frontend-test-utils@0.1.12-next.2 + +### Patch Changes + +- 8209449: Added new APIs for testing extensions +- 72754db: Updated usage of `useRouteRef`, which can now always return `undefined`. +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/frontend-app-api@0.7.5-next.2 + - @backstage/test-utils@1.5.10-next.2 + - @backstage/config@1.2.0 + - @backstage/types@1.1.1 + +## @backstage/repo-tools@0.9.5-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/config-loader@1.9.0-next.2 + - @backstage/cli-node@0.2.7 + - @backstage/catalog-model@1.5.0 + - @backstage/cli-common@0.1.14 + - @backstage/errors@1.2.4 + +## @techdocs/cli@1.8.17-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-defaults@0.4.2-next.2 + - @backstage/plugin-techdocs-node@1.12.9-next.2 + - @backstage/catalog-model@1.5.0 + - @backstage/cli-common@0.1.14 + - @backstage/config@1.2.0 + +## @backstage/test-utils@1.5.10-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/plugin-permission-react@0.4.25-next.1 + - @backstage/config@1.2.0 + - @backstage/core-app-api@1.14.2-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/theme@0.5.6 + - @backstage/types@1.1.1 + +## @backstage/plugin-api-docs@0.11.8-next.2 + +### Patch Changes + +- 4b6d2cb: Updated dependency `@graphiql/react` to `^0.23.0`. +- Updated dependencies + - @backstage/plugin-catalog@1.22.0-next.2 + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-compat-api@0.2.8-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/plugin-permission-react@0.4.25-next.1 + - @backstage/catalog-model@1.5.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + +## @backstage/plugin-app-backend@0.3.72-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/config-loader@1.9.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-app-node@0.1.23-next.2 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + +## @backstage/plugin-app-node@0.1.23-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/config-loader@1.9.0-next.2 + +## @backstage/plugin-app-visualizer@0.1.9-next.2 + +### Patch Changes + +- 72754db: Updated usage of `useRouteRef`, which can now always return `undefined`. +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + +## @backstage/plugin-auth-backend@0.22.10-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-backend-module-cloudflare-access-provider@0.1.6-next.2 + - @backstage/plugin-auth-backend-module-microsoft-provider@0.1.18-next.2 + - @backstage/plugin-auth-backend-module-aws-alb-provider@0.1.15-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-auth-backend-module-atlassian-provider@0.2.4-next.2 + - @backstage/plugin-auth-backend-module-bitbucket-provider@0.1.6-next.2 + - @backstage/plugin-auth-backend-module-github-provider@0.1.20-next.2 + - @backstage/plugin-auth-backend-module-gitlab-provider@0.1.20-next.2 + - @backstage/plugin-auth-backend-module-oauth2-provider@0.2.4-next.2 + - @backstage/plugin-auth-backend-module-oidc-provider@0.2.4-next.2 + - @backstage/plugin-auth-backend-module-okta-provider@0.0.16-next.2 + - @backstage/plugin-auth-backend-module-onelogin-provider@0.1.4-next.2 + - @backstage/plugin-auth-backend-module-azure-easyauth-provider@0.1.6-next.2 + - @backstage/plugin-auth-backend-module-gcp-iap-provider@0.2.18-next.2 + - @backstage/plugin-auth-backend-module-google-provider@0.1.20-next.2 + - @backstage/plugin-auth-backend-module-oauth2-proxy-provider@0.1.16-next.2 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + +## @backstage/plugin-auth-backend-module-atlassian-provider@0.2.4-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + +## @backstage/plugin-auth-backend-module-aws-alb-provider@0.1.15-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-auth-backend@0.22.10-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/errors@1.2.4 + +## @backstage/plugin-auth-backend-module-azure-easyauth-provider@0.1.6-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/catalog-model@1.5.0 + - @backstage/errors@1.2.4 + +## @backstage/plugin-auth-backend-module-bitbucket-provider@0.1.6-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + +## @backstage/plugin-auth-backend-module-cloudflare-access-provider@0.1.6-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + +## @backstage/plugin-auth-backend-module-gcp-iap-provider@0.2.18-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + +## @backstage/plugin-auth-backend-module-github-provider@0.1.20-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + +## @backstage/plugin-auth-backend-module-gitlab-provider@0.1.20-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + +## @backstage/plugin-auth-backend-module-google-provider@0.1.20-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + +## @backstage/plugin-auth-backend-module-guest-provider@0.1.9-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/catalog-model@1.5.0 + - @backstage/errors@1.2.4 + +## @backstage/plugin-auth-backend-module-microsoft-provider@0.1.18-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + +## @backstage/plugin-auth-backend-module-oauth2-provider@0.2.4-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + +## @backstage/plugin-auth-backend-module-oauth2-proxy-provider@0.1.16-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/errors@1.2.4 + +## @backstage/plugin-auth-backend-module-oidc-provider@0.2.4-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-auth-backend@0.22.10-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + +## @backstage/plugin-auth-backend-module-okta-provider@0.0.16-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + +## @backstage/plugin-auth-backend-module-onelogin-provider@0.1.4-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + +## @backstage/plugin-auth-backend-module-pinniped-provider@0.1.17-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/config@1.2.0 + +## @backstage/plugin-auth-backend-module-vmware-cloud-provider@0.2.4-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/catalog-model@1.5.0 + +## @backstage/plugin-bitbucket-cloud-common@0.2.22-next.1 + +### Patch Changes + +- 3fca643: Added method `listBranchesByRepository` to `BitbucketCloudClient` +- Updated dependencies + - @backstage/integration@1.14.0-next.0 + +## @backstage/plugin-catalog-backend@1.24.1-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-permission-node@0.8.1-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/backend-openapi-utils@0.1.16-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/plugin-search-backend-module-catalog@0.1.29-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + +## @backstage/plugin-catalog-backend-module-aws@0.3.18-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/plugin-kubernetes-common@0.8.2-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/integration-aws-node@0.1.12 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + +## @backstage/plugin-catalog-backend-module-azure@0.1.43-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + +## @backstage/plugin-catalog-backend-module-backstage-openapi@0.2.6-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/backend-openapi-utils@0.1.16-next.2 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + +## @backstage/plugin-catalog-backend-module-bitbucket-cloud@0.2.10-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-bitbucket-cloud-common@0.2.22-next.1 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + +## @backstage/plugin-catalog-backend-module-bitbucket-server@0.1.37-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + +## @backstage/plugin-catalog-backend-module-gcp@0.1.24-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-kubernetes-common@0.8.2-next.1 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + +## @backstage/plugin-catalog-backend-module-gerrit@0.1.40-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + +## @backstage/plugin-catalog-backend-module-github@0.6.6-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-catalog-backend@1.24.1-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + +## @backstage/plugin-catalog-backend-module-github-org@0.1.18-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-catalog-backend-module-github@0.6.6-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/config@1.2.0 + +## @backstage/plugin-catalog-backend-module-gitlab@0.3.22-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + +## @backstage/plugin-catalog-backend-module-gitlab-org@0.0.6-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-catalog-backend-module-gitlab@0.3.22-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + +## @backstage/plugin-catalog-backend-module-incremental-ingestion@0.4.28-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-catalog-backend@1.24.1-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + +## @backstage/plugin-catalog-backend-module-ldap@0.7.1-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + +## @backstage/plugin-catalog-backend-module-logs@0.0.2-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-catalog-backend@1.24.1-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + +## @backstage/plugin-catalog-backend-module-msgraph@0.5.31-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + +## @backstage/plugin-catalog-backend-module-openapi@0.1.41-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-catalog-backend@1.24.1-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/types@1.1.1 + +## @backstage/plugin-catalog-backend-module-puppetdb@0.1.29-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + +## @backstage/plugin-catalog-backend-module-scaffolder-entity-model@0.1.21-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/plugin-scaffolder-common@1.5.5-next.1 + - @backstage/catalog-model@1.5.0 + +## @backstage/plugin-catalog-backend-module-unprocessed@0.4.10-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-catalog-unprocessed-entities-common@0.0.4-next.1 + - @backstage/catalog-model@1.5.0 + - @backstage/errors@1.2.4 + +## @backstage/plugin-catalog-common@1.0.26-next.1 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/catalog-model@1.5.0 + +## @backstage/plugin-catalog-graph@0.4.8-next.3 + +### Patch Changes + +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-compat-api@0.2.8-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/types@1.1.1 + +## @backstage/plugin-catalog-import@0.12.2-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-compat-api@0.2.8-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/errors@1.2.4 + - @backstage/integration-react@1.1.30-next.0 + +## @backstage/plugin-catalog-node@1.12.5-next.2 + +### Patch Changes + +- 7c5f3b0: Explicit declare if the service ref accepts `single` or `multiple` implementations. +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/plugin-permission-node@0.8.1-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + +## @backstage/plugin-catalog-react@1.12.3-next.2 + +### Patch Changes + +- 012e3eb: Entity page extensions created for the new frontend system via the `/alpha` exports will now be enabled by default. +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/plugin-permission-react@0.4.25-next.1 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/errors@1.2.4 + - @backstage/integration-react@1.1.30-next.0 + - @backstage/types@1.1.1 + - @backstage/version-bridge@1.0.8 + +## @backstage/plugin-catalog-unprocessed-entities-common@0.0.4-next.1 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-permission-common@0.8.1-next.1 + +## @backstage/plugin-devtools@0.1.17-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-compat-api@0.2.8-next.2 + - @backstage/plugin-devtools-common@0.1.12-next.1 + - @backstage/plugin-permission-react@0.4.25-next.1 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/errors@1.2.4 + +## @backstage/plugin-devtools-backend@0.3.9-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/config-loader@1.9.0-next.2 + - @backstage/plugin-permission-node@0.8.1-next.2 + - @backstage/plugin-devtools-common@0.1.12-next.1 + - @backstage/cli-common@0.1.14 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + +## @backstage/plugin-devtools-common@0.1.12-next.1 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/types@1.1.1 + +## @backstage/plugin-events-backend@0.3.10-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/config@1.2.0 + +## @backstage/plugin-events-backend-module-aws-sqs@0.3.9-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/config@1.2.0 + - @backstage/types@1.1.1 + +## @backstage/plugin-events-backend-module-azure@0.2.9-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + +## @backstage/plugin-events-backend-module-bitbucket-cloud@0.2.9-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + +## @backstage/plugin-events-backend-module-gerrit@0.2.9-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + +## @backstage/plugin-events-backend-module-github@0.2.9-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/config@1.2.0 + +## @backstage/plugin-events-backend-module-gitlab@0.2.9-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/config@1.2.0 + +## @backstage/plugin-events-backend-test-utils@0.1.33-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-events-node@0.3.9-next.2 + +## @backstage/plugin-events-node@0.3.9-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + +## @backstage/plugin-home@0.7.9-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-compat-api@0.2.8-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/core-app-api@1.14.2-next.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/theme@0.5.6 + - @backstage/plugin-home-react@0.1.16-next.0 + +## @backstage/plugin-kubernetes@0.11.13-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-compat-api@0.2.8-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/plugin-kubernetes-common@0.8.2-next.1 + - @backstage/catalog-model@1.5.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/plugin-kubernetes-react@0.4.2-next.2 + +## @backstage/plugin-kubernetes-backend@0.18.4-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- 8c1aa06: Add `kubernetes.clusterLocatorMethods[].clusters[].customResources` to the configuration schema. + This was already documented and supported by the plugin. +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-kubernetes-node@0.1.17-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-permission-node@0.8.1-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-kubernetes-common@0.8.2-next.1 + - @backstage/integration-aws-node@0.1.12 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + +## @backstage/plugin-kubernetes-cluster@0.0.14-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/plugin-kubernetes-common@0.8.2-next.1 + - @backstage/catalog-model@1.5.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/plugin-kubernetes-react@0.4.2-next.2 + +## @backstage/plugin-kubernetes-common@0.8.2-next.1 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/catalog-model@1.5.0 + - @backstage/types@1.1.1 + +## @backstage/plugin-kubernetes-node@0.1.17-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-kubernetes-common@0.8.2-next.1 + - @backstage/catalog-model@1.5.0 + - @backstage/types@1.1.1 + +## @backstage/plugin-kubernetes-react@0.4.2-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-kubernetes-common@0.8.2-next.1 + - @backstage/catalog-model@1.5.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + +## @backstage/plugin-notifications-backend@0.3.4-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-notifications-node@0.2.4-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/plugin-signals-node@0.1.9-next.2 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/plugin-notifications-common@0.0.5 + +## @backstage/plugin-notifications-backend-module-email@0.2.0-next.2 + +### Patch Changes + +- cdb630d: Add support for stream transport for debugging purposes +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-notifications-node@0.2.4-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/integration-aws-node@0.1.12 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/types@1.1.1 + - @backstage/plugin-notifications-common@0.0.5 + +## @backstage/plugin-notifications-node@0.2.4-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-signals-node@0.1.9-next.2 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/plugin-notifications-common@0.0.5 + +## @backstage/plugin-org@0.6.28-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-compat-api@0.2.8-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/catalog-model@1.5.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + +## @backstage/plugin-org-react@0.1.27-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + +## @backstage/plugin-permission-backend@0.5.47-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-permission-node@0.8.1-next.2 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + +## @backstage/plugin-permission-backend-module-allow-all-policy@0.1.20-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-permission-node@0.8.1-next.2 + +## @backstage/plugin-permission-common@0.8.1-next.1 + +### Patch Changes + +- df784fe: Add the MetadataResponse type from @backstage/plugin-permission-node, since this + type might be used in frontend code. +- Updated dependencies + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + +## @backstage/plugin-permission-node@0.8.1-next.2 + +### Patch Changes + +- df784fe: The MetadataResponse type has been moved to @backstage/plugin-permission-common + to match the recent move of MetadataResponseSerializedRule, and should be + imported from there going forward. To avoid an immediate breaking change, this + type is still re-exported from this package, but is marked as deprecated and + will be removed in a future release. +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + +## @backstage/plugin-permission-react@0.4.25-next.1 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/config@1.2.0 + - @backstage/core-plugin-api@1.9.3 + +## @backstage/plugin-proxy-backend@0.5.4-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/config@1.2.0 + - @backstage/types@1.1.1 + +## @backstage/plugin-scaffolder-backend@1.23.1-next.2 + +### Patch Changes + +- c544f81: Add support for status filtering in scaffolder tasks endpoint +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/plugin-scaffolder-backend-module-bitbucket-server@0.1.13-next.2 + - @backstage/plugin-scaffolder-backend-module-bitbucket-cloud@0.1.13-next.2 + - @backstage/plugin-scaffolder-backend-module-bitbucket@0.2.13-next.2 + - @backstage/plugin-scaffolder-backend-module-gerrit@0.1.15-next.2 + - @backstage/plugin-scaffolder-backend-module-gitea@0.1.13-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-permission-node@0.8.1-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-bitbucket-cloud-common@0.2.22-next.1 + - @backstage/plugin-catalog-backend-module-scaffolder-entity-model@0.1.21-next.2 + - @backstage/plugin-scaffolder-backend-module-azure@0.1.15-next.2 + - @backstage/plugin-scaffolder-backend-module-github@0.4.1-next.2 + - @backstage/plugin-scaffolder-backend-module-gitlab@0.4.5-next.2 + - @backstage/plugin-scaffolder-common@1.5.5-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + +## @backstage/plugin-scaffolder-backend-module-azure@0.1.15-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + +## @backstage/plugin-scaffolder-backend-module-bitbucket@0.2.13-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/plugin-scaffolder-backend-module-bitbucket-server@0.1.13-next.2 + - @backstage/plugin-scaffolder-backend-module-bitbucket-cloud@0.1.13-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + +## @backstage/plugin-scaffolder-backend-module-bitbucket-cloud@0.1.13-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- 3fca643: Added autocompletion support for resource `branches` +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/plugin-bitbucket-cloud-common@0.2.22-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + +## @backstage/plugin-scaffolder-backend-module-bitbucket-server@0.1.13-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + +## @backstage/plugin-scaffolder-backend-module-confluence-to-markdown@0.2.24-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + +## @backstage/plugin-scaffolder-backend-module-cookiecutter@0.2.47-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + +## @backstage/plugin-scaffolder-backend-module-gcp@0.1.1-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + +## @backstage/plugin-scaffolder-backend-module-gerrit@0.1.15-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + +## @backstage/plugin-scaffolder-backend-module-gitea@0.1.13-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + +## @backstage/plugin-scaffolder-backend-module-github@0.4.1-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + +## @backstage/plugin-scaffolder-backend-module-gitlab@0.4.5-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + +## @backstage/plugin-scaffolder-backend-module-notifications@0.0.6-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/plugin-notifications-node@0.2.4-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-notifications-common@0.0.5 + +## @backstage/plugin-scaffolder-backend-module-rails@0.4.40-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + +## @backstage/plugin-scaffolder-backend-module-sentry@0.1.31-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- 382e868: Added test cases for sentry:project:create examples +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + +## @backstage/plugin-scaffolder-backend-module-yeoman@0.3.7-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/plugin-scaffolder-node-test-utils@0.1.10-next.2 + - @backstage/types@1.1.1 + +## @backstage/plugin-scaffolder-common@1.5.5-next.1 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/catalog-model@1.5.0 + - @backstage/types@1.1.1 + +## @backstage/plugin-scaffolder-node@0.4.9-next.2 + +### Patch Changes + +- c544f81: Add support for status filtering in scaffolder tasks endpoint +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-scaffolder-common@1.5.5-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-model@1.5.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + +## @backstage/plugin-scaffolder-node-test-utils@0.1.10-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-test-utils@0.4.5-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/types@1.1.1 + +## @backstage/plugin-scaffolder-react@1.11.0-next.2 + +### Patch Changes + +- 072c00c: Fixed a bug in `DefaultTableOutputs` where output elements overlapped on smaller screen sizes +- 04759f2: Fix null check in `isJsonObject` utility function for scaffolder review state component +- Updated dependencies + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/plugin-permission-react@0.4.25-next.1 + - @backstage/plugin-scaffolder-common@1.5.5-next.1 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/theme@0.5.6 + - @backstage/types@1.1.1 + - @backstage/version-bridge@1.0.8 + +## @backstage/plugin-search@1.4.15-next.2 + +### Patch Changes + +- 3123c16: Fix package metadata +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-compat-api@0.2.8-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/plugin-search-react@1.7.14-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + - @backstage/version-bridge@1.0.8 + +## @backstage/plugin-search-backend@1.5.15-next.2 + +### Patch Changes + +- 3123c16: Fix package metadata +- Updated dependencies + - @backstage/backend-defaults@0.4.2-next.2 + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-permission-node@0.8.1-next.2 + - @backstage/plugin-search-backend-node@1.2.28-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/backend-openapi-utils@0.1.16-next.2 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + +## @backstage/plugin-search-backend-module-catalog@0.1.29-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-search-backend-node@1.2.28-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + +## @backstage/plugin-search-backend-module-elasticsearch@1.5.4-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-search-backend-node@1.2.28-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/integration-aws-node@0.1.12 + - @backstage/config@1.2.0 + +## @backstage/plugin-search-backend-module-explore@0.1.29-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-search-backend-node@1.2.28-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/config@1.2.0 + +## @backstage/plugin-search-backend-module-pg@0.5.33-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-search-backend-node@1.2.28-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/config@1.2.0 + +## @backstage/plugin-search-backend-module-stack-overflow-collator@0.1.16-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-search-backend-node@1.2.28-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/config@1.2.0 + +## @backstage/plugin-search-backend-module-techdocs@0.1.28-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-search-backend-node@1.2.28-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-techdocs-node@1.12.9-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + +## @backstage/plugin-search-backend-node@1.2.28-next.2 + +### Patch Changes + +- 3123c16: Fix package metadata +- 7c5f3b0: Explicit declare if the service ref accepts `single` or `multiple` implementations. +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + +## @backstage/plugin-search-common@1.2.14-next.1 + +### Patch Changes + +- 3123c16: Fix package metadata +- Updated dependencies + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/types@1.1.1 + +## @backstage/plugin-search-react@1.7.14-next.2 + +### Patch Changes + +- 3123c16: Fix package metadata +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/theme@0.5.6 + - @backstage/types@1.1.1 + - @backstage/version-bridge@1.0.8 + +## @backstage/plugin-signals-backend@0.1.9-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/plugin-signals-node@0.1.9-next.2 + - @backstage/config@1.2.0 + - @backstage/types@1.1.1 + +## @backstage/plugin-signals-node@0.1.9-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/config@1.2.0 + - @backstage/types@1.1.1 + +## @backstage/plugin-techdocs@1.10.8-next.2 + +### Patch Changes + +- 67e76f2: TechDocs now supports the `mkdocs-redirects` plugin. Redirects defined using the `mkdocs-redirect` plugin will be handled automatically in TechDocs. Redirecting to external urls is not supported. In the case that an external redirect url is provided, TechDocs will redirect to the current documentation site home. +- bdc5471: Fixed issue where header styles were incorrectly generated when themes used CSS variables to define font size. +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-compat-api@0.2.8-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/plugin-search-react@1.7.14-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/errors@1.2.4 + - @backstage/integration-react@1.1.30-next.0 + - @backstage/theme@0.5.6 + - @backstage/plugin-auth-react@0.1.5-next.0 + - @backstage/plugin-techdocs-common@0.1.0-next.0 + - @backstage/plugin-techdocs-react@1.2.7-next.0 + +## @backstage/plugin-techdocs-addons-test-utils@1.0.37-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-catalog@1.22.0-next.2 + - @backstage/plugin-search-react@1.7.14-next.2 + - @backstage/plugin-techdocs@1.10.8-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/test-utils@1.5.10-next.2 + - @backstage/core-app-api@1.14.2-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/integration-react@1.1.30-next.0 + - @backstage/plugin-techdocs-react@1.2.7-next.0 + +## @backstage/plugin-techdocs-backend@1.10.10-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/plugin-search-backend-module-techdocs@0.1.28-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-techdocs-node@1.12.9-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/plugin-techdocs-common@0.1.0-next.0 + +## @backstage/plugin-techdocs-node@1.12.9-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/integration-aws-node@0.1.12 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/plugin-techdocs-common@0.1.0-next.0 + +## @backstage/plugin-user-settings@0.8.11-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-compat-api@0.2.8-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/core-app-api@1.14.2-next.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/errors@1.2.4 + - @backstage/theme@0.5.6 + - @backstage/types@1.1.1 + - @backstage/plugin-signals-react@0.0.4 + - @backstage/plugin-user-settings-common@0.0.1 + +## @backstage/plugin-user-settings-backend@0.2.22-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-signals-node@0.1.9-next.2 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + - @backstage/plugin-user-settings-common@0.0.1 + +## example-app@0.2.100-next.3 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-scaffolder-react@1.11.0-next.2 + - @backstage/plugin-catalog@1.22.0-next.2 + - @backstage/cli@0.27.0-next.3 + - @backstage/frontend-app-api@0.7.5-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/plugin-search-react@1.7.14-next.2 + - @backstage/plugin-search@1.4.15-next.2 + - @backstage/plugin-api-docs@0.11.8-next.2 + - @backstage/plugin-techdocs@1.10.8-next.2 + - @backstage/plugin-scaffolder@1.24.0-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/plugin-catalog-graph@0.4.8-next.3 + - @backstage/plugin-catalog-import@0.12.2-next.2 + - @backstage/plugin-org@0.6.28-next.2 + - @backstage/plugin-user-settings@0.8.11-next.2 + - @backstage/plugin-devtools@0.1.17-next.2 + - @backstage/plugin-home@0.7.9-next.2 + - @backstage/plugin-kubernetes@0.11.13-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/plugin-permission-react@0.4.25-next.1 + - @backstage/app-defaults@1.5.10-next.2 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/core-app-api@1.14.2-next.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/integration-react@1.1.30-next.0 + - @backstage/theme@0.5.6 + - @backstage/plugin-auth-react@0.1.5-next.0 + - @backstage/plugin-catalog-unprocessed-entities@0.2.7-next.0 + - @backstage/plugin-kubernetes-cluster@0.0.14-next.2 + - @backstage/plugin-notifications@0.2.4-next.0 + - @backstage/plugin-signals@0.0.9-next.0 + - @backstage/plugin-techdocs-module-addons-contrib@1.1.13-next.0 + - @backstage/plugin-techdocs-react@1.2.7-next.0 + +## example-app-next@0.0.14-next.3 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-scaffolder-react@1.11.0-next.2 + - @backstage/plugin-catalog@1.22.0-next.2 + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/cli@0.27.0-next.3 + - @backstage/frontend-app-api@0.7.5-next.2 + - @backstage/core-compat-api@0.2.8-next.2 + - @backstage/plugin-app-visualizer@0.1.9-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/plugin-search-react@1.7.14-next.2 + - @backstage/plugin-search@1.4.15-next.2 + - @backstage/plugin-api-docs@0.11.8-next.2 + - @backstage/plugin-techdocs@1.10.8-next.2 + - @backstage/plugin-scaffolder@1.24.0-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/plugin-catalog-graph@0.4.8-next.3 + - @backstage/plugin-catalog-import@0.12.2-next.2 + - @backstage/plugin-org@0.6.28-next.2 + - @backstage/plugin-user-settings@0.8.11-next.2 + - @backstage/plugin-home@0.7.9-next.2 + - @backstage/plugin-kubernetes@0.11.13-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/plugin-permission-react@0.4.25-next.1 + - @backstage/app-defaults@1.5.10-next.2 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/core-app-api@1.14.2-next.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/integration-react@1.1.30-next.0 + - @backstage/theme@0.5.6 + - @backstage/plugin-auth-react@0.1.5-next.0 + - @backstage/plugin-catalog-unprocessed-entities@0.2.7-next.0 + - @backstage/plugin-kubernetes-cluster@0.0.14-next.2 + - @backstage/plugin-notifications@0.2.4-next.0 + - @backstage/plugin-signals@0.0.9-next.0 + - @backstage/plugin-techdocs-module-addons-contrib@1.1.13-next.0 + - @backstage/plugin-techdocs-react@1.2.7-next.0 + +## app-next-example-plugin@0.0.14-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-components@0.14.10-next.0 + +## example-backend@0.0.29-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-defaults@0.4.2-next.2 + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-backend@1.23.1-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/plugin-search-backend-module-techdocs@0.1.28-next.2 + - @backstage/plugin-search-backend-module-explore@0.1.29-next.2 + - @backstage/plugin-notifications-backend@0.3.4-next.2 + - @backstage/plugin-kubernetes-backend@0.18.4-next.2 + - @backstage/plugin-permission-backend@0.5.47-next.2 + - @backstage/plugin-devtools-backend@0.3.9-next.2 + - @backstage/plugin-techdocs-backend@1.10.10-next.2 + - @backstage/plugin-catalog-backend@1.24.1-next.2 + - @backstage/plugin-signals-backend@0.1.9-next.2 + - @backstage/plugin-proxy-backend@0.5.4-next.2 + - @backstage/plugin-auth-backend@0.22.10-next.2 + - @backstage/plugin-app-backend@0.3.72-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-permission-node@0.8.1-next.2 + - @backstage/plugin-search-backend-node@1.2.28-next.2 + - @backstage/plugin-search-backend@1.5.15-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-auth-backend-module-github-provider@0.1.20-next.2 + - @backstage/plugin-auth-backend-module-guest-provider@0.1.9-next.2 + - @backstage/plugin-catalog-backend-module-backstage-openapi@0.2.6-next.2 + - @backstage/plugin-catalog-backend-module-openapi@0.1.41-next.2 + - @backstage/plugin-catalog-backend-module-scaffolder-entity-model@0.1.21-next.2 + - @backstage/plugin-catalog-backend-module-unprocessed@0.4.10-next.2 + - @backstage/plugin-permission-backend-module-allow-all-policy@0.1.20-next.2 + - @backstage/plugin-scaffolder-backend-module-github@0.4.1-next.2 + - @backstage/plugin-search-backend-module-catalog@0.1.29-next.2 + - @backstage/catalog-model@1.5.0 + +## example-backend-legacy@0.2.101-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-scaffolder-backend@1.23.1-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/plugin-scaffolder-backend-module-confluence-to-markdown@0.2.24-next.2 + - @backstage/plugin-search-backend-module-techdocs@0.1.28-next.2 + - @backstage/plugin-search-backend-module-explore@0.1.29-next.2 + - @backstage/plugin-kubernetes-backend@0.18.4-next.2 + - @backstage/plugin-permission-backend@0.5.47-next.2 + - @backstage/plugin-devtools-backend@0.3.9-next.2 + - @backstage/plugin-techdocs-backend@1.10.10-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-catalog-backend@1.24.1-next.2 + - @backstage/plugin-signals-backend@0.1.9-next.2 + - @backstage/plugin-proxy-backend@0.5.4-next.2 + - @backstage/plugin-auth-backend@0.22.10-next.2 + - @backstage/plugin-app-backend@0.3.72-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-permission-node@0.8.1-next.2 + - @backstage/plugin-search-backend-node@1.2.28-next.2 + - @backstage/plugin-search-backend@1.5.15-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-catalog-backend-module-scaffolder-entity-model@0.1.21-next.2 + - @backstage/plugin-catalog-backend-module-unprocessed@0.4.10-next.2 + - @backstage/plugin-events-backend@0.3.10-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/plugin-scaffolder-backend-module-gitlab@0.4.5-next.2 + - @backstage/plugin-scaffolder-backend-module-rails@0.4.40-next.2 + - @backstage/plugin-search-backend-module-catalog@0.1.29-next.2 + - @backstage/plugin-search-backend-module-elasticsearch@1.5.4-next.2 + - @backstage/plugin-search-backend-module-pg@0.5.33-next.2 + - @backstage/plugin-signals-node@0.1.9-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + +## e2e-test@0.2.19-next.3 + +### Patch Changes + +- Updated dependencies + - @backstage/create-app@0.5.18-next.3 + - @backstage/cli-common@0.1.14 + - @backstage/errors@1.2.4 + +## techdocs-cli-embedded-app@0.2.99-next.3 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-catalog@1.22.0-next.2 + - @backstage/cli@0.27.0-next.3 + - @backstage/plugin-techdocs@1.10.8-next.2 + - @backstage/test-utils@1.5.10-next.2 + - @backstage/app-defaults@1.5.10-next.2 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/core-app-api@1.14.2-next.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/integration-react@1.1.30-next.0 + - @backstage/theme@0.5.6 + - @backstage/plugin-techdocs-react@1.2.7-next.0 + +## @internal/plugin-todo-list-backend@1.0.30-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/errors@1.2.4 + +## @internal/plugin-todo-list-common@1.0.21-next.1 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-permission-common@0.8.1-next.1 diff --git a/package.json b/package.json index 8e7a047d7b..d9b384fb7d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "root", - "version": "1.30.0-next.2", + "version": "1.30.0-next.3", "private": true, "repository": { "type": "git", diff --git a/packages/app-defaults/CHANGELOG.md b/packages/app-defaults/CHANGELOG.md index ef2ecbce78..410841fec9 100644 --- a/packages/app-defaults/CHANGELOG.md +++ b/packages/app-defaults/CHANGELOG.md @@ -1,5 +1,16 @@ # @backstage/app-defaults +## 1.5.10-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-permission-react@0.4.25-next.1 + - @backstage/core-app-api@1.14.2-next.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/theme@0.5.6 + ## 1.5.10-next.1 ### Patch Changes diff --git a/packages/app-defaults/package.json b/packages/app-defaults/package.json index 6bed796754..284e832ae5 100644 --- a/packages/app-defaults/package.json +++ b/packages/app-defaults/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/app-defaults", - "version": "1.5.10-next.1", + "version": "1.5.10-next.2", "description": "Provides the default wiring of a Backstage App", "backstage": { "role": "web-library" diff --git a/packages/app-next-example-plugin/CHANGELOG.md b/packages/app-next-example-plugin/CHANGELOG.md index 13cd327ef1..62a7b18df0 100644 --- a/packages/app-next-example-plugin/CHANGELOG.md +++ b/packages/app-next-example-plugin/CHANGELOG.md @@ -1,5 +1,13 @@ # app-next-example-plugin +## 0.0.14-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-components@0.14.10-next.0 + ## 0.0.14-next.1 ### Patch Changes diff --git a/packages/app-next-example-plugin/package.json b/packages/app-next-example-plugin/package.json index 64be34d516..ad179ebbe5 100644 --- a/packages/app-next-example-plugin/package.json +++ b/packages/app-next-example-plugin/package.json @@ -1,6 +1,6 @@ { "name": "app-next-example-plugin", - "version": "0.0.14-next.1", + "version": "0.0.14-next.2", "description": "Backstage internal example plugin", "backstage": { "role": "frontend-plugin", diff --git a/packages/app-next/CHANGELOG.md b/packages/app-next/CHANGELOG.md index 7eb9535771..6382efa811 100644 --- a/packages/app-next/CHANGELOG.md +++ b/packages/app-next/CHANGELOG.md @@ -1,5 +1,48 @@ # example-app-next +## 0.0.14-next.3 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-scaffolder-react@1.11.0-next.2 + - @backstage/plugin-catalog@1.22.0-next.2 + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/cli@0.27.0-next.3 + - @backstage/frontend-app-api@0.7.5-next.2 + - @backstage/core-compat-api@0.2.8-next.2 + - @backstage/plugin-app-visualizer@0.1.9-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/plugin-search-react@1.7.14-next.2 + - @backstage/plugin-search@1.4.15-next.2 + - @backstage/plugin-api-docs@0.11.8-next.2 + - @backstage/plugin-techdocs@1.10.8-next.2 + - @backstage/plugin-scaffolder@1.24.0-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/plugin-catalog-graph@0.4.8-next.3 + - @backstage/plugin-catalog-import@0.12.2-next.2 + - @backstage/plugin-org@0.6.28-next.2 + - @backstage/plugin-user-settings@0.8.11-next.2 + - @backstage/plugin-home@0.7.9-next.2 + - @backstage/plugin-kubernetes@0.11.13-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/plugin-permission-react@0.4.25-next.1 + - @backstage/app-defaults@1.5.10-next.2 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/core-app-api@1.14.2-next.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/integration-react@1.1.30-next.0 + - @backstage/theme@0.5.6 + - @backstage/plugin-auth-react@0.1.5-next.0 + - @backstage/plugin-catalog-unprocessed-entities@0.2.7-next.0 + - @backstage/plugin-kubernetes-cluster@0.0.14-next.2 + - @backstage/plugin-notifications@0.2.4-next.0 + - @backstage/plugin-signals@0.0.9-next.0 + - @backstage/plugin-techdocs-module-addons-contrib@1.1.13-next.0 + - @backstage/plugin-techdocs-react@1.2.7-next.0 + ## 0.0.14-next.2 ### Patch Changes diff --git a/packages/app-next/package.json b/packages/app-next/package.json index 8a9d97d560..a12371a135 100644 --- a/packages/app-next/package.json +++ b/packages/app-next/package.json @@ -1,6 +1,6 @@ { "name": "example-app-next", - "version": "0.0.14-next.2", + "version": "0.0.14-next.3", "private": true, "repository": { "type": "git", diff --git a/packages/app/CHANGELOG.md b/packages/app/CHANGELOG.md index 4bcd5461a7..88e1134800 100644 --- a/packages/app/CHANGELOG.md +++ b/packages/app/CHANGELOG.md @@ -1,5 +1,46 @@ # example-app +## 0.2.100-next.3 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-scaffolder-react@1.11.0-next.2 + - @backstage/plugin-catalog@1.22.0-next.2 + - @backstage/cli@0.27.0-next.3 + - @backstage/frontend-app-api@0.7.5-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/plugin-search-react@1.7.14-next.2 + - @backstage/plugin-search@1.4.15-next.2 + - @backstage/plugin-api-docs@0.11.8-next.2 + - @backstage/plugin-techdocs@1.10.8-next.2 + - @backstage/plugin-scaffolder@1.24.0-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/plugin-catalog-graph@0.4.8-next.3 + - @backstage/plugin-catalog-import@0.12.2-next.2 + - @backstage/plugin-org@0.6.28-next.2 + - @backstage/plugin-user-settings@0.8.11-next.2 + - @backstage/plugin-devtools@0.1.17-next.2 + - @backstage/plugin-home@0.7.9-next.2 + - @backstage/plugin-kubernetes@0.11.13-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/plugin-permission-react@0.4.25-next.1 + - @backstage/app-defaults@1.5.10-next.2 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/core-app-api@1.14.2-next.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/integration-react@1.1.30-next.0 + - @backstage/theme@0.5.6 + - @backstage/plugin-auth-react@0.1.5-next.0 + - @backstage/plugin-catalog-unprocessed-entities@0.2.7-next.0 + - @backstage/plugin-kubernetes-cluster@0.0.14-next.2 + - @backstage/plugin-notifications@0.2.4-next.0 + - @backstage/plugin-signals@0.0.9-next.0 + - @backstage/plugin-techdocs-module-addons-contrib@1.1.13-next.0 + - @backstage/plugin-techdocs-react@1.2.7-next.0 + ## 0.2.100-next.2 ### Patch Changes diff --git a/packages/app/package.json b/packages/app/package.json index 855d32fce7..c4c0c18391 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -1,6 +1,6 @@ { "name": "example-app", - "version": "0.2.100-next.2", + "version": "0.2.100-next.3", "backstage": { "role": "frontend" }, diff --git a/packages/backend-app-api/CHANGELOG.md b/packages/backend-app-api/CHANGELOG.md index cbbb9e949e..c7c8883302 100644 --- a/packages/backend-app-api/CHANGELOG.md +++ b/packages/backend-app-api/CHANGELOG.md @@ -1,5 +1,26 @@ # @backstage/backend-app-api +## 0.8.1-next.2 + +### Patch Changes + +- 8b13183: Added support for the latest version of `BackendFeature`s from `@backstage/backend-plugin-api`, including feature loaders. +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- 7c5f3b0: Update the `ServiceRegister` implementation to enable registering multiple service implementations for a given service ref. +- 80a0737: Added configuration for the `packages` options to config schema +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/config-loader@1.9.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-permission-node@0.8.1-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/cli-node@0.2.7 + - @backstage/cli-common@0.1.14 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + ## 0.8.1-next.1 ### Patch Changes diff --git a/packages/backend-app-api/package.json b/packages/backend-app-api/package.json index 6a4e3a669b..e809d1c2f0 100644 --- a/packages/backend-app-api/package.json +++ b/packages/backend-app-api/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/backend-app-api", - "version": "0.8.1-next.1", + "version": "0.8.1-next.2", "description": "Core API used by Backstage backend apps", "backstage": { "role": "node-library" diff --git a/packages/backend-common/CHANGELOG.md b/packages/backend-common/CHANGELOG.md index 2bd24bc8d5..5eadae4c0f 100644 --- a/packages/backend-common/CHANGELOG.md +++ b/packages/backend-common/CHANGELOG.md @@ -1,5 +1,22 @@ # @backstage/backend-common +## 0.23.4-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/config-loader@1.9.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/integration-aws-node@0.1.12 + - @backstage/backend-dev-utils@0.1.4 + - @backstage/cli-common@0.1.14 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + ## 0.23.4-next.1 ### Patch Changes diff --git a/packages/backend-common/package.json b/packages/backend-common/package.json index 17913d87d4..ccf44fba0f 100644 --- a/packages/backend-common/package.json +++ b/packages/backend-common/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/backend-common", - "version": "0.23.4-next.1", + "version": "0.23.4-next.2", "description": "Common functionality library for Backstage backends", "backstage": { "role": "node-library" diff --git a/packages/backend-defaults/CHANGELOG.md b/packages/backend-defaults/CHANGELOG.md index 387c9d197e..44b0a6b9b0 100644 --- a/packages/backend-defaults/CHANGELOG.md +++ b/packages/backend-defaults/CHANGELOG.md @@ -1,5 +1,30 @@ # @backstage/backend-defaults +## 0.4.2-next.2 + +### Patch Changes + +- 0d16b52: Add access restrictions to the JWKS external access method config schema +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- ba9abf4: The `SchedulerService` now allows tasks with `frequency: { trigger: 'manual' }`. This means that the task will not be scheduled, but rather run only when manually triggered with `SchedulerService.triggerTask`. +- 7c5f3b0: Update the `UrlReader` service to depends on multiple instances of `UrlReaderFactoryProvider` service. +- 1d5f298: Avoid excessive numbers of error listeners on cache clients +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-app-api@0.8.1-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/config-loader@1.9.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-permission-node@0.8.1-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/integration-aws-node@0.1.12 + - @backstage/backend-dev-utils@0.1.4 + - @backstage/cli-common@0.1.14 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + ## 0.4.2-next.1 ### Patch Changes diff --git a/packages/backend-defaults/package.json b/packages/backend-defaults/package.json index 196c9b188a..cef9641de6 100644 --- a/packages/backend-defaults/package.json +++ b/packages/backend-defaults/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/backend-defaults", - "version": "0.4.2-next.1", + "version": "0.4.2-next.2", "description": "Backend defaults used by Backstage backend apps", "backstage": { "role": "node-library" diff --git a/packages/backend-dynamic-feature-service/CHANGELOG.md b/packages/backend-dynamic-feature-service/CHANGELOG.md index ede70bfbca..14111873a1 100644 --- a/packages/backend-dynamic-feature-service/CHANGELOG.md +++ b/packages/backend-dynamic-feature-service/CHANGELOG.md @@ -1,5 +1,31 @@ # @backstage/backend-dynamic-feature-service +## 0.2.16-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-app-api@0.8.1-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-catalog-backend@1.24.1-next.2 + - @backstage/config-loader@1.9.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-permission-node@0.8.1-next.2 + - @backstage/plugin-search-backend-node@1.2.28-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-app-node@0.1.23-next.2 + - @backstage/plugin-events-backend@0.3.10-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/cli-node@0.2.7 + - @backstage/cli-common@0.1.14 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + ## 0.2.16-next.1 ### Patch Changes diff --git a/packages/backend-dynamic-feature-service/package.json b/packages/backend-dynamic-feature-service/package.json index 1282d39d6c..d6ac21a3ae 100644 --- a/packages/backend-dynamic-feature-service/package.json +++ b/packages/backend-dynamic-feature-service/package.json @@ -1,7 +1,7 @@ { "name": "@backstage/backend-dynamic-feature-service", "description": "Backstage dynamic feature service", - "version": "0.2.16-next.1", + "version": "0.2.16-next.2", "main": "src/index.ts", "types": "src/index.ts", "publishConfig": { diff --git a/packages/backend-legacy/CHANGELOG.md b/packages/backend-legacy/CHANGELOG.md index f036362cd2..a601890055 100644 --- a/packages/backend-legacy/CHANGELOG.md +++ b/packages/backend-legacy/CHANGELOG.md @@ -1,5 +1,46 @@ # example-backend-legacy +## 0.2.101-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-scaffolder-backend@1.23.1-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/plugin-scaffolder-backend-module-confluence-to-markdown@0.2.24-next.2 + - @backstage/plugin-search-backend-module-techdocs@0.1.28-next.2 + - @backstage/plugin-search-backend-module-explore@0.1.29-next.2 + - @backstage/plugin-kubernetes-backend@0.18.4-next.2 + - @backstage/plugin-permission-backend@0.5.47-next.2 + - @backstage/plugin-devtools-backend@0.3.9-next.2 + - @backstage/plugin-techdocs-backend@1.10.10-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-catalog-backend@1.24.1-next.2 + - @backstage/plugin-signals-backend@0.1.9-next.2 + - @backstage/plugin-proxy-backend@0.5.4-next.2 + - @backstage/plugin-auth-backend@0.22.10-next.2 + - @backstage/plugin-app-backend@0.3.72-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-permission-node@0.8.1-next.2 + - @backstage/plugin-search-backend-node@1.2.28-next.2 + - @backstage/plugin-search-backend@1.5.15-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-catalog-backend-module-scaffolder-entity-model@0.1.21-next.2 + - @backstage/plugin-catalog-backend-module-unprocessed@0.4.10-next.2 + - @backstage/plugin-events-backend@0.3.10-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/plugin-scaffolder-backend-module-gitlab@0.4.5-next.2 + - @backstage/plugin-scaffolder-backend-module-rails@0.4.40-next.2 + - @backstage/plugin-search-backend-module-catalog@0.1.29-next.2 + - @backstage/plugin-search-backend-module-elasticsearch@1.5.4-next.2 + - @backstage/plugin-search-backend-module-pg@0.5.33-next.2 + - @backstage/plugin-signals-node@0.1.9-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + ## 0.2.101-next.1 ### Patch Changes diff --git a/packages/backend-legacy/package.json b/packages/backend-legacy/package.json index 3f59103f4c..a650924720 100644 --- a/packages/backend-legacy/package.json +++ b/packages/backend-legacy/package.json @@ -1,6 +1,6 @@ { "name": "example-backend-legacy", - "version": "0.2.101-next.1", + "version": "0.2.101-next.2", "backstage": { "role": "backend" }, diff --git a/packages/backend-openapi-utils/CHANGELOG.md b/packages/backend-openapi-utils/CHANGELOG.md index 37bb91f625..682036d984 100644 --- a/packages/backend-openapi-utils/CHANGELOG.md +++ b/packages/backend-openapi-utils/CHANGELOG.md @@ -1,5 +1,13 @@ # @backstage/backend-openapi-utils +## 0.1.16-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/errors@1.2.4 + ## 0.1.16-next.1 ### Patch Changes diff --git a/packages/backend-openapi-utils/package.json b/packages/backend-openapi-utils/package.json index ccf49f2be7..35db691c25 100644 --- a/packages/backend-openapi-utils/package.json +++ b/packages/backend-openapi-utils/package.json @@ -1,7 +1,7 @@ { "name": "@backstage/backend-openapi-utils", "description": "OpenAPI typescript support.", - "version": "0.1.16-next.1", + "version": "0.1.16-next.2", "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", diff --git a/packages/backend-plugin-api/CHANGELOG.md b/packages/backend-plugin-api/CHANGELOG.md index 9f5ced6b18..d404d05b33 100644 --- a/packages/backend-plugin-api/CHANGELOG.md +++ b/packages/backend-plugin-api/CHANGELOG.md @@ -1,5 +1,99 @@ # @backstage/backend-plugin-api +## 0.8.0-next.2 + +### Minor Changes + +- 7c5f3b0: The `createServiceRef` function now accepts a new boolean `multiple` option. The `multiple` option defaults to `false` and when set to `true`, it enables that multiple implementation are installed for the created service ref. + + We're looking for ways to make it possible to augment services without the need to replace the entire service. + + Typical example of that being the ability to install support for additional targets for the `UrlReader` service without replacing the service itself. This achieves that by allowing us to define services that can have multiple simultaneous implementation, allowing the `UrlReader` implementation to depend on such a service to collect all possible implementation of support for external targets: + + ```diff + // @backstage/backend-defaults + + + export const urlReaderFactoriesServiceRef = createServiceRef({ + + id: 'core.urlReader.factories', + + scope: 'plugin', + + multiton: true, + + }); + + ... + + export const urlReaderServiceFactory = createServiceFactory({ + service: coreServices.urlReader, + deps: { + config: coreServices.rootConfig, + logger: coreServices.logger, + + factories: urlReaderFactoriesServiceRef, + }, + - async factory({ config, logger }) { + + async factory({ config, logger, factories }) { + return UrlReaders.default({ + config, + logger, + + factories, + }); + }, + }); + ``` + + With that, you can then add more custom `UrlReader` factories by installing more implementations of the `urlReaderFactoriesServiceRef` in your backend instance. Something like: + + ```ts + // packages/backend/index.ts + import { createServiceFactory } from '@backstage/backend-plugin-api'; + import { urlReaderFactoriesServiceRef } from '@backstage/backend-defaults'; + ... + + backend.add(createServiceFactory({ + service: urlReaderFactoriesServiceRef, + deps: {}, + async factory() { + return CustomUrlReader.factory; + }, + })); + + ... + + ``` + +### Patch Changes + +- 6061061: Added `createBackendFeatureLoader`, which can be used to create an installable backend feature that can in turn load in additional backend features in a dynamic way. +- ba9abf4: The `SchedulerService` now allows tasks with `frequency: { trigger: 'manual' }`. This means that the task will not be scheduled, but rather run only when manually triggered with `SchedulerService.triggerTask`. +- 8b13183: Added `createBackendFeatureLoader`, which can be used to programmatically select and install backend features. + + A feature loader can return an list of features to be installed, for example in the form on an `Array` or other for of iterable, which allows for the loader to be defined as a generator function. Both synchronous and asynchronous loaders are supported. + + Additionally, a loader can depend on services in its implementation, with the restriction that it can only depend on root-scoped services, and it may not override services that have already been instantiated. + + ```ts + const searchLoader = createBackendFeatureLoader({ + deps: { + config: coreServices.rootConfig, + }, + *loader({ config }) { + // Example of a custom config flag to enable search + if (config.getOptionalString('customFeatureToggle.search')) { + yield import('@backstage/plugin-search-backend/alpha'); + yield import('@backstage/plugin-search-backend-module-catalog/alpha'); + yield import('@backstage/plugin-search-backend-module-explore/alpha'); + yield import('@backstage/plugin-search-backend-module-techdocs/alpha'); + } + }, + }); + ``` + +- Updated dependencies + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/cli-common@0.1.14 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + ## 0.7.1-next.1 ### Patch Changes diff --git a/packages/backend-plugin-api/package.json b/packages/backend-plugin-api/package.json index 267fdf6a01..61f8b9353d 100644 --- a/packages/backend-plugin-api/package.json +++ b/packages/backend-plugin-api/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/backend-plugin-api", - "version": "0.7.1-next.1", + "version": "0.8.0-next.2", "description": "Core API used by Backstage backend plugins", "backstage": { "role": "node-library" diff --git a/packages/backend-tasks/CHANGELOG.md b/packages/backend-tasks/CHANGELOG.md index 2313e04748..1a5879f14e 100644 --- a/packages/backend-tasks/CHANGELOG.md +++ b/packages/backend-tasks/CHANGELOG.md @@ -1,5 +1,17 @@ # @backstage/backend-tasks +## 0.5.28-next.2 + +### Patch Changes + +- ba9abf4: The `PluginTaskScheduler` now allows tasks with `frequency: { trigger: 'manual' }`. This means that the task will not be scheduled, but rather run only when manually triggered with `PluginTaskScheduler.triggerTask`. +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + ## 0.5.28-next.1 ### Patch Changes diff --git a/packages/backend-tasks/package.json b/packages/backend-tasks/package.json index a6c88c2be4..3f482b38e6 100644 --- a/packages/backend-tasks/package.json +++ b/packages/backend-tasks/package.json @@ -1,7 +1,7 @@ { "name": "@backstage/backend-tasks", "description": "Common distributed task management library for Backstage backends", - "version": "0.5.28-next.1", + "version": "0.5.28-next.2", "main": "src/index.ts", "types": "src/index.ts", "publishConfig": { diff --git a/packages/backend-test-utils/CHANGELOG.md b/packages/backend-test-utils/CHANGELOG.md index 288bc2fd1d..cbca6bdcab 100644 --- a/packages/backend-test-utils/CHANGELOG.md +++ b/packages/backend-test-utils/CHANGELOG.md @@ -1,5 +1,21 @@ # @backstage/backend-test-utils +## 0.4.5-next.2 + +### Patch Changes + +- 8b13183: Internal updates to support latest version of `BackendFeauture`s from `@backstage/backend-plugin-api`. +- 7c5f3b0: Update the `ServiceFactoryTester` to be able to test services that enables multi implementation installation. +- Updated dependencies + - @backstage/backend-defaults@0.4.2-next.2 + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-app-api@0.8.1-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + ## 0.4.5-next.1 ### Patch Changes diff --git a/packages/backend-test-utils/package.json b/packages/backend-test-utils/package.json index bb0786b02c..44373e733f 100644 --- a/packages/backend-test-utils/package.json +++ b/packages/backend-test-utils/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/backend-test-utils", - "version": "0.4.5-next.1", + "version": "0.4.5-next.2", "description": "Test helpers library for Backstage backends", "backstage": { "role": "node-library" diff --git a/packages/backend/CHANGELOG.md b/packages/backend/CHANGELOG.md index 0c58a76dd1..8fbce11752 100644 --- a/packages/backend/CHANGELOG.md +++ b/packages/backend/CHANGELOG.md @@ -1,5 +1,42 @@ # example-backend +## 0.0.29-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-defaults@0.4.2-next.2 + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-backend@1.23.1-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/plugin-search-backend-module-techdocs@0.1.28-next.2 + - @backstage/plugin-search-backend-module-explore@0.1.29-next.2 + - @backstage/plugin-notifications-backend@0.3.4-next.2 + - @backstage/plugin-kubernetes-backend@0.18.4-next.2 + - @backstage/plugin-permission-backend@0.5.47-next.2 + - @backstage/plugin-devtools-backend@0.3.9-next.2 + - @backstage/plugin-techdocs-backend@1.10.10-next.2 + - @backstage/plugin-catalog-backend@1.24.1-next.2 + - @backstage/plugin-signals-backend@0.1.9-next.2 + - @backstage/plugin-proxy-backend@0.5.4-next.2 + - @backstage/plugin-auth-backend@0.22.10-next.2 + - @backstage/plugin-app-backend@0.3.72-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-permission-node@0.8.1-next.2 + - @backstage/plugin-search-backend-node@1.2.28-next.2 + - @backstage/plugin-search-backend@1.5.15-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-auth-backend-module-github-provider@0.1.20-next.2 + - @backstage/plugin-auth-backend-module-guest-provider@0.1.9-next.2 + - @backstage/plugin-catalog-backend-module-backstage-openapi@0.2.6-next.2 + - @backstage/plugin-catalog-backend-module-openapi@0.1.41-next.2 + - @backstage/plugin-catalog-backend-module-scaffolder-entity-model@0.1.21-next.2 + - @backstage/plugin-catalog-backend-module-unprocessed@0.4.10-next.2 + - @backstage/plugin-permission-backend-module-allow-all-policy@0.1.20-next.2 + - @backstage/plugin-scaffolder-backend-module-github@0.4.1-next.2 + - @backstage/plugin-search-backend-module-catalog@0.1.29-next.2 + - @backstage/catalog-model@1.5.0 + ## 0.0.29-next.1 ### Patch Changes diff --git a/packages/backend/package.json b/packages/backend/package.json index 91c63d7553..cafe89a527 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -1,6 +1,6 @@ { "name": "example-backend", - "version": "0.0.29-next.1", + "version": "0.0.29-next.2", "main": "dist/index.cjs.js", "types": "src/index.ts", "license": "Apache-2.0", diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index df526b2b00..887445aac7 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,5 +1,22 @@ # @backstage/cli +## 0.27.0-next.3 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/config-loader@1.9.0-next.2 + - @backstage/cli-node@0.2.7 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-model@1.5.0 + - @backstage/cli-common@0.1.14 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/eslint-plugin@0.1.8 + - @backstage/release-manifests@0.0.11 + - @backstage/types@1.1.1 + ## 0.27.0-next.2 ### Patch Changes diff --git a/packages/cli/package.json b/packages/cli/package.json index 79740ea4fa..ba45b8f514 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/cli", - "version": "0.27.0-next.2", + "version": "0.27.0-next.3", "description": "CLI for developing Backstage plugins and apps", "backstage": { "role": "cli" diff --git a/packages/config-loader/CHANGELOG.md b/packages/config-loader/CHANGELOG.md index a026e7549d..78f2123970 100644 --- a/packages/config-loader/CHANGELOG.md +++ b/packages/config-loader/CHANGELOG.md @@ -1,5 +1,16 @@ # @backstage/config-loader +## 1.9.0-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/cli-common@0.1.14 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + ## 1.9.0-next.1 ### Minor Changes diff --git a/packages/config-loader/package.json b/packages/config-loader/package.json index 1b49af9cf0..a47a17c12f 100644 --- a/packages/config-loader/package.json +++ b/packages/config-loader/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/config-loader", - "version": "1.9.0-next.1", + "version": "1.9.0-next.2", "description": "Config loading functionality used by Backstage backend, and CLI", "backstage": { "role": "node-library" diff --git a/packages/core-compat-api/CHANGELOG.md b/packages/core-compat-api/CHANGELOG.md index 587d78242b..34c134f731 100644 --- a/packages/core-compat-api/CHANGELOG.md +++ b/packages/core-compat-api/CHANGELOG.md @@ -1,5 +1,16 @@ # @backstage/core-compat-api +## 0.2.8-next.2 + +### Patch Changes + +- 72754db: Updated usage of `useRouteRef`, which can now always return `undefined`. +- 16cf96c: Both `compatWrapper` and `convertLegacyRouteRef` now support converting from the new system to the old. +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-plugin-api@1.9.3 + - @backstage/version-bridge@1.0.8 + ## 0.2.8-next.1 ### Patch Changes diff --git a/packages/core-compat-api/package.json b/packages/core-compat-api/package.json index 4a143a50c7..0434b206d9 100644 --- a/packages/core-compat-api/package.json +++ b/packages/core-compat-api/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/core-compat-api", - "version": "0.2.8-next.1", + "version": "0.2.8-next.2", "backstage": { "role": "web-library" }, diff --git a/packages/create-app/CHANGELOG.md b/packages/create-app/CHANGELOG.md index 85587de268..dce729b811 100644 --- a/packages/create-app/CHANGELOG.md +++ b/packages/create-app/CHANGELOG.md @@ -1,5 +1,13 @@ # @backstage/create-app +## 0.5.18-next.3 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/cli-common@0.1.14 + ## 0.5.18-next.2 ### Patch Changes diff --git a/packages/create-app/package.json b/packages/create-app/package.json index df46c8ffde..8886ed9a6d 100644 --- a/packages/create-app/package.json +++ b/packages/create-app/package.json @@ -1,7 +1,7 @@ { "name": "@backstage/create-app", "description": "A CLI that helps you create your own Backstage app", - "version": "0.5.18-next.2", + "version": "0.5.18-next.3", "publishConfig": { "access": "public" }, diff --git a/packages/dev-utils/CHANGELOG.md b/packages/dev-utils/CHANGELOG.md index 30aeba5a08..5ea08c7762 100644 --- a/packages/dev-utils/CHANGELOG.md +++ b/packages/dev-utils/CHANGELOG.md @@ -1,5 +1,19 @@ # @backstage/dev-utils +## 1.0.37-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/app-defaults@1.5.10-next.2 + - @backstage/catalog-model@1.5.0 + - @backstage/core-app-api@1.14.2-next.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/integration-react@1.1.30-next.0 + - @backstage/theme@0.5.6 + ## 1.0.37-next.1 ### Patch Changes diff --git a/packages/dev-utils/package.json b/packages/dev-utils/package.json index f3f835b015..b2b6eb3292 100644 --- a/packages/dev-utils/package.json +++ b/packages/dev-utils/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/dev-utils", - "version": "1.0.37-next.1", + "version": "1.0.37-next.2", "description": "Utilities for developing Backstage plugins.", "backstage": { "role": "web-library" diff --git a/packages/e2e-test/CHANGELOG.md b/packages/e2e-test/CHANGELOG.md index 488f48fd4b..4609771fb5 100644 --- a/packages/e2e-test/CHANGELOG.md +++ b/packages/e2e-test/CHANGELOG.md @@ -1,5 +1,14 @@ # e2e-test +## 0.2.19-next.3 + +### Patch Changes + +- Updated dependencies + - @backstage/create-app@0.5.18-next.3 + - @backstage/cli-common@0.1.14 + - @backstage/errors@1.2.4 + ## 0.2.19-next.2 ### Patch Changes diff --git a/packages/e2e-test/package.json b/packages/e2e-test/package.json index 190d66c7b3..481b011d01 100644 --- a/packages/e2e-test/package.json +++ b/packages/e2e-test/package.json @@ -1,7 +1,7 @@ { "name": "e2e-test", "description": "E2E test for verifying Backstage packages", - "version": "0.2.19-next.2", + "version": "0.2.19-next.3", "private": true, "backstage": { "role": "cli" diff --git a/packages/frontend-app-api/CHANGELOG.md b/packages/frontend-app-api/CHANGELOG.md index 8593bb38e5..dd419c284b 100644 --- a/packages/frontend-app-api/CHANGELOG.md +++ b/packages/frontend-app-api/CHANGELOG.md @@ -1,5 +1,21 @@ # @backstage/frontend-app-api +## 0.7.5-next.2 + +### Patch Changes + +- 72754db: Updated usage of `useRouteRef`, which can now always return `undefined`. +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/config@1.2.0 + - @backstage/core-app-api@1.14.2-next.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/errors@1.2.4 + - @backstage/theme@0.5.6 + - @backstage/types@1.1.1 + - @backstage/version-bridge@1.0.8 + ## 0.7.5-next.1 ### Patch Changes diff --git a/packages/frontend-app-api/package.json b/packages/frontend-app-api/package.json index 11059214c2..0d462e2721 100644 --- a/packages/frontend-app-api/package.json +++ b/packages/frontend-app-api/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/frontend-app-api", - "version": "0.7.5-next.1", + "version": "0.7.5-next.2", "backstage": { "role": "web-library" }, diff --git a/packages/frontend-plugin-api/CHANGELOG.md b/packages/frontend-plugin-api/CHANGELOG.md index 40961b558f..302d541b18 100644 --- a/packages/frontend-plugin-api/CHANGELOG.md +++ b/packages/frontend-plugin-api/CHANGELOG.md @@ -1,5 +1,22 @@ # @backstage/frontend-plugin-api +## 0.7.0-next.2 + +### Minor Changes + +- 72754db: **BREAKING**: All types of route refs are always considered optional by `useRouteRef`, which means the caller must always handle a potential `undefined` return value. Related to this change, the `optional` option from `createExternalRouteRef` has been removed, since it is no longer necessary. + + This is released as an immediate breaking change as we expect the usage of the new route refs to be extremely low or zero, since plugins that support the new system will still use route refs and `useRouteRef` from `@backstage/core-plugin-api` in combination with `convertLegacyRouteRef` from `@backstage/core-compat-api`. + +### Patch Changes + +- 210d066: Added support for using the `params` in other properties of the `createExtensionBlueprint` options by providing a callback. +- Updated dependencies + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/types@1.1.1 + - @backstage/version-bridge@1.0.8 + ## 0.6.8-next.1 ### Patch Changes diff --git a/packages/frontend-plugin-api/package.json b/packages/frontend-plugin-api/package.json index 5ee4667c3a..8f729a5c4d 100644 --- a/packages/frontend-plugin-api/package.json +++ b/packages/frontend-plugin-api/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/frontend-plugin-api", - "version": "0.6.8-next.1", + "version": "0.7.0-next.2", "backstage": { "role": "web-library" }, diff --git a/packages/frontend-test-utils/CHANGELOG.md b/packages/frontend-test-utils/CHANGELOG.md index 8f770b7b31..4ba38f5065 100644 --- a/packages/frontend-test-utils/CHANGELOG.md +++ b/packages/frontend-test-utils/CHANGELOG.md @@ -1,5 +1,18 @@ # @backstage/frontend-test-utils +## 0.1.12-next.2 + +### Patch Changes + +- 8209449: Added new APIs for testing extensions +- 72754db: Updated usage of `useRouteRef`, which can now always return `undefined`. +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/frontend-app-api@0.7.5-next.2 + - @backstage/test-utils@1.5.10-next.2 + - @backstage/config@1.2.0 + - @backstage/types@1.1.1 + ## 0.1.12-next.1 ### Patch Changes diff --git a/packages/frontend-test-utils/package.json b/packages/frontend-test-utils/package.json index 737d30363a..e8152cfdda 100644 --- a/packages/frontend-test-utils/package.json +++ b/packages/frontend-test-utils/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/frontend-test-utils", - "version": "0.1.12-next.1", + "version": "0.1.12-next.2", "backstage": { "role": "web-library" }, diff --git a/packages/repo-tools/CHANGELOG.md b/packages/repo-tools/CHANGELOG.md index 35c7f35836..f74dd57ea0 100644 --- a/packages/repo-tools/CHANGELOG.md +++ b/packages/repo-tools/CHANGELOG.md @@ -1,5 +1,17 @@ # @backstage/repo-tools +## 0.9.5-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/config-loader@1.9.0-next.2 + - @backstage/cli-node@0.2.7 + - @backstage/catalog-model@1.5.0 + - @backstage/cli-common@0.1.14 + - @backstage/errors@1.2.4 + ## 0.9.5-next.1 ### Patch Changes diff --git a/packages/repo-tools/package.json b/packages/repo-tools/package.json index 7e03d78758..63be4d526e 100644 --- a/packages/repo-tools/package.json +++ b/packages/repo-tools/package.json @@ -1,7 +1,7 @@ { "name": "@backstage/repo-tools", "description": "CLI for Backstage repo tooling ", - "version": "0.9.5-next.1", + "version": "0.9.5-next.2", "publishConfig": { "access": "public" }, diff --git a/packages/techdocs-cli-embedded-app/CHANGELOG.md b/packages/techdocs-cli-embedded-app/CHANGELOG.md index 728145048a..57fb204390 100644 --- a/packages/techdocs-cli-embedded-app/CHANGELOG.md +++ b/packages/techdocs-cli-embedded-app/CHANGELOG.md @@ -1,5 +1,24 @@ # techdocs-cli-embedded-app +## 0.2.99-next.3 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-catalog@1.22.0-next.2 + - @backstage/cli@0.27.0-next.3 + - @backstage/plugin-techdocs@1.10.8-next.2 + - @backstage/test-utils@1.5.10-next.2 + - @backstage/app-defaults@1.5.10-next.2 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/core-app-api@1.14.2-next.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/integration-react@1.1.30-next.0 + - @backstage/theme@0.5.6 + - @backstage/plugin-techdocs-react@1.2.7-next.0 + ## 0.2.99-next.2 ### Patch Changes diff --git a/packages/techdocs-cli-embedded-app/package.json b/packages/techdocs-cli-embedded-app/package.json index 09635b74ed..472936193a 100644 --- a/packages/techdocs-cli-embedded-app/package.json +++ b/packages/techdocs-cli-embedded-app/package.json @@ -1,6 +1,6 @@ { "name": "techdocs-cli-embedded-app", - "version": "0.2.99-next.2", + "version": "0.2.99-next.3", "private": true, "backstage": { "role": "frontend" diff --git a/packages/techdocs-cli/CHANGELOG.md b/packages/techdocs-cli/CHANGELOG.md index d6d5128e4d..76f9891bf0 100644 --- a/packages/techdocs-cli/CHANGELOG.md +++ b/packages/techdocs-cli/CHANGELOG.md @@ -1,5 +1,16 @@ # @techdocs/cli +## 1.8.17-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-defaults@0.4.2-next.2 + - @backstage/plugin-techdocs-node@1.12.9-next.2 + - @backstage/catalog-model@1.5.0 + - @backstage/cli-common@0.1.14 + - @backstage/config@1.2.0 + ## 1.8.17-next.1 ### Patch Changes diff --git a/packages/techdocs-cli/package.json b/packages/techdocs-cli/package.json index fc28ab1458..c655649ceb 100644 --- a/packages/techdocs-cli/package.json +++ b/packages/techdocs-cli/package.json @@ -1,7 +1,7 @@ { "name": "@techdocs/cli", "description": "Utility CLI for managing TechDocs sites in Backstage.", - "version": "1.8.17-next.1", + "version": "1.8.17-next.2", "publishConfig": { "access": "public" }, diff --git a/packages/test-utils/CHANGELOG.md b/packages/test-utils/CHANGELOG.md index 6684b8b4b5..a6c013a34a 100644 --- a/packages/test-utils/CHANGELOG.md +++ b/packages/test-utils/CHANGELOG.md @@ -1,5 +1,18 @@ # @backstage/test-utils +## 1.5.10-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/plugin-permission-react@0.4.25-next.1 + - @backstage/config@1.2.0 + - @backstage/core-app-api@1.14.2-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/theme@0.5.6 + - @backstage/types@1.1.1 + ## 1.5.10-next.1 ### Patch Changes diff --git a/packages/test-utils/package.json b/packages/test-utils/package.json index 32a69da9df..3007c734bd 100644 --- a/packages/test-utils/package.json +++ b/packages/test-utils/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/test-utils", - "version": "1.5.10-next.1", + "version": "1.5.10-next.2", "description": "Utilities to test Backstage plugins and apps.", "backstage": { "role": "web-library" diff --git a/plugins/api-docs/CHANGELOG.md b/plugins/api-docs/CHANGELOG.md index f649d4e0b8..c87bfcaafa 100644 --- a/plugins/api-docs/CHANGELOG.md +++ b/plugins/api-docs/CHANGELOG.md @@ -1,5 +1,21 @@ # @backstage/plugin-api-docs +## 0.11.8-next.2 + +### Patch Changes + +- 4b6d2cb: Updated dependency `@graphiql/react` to `^0.23.0`. +- Updated dependencies + - @backstage/plugin-catalog@1.22.0-next.2 + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-compat-api@0.2.8-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/plugin-permission-react@0.4.25-next.1 + - @backstage/catalog-model@1.5.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + ## 0.11.8-next.1 ### Patch Changes diff --git a/plugins/api-docs/package.json b/plugins/api-docs/package.json index 3633471588..96b52002d8 100644 --- a/plugins/api-docs/package.json +++ b/plugins/api-docs/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-api-docs", - "version": "0.11.8-next.1", + "version": "0.11.8-next.2", "description": "A Backstage plugin that helps represent API entities in the frontend", "backstage": { "role": "frontend-plugin", diff --git a/plugins/app-backend/CHANGELOG.md b/plugins/app-backend/CHANGELOG.md index c0a59fca0e..305d90e2ec 100644 --- a/plugins/app-backend/CHANGELOG.md +++ b/plugins/app-backend/CHANGELOG.md @@ -1,5 +1,20 @@ # @backstage/plugin-app-backend +## 0.3.72-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/config-loader@1.9.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-app-node@0.1.23-next.2 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + ## 0.3.72-next.1 ### Patch Changes diff --git a/plugins/app-backend/package.json b/plugins/app-backend/package.json index 2bd66c7ca0..d6ac29953e 100644 --- a/plugins/app-backend/package.json +++ b/plugins/app-backend/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-app-backend", - "version": "0.3.72-next.1", + "version": "0.3.72-next.2", "description": "A Backstage backend plugin that serves the Backstage frontend app", "backstage": { "role": "backend-plugin", diff --git a/plugins/app-node/CHANGELOG.md b/plugins/app-node/CHANGELOG.md index efd406fc95..25861bc8a1 100644 --- a/plugins/app-node/CHANGELOG.md +++ b/plugins/app-node/CHANGELOG.md @@ -1,5 +1,13 @@ # @backstage/plugin-app-node +## 0.1.23-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/config-loader@1.9.0-next.2 + ## 0.1.23-next.1 ### Patch Changes diff --git a/plugins/app-node/package.json b/plugins/app-node/package.json index 3d02ac0388..e5e4d19a47 100644 --- a/plugins/app-node/package.json +++ b/plugins/app-node/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-app-node", - "version": "0.1.23-next.1", + "version": "0.1.23-next.2", "description": "Node.js library for the app plugin", "backstage": { "role": "node-library", diff --git a/plugins/app-visualizer/CHANGELOG.md b/plugins/app-visualizer/CHANGELOG.md index 0a676a49cf..a7f8d8a012 100644 --- a/plugins/app-visualizer/CHANGELOG.md +++ b/plugins/app-visualizer/CHANGELOG.md @@ -1,5 +1,15 @@ # @backstage/plugin-app-visualizer +## 0.1.9-next.2 + +### Patch Changes + +- 72754db: Updated usage of `useRouteRef`, which can now always return `undefined`. +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + ## 0.1.9-next.1 ### Patch Changes diff --git a/plugins/app-visualizer/package.json b/plugins/app-visualizer/package.json index 784848a573..0d825be137 100644 --- a/plugins/app-visualizer/package.json +++ b/plugins/app-visualizer/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-app-visualizer", - "version": "0.1.9-next.1", + "version": "0.1.9-next.2", "description": "Visualizes the Backstage app structure", "backstage": { "role": "frontend-plugin", diff --git a/plugins/auth-backend-module-atlassian-provider/CHANGELOG.md b/plugins/auth-backend-module-atlassian-provider/CHANGELOG.md index 74b7d191c4..e2014d6749 100644 --- a/plugins/auth-backend-module-atlassian-provider/CHANGELOG.md +++ b/plugins/auth-backend-module-atlassian-provider/CHANGELOG.md @@ -1,5 +1,13 @@ # @backstage/plugin-auth-backend-module-atlassian-provider +## 0.2.4-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + ## 0.2.4-next.1 ### Patch Changes diff --git a/plugins/auth-backend-module-atlassian-provider/package.json b/plugins/auth-backend-module-atlassian-provider/package.json index c6416f1cfc..995b980124 100644 --- a/plugins/auth-backend-module-atlassian-provider/package.json +++ b/plugins/auth-backend-module-atlassian-provider/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-auth-backend-module-atlassian-provider", - "version": "0.2.4-next.1", + "version": "0.2.4-next.2", "description": "The atlassian-provider backend module for the auth plugin.", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/auth-backend-module-aws-alb-provider/CHANGELOG.md b/plugins/auth-backend-module-aws-alb-provider/CHANGELOG.md index bf64404405..ce99594759 100644 --- a/plugins/auth-backend-module-aws-alb-provider/CHANGELOG.md +++ b/plugins/auth-backend-module-aws-alb-provider/CHANGELOG.md @@ -1,5 +1,17 @@ # @backstage/plugin-auth-backend-module-aws-alb-provider +## 0.1.15-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-auth-backend@0.22.10-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/errors@1.2.4 + ## 0.1.15-next.1 ### Patch Changes diff --git a/plugins/auth-backend-module-aws-alb-provider/package.json b/plugins/auth-backend-module-aws-alb-provider/package.json index cb1649a23e..2ddace0546 100644 --- a/plugins/auth-backend-module-aws-alb-provider/package.json +++ b/plugins/auth-backend-module-aws-alb-provider/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-auth-backend-module-aws-alb-provider", - "version": "0.1.15-next.1", + "version": "0.1.15-next.2", "description": "The aws-alb provider module for the Backstage auth backend.", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/auth-backend-module-azure-easyauth-provider/CHANGELOG.md b/plugins/auth-backend-module-azure-easyauth-provider/CHANGELOG.md index cfc576d6e1..471f86842e 100644 --- a/plugins/auth-backend-module-azure-easyauth-provider/CHANGELOG.md +++ b/plugins/auth-backend-module-azure-easyauth-provider/CHANGELOG.md @@ -1,5 +1,15 @@ # @backstage/plugin-auth-backend-module-azure-easyauth-provider +## 0.1.6-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/catalog-model@1.5.0 + - @backstage/errors@1.2.4 + ## 0.1.6-next.1 ### Patch Changes diff --git a/plugins/auth-backend-module-azure-easyauth-provider/package.json b/plugins/auth-backend-module-azure-easyauth-provider/package.json index 521318cb37..f48e7ce40b 100644 --- a/plugins/auth-backend-module-azure-easyauth-provider/package.json +++ b/plugins/auth-backend-module-azure-easyauth-provider/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-auth-backend-module-azure-easyauth-provider", - "version": "0.1.6-next.1", + "version": "0.1.6-next.2", "description": "The azure-easyauth-provider backend module for the auth plugin.", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/auth-backend-module-bitbucket-provider/CHANGELOG.md b/plugins/auth-backend-module-bitbucket-provider/CHANGELOG.md index 87da903953..e70bd7f8ee 100644 --- a/plugins/auth-backend-module-bitbucket-provider/CHANGELOG.md +++ b/plugins/auth-backend-module-bitbucket-provider/CHANGELOG.md @@ -1,5 +1,13 @@ # @backstage/plugin-auth-backend-module-bitbucket-provider +## 0.1.6-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + ## 0.1.6-next.1 ### Patch Changes diff --git a/plugins/auth-backend-module-bitbucket-provider/package.json b/plugins/auth-backend-module-bitbucket-provider/package.json index 912f0c99a7..ae9692bfe8 100644 --- a/plugins/auth-backend-module-bitbucket-provider/package.json +++ b/plugins/auth-backend-module-bitbucket-provider/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-auth-backend-module-bitbucket-provider", - "version": "0.1.6-next.1", + "version": "0.1.6-next.2", "description": "The bitbucket-provider backend module for the auth plugin.", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/auth-backend-module-cloudflare-access-provider/CHANGELOG.md b/plugins/auth-backend-module-cloudflare-access-provider/CHANGELOG.md index f1423273d7..493b57d26a 100644 --- a/plugins/auth-backend-module-cloudflare-access-provider/CHANGELOG.md +++ b/plugins/auth-backend-module-cloudflare-access-provider/CHANGELOG.md @@ -1,5 +1,16 @@ # @backstage/plugin-auth-backend-module-cloudflare-access-provider +## 0.1.6-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + ## 0.1.6-next.1 ### Patch Changes diff --git a/plugins/auth-backend-module-cloudflare-access-provider/package.json b/plugins/auth-backend-module-cloudflare-access-provider/package.json index 2cd60873d3..c388ead3cb 100644 --- a/plugins/auth-backend-module-cloudflare-access-provider/package.json +++ b/plugins/auth-backend-module-cloudflare-access-provider/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-auth-backend-module-cloudflare-access-provider", - "version": "0.1.6-next.1", + "version": "0.1.6-next.2", "description": "The cloudflare-access-provider backend module for the auth plugin.", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/auth-backend-module-gcp-iap-provider/CHANGELOG.md b/plugins/auth-backend-module-gcp-iap-provider/CHANGELOG.md index 6d000cede5..3b4f24a64a 100644 --- a/plugins/auth-backend-module-gcp-iap-provider/CHANGELOG.md +++ b/plugins/auth-backend-module-gcp-iap-provider/CHANGELOG.md @@ -1,5 +1,15 @@ # @backstage/plugin-auth-backend-module-gcp-iap-provider +## 0.2.18-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + ## 0.2.18-next.1 ### Patch Changes diff --git a/plugins/auth-backend-module-gcp-iap-provider/package.json b/plugins/auth-backend-module-gcp-iap-provider/package.json index 098416f347..20b3f88606 100644 --- a/plugins/auth-backend-module-gcp-iap-provider/package.json +++ b/plugins/auth-backend-module-gcp-iap-provider/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-auth-backend-module-gcp-iap-provider", - "version": "0.2.18-next.1", + "version": "0.2.18-next.2", "description": "A GCP IAP auth provider module for the Backstage auth backend", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/auth-backend-module-github-provider/CHANGELOG.md b/plugins/auth-backend-module-github-provider/CHANGELOG.md index cb68d5ab5c..83db20aaa5 100644 --- a/plugins/auth-backend-module-github-provider/CHANGELOG.md +++ b/plugins/auth-backend-module-github-provider/CHANGELOG.md @@ -1,5 +1,13 @@ # @backstage/plugin-auth-backend-module-github-provider +## 0.1.20-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + ## 0.1.20-next.1 ### Patch Changes diff --git a/plugins/auth-backend-module-github-provider/package.json b/plugins/auth-backend-module-github-provider/package.json index 13504d3a2f..e773518782 100644 --- a/plugins/auth-backend-module-github-provider/package.json +++ b/plugins/auth-backend-module-github-provider/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-auth-backend-module-github-provider", - "version": "0.1.20-next.1", + "version": "0.1.20-next.2", "description": "The github-provider backend module for the auth plugin.", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/auth-backend-module-gitlab-provider/CHANGELOG.md b/plugins/auth-backend-module-gitlab-provider/CHANGELOG.md index 4bf32bad63..8f502140b7 100644 --- a/plugins/auth-backend-module-gitlab-provider/CHANGELOG.md +++ b/plugins/auth-backend-module-gitlab-provider/CHANGELOG.md @@ -1,5 +1,13 @@ # @backstage/plugin-auth-backend-module-gitlab-provider +## 0.1.20-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + ## 0.1.20-next.1 ### Patch Changes diff --git a/plugins/auth-backend-module-gitlab-provider/package.json b/plugins/auth-backend-module-gitlab-provider/package.json index c77669aaac..88fd39a53b 100644 --- a/plugins/auth-backend-module-gitlab-provider/package.json +++ b/plugins/auth-backend-module-gitlab-provider/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-auth-backend-module-gitlab-provider", - "version": "0.1.20-next.1", + "version": "0.1.20-next.2", "description": "The gitlab-provider backend module for the auth plugin.", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/auth-backend-module-google-provider/CHANGELOG.md b/plugins/auth-backend-module-google-provider/CHANGELOG.md index 08739b52cf..64d59dc5aa 100644 --- a/plugins/auth-backend-module-google-provider/CHANGELOG.md +++ b/plugins/auth-backend-module-google-provider/CHANGELOG.md @@ -1,5 +1,13 @@ # @backstage/plugin-auth-backend-module-google-provider +## 0.1.20-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + ## 0.1.20-next.1 ### Patch Changes diff --git a/plugins/auth-backend-module-google-provider/package.json b/plugins/auth-backend-module-google-provider/package.json index 209a422980..ed2e536396 100644 --- a/plugins/auth-backend-module-google-provider/package.json +++ b/plugins/auth-backend-module-google-provider/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-auth-backend-module-google-provider", - "version": "0.1.20-next.1", + "version": "0.1.20-next.2", "description": "A Google auth provider module for the Backstage auth backend", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/auth-backend-module-guest-provider/CHANGELOG.md b/plugins/auth-backend-module-guest-provider/CHANGELOG.md index 94904ce214..4c5df385c7 100644 --- a/plugins/auth-backend-module-guest-provider/CHANGELOG.md +++ b/plugins/auth-backend-module-guest-provider/CHANGELOG.md @@ -1,5 +1,16 @@ # @backstage/plugin-auth-backend-module-guest-provider +## 0.1.9-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/catalog-model@1.5.0 + - @backstage/errors@1.2.4 + ## 0.1.9-next.1 ### Patch Changes diff --git a/plugins/auth-backend-module-guest-provider/package.json b/plugins/auth-backend-module-guest-provider/package.json index 9ddc9f5877..d41612d32a 100644 --- a/plugins/auth-backend-module-guest-provider/package.json +++ b/plugins/auth-backend-module-guest-provider/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-auth-backend-module-guest-provider", - "version": "0.1.9-next.1", + "version": "0.1.9-next.2", "description": "The guest-provider backend module for the auth plugin.", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/auth-backend-module-microsoft-provider/CHANGELOG.md b/plugins/auth-backend-module-microsoft-provider/CHANGELOG.md index 4e640b0b73..9bbf02ba3c 100644 --- a/plugins/auth-backend-module-microsoft-provider/CHANGELOG.md +++ b/plugins/auth-backend-module-microsoft-provider/CHANGELOG.md @@ -1,5 +1,14 @@ # @backstage/plugin-auth-backend-module-microsoft-provider +## 0.1.18-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + ## 0.1.18-next.1 ### Patch Changes diff --git a/plugins/auth-backend-module-microsoft-provider/package.json b/plugins/auth-backend-module-microsoft-provider/package.json index e80adbac1a..f18104ba15 100644 --- a/plugins/auth-backend-module-microsoft-provider/package.json +++ b/plugins/auth-backend-module-microsoft-provider/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-auth-backend-module-microsoft-provider", - "version": "0.1.18-next.1", + "version": "0.1.18-next.2", "description": "The microsoft-provider backend module for the auth plugin.", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/auth-backend-module-oauth2-provider/CHANGELOG.md b/plugins/auth-backend-module-oauth2-provider/CHANGELOG.md index 066695c188..63c6662332 100644 --- a/plugins/auth-backend-module-oauth2-provider/CHANGELOG.md +++ b/plugins/auth-backend-module-oauth2-provider/CHANGELOG.md @@ -1,5 +1,13 @@ # @backstage/plugin-auth-backend-module-oauth2-provider +## 0.2.4-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + ## 0.2.4-next.1 ### Patch Changes diff --git a/plugins/auth-backend-module-oauth2-provider/package.json b/plugins/auth-backend-module-oauth2-provider/package.json index b475437611..77a00a52d6 100644 --- a/plugins/auth-backend-module-oauth2-provider/package.json +++ b/plugins/auth-backend-module-oauth2-provider/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-auth-backend-module-oauth2-provider", - "version": "0.2.4-next.1", + "version": "0.2.4-next.2", "description": "The oauth2-provider backend module for the auth plugin.", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/auth-backend-module-oauth2-proxy-provider/CHANGELOG.md b/plugins/auth-backend-module-oauth2-proxy-provider/CHANGELOG.md index acad1b96a8..a9d6523201 100644 --- a/plugins/auth-backend-module-oauth2-proxy-provider/CHANGELOG.md +++ b/plugins/auth-backend-module-oauth2-proxy-provider/CHANGELOG.md @@ -1,5 +1,14 @@ # @backstage/plugin-auth-backend-module-oauth2-proxy-provider +## 0.1.16-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/errors@1.2.4 + ## 0.1.16-next.1 ### Patch Changes diff --git a/plugins/auth-backend-module-oauth2-proxy-provider/package.json b/plugins/auth-backend-module-oauth2-proxy-provider/package.json index ff6d31ebee..4df4e14dfe 100644 --- a/plugins/auth-backend-module-oauth2-proxy-provider/package.json +++ b/plugins/auth-backend-module-oauth2-proxy-provider/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-auth-backend-module-oauth2-proxy-provider", - "version": "0.1.16-next.1", + "version": "0.1.16-next.2", "description": "The oauth2-proxy-provider backend module for the auth plugin.", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/auth-backend-module-oidc-provider/CHANGELOG.md b/plugins/auth-backend-module-oidc-provider/CHANGELOG.md index b0686455b5..6c32155ebe 100644 --- a/plugins/auth-backend-module-oidc-provider/CHANGELOG.md +++ b/plugins/auth-backend-module-oidc-provider/CHANGELOG.md @@ -1,5 +1,15 @@ # @backstage/plugin-auth-backend-module-oidc-provider +## 0.2.4-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-auth-backend@0.22.10-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + ## 0.2.4-next.1 ### Patch Changes diff --git a/plugins/auth-backend-module-oidc-provider/package.json b/plugins/auth-backend-module-oidc-provider/package.json index 90fd9c4b63..5f59a4e0d1 100644 --- a/plugins/auth-backend-module-oidc-provider/package.json +++ b/plugins/auth-backend-module-oidc-provider/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-auth-backend-module-oidc-provider", - "version": "0.2.4-next.1", + "version": "0.2.4-next.2", "description": "The oidc-provider backend module for the auth plugin.", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/auth-backend-module-okta-provider/CHANGELOG.md b/plugins/auth-backend-module-okta-provider/CHANGELOG.md index 12266f8aba..38fe3bed5d 100644 --- a/plugins/auth-backend-module-okta-provider/CHANGELOG.md +++ b/plugins/auth-backend-module-okta-provider/CHANGELOG.md @@ -1,5 +1,13 @@ # @backstage/plugin-auth-backend-module-okta-provider +## 0.0.16-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + ## 0.0.16-next.1 ### Patch Changes diff --git a/plugins/auth-backend-module-okta-provider/package.json b/plugins/auth-backend-module-okta-provider/package.json index a2460cc5f3..ad0c5c5ecb 100644 --- a/plugins/auth-backend-module-okta-provider/package.json +++ b/plugins/auth-backend-module-okta-provider/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-auth-backend-module-okta-provider", - "version": "0.0.16-next.1", + "version": "0.0.16-next.2", "description": "The okta-provider backend module for the auth plugin.", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/auth-backend-module-onelogin-provider/CHANGELOG.md b/plugins/auth-backend-module-onelogin-provider/CHANGELOG.md index b2ab669eca..476df484d2 100644 --- a/plugins/auth-backend-module-onelogin-provider/CHANGELOG.md +++ b/plugins/auth-backend-module-onelogin-provider/CHANGELOG.md @@ -1,5 +1,13 @@ # @backstage/plugin-auth-backend-module-onelogin-provider +## 0.1.4-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + ## 0.1.4-next.1 ### Patch Changes diff --git a/plugins/auth-backend-module-onelogin-provider/package.json b/plugins/auth-backend-module-onelogin-provider/package.json index c299519e45..1d1feee009 100644 --- a/plugins/auth-backend-module-onelogin-provider/package.json +++ b/plugins/auth-backend-module-onelogin-provider/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-auth-backend-module-onelogin-provider", - "version": "0.1.4-next.1", + "version": "0.1.4-next.2", "description": "The onelogin-provider backend module for the auth plugin.", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/auth-backend-module-pinniped-provider/CHANGELOG.md b/plugins/auth-backend-module-pinniped-provider/CHANGELOG.md index 3dcce4d28f..8b23915d26 100644 --- a/plugins/auth-backend-module-pinniped-provider/CHANGELOG.md +++ b/plugins/auth-backend-module-pinniped-provider/CHANGELOG.md @@ -1,5 +1,14 @@ # @backstage/plugin-auth-backend-module-pinniped-provider +## 0.1.17-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/config@1.2.0 + ## 0.1.17-next.1 ### Patch Changes diff --git a/plugins/auth-backend-module-pinniped-provider/package.json b/plugins/auth-backend-module-pinniped-provider/package.json index a33c321292..c720d9b501 100644 --- a/plugins/auth-backend-module-pinniped-provider/package.json +++ b/plugins/auth-backend-module-pinniped-provider/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-auth-backend-module-pinniped-provider", - "version": "0.1.17-next.1", + "version": "0.1.17-next.2", "description": "The pinniped-provider backend module for the auth plugin.", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/auth-backend-module-vmware-cloud-provider/CHANGELOG.md b/plugins/auth-backend-module-vmware-cloud-provider/CHANGELOG.md index cc50745204..9f81a53961 100644 --- a/plugins/auth-backend-module-vmware-cloud-provider/CHANGELOG.md +++ b/plugins/auth-backend-module-vmware-cloud-provider/CHANGELOG.md @@ -1,5 +1,14 @@ # @backstage/plugin-auth-backend-module-vmware-cloud-provider +## 0.2.4-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/catalog-model@1.5.0 + ## 0.2.4-next.1 ### Patch Changes diff --git a/plugins/auth-backend-module-vmware-cloud-provider/package.json b/plugins/auth-backend-module-vmware-cloud-provider/package.json index 8fcf5fb2a4..166b7e8e82 100644 --- a/plugins/auth-backend-module-vmware-cloud-provider/package.json +++ b/plugins/auth-backend-module-vmware-cloud-provider/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-auth-backend-module-vmware-cloud-provider", - "version": "0.2.4-next.1", + "version": "0.2.4-next.2", "description": "The vmware-cloud-provider backend module for the auth plugin.", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/auth-backend/CHANGELOG.md b/plugins/auth-backend/CHANGELOG.md index d17fdabb26..f99c8d0453 100644 --- a/plugins/auth-backend/CHANGELOG.md +++ b/plugins/auth-backend/CHANGELOG.md @@ -1,5 +1,36 @@ # @backstage/plugin-auth-backend +## 0.22.10-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-auth-backend-module-cloudflare-access-provider@0.1.6-next.2 + - @backstage/plugin-auth-backend-module-microsoft-provider@0.1.18-next.2 + - @backstage/plugin-auth-backend-module-aws-alb-provider@0.1.15-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-auth-backend-module-atlassian-provider@0.2.4-next.2 + - @backstage/plugin-auth-backend-module-bitbucket-provider@0.1.6-next.2 + - @backstage/plugin-auth-backend-module-github-provider@0.1.20-next.2 + - @backstage/plugin-auth-backend-module-gitlab-provider@0.1.20-next.2 + - @backstage/plugin-auth-backend-module-oauth2-provider@0.2.4-next.2 + - @backstage/plugin-auth-backend-module-oidc-provider@0.2.4-next.2 + - @backstage/plugin-auth-backend-module-okta-provider@0.0.16-next.2 + - @backstage/plugin-auth-backend-module-onelogin-provider@0.1.4-next.2 + - @backstage/plugin-auth-backend-module-azure-easyauth-provider@0.1.6-next.2 + - @backstage/plugin-auth-backend-module-gcp-iap-provider@0.2.18-next.2 + - @backstage/plugin-auth-backend-module-google-provider@0.1.20-next.2 + - @backstage/plugin-auth-backend-module-oauth2-proxy-provider@0.1.16-next.2 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + ## 0.22.10-next.1 ### Patch Changes diff --git a/plugins/auth-backend/package.json b/plugins/auth-backend/package.json index 8a3d2966a8..8dec959418 100644 --- a/plugins/auth-backend/package.json +++ b/plugins/auth-backend/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-auth-backend", - "version": "0.22.10-next.1", + "version": "0.22.10-next.2", "description": "A Backstage backend plugin that handles authentication", "backstage": { "role": "backend-plugin", diff --git a/plugins/auth-node/CHANGELOG.md b/plugins/auth-node/CHANGELOG.md index e8b2a4f4b9..1905329e0a 100644 --- a/plugins/auth-node/CHANGELOG.md +++ b/plugins/auth-node/CHANGELOG.md @@ -1,5 +1,23 @@ # @backstage/plugin-auth-node +## 0.5.0-next.2 + +### Minor Changes + +- 579afd0: **BREAKING**: Sign-in resolvers configured via `.signIn.resolvers` now take precedence over sign-in resolvers passed to `signInResolver` option of `createOAuthProviderFactory`. This effectively makes sign-in resolvers passed via the `signInResolver` the default one, which you can then override through configuration. + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + ## 0.4.18-next.1 ### Patch Changes diff --git a/plugins/auth-node/package.json b/plugins/auth-node/package.json index bb0057f42a..348db40dd7 100644 --- a/plugins/auth-node/package.json +++ b/plugins/auth-node/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-auth-node", - "version": "0.4.18-next.1", + "version": "0.5.0-next.2", "backstage": { "role": "node-library", "pluginId": "auth", diff --git a/plugins/bitbucket-cloud-common/CHANGELOG.md b/plugins/bitbucket-cloud-common/CHANGELOG.md index c4ce7148f4..30e2e77a6e 100644 --- a/plugins/bitbucket-cloud-common/CHANGELOG.md +++ b/plugins/bitbucket-cloud-common/CHANGELOG.md @@ -1,5 +1,13 @@ # @backstage/plugin-bitbucket-cloud-common +## 0.2.22-next.1 + +### Patch Changes + +- 3fca643: Added method `listBranchesByRepository` to `BitbucketCloudClient` +- Updated dependencies + - @backstage/integration@1.14.0-next.0 + ## 0.2.22-next.0 ### Patch Changes diff --git a/plugins/bitbucket-cloud-common/package.json b/plugins/bitbucket-cloud-common/package.json index 06fd4e6f3a..d2f22cc966 100644 --- a/plugins/bitbucket-cloud-common/package.json +++ b/plugins/bitbucket-cloud-common/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-bitbucket-cloud-common", - "version": "0.2.22-next.0", + "version": "0.2.22-next.1", "description": "Common functionalities for bitbucket-cloud plugins", "backstage": { "role": "common-library", diff --git a/plugins/catalog-backend-module-aws/CHANGELOG.md b/plugins/catalog-backend-module-aws/CHANGELOG.md index 705712aac6..69c16e9875 100644 --- a/plugins/catalog-backend-module-aws/CHANGELOG.md +++ b/plugins/catalog-backend-module-aws/CHANGELOG.md @@ -1,5 +1,22 @@ # @backstage/plugin-catalog-backend-module-aws +## 0.3.18-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/plugin-kubernetes-common@0.8.2-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/integration-aws-node@0.1.12 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + ## 0.3.18-next.1 ### Patch Changes diff --git a/plugins/catalog-backend-module-aws/package.json b/plugins/catalog-backend-module-aws/package.json index 96c57eb821..443dfebb87 100644 --- a/plugins/catalog-backend-module-aws/package.json +++ b/plugins/catalog-backend-module-aws/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-catalog-backend-module-aws", - "version": "0.3.18-next.1", + "version": "0.3.18-next.2", "description": "A Backstage catalog backend module that helps integrate towards AWS", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/catalog-backend-module-azure/CHANGELOG.md b/plugins/catalog-backend-module-azure/CHANGELOG.md index d7b4c90862..89d6847511 100644 --- a/plugins/catalog-backend-module-azure/CHANGELOG.md +++ b/plugins/catalog-backend-module-azure/CHANGELOG.md @@ -1,5 +1,19 @@ # @backstage/plugin-catalog-backend-module-azure +## 0.1.43-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + ## 0.1.43-next.1 ### Patch Changes diff --git a/plugins/catalog-backend-module-azure/package.json b/plugins/catalog-backend-module-azure/package.json index 39f889cb54..de18ae5895 100644 --- a/plugins/catalog-backend-module-azure/package.json +++ b/plugins/catalog-backend-module-azure/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-catalog-backend-module-azure", - "version": "0.1.43-next.1", + "version": "0.1.43-next.2", "description": "A Backstage catalog backend module that helps integrate towards Azure", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/catalog-backend-module-backstage-openapi/CHANGELOG.md b/plugins/catalog-backend-module-backstage-openapi/CHANGELOG.md index 17b20064ba..771702d86d 100644 --- a/plugins/catalog-backend-module-backstage-openapi/CHANGELOG.md +++ b/plugins/catalog-backend-module-backstage-openapi/CHANGELOG.md @@ -1,5 +1,18 @@ # @backstage/plugin-catalog-backend-module-backstage-openapi +## 0.2.6-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/backend-openapi-utils@0.1.16-next.2 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + ## 0.2.6-next.1 ### Patch Changes diff --git a/plugins/catalog-backend-module-backstage-openapi/package.json b/plugins/catalog-backend-module-backstage-openapi/package.json index d854bbd8e5..d9ba70c806 100644 --- a/plugins/catalog-backend-module-backstage-openapi/package.json +++ b/plugins/catalog-backend-module-backstage-openapi/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-catalog-backend-module-backstage-openapi", - "version": "0.2.6-next.1", + "version": "0.2.6-next.2", "backstage": { "role": "backend-plugin-module", "pluginId": "catalog", diff --git a/plugins/catalog-backend-module-bitbucket-cloud/CHANGELOG.md b/plugins/catalog-backend-module-bitbucket-cloud/CHANGELOG.md index 58c54afce9..ec27de045c 100644 --- a/plugins/catalog-backend-module-bitbucket-cloud/CHANGELOG.md +++ b/plugins/catalog-backend-module-bitbucket-cloud/CHANGELOG.md @@ -1,5 +1,22 @@ # @backstage/plugin-catalog-backend-module-bitbucket-cloud +## 0.2.10-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-bitbucket-cloud-common@0.2.22-next.1 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + ## 0.2.10-next.1 ### Patch Changes diff --git a/plugins/catalog-backend-module-bitbucket-cloud/package.json b/plugins/catalog-backend-module-bitbucket-cloud/package.json index 03ae26f4c2..3f4389788c 100644 --- a/plugins/catalog-backend-module-bitbucket-cloud/package.json +++ b/plugins/catalog-backend-module-bitbucket-cloud/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-catalog-backend-module-bitbucket-cloud", - "version": "0.2.10-next.1", + "version": "0.2.10-next.2", "description": "A Backstage catalog backend module that helps integrate towards Bitbucket Cloud", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/catalog-backend-module-bitbucket-server/CHANGELOG.md b/plugins/catalog-backend-module-bitbucket-server/CHANGELOG.md index 762d73c1b6..46469b747a 100644 --- a/plugins/catalog-backend-module-bitbucket-server/CHANGELOG.md +++ b/plugins/catalog-backend-module-bitbucket-server/CHANGELOG.md @@ -1,5 +1,20 @@ # @backstage/plugin-catalog-backend-module-bitbucket-server +## 0.1.37-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + ## 0.1.37-next.1 ### Patch Changes diff --git a/plugins/catalog-backend-module-bitbucket-server/package.json b/plugins/catalog-backend-module-bitbucket-server/package.json index 7d6f1a38b3..eeafae91d5 100644 --- a/plugins/catalog-backend-module-bitbucket-server/package.json +++ b/plugins/catalog-backend-module-bitbucket-server/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-catalog-backend-module-bitbucket-server", - "version": "0.1.37-next.1", + "version": "0.1.37-next.2", "backstage": { "role": "backend-plugin-module", "pluginId": "catalog", diff --git a/plugins/catalog-backend-module-gcp/CHANGELOG.md b/plugins/catalog-backend-module-gcp/CHANGELOG.md index 0a5ed326fd..f5f805edd9 100644 --- a/plugins/catalog-backend-module-gcp/CHANGELOG.md +++ b/plugins/catalog-backend-module-gcp/CHANGELOG.md @@ -1,5 +1,18 @@ # @backstage/plugin-catalog-backend-module-gcp +## 0.1.24-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-kubernetes-common@0.8.2-next.1 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + ## 0.1.24-next.1 ### Patch Changes diff --git a/plugins/catalog-backend-module-gcp/package.json b/plugins/catalog-backend-module-gcp/package.json index 9abc3da395..0673dd1805 100644 --- a/plugins/catalog-backend-module-gcp/package.json +++ b/plugins/catalog-backend-module-gcp/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-catalog-backend-module-gcp", - "version": "0.1.24-next.1", + "version": "0.1.24-next.2", "description": "A Backstage catalog backend module that helps integrate towards GCP", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/catalog-backend-module-gerrit/CHANGELOG.md b/plugins/catalog-backend-module-gerrit/CHANGELOG.md index 78f6172a3d..d4b173cc3f 100644 --- a/plugins/catalog-backend-module-gerrit/CHANGELOG.md +++ b/plugins/catalog-backend-module-gerrit/CHANGELOG.md @@ -1,5 +1,19 @@ # @backstage/plugin-catalog-backend-module-gerrit +## 0.1.40-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + ## 0.1.40-next.1 ### Patch Changes diff --git a/plugins/catalog-backend-module-gerrit/package.json b/plugins/catalog-backend-module-gerrit/package.json index 6358590dae..b10e48d34b 100644 --- a/plugins/catalog-backend-module-gerrit/package.json +++ b/plugins/catalog-backend-module-gerrit/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-catalog-backend-module-gerrit", - "version": "0.1.40-next.1", + "version": "0.1.40-next.2", "backstage": { "role": "backend-plugin-module", "pluginId": "catalog", diff --git a/plugins/catalog-backend-module-github-org/CHANGELOG.md b/plugins/catalog-backend-module-github-org/CHANGELOG.md index f0f37b1c03..ebaa50af30 100644 --- a/plugins/catalog-backend-module-github-org/CHANGELOG.md +++ b/plugins/catalog-backend-module-github-org/CHANGELOG.md @@ -1,5 +1,18 @@ # @backstage/plugin-catalog-backend-module-github-org +## 0.1.18-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-catalog-backend-module-github@0.6.6-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/config@1.2.0 + ## 0.1.18-next.1 ### Patch Changes diff --git a/plugins/catalog-backend-module-github-org/package.json b/plugins/catalog-backend-module-github-org/package.json index 562b20401a..e1f60aec67 100644 --- a/plugins/catalog-backend-module-github-org/package.json +++ b/plugins/catalog-backend-module-github-org/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-catalog-backend-module-github-org", - "version": "0.1.18-next.1", + "version": "0.1.18-next.2", "description": "The github-org backend module for the catalog plugin.", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/catalog-backend-module-github/CHANGELOG.md b/plugins/catalog-backend-module-github/CHANGELOG.md index e42812d75d..c7a032c43e 100644 --- a/plugins/catalog-backend-module-github/CHANGELOG.md +++ b/plugins/catalog-backend-module-github/CHANGELOG.md @@ -1,5 +1,23 @@ # @backstage/plugin-catalog-backend-module-github +## 0.6.6-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-catalog-backend@1.24.1-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + ## 0.6.6-next.1 ### Patch Changes diff --git a/plugins/catalog-backend-module-github/package.json b/plugins/catalog-backend-module-github/package.json index c6af27c2ce..dfde8e9718 100644 --- a/plugins/catalog-backend-module-github/package.json +++ b/plugins/catalog-backend-module-github/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-catalog-backend-module-github", - "version": "0.6.6-next.1", + "version": "0.6.6-next.2", "description": "A Backstage catalog backend module that helps integrate towards GitHub", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/catalog-backend-module-gitlab-org/CHANGELOG.md b/plugins/catalog-backend-module-gitlab-org/CHANGELOG.md index 33ce83336c..5611260f87 100644 --- a/plugins/catalog-backend-module-gitlab-org/CHANGELOG.md +++ b/plugins/catalog-backend-module-gitlab-org/CHANGELOG.md @@ -1,5 +1,16 @@ # @backstage/plugin-catalog-backend-module-gitlab-org +## 0.0.6-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-catalog-backend-module-gitlab@0.3.22-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + ## 0.0.6-next.1 ### Patch Changes diff --git a/plugins/catalog-backend-module-gitlab-org/package.json b/plugins/catalog-backend-module-gitlab-org/package.json index 79c43d6529..68e1c8f252 100644 --- a/plugins/catalog-backend-module-gitlab-org/package.json +++ b/plugins/catalog-backend-module-gitlab-org/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-catalog-backend-module-gitlab-org", - "version": "0.0.6-next.1", + "version": "0.0.6-next.2", "description": "The gitlab-org backend module for the catalog plugin.", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/catalog-backend-module-gitlab/CHANGELOG.md b/plugins/catalog-backend-module-gitlab/CHANGELOG.md index 2b8cffa0d6..737f79de59 100644 --- a/plugins/catalog-backend-module-gitlab/CHANGELOG.md +++ b/plugins/catalog-backend-module-gitlab/CHANGELOG.md @@ -1,5 +1,21 @@ # @backstage/plugin-catalog-backend-module-gitlab +## 0.3.22-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + ## 0.3.22-next.1 ### Patch Changes diff --git a/plugins/catalog-backend-module-gitlab/package.json b/plugins/catalog-backend-module-gitlab/package.json index 2b44a0b75e..d15deafd08 100644 --- a/plugins/catalog-backend-module-gitlab/package.json +++ b/plugins/catalog-backend-module-gitlab/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-catalog-backend-module-gitlab", - "version": "0.3.22-next.1", + "version": "0.3.22-next.2", "description": "A Backstage catalog backend module that helps integrate towards GitLab", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/catalog-backend-module-incremental-ingestion/CHANGELOG.md b/plugins/catalog-backend-module-incremental-ingestion/CHANGELOG.md index d43ff7902d..e56e14b95f 100644 --- a/plugins/catalog-backend-module-incremental-ingestion/CHANGELOG.md +++ b/plugins/catalog-backend-module-incremental-ingestion/CHANGELOG.md @@ -1,5 +1,21 @@ # @backstage/plugin-catalog-backend-module-incremental-ingestion +## 0.4.28-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-catalog-backend@1.24.1-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + ## 0.4.28-next.1 ### Patch Changes diff --git a/plugins/catalog-backend-module-incremental-ingestion/package.json b/plugins/catalog-backend-module-incremental-ingestion/package.json index 8d3d25188d..f3744d9b07 100644 --- a/plugins/catalog-backend-module-incremental-ingestion/package.json +++ b/plugins/catalog-backend-module-incremental-ingestion/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-catalog-backend-module-incremental-ingestion", - "version": "0.4.28-next.1", + "version": "0.4.28-next.2", "description": "An entity provider for streaming large asset sources into the catalog", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/catalog-backend-module-ldap/CHANGELOG.md b/plugins/catalog-backend-module-ldap/CHANGELOG.md index a93f095557..8b8907bd7b 100644 --- a/plugins/catalog-backend-module-ldap/CHANGELOG.md +++ b/plugins/catalog-backend-module-ldap/CHANGELOG.md @@ -1,5 +1,19 @@ # @backstage/plugin-catalog-backend-module-ldap +## 0.7.1-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + ## 0.7.1-next.1 ### Patch Changes diff --git a/plugins/catalog-backend-module-ldap/package.json b/plugins/catalog-backend-module-ldap/package.json index efda8a6b40..fa627cb55f 100644 --- a/plugins/catalog-backend-module-ldap/package.json +++ b/plugins/catalog-backend-module-ldap/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-catalog-backend-module-ldap", - "version": "0.7.1-next.1", + "version": "0.7.1-next.2", "description": "A Backstage catalog backend module that helps integrate towards LDAP", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/catalog-backend-module-logs/CHANGELOG.md b/plugins/catalog-backend-module-logs/CHANGELOG.md index a62e7d7984..4637f19052 100644 --- a/plugins/catalog-backend-module-logs/CHANGELOG.md +++ b/plugins/catalog-backend-module-logs/CHANGELOG.md @@ -1,5 +1,14 @@ # @backstage/plugin-catalog-backend-module-logs +## 0.0.2-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-catalog-backend@1.24.1-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + ## 0.0.2-next.1 ### Patch Changes diff --git a/plugins/catalog-backend-module-logs/package.json b/plugins/catalog-backend-module-logs/package.json index 2cf01d9e2c..a6609c7227 100644 --- a/plugins/catalog-backend-module-logs/package.json +++ b/plugins/catalog-backend-module-logs/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-catalog-backend-module-logs", - "version": "0.0.2-next.1", + "version": "0.0.2-next.2", "description": "A module that subscribes to catalog releated events and logs them.", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/catalog-backend-module-msgraph/CHANGELOG.md b/plugins/catalog-backend-module-msgraph/CHANGELOG.md index 86bf7e2e45..2efe171ec1 100644 --- a/plugins/catalog-backend-module-msgraph/CHANGELOG.md +++ b/plugins/catalog-backend-module-msgraph/CHANGELOG.md @@ -1,5 +1,19 @@ # @backstage/plugin-catalog-backend-module-msgraph +## 0.5.31-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + ## 0.5.31-next.1 ### Patch Changes diff --git a/plugins/catalog-backend-module-msgraph/package.json b/plugins/catalog-backend-module-msgraph/package.json index a889d6a22a..daba6c4b9f 100644 --- a/plugins/catalog-backend-module-msgraph/package.json +++ b/plugins/catalog-backend-module-msgraph/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-catalog-backend-module-msgraph", - "version": "0.5.31-next.1", + "version": "0.5.31-next.2", "description": "A Backstage catalog backend module that helps integrate towards Microsoft Graph", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/catalog-backend-module-openapi/CHANGELOG.md b/plugins/catalog-backend-module-openapi/CHANGELOG.md index 8daf794314..eb0dbcf08d 100644 --- a/plugins/catalog-backend-module-openapi/CHANGELOG.md +++ b/plugins/catalog-backend-module-openapi/CHANGELOG.md @@ -1,5 +1,20 @@ # @backstage/plugin-catalog-backend-module-openapi +## 0.1.41-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-catalog-backend@1.24.1-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/types@1.1.1 + ## 0.1.41-next.1 ### Patch Changes diff --git a/plugins/catalog-backend-module-openapi/package.json b/plugins/catalog-backend-module-openapi/package.json index c6147804f9..aa4ec5a803 100644 --- a/plugins/catalog-backend-module-openapi/package.json +++ b/plugins/catalog-backend-module-openapi/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-catalog-backend-module-openapi", - "version": "0.1.41-next.1", + "version": "0.1.41-next.2", "description": "A Backstage catalog backend module that helps with OpenAPI specifications", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/catalog-backend-module-puppetdb/CHANGELOG.md b/plugins/catalog-backend-module-puppetdb/CHANGELOG.md index 924e0a9df0..209160b4e1 100644 --- a/plugins/catalog-backend-module-puppetdb/CHANGELOG.md +++ b/plugins/catalog-backend-module-puppetdb/CHANGELOG.md @@ -1,5 +1,20 @@ # @backstage/plugin-catalog-backend-module-puppetdb +## 0.1.29-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + ## 0.1.29-next.1 ### Patch Changes diff --git a/plugins/catalog-backend-module-puppetdb/package.json b/plugins/catalog-backend-module-puppetdb/package.json index fd9384b567..977379fefa 100644 --- a/plugins/catalog-backend-module-puppetdb/package.json +++ b/plugins/catalog-backend-module-puppetdb/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-catalog-backend-module-puppetdb", - "version": "0.1.29-next.1", + "version": "0.1.29-next.2", "description": "A Backstage catalog backend module that helps integrate towards PuppetDB", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/catalog-backend-module-scaffolder-entity-model/CHANGELOG.md b/plugins/catalog-backend-module-scaffolder-entity-model/CHANGELOG.md index 262105e62a..0813e4b6ab 100644 --- a/plugins/catalog-backend-module-scaffolder-entity-model/CHANGELOG.md +++ b/plugins/catalog-backend-module-scaffolder-entity-model/CHANGELOG.md @@ -1,5 +1,16 @@ # @backstage/plugin-catalog-backend-module-scaffolder-entity-model +## 0.1.21-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/plugin-scaffolder-common@1.5.5-next.1 + - @backstage/catalog-model@1.5.0 + ## 0.1.21-next.1 ### Patch Changes diff --git a/plugins/catalog-backend-module-scaffolder-entity-model/package.json b/plugins/catalog-backend-module-scaffolder-entity-model/package.json index 0b3b1a9534..02c8a09ae9 100644 --- a/plugins/catalog-backend-module-scaffolder-entity-model/package.json +++ b/plugins/catalog-backend-module-scaffolder-entity-model/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-catalog-backend-module-scaffolder-entity-model", - "version": "0.1.21-next.1", + "version": "0.1.21-next.2", "description": "Adds support for the scaffolder specific entity model (e.g. the Template kind) to the catalog backend plugin.", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/catalog-backend-module-unprocessed/CHANGELOG.md b/plugins/catalog-backend-module-unprocessed/CHANGELOG.md index 435637c3d8..37413e5f02 100644 --- a/plugins/catalog-backend-module-unprocessed/CHANGELOG.md +++ b/plugins/catalog-backend-module-unprocessed/CHANGELOG.md @@ -1,5 +1,19 @@ # @backstage/plugin-catalog-backend-module-unprocessed +## 0.4.10-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-catalog-unprocessed-entities-common@0.0.4-next.1 + - @backstage/catalog-model@1.5.0 + - @backstage/errors@1.2.4 + ## 0.4.10-next.1 ### Patch Changes diff --git a/plugins/catalog-backend-module-unprocessed/package.json b/plugins/catalog-backend-module-unprocessed/package.json index a1078106eb..eaf86d75ed 100644 --- a/plugins/catalog-backend-module-unprocessed/package.json +++ b/plugins/catalog-backend-module-unprocessed/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-catalog-backend-module-unprocessed", - "version": "0.4.10-next.1", + "version": "0.4.10-next.2", "description": "Backstage Catalog module to view unprocessed entities", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/catalog-backend/CHANGELOG.md b/plugins/catalog-backend/CHANGELOG.md index 826f0c5897..fe707b2a9a 100644 --- a/plugins/catalog-backend/CHANGELOG.md +++ b/plugins/catalog-backend/CHANGELOG.md @@ -1,5 +1,28 @@ # @backstage/plugin-catalog-backend +## 1.24.1-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-permission-node@0.8.1-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/backend-openapi-utils@0.1.16-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/plugin-search-backend-module-catalog@0.1.29-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + ## 1.24.1-next.1 ### Patch Changes diff --git a/plugins/catalog-backend/package.json b/plugins/catalog-backend/package.json index cb3cc31cca..0a046b43e4 100644 --- a/plugins/catalog-backend/package.json +++ b/plugins/catalog-backend/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-catalog-backend", - "version": "1.24.1-next.1", + "version": "1.24.1-next.2", "description": "The Backstage backend plugin that provides the Backstage catalog", "backstage": { "role": "backend-plugin", diff --git a/plugins/catalog-common/CHANGELOG.md b/plugins/catalog-common/CHANGELOG.md index 615bcc538e..2d0fde55da 100644 --- a/plugins/catalog-common/CHANGELOG.md +++ b/plugins/catalog-common/CHANGELOG.md @@ -1,5 +1,14 @@ # @backstage/plugin-catalog-common +## 1.0.26-next.1 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/catalog-model@1.5.0 + ## 1.0.26-next.0 ### Patch Changes diff --git a/plugins/catalog-common/package.json b/plugins/catalog-common/package.json index 167c1b0a91..cfcfee74d8 100644 --- a/plugins/catalog-common/package.json +++ b/plugins/catalog-common/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-catalog-common", - "version": "1.0.26-next.0", + "version": "1.0.26-next.1", "description": "Common functionalities for the catalog plugin", "backstage": { "role": "common-library", diff --git a/plugins/catalog-graph/CHANGELOG.md b/plugins/catalog-graph/CHANGELOG.md index 5648055a3e..695af8d4fe 100644 --- a/plugins/catalog-graph/CHANGELOG.md +++ b/plugins/catalog-graph/CHANGELOG.md @@ -1,5 +1,19 @@ # @backstage/plugin-catalog-graph +## 0.4.8-next.3 + +### Patch Changes + +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-compat-api@0.2.8-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/types@1.1.1 + ## 0.4.8-next.2 ### Patch Changes diff --git a/plugins/catalog-graph/package.json b/plugins/catalog-graph/package.json index 04fe835f5c..08a5497dc0 100644 --- a/plugins/catalog-graph/package.json +++ b/plugins/catalog-graph/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-catalog-graph", - "version": "0.4.8-next.2", + "version": "0.4.8-next.3", "backstage": { "role": "frontend-plugin", "pluginId": "catalog-graph", diff --git a/plugins/catalog-import/CHANGELOG.md b/plugins/catalog-import/CHANGELOG.md index 43e132823a..2063f9e2f9 100644 --- a/plugins/catalog-import/CHANGELOG.md +++ b/plugins/catalog-import/CHANGELOG.md @@ -1,5 +1,23 @@ # @backstage/plugin-catalog-import +## 0.12.2-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-compat-api@0.2.8-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/errors@1.2.4 + - @backstage/integration-react@1.1.30-next.0 + ## 0.12.2-next.1 ### Patch Changes diff --git a/plugins/catalog-import/package.json b/plugins/catalog-import/package.json index 397d3c92d9..44076a3fbc 100644 --- a/plugins/catalog-import/package.json +++ b/plugins/catalog-import/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-catalog-import", - "version": "0.12.2-next.1", + "version": "0.12.2-next.2", "description": "A Backstage plugin the helps you import entities into your catalog", "backstage": { "role": "frontend-plugin", diff --git a/plugins/catalog-node/CHANGELOG.md b/plugins/catalog-node/CHANGELOG.md index f276e0a93e..24f1446c6d 100644 --- a/plugins/catalog-node/CHANGELOG.md +++ b/plugins/catalog-node/CHANGELOG.md @@ -1,5 +1,20 @@ # @backstage/plugin-catalog-node +## 1.12.5-next.2 + +### Patch Changes + +- 7c5f3b0: Explicit declare if the service ref accepts `single` or `multiple` implementations. +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/plugin-permission-node@0.8.1-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + ## 1.12.5-next.1 ### Patch Changes diff --git a/plugins/catalog-node/package.json b/plugins/catalog-node/package.json index 3e755330e3..330427c7b5 100644 --- a/plugins/catalog-node/package.json +++ b/plugins/catalog-node/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-catalog-node", - "version": "1.12.5-next.1", + "version": "1.12.5-next.2", "description": "The plugin-catalog-node module for @backstage/plugin-catalog-backend", "backstage": { "role": "node-library", diff --git a/plugins/catalog-react/CHANGELOG.md b/plugins/catalog-react/CHANGELOG.md index 38c15e8957..24a1cf6572 100644 --- a/plugins/catalog-react/CHANGELOG.md +++ b/plugins/catalog-react/CHANGELOG.md @@ -1,5 +1,24 @@ # @backstage/plugin-catalog-react +## 1.12.3-next.2 + +### Patch Changes + +- 012e3eb: Entity page extensions created for the new frontend system via the `/alpha` exports will now be enabled by default. +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/plugin-permission-react@0.4.25-next.1 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/errors@1.2.4 + - @backstage/integration-react@1.1.30-next.0 + - @backstage/types@1.1.1 + - @backstage/version-bridge@1.0.8 + ## 1.12.3-next.1 ### Patch Changes diff --git a/plugins/catalog-react/package.json b/plugins/catalog-react/package.json index fdbd942529..7300729db5 100644 --- a/plugins/catalog-react/package.json +++ b/plugins/catalog-react/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-catalog-react", - "version": "1.12.3-next.1", + "version": "1.12.3-next.2", "description": "A frontend library that helps other Backstage plugins interact with the catalog", "backstage": { "role": "web-library", diff --git a/plugins/catalog-unprocessed-entities-common/CHANGELOG.md b/plugins/catalog-unprocessed-entities-common/CHANGELOG.md index e3dc87146f..b299631a21 100644 --- a/plugins/catalog-unprocessed-entities-common/CHANGELOG.md +++ b/plugins/catalog-unprocessed-entities-common/CHANGELOG.md @@ -1,5 +1,12 @@ # @backstage/plugin-catalog-unprocessed-entities-common +## 0.0.4-next.1 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-permission-common@0.8.1-next.1 + ## 0.0.4-next.0 ### Patch Changes diff --git a/plugins/catalog-unprocessed-entities-common/package.json b/plugins/catalog-unprocessed-entities-common/package.json index 8bded795b4..e5f88ebba4 100644 --- a/plugins/catalog-unprocessed-entities-common/package.json +++ b/plugins/catalog-unprocessed-entities-common/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-catalog-unprocessed-entities-common", - "version": "0.0.4-next.0", + "version": "0.0.4-next.1", "description": "Common functionalities for the catalog-unprocessed-entities plugin", "backstage": { "role": "common-library", diff --git a/plugins/catalog/CHANGELOG.md b/plugins/catalog/CHANGELOG.md index 0a229ff17a..48daaa7774 100644 --- a/plugins/catalog/CHANGELOG.md +++ b/plugins/catalog/CHANGELOG.md @@ -1,5 +1,31 @@ # @backstage/plugin-catalog +## 1.22.0-next.2 + +### Minor Changes + +- 6925dcb: Introduces the HasSubdomainsCard component that displays the subdomains of a given domain + +### Patch Changes + +- 604a504: The entity relation cards available for the new frontend system via `/alpha` now have more accurate and granular default filters. +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-compat-api@0.2.8-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/plugin-search-react@1.7.14-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/plugin-permission-react@0.4.25-next.1 + - @backstage/plugin-scaffolder-common@1.5.5-next.1 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/errors@1.2.4 + - @backstage/integration-react@1.1.30-next.0 + - @backstage/types@1.1.1 + ## 1.21.2-next.1 ### Patch Changes diff --git a/plugins/catalog/package.json b/plugins/catalog/package.json index e747170032..0208271d1a 100644 --- a/plugins/catalog/package.json +++ b/plugins/catalog/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-catalog", - "version": "1.21.2-next.1", + "version": "1.22.0-next.2", "description": "The Backstage plugin for browsing the Backstage catalog", "backstage": { "role": "frontend-plugin", diff --git a/plugins/devtools-backend/CHANGELOG.md b/plugins/devtools-backend/CHANGELOG.md index 323385dc82..db4d04fc6e 100644 --- a/plugins/devtools-backend/CHANGELOG.md +++ b/plugins/devtools-backend/CHANGELOG.md @@ -1,5 +1,22 @@ # @backstage/plugin-devtools-backend +## 0.3.9-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/config-loader@1.9.0-next.2 + - @backstage/plugin-permission-node@0.8.1-next.2 + - @backstage/plugin-devtools-common@0.1.12-next.1 + - @backstage/cli-common@0.1.14 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + ## 0.3.9-next.1 ### Patch Changes diff --git a/plugins/devtools-backend/package.json b/plugins/devtools-backend/package.json index 630ea213b8..64cfc4f883 100644 --- a/plugins/devtools-backend/package.json +++ b/plugins/devtools-backend/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-devtools-backend", - "version": "0.3.9-next.1", + "version": "0.3.9-next.2", "backstage": { "role": "backend-plugin", "pluginId": "devtools", diff --git a/plugins/devtools-common/CHANGELOG.md b/plugins/devtools-common/CHANGELOG.md index 09e8a85edb..80d0584c77 100644 --- a/plugins/devtools-common/CHANGELOG.md +++ b/plugins/devtools-common/CHANGELOG.md @@ -1,5 +1,13 @@ # @backstage/plugin-devtools-common +## 0.1.12-next.1 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/types@1.1.1 + ## 0.1.12-next.0 ### Patch Changes diff --git a/plugins/devtools-common/package.json b/plugins/devtools-common/package.json index be1fab2967..d8a87753ca 100644 --- a/plugins/devtools-common/package.json +++ b/plugins/devtools-common/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-devtools-common", - "version": "0.1.12-next.0", + "version": "0.1.12-next.1", "description": "Common functionalities for the devtools plugin", "backstage": { "role": "common-library", diff --git a/plugins/devtools/CHANGELOG.md b/plugins/devtools/CHANGELOG.md index 496ff5cf52..afebfeefe2 100644 --- a/plugins/devtools/CHANGELOG.md +++ b/plugins/devtools/CHANGELOG.md @@ -1,5 +1,18 @@ # @backstage/plugin-devtools +## 0.1.17-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-compat-api@0.2.8-next.2 + - @backstage/plugin-devtools-common@0.1.12-next.1 + - @backstage/plugin-permission-react@0.4.25-next.1 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/errors@1.2.4 + ## 0.1.17-next.1 ### Patch Changes diff --git a/plugins/devtools/package.json b/plugins/devtools/package.json index a6956161c6..264f7af95b 100644 --- a/plugins/devtools/package.json +++ b/plugins/devtools/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-devtools", - "version": "0.1.17-next.1", + "version": "0.1.17-next.2", "backstage": { "role": "frontend-plugin", "pluginId": "devtools", diff --git a/plugins/events-backend-module-aws-sqs/CHANGELOG.md b/plugins/events-backend-module-aws-sqs/CHANGELOG.md index 53a4e8a3fa..a4a4da2b17 100644 --- a/plugins/events-backend-module-aws-sqs/CHANGELOG.md +++ b/plugins/events-backend-module-aws-sqs/CHANGELOG.md @@ -1,5 +1,17 @@ # @backstage/plugin-events-backend-module-aws-sqs +## 0.3.9-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/config@1.2.0 + - @backstage/types@1.1.1 + ## 0.3.9-next.1 ### Patch Changes diff --git a/plugins/events-backend-module-aws-sqs/package.json b/plugins/events-backend-module-aws-sqs/package.json index 0a4ef481ff..7b1da53130 100644 --- a/plugins/events-backend-module-aws-sqs/package.json +++ b/plugins/events-backend-module-aws-sqs/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-events-backend-module-aws-sqs", - "version": "0.3.9-next.1", + "version": "0.3.9-next.2", "backstage": { "role": "backend-plugin-module", "pluginId": "events", diff --git a/plugins/events-backend-module-azure/CHANGELOG.md b/plugins/events-backend-module-azure/CHANGELOG.md index 0c13627d71..804293b869 100644 --- a/plugins/events-backend-module-azure/CHANGELOG.md +++ b/plugins/events-backend-module-azure/CHANGELOG.md @@ -1,5 +1,13 @@ # @backstage/plugin-events-backend-module-azure +## 0.2.9-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + ## 0.2.9-next.1 ### Patch Changes diff --git a/plugins/events-backend-module-azure/package.json b/plugins/events-backend-module-azure/package.json index c24b8743ac..5d7fc3f1bf 100644 --- a/plugins/events-backend-module-azure/package.json +++ b/plugins/events-backend-module-azure/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-events-backend-module-azure", - "version": "0.2.9-next.1", + "version": "0.2.9-next.2", "backstage": { "role": "backend-plugin-module", "pluginId": "events", diff --git a/plugins/events-backend-module-bitbucket-cloud/CHANGELOG.md b/plugins/events-backend-module-bitbucket-cloud/CHANGELOG.md index 0c333e1d8f..edef56d946 100644 --- a/plugins/events-backend-module-bitbucket-cloud/CHANGELOG.md +++ b/plugins/events-backend-module-bitbucket-cloud/CHANGELOG.md @@ -1,5 +1,13 @@ # @backstage/plugin-events-backend-module-bitbucket-cloud +## 0.2.9-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + ## 0.2.9-next.1 ### Patch Changes diff --git a/plugins/events-backend-module-bitbucket-cloud/package.json b/plugins/events-backend-module-bitbucket-cloud/package.json index 87fb26f2e5..a58bacdf8c 100644 --- a/plugins/events-backend-module-bitbucket-cloud/package.json +++ b/plugins/events-backend-module-bitbucket-cloud/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-events-backend-module-bitbucket-cloud", - "version": "0.2.9-next.1", + "version": "0.2.9-next.2", "backstage": { "role": "backend-plugin-module", "pluginId": "events", diff --git a/plugins/events-backend-module-gerrit/CHANGELOG.md b/plugins/events-backend-module-gerrit/CHANGELOG.md index 2cd77d9933..fcdda38e9b 100644 --- a/plugins/events-backend-module-gerrit/CHANGELOG.md +++ b/plugins/events-backend-module-gerrit/CHANGELOG.md @@ -1,5 +1,13 @@ # @backstage/plugin-events-backend-module-gerrit +## 0.2.9-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + ## 0.2.9-next.1 ### Patch Changes diff --git a/plugins/events-backend-module-gerrit/package.json b/plugins/events-backend-module-gerrit/package.json index 43fd0446eb..91e598511f 100644 --- a/plugins/events-backend-module-gerrit/package.json +++ b/plugins/events-backend-module-gerrit/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-events-backend-module-gerrit", - "version": "0.2.9-next.1", + "version": "0.2.9-next.2", "backstage": { "role": "backend-plugin-module", "pluginId": "events", diff --git a/plugins/events-backend-module-github/CHANGELOG.md b/plugins/events-backend-module-github/CHANGELOG.md index 068b54c0b0..38b1e277e8 100644 --- a/plugins/events-backend-module-github/CHANGELOG.md +++ b/plugins/events-backend-module-github/CHANGELOG.md @@ -1,5 +1,14 @@ # @backstage/plugin-events-backend-module-github +## 0.2.9-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/config@1.2.0 + ## 0.2.9-next.1 ### Patch Changes diff --git a/plugins/events-backend-module-github/package.json b/plugins/events-backend-module-github/package.json index 57516356ea..f77c2c9df8 100644 --- a/plugins/events-backend-module-github/package.json +++ b/plugins/events-backend-module-github/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-events-backend-module-github", - "version": "0.2.9-next.1", + "version": "0.2.9-next.2", "backstage": { "role": "backend-plugin-module", "pluginId": "events", diff --git a/plugins/events-backend-module-gitlab/CHANGELOG.md b/plugins/events-backend-module-gitlab/CHANGELOG.md index b717e5886d..a7986891fa 100644 --- a/plugins/events-backend-module-gitlab/CHANGELOG.md +++ b/plugins/events-backend-module-gitlab/CHANGELOG.md @@ -1,5 +1,14 @@ # @backstage/plugin-events-backend-module-gitlab +## 0.2.9-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/config@1.2.0 + ## 0.2.9-next.1 ### Patch Changes diff --git a/plugins/events-backend-module-gitlab/package.json b/plugins/events-backend-module-gitlab/package.json index 34643977cb..c5a0abfeb8 100644 --- a/plugins/events-backend-module-gitlab/package.json +++ b/plugins/events-backend-module-gitlab/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-events-backend-module-gitlab", - "version": "0.2.9-next.1", + "version": "0.2.9-next.2", "backstage": { "role": "backend-plugin-module", "pluginId": "events", diff --git a/plugins/events-backend-test-utils/CHANGELOG.md b/plugins/events-backend-test-utils/CHANGELOG.md index 33ad7e0318..f408883694 100644 --- a/plugins/events-backend-test-utils/CHANGELOG.md +++ b/plugins/events-backend-test-utils/CHANGELOG.md @@ -1,5 +1,12 @@ # @backstage/plugin-events-backend-test-utils +## 0.1.33-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-events-node@0.3.9-next.2 + ## 0.1.33-next.1 ### Patch Changes diff --git a/plugins/events-backend-test-utils/package.json b/plugins/events-backend-test-utils/package.json index a20f4fa7c7..0cff95bf35 100644 --- a/plugins/events-backend-test-utils/package.json +++ b/plugins/events-backend-test-utils/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-events-backend-test-utils", - "version": "0.1.33-next.1", + "version": "0.1.33-next.2", "description": "The plugin-events-backend-test-utils for @backstage/plugin-events-node", "backstage": { "role": "node-library", diff --git a/plugins/events-backend/CHANGELOG.md b/plugins/events-backend/CHANGELOG.md index 1bbf2359e4..8c2e2f767b 100644 --- a/plugins/events-backend/CHANGELOG.md +++ b/plugins/events-backend/CHANGELOG.md @@ -1,5 +1,15 @@ # @backstage/plugin-events-backend +## 0.3.10-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/config@1.2.0 + ## 0.3.10-next.1 ### Patch Changes diff --git a/plugins/events-backend/package.json b/plugins/events-backend/package.json index e563551d5b..01310be5d8 100644 --- a/plugins/events-backend/package.json +++ b/plugins/events-backend/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-events-backend", - "version": "0.3.10-next.1", + "version": "0.3.10-next.2", "backstage": { "role": "backend-plugin", "pluginId": "events", diff --git a/plugins/events-node/CHANGELOG.md b/plugins/events-node/CHANGELOG.md index a01292b23e..ec7c864d23 100644 --- a/plugins/events-node/CHANGELOG.md +++ b/plugins/events-node/CHANGELOG.md @@ -1,5 +1,12 @@ # @backstage/plugin-events-node +## 0.3.9-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + ## 0.3.9-next.1 ### Patch Changes diff --git a/plugins/events-node/package.json b/plugins/events-node/package.json index 7943aadc8f..db2a6f4271 100644 --- a/plugins/events-node/package.json +++ b/plugins/events-node/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-events-node", - "version": "0.3.9-next.1", + "version": "0.3.9-next.2", "description": "The plugin-events-node module for @backstage/plugin-events-backend", "backstage": { "role": "node-library", diff --git a/plugins/example-todo-list-backend/CHANGELOG.md b/plugins/example-todo-list-backend/CHANGELOG.md index cff91b2e5c..370053d097 100644 --- a/plugins/example-todo-list-backend/CHANGELOG.md +++ b/plugins/example-todo-list-backend/CHANGELOG.md @@ -1,5 +1,15 @@ # @internal/plugin-todo-list-backend +## 1.0.30-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/errors@1.2.4 + ## 1.0.30-next.1 ### Patch Changes diff --git a/plugins/example-todo-list-backend/package.json b/plugins/example-todo-list-backend/package.json index 2e84c6c2b7..b9b04c178f 100644 --- a/plugins/example-todo-list-backend/package.json +++ b/plugins/example-todo-list-backend/package.json @@ -1,6 +1,6 @@ { "name": "@internal/plugin-todo-list-backend", - "version": "1.0.30-next.1", + "version": "1.0.30-next.2", "backstage": { "role": "backend-plugin", "pluginId": "todo-list", diff --git a/plugins/example-todo-list-common/CHANGELOG.md b/plugins/example-todo-list-common/CHANGELOG.md index f780b14906..b2f2175573 100644 --- a/plugins/example-todo-list-common/CHANGELOG.md +++ b/plugins/example-todo-list-common/CHANGELOG.md @@ -1,5 +1,12 @@ # @internal/plugin-todo-list-common +## 1.0.21-next.1 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-permission-common@0.8.1-next.1 + ## 1.0.21-next.0 ### Patch Changes diff --git a/plugins/example-todo-list-common/package.json b/plugins/example-todo-list-common/package.json index 6071032963..cca7f5aa4b 100644 --- a/plugins/example-todo-list-common/package.json +++ b/plugins/example-todo-list-common/package.json @@ -1,6 +1,6 @@ { "name": "@internal/plugin-todo-list-common", - "version": "1.0.21-next.0", + "version": "1.0.21-next.1", "backstage": { "role": "common-library", "pluginId": "todo-list", diff --git a/plugins/home/CHANGELOG.md b/plugins/home/CHANGELOG.md index 2cd0a184fd..08cf9bec5f 100644 --- a/plugins/home/CHANGELOG.md +++ b/plugins/home/CHANGELOG.md @@ -1,5 +1,22 @@ # @backstage/plugin-home +## 0.7.9-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-compat-api@0.2.8-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/core-app-api@1.14.2-next.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/theme@0.5.6 + - @backstage/plugin-home-react@0.1.16-next.0 + ## 0.7.9-next.1 ### Patch Changes diff --git a/plugins/home/package.json b/plugins/home/package.json index 792f7a1525..e566b46e78 100644 --- a/plugins/home/package.json +++ b/plugins/home/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-home", - "version": "0.7.9-next.1", + "version": "0.7.9-next.2", "description": "A Backstage plugin that helps you build a home page", "backstage": { "role": "frontend-plugin", diff --git a/plugins/kubernetes-backend/CHANGELOG.md b/plugins/kubernetes-backend/CHANGELOG.md index c286d49164..1255d6d0fd 100644 --- a/plugins/kubernetes-backend/CHANGELOG.md +++ b/plugins/kubernetes-backend/CHANGELOG.md @@ -1,5 +1,28 @@ # @backstage/plugin-kubernetes-backend +## 0.18.4-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- 8c1aa06: Add `kubernetes.clusterLocatorMethods[].clusters[].customResources` to the configuration schema. + This was already documented and supported by the plugin. +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-kubernetes-node@0.1.17-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-permission-node@0.8.1-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-kubernetes-common@0.8.2-next.1 + - @backstage/integration-aws-node@0.1.12 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + ## 0.18.4-next.1 ### Patch Changes diff --git a/plugins/kubernetes-backend/package.json b/plugins/kubernetes-backend/package.json index 4b69c912b8..70f640e0ba 100644 --- a/plugins/kubernetes-backend/package.json +++ b/plugins/kubernetes-backend/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-kubernetes-backend", - "version": "0.18.4-next.1", + "version": "0.18.4-next.2", "description": "A Backstage backend plugin that integrates towards Kubernetes", "backstage": { "role": "backend-plugin", diff --git a/plugins/kubernetes-cluster/CHANGELOG.md b/plugins/kubernetes-cluster/CHANGELOG.md index cab3826e64..801c2018c9 100644 --- a/plugins/kubernetes-cluster/CHANGELOG.md +++ b/plugins/kubernetes-cluster/CHANGELOG.md @@ -1,5 +1,17 @@ # @backstage/plugin-kubernetes-cluster +## 0.0.14-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/plugin-kubernetes-common@0.8.2-next.1 + - @backstage/catalog-model@1.5.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/plugin-kubernetes-react@0.4.2-next.2 + ## 0.0.14-next.1 ### Patch Changes diff --git a/plugins/kubernetes-cluster/package.json b/plugins/kubernetes-cluster/package.json index f2b1feb906..75c0758ac5 100644 --- a/plugins/kubernetes-cluster/package.json +++ b/plugins/kubernetes-cluster/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-kubernetes-cluster", - "version": "0.0.14-next.1", + "version": "0.0.14-next.2", "description": "A Backstage plugin that shows details of Kubernetes clusters", "backstage": { "role": "frontend-plugin", diff --git a/plugins/kubernetes-common/CHANGELOG.md b/plugins/kubernetes-common/CHANGELOG.md index 9ff6547ad4..f8ac4b4768 100644 --- a/plugins/kubernetes-common/CHANGELOG.md +++ b/plugins/kubernetes-common/CHANGELOG.md @@ -1,5 +1,14 @@ # @backstage/plugin-kubernetes-common +## 0.8.2-next.1 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/catalog-model@1.5.0 + - @backstage/types@1.1.1 + ## 0.8.2-next.0 ### Patch Changes diff --git a/plugins/kubernetes-common/package.json b/plugins/kubernetes-common/package.json index 7ac04abea5..1e05ed873e 100644 --- a/plugins/kubernetes-common/package.json +++ b/plugins/kubernetes-common/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-kubernetes-common", - "version": "0.8.2-next.0", + "version": "0.8.2-next.1", "description": "Common functionalities for kubernetes, to be shared between kubernetes and kubernetes-backend plugin", "backstage": { "role": "common-library", diff --git a/plugins/kubernetes-node/CHANGELOG.md b/plugins/kubernetes-node/CHANGELOG.md index 6e738ab3aa..42e5885c49 100644 --- a/plugins/kubernetes-node/CHANGELOG.md +++ b/plugins/kubernetes-node/CHANGELOG.md @@ -1,5 +1,16 @@ # @backstage/plugin-kubernetes-node +## 0.1.17-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-kubernetes-common@0.8.2-next.1 + - @backstage/catalog-model@1.5.0 + - @backstage/types@1.1.1 + ## 0.1.17-next.1 ### Patch Changes diff --git a/plugins/kubernetes-node/package.json b/plugins/kubernetes-node/package.json index f238334824..5377f26b4d 100644 --- a/plugins/kubernetes-node/package.json +++ b/plugins/kubernetes-node/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-kubernetes-node", - "version": "0.1.17-next.1", + "version": "0.1.17-next.2", "description": "Node.js library for the kubernetes plugin", "backstage": { "role": "node-library", diff --git a/plugins/kubernetes-react/CHANGELOG.md b/plugins/kubernetes-react/CHANGELOG.md index 8859563287..34e9b259be 100644 --- a/plugins/kubernetes-react/CHANGELOG.md +++ b/plugins/kubernetes-react/CHANGELOG.md @@ -1,5 +1,17 @@ # @backstage/plugin-kubernetes-react +## 0.4.2-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-kubernetes-common@0.8.2-next.1 + - @backstage/catalog-model@1.5.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + ## 0.4.2-next.1 ### Patch Changes diff --git a/plugins/kubernetes-react/package.json b/plugins/kubernetes-react/package.json index 094fdaa5e2..dbf89ae0cf 100644 --- a/plugins/kubernetes-react/package.json +++ b/plugins/kubernetes-react/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-kubernetes-react", - "version": "0.4.2-next.1", + "version": "0.4.2-next.2", "description": "Web library for the kubernetes-react plugin", "backstage": { "role": "web-library", diff --git a/plugins/kubernetes/CHANGELOG.md b/plugins/kubernetes/CHANGELOG.md index 384f6574bc..1b5ca07506 100644 --- a/plugins/kubernetes/CHANGELOG.md +++ b/plugins/kubernetes/CHANGELOG.md @@ -1,5 +1,19 @@ # @backstage/plugin-kubernetes +## 0.11.13-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-compat-api@0.2.8-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/plugin-kubernetes-common@0.8.2-next.1 + - @backstage/catalog-model@1.5.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/plugin-kubernetes-react@0.4.2-next.2 + ## 0.11.13-next.1 ### Patch Changes diff --git a/plugins/kubernetes/package.json b/plugins/kubernetes/package.json index d711c5bdb5..ab8fe84d9b 100644 --- a/plugins/kubernetes/package.json +++ b/plugins/kubernetes/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-kubernetes", - "version": "0.11.13-next.1", + "version": "0.11.13-next.2", "description": "A Backstage plugin that integrates towards Kubernetes", "backstage": { "role": "frontend-plugin", diff --git a/plugins/notifications-backend-module-email/CHANGELOG.md b/plugins/notifications-backend-module-email/CHANGELOG.md index 1a9e5ad4bc..a0b4bc8caa 100644 --- a/plugins/notifications-backend-module-email/CHANGELOG.md +++ b/plugins/notifications-backend-module-email/CHANGELOG.md @@ -1,5 +1,21 @@ # @backstage/plugin-notifications-backend-module-email +## 0.2.0-next.2 + +### Patch Changes + +- cdb630d: Add support for stream transport for debugging purposes +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-notifications-node@0.2.4-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/integration-aws-node@0.1.12 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/types@1.1.1 + - @backstage/plugin-notifications-common@0.0.5 + ## 0.2.0-next.1 ### Minor Changes diff --git a/plugins/notifications-backend-module-email/package.json b/plugins/notifications-backend-module-email/package.json index 425186fcad..33451341ea 100644 --- a/plugins/notifications-backend-module-email/package.json +++ b/plugins/notifications-backend-module-email/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-notifications-backend-module-email", - "version": "0.2.0-next.1", + "version": "0.2.0-next.2", "description": "The email backend module for the notifications plugin.", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/notifications-backend/CHANGELOG.md b/plugins/notifications-backend/CHANGELOG.md index 9afeff1a51..61cba9e3a6 100644 --- a/plugins/notifications-backend/CHANGELOG.md +++ b/plugins/notifications-backend/CHANGELOG.md @@ -1,5 +1,23 @@ # @backstage/plugin-notifications-backend +## 0.3.4-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-notifications-node@0.2.4-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/plugin-signals-node@0.1.9-next.2 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/plugin-notifications-common@0.0.5 + ## 0.3.4-next.1 ### Patch Changes diff --git a/plugins/notifications-backend/package.json b/plugins/notifications-backend/package.json index 8bb3fd2acf..9bc26f7a1f 100644 --- a/plugins/notifications-backend/package.json +++ b/plugins/notifications-backend/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-notifications-backend", - "version": "0.3.4-next.1", + "version": "0.3.4-next.2", "backstage": { "role": "backend-plugin", "pluginId": "notifications", diff --git a/plugins/notifications-node/CHANGELOG.md b/plugins/notifications-node/CHANGELOG.md index 6907885ce7..627cb53ea0 100644 --- a/plugins/notifications-node/CHANGELOG.md +++ b/plugins/notifications-node/CHANGELOG.md @@ -1,5 +1,18 @@ # @backstage/plugin-notifications-node +## 0.2.4-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-signals-node@0.1.9-next.2 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/plugin-notifications-common@0.0.5 + ## 0.2.4-next.1 ### Patch Changes diff --git a/plugins/notifications-node/package.json b/plugins/notifications-node/package.json index d71fb7af82..533ebe7ce2 100644 --- a/plugins/notifications-node/package.json +++ b/plugins/notifications-node/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-notifications-node", - "version": "0.2.4-next.1", + "version": "0.2.4-next.2", "description": "Node.js library for the notifications plugin", "backstage": { "role": "node-library", diff --git a/plugins/org-react/CHANGELOG.md b/plugins/org-react/CHANGELOG.md index e5994b4ec4..4bbf343849 100644 --- a/plugins/org-react/CHANGELOG.md +++ b/plugins/org-react/CHANGELOG.md @@ -1,5 +1,16 @@ # @backstage/plugin-org-react +## 0.1.27-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + ## 0.1.27-next.1 ### Patch Changes diff --git a/plugins/org-react/package.json b/plugins/org-react/package.json index 3dca7e029b..d91d73c4ca 100644 --- a/plugins/org-react/package.json +++ b/plugins/org-react/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-org-react", - "version": "0.1.27-next.1", + "version": "0.1.27-next.2", "backstage": { "role": "web-library", "pluginId": "org", diff --git a/plugins/org/CHANGELOG.md b/plugins/org/CHANGELOG.md index 69d6b3fc0f..923d5d1d23 100644 --- a/plugins/org/CHANGELOG.md +++ b/plugins/org/CHANGELOG.md @@ -1,5 +1,18 @@ # @backstage/plugin-org +## 0.6.28-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-compat-api@0.2.8-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/catalog-model@1.5.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + ## 0.6.28-next.1 ### Patch Changes diff --git a/plugins/org/package.json b/plugins/org/package.json index 72ea35013d..44ae3d10f6 100644 --- a/plugins/org/package.json +++ b/plugins/org/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-org", - "version": "0.6.28-next.1", + "version": "0.6.28-next.2", "description": "A Backstage plugin that helps you create entity pages for your organization", "backstage": { "role": "frontend-plugin", diff --git a/plugins/permission-backend-module-policy-allow-all/CHANGELOG.md b/plugins/permission-backend-module-policy-allow-all/CHANGELOG.md index 559697105d..7c0765ad43 100644 --- a/plugins/permission-backend-module-policy-allow-all/CHANGELOG.md +++ b/plugins/permission-backend-module-policy-allow-all/CHANGELOG.md @@ -1,5 +1,15 @@ # @backstage/plugin-permission-backend-module-allow-all-policy +## 0.1.20-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-permission-node@0.8.1-next.2 + ## 0.1.20-next.1 ### Patch Changes diff --git a/plugins/permission-backend-module-policy-allow-all/package.json b/plugins/permission-backend-module-policy-allow-all/package.json index fb40f025ce..0ba16a61f7 100644 --- a/plugins/permission-backend-module-policy-allow-all/package.json +++ b/plugins/permission-backend-module-policy-allow-all/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-permission-backend-module-allow-all-policy", - "version": "0.1.20-next.1", + "version": "0.1.20-next.2", "description": "Allow all policy backend module for the permission plugin.", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/permission-backend/CHANGELOG.md b/plugins/permission-backend/CHANGELOG.md index 9f0f3cf8ac..89955c0f69 100644 --- a/plugins/permission-backend/CHANGELOG.md +++ b/plugins/permission-backend/CHANGELOG.md @@ -1,5 +1,19 @@ # @backstage/plugin-permission-backend +## 0.5.47-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-permission-node@0.8.1-next.2 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + ## 0.5.47-next.1 ### Patch Changes diff --git a/plugins/permission-backend/package.json b/plugins/permission-backend/package.json index a5b6a9fb59..7a331c1ccd 100644 --- a/plugins/permission-backend/package.json +++ b/plugins/permission-backend/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-permission-backend", - "version": "0.5.47-next.1", + "version": "0.5.47-next.2", "backstage": { "role": "backend-plugin", "pluginId": "permission", diff --git a/plugins/permission-common/CHANGELOG.md b/plugins/permission-common/CHANGELOG.md index 9194c9cae6..8ef1eb314f 100644 --- a/plugins/permission-common/CHANGELOG.md +++ b/plugins/permission-common/CHANGELOG.md @@ -1,5 +1,16 @@ # @backstage/plugin-permission-common +## 0.8.1-next.1 + +### Patch Changes + +- df784fe: Add the MetadataResponse type from @backstage/plugin-permission-node, since this + type might be used in frontend code. +- Updated dependencies + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + ## 0.8.1-next.0 ### Patch Changes diff --git a/plugins/permission-common/package.json b/plugins/permission-common/package.json index 323dea5638..faeaf4a972 100644 --- a/plugins/permission-common/package.json +++ b/plugins/permission-common/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-permission-common", - "version": "0.8.1-next.0", + "version": "0.8.1-next.1", "description": "Isomorphic types and client for Backstage permissions and authorization", "backstage": { "role": "common-library", diff --git a/plugins/permission-node/CHANGELOG.md b/plugins/permission-node/CHANGELOG.md index 3e29fe0c2a..282ea5fda8 100644 --- a/plugins/permission-node/CHANGELOG.md +++ b/plugins/permission-node/CHANGELOG.md @@ -1,5 +1,22 @@ # @backstage/plugin-permission-node +## 0.8.1-next.2 + +### Patch Changes + +- df784fe: The MetadataResponse type has been moved to @backstage/plugin-permission-common + to match the recent move of MetadataResponseSerializedRule, and should be + imported from there going forward. To avoid an immediate breaking change, this + type is still re-exported from this package, but is marked as deprecated and + will be removed in a future release. +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + ## 0.8.1-next.1 ### Patch Changes diff --git a/plugins/permission-node/package.json b/plugins/permission-node/package.json index 4e024a3f10..b2c2d06f11 100644 --- a/plugins/permission-node/package.json +++ b/plugins/permission-node/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-permission-node", - "version": "0.8.1-next.1", + "version": "0.8.1-next.2", "description": "Common permission and authorization utilities for backend plugins", "backstage": { "role": "node-library", diff --git a/plugins/permission-react/CHANGELOG.md b/plugins/permission-react/CHANGELOG.md index 8b2e8e3250..83f4dea7ed 100644 --- a/plugins/permission-react/CHANGELOG.md +++ b/plugins/permission-react/CHANGELOG.md @@ -1,5 +1,14 @@ # @backstage/plugin-permission-react +## 0.4.25-next.1 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/config@1.2.0 + - @backstage/core-plugin-api@1.9.3 + ## 0.4.25-next.0 ### Patch Changes diff --git a/plugins/permission-react/package.json b/plugins/permission-react/package.json index 8bd566a34c..394f56ff02 100644 --- a/plugins/permission-react/package.json +++ b/plugins/permission-react/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-permission-react", - "version": "0.4.25-next.0", + "version": "0.4.25-next.1", "backstage": { "role": "web-library", "pluginId": "permission", diff --git a/plugins/proxy-backend/CHANGELOG.md b/plugins/proxy-backend/CHANGELOG.md index bfec70e942..138b98902b 100644 --- a/plugins/proxy-backend/CHANGELOG.md +++ b/plugins/proxy-backend/CHANGELOG.md @@ -1,5 +1,16 @@ # @backstage/plugin-proxy-backend +## 0.5.4-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/config@1.2.0 + - @backstage/types@1.1.1 + ## 0.5.4-next.1 ### Patch Changes diff --git a/plugins/proxy-backend/package.json b/plugins/proxy-backend/package.json index 655ccfed9d..091e637886 100644 --- a/plugins/proxy-backend/package.json +++ b/plugins/proxy-backend/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-proxy-backend", - "version": "0.5.4-next.1", + "version": "0.5.4-next.2", "description": "A Backstage backend plugin that helps you set up proxy endpoints in the backend", "backstage": { "role": "backend-plugin", diff --git a/plugins/scaffolder-backend-module-azure/CHANGELOG.md b/plugins/scaffolder-backend-module-azure/CHANGELOG.md index fe925ffb7d..90541db310 100644 --- a/plugins/scaffolder-backend-module-azure/CHANGELOG.md +++ b/plugins/scaffolder-backend-module-azure/CHANGELOG.md @@ -1,5 +1,16 @@ # @backstage/plugin-scaffolder-backend-module-azure +## 0.1.15-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + ## 0.1.15-next.1 ### Patch Changes diff --git a/plugins/scaffolder-backend-module-azure/package.json b/plugins/scaffolder-backend-module-azure/package.json index 19470655e6..92d64ec7f0 100644 --- a/plugins/scaffolder-backend-module-azure/package.json +++ b/plugins/scaffolder-backend-module-azure/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-scaffolder-backend-module-azure", - "version": "0.1.15-next.1", + "version": "0.1.15-next.2", "description": "The azure module for @backstage/plugin-scaffolder-backend", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/scaffolder-backend-module-bitbucket-cloud/CHANGELOG.md b/plugins/scaffolder-backend-module-bitbucket-cloud/CHANGELOG.md index 0d52996a88..604b44d3da 100644 --- a/plugins/scaffolder-backend-module-bitbucket-cloud/CHANGELOG.md +++ b/plugins/scaffolder-backend-module-bitbucket-cloud/CHANGELOG.md @@ -1,5 +1,19 @@ # @backstage/plugin-scaffolder-backend-module-bitbucket-cloud +## 0.1.13-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- 3fca643: Added autocompletion support for resource `branches` +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/plugin-bitbucket-cloud-common@0.2.22-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + ## 0.1.13-next.1 ### Patch Changes diff --git a/plugins/scaffolder-backend-module-bitbucket-cloud/package.json b/plugins/scaffolder-backend-module-bitbucket-cloud/package.json index 0446c39b0c..1806189dd4 100644 --- a/plugins/scaffolder-backend-module-bitbucket-cloud/package.json +++ b/plugins/scaffolder-backend-module-bitbucket-cloud/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-scaffolder-backend-module-bitbucket-cloud", - "version": "0.1.13-next.1", + "version": "0.1.13-next.2", "description": "The Bitbucket Cloud module for @backstage/plugin-scaffolder-backend", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/scaffolder-backend-module-bitbucket-server/CHANGELOG.md b/plugins/scaffolder-backend-module-bitbucket-server/CHANGELOG.md index 7d4b793d10..221a626169 100644 --- a/plugins/scaffolder-backend-module-bitbucket-server/CHANGELOG.md +++ b/plugins/scaffolder-backend-module-bitbucket-server/CHANGELOG.md @@ -1,5 +1,17 @@ # @backstage/plugin-scaffolder-backend-module-bitbucket-server +## 0.1.13-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + ## 0.1.13-next.1 ### Patch Changes diff --git a/plugins/scaffolder-backend-module-bitbucket-server/package.json b/plugins/scaffolder-backend-module-bitbucket-server/package.json index 0ce8ac90e8..5c08e23b6f 100644 --- a/plugins/scaffolder-backend-module-bitbucket-server/package.json +++ b/plugins/scaffolder-backend-module-bitbucket-server/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-scaffolder-backend-module-bitbucket-server", - "version": "0.1.13-next.1", + "version": "0.1.13-next.2", "description": "The Bitbucket Server module for @backstage/plugin-scaffolder-backend", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/scaffolder-backend-module-bitbucket/CHANGELOG.md b/plugins/scaffolder-backend-module-bitbucket/CHANGELOG.md index 8ab0a80df0..062d54226d 100644 --- a/plugins/scaffolder-backend-module-bitbucket/CHANGELOG.md +++ b/plugins/scaffolder-backend-module-bitbucket/CHANGELOG.md @@ -1,5 +1,19 @@ # @backstage/plugin-scaffolder-backend-module-bitbucket +## 0.2.13-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/plugin-scaffolder-backend-module-bitbucket-server@0.1.13-next.2 + - @backstage/plugin-scaffolder-backend-module-bitbucket-cloud@0.1.13-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + ## 0.2.13-next.1 ### Patch Changes diff --git a/plugins/scaffolder-backend-module-bitbucket/package.json b/plugins/scaffolder-backend-module-bitbucket/package.json index e29e75ee12..a9f499ec74 100644 --- a/plugins/scaffolder-backend-module-bitbucket/package.json +++ b/plugins/scaffolder-backend-module-bitbucket/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-scaffolder-backend-module-bitbucket", - "version": "0.2.13-next.1", + "version": "0.2.13-next.2", "description": "The bitbucket module for @backstage/plugin-scaffolder-backend", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/scaffolder-backend-module-confluence-to-markdown/CHANGELOG.md b/plugins/scaffolder-backend-module-confluence-to-markdown/CHANGELOG.md index 9c9b493c1d..2621b1d8f3 100644 --- a/plugins/scaffolder-backend-module-confluence-to-markdown/CHANGELOG.md +++ b/plugins/scaffolder-backend-module-confluence-to-markdown/CHANGELOG.md @@ -1,5 +1,18 @@ # @backstage/plugin-scaffolder-backend-module-confluence-to-markdown +## 0.2.24-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + ## 0.2.24-next.1 ### Patch Changes diff --git a/plugins/scaffolder-backend-module-confluence-to-markdown/package.json b/plugins/scaffolder-backend-module-confluence-to-markdown/package.json index a0d5631608..b4b10f7d4c 100644 --- a/plugins/scaffolder-backend-module-confluence-to-markdown/package.json +++ b/plugins/scaffolder-backend-module-confluence-to-markdown/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-scaffolder-backend-module-confluence-to-markdown", - "version": "0.2.24-next.1", + "version": "0.2.24-next.2", "description": "The confluence-to-markdown module for @backstage/plugin-scaffolder-backend", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/scaffolder-backend-module-cookiecutter/CHANGELOG.md b/plugins/scaffolder-backend-module-cookiecutter/CHANGELOG.md index 71ce038f43..160953da23 100644 --- a/plugins/scaffolder-backend-module-cookiecutter/CHANGELOG.md +++ b/plugins/scaffolder-backend-module-cookiecutter/CHANGELOG.md @@ -1,5 +1,18 @@ # @backstage/plugin-scaffolder-backend-module-cookiecutter +## 0.2.47-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + ## 0.2.47-next.1 ### Patch Changes diff --git a/plugins/scaffolder-backend-module-cookiecutter/package.json b/plugins/scaffolder-backend-module-cookiecutter/package.json index ec1899099b..7749830304 100644 --- a/plugins/scaffolder-backend-module-cookiecutter/package.json +++ b/plugins/scaffolder-backend-module-cookiecutter/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-scaffolder-backend-module-cookiecutter", - "version": "0.2.47-next.1", + "version": "0.2.47-next.2", "description": "A module for the scaffolder backend that lets you template projects using cookiecutter", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/scaffolder-backend-module-gcp/CHANGELOG.md b/plugins/scaffolder-backend-module-gcp/CHANGELOG.md index 551141df6c..c759549d90 100644 --- a/plugins/scaffolder-backend-module-gcp/CHANGELOG.md +++ b/plugins/scaffolder-backend-module-gcp/CHANGELOG.md @@ -1,5 +1,16 @@ # @backstage/plugin-scaffolder-backend-module-gcp +## 0.1.1-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + ## 0.1.1-next.1 ### Patch Changes diff --git a/plugins/scaffolder-backend-module-gcp/package.json b/plugins/scaffolder-backend-module-gcp/package.json index 1c2feb106a..33459ba5b6 100644 --- a/plugins/scaffolder-backend-module-gcp/package.json +++ b/plugins/scaffolder-backend-module-gcp/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-scaffolder-backend-module-gcp", - "version": "0.1.1-next.1", + "version": "0.1.1-next.2", "description": "The GCP Bucket module for @backstage/plugin-scaffolder-backend", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/scaffolder-backend-module-gerrit/CHANGELOG.md b/plugins/scaffolder-backend-module-gerrit/CHANGELOG.md index 6827109801..811e9a80cc 100644 --- a/plugins/scaffolder-backend-module-gerrit/CHANGELOG.md +++ b/plugins/scaffolder-backend-module-gerrit/CHANGELOG.md @@ -1,5 +1,17 @@ # @backstage/plugin-scaffolder-backend-module-gerrit +## 0.1.15-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + ## 0.1.15-next.1 ### Patch Changes diff --git a/plugins/scaffolder-backend-module-gerrit/package.json b/plugins/scaffolder-backend-module-gerrit/package.json index f39e67cedc..0e50124013 100644 --- a/plugins/scaffolder-backend-module-gerrit/package.json +++ b/plugins/scaffolder-backend-module-gerrit/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-scaffolder-backend-module-gerrit", - "version": "0.1.15-next.1", + "version": "0.1.15-next.2", "description": "The gerrit module for @backstage/plugin-scaffolder-backend", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/scaffolder-backend-module-gitea/CHANGELOG.md b/plugins/scaffolder-backend-module-gitea/CHANGELOG.md index 983d3cebb0..0a05340f77 100644 --- a/plugins/scaffolder-backend-module-gitea/CHANGELOG.md +++ b/plugins/scaffolder-backend-module-gitea/CHANGELOG.md @@ -1,5 +1,17 @@ # @backstage/plugin-scaffolder-backend-module-gitea +## 0.1.13-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + ## 0.1.13-next.1 ### Patch Changes diff --git a/plugins/scaffolder-backend-module-gitea/package.json b/plugins/scaffolder-backend-module-gitea/package.json index 14b0305b10..cb888b65ad 100644 --- a/plugins/scaffolder-backend-module-gitea/package.json +++ b/plugins/scaffolder-backend-module-gitea/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-scaffolder-backend-module-gitea", - "version": "0.1.13-next.1", + "version": "0.1.13-next.2", "description": "The gitea module for @backstage/plugin-scaffolder-backend", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/scaffolder-backend-module-github/CHANGELOG.md b/plugins/scaffolder-backend-module-github/CHANGELOG.md index d39143c7c4..e9d841aa0c 100644 --- a/plugins/scaffolder-backend-module-github/CHANGELOG.md +++ b/plugins/scaffolder-backend-module-github/CHANGELOG.md @@ -1,5 +1,17 @@ # @backstage/plugin-scaffolder-backend-module-github +## 0.4.1-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + ## 0.4.1-next.1 ### Patch Changes diff --git a/plugins/scaffolder-backend-module-github/package.json b/plugins/scaffolder-backend-module-github/package.json index 68a0475622..c373839d13 100644 --- a/plugins/scaffolder-backend-module-github/package.json +++ b/plugins/scaffolder-backend-module-github/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-scaffolder-backend-module-github", - "version": "0.4.1-next.1", + "version": "0.4.1-next.2", "description": "The github module for @backstage/plugin-scaffolder-backend", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/scaffolder-backend-module-gitlab/CHANGELOG.md b/plugins/scaffolder-backend-module-gitlab/CHANGELOG.md index c0099a16c6..f62e5b4db8 100644 --- a/plugins/scaffolder-backend-module-gitlab/CHANGELOG.md +++ b/plugins/scaffolder-backend-module-gitlab/CHANGELOG.md @@ -1,5 +1,17 @@ # @backstage/plugin-scaffolder-backend-module-gitlab +## 0.4.5-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + ## 0.4.5-next.1 ### Patch Changes diff --git a/plugins/scaffolder-backend-module-gitlab/package.json b/plugins/scaffolder-backend-module-gitlab/package.json index 410a6111f5..dde6e48a6e 100644 --- a/plugins/scaffolder-backend-module-gitlab/package.json +++ b/plugins/scaffolder-backend-module-gitlab/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-scaffolder-backend-module-gitlab", - "version": "0.4.5-next.1", + "version": "0.4.5-next.2", "backstage": { "role": "backend-plugin-module", "pluginId": "scaffolder", diff --git a/plugins/scaffolder-backend-module-notifications/CHANGELOG.md b/plugins/scaffolder-backend-module-notifications/CHANGELOG.md index 31f8197923..85da251d02 100644 --- a/plugins/scaffolder-backend-module-notifications/CHANGELOG.md +++ b/plugins/scaffolder-backend-module-notifications/CHANGELOG.md @@ -1,5 +1,16 @@ # @backstage/plugin-scaffolder-backend-module-notifications +## 0.0.6-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/plugin-notifications-node@0.2.4-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-notifications-common@0.0.5 + ## 0.0.6-next.1 ### Patch Changes diff --git a/plugins/scaffolder-backend-module-notifications/package.json b/plugins/scaffolder-backend-module-notifications/package.json index c4a10f6a92..204bf597e9 100644 --- a/plugins/scaffolder-backend-module-notifications/package.json +++ b/plugins/scaffolder-backend-module-notifications/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-scaffolder-backend-module-notifications", - "version": "0.0.6-next.1", + "version": "0.0.6-next.2", "description": "The notifications backend module for the scaffolder plugin.", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/scaffolder-backend-module-rails/CHANGELOG.md b/plugins/scaffolder-backend-module-rails/CHANGELOG.md index ff68b1d78c..ed34f47a58 100644 --- a/plugins/scaffolder-backend-module-rails/CHANGELOG.md +++ b/plugins/scaffolder-backend-module-rails/CHANGELOG.md @@ -1,5 +1,18 @@ # @backstage/plugin-scaffolder-backend-module-rails +## 0.4.40-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + ## 0.4.40-next.1 ### Patch Changes diff --git a/plugins/scaffolder-backend-module-rails/package.json b/plugins/scaffolder-backend-module-rails/package.json index 38088ccfc8..8cbd5e1067 100644 --- a/plugins/scaffolder-backend-module-rails/package.json +++ b/plugins/scaffolder-backend-module-rails/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-scaffolder-backend-module-rails", - "version": "0.4.40-next.1", + "version": "0.4.40-next.2", "description": "A module for the scaffolder backend that lets you template projects using Rails", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/scaffolder-backend-module-sentry/CHANGELOG.md b/plugins/scaffolder-backend-module-sentry/CHANGELOG.md index 7515c6494b..c4421d314b 100644 --- a/plugins/scaffolder-backend-module-sentry/CHANGELOG.md +++ b/plugins/scaffolder-backend-module-sentry/CHANGELOG.md @@ -1,5 +1,17 @@ # @backstage/plugin-scaffolder-backend-module-sentry +## 0.1.31-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- 382e868: Added test cases for sentry:project:create examples +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + ## 0.1.31-next.1 ### Patch Changes diff --git a/plugins/scaffolder-backend-module-sentry/package.json b/plugins/scaffolder-backend-module-sentry/package.json index 81171ea78d..f683e23d09 100644 --- a/plugins/scaffolder-backend-module-sentry/package.json +++ b/plugins/scaffolder-backend-module-sentry/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-scaffolder-backend-module-sentry", - "version": "0.1.31-next.1", + "version": "0.1.31-next.2", "backstage": { "role": "backend-plugin-module", "pluginId": "scaffolder", diff --git a/plugins/scaffolder-backend-module-yeoman/CHANGELOG.md b/plugins/scaffolder-backend-module-yeoman/CHANGELOG.md index 069390e33f..4833302170 100644 --- a/plugins/scaffolder-backend-module-yeoman/CHANGELOG.md +++ b/plugins/scaffolder-backend-module-yeoman/CHANGELOG.md @@ -1,5 +1,15 @@ # @backstage/plugin-scaffolder-backend-module-yeoman +## 0.3.7-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/plugin-scaffolder-node-test-utils@0.1.10-next.2 + - @backstage/types@1.1.1 + ## 0.3.7-next.1 ### Patch Changes diff --git a/plugins/scaffolder-backend-module-yeoman/package.json b/plugins/scaffolder-backend-module-yeoman/package.json index a820392630..36aed409cc 100644 --- a/plugins/scaffolder-backend-module-yeoman/package.json +++ b/plugins/scaffolder-backend-module-yeoman/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-scaffolder-backend-module-yeoman", - "version": "0.3.7-next.1", + "version": "0.3.7-next.2", "backstage": { "role": "backend-plugin-module", "pluginId": "scaffolder", diff --git a/plugins/scaffolder-backend/CHANGELOG.md b/plugins/scaffolder-backend/CHANGELOG.md index b1bb14c6a7..0ed359768e 100644 --- a/plugins/scaffolder-backend/CHANGELOG.md +++ b/plugins/scaffolder-backend/CHANGELOG.md @@ -1,5 +1,37 @@ # @backstage/plugin-scaffolder-backend +## 1.23.1-next.2 + +### Patch Changes + +- c544f81: Add support for status filtering in scaffolder tasks endpoint +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/plugin-scaffolder-backend-module-bitbucket-server@0.1.13-next.2 + - @backstage/plugin-scaffolder-backend-module-bitbucket-cloud@0.1.13-next.2 + - @backstage/plugin-scaffolder-backend-module-bitbucket@0.2.13-next.2 + - @backstage/plugin-scaffolder-backend-module-gerrit@0.1.15-next.2 + - @backstage/plugin-scaffolder-backend-module-gitea@0.1.13-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-permission-node@0.8.1-next.2 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-bitbucket-cloud-common@0.2.22-next.1 + - @backstage/plugin-catalog-backend-module-scaffolder-entity-model@0.1.21-next.2 + - @backstage/plugin-scaffolder-backend-module-azure@0.1.15-next.2 + - @backstage/plugin-scaffolder-backend-module-github@0.4.1-next.2 + - @backstage/plugin-scaffolder-backend-module-gitlab@0.4.5-next.2 + - @backstage/plugin-scaffolder-common@1.5.5-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + ## 1.23.1-next.1 ### Patch Changes diff --git a/plugins/scaffolder-backend/package.json b/plugins/scaffolder-backend/package.json index 8f304690f6..974125ad94 100644 --- a/plugins/scaffolder-backend/package.json +++ b/plugins/scaffolder-backend/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-scaffolder-backend", - "version": "1.23.1-next.1", + "version": "1.23.1-next.2", "description": "The Backstage backend plugin that helps you create new things", "backstage": { "role": "backend-plugin", diff --git a/plugins/scaffolder-common/CHANGELOG.md b/plugins/scaffolder-common/CHANGELOG.md index 6c2b31d18b..4810656ef4 100644 --- a/plugins/scaffolder-common/CHANGELOG.md +++ b/plugins/scaffolder-common/CHANGELOG.md @@ -1,5 +1,14 @@ # @backstage/plugin-scaffolder-common +## 1.5.5-next.1 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/catalog-model@1.5.0 + - @backstage/types@1.1.1 + ## 1.5.5-next.0 ### Patch Changes diff --git a/plugins/scaffolder-common/package.json b/plugins/scaffolder-common/package.json index e37ee5462c..949a831906 100644 --- a/plugins/scaffolder-common/package.json +++ b/plugins/scaffolder-common/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-scaffolder-common", - "version": "1.5.5-next.0", + "version": "1.5.5-next.1", "description": "Common functionalities for the scaffolder, to be shared between scaffolder and scaffolder-backend plugin", "backstage": { "role": "common-library", diff --git a/plugins/scaffolder-node-test-utils/CHANGELOG.md b/plugins/scaffolder-node-test-utils/CHANGELOG.md index d49e076730..c7d37fb0c8 100644 --- a/plugins/scaffolder-node-test-utils/CHANGELOG.md +++ b/plugins/scaffolder-node-test-utils/CHANGELOG.md @@ -1,5 +1,15 @@ # @backstage/plugin-scaffolder-node-test-utils +## 0.1.10-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-test-utils@0.4.5-next.2 + - @backstage/plugin-scaffolder-node@0.4.9-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/types@1.1.1 + ## 0.1.10-next.1 ### Patch Changes diff --git a/plugins/scaffolder-node-test-utils/package.json b/plugins/scaffolder-node-test-utils/package.json index f3ee13fcbe..707ffa1388 100644 --- a/plugins/scaffolder-node-test-utils/package.json +++ b/plugins/scaffolder-node-test-utils/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-scaffolder-node-test-utils", - "version": "0.1.10-next.1", + "version": "0.1.10-next.2", "backstage": { "role": "node-library", "pluginId": "scaffolder", diff --git a/plugins/scaffolder-node/CHANGELOG.md b/plugins/scaffolder-node/CHANGELOG.md index 3dc6b6b952..42fc13a644 100644 --- a/plugins/scaffolder-node/CHANGELOG.md +++ b/plugins/scaffolder-node/CHANGELOG.md @@ -1,5 +1,19 @@ # @backstage/plugin-scaffolder-node +## 0.4.9-next.2 + +### Patch Changes + +- c544f81: Add support for status filtering in scaffolder tasks endpoint +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-scaffolder-common@1.5.5-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-model@1.5.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + ## 0.4.9-next.1 ### Patch Changes diff --git a/plugins/scaffolder-node/package.json b/plugins/scaffolder-node/package.json index 544c40d5b7..6e84b278c2 100644 --- a/plugins/scaffolder-node/package.json +++ b/plugins/scaffolder-node/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-scaffolder-node", - "version": "0.4.9-next.1", + "version": "0.4.9-next.2", "description": "The plugin-scaffolder-node module for @backstage/plugin-scaffolder-backend", "backstage": { "role": "node-library", diff --git a/plugins/scaffolder-react/CHANGELOG.md b/plugins/scaffolder-react/CHANGELOG.md index ab664aecb3..1661f3d1c7 100644 --- a/plugins/scaffolder-react/CHANGELOG.md +++ b/plugins/scaffolder-react/CHANGELOG.md @@ -1,5 +1,23 @@ # @backstage/plugin-scaffolder-react +## 1.11.0-next.2 + +### Patch Changes + +- 072c00c: Fixed a bug in `DefaultTableOutputs` where output elements overlapped on smaller screen sizes +- 04759f2: Fix null check in `isJsonObject` utility function for scaffolder review state component +- Updated dependencies + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/plugin-permission-react@0.4.25-next.1 + - @backstage/plugin-scaffolder-common@1.5.5-next.1 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/theme@0.5.6 + - @backstage/types@1.1.1 + - @backstage/version-bridge@1.0.8 + ## 1.11.0-next.1 ### Patch Changes diff --git a/plugins/scaffolder-react/package.json b/plugins/scaffolder-react/package.json index d4bdd70081..b47bbd731f 100644 --- a/plugins/scaffolder-react/package.json +++ b/plugins/scaffolder-react/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-scaffolder-react", - "version": "1.11.0-next.1", + "version": "1.11.0-next.2", "description": "A frontend library that helps other Backstage plugins interact with the Scaffolder", "backstage": { "role": "web-library", diff --git a/plugins/scaffolder/CHANGELOG.md b/plugins/scaffolder/CHANGELOG.md index 8bb5dc093d..3c4b39541c 100644 --- a/plugins/scaffolder/CHANGELOG.md +++ b/plugins/scaffolder/CHANGELOG.md @@ -1,5 +1,30 @@ # @backstage/plugin-scaffolder +## 1.24.0-next.2 + +### Minor Changes + +- 3fca643: Added field extension `RepoBranchPicker` that supports autocompletion for Bitbucket + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-scaffolder-react@1.11.0-next.2 + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-compat-api@0.2.8-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/plugin-permission-react@0.4.25-next.1 + - @backstage/plugin-scaffolder-common@1.5.5-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/errors@1.2.4 + - @backstage/integration-react@1.1.30-next.0 + - @backstage/types@1.1.1 + ## 1.23.1-next.1 ### Patch Changes diff --git a/plugins/scaffolder/package.json b/plugins/scaffolder/package.json index 5d0b842be6..43b94a9361 100644 --- a/plugins/scaffolder/package.json +++ b/plugins/scaffolder/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-scaffolder", - "version": "1.23.1-next.1", + "version": "1.24.0-next.2", "description": "The Backstage plugin that helps you create new things", "backstage": { "role": "frontend-plugin", diff --git a/plugins/search-backend-module-catalog/CHANGELOG.md b/plugins/search-backend-module-catalog/CHANGELOG.md index 14b950872a..8c8e397620 100644 --- a/plugins/search-backend-module-catalog/CHANGELOG.md +++ b/plugins/search-backend-module-catalog/CHANGELOG.md @@ -1,5 +1,23 @@ # @backstage/plugin-search-backend-module-catalog +## 0.1.29-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-search-backend-node@1.2.28-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + ## 0.1.29-next.1 ### Patch Changes diff --git a/plugins/search-backend-module-catalog/package.json b/plugins/search-backend-module-catalog/package.json index 9914ab599e..8eda12eac2 100644 --- a/plugins/search-backend-module-catalog/package.json +++ b/plugins/search-backend-module-catalog/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-search-backend-module-catalog", - "version": "0.1.29-next.1", + "version": "0.1.29-next.2", "description": "A module for the search backend that exports catalog modules", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/search-backend-module-elasticsearch/CHANGELOG.md b/plugins/search-backend-module-elasticsearch/CHANGELOG.md index d851114cc3..f6866f0878 100644 --- a/plugins/search-backend-module-elasticsearch/CHANGELOG.md +++ b/plugins/search-backend-module-elasticsearch/CHANGELOG.md @@ -1,5 +1,17 @@ # @backstage/plugin-search-backend-module-elasticsearch +## 1.5.4-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-search-backend-node@1.2.28-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/integration-aws-node@0.1.12 + - @backstage/config@1.2.0 + ## 1.5.4-next.1 ### Patch Changes diff --git a/plugins/search-backend-module-elasticsearch/package.json b/plugins/search-backend-module-elasticsearch/package.json index 56a1dcd6e2..e4f6a80774 100644 --- a/plugins/search-backend-module-elasticsearch/package.json +++ b/plugins/search-backend-module-elasticsearch/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-search-backend-module-elasticsearch", - "version": "1.5.4-next.1", + "version": "1.5.4-next.2", "description": "A module for the search backend that implements search using ElasticSearch", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/search-backend-module-explore/CHANGELOG.md b/plugins/search-backend-module-explore/CHANGELOG.md index 344969254c..4ea47e64cc 100644 --- a/plugins/search-backend-module-explore/CHANGELOG.md +++ b/plugins/search-backend-module-explore/CHANGELOG.md @@ -1,5 +1,18 @@ # @backstage/plugin-search-backend-module-explore +## 0.1.29-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-search-backend-node@1.2.28-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/config@1.2.0 + ## 0.1.29-next.1 ### Patch Changes diff --git a/plugins/search-backend-module-explore/package.json b/plugins/search-backend-module-explore/package.json index 9c6197e8ca..0b9f84e86e 100644 --- a/plugins/search-backend-module-explore/package.json +++ b/plugins/search-backend-module-explore/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-search-backend-module-explore", - "version": "0.1.29-next.1", + "version": "0.1.29-next.2", "description": "A module for the search backend that exports explore modules", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/search-backend-module-pg/CHANGELOG.md b/plugins/search-backend-module-pg/CHANGELOG.md index 03a33c2081..bc3a4e1ef4 100644 --- a/plugins/search-backend-module-pg/CHANGELOG.md +++ b/plugins/search-backend-module-pg/CHANGELOG.md @@ -1,5 +1,16 @@ # @backstage/plugin-search-backend-module-pg +## 0.5.33-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-search-backend-node@1.2.28-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/config@1.2.0 + ## 0.5.33-next.1 ### Patch Changes diff --git a/plugins/search-backend-module-pg/package.json b/plugins/search-backend-module-pg/package.json index 62b5309b06..76e5de5af1 100644 --- a/plugins/search-backend-module-pg/package.json +++ b/plugins/search-backend-module-pg/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-search-backend-module-pg", - "version": "0.5.33-next.1", + "version": "0.5.33-next.2", "description": "A module for the search backend that implements search using PostgreSQL", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/search-backend-module-stack-overflow-collator/CHANGELOG.md b/plugins/search-backend-module-stack-overflow-collator/CHANGELOG.md index a3c64851bb..caada51643 100644 --- a/plugins/search-backend-module-stack-overflow-collator/CHANGELOG.md +++ b/plugins/search-backend-module-stack-overflow-collator/CHANGELOG.md @@ -1,5 +1,18 @@ # @backstage/plugin-search-backend-module-stack-overflow-collator +## 0.1.16-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-search-backend-node@1.2.28-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/config@1.2.0 + ## 0.1.16-next.1 ### Patch Changes diff --git a/plugins/search-backend-module-stack-overflow-collator/package.json b/plugins/search-backend-module-stack-overflow-collator/package.json index 08236889af..91a45a3a65 100644 --- a/plugins/search-backend-module-stack-overflow-collator/package.json +++ b/plugins/search-backend-module-stack-overflow-collator/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-search-backend-module-stack-overflow-collator", - "version": "0.1.16-next.1", + "version": "0.1.16-next.2", "description": "A module for the search backend that exports stack overflow modules", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/search-backend-module-techdocs/CHANGELOG.md b/plugins/search-backend-module-techdocs/CHANGELOG.md index 9f5b9e41da..743b2a32ee 100644 --- a/plugins/search-backend-module-techdocs/CHANGELOG.md +++ b/plugins/search-backend-module-techdocs/CHANGELOG.md @@ -1,5 +1,24 @@ # @backstage/plugin-search-backend-module-techdocs +## 0.1.28-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-search-backend-node@1.2.28-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/plugin-catalog-node@1.12.5-next.2 + - @backstage/plugin-techdocs-node@1.12.9-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + ## 0.1.28-next.1 ### Patch Changes diff --git a/plugins/search-backend-module-techdocs/package.json b/plugins/search-backend-module-techdocs/package.json index 0dc3a362d3..92b59c209c 100644 --- a/plugins/search-backend-module-techdocs/package.json +++ b/plugins/search-backend-module-techdocs/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-search-backend-module-techdocs", - "version": "0.1.28-next.1", + "version": "0.1.28-next.2", "description": "A module for the search backend that exports techdocs modules", "backstage": { "role": "backend-plugin-module", diff --git a/plugins/search-backend-node/CHANGELOG.md b/plugins/search-backend-node/CHANGELOG.md index 9597076338..90c4b9fa8b 100644 --- a/plugins/search-backend-node/CHANGELOG.md +++ b/plugins/search-backend-node/CHANGELOG.md @@ -1,5 +1,20 @@ # @backstage/plugin-search-backend-node +## 1.2.28-next.2 + +### Patch Changes + +- 3123c16: Fix package metadata +- 7c5f3b0: Explicit declare if the service ref accepts `single` or `multiple` implementations. +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/backend-tasks@0.5.28-next.2 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + ## 1.2.28-next.1 ### Patch Changes diff --git a/plugins/search-backend-node/package.json b/plugins/search-backend-node/package.json index 01337796b0..a7c53e61d1 100644 --- a/plugins/search-backend-node/package.json +++ b/plugins/search-backend-node/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-search-backend-node", - "version": "1.2.28-next.1", + "version": "1.2.28-next.2", "description": "A library for Backstage backend plugins that want to interact with the search backend plugin", "backstage": { "role": "node-library", diff --git a/plugins/search-backend/CHANGELOG.md b/plugins/search-backend/CHANGELOG.md index 16e4c8ae4f..b6f4e9c001 100644 --- a/plugins/search-backend/CHANGELOG.md +++ b/plugins/search-backend/CHANGELOG.md @@ -1,5 +1,23 @@ # @backstage/plugin-search-backend +## 1.5.15-next.2 + +### Patch Changes + +- 3123c16: Fix package metadata +- Updated dependencies + - @backstage/backend-defaults@0.4.2-next.2 + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-permission-node@0.8.1-next.2 + - @backstage/plugin-search-backend-node@1.2.28-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/backend-openapi-utils@0.1.16-next.2 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + ## 1.5.15-next.1 ### Patch Changes diff --git a/plugins/search-backend/package.json b/plugins/search-backend/package.json index 0e39ff2638..105a317a39 100644 --- a/plugins/search-backend/package.json +++ b/plugins/search-backend/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-search-backend", - "version": "1.5.15-next.1", + "version": "1.5.15-next.2", "description": "The Backstage backend plugin that provides your backstage app with search", "backstage": { "role": "backend-plugin", diff --git a/plugins/search-common/CHANGELOG.md b/plugins/search-common/CHANGELOG.md index dc76382d5c..9b6f2ed89c 100644 --- a/plugins/search-common/CHANGELOG.md +++ b/plugins/search-common/CHANGELOG.md @@ -1,5 +1,14 @@ # @backstage/plugin-search-common +## 1.2.14-next.1 + +### Patch Changes + +- 3123c16: Fix package metadata +- Updated dependencies + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/types@1.1.1 + ## 1.2.14-next.0 ### Patch Changes diff --git a/plugins/search-common/package.json b/plugins/search-common/package.json index c58aff0c21..073f5ead39 100644 --- a/plugins/search-common/package.json +++ b/plugins/search-common/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-search-common", - "version": "1.2.14-next.0", + "version": "1.2.14-next.1", "description": "Common functionalities for Search, to be shared between various search-enabled plugins", "backstage": { "role": "common-library", diff --git a/plugins/search-react/CHANGELOG.md b/plugins/search-react/CHANGELOG.md index f3c5688145..4b8307c516 100644 --- a/plugins/search-react/CHANGELOG.md +++ b/plugins/search-react/CHANGELOG.md @@ -1,5 +1,19 @@ # @backstage/plugin-search-react +## 1.7.14-next.2 + +### Patch Changes + +- 3123c16: Fix package metadata +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/theme@0.5.6 + - @backstage/types@1.1.1 + - @backstage/version-bridge@1.0.8 + ## 1.7.14-next.1 ### Patch Changes diff --git a/plugins/search-react/package.json b/plugins/search-react/package.json index 87ebe36f14..21ee4e4904 100644 --- a/plugins/search-react/package.json +++ b/plugins/search-react/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-search-react", - "version": "1.7.14-next.1", + "version": "1.7.14-next.2", "backstage": { "role": "web-library", "pluginId": "search", diff --git a/plugins/search/CHANGELOG.md b/plugins/search/CHANGELOG.md index 5e04d7a198..ad3703a51e 100644 --- a/plugins/search/CHANGELOG.md +++ b/plugins/search/CHANGELOG.md @@ -1,5 +1,22 @@ # @backstage/plugin-search +## 1.4.15-next.2 + +### Patch Changes + +- 3123c16: Fix package metadata +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-compat-api@0.2.8-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/plugin-search-react@1.7.14-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + - @backstage/version-bridge@1.0.8 + ## 1.4.15-next.1 ### Patch Changes diff --git a/plugins/search/package.json b/plugins/search/package.json index e1cbfcd76a..9cad64fcd5 100644 --- a/plugins/search/package.json +++ b/plugins/search/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-search", - "version": "1.4.15-next.1", + "version": "1.4.15-next.2", "description": "The Backstage plugin that provides your backstage app with search", "backstage": { "role": "frontend-plugin", diff --git a/plugins/signals-backend/CHANGELOG.md b/plugins/signals-backend/CHANGELOG.md index d95a9d74a3..ad5f012dbd 100644 --- a/plugins/signals-backend/CHANGELOG.md +++ b/plugins/signals-backend/CHANGELOG.md @@ -1,5 +1,19 @@ # @backstage/plugin-signals-backend +## 0.1.9-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/plugin-signals-node@0.1.9-next.2 + - @backstage/config@1.2.0 + - @backstage/types@1.1.1 + ## 0.1.9-next.1 ### Patch Changes diff --git a/plugins/signals-backend/package.json b/plugins/signals-backend/package.json index 05e7189beb..81627acd13 100644 --- a/plugins/signals-backend/package.json +++ b/plugins/signals-backend/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-signals-backend", - "version": "0.1.9-next.1", + "version": "0.1.9-next.2", "backstage": { "role": "backend-plugin", "pluginId": "signals", diff --git a/plugins/signals-node/CHANGELOG.md b/plugins/signals-node/CHANGELOG.md index ac1b4d835d..c9b4ed0d9f 100644 --- a/plugins/signals-node/CHANGELOG.md +++ b/plugins/signals-node/CHANGELOG.md @@ -1,5 +1,17 @@ # @backstage/plugin-signals-node +## 0.1.9-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-events-node@0.3.9-next.2 + - @backstage/config@1.2.0 + - @backstage/types@1.1.1 + ## 0.1.9-next.1 ### Patch Changes diff --git a/plugins/signals-node/package.json b/plugins/signals-node/package.json index 7b98587482..7dd3df3902 100644 --- a/plugins/signals-node/package.json +++ b/plugins/signals-node/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-signals-node", - "version": "0.1.9-next.1", + "version": "0.1.9-next.2", "description": "Node.js library for the signals plugin", "backstage": { "role": "node-library", diff --git a/plugins/techdocs-addons-test-utils/CHANGELOG.md b/plugins/techdocs-addons-test-utils/CHANGELOG.md index 728f9e073d..e6556fd543 100644 --- a/plugins/techdocs-addons-test-utils/CHANGELOG.md +++ b/plugins/techdocs-addons-test-utils/CHANGELOG.md @@ -1,5 +1,20 @@ # @backstage/plugin-techdocs-addons-test-utils +## 1.0.37-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/plugin-catalog@1.22.0-next.2 + - @backstage/plugin-search-react@1.7.14-next.2 + - @backstage/plugin-techdocs@1.10.8-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/test-utils@1.5.10-next.2 + - @backstage/core-app-api@1.14.2-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/integration-react@1.1.30-next.0 + - @backstage/plugin-techdocs-react@1.2.7-next.0 + ## 1.0.37-next.1 ### Patch Changes diff --git a/plugins/techdocs-addons-test-utils/package.json b/plugins/techdocs-addons-test-utils/package.json index a13624e2d8..9ef481927e 100644 --- a/plugins/techdocs-addons-test-utils/package.json +++ b/plugins/techdocs-addons-test-utils/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-techdocs-addons-test-utils", - "version": "1.0.37-next.1", + "version": "1.0.37-next.2", "backstage": { "role": "web-library", "pluginId": "techdocs-addons", diff --git a/plugins/techdocs-backend/CHANGELOG.md b/plugins/techdocs-backend/CHANGELOG.md index cc0383d7f4..0fc47107da 100644 --- a/plugins/techdocs-backend/CHANGELOG.md +++ b/plugins/techdocs-backend/CHANGELOG.md @@ -1,5 +1,24 @@ # @backstage/plugin-techdocs-backend +## 1.10.10-next.2 + +### Patch Changes + +- 93095ee: Make sure node-fetch is version 2.7.0 or greater +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/plugin-permission-common@0.8.1-next.1 + - @backstage/plugin-search-backend-module-techdocs@0.1.28-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-techdocs-node@1.12.9-next.2 + - @backstage/plugin-catalog-common@1.0.26-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-client@1.6.5 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/plugin-techdocs-common@0.1.0-next.0 + ## 1.10.10-next.1 ### Patch Changes diff --git a/plugins/techdocs-backend/package.json b/plugins/techdocs-backend/package.json index 448f88e800..9c0355956e 100644 --- a/plugins/techdocs-backend/package.json +++ b/plugins/techdocs-backend/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-techdocs-backend", - "version": "1.10.10-next.1", + "version": "1.10.10-next.2", "description": "The Backstage backend plugin that renders technical documentation for your components", "backstage": { "role": "backend-plugin", diff --git a/plugins/techdocs-node/CHANGELOG.md b/plugins/techdocs-node/CHANGELOG.md index 40c203014e..22cf92a28c 100644 --- a/plugins/techdocs-node/CHANGELOG.md +++ b/plugins/techdocs-node/CHANGELOG.md @@ -1,5 +1,20 @@ # @backstage/plugin-techdocs-node +## 1.12.9-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/integration@1.14.0-next.0 + - @backstage/integration-aws-node@0.1.12 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/plugin-techdocs-common@0.1.0-next.0 + ## 1.12.9-next.1 ### Patch Changes diff --git a/plugins/techdocs-node/package.json b/plugins/techdocs-node/package.json index 8553169546..f6fa8a9948 100644 --- a/plugins/techdocs-node/package.json +++ b/plugins/techdocs-node/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-techdocs-node", - "version": "1.12.9-next.1", + "version": "1.12.9-next.2", "description": "Common node.js functionalities for TechDocs, to be shared between techdocs-backend plugin and techdocs-cli", "backstage": { "role": "node-library", diff --git a/plugins/techdocs/CHANGELOG.md b/plugins/techdocs/CHANGELOG.md index 0318bf45aa..237612750d 100644 --- a/plugins/techdocs/CHANGELOG.md +++ b/plugins/techdocs/CHANGELOG.md @@ -1,5 +1,29 @@ # @backstage/plugin-techdocs +## 1.10.8-next.2 + +### Patch Changes + +- 67e76f2: TechDocs now supports the `mkdocs-redirects` plugin. Redirects defined using the `mkdocs-redirect` plugin will be handled automatically in TechDocs. Redirecting to external urls is not supported. In the case that an external redirect url is provided, TechDocs will redirect to the current documentation site home. +- bdc5471: Fixed issue where header styles were incorrectly generated when themes used CSS variables to define font size. +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-compat-api@0.2.8-next.2 + - @backstage/plugin-search-common@1.2.14-next.1 + - @backstage/plugin-search-react@1.7.14-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/integration@1.14.0-next.0 + - @backstage/catalog-model@1.5.0 + - @backstage/config@1.2.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/errors@1.2.4 + - @backstage/integration-react@1.1.30-next.0 + - @backstage/theme@0.5.6 + - @backstage/plugin-auth-react@0.1.5-next.0 + - @backstage/plugin-techdocs-common@0.1.0-next.0 + - @backstage/plugin-techdocs-react@1.2.7-next.0 + ## 1.10.8-next.1 ### Patch Changes diff --git a/plugins/techdocs/package.json b/plugins/techdocs/package.json index c08dd92f09..9ff5e3e2f4 100644 --- a/plugins/techdocs/package.json +++ b/plugins/techdocs/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-techdocs", - "version": "1.10.8-next.1", + "version": "1.10.8-next.2", "description": "The Backstage plugin that renders technical documentation for your components", "backstage": { "role": "frontend-plugin", diff --git a/plugins/user-settings-backend/CHANGELOG.md b/plugins/user-settings-backend/CHANGELOG.md index 9101a22bef..144d27d627 100644 --- a/plugins/user-settings-backend/CHANGELOG.md +++ b/plugins/user-settings-backend/CHANGELOG.md @@ -1,5 +1,19 @@ # @backstage/plugin-user-settings-backend +## 0.2.22-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/backend-plugin-api@0.8.0-next.2 + - @backstage/backend-common@0.23.4-next.2 + - @backstage/plugin-auth-node@0.5.0-next.2 + - @backstage/plugin-signals-node@0.1.9-next.2 + - @backstage/config@1.2.0 + - @backstage/errors@1.2.4 + - @backstage/types@1.1.1 + - @backstage/plugin-user-settings-common@0.0.1 + ## 0.2.22-next.1 ### Patch Changes diff --git a/plugins/user-settings-backend/package.json b/plugins/user-settings-backend/package.json index 244209a267..808f59fec4 100644 --- a/plugins/user-settings-backend/package.json +++ b/plugins/user-settings-backend/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-user-settings-backend", - "version": "0.2.22-next.1", + "version": "0.2.22-next.2", "description": "The Backstage backend plugin to manage user settings", "backstage": { "role": "backend-plugin", diff --git a/plugins/user-settings/CHANGELOG.md b/plugins/user-settings/CHANGELOG.md index dafa984b09..a1aaa74828 100644 --- a/plugins/user-settings/CHANGELOG.md +++ b/plugins/user-settings/CHANGELOG.md @@ -1,5 +1,22 @@ # @backstage/plugin-user-settings +## 0.8.11-next.2 + +### Patch Changes + +- Updated dependencies + - @backstage/frontend-plugin-api@0.7.0-next.2 + - @backstage/core-compat-api@0.2.8-next.2 + - @backstage/plugin-catalog-react@1.12.3-next.2 + - @backstage/core-app-api@1.14.2-next.0 + - @backstage/core-components@0.14.10-next.0 + - @backstage/core-plugin-api@1.9.3 + - @backstage/errors@1.2.4 + - @backstage/theme@0.5.6 + - @backstage/types@1.1.1 + - @backstage/plugin-signals-react@0.0.4 + - @backstage/plugin-user-settings-common@0.0.1 + ## 0.8.11-next.1 ### Patch Changes diff --git a/plugins/user-settings/package.json b/plugins/user-settings/package.json index b229e625b6..4217cf3329 100644 --- a/plugins/user-settings/package.json +++ b/plugins/user-settings/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-user-settings", - "version": "0.8.11-next.1", + "version": "0.8.11-next.2", "description": "A Backstage plugin that provides a settings page", "backstage": { "role": "frontend-plugin", From fed70efe37f27ce7f589108475c3be29aa4d69d0 Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 5 Aug 2024 16:03:35 +0200 Subject: [PATCH 138/372] chore: working through the inputs merging Signed-off-by: blam --- .../wiring/createExtensionBlueprint.test.tsx | 66 +++++++++++++++++++ .../src/wiring/createExtensionBlueprint.ts | 39 +++++++---- 2 files changed, 93 insertions(+), 12 deletions(-) diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx index dfdbfface6..5f1324fe7c 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx @@ -384,4 +384,70 @@ describe('createExtensionBlueprint', () => { expect(true).toBe(true); }); + + it('should allow merging of inputs', () => { + const blueprint = createExtensionBlueprint({ + kind: 'test-extension', + attachTo: { id: 'test', input: 'default' }, + inputs: { + test: createExtensionInput([coreExtensionData.routeRef], { + singleton: true, + }), + }, + output: [coreExtensionData.reactElement.optional()], + factory(_params: { x?: string }, { inputs }) { + const ref: RouteRef = inputs.test.get(coreExtensionData.routeRef); + + unused(ref); + return []; + }, + }); + + blueprint.make({ + inputs: { + test2: createExtensionInput([coreExtensionData.reactElement], { + singleton: true, + }), + }, + factory(origFactory, { inputs }) { + const ref: RouteRef = inputs.test.get(coreExtensionData.routeRef); + + const el: JSX.Element = inputs.test2.get( + coreExtensionData.reactElement, + ); + + unused(ref, el); + + return origFactory({}); + }, + }); + + expect(true).toBe(true); + }); + + it('should not allow overriding inputs', () => { + const blueprint = createExtensionBlueprint({ + kind: 'test-extension', + attachTo: { id: 'test', input: 'default' }, + inputs: { + test: createExtensionInput([coreExtensionData.routeRef]), + }, + output: [coreExtensionData.reactElement.optional()], + factory() { + return []; + }, + }); + + blueprint.make({ + inputs: { + // @ts-expect-error + test: createExtensionInput([]), // Overrides are not allowed + }, + factory(origFactory) { + return origFactory({}); + }, + }); + + expect(true).toBe(true); + }); }); diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts index 46db278bf8..90736703a0 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts @@ -83,7 +83,6 @@ export interface ExtensionBlueprint< { optional: boolean; singleton: boolean } >; }, - UExtraOutput extends AnyExtensionDataRef, TConfig extends { [key in string]: unknown }, TConfigInput extends { [key in string]: unknown }, TDataRefs extends { [name in string]: AnyExtensionDataRef }, @@ -101,13 +100,23 @@ export interface ExtensionBlueprint< [key in string]: (zImpl: typeof z) => z.ZodType; }, UFactoryOutput extends ExtensionDataValue, + UExtraOutput extends AnyExtensionDataRef, + TExtraInputs extends { + [inputName in string]: ExtensionInput< + AnyExtensionDataRef, + { optional: boolean; singleton: boolean } + >; + }, >( args: { namespace?: string; name?: string; attachTo?: { id: string; input: string }; disabled?: boolean; - inputs?: TInputs; + inputs?: TExtraInputs & { + [KName in keyof TInputs]?: `Error: Input '${KName & + string}' is already defined in parent definition`; + }; output?: Array; config?: { schema: TExtensionConfigSchema & { @@ -132,7 +141,7 @@ export interface ExtensionBlueprint< ReturnType >; }; - inputs: Expand>; + inputs: Expand>; }, ): Iterable; } & VerifyExtensionFactoryOutput< @@ -172,7 +181,6 @@ class ExtensionBlueprintImpl< { optional: boolean; singleton: boolean } >; }, - UExtraOutput extends AnyExtensionDataRef, TConfigSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType }, TDataRefs extends { [name in string]: AnyExtensionDataRef }, > { @@ -196,12 +204,22 @@ class ExtensionBlueprintImpl< [key in string]: (zImpl: typeof z) => z.ZodType; }, UFactoryOutput extends ExtensionDataValue, + UExtraOutput extends AnyExtensionDataRef, + TExtraInputs extends { + [inputName in string]: ExtensionInput< + AnyExtensionDataRef, + { optional: boolean; singleton: boolean } + >; + }, >(args: { namespace?: string; name?: string; attachTo?: { id: string; input: string }; disabled?: boolean; - inputs?: TInputs; + inputs?: TExtraInputs & { + [KName in keyof TInputs]?: `Error: Input '${KName & + string}' is already defined in parent definition`; + }; output?: Array; params?: TParams; config?: { @@ -228,7 +246,7 @@ class ExtensionBlueprintImpl< } & { [key in keyof TConfigSchema]: z.infer>; }; - inputs: Expand>; + inputs: Expand>; }, ): Iterable; }): ExtensionDefinition< @@ -277,7 +295,7 @@ class ExtensionBlueprintImpl< name: args.name ?? name, attachTo: args.attachTo ?? this.options.attachTo, disabled: args.disabled ?? this.options.disabled, - inputs: args.inputs ?? this.options.inputs, + inputs: { ...args.inputs, ...this.options.inputs }, output: [...(args.output ?? []), ...this.options.output], config: Object.keys(schema).length === 0 ? undefined : { schema }, factory: ({ node, config, inputs }) => { @@ -297,7 +315,7 @@ class ExtensionBlueprintImpl< return this.options.factory(innerParams, { node, config: innerContext?.config ?? config, - inputs: innerContext?.inputs ?? inputs, + inputs: (innerContext?.inputs ?? inputs) as any, // TODO: Fix the way input values are overridden }); }, { @@ -317,7 +335,7 @@ class ExtensionBlueprintImpl< }, } as CreateExtensionOptions< UOutput, - TInputs, + TInputs & TExtraInputs, { [key in keyof TExtensionConfigSchema]: z.infer< ReturnType @@ -357,7 +375,6 @@ export function createExtensionBlueprint< { optional: boolean; singleton: boolean } >; }, - UExtraOutput extends AnyExtensionDataRef, TConfigSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType }, UFactoryOutput extends ExtensionDataValue, TDataRefs extends { [name in string]: AnyExtensionDataRef } = never, @@ -374,7 +391,6 @@ export function createExtensionBlueprint< TParams, UOutput, TInputs, - UExtraOutput, string extends keyof TConfigSchema ? {} : { [key in keyof TConfigSchema]: z.infer> }, @@ -391,7 +407,6 @@ export function createExtensionBlueprint< TParams, UOutput, TInputs, - UExtraOutput, string extends keyof TConfigSchema ? {} : { From 65a1f99d0320179a22129956d5f6291f1765d73a Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 5 Aug 2024 17:11:56 +0200 Subject: [PATCH 139/372] chore: Fixing some typescript errors Signed-off-by: blam --- .../src/wiring/createExtensionBlueprint.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts index 90736703a0..465bb10ee6 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts @@ -328,7 +328,10 @@ class ExtensionBlueprintImpl< return this.options.factory(args.params, { node, config, - inputs, + // TODO: Figure out types once legacy data map input type is gone + inputs: inputs as unknown as Expand< + ResolvedExtensionInputs + >, }); } throw new Error('Either params or factory must be provided'); From 34f1b2aeb1234428fe74e4581161845dd8fbfdff Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 5 Aug 2024 17:13:50 +0200 Subject: [PATCH 140/372] chore: changeset Signed-off-by: blam --- .changeset/six-mails-smell.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/six-mails-smell.md diff --git a/.changeset/six-mails-smell.md b/.changeset/six-mails-smell.md new file mode 100644 index 0000000000..db39259632 --- /dev/null +++ b/.changeset/six-mails-smell.md @@ -0,0 +1,5 @@ +--- +'@backstage/frontend-plugin-api': patch +--- + +Support merging of `inputs` in `Blueprints` From 1533b959ef56550d5dfa38ecd4591845796522b1 Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 5 Aug 2024 17:35:13 +0200 Subject: [PATCH 141/372] chore: steps to making outputs and factories look pretty Signed-off-by: blam --- .../src/wiring/createExtension.ts | 36 +++++---- .../wiring/createExtensionBlueprint.test.tsx | 76 +++++++++++++++++++ .../src/wiring/createExtensionBlueprint.ts | 6 +- 3 files changed, 102 insertions(+), 16 deletions(-) diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.ts b/packages/frontend-plugin-api/src/wiring/createExtension.ts index a8bf4ef17c..101c5cd43a 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.ts @@ -148,7 +148,9 @@ export interface LegacyCreateExtensionOptions< /** @ignore */ export type VerifyExtensionFactoryOutput< UDeclaredOutput extends AnyExtensionDataRef, - UFactoryOutput extends ExtensionDataValue, + UFactoryOutput extends + | ExtensionDataValue + | ExtensionDataContainer, > = ( UDeclaredOutput extends any ? UDeclaredOutput['config']['optional'] extends true @@ -156,21 +158,29 @@ export type VerifyExtensionFactoryOutput< : UDeclaredOutput['id'] : never ) extends infer IRequiredOutputIds - ? [IRequiredOutputIds] extends [UFactoryOutput['id']] - ? [UFactoryOutput['id']] extends [UDeclaredOutput['id']] - ? {} + ? ( + UFactoryOutput extends ExtensionDataValue + ? UFactoryOutput['id'] + : UFactoryOutput extends ExtensionDataContainer + ? IDataRefs['id'] + : never + ) extends infer IFactoryOutputIds + ? [IRequiredOutputIds] extends [IFactoryOutputIds] + ? [IFactoryOutputIds] extends [UDeclaredOutput['id']] + ? {} + : { + 'Error: The extension factory has undeclared output(s)': Exclude< + IFactoryOutputIds, + UDeclaredOutput['id'] + >; + } : { - 'Error: The extension factory has undeclared output(s)': Exclude< - UFactoryOutput['id'], - UDeclaredOutput['id'] + 'Error: The extension factory is missing the following output(s)': Exclude< + IRequiredOutputIds, + IFactoryOutputIds >; } - : { - 'Error: The extension factory is missing the following output(s)': Exclude< - IRequiredOutputIds, - UFactoryOutput['id'] - >; - } + : never : never; /** @public */ diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx index 5f1324fe7c..fed8185df1 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx @@ -21,6 +21,7 @@ import { createExtensionTester } from '@backstage/frontend-test-utils'; import { createExtensionDataRef } from './createExtensionDataRef'; import { createExtensionInput } from './createExtensionInput'; import { RouteRef } from '../routing'; +import { toInternalExtensionDefinition } from './createExtension'; function unused(..._any: any[]) {} @@ -450,4 +451,79 @@ describe('createExtensionBlueprint', () => { expect(true).toBe(true); }); + + it('should replace the outputs when provided through make', () => { + const testDataRef1 = createExtensionDataRef().with({ id: 'test1' }); + const testDataRef2 = createExtensionDataRef().with({ id: 'test2' }); + + const blueprint = createExtensionBlueprint({ + kind: 'test-extension', + attachTo: { id: 'test', input: 'default' }, + output: [testDataRef1], + factory() { + return [testDataRef1('foo')]; + }, + }); + + const ext = toInternalExtensionDefinition( + blueprint.make({ + output: [testDataRef2], + factory(origFactory) { + const parent = origFactory({}); + return [testDataRef2(`${parent.get(testDataRef1)}bar`)]; + }, + }), + ); + + expect(ext.output).toEqual([testDataRef2]); + }); + + it('should allow returning of the parent data container', () => { + const testDataRef1 = createExtensionDataRef().with({ id: 'test1' }); + const testDataRef2 = createExtensionDataRef().with({ id: 'test2' }); + + const blueprint = createExtensionBlueprint({ + kind: 'test-extension', + attachTo: { id: 'test', input: 'default' }, + output: [testDataRef1], + factory() { + return [testDataRef1('foo')]; + }, + }); + + blueprint.make({ + output: [testDataRef1, testDataRef2], + *factory(origFactory) { + yield origFactory({}); + yield testDataRef2('bar'); + }, + }); + + expect(true).toBe(true); + // todo: test that the data is actually available + }); + + it('should not allow returning parent output if outputs are overridden', () => { + const testDataRef1 = createExtensionDataRef().with({ id: 'test1' }); + const testDataRef2 = createExtensionDataRef().with({ id: 'test2' }); + + const blueprint = createExtensionBlueprint({ + kind: 'test-extension', + attachTo: { id: 'test', input: 'default' }, + output: [testDataRef1.optional()], + factory() { + return [testDataRef1('foo')]; + }, + }); + + blueprint.make({ + output: [testDataRef2.optional()], + *factory(origFactory) { + // yield testDataRef1('bar'); + yield testDataRef2('bar'); + }, + }); + + expect(true).toBe(true); + }); }); diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts index 465bb10ee6..e56c30410d 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts @@ -204,7 +204,7 @@ class ExtensionBlueprintImpl< [key in string]: (zImpl: typeof z) => z.ZodType; }, UFactoryOutput extends ExtensionDataValue, - UExtraOutput extends AnyExtensionDataRef, + UNewOutput extends AnyExtensionDataRef, TExtraInputs extends { [inputName in string]: ExtensionInput< AnyExtensionDataRef, @@ -220,7 +220,7 @@ class ExtensionBlueprintImpl< [KName in keyof TInputs]?: `Error: Input '${KName & string}' is already defined in parent definition`; }; - output?: Array; + output?: Array; params?: TParams; config?: { schema: TExtensionConfigSchema; @@ -296,7 +296,7 @@ class ExtensionBlueprintImpl< attachTo: args.attachTo ?? this.options.attachTo, disabled: args.disabled ?? this.options.disabled, inputs: { ...args.inputs, ...this.options.inputs }, - output: [...(args.output ?? []), ...this.options.output], + output: args.output ?? this.options.output, config: Object.keys(schema).length === 0 ? undefined : { schema }, factory: ({ node, config, inputs }) => { if (args.factory) { From eda2165093264814f648d0e9db7f495149701a79 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 6 Aug 2024 15:47:57 +0200 Subject: [PATCH 142/372] frontend-plugin-api: working types for extension data containers as iterables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fredrik Adelöw Co-authored-by: blam Signed-off-by: Patrik Oldsberg --- .../src/wiring/createExtension.ts | 12 +++++++++++- .../src/wiring/createExtensionBlueprint.test.tsx | 12 +++++++++--- .../src/wiring/createExtensionBlueprint.ts | 14 +++++++------- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.ts b/packages/frontend-plugin-api/src/wiring/createExtension.ts index 101c5cd43a..2c82c44ee1 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.ts @@ -65,7 +65,17 @@ export type ExtensionDataValues = { /** @public */ export type ExtensionDataContainer = - { + Iterable< + UExtensionData extends ExtensionDataRef< + infer IData, + infer IId, + infer IConfig + > + ? IConfig['optional'] extends true + ? never + : ExtensionDataValue + : never + > & { get( ref: ExtensionDataRef, ): UExtensionData extends ExtensionDataRef diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx index fed8185df1..70d874d9ad 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx @@ -494,11 +494,18 @@ describe('createExtensionBlueprint', () => { blueprint.make({ output: [testDataRef1, testDataRef2], *factory(origFactory) { - yield origFactory({}); + yield* origFactory({}); yield testDataRef2('bar'); }, }); + blueprint.make({ + output: [testDataRef1, testDataRef2], + factory(origFactory) { + return [...origFactory({}), testDataRef2('bar')]; + }, + }); + expect(true).toBe(true); // todo: test that the data is actually available }); @@ -518,8 +525,7 @@ describe('createExtensionBlueprint', () => { blueprint.make({ output: [testDataRef2.optional()], - *factory(origFactory) { - // yield testDataRef1('bar'); + *factory() { yield testDataRef2('bar'); }, }); diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts index e56c30410d..603ffda621 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts @@ -18,6 +18,7 @@ import { AppNode } from '../apis'; import { Expand } from '../types'; import { CreateExtensionOptions, + ExtensionDataContainer, ExtensionDefinition, ResolvedExtensionInputs, VerifyExtensionFactoryOutput, @@ -27,7 +28,6 @@ import { z } from 'zod'; import { ExtensionInput } from './createExtensionInput'; import { AnyExtensionDataRef, - ExtensionDataRefToValue, ExtensionDataValue, } from './createExtensionDataRef'; @@ -100,7 +100,7 @@ export interface ExtensionBlueprint< [key in string]: (zImpl: typeof z) => z.ZodType; }, UFactoryOutput extends ExtensionDataValue, - UExtraOutput extends AnyExtensionDataRef, + UNewOutput extends AnyExtensionDataRef, TExtraInputs extends { [inputName in string]: ExtensionInput< AnyExtensionDataRef, @@ -117,7 +117,7 @@ export interface ExtensionBlueprint< [KName in keyof TInputs]?: `Error: Input '${KName & string}' is already defined in parent definition`; }; - output?: Array; + output?: Array; config?: { schema: TExtensionConfigSchema & { [KName in keyof TConfig]?: `Error: Config key '${KName & @@ -133,7 +133,7 @@ export interface ExtensionBlueprint< config?: TConfig; inputs?: Expand>; }, - ) => Iterable>, + ) => ExtensionDataContainer, context: { node: AppNode; config: TConfig & { @@ -145,7 +145,7 @@ export interface ExtensionBlueprint< }, ): Iterable; } & VerifyExtensionFactoryOutput< - UOutput & UExtraOutput, + AnyExtensionDataRef extends UNewOutput ? UOutput : UNewOutput, UFactoryOutput >) | { @@ -236,7 +236,7 @@ class ExtensionBlueprintImpl< }; inputs?: Expand>; }, - ) => Iterable>, + ) => ExtensionDataContainer, context: { node: AppNode; config: { @@ -311,7 +311,7 @@ class ExtensionBlueprintImpl< }; inputs?: Expand>; }, - ): Iterable> => { + ): ExtensionDataContainer => { return this.options.factory(innerParams, { node, config: innerContext?.config ?? config, From e8867e17f1fb751cb47b85d273fb93a2ba4e3bc3 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 6 Aug 2024 17:23:26 +0200 Subject: [PATCH 143/372] frontend-plugin-api: extension data container runtime + tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fredrik Adelöw Co-authored-by: blam Signed-off-by: Patrik Oldsberg --- .../wiring/createExtensionBlueprint.test.tsx | 99 +++++++++++++++---- .../src/wiring/createExtensionBlueprint.ts | 37 ++++++- 2 files changed, 113 insertions(+), 23 deletions(-) diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx index 70d874d9ad..66c3939a96 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx @@ -21,10 +21,21 @@ import { createExtensionTester } from '@backstage/frontend-test-utils'; import { createExtensionDataRef } from './createExtensionDataRef'; import { createExtensionInput } from './createExtensionInput'; import { RouteRef } from '../routing'; -import { toInternalExtensionDefinition } from './createExtension'; +import { + ExtensionDefinition, + toInternalExtensionDefinition, +} from './createExtension'; function unused(..._any: any[]) {} +function factoryOutput(ext: ExtensionDefinition) { + const int = toInternalExtensionDefinition(ext); + if (int.version !== 'v2') { + throw new Error('Expected v2 extension'); + } + return Array.from(int.factory({} as any)); +} + describe('createExtensionBlueprint', () => { it('should allow creation of extension blueprints', () => { const TestExtensionBlueprint = createExtensionBlueprint({ @@ -476,6 +487,8 @@ describe('createExtensionBlueprint', () => { ); expect(ext.output).toEqual([testDataRef2]); + + expect(factoryOutput(ext)).toEqual([testDataRef2('foobar')]); }); it('should allow returning of the parent data container', () => { @@ -491,23 +504,28 @@ describe('createExtensionBlueprint', () => { }, }); - blueprint.make({ - output: [testDataRef1, testDataRef2], - *factory(origFactory) { - yield* origFactory({}); - yield testDataRef2('bar'); - }, - }); + expect( + factoryOutput( + blueprint.make({ + output: [testDataRef1, testDataRef2], + *factory(origFactory) { + yield* origFactory({}); + yield testDataRef2('bar'); + }, + }), + ), + ).toEqual([testDataRef1('foo'), testDataRef2('bar')]); - blueprint.make({ - output: [testDataRef1, testDataRef2], - factory(origFactory) { - return [...origFactory({}), testDataRef2('bar')]; - }, - }); - - expect(true).toBe(true); - // todo: test that the data is actually available + expect( + factoryOutput( + blueprint.make({ + output: [testDataRef1, testDataRef2], + factory(origFactory) { + return [...origFactory({}), testDataRef2('bar')]; + }, + }), + ), + ).toEqual([testDataRef1('foo'), testDataRef2('bar')]); }); it('should not allow returning parent output if outputs are overridden', () => { @@ -523,13 +541,58 @@ describe('createExtensionBlueprint', () => { }, }); + // @ts-expect-error blueprint.make({ output: [testDataRef2.optional()], *factory() { + yield testDataRef1('foo'); yield testDataRef2('bar'); }, }); - expect(true).toBe(true); + expect( + factoryOutput( + blueprint.make({ + output: [testDataRef2.optional()], + *factory() { + yield testDataRef2('bar'); + }, + }), + ), + ).toEqual([testDataRef2('bar')]); + }); + + it('should not rely on optional outputs when forwarding from parent', () => { + const testDataRef1 = createExtensionDataRef().with({ id: 'test1' }); + const testDataRef2 = createExtensionDataRef().with({ id: 'test2' }); + + const blueprint = createExtensionBlueprint({ + kind: 'test-extension', + attachTo: { id: 'test', input: 'default' }, + output: [testDataRef1, testDataRef2.optional()], + factory() { + return [testDataRef1('foo')]; + }, + }); + + // @ts-expect-error + blueprint.make({ + output: [testDataRef1, testDataRef2], + *factory(origFactory) { + yield* origFactory({}); + }, + }); + + expect( + factoryOutput( + blueprint.make({ + output: [testDataRef1, testDataRef2], + *factory(origFactory) { + yield* origFactory({}); + yield testDataRef2('bar'); + }, + }), + ), + ).toEqual([testDataRef1('foo'), testDataRef2('bar')]); }); }); diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts index 603ffda621..2b80dac81e 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts @@ -28,6 +28,7 @@ import { z } from 'zod'; import { ExtensionInput } from './createExtensionInput'; import { AnyExtensionDataRef, + ExtensionDataRef, ExtensionDataValue, } from './createExtensionDataRef'; @@ -169,6 +170,30 @@ export interface ExtensionBlueprint< >; } +/** @internal */ +function createDataContainer( + values: Iterable< + UData extends ExtensionDataRef + ? ExtensionDataValue + : never + >, +): ExtensionDataContainer { + const container = new Map>(); + + for (const output of values) { + container.set(output.id, output); + } + + return { + get(ref) { + return container.get(ref.id)?.value; + }, + [Symbol.iterator]() { + return container.values(); + }, + } as ExtensionDataContainer; +} + /** * @internal */ @@ -312,11 +337,13 @@ class ExtensionBlueprintImpl< inputs?: Expand>; }, ): ExtensionDataContainer => { - return this.options.factory(innerParams, { - node, - config: innerContext?.config ?? config, - inputs: (innerContext?.inputs ?? inputs) as any, // TODO: Fix the way input values are overridden - }); + return createDataContainer( + this.options.factory(innerParams, { + node, + config: innerContext?.config ?? config, + inputs: (innerContext?.inputs ?? inputs) as any, // TODO: Fix the way input values are overridden + }), + ); }, { node, From 8015a2d81c730c28be30598cc1cb9cd5a9fa5dcc Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 6 Aug 2024 17:27:18 +0200 Subject: [PATCH 144/372] changesets: update blueprints changeset Signed-off-by: Patrik Oldsberg --- .changeset/six-mails-smell.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/six-mails-smell.md b/.changeset/six-mails-smell.md index db39259632..3845c72626 100644 --- a/.changeset/six-mails-smell.md +++ b/.changeset/six-mails-smell.md @@ -2,4 +2,4 @@ '@backstage/frontend-plugin-api': patch --- -Support merging of `inputs` in `Blueprints` +Support merging of `inputs` in extension blueprints, but stop merging `output`. In addition, the original factory in extension blueprints now returns a data container that both provides access to the returned data, but can also be forwarded as output. From 51a4ef638b0406c7bbb1ade7a267ae33af3d91b9 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 6 Aug 2024 17:29:14 +0200 Subject: [PATCH 145/372] frontend-plugin-api: update API report Signed-off-by: Patrik Oldsberg --- packages/frontend-plugin-api/api-report.md | 39 ++++++++++++++++------ 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/packages/frontend-plugin-api/api-report.md b/packages/frontend-plugin-api/api-report.md index cbe92463ba..38b980fcbf 100644 --- a/packages/frontend-plugin-api/api-report.md +++ b/packages/frontend-plugin-api/api-report.md @@ -603,7 +603,6 @@ export function createExtensionBlueprint< } >; }, - UExtraOutput extends AnyExtensionDataRef, TConfigSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType; }, @@ -624,7 +623,6 @@ export function createExtensionBlueprint< TParams, UOutput, TInputs, - UExtraOutput, string extends keyof TConfigSchema ? {} : { @@ -1090,7 +1088,6 @@ export interface ExtensionBlueprint< } >; }, - UExtraOutput extends AnyExtensionDataRef, TConfig extends { [key in string]: unknown; }, @@ -1108,6 +1105,16 @@ export interface ExtensionBlueprint< [key in string]: (zImpl: typeof z) => z.ZodType; }, UFactoryOutput extends ExtensionDataValue, + UNewOutput extends AnyExtensionDataRef, + TExtraInputs extends { + [inputName in string]: ExtensionInput< + AnyExtensionDataRef, + { + optional: boolean; + singleton: boolean; + } + >; + }, >( args: { namespace?: string; @@ -1117,8 +1124,11 @@ export interface ExtensionBlueprint< input: string; }; disabled?: boolean; - inputs?: TInputs; - output?: Array; + inputs?: TExtraInputs & { + [KName in keyof TInputs]?: `Error: Input '${KName & + string}' is already defined in parent definition`; + }; + output?: Array; config?: { schema: TExtensionConfigSchema & { [KName in keyof TConfig]?: `Error: Config key '${KName & @@ -1134,7 +1144,7 @@ export interface ExtensionBlueprint< config?: TConfig; inputs?: Expand>; }, - ) => Iterable>, + ) => ExtensionDataContainer, context: { node: AppNode; config: TConfig & { @@ -1142,11 +1152,11 @@ export interface ExtensionBlueprint< ReturnType >; }; - inputs: Expand>; + inputs: Expand>; }, ): Iterable; } & VerifyExtensionFactoryOutput< - UOutput & UExtraOutput, + AnyExtensionDataRef extends UNewOutput ? UOutput : UNewOutput, UFactoryOutput >) | { @@ -1186,7 +1196,17 @@ export interface ExtensionBoundaryProps { // @public (undocumented) export type ExtensionDataContainer = - { + Iterable< + UExtensionData extends ExtensionDataRef< + infer IData, + infer IId, + infer IConfig + > + ? IConfig['optional'] extends true + ? never + : ExtensionDataValue + : never + > & { get( ref: ExtensionDataRef, ): UExtensionData extends ExtensionDataRef @@ -1356,7 +1376,6 @@ export const IconBundleBlueprint: ExtensionBlueprint< } >; }, - AnyExtensionDataRef, { icons: string; test: string; From 2212c3ef08c63cd54ef19333200c63da9e7d895f Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 6 Aug 2024 17:32:28 +0200 Subject: [PATCH 146/372] frontend-plugin-api: clean up output verification Signed-off-by: Patrik Oldsberg --- .../src/wiring/createExtension.ts | 36 +++++++------------ 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.ts b/packages/frontend-plugin-api/src/wiring/createExtension.ts index 2c82c44ee1..2a29fe1ab4 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.ts @@ -158,9 +158,7 @@ export interface LegacyCreateExtensionOptions< /** @ignore */ export type VerifyExtensionFactoryOutput< UDeclaredOutput extends AnyExtensionDataRef, - UFactoryOutput extends - | ExtensionDataValue - | ExtensionDataContainer, + UFactoryOutput extends ExtensionDataValue, > = ( UDeclaredOutput extends any ? UDeclaredOutput['config']['optional'] extends true @@ -168,29 +166,21 @@ export type VerifyExtensionFactoryOutput< : UDeclaredOutput['id'] : never ) extends infer IRequiredOutputIds - ? ( - UFactoryOutput extends ExtensionDataValue - ? UFactoryOutput['id'] - : UFactoryOutput extends ExtensionDataContainer - ? IDataRefs['id'] - : never - ) extends infer IFactoryOutputIds - ? [IRequiredOutputIds] extends [IFactoryOutputIds] - ? [IFactoryOutputIds] extends [UDeclaredOutput['id']] - ? {} - : { - 'Error: The extension factory has undeclared output(s)': Exclude< - IFactoryOutputIds, - UDeclaredOutput['id'] - >; - } + ? [IRequiredOutputIds] extends [UFactoryOutput['id']] + ? [UFactoryOutput['id']] extends [UDeclaredOutput['id']] + ? {} : { - 'Error: The extension factory is missing the following output(s)': Exclude< - IRequiredOutputIds, - IFactoryOutputIds + 'Error: The extension factory has undeclared output(s)': Exclude< + UFactoryOutput['id'], + UDeclaredOutput['id'] >; } - : never + : { + 'Error: The extension factory is missing the following output(s)': Exclude< + IRequiredOutputIds, + UFactoryOutput['id'] + >; + } : never; /** @public */ From 67f3a3932f857d5bf20b93e6fc3fb01c5adeb5b6 Mon Sep 17 00:00:00 2001 From: Chris Langhout Date: Tue, 6 Aug 2024 18:09:27 +0200 Subject: [PATCH 147/372] fix: add type dep Signed-off-by: Chris Langhout --- packages/backend-defaults/package.json | 1 + .../src/entrypoints/database/connectors/postgres.ts | 2 +- yarn.lock | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/backend-defaults/package.json b/packages/backend-defaults/package.json index 3341c96c75..38d703e2b4 100644 --- a/packages/backend-defaults/package.json +++ b/packages/backend-defaults/package.json @@ -141,6 +141,7 @@ "@opentelemetry/api": "^1.3.0", "@types/cors": "^2.8.6", "@types/express": "^4.17.6", + "@types/pg-format": "^1.0.5", "archiver": "^6.0.0", "base64-stream": "^1.0.0", "better-sqlite3": "^11.0.0", diff --git a/packages/backend-defaults/src/entrypoints/database/connectors/postgres.ts b/packages/backend-defaults/src/entrypoints/database/connectors/postgres.ts index afaa946c05..46b958789d 100644 --- a/packages/backend-defaults/src/entrypoints/database/connectors/postgres.ts +++ b/packages/backend-defaults/src/entrypoints/database/connectors/postgres.ts @@ -29,7 +29,7 @@ import { Connector } from '../types'; import defaultNameOverride from './defaultNameOverride'; import defaultSchemaOverride from './defaultSchemaOverride'; import { mergeDatabaseConfig } from './mergeDatabaseConfig'; -import { format } from 'pg-format'; +import format from 'pg-format'; // Limits the number of concurrent DDL operations to 1 const ddlLimiter = limiterFactory(1); diff --git a/yarn.lock b/yarn.lock index 75552e383b..2da7805693 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3649,6 +3649,7 @@ __metadata: "@types/http-errors": ^2.0.0 "@types/morgan": ^1.9.0 "@types/node-forge": ^1.3.0 + "@types/pg-format": ^1.0.5 "@types/stoppable": ^1.1.0 archiver: ^6.0.0 aws-sdk-client-mock: ^4.0.0 @@ -18593,6 +18594,13 @@ __metadata: languageName: node linkType: hard +"@types/pg-format@npm:^1.0.5": + version: 1.0.5 + resolution: "@types/pg-format@npm:1.0.5" + checksum: e7907b1e478b54aec581d14bc4df349d40d6e30e1f03605e9d162f515f35064e9deaeeb563cb812adfac271522c7ed68b13ebb6e2036d557c5533cf6357419bd + languageName: node + linkType: hard + "@types/pg-pool@npm:2.0.4": version: 2.0.4 resolution: "@types/pg-pool@npm:2.0.4" From 8543e723a5d40b61e7fb32bd5f6d6c9f0df1883a Mon Sep 17 00:00:00 2001 From: Sydney Achinger <78113809+squid-ney@users.noreply.github.com> Date: Tue, 6 Aug 2024 20:55:39 -0400 Subject: [PATCH 148/372] Add UI element to notify user before redirect occurs. (#25911) * Add UI element to notify user before redirect occurs. Allow user to skip to redirect from notification. --------- Signed-off-by: Sydney Achinger --- .changeset/popular-panthers-hear.md | 5 + .../transformers/handleMetaRedirects.test.ts | 30 ++++- .../transformers/handleMetaRedirects.ts | 59 -------- .../transformers/handleMetaRedirects.tsx | 126 ++++++++++++++++++ 4 files changed, 160 insertions(+), 60 deletions(-) create mode 100644 .changeset/popular-panthers-hear.md delete mode 100644 plugins/techdocs/src/reader/transformers/handleMetaRedirects.ts create mode 100644 plugins/techdocs/src/reader/transformers/handleMetaRedirects.tsx diff --git a/.changeset/popular-panthers-hear.md b/.changeset/popular-panthers-hear.md new file mode 100644 index 0000000000..c31586ea82 --- /dev/null +++ b/.changeset/popular-panthers-hear.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs': patch +--- + +TechDocs redirect feature now includes a notification to the user before they are redirected. diff --git a/plugins/techdocs/src/reader/transformers/handleMetaRedirects.test.ts b/plugins/techdocs/src/reader/transformers/handleMetaRedirects.test.ts index 8fbd63428d..12a552577a 100644 --- a/plugins/techdocs/src/reader/transformers/handleMetaRedirects.test.ts +++ b/plugins/techdocs/src/reader/transformers/handleMetaRedirects.test.ts @@ -16,6 +16,7 @@ import { handleMetaRedirects } from './handleMetaRedirects'; import { createTestShadowDom } from '../../test-utils'; +import { screen } from '@testing-library/react'; describe('handleMetaRedirects', () => { const navigate = jest.fn(); @@ -35,15 +36,19 @@ describe('handleMetaRedirects', () => { }, writable: true, }); - return await createTestShadowDom(html, { preTransformers: [], postTransformers: [handleMetaRedirects(navigate, entityName)], }); }; + beforeEach(() => { + jest.useFakeTimers(); + }); afterEach(() => { jest.clearAllMocks(); + jest.useRealTimers(); + document.body.innerHTML = ''; }); it('should navigate to relative URL if meta redirect tag is present', async () => { @@ -52,6 +57,13 @@ describe('handleMetaRedirects', () => { 'http://localhost/docs/default/component/testEntity/subpath', '/docs/default/component/testEntity/subpath', ); + + expect( + await screen.findByText( + 'This TechDocs page is no longer maintained. Will automatically redirect to the designated replacement.', + ), + ).toBeInTheDocument(); + jest.runAllTimers(); expect(navigate).toHaveBeenCalledWith( 'http://localhost/docs/default/component/testEntity/anotherPage', ); @@ -63,6 +75,13 @@ describe('handleMetaRedirects', () => { 'http://localhost/docs/default/component/testEntity/subpath', '/docs/default/component/testEntity/subpath', ); + + expect( + await screen.findByText( + 'This TechDocs page is no longer maintained. Will automatically redirect to the designated replacement.', + ), + ).toBeInTheDocument(); + jest.runAllTimers(); expect(navigate).toHaveBeenCalledWith('/docs/default/component/testEntity'); }); @@ -72,6 +91,13 @@ describe('handleMetaRedirects', () => { 'http://localhost/docs/default/component/testEntity/subpath', '/docs/default/component/testEntity/subpath', ); + + expect( + await screen.findByText( + 'This TechDocs page is no longer maintained. Will automatically redirect to the designated replacement.', + ), + ).toBeInTheDocument(); + jest.runAllTimers(); expect(navigate).toHaveBeenCalledWith('http://localhost/test'); }); @@ -81,6 +107,8 @@ describe('handleMetaRedirects', () => { 'http://localhost/docs/default/component/testEntity/subpath', '/docs/default/component/testEntity/subpath', ); + + jest.runAllTimers(); expect(navigate).not.toHaveBeenCalled(); }); }); diff --git a/plugins/techdocs/src/reader/transformers/handleMetaRedirects.ts b/plugins/techdocs/src/reader/transformers/handleMetaRedirects.ts deleted file mode 100644 index 4c56d4d363..0000000000 --- a/plugins/techdocs/src/reader/transformers/handleMetaRedirects.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2024 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 { Transformer } from './transformer'; -import { normalizeUrl } from './rewriteDocLinks'; - -export const handleMetaRedirects = ( - navigate: (to: string) => void, - entityName: string, -): Transformer => { - return dom => { - for (const elem of Array.from(dom.querySelectorAll('meta'))) { - if (elem.getAttribute('http-equiv') === 'refresh') { - const metaContentParameters = elem - .getAttribute('content') - ?.split('url='); - if (!metaContentParameters || metaContentParameters.length < 2) { - continue; - } - - const metaUrl = metaContentParameters[1]; - const normalizedCurrentUrl = normalizeUrl(window.location.href); - // If metaUrl is relative, it will be resolved with base href. If it is absolute, it will replace the base href when creating URL object. - const absoluteRedirectObj = new URL(metaUrl, normalizedCurrentUrl); - const isExternalRedirect = - absoluteRedirectObj.hostname !== window.location.hostname; - - if (isExternalRedirect) { - // If the redirect is external, navigate to the documentation site home instead of the external url. - const currentTechDocPath = window.location.pathname; - const indexOfSiteHome = currentTechDocPath.indexOf(entityName); - const siteHomePath = currentTechDocPath.slice( - 0, - indexOfSiteHome + entityName.length, - ); - navigate(siteHomePath); - } else { - // The navigate function from dom.tsx is a wrapper around react-router navigate function that helps absolute url redirects. - navigate(absoluteRedirectObj.href); - } - return dom; - } - } - return dom; - }; -}; diff --git a/plugins/techdocs/src/reader/transformers/handleMetaRedirects.tsx b/plugins/techdocs/src/reader/transformers/handleMetaRedirects.tsx new file mode 100644 index 0000000000..2d74f4cbf5 --- /dev/null +++ b/plugins/techdocs/src/reader/transformers/handleMetaRedirects.tsx @@ -0,0 +1,126 @@ +/* + * Copyright 2024 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 { Transformer } from './transformer'; +import { normalizeUrl } from './rewriteDocLinks'; +import Snackbar from '@material-ui/core/Snackbar'; +import React, { useState } from 'react'; +import { renderReactElement } from './renderReactElement'; +import Button from '@material-ui/core/Button'; +import { makeStyles } from '@material-ui/core/styles'; + +type RedirectNotificationProps = { + handleButtonClick: () => void; + message: string; + autoHideDuration: number; +}; + +const useStyles = makeStyles(theme => ({ + button: { + color: theme.palette.primary.light, + textDecoration: 'underline', + }, +})); +const RedirectNotification = ({ + message, + handleButtonClick, + autoHideDuration, +}: RedirectNotificationProps) => { + const classes = useStyles(); + const [open, setOpen] = useState(true); + const handleClose = () => { + setOpen(prev => !prev); + }; + + return ( + + Redirect now + + } + /> + ); +}; + +export const handleMetaRedirects = ( + navigate: (to: string) => void, + entityName: string, +): Transformer => { + const redirectAfterMs = 4000; + const determineRedirectURL = (metaUrl: string) => { + const normalizedCurrentUrl = normalizeUrl(window.location.href); + // If metaUrl is relative, it will be resolved with base href. If it is absolute, it will replace the base href when creating URL object. + const absoluteRedirectObj = new URL(metaUrl, normalizedCurrentUrl); + const isExternalRedirect = + absoluteRedirectObj.hostname !== window.location.hostname; + + if (isExternalRedirect) { + const currentTechDocPath = window.location.pathname; + const indexOfSiteHome = currentTechDocPath.indexOf(entityName); + const siteHomePath = currentTechDocPath.slice( + 0, + indexOfSiteHome + entityName.length, + ); + return siteHomePath; + } + // The navigate function from dom.tsx is a wrapper around react-router navigate function that helps absolute url redirects. + return absoluteRedirectObj.href; + }; + + return dom => { + for (const elem of Array.from(dom.querySelectorAll('meta'))) { + if (elem.getAttribute('http-equiv') === 'refresh') { + const metaContentParameters = elem + .getAttribute('content') + ?.split('url='); + if (!metaContentParameters || metaContentParameters.length < 2) { + continue; + } + const metaUrl = metaContentParameters[1]; + const redirectURL = determineRedirectURL(metaUrl); + const container = document.createElement('div'); + + renderReactElement( + navigate(redirectURL)} + autoHideDuration={redirectAfterMs} + />, + container, + ); + document.body.appendChild(container); + + setTimeout(() => { + navigate(redirectURL); + }, redirectAfterMs); + + return dom; + } + } + return dom; + }; +}; From d18f4eba43f6fe589c09b62b47a3bb9fe099be23 Mon Sep 17 00:00:00 2001 From: Himanshu Mishra Date: Wed, 7 Aug 2024 11:24:46 +0530 Subject: [PATCH 149/372] scaffolder: remove undefined from the title of Scaffolder Run page Signed-off-by: Himanshu Mishra --- .changeset/real-lizards-sit.md | 5 +++++ .../scaffolder/src/components/OngoingTask/OngoingTask.tsx | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/real-lizards-sit.md diff --git a/.changeset/real-lizards-sit.md b/.changeset/real-lizards-sit.md new file mode 100644 index 0000000000..747f041508 --- /dev/null +++ b/.changeset/real-lizards-sit.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder': patch +--- + +Fix undefined in the title of Scaffolder Runs on the page load diff --git a/plugins/scaffolder/src/components/OngoingTask/OngoingTask.tsx b/plugins/scaffolder/src/components/OngoingTask/OngoingTask.tsx index 31c2870352..459ba682d2 100644 --- a/plugins/scaffolder/src/components/OngoingTask/OngoingTask.tsx +++ b/plugins/scaffolder/src/components/OngoingTask/OngoingTask.tsx @@ -173,7 +173,9 @@ export const OngoingTask = (props: { return (
    Run of {templateName} From b9cd50536fa43f1c9c8ac62a819c2db826f526a7 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 7 Aug 2024 11:21:31 +0200 Subject: [PATCH 150/372] chore: fix Signed-off-by: blam Signed-off-by: blam --- .../src/wiring/createExtensionBlueprint.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts index 2b80dac81e..88b2523111 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts @@ -420,7 +420,7 @@ export function createExtensionBlueprint< ): ExtensionBlueprint< TParams, UOutput, - TInputs, + string extends keyof TInputs ? {} : TInputs, string extends keyof TConfigSchema ? {} : { [key in keyof TConfigSchema]: z.infer> }, @@ -436,7 +436,7 @@ export function createExtensionBlueprint< return new ExtensionBlueprintImpl(options) as ExtensionBlueprint< TParams, UOutput, - TInputs, + string extends keyof TInputs ? {} : TInputs, string extends keyof TConfigSchema ? {} : { From 6f72c2b9905c86fc7cf4d30ced9887facf017e58 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 7 Aug 2024 11:22:37 +0200 Subject: [PATCH 151/372] chore: updating changeset Signed-off-by: blam --- .changeset/breezy-cats-kiss.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/breezy-cats-kiss.md diff --git a/.changeset/breezy-cats-kiss.md b/.changeset/breezy-cats-kiss.md new file mode 100644 index 0000000000..3bcbfaf00a --- /dev/null +++ b/.changeset/breezy-cats-kiss.md @@ -0,0 +1,5 @@ +--- +'@backstage/frontend-plugin-api': patch +--- + +Fixing issue with `Blueprints` `inputs` merging From 9a0147e6daa458ecd1add64d1a20ed3c48781b24 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 7 Aug 2024 11:39:13 +0200 Subject: [PATCH 152/372] chore: fixing api reports Signed-off-by: blam --- packages/frontend-plugin-api/api-report.md | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/packages/frontend-plugin-api/api-report.md b/packages/frontend-plugin-api/api-report.md index 38b980fcbf..4dc9c99c78 100644 --- a/packages/frontend-plugin-api/api-report.md +++ b/packages/frontend-plugin-api/api-report.md @@ -622,7 +622,7 @@ export function createExtensionBlueprint< ): ExtensionBlueprint< TParams, UOutput, - TInputs, + string extends keyof TInputs ? {} : TInputs, string extends keyof TConfigSchema ? {} : { @@ -1367,15 +1367,7 @@ export const IconBundleBlueprint: ExtensionBlueprint< 'core.icons', {} >, - { - [x: string]: ExtensionInput< - AnyExtensionDataRef, - { - optional: boolean; - singleton: boolean; - } - >; - }, + {}, { icons: string; test: string; From f4612847a2090aec61e05798f7a758328c4df3c1 Mon Sep 17 00:00:00 2001 From: Marek Libra Date: Tue, 6 Aug 2024 16:05:57 +0200 Subject: [PATCH 153/372] Add install instructions for older nevironments Signed-off-by: Marek Libra --- docs/notifications/getting-started.md | 104 +++++++++++++++++++++++- plugins/notifications-backend/README.md | 12 +-- plugins/notifications/README.md | 35 +------- plugins/signals-backend/README.md | 39 +-------- plugins/signals/README.md | 18 +--- 5 files changed, 107 insertions(+), 101 deletions(-) diff --git a/docs/notifications/getting-started.md b/docs/notifications/getting-started.md index 583be64cc8..dc006e21b2 100644 --- a/docs/notifications/getting-started.md +++ b/docs/notifications/getting-started.md @@ -6,7 +6,7 @@ description: How to get started with the notifications and signals The Backstage Notifications System provides a way for plugins and external services to send notifications to Backstage users. These notifications are displayed in the dedicated page of the Backstage frontend UI or by frontend plugins per specific scenarios. -Additionally, plugins can implement processors to send notifications through external channels like email, Slack, or MS Teams. +Additionally, notifications can be sent to external channels (like email) via "processors" implemented within plugins. Notifications can be optionally integrated with the signals (a push mechanism) to ensure users receive them immediately. @@ -31,6 +31,104 @@ Example of use-cases: - Notifications for individuals: e.g., updates you have subscribed to, new required training courses - Notifications pertaining to a particular entity in the catalog: A notification might apply to an entity and the owning team. +## Installation in Older Environments + +Newer versions of instances created by the create-app have both the notifications and signals plugins included by default, this section can be skipped right to the Configuration. + +Following installation instructions are valid for enabling the plugins in older environments. + +### Add Notifications Backend + +```bash +yarn workspace backend add @backstage/plugin-notifications-backend +``` + +Add the notifications to your `backend/src/index.ts`: + +```ts +const backend = createBackend(); +// ... +backend.add(import('@backstage/plugin-notifications-backend')); +``` + +### Add Notifications Frontend + +```bash +yarn workspace app add @backstage/notifications +``` + +To add the notifications main menu, add following to your `packages/app/src/components/Root/Root.tsx`: + +```tsx +import { NotificationsSidebarItem } from '@backstage/plugin-notifications'; + + + + + // ... + + + +; +``` + +Also add the route to notifications to `packages/app/src/App.tsx`: + +```tsx +import { NotificationsPage } from '@backstage/plugin-notifications'; + + + // ... + } /> +; +``` + +### Optional: Add Signals Backend + +Optionally add Signals to your backend by + +```bash +yarn workspace backend add @backstage/plugin-signals-backend +``` + +Add the signals to your `backend/src/index.ts`: + +```ts +const backend = createBackend(); +// ... +backend.add(import('@backstage/plugin-signals-backend')); +``` + +### Optional: Signals Frontend + +The use of signals is optional but improves user experience. + +Start with: + +```bash +yarn workspace app add @backstage/plugin-signals +``` + +To install the plugin, you have to add the following to your `packages/app/src/plugins.ts`: + +```ts +export { signalsPlugin } from '@backstage/plugin-signals'; +``` + +And make sure that your `packages/app/src/App.tsx` contains: + +```ts +import * as plugins from './plugins'; + +const app = createApp({ + // ... + plugins: Object.values(plugins), + // ... +}); +``` + +If the signals plugin is properly configured, it will be automatically discovered by the notifications plugin and used. + ## Configuration ### Notifications Backend @@ -209,7 +307,9 @@ curl -X POST https://[BACKSTAGE_BACKEND]/api/notifications -H "Content-Type: app ## Additional info -Additional details can be found in the plugins' implementation: +An example of a backend plugin sending notifications can be found in https://github.com/backstage/backstage/tree/master/plugins/scaffolder-backend-module-notifications. + +Sources of the notifications and signal plugins: - https://github.com/backstage/backstage/blob/master/plugins/notifications diff --git a/plugins/notifications-backend/README.md b/plugins/notifications-backend/README.md index ebd129f572..a6b6615d9f 100644 --- a/plugins/notifications-backend/README.md +++ b/plugins/notifications-backend/README.md @@ -4,17 +4,7 @@ Welcome to the notifications backend plugin! ## Getting started -```bash -yarn workspace backend add @backstage/notifications-backend -``` - -Add the notifications to your backend: - -```ts -const backend = createBackend(); -// ... -backend.add(import('@backstage/plugin-notifications-backend')); -``` +To install, please refer the [Getting Started](https://backstage.io/docs/notifications) Backstage Notifications and Signals documentation section. For users to be able to see notifications in real-time, you have to install also the signals plugin (`@backstage/plugin-signals-node`, `@backstage/plugin-signals-backend`, and diff --git a/plugins/notifications/README.md b/plugins/notifications/README.md index 32fbb8c701..78bcf4e753 100644 --- a/plugins/notifications/README.md +++ b/plugins/notifications/README.md @@ -4,40 +4,9 @@ Welcome to the notifications plugin! ## Getting started -First, install the `@backstage/plugin-notifications-backend` and `@backstage/plugin-notifications-node` packages. -See the documentation for installation instructions. +To install, please refer the [Getting Started](https://backstage.io/docs/notifications) Backstage Notifications and Signals documentation section. -Then add this frontend package: - -```bash -yarn workspace app add @backstage/notifications -``` - -To add the notifications main menu, add the following to your `packages/app/src/components/Root/Root.tsx`: - -```tsx -import { NotificationsSidebarItem } from '@backstage/plugin-notifications'; - - - - - // ... - - - -; -``` - -Also add the route to notifications to `packages/app/src/App.tsx`: - -```tsx -import { NotificationsPage } from '@backstage/plugin-notifications'; - - - // ... - } /> -; -``` +Please mind installing the `@backstage/plugin-notifications-backend` and `@backstage/plugin-notifications-node` packages before this frontend plugin. ## Real-time notifications diff --git a/plugins/signals-backend/README.md b/plugins/signals-backend/README.md index d76038a38e..24d8832d26 100644 --- a/plugins/signals-backend/README.md +++ b/plugins/signals-backend/README.md @@ -6,41 +6,4 @@ Signals plugin allows backend plugins to publish messages to frontend plugins. ## Getting started -First install the `@backstage/plugin-signals-node` plugin to get the `SignalsService` set up. - -Next, add Signals router to your backend in `packages/backend/src/plugins/signals.ts`: - -```ts -import { Router } from 'express'; -import { createRouter } from '@backstage/plugin-signals-backend'; -import { PluginEnvironment } from '../types'; - -export default async function createPlugin( - env: PluginEnvironment, -): Promise { - return await createRouter({ - logger: env.logger, - eventBroker: env.eventBroker, - identity: env.identity, - discovery: env.discovery, - }); -} -``` - -Now add the signals to `packages/backend/src/index.ts`: - -```ts -// ... -import signals from './plugins/signals'; - -async function main() { - // ... - const signalsEnv = useHotMemoize(module, () => createEnv('signals')); - - const apiRouter = Router(); - // ... - apiRouter.use('/signals', await signals(signalsEnv)); - apiRouter.use(notFoundHandler()); - // ... -} -``` +To install this signals backend plugin, please refer the [Getting Started](https://backstage.io/docs/notifications) Backstage Notifications and Signals documentation section. diff --git a/plugins/signals/README.md b/plugins/signals/README.md index 38dc18808b..5b08983621 100644 --- a/plugins/signals/README.md +++ b/plugins/signals/README.md @@ -9,23 +9,7 @@ Signals plugin allows backend plugins to publish messages to frontend plugins. This plugin contains client that can receive messages from the backend. To get started, see installation instructions from `@backstage/plugin-signals-node`, `@backstage/plugin-signals-backend`. -To install the plugin, you have to add the following to your `packages/app/src/plugins.ts`: - -```ts -export { signalsPlugin } from '@backstage/plugin-signals'; -``` - -And make sure that your `packages/app/src/App.tsx` contains: - -```ts -import * as plugins from './plugins'; - -const app = createApp({ - // ... - plugins: Object.values(plugins), - // ... -}); -``` +To install this signals frontend plugin, please refer the [Getting Started](https://backstage.io/docs/notifications) Backstage Notifications and Signals documentation section. Now you can utilize the API from other plugins using the `@backstage/plugin-signals-react` package or simply by: From 3a8e23d8ff1b03bc1caaae1441b7fb828f67e5b1 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 7 Aug 2024 11:47:47 +0200 Subject: [PATCH 154/372] chore: updating changeset wording Signed-off-by: blam --- .changeset/breezy-cats-kiss.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/breezy-cats-kiss.md b/.changeset/breezy-cats-kiss.md index 3bcbfaf00a..900016c1e8 100644 --- a/.changeset/breezy-cats-kiss.md +++ b/.changeset/breezy-cats-kiss.md @@ -2,4 +2,4 @@ '@backstage/frontend-plugin-api': patch --- -Fixing issue with `Blueprints` `inputs` merging +Fixing issue with extension blueprints `inputs` merging. From 3fbf4a8719270ed227f8496ec0edeebca7abd271 Mon Sep 17 00:00:00 2001 From: Evan Kelly <47178446+EvanGKelly@users.noreply.github.com> Date: Wed, 7 Aug 2024 11:13:29 +0100 Subject: [PATCH 155/372] Update docs/integrations/datadog-rum/installation.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fredrik Adelöw Signed-off-by: Evan Kelly <47178446+EvanGKelly@users.noreply.github.com> --- docs/integrations/datadog-rum/installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/integrations/datadog-rum/installation.md b/docs/integrations/datadog-rum/installation.md index 414317d593..8213b8296f 100644 --- a/docs/integrations/datadog-rum/installation.md +++ b/docs/integrations/datadog-rum/installation.md @@ -28,7 +28,7 @@ app: If your [`app-config.yaml`](https://github.com/backstage/backstage/blob/e0506af8fc54074a160fb91c83d6cae8172d3bb3/app-config.yaml#L5) file does not have this configuration, you may have to adjust your [`packages/app/public/index.html`](https://github.com/backstage/backstage/blob/e0506af8fc54074a160fb91c83d6cae8172d3bb3/packages/app/public/index.html#L69) to include the Datadog RUM `init()` section manually. -Please note, there's a bug where env value MUST be specified at build time +Please note that the env value MUST be specified at build time :::note In case after a proper configuration, the events still arent being capture copy and paste this section in to your `packages/app/public/index.html` under the `` tag. From 807bd071759be7e431d09c300839177498850bc9 Mon Sep 17 00:00:00 2001 From: Evan Kelly <47178446+EvanGKelly@users.noreply.github.com> Date: Wed, 7 Aug 2024 11:13:39 +0100 Subject: [PATCH 156/372] Update docs/integrations/datadog-rum/installation.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fredrik Adelöw Signed-off-by: Evan Kelly <47178446+EvanGKelly@users.noreply.github.com> --- docs/integrations/datadog-rum/installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/integrations/datadog-rum/installation.md b/docs/integrations/datadog-rum/installation.md index 8213b8296f..6659bec182 100644 --- a/docs/integrations/datadog-rum/installation.md +++ b/docs/integrations/datadog-rum/installation.md @@ -31,7 +31,7 @@ If your [`app-config.yaml`](https://github.com/backstage/backstage/blob/e0506af8 Please note that the env value MUST be specified at build time :::note -In case after a proper configuration, the events still arent being capture copy and paste this section in to your `packages/app/public/index.html` under the `` tag. +In case after a proper configuration, the events still are not being captured: Copy and paste this section in to your `packages/app/public/index.html` under the `` tag. ```html <% if (config.has('app.datadogRum')) { %> From ddde5fe772b3cb910fa8397db67b8fe98472e135 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 7 Aug 2024 12:48:09 +0200 Subject: [PATCH 157/372] backend-plugin-api: fix for plugins and modules depending on multion services Signed-off-by: Patrik Oldsberg --- .changeset/seven-days-film.md | 5 ++ .changeset/silver-pillows-begin.md | 5 ++ .../config/vocabularies/Backstage/accept.txt | 1 + .../src/wiring/BackendInitializer.test.ts | 56 +++++++++++++++++++ .../src/compat/legacy/legacy.ts | 8 ++- packages/backend-plugin-api/api-report.md | 20 +++---- .../src/wiring/createBackendModule.test.ts | 33 +++++++++++ .../src/wiring/createBackendPlugin.test.ts | 48 ++++++++++++++++ .../backend-plugin-api/src/wiring/types.ts | 35 ++++++++---- 9 files changed, 187 insertions(+), 24 deletions(-) create mode 100644 .changeset/seven-days-film.md create mode 100644 .changeset/silver-pillows-begin.md diff --git a/.changeset/seven-days-film.md b/.changeset/seven-days-film.md new file mode 100644 index 0000000000..9d757b0611 --- /dev/null +++ b/.changeset/seven-days-film.md @@ -0,0 +1,5 @@ +--- +'@backstage/backend-plugin-api': patch +--- + +Fixed a type issue where plugin and modules depending on multiton services would not receive the correct type. diff --git a/.changeset/silver-pillows-begin.md b/.changeset/silver-pillows-begin.md new file mode 100644 index 0000000000..8fe1ccc230 --- /dev/null +++ b/.changeset/silver-pillows-begin.md @@ -0,0 +1,5 @@ +--- +'@backstage/backend-common': patch +--- + +Internal type refactor. diff --git a/.github/vale/config/vocabularies/Backstage/accept.txt b/.github/vale/config/vocabularies/Backstage/accept.txt index 42b0e4895c..bad61de7ff 100644 --- a/.github/vale/config/vocabularies/Backstage/accept.txt +++ b/.github/vale/config/vocabularies/Backstage/accept.txt @@ -245,6 +245,7 @@ Monorepo monorepos msgraph msw +multiton mutex mutexes mysql diff --git a/packages/backend-app-api/src/wiring/BackendInitializer.test.ts b/packages/backend-app-api/src/wiring/BackendInitializer.test.ts index 6f60d65861..cf8845fcec 100644 --- a/packages/backend-app-api/src/wiring/BackendInitializer.test.ts +++ b/packages/backend-app-api/src/wiring/BackendInitializer.test.ts @@ -342,6 +342,62 @@ describe('BackendInitializer', () => { await init.start(); }); + it('should allow plugins and modules depend on multiton services', async () => { + expect.assertions(2); + + const multiServiceRef = createServiceRef({ + id: 'a', + multiton: true, + }); + const init = new BackendInitializer(baseFactories); + + init.add( + createServiceFactory({ + service: multiServiceRef, + deps: {}, + factory: () => 'x', + }), + ); + init.add( + createServiceFactory({ + service: multiServiceRef, + deps: {}, + factory: () => 'y', + }), + ); + + init.add( + createBackendPlugin({ + pluginId: 'test', + register(reg) { + reg.registerInit({ + deps: { multi: multiServiceRef }, + async init({ multi }) { + expect(multi).toEqual(['x', 'y']); + }, + }); + }, + }), + ); + + init.add( + createBackendModule({ + pluginId: 'test', + moduleId: 'test', + register(reg) { + reg.registerInit({ + deps: { multi: multiServiceRef }, + async init({ multi }) { + expect(multi).toEqual(['x', 'y']); + }, + }); + }, + }), + ); + + await init.start(); + }); + it('should forward errors when plugins fail to start', async () => { const init = new BackendInitializer([]); init.add( diff --git a/packages/backend-common/src/compat/legacy/legacy.ts b/packages/backend-common/src/compat/legacy/legacy.ts index c779daacd2..4dc7d1a09a 100644 --- a/packages/backend-common/src/compat/legacy/legacy.ts +++ b/packages/backend-common/src/compat/legacy/legacy.ts @@ -18,6 +18,7 @@ import { AuthService, coreServices, createBackendPlugin, + HttpRouterService, ServiceRef, } from '@backstage/backend-plugin-api'; import { RequestHandler } from 'express'; @@ -107,7 +108,10 @@ export function makeLegacyPlugin< return [key, transform(dep)]; } if (key === 'tokenManager') { - return [key, wrapTokenManager(dep as TokenManager, _auth)]; + return [ + key, + wrapTokenManager(dep as TokenManager, _auth as AuthService), + ]; } return [key, dep]; }), @@ -115,7 +119,7 @@ export function makeLegacyPlugin< const router = await createRouter( pluginEnv as TransformedEnv, ); - _router.use(router); + (_router as HttpRouterService).use(router); }, }); }, diff --git a/packages/backend-plugin-api/api-report.md b/packages/backend-plugin-api/api-report.md index e5189dce4d..319ddf0bc6 100644 --- a/packages/backend-plugin-api/api-report.md +++ b/packages/backend-plugin-api/api-report.md @@ -82,14 +82,12 @@ export interface BackendModuleRegistrationPoints { ): void; // (undocumented) registerInit< - Deps extends { - [name in string]: unknown; + TDeps extends { + [name in string]: ServiceRef | ExtensionPoint; }, >(options: { - deps: { - [name in keyof Deps]: ServiceRef | ExtensionPoint; - }; - init(deps: Deps): Promise; + deps: TDeps; + init(deps: DepsToInstances): Promise; }): void; } @@ -105,14 +103,12 @@ export interface BackendPluginRegistrationPoints { ): void; // (undocumented) registerInit< - Deps extends { - [name in string]: unknown; + TDeps extends { + [name in string]: ServiceRef; }, >(options: { - deps: { - [name in keyof Deps]: ServiceRef; - }; - init(deps: Deps): Promise; + deps: TDeps; + init(deps: DepsToInstances): Promise; }): void; } diff --git a/packages/backend-plugin-api/src/wiring/createBackendModule.test.ts b/packages/backend-plugin-api/src/wiring/createBackendModule.test.ts index e3c9f9007a..3426d5a90c 100644 --- a/packages/backend-plugin-api/src/wiring/createBackendModule.test.ts +++ b/packages/backend-plugin-api/src/wiring/createBackendModule.test.ts @@ -14,7 +14,9 @@ * limitations under the License. */ +import { createServiceRef } from '../services'; import { createBackendModule } from './createBackendModule'; +import { createExtensionPoint } from './createExtensionPoint'; import { InternalBackendRegistrations } from './types'; describe('createBackendModule', () => { @@ -54,4 +56,35 @@ describe('createBackendModule', () => { // @ts-expect-error expect(module({ a: 'a' })).toBeDefined(); }); + + it('should be able to depend on all types of dependencies', () => { + const extensionPoint = createExtensionPoint({ id: 'point' }); + const singleServiceRef = createServiceRef({ id: 'single' }); + const multiServiceRef = createServiceRef({ + id: 'multi', + multiton: true, + }); + + const plugin = createBackendModule({ + pluginId: 'x', + moduleId: 'y', + register(r) { + r.registerInit({ + deps: { + point: extensionPoint, + single: singleServiceRef, + multi: multiServiceRef, + }, + async init({ point, single, multi }) { + const a: string = point; + const b: string = single; + const c: string[] = multi; + expect([a, b, c]).toBe('unused'); + }, + }); + }, + }); + + expect(plugin.$$type).toEqual('@backstage/BackendFeature'); + }); }); diff --git a/packages/backend-plugin-api/src/wiring/createBackendPlugin.test.ts b/packages/backend-plugin-api/src/wiring/createBackendPlugin.test.ts index db4d60ee19..f4a0877b85 100644 --- a/packages/backend-plugin-api/src/wiring/createBackendPlugin.test.ts +++ b/packages/backend-plugin-api/src/wiring/createBackendPlugin.test.ts @@ -14,7 +14,9 @@ * limitations under the License. */ +import { createServiceRef } from '../services'; import { createBackendPlugin } from './createBackendPlugin'; +import { createExtensionPoint } from './createExtensionPoint'; import { InternalBackendRegistrations } from './types'; describe('createBackendPlugin', () => { @@ -52,4 +54,50 @@ describe('createBackendPlugin', () => { // @ts-expect-error expect(plugin({ a: 'a' })).toBeDefined(); }); + + it('should be able to depend on all compatible dependencies', () => { + const singleServiceRef = createServiceRef({ id: 'single' }); + const multiServiceRef = createServiceRef({ + id: 'multi', + multiton: true, + }); + + const plugin = createBackendPlugin({ + pluginId: 'x', + register(r) { + r.registerInit({ + deps: { + single: singleServiceRef, + multi: multiServiceRef, + }, + async init({ single, multi }) { + const a: string = single; + const b: string[] = multi; + expect([a, b]).toBe('unused'); + }, + }); + }, + }); + + expect(plugin.$$type).toEqual('@backstage/BackendFeature'); + }); + + it('should not be able to depend on extension points', () => { + const extensionPoint = createExtensionPoint({ id: 'point' }); + + const plugin = createBackendPlugin({ + pluginId: 'x', + register(r) { + r.registerInit({ + deps: { + // @ts-expect-error + point: extensionPoint, + }, + async init() {}, + }); + }, + }); + + expect(plugin.$$type).toEqual('@backstage/BackendFeature'); + }); }); diff --git a/packages/backend-plugin-api/src/wiring/types.ts b/packages/backend-plugin-api/src/wiring/types.ts index 01ab8c2e3e..1e8c3910a3 100644 --- a/packages/backend-plugin-api/src/wiring/types.ts +++ b/packages/backend-plugin-api/src/wiring/types.ts @@ -36,6 +36,17 @@ export type ExtensionPoint = { $$type: '@backstage/ExtensionPoint'; }; +/** @ignore */ +type DepsToInstances< + TDeps extends { + [key in string]: ServiceRef | ExtensionPoint; + }, +> = { + [key in keyof TDeps]: TDeps[key] extends ServiceRef + ? Array + : TDeps[key]['T']; +}; + /** * The callbacks passed to the `register` method of a backend plugin. * @@ -46,11 +57,13 @@ export interface BackendPluginRegistrationPoints { ref: ExtensionPoint, impl: TExtensionPoint, ): void; - registerInit(options: { - deps: { - [name in keyof Deps]: ServiceRef; - }; - init(deps: Deps): Promise; + registerInit< + TDeps extends { + [name in string]: ServiceRef; + }, + >(options: { + deps: TDeps; + init(deps: DepsToInstances): Promise; }): void; } @@ -64,11 +77,13 @@ export interface BackendModuleRegistrationPoints { ref: ExtensionPoint, impl: TExtensionPoint, ): void; - registerInit(options: { - deps: { - [name in keyof Deps]: ServiceRef | ExtensionPoint; - }; - init(deps: Deps): Promise; + registerInit< + TDeps extends { + [name in string]: ServiceRef | ExtensionPoint; + }, + >(options: { + deps: TDeps; + init(deps: DepsToInstances): Promise; }): void; } From aa5149806e3583b67f166dd36ba6fa472bcec4ed Mon Sep 17 00:00:00 2001 From: Chris Langhout Date: Wed, 7 Aug 2024 12:29:16 +0200 Subject: [PATCH 158/372] fix: move @types deps to dev-dependencies Signed-off-by: Chris Langhout --- packages/backend-defaults/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend-defaults/package.json b/packages/backend-defaults/package.json index 38d703e2b4..4ac9a759c0 100644 --- a/packages/backend-defaults/package.json +++ b/packages/backend-defaults/package.json @@ -141,7 +141,6 @@ "@opentelemetry/api": "^1.3.0", "@types/cors": "^2.8.6", "@types/express": "^4.17.6", - "@types/pg-format": "^1.0.5", "archiver": "^6.0.0", "base64-stream": "^1.0.0", "better-sqlite3": "^11.0.0", @@ -193,6 +192,7 @@ "@types/http-errors": "^2.0.0", "@types/morgan": "^1.9.0", "@types/node-forge": "^1.3.0", + "@types/pg-format": "^1.0.5", "@types/stoppable": "^1.1.0", "aws-sdk-client-mock": "^4.0.0", "http-errors": "^2.0.0", From 66523e8d01fbb57e35bcfd164c20b11ba7fcae26 Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 30 Jul 2024 15:47:45 +0200 Subject: [PATCH 159/372] chore: wip Signed-off-by: blam --- packages/app-next/src/App.tsx | 48 ++++++- .../src/extensions/createPageExtension.tsx | 131 ++++++++++++++++++ plugins/home/src/alpha.tsx | 58 +++++++- 3 files changed, 223 insertions(+), 14 deletions(-) diff --git a/packages/app-next/src/App.tsx b/packages/app-next/src/App.tsx index b57c680474..25d1aacf8f 100644 --- a/packages/app-next/src/App.tsx +++ b/packages/app-next/src/App.tsx @@ -20,6 +20,7 @@ import { pagesPlugin } from './examples/pagesPlugin'; import notFoundErrorPage from './examples/notFoundErrorPageExtension'; import userSettingsPlugin from '@backstage/plugin-user-settings/alpha'; import homePlugin, { + extensions, titleExtensionDataRef, } from '@backstage/plugin-home/alpha'; @@ -74,13 +75,46 @@ TODO: /* app.tsx */ -const homePageExtension = createExtension({ - name: 'myhomepage', - attachTo: { id: 'page:home', input: 'props' }, - output: { - children: coreExtensionData.reactElement, - title: titleExtensionDataRef, - }, +// const homePageExtension = createExtension({ +// name: 'myhomepage', +// attachTo: { id: 'page:home', input: 'props' }, +// output: { +// children: coreExtensionData.reactElement, +// title: titleExtensionDataRef, +// }, +// factory() { +// return { children: homePage, title: 'just a title' }; +// }, +// }); + +// const homePage = createPageExtension({ +// defaultPath: '/home', +// routeRef: rootRouteRef, +// inputs: { +// props: createExtensionInput( +// { +// children: coreExtensionData.reactElement.optional(), +// title: titleExtensionDataRef.optional(), +// }, + +// { +// singleton: true, +// optional: true, +// }, +// ), +// }, +// loader: ({ inputs }) => +// import('./components/').then(m => +// compatWrapper( +// , +// ), +// ), +// }); + +const homePageExtension = extensions.homePage.override({ factory() { return { children: homePage, title: 'just a title' }; }, diff --git a/packages/frontend-plugin-api/src/extensions/createPageExtension.tsx b/packages/frontend-plugin-api/src/extensions/createPageExtension.tsx index cd434a3ffc..b10901f1bd 100644 --- a/packages/frontend-plugin-api/src/extensions/createPageExtension.tsx +++ b/packages/frontend-plugin-api/src/extensions/createPageExtension.tsx @@ -22,6 +22,9 @@ import { createExtension, ResolvedExtensionInputs, AnyExtensionInputMap, + createExtensionBlueprint, + ExtensionInput, + AnyExtensionDataRef, } from '../wiring'; import { RouteRef } from '../routing'; import { Expand } from '../types'; @@ -95,3 +98,131 @@ export function createPageExtension< }, }); } + +export function createNewPageExtension< + TConfig extends { path: string }, + TInputs extends { + [inputName in string]: ExtensionInput< + AnyExtensionDataRef, + { optional: boolean; singleton: boolean } + >; + }, +>( + options: ( + | { + defaultPath: string; + } + | { + configSchema: PortableSchema; + } + ) & { + namespace?: string; + name?: string; + attachTo?: { id: string; input: string }; + disabled?: boolean; + inputs?: TInputs; + routeRef?: RouteRef; + loader: (options: { + config: TConfig; + inputs: Expand>; + }) => Promise; + }, +): ExtensionDefinition { + const configSchema = + 'configSchema' in options + ? options.configSchema + : (createSchemaFromZod(z => + z.object({ path: z.string().default(options.defaultPath) }), + ) as PortableSchema); + + return createExtension({ + kind: 'page', + namespace: options.namespace, + name: options.name, + attachTo: options.attachTo ?? { id: 'app/routes', input: 'routes' }, + configSchema, + inputs: options.inputs, + disabled: options.disabled, + output: [ + coreExtensionData.routePath, + coreExtensionData.reactElement, + coreExtensionData.routeRef.optional(), + ], + factory({ config, inputs, node }) { + const ExtensionComponent = lazy(() => + options + .loader({ config, inputs }) + .then(element => ({ default: () => element })), + ); + + const outputs = [ + coreExtensionData.routePath(config.path), + coreExtensionData.reactElement( + + + , + ), + ]; + + if (options.routeRef) { + return [...outputs, coreExtensionData.routeRef(options.routeRef)]; + } + + return outputs; + }, + }); +} +/** + * A blueprint for creating extensions for routable React page components. + * @public + */ +export const PageExtensionBlueprint = createExtensionBlueprint({ + kind: 'page', + attachTo: { id: 'app/routes', input: 'routes' }, + output: [ + coreExtensionData.routePath, + coreExtensionData.reactElement, + coreExtensionData.routeRef.optional(), + ], + config: { + schema: { + path: z => z.string().optional(), + }, + }, + factory( + { + defaultPath, + loader, + routeRef, + }: { + defaultPath?: string; + // TODO(blam) This type is impossible to type properly here as we don't have access + // to the input type generic. Maybe not a deal breaker though. + // It means we have to override the factory function in the `.make` method instead. + loader: (opts: unknown) => Promise; + routeRef?: RouteRef; + }, + { config, inputs, node }, + ) { + const ExtensionComponent = lazy(() => + loader({ config, inputs }).then(element => ({ default: () => element })), + ); + + // TODO(blam): this is a little awkward for optional returns. I wonder if we should be using generators or yield instead + // for a better API here. + const outputs = [ + coreExtensionData.routePath(config.path ?? defaultPath!), + coreExtensionData.reactElement( + + + , + ), + ]; + + if (routeRef) { + return [...outputs, coreExtensionData.routeRef(routeRef)]; + } + + return outputs; + }, +}); diff --git a/plugins/home/src/alpha.tsx b/plugins/home/src/alpha.tsx index b13c2a2e0e..109eea333e 100644 --- a/plugins/home/src/alpha.tsx +++ b/plugins/home/src/alpha.tsx @@ -25,6 +25,10 @@ import { createRouteRef, } from '@backstage/frontend-plugin-api'; import { compatWrapper } from '@backstage/core-compat-api'; +import { + PageExtensionBlueprint, + createNewPageExtension, +} from '@backstage/frontend-plugin-api/src/extensions/createPageExtension'; const rootRouteRef = createRouteRef(); @@ -35,15 +39,15 @@ export const titleExtensionDataRef = createExtensionDataRef().with({ id: 'title', }); -const homePage = createPageExtension({ +const homePage = createNewPageExtension({ defaultPath: '/home', routeRef: rootRouteRef, inputs: { props: createExtensionInput( - { - children: coreExtensionData.reactElement.optional(), - title: titleExtensionDataRef.optional(), - }, + [ + coreExtensionData.reactElement.optional(), + titleExtensionDataRef.optional(), + ], { singleton: true, @@ -55,13 +59,53 @@ const homePage = createPageExtension({ import('./components/').then(m => compatWrapper( , ), ), }); +homePage.override({ + factory() {}, +}); + +// const homePage2 = PageExtensionBlueprint.make({ +// inputs: { +// props: createExtensionInput( +// [ +// coreExtensionData.reactElement.optional(), +// titleExtensionDataRef.optional(), +// ], +// { +// singleton: true, +// optional: true, +// }, +// ), +// }, +// factory(origFactory, { config, inputs, node }) { +// return origFactory({ +// defaultPath: '/home', +// routeRef: rootRouteRef, +// loader: () => +// import('./components/').then(m => +// compatWrapper( +// , +// ), +// }, +// }); + +/** + * @alpha + * This will not be the way to export extensions eventually, + * will be something like `homePlugin.extensions.homePage` or `homePlugin.extensions.get('page')` + * Just haven't worked out a nice way to fix the types yet + */ +export const extensions = { homePage }; + /** * @alpha */ From f30705fc23121030aa875f11b2d0bf12c04cf795 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 31 Jul 2024 14:00:06 +0200 Subject: [PATCH 160/372] chore: some more exploration Signed-off-by: blam --- packages/app-next/src/App.tsx | 4 +- .../src/extensions/createPageExtension.tsx | 2 +- .../src/wiring/createExtension.ts | 94 ++++++++++++++++++- plugins/home/src/alpha.tsx | 4 - 4 files changed, 95 insertions(+), 9 deletions(-) diff --git a/packages/app-next/src/App.tsx b/packages/app-next/src/App.tsx index 25d1aacf8f..a33b2de8dc 100644 --- a/packages/app-next/src/App.tsx +++ b/packages/app-next/src/App.tsx @@ -115,8 +115,8 @@ TODO: // }); const homePageExtension = extensions.homePage.override({ - factory() { - return { children: homePage, title: 'just a title' }; + factory(origi) { + return origi(); }, }); diff --git a/packages/frontend-plugin-api/src/extensions/createPageExtension.tsx b/packages/frontend-plugin-api/src/extensions/createPageExtension.tsx index b10901f1bd..efe6ab54d9 100644 --- a/packages/frontend-plugin-api/src/extensions/createPageExtension.tsx +++ b/packages/frontend-plugin-api/src/extensions/createPageExtension.tsx @@ -127,7 +127,7 @@ export function createNewPageExtension< inputs: Expand>; }) => Promise; }, -): ExtensionDefinition { +) { const configSchema = 'configSchema' in options ? options.configSchema diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.ts b/packages/frontend-plugin-api/src/wiring/createExtension.ts index 2a29fe1ab4..6684323b51 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.ts @@ -20,6 +20,7 @@ import { Expand } from '../types'; import { AnyExtensionDataRef, ExtensionDataRef, + ExtensionDataRefToValue, ExtensionDataValue, } from './createExtensionDataRef'; import { ExtensionInput, LegacyExtensionInput } from './createExtensionInput'; @@ -234,6 +235,79 @@ export interface ExtensionDefinition { readonly configSchema?: PortableSchema; } +export type OverrideExtensionOptions< + UOutput extends AnyExtensionDataRef, + TInputs extends { + [inputName in string]: ExtensionInput< + AnyExtensionDataRef, + { optional: boolean; singleton: boolean } + >; + }, + TConfig, + TConfigInput, + TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType }, + UFactoryOutput extends ExtensionDataValue, +> = { + kind?: string; + namespace?: string; + name?: string; + attachTo?: { id: string; input: string }; + disabled?: boolean; + inputs?: TInputs; + output: Array; + /** @deprecated - use `config.schema` instead */ + configSchema?: PortableSchema; + config?: { + schema: TConfigSchema; + }; + factory?( + originalFactory: (context?: { + config?: { + [key in keyof TConfigSchema]: z.infer>; + }; + inputs?: Expand>; + }) => Iterable>, + context: { + node: AppNode; + config: TConfig & + (string extends keyof TConfigSchema + ? {} + : { + [key in keyof TConfigSchema]: z.infer< + ReturnType + >; + }); + inputs: Expand>; + }, + ): Iterable; +} & VerifyExtensionFactoryOutput; + +/** @public */ +export type OverridableExtension< + UOutput extends AnyExtensionDataRef, + TInputs extends { + [inputName in string]: ExtensionInput< + AnyExtensionDataRef, + { optional: boolean; singleton: boolean } + >; + }, + TConfig, + TConfigInput, + TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType }, + UFactoryOutput extends ExtensionDataValue, +> = { + override( + options: OverrideExtensionOptions< + UOutput, + TInputs, + TConfig, + TConfigInput, + TConfigSchema, + UFactoryOutput + >, + ): ExtensionDefinition; +}; + /** @internal */ export type InternalExtensionDefinition = ExtensionDefinition & @@ -329,7 +403,15 @@ export function createExtension< [key in keyof TConfigSchema]: ReturnType; }> >) ->; +> & + OverridableExtension< + UOutput, + TInputs, + TConfig, + TConfigInput, + TConfigSchema, + UFactoryOutput + >; /** * @public * @deprecated - use the array format of `output` instead, see TODO-doc-link @@ -409,7 +491,15 @@ export function createExtension< [key in keyof TConfigSchema]: ReturnType; }> >) -> { +> & + OverridableExtension< + UOutput, + TInputs, + TConfig, + TConfigInput, + TConfigSchema, + UFactoryOutput + > { const newConfigSchema = options.config?.schema; if (newConfigSchema && options.configSchema) { throw new Error(`Cannot provide both configSchema and config.schema`); diff --git a/plugins/home/src/alpha.tsx b/plugins/home/src/alpha.tsx index 109eea333e..31851726e5 100644 --- a/plugins/home/src/alpha.tsx +++ b/plugins/home/src/alpha.tsx @@ -66,10 +66,6 @@ const homePage = createNewPageExtension({ ), }); -homePage.override({ - factory() {}, -}); - // const homePage2 = PageExtensionBlueprint.make({ // inputs: { // props: createExtensionInput( From 665448b21fe97ed448894ddd226b850ad95b6647 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 31 Jul 2024 15:01:22 +0200 Subject: [PATCH 161/372] chore: overriding of config seems to work in typescript Signed-off-by: blam --- .../src/wiring/createExtension.test.ts | 31 +++++++++++++++++++ .../src/wiring/createExtension.ts | 26 +++++++++++++--- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts index ab6a6c19a5..8da3504434 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts @@ -561,4 +561,35 @@ describe('createExtension', () => { }), ).toMatchObject({ version: 'v2' }); }); + + describe('overrides', () => { + it('should allow overriding of the default factory', () => { + const testExtension = createExtension({ + namespace: 'test', + attachTo: { id: 'root', input: 'blob' }, + output: [stringDataRef], + config: { + schema: { + foo: z => z.string().optional(), + }, + }, + factory() { + return [stringDataRef('default')]; + }, + }); + + testExtension.override({ + config: { + schema: { + bar: z => z.string().optional(), + }, + }, + factory(_, { config }) { + return [stringDataRef(config.foo ?? config.bar ?? 'default')]; + }, + }); + + expect(true).toBe(true); + }); + }); }); diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.ts b/packages/frontend-plugin-api/src/wiring/createExtension.ts index 6684323b51..f1db16b4d2 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.ts @@ -247,6 +247,10 @@ export type OverrideExtensionOptions< TConfigInput, TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType }, UFactoryOutput extends ExtensionDataValue, + TConfigSchemaOverrides extends { + [key: string]: (zImpl: typeof z) => z.ZodType; + }, + UOutputOverrides extends AnyExtensionDataRef = UOutput, > = { kind?: string; namespace?: string; @@ -254,11 +258,11 @@ export type OverrideExtensionOptions< attachTo?: { id: string; input: string }; disabled?: boolean; inputs?: TInputs; - output: Array; + output?: Array; /** @deprecated - use `config.schema` instead */ configSchema?: PortableSchema; config?: { - schema: TConfigSchema; + schema: TConfigSchemaOverrides; }; factory?( originalFactory: (context?: { @@ -273,6 +277,10 @@ export type OverrideExtensionOptions< (string extends keyof TConfigSchema ? {} : { + [key in keyof TConfigSchemaOverrides]: z.infer< + ReturnType + >; + } & { [key in keyof TConfigSchema]: z.infer< ReturnType >; @@ -280,7 +288,7 @@ export type OverrideExtensionOptions< inputs: Expand>; }, ): Iterable; -} & VerifyExtensionFactoryOutput; +} & VerifyExtensionFactoryOutput; /** @public */ export type OverridableExtension< @@ -296,14 +304,19 @@ export type OverridableExtension< TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType }, UFactoryOutput extends ExtensionDataValue, > = { - override( + override< + TConfigSchemaOverrides extends { + [key in string]: (zImpl: typeof z) => z.ZodType; + }, + >( options: OverrideExtensionOptions< UOutput, TInputs, TConfig, TConfigInput, TConfigSchema, - UFactoryOutput + UFactoryOutput, + TConfigSchemaOverrides >, ): ExtensionDefinition; }; @@ -540,6 +553,9 @@ export function createExtension< parts.push(`attachTo=${options.attachTo.id}@${options.attachTo.input}`); return `ExtensionDefinition{${parts.join(',')}}`; }, + override() { + // todo(blam): implement. + }, } as InternalExtensionDefinition< TConfig & (string extends keyof TConfigSchema From 40ffc63b7016cdc35d3a2c9d3ecdebf75b152916 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 31 Jul 2024 15:30:33 +0200 Subject: [PATCH 162/372] chore: added some more overrides part Signed-off-by: blam --- .../src/wiring/createExtension.test.ts | 52 ++++++++++++++++++- .../src/wiring/createExtension.ts | 23 +++++--- 2 files changed, 67 insertions(+), 8 deletions(-) diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts index 8da3504434..7f27df4947 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +import { coreExtensionData } from './coreExtensionData'; import { createExtension } from './createExtension'; import { createExtensionDataRef } from './createExtensionDataRef'; import { createExtensionInput } from './createExtensionInput'; @@ -563,7 +564,7 @@ describe('createExtension', () => { }); describe('overrides', () => { - it('should allow overriding of the default factory', () => { + it('should allow overriding of config and merging', () => { const testExtension = createExtension({ namespace: 'test', attachTo: { id: 'root', input: 'blob' }, @@ -591,5 +592,54 @@ describe('createExtension', () => { expect(true).toBe(true); }); + + it('should allow overriding of outputs', () => { + const testExtension = createExtension({ + namespace: 'test', + attachTo: { id: 'root', input: 'blob' }, + output: [stringDataRef], + inputs: { + test: createExtensionInput([stringDataRef], { singleton: true }), + }, + config: { + schema: { + foo: z => z.string().optional(), + }, + }, + factory({ inputs }) { + return [stringDataRef(inputs.test.get(stringDataRef))]; + }, + }); + + const override = testExtension.override({ + output: [numberDataRef], + factory(_, { inputs }) { + return [ + numberDataRef(inputs.test.get(stringDataRef).length), + stringDataRef('default'), + ]; + }, + }); + + // @ts-expect-error - should fail as the string output from previous is not provided + const override2 = testExtension.override({ + output: [numberDataRef], + factory(_, { inputs }) { + return [numberDataRef(inputs.test.get(stringDataRef).length)]; + }, + }); + + // @ts-expect-error - this should fail because string output should be merged? + const override3 = testExtension.override({ + output: [numberDataRef], + factory(_, { inputs }) { + return [stringDataRef(inputs.test.get(stringDataRef))]; + }, + }); + + unused(override, override2, override3); + + expect(true).toBe(true); + }); }); }); diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.ts b/packages/frontend-plugin-api/src/wiring/createExtension.ts index f1db16b4d2..3ec674f75f 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.ts @@ -246,11 +246,12 @@ export type OverrideExtensionOptions< TConfig, TConfigInput, TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType }, - UFactoryOutput extends ExtensionDataValue, + UOriginalFactoryOutput extends ExtensionDataValue, TConfigSchemaOverrides extends { [key: string]: (zImpl: typeof z) => z.ZodType; }, - UOutputOverrides extends AnyExtensionDataRef = UOutput, + UOutputOverrides extends AnyExtensionDataRef, + UFactoryOverrideOutput extends ExtensionDataValue, > = { kind?: string; namespace?: string; @@ -262,7 +263,10 @@ export type OverrideExtensionOptions< /** @deprecated - use `config.schema` instead */ configSchema?: PortableSchema; config?: { - schema: TConfigSchemaOverrides; + schema: TConfigSchemaOverrides & { + [KName in keyof TConfig]?: `Error: Config key '${KName & + string}' is already defined in parent schema`; + }; }; factory?( originalFactory: (context?: { @@ -270,7 +274,7 @@ export type OverrideExtensionOptions< [key in keyof TConfigSchema]: z.infer>; }; inputs?: Expand>; - }) => Iterable>, + }) => Iterable, context: { node: AppNode; config: TConfig & @@ -287,8 +291,9 @@ export type OverrideExtensionOptions< }); inputs: Expand>; }, - ): Iterable; -} & VerifyExtensionFactoryOutput; + ): Iterable; + // todo(blam): need to verify that the outputs are meged properly. +} & VerifyExtensionFactoryOutput; /** @public */ export type OverridableExtension< @@ -308,6 +313,8 @@ export type OverridableExtension< TConfigSchemaOverrides extends { [key in string]: (zImpl: typeof z) => z.ZodType; }, + UOutputOverrides extends AnyExtensionDataRef, + UFactoryOverrideOutput extends ExtensionDataValue, >( options: OverrideExtensionOptions< UOutput, @@ -316,7 +323,9 @@ export type OverridableExtension< TConfigInput, TConfigSchema, UFactoryOutput, - TConfigSchemaOverrides + TConfigSchemaOverrides, + UOutputOverrides, + UFactoryOverrideOutput >, ): ExtensionDefinition; }; From 33786b586e08ef27cea7beb4a1c6062bacc4fb89 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 31 Jul 2024 15:33:44 +0200 Subject: [PATCH 163/372] chore: reset some things Signed-off-by: blam --- packages/app-next/src/App.tsx | 52 +++---------- .../src/extensions/createPageExtension.tsx | 78 +------------------ plugins/home/src/alpha.tsx | 54 ++----------- 3 files changed, 18 insertions(+), 166 deletions(-) diff --git a/packages/app-next/src/App.tsx b/packages/app-next/src/App.tsx index a33b2de8dc..b57c680474 100644 --- a/packages/app-next/src/App.tsx +++ b/packages/app-next/src/App.tsx @@ -20,7 +20,6 @@ import { pagesPlugin } from './examples/pagesPlugin'; import notFoundErrorPage from './examples/notFoundErrorPageExtension'; import userSettingsPlugin from '@backstage/plugin-user-settings/alpha'; import homePlugin, { - extensions, titleExtensionDataRef, } from '@backstage/plugin-home/alpha'; @@ -75,48 +74,15 @@ TODO: /* app.tsx */ -// const homePageExtension = createExtension({ -// name: 'myhomepage', -// attachTo: { id: 'page:home', input: 'props' }, -// output: { -// children: coreExtensionData.reactElement, -// title: titleExtensionDataRef, -// }, -// factory() { -// return { children: homePage, title: 'just a title' }; -// }, -// }); - -// const homePage = createPageExtension({ -// defaultPath: '/home', -// routeRef: rootRouteRef, -// inputs: { -// props: createExtensionInput( -// { -// children: coreExtensionData.reactElement.optional(), -// title: titleExtensionDataRef.optional(), -// }, - -// { -// singleton: true, -// optional: true, -// }, -// ), -// }, -// loader: ({ inputs }) => -// import('./components/').then(m => -// compatWrapper( -// , -// ), -// ), -// }); - -const homePageExtension = extensions.homePage.override({ - factory(origi) { - return origi(); +const homePageExtension = createExtension({ + name: 'myhomepage', + attachTo: { id: 'page:home', input: 'props' }, + output: { + children: coreExtensionData.reactElement, + title: titleExtensionDataRef, + }, + factory() { + return { children: homePage, title: 'just a title' }; }, }); diff --git a/packages/frontend-plugin-api/src/extensions/createPageExtension.tsx b/packages/frontend-plugin-api/src/extensions/createPageExtension.tsx index efe6ab54d9..27b6b53b63 100644 --- a/packages/frontend-plugin-api/src/extensions/createPageExtension.tsx +++ b/packages/frontend-plugin-api/src/extensions/createPageExtension.tsx @@ -23,8 +23,6 @@ import { ResolvedExtensionInputs, AnyExtensionInputMap, createExtensionBlueprint, - ExtensionInput, - AnyExtensionDataRef, } from '../wiring'; import { RouteRef } from '../routing'; import { Expand } from '../types'; @@ -99,79 +97,6 @@ export function createPageExtension< }); } -export function createNewPageExtension< - TConfig extends { path: string }, - TInputs extends { - [inputName in string]: ExtensionInput< - AnyExtensionDataRef, - { optional: boolean; singleton: boolean } - >; - }, ->( - options: ( - | { - defaultPath: string; - } - | { - configSchema: PortableSchema; - } - ) & { - namespace?: string; - name?: string; - attachTo?: { id: string; input: string }; - disabled?: boolean; - inputs?: TInputs; - routeRef?: RouteRef; - loader: (options: { - config: TConfig; - inputs: Expand>; - }) => Promise; - }, -) { - const configSchema = - 'configSchema' in options - ? options.configSchema - : (createSchemaFromZod(z => - z.object({ path: z.string().default(options.defaultPath) }), - ) as PortableSchema); - - return createExtension({ - kind: 'page', - namespace: options.namespace, - name: options.name, - attachTo: options.attachTo ?? { id: 'app/routes', input: 'routes' }, - configSchema, - inputs: options.inputs, - disabled: options.disabled, - output: [ - coreExtensionData.routePath, - coreExtensionData.reactElement, - coreExtensionData.routeRef.optional(), - ], - factory({ config, inputs, node }) { - const ExtensionComponent = lazy(() => - options - .loader({ config, inputs }) - .then(element => ({ default: () => element })), - ); - - const outputs = [ - coreExtensionData.routePath(config.path), - coreExtensionData.reactElement( - - - , - ), - ]; - - if (options.routeRef) { - return [...outputs, coreExtensionData.routeRef(options.routeRef)]; - } - - return outputs; - }, - }); -} /** * A blueprint for creating extensions for routable React page components. * @public @@ -208,7 +133,8 @@ export const PageExtensionBlueprint = createExtensionBlueprint({ loader({ config, inputs }).then(element => ({ default: () => element })), ); - // TODO(blam): this is a little awkward for optional returns. I wonder if we should be using generators or yield instead + // TODO(blam): this is a little awkward for optional returns. + // I wonder if we should be using generators or yield instead // for a better API here. const outputs = [ coreExtensionData.routePath(config.path ?? defaultPath!), diff --git a/plugins/home/src/alpha.tsx b/plugins/home/src/alpha.tsx index 31851726e5..b13c2a2e0e 100644 --- a/plugins/home/src/alpha.tsx +++ b/plugins/home/src/alpha.tsx @@ -25,10 +25,6 @@ import { createRouteRef, } from '@backstage/frontend-plugin-api'; import { compatWrapper } from '@backstage/core-compat-api'; -import { - PageExtensionBlueprint, - createNewPageExtension, -} from '@backstage/frontend-plugin-api/src/extensions/createPageExtension'; const rootRouteRef = createRouteRef(); @@ -39,15 +35,15 @@ export const titleExtensionDataRef = createExtensionDataRef().with({ id: 'title', }); -const homePage = createNewPageExtension({ +const homePage = createPageExtension({ defaultPath: '/home', routeRef: rootRouteRef, inputs: { props: createExtensionInput( - [ - coreExtensionData.reactElement.optional(), - titleExtensionDataRef.optional(), - ], + { + children: coreExtensionData.reactElement.optional(), + title: titleExtensionDataRef.optional(), + }, { singleton: true, @@ -59,49 +55,13 @@ const homePage = createNewPageExtension({ import('./components/').then(m => compatWrapper( , ), ), }); -// const homePage2 = PageExtensionBlueprint.make({ -// inputs: { -// props: createExtensionInput( -// [ -// coreExtensionData.reactElement.optional(), -// titleExtensionDataRef.optional(), -// ], -// { -// singleton: true, -// optional: true, -// }, -// ), -// }, -// factory(origFactory, { config, inputs, node }) { -// return origFactory({ -// defaultPath: '/home', -// routeRef: rootRouteRef, -// loader: () => -// import('./components/').then(m => -// compatWrapper( -// , -// ), -// }, -// }); - -/** - * @alpha - * This will not be the way to export extensions eventually, - * will be something like `homePlugin.extensions.homePage` or `homePlugin.extensions.get('page')` - * Just haven't worked out a nice way to fix the types yet - */ -export const extensions = { homePage }; - /** * @alpha */ From 3ac12d718954a906c1d07f66d7d894cd3978059c Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 31 Jul 2024 17:02:53 +0200 Subject: [PATCH 164/372] chore: some more tests and comments Signed-off-by: blam --- .../src/wiring/createExtension.test.ts | 30 ++++++++++++++++++- .../src/wiring/createExtension.ts | 9 ++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts index 7f27df4947..e38a24cebe 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts @@ -599,7 +599,9 @@ describe('createExtension', () => { attachTo: { id: 'root', input: 'blob' }, output: [stringDataRef], inputs: { - test: createExtensionInput([stringDataRef], { singleton: true }), + test: createExtensionInput([stringDataRef], { + singleton: true, + }), }, config: { schema: { @@ -641,5 +643,31 @@ describe('createExtension', () => { expect(true).toBe(true); }); + + it('should allow overriding the factory function and calling the original factory', () => { + const testExtension = createExtension({ + namespace: 'test', + attachTo: { id: 'root', input: 'blob' }, + output: [stringDataRef], + config: { + schema: { + foo: z => z.string().optional(), + }, + }, + factory() { + return [stringDataRef('default')]; + }, + }); + + testExtension.override({ + factory(originalFactory) { + const response = originalFactory(); + + const foo: string = response.get(stringDataRef); + + return [stringDataRef(`foo-${foo}-override`)]; + }, + }); + }); }); }); diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.ts b/packages/frontend-plugin-api/src/wiring/createExtension.ts index 3ec674f75f..678ce4e042 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.ts @@ -274,6 +274,8 @@ export type OverrideExtensionOptions< [key in keyof TConfigSchema]: z.infer>; }; inputs?: Expand>; + // todo(blam): Think this is better as a DataContainer instead + // should probably update that everywhere. }) => Iterable, context: { node: AppNode; @@ -292,8 +294,11 @@ export type OverrideExtensionOptions< inputs: Expand>; }, ): Iterable; - // todo(blam): need to verify that the outputs are meged properly. -} & VerifyExtensionFactoryOutput; + // todo(blam): need to verify that the outputs are merged and verified properly. +} & VerifyExtensionFactoryOutput< + UOutput & UFactoryOverrideOutput, + UFactoryOverrideOutput +>; /** @public */ export type OverridableExtension< From 45eb5b437a690b6a0d33fea3174d53ed02f88380 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 1 Aug 2024 09:41:40 +0200 Subject: [PATCH 165/372] chore: got the data container working nicely Signed-off-by: blam --- .../src/wiring/createExtension.test.ts | 3 ++ .../src/wiring/createExtension.ts | 28 +++---------------- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts index e38a24cebe..c688f92004 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts @@ -665,6 +665,9 @@ describe('createExtension', () => { const foo: string = response.get(stringDataRef); + // @ts-expect-error - fails because original factory does not return number + const number: boolean = response.get(numberDataRef); + return [stringDataRef(`foo-${foo}-override`)]; }, }); diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.ts b/packages/frontend-plugin-api/src/wiring/createExtension.ts index 678ce4e042..87a4342df7 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.ts @@ -20,7 +20,6 @@ import { Expand } from '../types'; import { AnyExtensionDataRef, ExtensionDataRef, - ExtensionDataRefToValue, ExtensionDataValue, } from './createExtensionDataRef'; import { ExtensionInput, LegacyExtensionInput } from './createExtensionInput'; @@ -246,7 +245,6 @@ export type OverrideExtensionOptions< TConfig, TConfigInput, TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType }, - UOriginalFactoryOutput extends ExtensionDataValue, TConfigSchemaOverrides extends { [key: string]: (zImpl: typeof z) => z.ZodType; }, @@ -274,9 +272,7 @@ export type OverrideExtensionOptions< [key in keyof TConfigSchema]: z.infer>; }; inputs?: Expand>; - // todo(blam): Think this is better as a DataContainer instead - // should probably update that everywhere. - }) => Iterable, + }) => ExtensionDataContainer, context: { node: AppNode; config: TConfig & @@ -296,7 +292,7 @@ export type OverrideExtensionOptions< ): Iterable; // todo(blam): need to verify that the outputs are merged and verified properly. } & VerifyExtensionFactoryOutput< - UOutput & UFactoryOverrideOutput, + UOutput & UOutputOverrides, UFactoryOverrideOutput >; @@ -312,7 +308,6 @@ export type OverridableExtension< TConfig, TConfigInput, TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType }, - UFactoryOutput extends ExtensionDataValue, > = { override< TConfigSchemaOverrides extends { @@ -327,7 +322,6 @@ export type OverridableExtension< TConfig, TConfigInput, TConfigSchema, - UFactoryOutput, TConfigSchemaOverrides, UOutputOverrides, UFactoryOverrideOutput @@ -431,14 +425,7 @@ export function createExtension< }> >) > & - OverridableExtension< - UOutput, - TInputs, - TConfig, - TConfigInput, - TConfigSchema, - UFactoryOutput - >; + OverridableExtension; /** * @public * @deprecated - use the array format of `output` instead, see TODO-doc-link @@ -519,14 +506,7 @@ export function createExtension< }> >) > & - OverridableExtension< - UOutput, - TInputs, - TConfig, - TConfigInput, - TConfigSchema, - UFactoryOutput - > { + OverridableExtension { const newConfigSchema = options.config?.schema; if (newConfigSchema && options.configSchema) { throw new Error(`Cannot provide both configSchema and config.schema`); From 8d631773468d3d852335d918d7f43599be1d2a56 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 1 Aug 2024 11:07:38 +0200 Subject: [PATCH 166/372] chore: added some tests Signed-off-by: blam --- .../src/wiring/createExtension.test.ts | 37 ++++++++ .../src/wiring/createExtension.ts | 86 ++++++++++++++++++- .../wiring/createExtensionOverrides.test.ts | 3 + 3 files changed, 124 insertions(+), 2 deletions(-) diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts index c688f92004..432fb7f89e 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +import { createExtensionTester } from '@backstage/frontend-test-utils'; import { coreExtensionData } from './coreExtensionData'; import { createExtension } from './createExtension'; import { createExtensionDataRef } from './createExtensionDataRef'; @@ -671,6 +672,42 @@ describe('createExtension', () => { return [stringDataRef(`foo-${foo}-override`)]; }, }); + + expect(true).toBe(true); + }); + + it('should work functionally with overrides', () => { + const testExtension = createExtension({ + kind: 'thing', + namespace: 'test', + attachTo: { id: 'root', input: 'default' }, + output: [stringDataRef], + config: { + schema: { + foo: z => z.string().default('boom'), + }, + }, + factory({ config }) { + return [stringDataRef(config.foo)]; + }, + }); + + const overriden = testExtension.override({ + config: { + schema: { + bar: z => z.string().optional(), + }, + }, + factory(originalFactory, { config }) { + const response = originalFactory(); + + const foo: string = response.get(stringDataRef); + + return [stringDataRef(`foo-${foo}-override-${config.bar}`)]; + }, + }); + + const tester = createExtensionTester(overriden).render(); }); }); }); diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.ts b/packages/frontend-plugin-api/src/wiring/createExtension.ts index 87a4342df7..200d3d1133 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +import { over } from 'lodash'; import { AppNode } from '../apis'; import { PortableSchema, createSchemaFromZod } from '../schema'; import { Expand } from '../types'; @@ -547,8 +548,89 @@ export function createExtension< parts.push(`attachTo=${options.attachTo.id}@${options.attachTo.input}`); return `ExtensionDefinition{${parts.join(',')}}`; }, - override() { - // todo(blam): implement. + override< + TConfigSchemaOverrides extends { + [key in string]: (zImpl: typeof z) => z.ZodType; + }, + UOutputOverrides extends AnyExtensionDataRef, + UFactoryOverrideOutput extends ExtensionDataValue, + >( + overrideOptions: OverrideExtensionOptions< + UOutput, + TInputs, + TConfig, + TConfigInput, + TConfigSchema, + TConfigSchemaOverrides, + UOutputOverrides, + UFactoryOverrideOutput + >, + ) { + const overrideNewConfigSchema = overrideOptions.config?.schema; + if (overrideNewConfigSchema && overrideOptions.configSchema) { + throw new Error(`Cannot provide both configSchema and config.schema`); + } + + const mergedConfigSchema = { + ...options.config?.schema, + ...overrideOptions.config?.schema, + }; + + const overrideConfigSchema = mergedConfigSchema + ? createSchemaFromZod(innerZ => + innerZ.object( + Object.fromEntries( + Object.entries(mergedConfigSchema).map(([k, v]) => [ + k, + v(innerZ), + ]), + ), + ), + ) + : overrideOptions.configSchema; + + const buildDataContainer = (outputs): ExtensionDataContainer => { + const dataMap = new Map(); + if (Symbol.iterator in outputs) { + for (const output of outputs) { + dataMap.set(output.id, output.value); + } + } + + return { + get(ref) { + return dataMap.get(ref.id); + }, + } as ExtensionDataContainer; + }; + + return createExtension({ + attachTo: options.attachTo, + output: overrideOptions.output ?? options.output, + configSchema: overrideConfigSchema, + factory: ({ node, config, inputs }) => { + if (overrideOptions.factory) { + return overrideOptions.factory( + innerCtx => { + const originalFactoryResponse = options.factory({ + node, + config: innerCtx?.config ?? config, + inputs: innerCtx?.inputs ?? inputs, + }); + + return buildDataContainer(originalFactoryResponse); + }, + { node, config, inputs }, + ); + } + return options.factory(originalFactory, context); + }, + disabled: overrideOptions.disabled ?? options.disabled, + inputs: overrideOptions.inputs ?? options.inputs, + kind: overrideOptions.kind ?? options.kind, + name: overrideOptions.name ?? options.name, + namespace: overrideOptions.namespace ?? options.namespace, + }); }, } as InternalExtensionDefinition< TConfig & diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionOverrides.test.ts b/packages/frontend-plugin-api/src/wiring/createExtensionOverrides.test.ts index aa00247222..555cd82d4c 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionOverrides.test.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtensionOverrides.test.ts @@ -75,6 +75,7 @@ describe('createExtensionOverrides', () => { "id": "a", "inputs": {}, "output": {}, + "override": [Function], "toString": [Function], "version": "v1", }, @@ -90,6 +91,7 @@ describe('createExtensionOverrides', () => { "id": "b", "inputs": {}, "output": {}, + "override": [Function], "toString": [Function], "version": "v1", }, @@ -105,6 +107,7 @@ describe('createExtensionOverrides', () => { "id": "k:c/n", "inputs": {}, "output": {}, + "override": [Function], "toString": [Function], "version": "v1", }, From 4f446c44f627f2081bd373727a8defef8f2113fa Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 1 Aug 2024 12:06:16 +0200 Subject: [PATCH 167/372] chore: test with the extension tester Signed-off-by: blam --- .../src/wiring/createExtension.test.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts index 432fb7f89e..6aa172cc5a 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts @@ -695,7 +695,7 @@ describe('createExtension', () => { const overriden = testExtension.override({ config: { schema: { - bar: z => z.string().optional(), + bar: z => z.string().default('hello'), }, }, factory(originalFactory, { config }) { @@ -707,7 +707,15 @@ describe('createExtension', () => { }, }); - const tester = createExtensionTester(overriden).render(); + expect(createExtensionTester(overriden).data(stringDataRef)).toBe( + 'foo-boom-override-hello', + ); + + expect( + createExtensionTester(overriden, { + config: { foo: 'hello', bar: 'world' }, + }).data(stringDataRef), + ).toBe('foo-hello-override-world'); }); }); }); From 4a6d9dc85e2042f854d7999e1a08e98ddc43ad53 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 1 Aug 2024 13:46:57 +0200 Subject: [PATCH 168/372] chore: reset page extension Signed-off-by: blam --- .../src/extensions/createPageExtension.tsx | 57 ------------------- 1 file changed, 57 deletions(-) diff --git a/packages/frontend-plugin-api/src/extensions/createPageExtension.tsx b/packages/frontend-plugin-api/src/extensions/createPageExtension.tsx index 27b6b53b63..cd434a3ffc 100644 --- a/packages/frontend-plugin-api/src/extensions/createPageExtension.tsx +++ b/packages/frontend-plugin-api/src/extensions/createPageExtension.tsx @@ -22,7 +22,6 @@ import { createExtension, ResolvedExtensionInputs, AnyExtensionInputMap, - createExtensionBlueprint, } from '../wiring'; import { RouteRef } from '../routing'; import { Expand } from '../types'; @@ -96,59 +95,3 @@ export function createPageExtension< }, }); } - -/** - * A blueprint for creating extensions for routable React page components. - * @public - */ -export const PageExtensionBlueprint = createExtensionBlueprint({ - kind: 'page', - attachTo: { id: 'app/routes', input: 'routes' }, - output: [ - coreExtensionData.routePath, - coreExtensionData.reactElement, - coreExtensionData.routeRef.optional(), - ], - config: { - schema: { - path: z => z.string().optional(), - }, - }, - factory( - { - defaultPath, - loader, - routeRef, - }: { - defaultPath?: string; - // TODO(blam) This type is impossible to type properly here as we don't have access - // to the input type generic. Maybe not a deal breaker though. - // It means we have to override the factory function in the `.make` method instead. - loader: (opts: unknown) => Promise; - routeRef?: RouteRef; - }, - { config, inputs, node }, - ) { - const ExtensionComponent = lazy(() => - loader({ config, inputs }).then(element => ({ default: () => element })), - ); - - // TODO(blam): this is a little awkward for optional returns. - // I wonder if we should be using generators or yield instead - // for a better API here. - const outputs = [ - coreExtensionData.routePath(config.path ?? defaultPath!), - coreExtensionData.reactElement( - - - , - ), - ]; - - if (routeRef) { - return [...outputs, coreExtensionData.routeRef(routeRef)]; - } - - return outputs; - }, -}); From 8e185e43ce5d4d99369d45358393f5d4d2ff1908 Mon Sep 17 00:00:00 2001 From: Marek Libra Date: Wed, 7 Aug 2024 15:04:20 +0200 Subject: [PATCH 169/372] Add Notifications to documentation sidebar Signed-off-by: Marek Libra --- docs/notifications/{getting-started.md => index.md} | 4 ++-- microsite/sidebars.json | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) rename docs/notifications/{getting-started.md => index.md} (98%) diff --git a/docs/notifications/getting-started.md b/docs/notifications/index.md similarity index 98% rename from docs/notifications/getting-started.md rename to docs/notifications/index.md index dc006e21b2..95d77a9b7f 100644 --- a/docs/notifications/getting-started.md +++ b/docs/notifications/index.md @@ -1,5 +1,5 @@ --- -id: getting-started +id: index title: Getting Started description: How to get started with the notifications and signals --- @@ -203,7 +203,7 @@ The use of signals with notifications is optional but generally enhances user ex When a notification is created, a new signal is emitted to a general-purpose message bus to announce it to subscribed listeners. -The frontend maintains a persistent connection (web socket) to receive these announcements from the notifications channel. +The frontend maintains a persistent connection (WebSocket) to receive these announcements from the notifications channel. The specific details of the updated or created notification should be retrieved via a request to the notifications API, except for new notifications, where the payload is included in the signal for performance reasons. In a frontend plugin, to subscribe for notifications' signals: diff --git a/microsite/sidebars.json b/microsite/sidebars.json index 075025afbb..71d0257dc7 100644 --- a/microsite/sidebars.json +++ b/microsite/sidebars.json @@ -295,6 +295,7 @@ "conf/writing", "conf/defining" ], + "Notifications": ["notifications/index"], "Auth and identity": [ "auth/index", { From d0e441e1b88c22b04f92270d9ceb6235ef920085 Mon Sep 17 00:00:00 2001 From: Andre Wanlin Date: Wed, 7 Aug 2024 09:30:12 -0500 Subject: [PATCH 170/372] Added missing `@internal` scope to plugin modules doc Signed-off-by: Andre Wanlin --- docs/backend-system/architecture/06-modules.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/backend-system/architecture/06-modules.md b/docs/backend-system/architecture/06-modules.md index eb00e737e3..010f36109c 100644 --- a/docs/backend-system/architecture/06-modules.md +++ b/docs/backend-system/architecture/06-modules.md @@ -52,7 +52,7 @@ This allows you to install the module in your backend instance by just referenci ```ts backend.add( - import('backstage-plugin-catalog-backend-module-example-processor'), + import('@internal/backstage-plugin-catalog-backend-module-example-processor'), ); ``` From 9fdbbd0889ec6af08e21b4dc7092cedbe7fac3bf Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 7 Aug 2024 17:11:24 +0200 Subject: [PATCH 171/372] chore: more work towards supporting extensions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Patrik Oldsberg Co-authored-by: Fredrik Adelöw Co-authored-by: Camila Belo Signed-off-by: blam --- .../src/extensions/createApiExtension.test.ts | 2 + .../createAppRootElementExtension.test.tsx | 2 + .../createAppRootWrapperExtension.test.tsx | 2 + .../createNavLogoExtension.test.tsx | 1 + .../extensions/createPageExtension.test.tsx | 3 + .../extensions/createRouterExtension.test.tsx | 2 + .../createTranslationExtension.test.ts | 3 + .../src/wiring/createExtension.test.ts | 28 +- .../src/wiring/createExtension.ts | 467 +++++++++--------- .../wiring/createExtensionBlueprint.test.tsx | 3 + .../src/wiring/createExtensionBlueprint.ts | 17 +- 11 files changed, 250 insertions(+), 280 deletions(-) diff --git a/packages/frontend-plugin-api/src/extensions/createApiExtension.test.ts b/packages/frontend-plugin-api/src/extensions/createApiExtension.test.ts index c4d0239094..8f8a0cd9ac 100644 --- a/packages/frontend-plugin-api/src/extensions/createApiExtension.test.ts +++ b/packages/frontend-plugin-api/src/extensions/createApiExtension.test.ts @@ -48,6 +48,7 @@ describe('createApiExtension', () => { }, factory: expect.any(Function), toString: expect.any(Function), + override: expect.any(Function), }); }); @@ -85,6 +86,7 @@ describe('createApiExtension', () => { }, factory: expect.any(Function), toString: expect.any(Function), + override: expect.any(Function), }); }); }); diff --git a/packages/frontend-plugin-api/src/extensions/createAppRootElementExtension.test.tsx b/packages/frontend-plugin-api/src/extensions/createAppRootElementExtension.test.tsx index c8bf6ee355..6e80f6fe13 100644 --- a/packages/frontend-plugin-api/src/extensions/createAppRootElementExtension.test.tsx +++ b/packages/frontend-plugin-api/src/extensions/createAppRootElementExtension.test.tsx @@ -41,6 +41,7 @@ describe('createAppRootElementExtension', () => { }, factory: expect.any(Function), toString: expect.any(Function), + override: expect.any(Function), }); createExtensionTester(extension).render(); @@ -88,6 +89,7 @@ describe('createAppRootElementExtension', () => { }, factory: expect.any(Function), toString: expect.any(Function), + override: expect.any(Function), }); createExtensionTester(extension, { config: { name: 'Robin' } }) diff --git a/packages/frontend-plugin-api/src/extensions/createAppRootWrapperExtension.test.tsx b/packages/frontend-plugin-api/src/extensions/createAppRootWrapperExtension.test.tsx index d21cfa7583..993c4fdee3 100644 --- a/packages/frontend-plugin-api/src/extensions/createAppRootWrapperExtension.test.tsx +++ b/packages/frontend-plugin-api/src/extensions/createAppRootWrapperExtension.test.tsx @@ -42,6 +42,7 @@ describe('createAppRootWrapperExtension', () => { }, factory: expect.any(Function), toString: expect.any(Function), + override: expect.any(Function), }); createExtensionTester( @@ -94,6 +95,7 @@ describe('createAppRootWrapperExtension', () => { component: expect.anything(), }, factory: expect.any(Function), + override: expect.any(Function), toString: expect.any(Function), }); diff --git a/packages/frontend-plugin-api/src/extensions/createNavLogoExtension.test.tsx b/packages/frontend-plugin-api/src/extensions/createNavLogoExtension.test.tsx index 8c54743f1d..17187a339d 100644 --- a/packages/frontend-plugin-api/src/extensions/createNavLogoExtension.test.tsx +++ b/packages/frontend-plugin-api/src/extensions/createNavLogoExtension.test.tsx @@ -41,6 +41,7 @@ describe('createNavLogoExtension', () => { logos: expect.anything(), }, factory: expect.any(Function), + override: expect.any(Function), toString: expect.any(Function), }); }); diff --git a/packages/frontend-plugin-api/src/extensions/createPageExtension.test.tsx b/packages/frontend-plugin-api/src/extensions/createPageExtension.test.tsx index 374400fce8..e5dd4027c0 100644 --- a/packages/frontend-plugin-api/src/extensions/createPageExtension.test.tsx +++ b/packages/frontend-plugin-api/src/extensions/createPageExtension.test.tsx @@ -56,6 +56,7 @@ describe('createPageExtension', () => { }, factory: expect.any(Function), toString: expect.any(Function), + override: expect.any(Function), }); expect( @@ -78,6 +79,7 @@ describe('createPageExtension', () => { kind: 'page', attachTo: { id: 'other', input: 'place' }, configSchema: expect.anything(), + override: expect.any(Function), disabled: true, inputs: { first: createExtensionInput({ @@ -115,6 +117,7 @@ describe('createPageExtension', () => { }, factory: expect.any(Function), toString: expect.any(Function), + override: expect.any(Function), }); }); diff --git a/packages/frontend-plugin-api/src/extensions/createRouterExtension.test.tsx b/packages/frontend-plugin-api/src/extensions/createRouterExtension.test.tsx index 7109e1a8aa..2c16076fcf 100644 --- a/packages/frontend-plugin-api/src/extensions/createRouterExtension.test.tsx +++ b/packages/frontend-plugin-api/src/extensions/createRouterExtension.test.tsx @@ -50,6 +50,7 @@ describe('createRouterExtension', () => { component: expect.anything(), }, factory: expect.any(Function), + override: expect.any(Function), toString: expect.any(Function), }); @@ -119,6 +120,7 @@ describe('createRouterExtension', () => { component: expect.anything(), }, factory: expect.any(Function), + override: expect.any(Function), toString: expect.any(Function), }); diff --git a/packages/frontend-plugin-api/src/extensions/createTranslationExtension.test.ts b/packages/frontend-plugin-api/src/extensions/createTranslationExtension.test.ts index 975901b8e5..019c565cbd 100644 --- a/packages/frontend-plugin-api/src/extensions/createTranslationExtension.test.ts +++ b/packages/frontend-plugin-api/src/extensions/createTranslationExtension.test.ts @@ -46,6 +46,7 @@ describe('createTranslationExtension', () => { namespace: 'test', attachTo: { id: 'app', input: 'translations' }, disabled: false, + override: expect.any(Function), inputs: {}, output: { resource: createTranslationExtension.translationDataRef, @@ -84,6 +85,7 @@ describe('createTranslationExtension', () => { namespace: 'test', attachTo: { id: 'app', input: 'translations' }, disabled: false, + override: expect.any(Function), inputs: {}, output: { resource: createTranslationExtension.translationDataRef, @@ -120,6 +122,7 @@ describe('createTranslationExtension', () => { version: 'v1', kind: 'translation', namespace: 'test', + override: expect.any(Function), name: 'sv', attachTo: { id: 'app', input: 'translations' }, disabled: false, diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts index 6aa172cc5a..30375049bf 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts @@ -15,7 +15,6 @@ */ import { createExtensionTester } from '@backstage/frontend-test-utils'; -import { coreExtensionData } from './coreExtensionData'; import { createExtension } from './createExtension'; import { createExtensionDataRef } from './createExtensionDataRef'; import { createExtensionInput } from './createExtensionInput'; @@ -306,9 +305,7 @@ describe('createExtension', () => { baz: z => z.string().optional(), }, }, - output: { - foo: stringDataRef, - }, + output: [stringDataRef], factory({ config }) { const a1: string = config.foo; const a2: string = config.bar; @@ -322,12 +319,10 @@ describe('createExtension', () => { const c3: number = config.baz; unused(a1, a2, a3, c1, c2, c3); - return { - foo: 'bar', - }; + return [stringDataRef('bar')]; }, }); - expect(extension).toMatchObject({ version: 'v1', namespace: 'test' }); + expect(extension).toMatchObject({ version: 'v2', namespace: 'test' }); expect(String(extension)).toBe( 'ExtensionDefinition{namespace=test,attachTo=root@default}', ); @@ -614,18 +609,7 @@ describe('createExtension', () => { }, }); - const override = testExtension.override({ - output: [numberDataRef], - factory(_, { inputs }) { - return [ - numberDataRef(inputs.test.get(stringDataRef).length), - stringDataRef('default'), - ]; - }, - }); - - // @ts-expect-error - should fail as the string output from previous is not provided - const override2 = testExtension.override({ + const override1 = testExtension.override({ output: [numberDataRef], factory(_, { inputs }) { return [numberDataRef(inputs.test.get(stringDataRef).length)]; @@ -633,14 +617,14 @@ describe('createExtension', () => { }); // @ts-expect-error - this should fail because string output should be merged? - const override3 = testExtension.override({ + const override2 = testExtension.override({ output: [numberDataRef], factory(_, { inputs }) { return [stringDataRef(inputs.test.get(stringDataRef))]; }, }); - unused(override, override2, override3); + unused(override1, override2); expect(true).toBe(true); }); diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.ts b/packages/frontend-plugin-api/src/wiring/createExtension.ts index 200d3d1133..6e75fc76e5 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.ts @@ -14,10 +14,10 @@ * limitations under the License. */ -import { over } from 'lodash'; import { AppNode } from '../apis'; import { PortableSchema, createSchemaFromZod } from '../schema'; import { Expand } from '../types'; +import { createDataContainer } from './createExtensionBlueprint'; import { AnyExtensionDataRef, ExtensionDataRef, @@ -128,7 +128,6 @@ export interface LegacyCreateExtensionOptions< TInputs extends AnyExtensionInputMap, TConfig, TConfigInput, - TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType }, > { kind?: string; namespace?: string; @@ -137,21 +136,10 @@ export interface LegacyCreateExtensionOptions< disabled?: boolean; inputs?: TInputs; output: TOutput; - /** @deprecated - use `config.schema` instead */ configSchema?: PortableSchema; - config?: { - schema: TConfigSchema; - }; factory(context: { node: AppNode; - config: TConfig & - (string extends keyof TConfigSchema - ? {} - : { - [key in keyof TConfigSchema]: z.infer< - ReturnType - >; - }); + config: TConfig; inputs: Expand>; }): Expand>; } @@ -193,8 +181,6 @@ export type CreateExtensionOptions< { optional: boolean; singleton: boolean } >; }, - TConfig, - TConfigInput, TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType }, UFactoryOutput extends ExtensionDataValue, > = { @@ -205,27 +191,30 @@ export type CreateExtensionOptions< disabled?: boolean; inputs?: TInputs; output: Array; - /** @deprecated - use `config.schema` instead */ - configSchema?: PortableSchema; config?: { schema: TConfigSchema; }; factory(context: { node: AppNode; - config: TConfig & - (string extends keyof TConfigSchema - ? {} - : { - [key in keyof TConfigSchema]: z.infer< - ReturnType - >; - }); + config: { + [key in keyof TConfigSchema]: z.infer>; + }; inputs: Expand>; }): Iterable; } & VerifyExtensionFactoryOutput; /** @public */ -export interface ExtensionDefinition { +export interface ExtensionDefinition< + TConfig, + TConfigInput = TConfig, + UOutput extends AnyExtensionDataRef = AnyExtensionDataRef, + TInputs extends { + [inputName in string]: ExtensionInput< + AnyExtensionDataRef, + { optional: boolean; singleton: boolean } + >; + } = {}, +> { $$type: '@backstage/ExtensionDefinition'; readonly kind?: string; readonly namespace?: string; @@ -233,102 +222,71 @@ export interface ExtensionDefinition { readonly attachTo: { id: string; input: string }; readonly disabled: boolean; readonly configSchema?: PortableSchema; -} -export type OverrideExtensionOptions< - UOutput extends AnyExtensionDataRef, - TInputs extends { - [inputName in string]: ExtensionInput< - AnyExtensionDataRef, - { optional: boolean; singleton: boolean } - >; - }, - TConfig, - TConfigInput, - TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType }, - TConfigSchemaOverrides extends { - [key: string]: (zImpl: typeof z) => z.ZodType; - }, - UOutputOverrides extends AnyExtensionDataRef, - UFactoryOverrideOutput extends ExtensionDataValue, -> = { - kind?: string; - namespace?: string; - name?: string; - attachTo?: { id: string; input: string }; - disabled?: boolean; - inputs?: TInputs; - output?: Array; - /** @deprecated - use `config.schema` instead */ - configSchema?: PortableSchema; - config?: { - schema: TConfigSchemaOverrides & { - [KName in keyof TConfig]?: `Error: Config key '${KName & - string}' is already defined in parent schema`; - }; - }; - factory?( - originalFactory: (context?: { - config?: { - [key in keyof TConfigSchema]: z.infer>; - }; - inputs?: Expand>; - }) => ExtensionDataContainer, - context: { - node: AppNode; - config: TConfig & - (string extends keyof TConfigSchema - ? {} - : { - [key in keyof TConfigSchemaOverrides]: z.infer< - ReturnType - >; - } & { - [key in keyof TConfigSchema]: z.infer< - ReturnType - >; - }); - inputs: Expand>; - }, - ): Iterable; - // todo(blam): need to verify that the outputs are merged and verified properly. -} & VerifyExtensionFactoryOutput< - UOutput & UOutputOverrides, - UFactoryOverrideOutput ->; - -/** @public */ -export type OverridableExtension< - UOutput extends AnyExtensionDataRef, - TInputs extends { - [inputName in string]: ExtensionInput< - AnyExtensionDataRef, - { optional: boolean; singleton: boolean } - >; - }, - TConfig, - TConfigInput, - TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType }, -> = { override< - TConfigSchemaOverrides extends { + TExtensionConfigSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType; }, - UOutputOverrides extends AnyExtensionDataRef, - UFactoryOverrideOutput extends ExtensionDataValue, + UFactoryOutput extends ExtensionDataValue, + UNewOutput extends AnyExtensionDataRef, + TExtraInputs extends { + [inputName in string]: ExtensionInput< + AnyExtensionDataRef, + { optional: boolean; singleton: boolean } + >; + }, >( - options: OverrideExtensionOptions< - UOutput, - TInputs, - TConfig, - TConfigInput, - TConfigSchema, - TConfigSchemaOverrides, - UOutputOverrides, - UFactoryOverrideOutput + args: { + attachTo?: { id: string; input: string }; + disabled?: boolean; + inputs?: TExtraInputs & { + [KName in keyof TInputs]?: `Error: Input '${KName & + string}' is already defined in parent definition`; + }; + output?: Array; + config?: { + schema: TExtensionConfigSchema & { + [KName in keyof TConfig]?: `Error: Config key '${KName & + string}' is already defined in parent schema`; + }; + }; + factory( + originalFactory: (context?: { + config?: TConfig; + inputs?: Expand>; + }) => ExtensionDataContainer, + context: { + node: AppNode; + config: TConfig & { + [key in keyof TExtensionConfigSchema]: z.infer< + ReturnType + >; + }; + inputs: Expand>; + }, + ): Iterable; + } & VerifyExtensionFactoryOutput< + AnyExtensionDataRef extends UNewOutput ? UOutput : UNewOutput, + UFactoryOutput >, - ): ExtensionDefinition; -}; + ): ExtensionDefinition< + { + [key in keyof TExtensionConfigSchema]: z.infer< + ReturnType + >; + } & TConfig, + z.input< + z.ZodObject<{ + [key in keyof TExtensionConfigSchema]: ReturnType< + TExtensionConfigSchema[key] + >; + }> + > & + TConfigInput, + AnyExtensionDataRef extends UNewOutput ? UOutput : UNewOutput, + TInputs & TExtraInputs + >; +} /** @internal */ export type InternalExtensionDefinition = @@ -397,36 +355,27 @@ export function createExtension< { optional: boolean; singleton: boolean } >; }, - TConfig, - TConfigInput, TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType }, UFactoryOutput extends ExtensionDataValue, >( options: CreateExtensionOptions< UOutput, TInputs, - TConfig, - TConfigInput, TConfigSchema, UFactoryOutput >, ): ExtensionDefinition< - TConfig & - (string extends keyof TConfigSchema - ? {} - : { - [key in keyof TConfigSchema]: z.infer>; - }), - TConfigInput & - (string extends keyof TConfigSchema - ? {} - : z.input< - z.ZodObject<{ - [key in keyof TConfigSchema]: ReturnType; - }> - >) -> & - OverridableExtension; + { + [key in keyof TConfigSchema]: z.infer>; + }, + z.input< + z.ZodObject<{ + [key in keyof TConfigSchema]: ReturnType; + }> + >, + UOutput, + TInputs +>; /** * @public * @deprecated - use the array format of `output` instead, see TODO-doc-link @@ -436,31 +385,14 @@ export function createExtension< TInputs extends AnyExtensionInputMap, TConfig, TConfigInput, - TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType }, >( options: LegacyCreateExtensionOptions< TOutput, TInputs, TConfig, - TConfigInput, - TConfigSchema + TConfigInput >, -): ExtensionDefinition< - TConfig & - (string extends keyof TConfigSchema - ? {} - : { - [key in keyof TConfigSchema]: z.infer>; - }), - TConfigInput & - (string extends keyof TConfigSchema - ? {} - : z.input< - z.ZodObject<{ - [key in keyof TConfigSchema]: ReturnType; - }> - >) ->; +): ExtensionDefinition; export function createExtension< UOutput extends AnyExtensionDataRef, TInputs extends { @@ -476,20 +408,12 @@ export function createExtension< UFactoryOutput extends ExtensionDataValue, >( options: - | CreateExtensionOptions< - UOutput, - TInputs, - TConfig, - TConfigInput, - TConfigSchema, - UFactoryOutput - > + | CreateExtensionOptions | LegacyCreateExtensionOptions< AnyExtensionDataMap, TLegacyInputs, TConfig, - TConfigInput, - TConfigSchema + TConfigInput >, ): ExtensionDefinition< TConfig & @@ -505,22 +429,29 @@ export function createExtension< z.ZodObject<{ [key in keyof TConfigSchema]: ReturnType; }> - >) -> & - OverridableExtension { - const newConfigSchema = options.config?.schema; - if (newConfigSchema && options.configSchema) { + >), + UOutput, + TInputs +> { + if ('configSchema' in options && 'config' in options) { throw new Error(`Cannot provide both configSchema and config.schema`); } - const configSchema = newConfigSchema - ? createSchemaFromZod(innerZ => + let configSchema: PortableSchema | undefined; + if ('configSchema' in options) { + configSchema = options.configSchema; + } + if ('config' in options) { + const newConfigSchema = options.config?.schema; + configSchema = + newConfigSchema && + createSchemaFromZod(innerZ => innerZ.object( Object.fromEntries( Object.entries(newConfigSchema).map(([k, v]) => [k, v(innerZ)]), ), ), - ) - : options.configSchema; + ); + } return { $$type: '@backstage/ExtensionDefinition', @@ -548,89 +479,133 @@ export function createExtension< parts.push(`attachTo=${options.attachTo.id}@${options.attachTo.input}`); return `ExtensionDefinition{${parts.join(',')}}`; }, - override< - TConfigSchemaOverrides extends { + override: < + TExtensionConfigSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType; }, - UOutputOverrides extends AnyExtensionDataRef, - UFactoryOverrideOutput extends ExtensionDataValue, - >( - overrideOptions: OverrideExtensionOptions< + UOverrideFactoryOutput extends ExtensionDataValue, + UNewOutput extends AnyExtensionDataRef, + TExtraInputs extends { + [inputName in string]: ExtensionInput< + AnyExtensionDataRef, + { optional: boolean; singleton: boolean } + >; + }, + >(overrideOptions: { + attachTo?: { id: string; input: string }; + disabled?: boolean; + inputs?: TExtraInputs; + output?: Array; + config?: { + schema: TExtensionConfigSchema; + }; + factory( + originalFactory: (context?: { + config?: { + [key in keyof TConfigSchema]: z.infer< + ReturnType + >; + }; + inputs?: Expand>; + }) => ExtensionDataContainer, + context: { + node: AppNode; + config: { + [key in keyof TExtensionConfigSchema]: z.infer< + ReturnType + >; + } & { + [key in keyof TConfigSchema]: z.infer< + ReturnType + >; + }; + inputs: Expand>; + }, + ): Iterable; + }): ExtensionDefinition< + { + [key in keyof TExtensionConfigSchema]: z.infer< + ReturnType + >; + } & { + [key in keyof TConfigSchema]: z.infer>; + }, + z.input< + z.ZodObject< + { + [key in keyof TExtensionConfigSchema]: ReturnType< + TExtensionConfigSchema[key] + >; + } & { + [key in keyof TConfigSchema]: ReturnType; + } + > + >, + AnyExtensionDataRef extends UNewOutput ? UOutput : UNewOutput, + TInputs & TExtraInputs + > => { + if (!Array.isArray(options.output)) { + throw new Error( + 'Cannot override an extension that is not declared using the new format with outputs as an array', + ); + } + const newOptions = options as CreateExtensionOptions< UOutput, TInputs, - TConfig, - TConfigInput, TConfigSchema, - TConfigSchemaOverrides, - UOutputOverrides, - UFactoryOverrideOutput - >, - ) { + UFactoryOutput + >; const overrideNewConfigSchema = overrideOptions.config?.schema; - if (overrideNewConfigSchema && overrideOptions.configSchema) { - throw new Error(`Cannot provide both configSchema and config.schema`); - } - const mergedConfigSchema = { - ...options.config?.schema, - ...overrideOptions.config?.schema, - }; - - const overrideConfigSchema = mergedConfigSchema - ? createSchemaFromZod(innerZ => - innerZ.object( - Object.fromEntries( - Object.entries(mergedConfigSchema).map(([k, v]) => [ - k, - v(innerZ), - ]), - ), - ), - ) - : overrideOptions.configSchema; - - const buildDataContainer = (outputs): ExtensionDataContainer => { - const dataMap = new Map(); - if (Symbol.iterator in outputs) { - for (const output of outputs) { - dataMap.set(output.id, output.value); - } - } - - return { - get(ref) { - return dataMap.get(ref.id); - }, - } as ExtensionDataContainer; - }; + const schema = { + ...newOptions.config?.schema, + ...overrideNewConfigSchema, + } as TConfigSchema & TExtensionConfigSchema; return createExtension({ - attachTo: options.attachTo, - output: overrideOptions.output ?? options.output, - configSchema: overrideConfigSchema, + kind: newOptions.kind, + namespace: newOptions.namespace, + name: newOptions.name, + attachTo: overrideOptions.attachTo ?? newOptions.attachTo, + disabled: overrideOptions.disabled ?? newOptions.disabled, + inputs: { ...overrideOptions.inputs, ...newOptions.inputs }, + output: overrideOptions.output ?? newOptions.output, + config: Object.keys(schema).length === 0 ? undefined : { schema }, factory: ({ node, config, inputs }) => { - if (overrideOptions.factory) { - return overrideOptions.factory( - innerCtx => { - const originalFactoryResponse = options.factory({ - node, - config: innerCtx?.config ?? config, - inputs: innerCtx?.inputs ?? inputs, - }); - - return buildDataContainer(originalFactoryResponse); - }, - { node, config, inputs }, - ); + if (!overrideOptions.factory) { + return newOptions.factory({ + node, + config, + inputs: inputs as unknown as Expand< + ResolvedExtensionInputs + >, + }); } - return options.factory(originalFactory, context); + return overrideOptions.factory( + (innerContext?: { + config?: { + [key in keyof TConfigSchema]: z.infer< + ReturnType + >; + }; + inputs?: Expand>; + }): ExtensionDataContainer => { + return createDataContainer( + newOptions.factory({ + node, + config: innerContext?.config ?? config, + inputs: (innerContext?.inputs ?? inputs) as any, // TODO: Fix the way input values are overridden + }) as Iterable, + ); + }, + { + node, + config, + inputs, + }, + ); }, - disabled: overrideOptions.disabled ?? options.disabled, - inputs: overrideOptions.inputs ?? options.inputs, - kind: overrideOptions.kind ?? options.kind, - name: overrideOptions.name ?? options.name, - namespace: overrideOptions.namespace ?? options.namespace, - }); + } as CreateExtensionOptions); }, } as InternalExtensionDefinition< TConfig & diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx index 66c3939a96..924eba2cba 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx @@ -69,6 +69,7 @@ describe('createExtensionBlueprint', () => { output: [coreExtensionData.reactElement], factory: expect.any(Function), toString: expect.any(Function), + override: expect.any(Function), version: 'v2', }); @@ -108,6 +109,7 @@ describe('createExtensionBlueprint', () => { output: [coreExtensionData.reactElement], factory: expect.any(Function), toString: expect.any(Function), + override: expect.any(Function), version: 'v2', }); @@ -389,6 +391,7 @@ describe('createExtensionBlueprint', () => { "output": [ [Function], ], + "override": [Function], "toString": [Function], "version": "v2", } diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts index 88b2523111..a8bf42c7f8 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts @@ -171,7 +171,7 @@ export interface ExtensionBlueprint< } /** @internal */ -function createDataContainer( +export function createDataContainer( values: Iterable< UData extends ExtensionDataRef ? ExtensionDataValue @@ -241,10 +241,7 @@ class ExtensionBlueprintImpl< name?: string; attachTo?: { id: string; input: string }; disabled?: boolean; - inputs?: TExtraInputs & { - [KName in keyof TInputs]?: `Error: Input '${KName & - string}' is already defined in parent definition`; - }; + inputs?: TExtraInputs; output?: Array; params?: TParams; config?: { @@ -363,9 +360,7 @@ class ExtensionBlueprintImpl< } throw new Error('Either params or factory must be provided'); }, - } as CreateExtensionOptions< - UOutput, - TInputs & TExtraInputs, + } as CreateExtensionOptions) as ExtensionDefinition< { [key in keyof TExtensionConfigSchema]: z.infer< ReturnType @@ -383,10 +378,8 @@ class ExtensionBlueprintImpl< [key in keyof TConfigSchema]: ReturnType; } > - >, - TConfigSchema, - UFactoryOutput - >); + > + >; } } From feb5fc73c386997e014714c22f6ceacbaa3d2b01 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 7 Aug 2024 17:30:47 +0200 Subject: [PATCH 172/372] chore: fix tests and update api-reports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Patrik Oldsberg Co-authored-by: Fredrik Adelöw Co-authored-by: Camila Belo Signed-off-by: blam --- .../src/tree/instantiateAppNodeTree.test.ts | 14 +- .../src/tree/resolveAppNodeSpecs.test.ts | 1 + packages/frontend-plugin-api/api-report.md | 180 +++++++++++------- .../wiring/createExtensionOverrides.test.ts | 3 - .../wiring/resolveExtensionDefinition.test.ts | 2 + .../src/wiring/resolveExtensionDefinition.ts | 8 +- .../src/app/createExtensionTester.tsx | 2 +- plugins/catalog-react/api-report-alpha.md | 6 +- plugins/catalog/api-report-alpha.md | 2 +- plugins/search-react/api-report-alpha.md | 2 +- plugins/search/api-report-alpha.md | 11 +- plugins/techdocs/api-report-alpha.md | 4 +- plugins/user-settings/api-report-alpha.md | 4 +- 13 files changed, 146 insertions(+), 93 deletions(-) diff --git a/packages/frontend-app-api/src/tree/instantiateAppNodeTree.test.ts b/packages/frontend-app-api/src/tree/instantiateAppNodeTree.test.ts index de8889daf0..aded5d7826 100644 --- a/packages/frontend-app-api/src/tree/instantiateAppNodeTree.test.ts +++ b/packages/frontend-app-api/src/tree/instantiateAppNodeTree.test.ts @@ -68,7 +68,7 @@ function makeNode( function makeInstanceWithId( extension: Extension, - config?: TConfig, + config?: TConfigInput, ): AppNode { const node = makeNode(extension, { config }); return { @@ -640,12 +640,12 @@ describe('instantiateAppNodeTree', () => { name: 'test', attachTo: { id: 'ignored', input: 'ignored' }, output: [testDataRef, otherDataRef.optional()], - configSchema: createSchemaFromZod(z => - z.object({ - output: z.string().default('test'), - other: z.number().optional(), - }), - ), + config: { + schema: { + output: z => z.string().default('test'), + other: z => z.number().optional(), + }, + }, factory({ config }) { return [ testDataRef(config.output), diff --git a/packages/frontend-app-api/src/tree/resolveAppNodeSpecs.test.ts b/packages/frontend-app-api/src/tree/resolveAppNodeSpecs.test.ts index 8af2aef070..65f3f77640 100644 --- a/packages/frontend-app-api/src/tree/resolveAppNodeSpecs.test.ts +++ b/packages/frontend-app-api/src/tree/resolveAppNodeSpecs.test.ts @@ -48,6 +48,7 @@ function makeExtDef( name, attachTo: { id: attachId, input: 'default' }, disabled: status === 'disabled', + override: () => ({} as ExtensionDefinition), } as ExtensionDefinition; } diff --git a/packages/frontend-plugin-api/api-report.md b/packages/frontend-plugin-api/api-report.md index 4dc9c99c78..325dbd193e 100644 --- a/packages/frontend-plugin-api/api-report.md +++ b/packages/frontend-plugin-api/api-report.md @@ -396,7 +396,7 @@ export function createApiExtension< configSchema?: PortableSchema; inputs?: TInputs; }, -): ExtensionDefinition; +): ExtensionDefinition; // @public (undocumented) export namespace createApiExtension { @@ -492,7 +492,7 @@ export function createComponentExtension< inputs: Expand>; }) => ComponentType; }; -}): ExtensionDefinition; +}): ExtensionDefinition; // @public (undocumented) export namespace createComponentExtension { @@ -524,8 +524,6 @@ export function createExtension< } >; }, - TConfig, - TConfigInput, TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType; }, @@ -534,26 +532,20 @@ export function createExtension< options: CreateExtensionOptions< UOutput, TInputs, - TConfig, - TConfigInput, TConfigSchema, UFactoryOutput >, ): ExtensionDefinition< - TConfig & - (string extends keyof TConfigSchema - ? {} - : { - [key in keyof TConfigSchema]: z.infer>; - }), - TConfigInput & - (string extends keyof TConfigSchema - ? {} - : z.input< - z.ZodObject<{ - [key in keyof TConfigSchema]: ReturnType; - }> - >) + { + [key in keyof TConfigSchema]: z.infer>; + }, + z.input< + z.ZodObject<{ + [key in keyof TConfigSchema]: ReturnType; + }> + >, + UOutput, + TInputs >; // @public @deprecated (undocumented) @@ -562,33 +554,14 @@ export function createExtension< TInputs extends AnyExtensionInputMap, TConfig, TConfigInput, - TConfigSchema extends { - [key: string]: (zImpl: typeof z) => z.ZodType; - }, >( options: LegacyCreateExtensionOptions< TOutput, TInputs, TConfig, - TConfigInput, - TConfigSchema + TConfigInput >, -): ExtensionDefinition< - TConfig & - (string extends keyof TConfigSchema - ? {} - : { - [key in keyof TConfigSchema]: z.infer>; - }), - TConfigInput & - (string extends keyof TConfigSchema - ? {} - : z.input< - z.ZodObject<{ - [key in keyof TConfigSchema]: ReturnType; - }> - >) ->; +): ExtensionDefinition; // @public export function createExtensionBlueprint< @@ -751,8 +724,6 @@ export type CreateExtensionOptions< } >; }, - TConfig, - TConfigInput, TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType; }, @@ -768,20 +739,14 @@ export type CreateExtensionOptions< disabled?: boolean; inputs?: TInputs; output: Array; - configSchema?: PortableSchema; config?: { schema: TConfigSchema; }; factory(context: { node: AppNode; - config: TConfig & - (string extends keyof TConfigSchema - ? {} - : { - [key in keyof TConfigSchema]: z.infer< - ReturnType - >; - }); + config: { + [key in keyof TConfigSchema]: z.infer>; + }; inputs: Expand>; }): Iterable; } & VerifyExtensionFactoryOutput; @@ -827,7 +792,9 @@ export function createNavItemExtension(options: { }, { title?: string | undefined; - } + }, + never, + never >; // @public (undocumented) @@ -850,7 +817,7 @@ export function createNavLogoExtension(options: { namespace?: string; logoIcon: JSX.Element; logoFull: JSX.Element; -}): ExtensionDefinition<{}, {}>; +}): ExtensionDefinition; // @public (undocumented) export namespace createNavLogoExtension { @@ -1005,7 +972,7 @@ export function createSubRouteRef< // @public (undocumented) export function createThemeExtension( theme: AppTheme, -): ExtensionDefinition<{}, {}>; +): ExtensionDefinition; // @public (undocumented) export namespace createThemeExtension { @@ -1021,7 +988,7 @@ export namespace createThemeExtension { export function createTranslationExtension(options: { name?: string; resource: TranslationResource | TranslationMessages; -}): ExtensionDefinition<{}, {}>; +}): ExtensionDefinition; // @public (undocumented) export namespace createTranslationExtension { @@ -1259,7 +1226,20 @@ export type ExtensionDataValues = { }; // @public (undocumented) -export interface ExtensionDefinition { +export interface ExtensionDefinition< + TConfig, + TConfigInput = TConfig, + UOutput extends AnyExtensionDataRef = AnyExtensionDataRef, + TInputs extends { + [inputName in string]: ExtensionInput< + AnyExtensionDataRef, + { + optional: boolean; + singleton: boolean; + } + >; + } = {}, +> { // (undocumented) $$type: '@backstage/ExtensionDefinition'; // (undocumented) @@ -1277,6 +1257,76 @@ export interface ExtensionDefinition { readonly name?: string; // (undocumented) readonly namespace?: string; + // (undocumented) + override< + TExtensionConfigSchema extends { + [key in string]: (zImpl: typeof z) => z.ZodType; + }, + UFactoryOutput extends ExtensionDataValue, + UNewOutput extends AnyExtensionDataRef, + TExtraInputs extends { + [inputName in string]: ExtensionInput< + AnyExtensionDataRef, + { + optional: boolean; + singleton: boolean; + } + >; + }, + >( + args: { + attachTo?: { + id: string; + input: string; + }; + disabled?: boolean; + inputs?: TExtraInputs & { + [KName in keyof TInputs]?: `Error: Input '${KName & + string}' is already defined in parent definition`; + }; + output?: Array; + config?: { + schema: TExtensionConfigSchema & { + [KName in keyof TConfig]?: `Error: Config key '${KName & + string}' is already defined in parent schema`; + }; + }; + factory( + originalFactory: (context?: { + config?: TConfig; + inputs?: Expand>; + }) => ExtensionDataContainer, + context: { + node: AppNode; + config: TConfig & { + [key in keyof TExtensionConfigSchema]: z.infer< + ReturnType + >; + }; + inputs: Expand>; + }, + ): Iterable; + } & VerifyExtensionFactoryOutput< + AnyExtensionDataRef extends UNewOutput ? UOutput : UNewOutput, + UFactoryOutput + >, + ): ExtensionDefinition< + { + [key in keyof TExtensionConfigSchema]: z.infer< + ReturnType + >; + } & TConfig, + z.input< + z.ZodObject<{ + [key in keyof TExtensionConfigSchema]: ReturnType< + TExtensionConfigSchema[key] + >; + }> + > & + TConfigInput, + AnyExtensionDataRef extends UNewOutput ? UOutput : UNewOutput, + TInputs & TExtraInputs + >; } // @public (undocumented) @@ -1418,9 +1468,6 @@ export interface LegacyCreateExtensionOptions< TInputs extends AnyExtensionInputMap, TConfig, TConfigInput, - TConfigSchema extends { - [key: string]: (zImpl: typeof z) => z.ZodType; - }, > { // (undocumented) attachTo: { @@ -1428,24 +1475,13 @@ export interface LegacyCreateExtensionOptions< input: string; }; // (undocumented) - config?: { - schema: TConfigSchema; - }; - // @deprecated (undocumented) configSchema?: PortableSchema; // (undocumented) disabled?: boolean; // (undocumented) factory(context: { node: AppNode; - config: TConfig & - (string extends keyof TConfigSchema - ? {} - : { - [key in keyof TConfigSchema]: z.infer< - ReturnType - >; - }); + config: TConfig; inputs: Expand>; }): Expand>; // (undocumented) diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionOverrides.test.ts b/packages/frontend-plugin-api/src/wiring/createExtensionOverrides.test.ts index 555cd82d4c..aa00247222 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionOverrides.test.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtensionOverrides.test.ts @@ -75,7 +75,6 @@ describe('createExtensionOverrides', () => { "id": "a", "inputs": {}, "output": {}, - "override": [Function], "toString": [Function], "version": "v1", }, @@ -91,7 +90,6 @@ describe('createExtensionOverrides', () => { "id": "b", "inputs": {}, "output": {}, - "override": [Function], "toString": [Function], "version": "v1", }, @@ -107,7 +105,6 @@ describe('createExtensionOverrides', () => { "id": "k:c/n", "inputs": {}, "output": {}, - "override": [Function], "toString": [Function], "version": "v1", }, diff --git a/packages/frontend-plugin-api/src/wiring/resolveExtensionDefinition.test.ts b/packages/frontend-plugin-api/src/wiring/resolveExtensionDefinition.test.ts index e1bfcbfc11..74d081e95d 100644 --- a/packages/frontend-plugin-api/src/wiring/resolveExtensionDefinition.test.ts +++ b/packages/frontend-plugin-api/src/wiring/resolveExtensionDefinition.test.ts @@ -23,6 +23,7 @@ describe('resolveExtensionDefinition', () => { version: 'v2', attachTo: { id: '', input: '' }, disabled: false, + override: () => ({} as ExtensionDefinition), }; it.each([ @@ -63,6 +64,7 @@ describe('old resolveExtensionDefinition', () => { version: 'v1', attachTo: { id: '', input: '' }, disabled: false, + override: () => ({} as ExtensionDefinition), }; it.each([ diff --git a/packages/frontend-plugin-api/src/wiring/resolveExtensionDefinition.ts b/packages/frontend-plugin-api/src/wiring/resolveExtensionDefinition.ts index 18b6f0a653..0c8a7959f7 100644 --- a/packages/frontend-plugin-api/src/wiring/resolveExtensionDefinition.ts +++ b/packages/frontend-plugin-api/src/wiring/resolveExtensionDefinition.ts @@ -100,7 +100,13 @@ export function resolveExtensionDefinition( context?: { namespace?: string }, ): Extension { const internalDefinition = toInternalExtensionDefinition(definition); - const { name, kind, namespace: _, ...rest } = internalDefinition; + const { + name, + kind, + namespace: _skip1, + override: _skip2, + ...rest + } = internalDefinition; const namespace = internalDefinition.namespace ?? context?.namespace; const namePart = diff --git a/packages/frontend-test-utils/src/app/createExtensionTester.tsx b/packages/frontend-test-utils/src/app/createExtensionTester.tsx index bbe52c3fbc..ce7da3701d 100644 --- a/packages/frontend-test-utils/src/app/createExtensionTester.tsx +++ b/packages/frontend-test-utils/src/app/createExtensionTester.tsx @@ -169,7 +169,7 @@ export class ExtensionTester { : [...internal.output, coreExtensionData.routePath], factory: params => { const parentOutput = Array.from( - internal.factory(params) as Iterable< + internal.factory(params as any) as Iterable< ExtensionDataValue >, ).filter(val => val.id !== coreExtensionData.routePath.id); diff --git a/plugins/catalog-react/api-report-alpha.md b/plugins/catalog-react/api-report-alpha.md index 206c0160e2..3ff0788b04 100644 --- a/plugins/catalog-react/api-report-alpha.md +++ b/plugins/catalog-react/api-report-alpha.md @@ -115,7 +115,7 @@ export function createEntityCardExtension< config: TConfig; inputs: Expand>; }) => Promise; -}): ExtensionDefinition; +}): ExtensionDefinition; // @alpha (undocumented) export function createEntityContentExtension< @@ -148,7 +148,9 @@ export function createEntityContentExtension< filter?: string | undefined; title?: string | undefined; path?: string | undefined; - } + }, + never, + never >; // @alpha diff --git a/plugins/catalog/api-report-alpha.md b/plugins/catalog/api-report-alpha.md index 336bf4bc2b..726ee80573 100644 --- a/plugins/catalog/api-report-alpha.md +++ b/plugins/catalog/api-report-alpha.md @@ -108,7 +108,7 @@ export function createCatalogFilterExtension< inputs?: TInputs; configSchema?: PortableSchema; loader: (options: { config: TConfig }) => Promise; -}): ExtensionDefinition; +}): ExtensionDefinition; // @alpha (undocumented) const _default: BackstagePlugin< diff --git a/plugins/search-react/api-report-alpha.md b/plugins/search-react/api-report-alpha.md index c6e011fe41..56c0b6eab9 100644 --- a/plugins/search-react/api-report-alpha.md +++ b/plugins/search-react/api-report-alpha.md @@ -25,7 +25,7 @@ export function createSearchResultListItemExtension< }, >( options: SearchResultItemExtensionOptions, -): ExtensionDefinition; +): ExtensionDefinition; // @alpha (undocumented) export namespace createSearchResultListItemExtension { diff --git a/plugins/search/api-report-alpha.md b/plugins/search/api-report-alpha.md index e9b86f1f87..bb670522e4 100644 --- a/plugins/search/api-report-alpha.md +++ b/plugins/search/api-report-alpha.md @@ -3,6 +3,7 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts +import { AnyExtensionDataRef } from '@backstage/frontend-plugin-api'; import { BackstagePlugin } from '@backstage/frontend-plugin-api'; import { ExtensionDefinition } from '@backstage/frontend-plugin-api'; import { RouteRef } from '@backstage/frontend-plugin-api'; @@ -17,7 +18,7 @@ const _default: BackstagePlugin< export default _default; // @alpha (undocumented) -export const searchApi: ExtensionDefinition<{}, {}>; +export const searchApi: ExtensionDefinition<{}, {}, never, never>; // @alpha (undocumented) export const searchNavItem: ExtensionDefinition< @@ -26,7 +27,9 @@ export const searchNavItem: ExtensionDefinition< }, { title?: string | undefined; - } + }, + never, + never >; // @alpha (undocumented) @@ -38,7 +41,9 @@ export const searchPage: ExtensionDefinition< { path: string; noTrack: boolean; - } + }, + AnyExtensionDataRef, + {} >; // (No @packageDocumentation comment for this package) diff --git a/plugins/techdocs/api-report-alpha.md b/plugins/techdocs/api-report-alpha.md index 04a0c5c512..e3c48ba214 100644 --- a/plugins/techdocs/api-report-alpha.md +++ b/plugins/techdocs/api-report-alpha.md @@ -37,7 +37,9 @@ export const techDocsSearchResultListItemExtension: ExtensionDefinition< asListItem: boolean; asLink: boolean; title?: string | undefined; - } + }, + never, + never >; // (No @packageDocumentation comment for this package) diff --git a/plugins/user-settings/api-report-alpha.md b/plugins/user-settings/api-report-alpha.md index fdb2c5f6bf..d0fad90e08 100644 --- a/plugins/user-settings/api-report-alpha.md +++ b/plugins/user-settings/api-report-alpha.md @@ -24,7 +24,9 @@ export const settingsNavItem: ExtensionDefinition< }, { title?: string | undefined; - } + }, + never, + never >; // @alpha (undocumented) From 467ec43f55ac9f4795bc95ba34dee1c2748b613d Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 8 Aug 2024 12:13:05 +0200 Subject: [PATCH 173/372] chore: wip Signed-off-by: blam --- .../src/wiring/createExtension.test.ts | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts index 30375049bf..547ec2a160 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts @@ -660,6 +660,57 @@ describe('createExtension', () => { expect(true).toBe(true); }); + it('should allow overriding the returned values from the parent factory', () => { + const testExtension = createExtension({ + kind: 'thing', + namespace: 'test', + attachTo: { id: 'root', input: 'default' }, + output: [stringDataRef, numberDataRef], + config: { + schema: { + foo: z => z.string().default('boom'), + }, + }, + factory({ config }) { + return [stringDataRef(config.foo), numberDataRef(42)]; + }, + }); + + const overridden = testExtension.override({ + output: [numberDataRef, stringDataRef], + *factory(originalFactory) { + const output = originalFactory(); + yield* output; + + yield numberDataRef(output.get(numberDataRef) + 1); + }, + }); + + const overridden = testExtension.override({ + output: [numberDataRef, stringDataRef], + *factory(originalFactory) { + const output = originalFactory(); + yield* output.omit(numberDataRef); + + yield numberDataRef(output.get(numberDataRef) + 1); + }, + }); + + const overridden = testExtension.override({ + output: [numberDataRef, stringDataRef], + *factory(originalFactory) { + const output = originalFactory(); + yield* output; + + yield numberDataRef(output.get(numberDataRef) + 1); + }, + }); + + const tester = createExtensionTester(overridden); + + expect(tester.data(numberDataRef)).toBe(43); + }); + it('should work functionally with overrides', () => { const testExtension = createExtension({ kind: 'thing', From 2d215993f14e9018a9fd031ed69c662d9b74783e Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 8 Aug 2024 13:22:59 +0200 Subject: [PATCH 174/372] chore: added changeset Signed-off-by: blam --- .changeset/thick-squids-drive.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .changeset/thick-squids-drive.md diff --git a/.changeset/thick-squids-drive.md b/.changeset/thick-squids-drive.md new file mode 100644 index 0000000000..07654da27d --- /dev/null +++ b/.changeset/thick-squids-drive.md @@ -0,0 +1,31 @@ +--- +'@backstage/frontend-plugin-api': patch +'@backstage/frontend-test-utils': patch +--- + +Added support for being able to override extension definitions. + +```tsx +const TestCard = EntityCardBlueprint.make({ + ... +}); + +TestCard.override({ + attachTo: { id: 'something-else', input: 'overriden' }, + config: { + schema: { + newConfig: z => z.string().optional(), + } + }, + *factory(originalFactory, { inputs, config }){ + const originalOutput = originalFactory(); + + yield coreExentsionData.reactElement( + + {originalOutput.get(coreExentsionData.reactElement)} + + ); + } +}); + +``` From 8fb60cb2f133a36684dd13028b02de54cb623a49 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 8 Aug 2024 13:41:00 +0200 Subject: [PATCH 175/372] chore: some more work MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Patrik Oldsberg Co-authored-by: Fredrik Adelöw Co-authored-by: Camila Belo Signed-off-by: blam --- .changeset/thick-squids-drive.md | 5 ++++- .../src/wiring/createExtension.test.ts | 20 ------------------- .../src/wiring/createExtension.ts | 9 ++++++++- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/.changeset/thick-squids-drive.md b/.changeset/thick-squids-drive.md index 07654da27d..0e798063c0 100644 --- a/.changeset/thick-squids-drive.md +++ b/.changeset/thick-squids-drive.md @@ -11,12 +11,15 @@ const TestCard = EntityCardBlueprint.make({ }); TestCard.override({ - attachTo: { id: 'something-else', input: 'overriden' }, + // override attachment points + attachTo: { id: 'something-else', input: 'overridden' }, + // extend the config schema config: { schema: { newConfig: z => z.string().optional(), } }, + // override factory *factory(originalFactory, { inputs, config }){ const originalOutput = originalFactory(); diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts index 547ec2a160..f9e39e98de 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts @@ -686,26 +686,6 @@ describe('createExtension', () => { }, }); - const overridden = testExtension.override({ - output: [numberDataRef, stringDataRef], - *factory(originalFactory) { - const output = originalFactory(); - yield* output.omit(numberDataRef); - - yield numberDataRef(output.get(numberDataRef) + 1); - }, - }); - - const overridden = testExtension.override({ - output: [numberDataRef, stringDataRef], - *factory(originalFactory) { - const output = originalFactory(); - yield* output; - - yield numberDataRef(output.get(numberDataRef) + 1); - }, - }); - const tester = createExtensionTester(overridden); expect(tester.data(numberDataRef)).toBe(43); diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.ts b/packages/frontend-plugin-api/src/wiring/createExtension.ts index 6e75fc76e5..600b96ebe0 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.ts @@ -581,7 +581,7 @@ export function createExtension< >, }); } - return overrideOptions.factory( + const parentResult = overrideOptions.factory( (innerContext?: { config?: { [key in keyof TConfigSchema]: z.infer< @@ -604,6 +604,13 @@ export function createExtension< inputs, }, ); + + const deduplicatedResult = new Map(); + for (const item of parentResult) { + deduplicatedResult.set(item.id, item); + } + + return deduplicatedResult.values() as Iterable; }, } as CreateExtensionOptions); }, From 80b84f77e51bc924cb52dceb8ed8e25285d41872 Mon Sep 17 00:00:00 2001 From: Heikki Hellgren Date: Thu, 8 Aug 2024 13:47:32 +0300 Subject: [PATCH 176/372] fix: notification reload on navigation this fixes issue when notifications are always reloaded when navigating in the portal. Signed-off-by: Heikki Hellgren --- .changeset/clean-kids-applaud.md | 5 +++++ .../NotificationsSideBarItem.tsx | 8 ++++---- plugins/notifications/src/hooks/useWebNotifications.ts | 10 ++++------ 3 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 .changeset/clean-kids-applaud.md diff --git a/.changeset/clean-kids-applaud.md b/.changeset/clean-kids-applaud.md new file mode 100644 index 0000000000..907b5978cd --- /dev/null +++ b/.changeset/clean-kids-applaud.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-notifications': patch +--- + +Fixed issue with notification reloading on page change diff --git a/plugins/notifications/src/components/NotificationsSideBarItem/NotificationsSideBarItem.tsx b/plugins/notifications/src/components/NotificationsSideBarItem/NotificationsSideBarItem.tsx index 457893b016..22ce11db69 100644 --- a/plugins/notifications/src/components/NotificationsSideBarItem/NotificationsSideBarItem.tsx +++ b/plugins/notifications/src/components/NotificationsSideBarItem/NotificationsSideBarItem.tsx @@ -111,7 +111,7 @@ export const NotificationsSidebarItem = (props?: { const notificationsApi = useApi(notificationsApiRef); const alertApi = useApi(alertApiRef); const [unreadCount, setUnreadCount] = React.useState(0); - const notificationsRoute = useRouteRef(rootRouteRef); + const notificationsRoute = useRouteRef(rootRouteRef)(); // TODO: Do we want to add long polling in case signals are not available const { lastSignal } = useSignal('notifications'); const { sendWebNotification, requestUserPermission } = useWebNotifications( @@ -126,7 +126,7 @@ export const NotificationsSidebarItem = (props?: { <> { if (notification.payload.link) { notificationsApi @@ -189,7 +189,6 @@ export const NotificationsSidebarItem = (props?: { ) { return; } - notificationsApi .getNotification(signal.notification_id) .then(notification => { @@ -211,6 +210,7 @@ export const NotificationsSidebarItem = (props?: { ? `${notification.payload.title.substring(0, 50)}...` : notification.payload.title; enqueueSnackbar(snackBarText, { + key: notification.id, variant: notification.payload.severity, anchorOrigin: { vertical: 'bottom', horizontal: 'right' }, action, @@ -273,7 +273,7 @@ export const NotificationsSidebarItem = (props?: { /> )} { requestUserPermission(); }} diff --git a/plugins/notifications/src/hooks/useWebNotifications.ts b/plugins/notifications/src/hooks/useWebNotifications.ts index ec120a614d..cc69a0e815 100644 --- a/plugins/notifications/src/hooks/useWebNotifications.ts +++ b/plugins/notifications/src/hooks/useWebNotifications.ts @@ -14,18 +14,16 @@ * limitations under the License. */ import { useCallback, useState } from 'react'; -import { rootRouteRef } from '../routes'; import { useApi, useRouteRef } from '@backstage/core-plugin-api'; -import { useNavigate } from 'react-router-dom'; import { notificationsApiRef } from '../api'; +import { rootRouteRef } from '../routes'; /** @internal */ export function useWebNotifications(enabled: boolean) { const [webNotificationPermission, setWebNotificationPermission] = useState('default'); - const notificationsRoute = useRouteRef(rootRouteRef); + const notificationsRoute = useRouteRef(rootRouteRef)(); const notificationsApi = useApi(notificationsApiRef); - const navigate = useNavigate(); const requestUserPermission = useCallback(() => { if ( @@ -64,14 +62,14 @@ export function useWebNotifications(enabled: boolean) { read: true, }); } else { - navigate(notificationsRoute()); + window.open(notificationsRoute); } notification.close(); }; return notification; }, - [webNotificationPermission, notificationsApi, navigate, notificationsRoute], + [webNotificationPermission, notificationsApi, notificationsRoute], ); return { sendWebNotification, requestUserPermission }; From 201c98bb2c09a2a226c875d9343418eacae297c2 Mon Sep 17 00:00:00 2001 From: bioerrorlog Date: Thu, 8 Aug 2024 21:02:07 +0900 Subject: [PATCH 177/372] docs: fix broken link in techdocs configuration Signed-off-by: bioerrorlog --- docs/features/techdocs/configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/features/techdocs/configuration.md b/docs/features/techdocs/configuration.md index a861a50c87..8c2348972c 100644 --- a/docs/features/techdocs/configuration.md +++ b/docs/features/techdocs/configuration.md @@ -20,7 +20,7 @@ techdocs: # spin up the techdocs-container docker image or to run mkdocs locally (assuming all the dependencies are taken care of). # You want to change this to 'local' if you are running Backstage using your own custom Docker setup and want to avoid running # into Docker in Docker situation. Read more here - # https://backstage.io/docs/features/techdocs/getting-started#disable-docker-in-docker-situation-optional + # https://backstage.io/docs/features/techdocs/getting-started/#disabling-docker-in-docker-situation-optional runIn: 'docker' From d57967cbd38c68d335099b1e288e2825a5dee4fd Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Thu, 8 Aug 2024 14:08:23 +0100 Subject: [PATCH 178/372] adds ability to configure the commit message when initializating a repo Signed-off-by: Brian Fletcher --- .changeset/five-mangos-agree.md | 5 +++++ .../src/actions/bitbucketCloud.ts | 13 ++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 .changeset/five-mangos-agree.md diff --git a/.changeset/five-mangos-agree.md b/.changeset/five-mangos-agree.md new file mode 100644 index 0000000000..1ad9b6b04c --- /dev/null +++ b/.changeset/five-mangos-agree.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend-module-bitbucket-cloud': patch +--- + +Add abilty to set the initial commit message when initializing a repository using the scaffolder action. diff --git a/plugins/scaffolder-backend-module-bitbucket-cloud/src/actions/bitbucketCloud.ts b/plugins/scaffolder-backend-module-bitbucket-cloud/src/actions/bitbucketCloud.ts index 99e8e52a43..71eacea955 100644 --- a/plugins/scaffolder-backend-module-bitbucket-cloud/src/actions/bitbucketCloud.ts +++ b/plugins/scaffolder-backend-module-bitbucket-cloud/src/actions/bitbucketCloud.ts @@ -111,6 +111,7 @@ export function createPublishBitbucketCloudAction(options: { description?: string; defaultBranch?: string; repoVisibility?: 'private' | 'public'; + gitCommitMessage?: string; sourcePath?: string; token?: string; }>({ @@ -141,6 +142,11 @@ export function createPublishBitbucketCloudAction(options: { type: 'string', description: `Sets the default branch on the repository. The default value is 'master'`, }, + gitCommitMessage: { + title: 'Git Commit Message', + type: 'string', + description: `Sets the commit message on the repository. The default value is 'initial commit'`, + }, sourcePath: { title: 'Source Path', description: @@ -178,6 +184,7 @@ export function createPublishBitbucketCloudAction(options: { repoUrl, description, defaultBranch = 'master', + gitCommitMessage, repoVisibility = 'private', } = ctx.input; @@ -256,9 +263,9 @@ export function createPublishBitbucketCloudAction(options: { auth, defaultBranch, logger: ctx.logger, - commitMessage: config.getOptionalString( - 'scaffolder.defaultCommitMessage', - ), + commitMessage: + gitCommitMessage || + config.getOptionalString('scaffolder.defaultCommitMessage'), gitAuthorInfo, }); From 2c7c7901bfa4373fb7c6368538997e46ad8e4da6 Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Thu, 8 Aug 2024 14:35:22 +0100 Subject: [PATCH 179/372] Adds api report changes Signed-off-by: Brian Fletcher --- plugins/scaffolder-backend-module-bitbucket-cloud/api-report.md | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/scaffolder-backend-module-bitbucket-cloud/api-report.md b/plugins/scaffolder-backend-module-bitbucket-cloud/api-report.md index a484f49f77..1f1a7ca1d0 100644 --- a/plugins/scaffolder-backend-module-bitbucket-cloud/api-report.md +++ b/plugins/scaffolder-backend-module-bitbucket-cloud/api-report.md @@ -36,6 +36,7 @@ export function createPublishBitbucketCloudAction(options: { description?: string | undefined; defaultBranch?: string | undefined; repoVisibility?: 'private' | 'public' | undefined; + gitCommitMessage?: string | undefined; sourcePath?: string | undefined; token?: string | undefined; }, From 2ced236e072ad432202f5ef13cd7bff987d7b8f3 Mon Sep 17 00:00:00 2001 From: MT Lewis Date: Thu, 25 Jul 2024 09:53:27 +0100 Subject: [PATCH 180/372] build(deps): bump @module-federation/enhanced to ^0.3.5 Avoids dependency on vulnerable version of ws: https://github.com/advisories/GHSA-3h5v-q93c-6h6q Signed-off-by: MT Lewis --- .changeset/slow-rocks-end.md | 5 + packages/cli/package.json | 2 +- yarn.lock | 171 ++++++++++++++++++++--------------- 3 files changed, 106 insertions(+), 72 deletions(-) create mode 100644 .changeset/slow-rocks-end.md diff --git a/.changeset/slow-rocks-end.md b/.changeset/slow-rocks-end.md new file mode 100644 index 0000000000..f2633c9924 --- /dev/null +++ b/.changeset/slow-rocks-end.md @@ -0,0 +1,5 @@ +--- +'@backstage/cli': patch +--- + +Updated dependency `@module-federation/enhanced` to `0.3.1` diff --git a/packages/cli/package.json b/packages/cli/package.json index ba45b8f514..45f58a463c 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -53,7 +53,7 @@ "@backstage/release-manifests": "workspace:^", "@backstage/types": "workspace:^", "@manypkg/get-packages": "^1.1.3", - "@module-federation/enhanced": "^0.1.19", + "@module-federation/enhanced": "^0.3.5", "@octokit/graphql": "^5.0.0", "@octokit/graphql-schema": "^13.7.0", "@octokit/oauth-app": "^4.2.0", diff --git a/yarn.lock b/yarn.lock index c14251269c..962650fc85 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3922,7 +3922,7 @@ __metadata: "@backstage/theme": "workspace:^" "@backstage/types": "workspace:^" "@manypkg/get-packages": ^1.1.3 - "@module-federation/enhanced": ^0.1.19 + "@module-federation/enhanced": ^0.3.5 "@octokit/graphql": ^5.0.0 "@octokit/graphql-schema": ^13.7.0 "@octokit/oauth-app": ^4.2.0 @@ -11132,13 +11132,22 @@ __metadata: languageName: node linkType: hard -"@module-federation/dts-plugin@npm:0.1.21": - version: 0.1.21 - resolution: "@module-federation/dts-plugin@npm:0.1.21" +"@module-federation/bridge-react-webpack-plugin@npm:0.3.5": + version: 0.3.5 + resolution: "@module-federation/bridge-react-webpack-plugin@npm:0.3.5" dependencies: - "@module-federation/managers": 0.1.21 - "@module-federation/sdk": 0.1.21 - "@module-federation/third-party-dts-extractor": 0.1.21 + "@module-federation/sdk": 0.3.5 + checksum: 9fb0aab200bd63a07c1adcc71e3342c713de4806dccc2b4a8ea2eb19677b2c8753b638906ed48ab49909c753319f33792cb2afd08c0d6a80b4af742d1dc57bd1 + languageName: node + linkType: hard + +"@module-federation/dts-plugin@npm:0.3.5": + version: 0.3.5 + resolution: "@module-federation/dts-plugin@npm:0.3.5" + dependencies: + "@module-federation/managers": 0.3.5 + "@module-federation/sdk": 0.3.5 + "@module-federation/third-party-dts-extractor": 0.3.5 adm-zip: ^0.5.10 ansi-colors: ^4.1.3 axios: ^1.6.7 @@ -11150,31 +11159,33 @@ __metadata: log4js: 6.9.1 node-schedule: 2.1.1 rambda: ^9.1.0 - ws: 8.17.0 + ws: 8.17.1 peerDependencies: typescript: ^4.9.0 || ^5.0.0 - vue-tsc: ^1.0.24 + vue-tsc: ">=1.0.24" peerDependenciesMeta: vue-tsc: optional: true - checksum: ec4cd030a25617698754cbac2da5463f8942cdd0a64bdc95f6ff5fd29fff6b88cf3db90e53e6b260cd3593893fe6ee2d6e149d0a46698eb7f9cc19a9df26193d + checksum: 8c8e653d0818b3df14ec399d6db0b5784f202c7909112e4884f29c4e268bd9ff6b2d891677776a65ac6204bf4df9cb2f377b7cb8884c1fee98d275d8d2f28f29 languageName: node linkType: hard -"@module-federation/enhanced@npm:^0.1.19": - version: 0.1.21 - resolution: "@module-federation/enhanced@npm:0.1.21" +"@module-federation/enhanced@npm:^0.3.5": + version: 0.3.5 + resolution: "@module-federation/enhanced@npm:0.3.5" dependencies: - "@module-federation/dts-plugin": 0.1.21 - "@module-federation/managers": 0.1.21 - "@module-federation/manifest": 0.1.21 - "@module-federation/rspack": 0.1.21 - "@module-federation/runtime-tools": 0.1.21 - "@module-federation/sdk": 0.1.21 + "@module-federation/bridge-react-webpack-plugin": 0.3.5 + "@module-federation/dts-plugin": 0.3.5 + "@module-federation/managers": 0.3.5 + "@module-federation/manifest": 0.3.5 + "@module-federation/rspack": 0.3.5 + "@module-federation/runtime-tools": 0.3.5 + "@module-federation/sdk": 0.3.5 + btoa: ^1.2.1 upath: 2.0.1 peerDependencies: typescript: ^4.9.0 || ^5.0.0 - vue-tsc: ^1.0.24 + vue-tsc: ">=1.0.24" webpack: ^5.0.0 peerDependenciesMeta: typescript: @@ -11183,91 +11194,100 @@ __metadata: optional: true webpack: optional: true - checksum: bc0ff541db1066b290b3ad9ab868437dc3d0754b9d06ab263f8fb7f54e08238eae9232a482a681dd6152e4a175578d65df9f27fe181fc8fb602d7cc1ae34807d + checksum: 40130aa86c1ae2c90cf49360754f4e9688f33900087d376215c14b64d1f596141785eb7794457bb76387bb79725a60bee1271e3911d95183e9379c6454145894 languageName: node linkType: hard -"@module-federation/managers@npm:0.1.21": - version: 0.1.21 - resolution: "@module-federation/managers@npm:0.1.21" +"@module-federation/managers@npm:0.3.5": + version: 0.3.5 + resolution: "@module-federation/managers@npm:0.3.5" dependencies: - "@module-federation/sdk": 0.1.21 + "@module-federation/sdk": 0.3.5 find-pkg: 2.0.0 fs-extra: 9.1.0 - checksum: 5f230d5795d86dfd68c404ee2b7a1264950c283a4b1c6f4ee9cc9579fabb413718dfbc1ff726b9c213f9d3223d944dd38dd9d04b700962e6398c3c3728d6323e + checksum: a60a21c2c9bf84fd0911365980e2f0e163485f0a952992e3fec242e8e7a33f0c803c62e1c463fb1326845f0077aef2d45d90eba0f6f69545e60e0ea708ebcaba languageName: node linkType: hard -"@module-federation/manifest@npm:0.1.21": - version: 0.1.21 - resolution: "@module-federation/manifest@npm:0.1.21" +"@module-federation/manifest@npm:0.3.5": + version: 0.3.5 + resolution: "@module-federation/manifest@npm:0.3.5" dependencies: - "@module-federation/dts-plugin": 0.1.21 - "@module-federation/managers": 0.1.21 - "@module-federation/sdk": 0.1.21 + "@module-federation/dts-plugin": 0.3.5 + "@module-federation/managers": 0.3.5 + "@module-federation/sdk": 0.3.5 chalk: 3.0.0 find-pkg: 2.0.0 - checksum: cef2011875f14e853a355626ae1dbc8ae3b0714d31140e329b5dd71525782b08c2e1d6ca45276a563bb3c3b7f7c4e64a31f0698ef12606f05aa6da46e759f345 + checksum: 0b0f41802630536a9a90b3e958052d2a1503bdd3927c40e1962e371ee26f2646172ef895b868fd287921a318e0bac5a513ef069517565c445fb659c150e3a257 languageName: node linkType: hard -"@module-federation/rspack@npm:0.1.21": - version: 0.1.21 - resolution: "@module-federation/rspack@npm:0.1.21" +"@module-federation/rspack@npm:0.3.5": + version: 0.3.5 + resolution: "@module-federation/rspack@npm:0.3.5" dependencies: - "@module-federation/dts-plugin": 0.1.21 - "@module-federation/managers": 0.1.21 - "@module-federation/manifest": 0.1.21 - "@module-federation/runtime-tools": 0.1.21 - "@module-federation/sdk": 0.1.21 - checksum: 55516285e23f4ca7127afafb14af667defbe46dc3224f85d7e07edbc8937d7fac909dfebc2f9dd73120b99bbe5135372cf0fbbe282990d80e6953a60dfa4c93e + "@module-federation/bridge-react-webpack-plugin": 0.3.5 + "@module-federation/dts-plugin": 0.3.5 + "@module-federation/managers": 0.3.5 + "@module-federation/manifest": 0.3.5 + "@module-federation/runtime-tools": 0.3.5 + "@module-federation/sdk": 0.3.5 + peerDependencies: + typescript: ^4.9.0 || ^5.0.0 + vue-tsc: ">=1.0.24" + peerDependenciesMeta: + typescript: + optional: true + vue-tsc: + optional: true + checksum: 0afd72784ebbc92ab5d295de1be938cec259f7fcdc59b753af881bbf5b7f982b816c9c04b1ee5e052326556b8a4647001a623c58562c908ee7ffe316f4171df6 languageName: node linkType: hard -"@module-federation/runtime-tools@npm:0.1.21": - version: 0.1.21 - resolution: "@module-federation/runtime-tools@npm:0.1.21" +"@module-federation/runtime-tools@npm:0.3.5": + version: 0.3.5 + resolution: "@module-federation/runtime-tools@npm:0.3.5" dependencies: - "@module-federation/runtime": 0.1.21 - "@module-federation/webpack-bundler-runtime": 0.1.21 - checksum: 628c0c4834093520f9c71481d587c9e18163f82e481b05b1900f04e2d5da4abb69af6d814ac5cd1951057b28d73f3adeb1cee7cd83628305b10cc7988405fbc5 + "@module-federation/runtime": 0.3.5 + "@module-federation/webpack-bundler-runtime": 0.3.5 + checksum: 5287783b12fff5a37d45cb904d9e004c569bb0803680c133a19002810f7c84f8bff87594dacbc473cdc813788eb8c9feb0915fb2f446ca0f4c609d0be9e33191 languageName: node linkType: hard -"@module-federation/runtime@npm:0.1.21": - version: 0.1.21 - resolution: "@module-federation/runtime@npm:0.1.21" +"@module-federation/runtime@npm:0.3.5": + version: 0.3.5 + resolution: "@module-federation/runtime@npm:0.3.5" dependencies: - "@module-federation/sdk": 0.1.21 - checksum: ce4de8515b54f1cd07a3c7c4cbd35fea163294b9fb24be10827872f3ebb62cd5c289f3602efe4149d963282739f79b51947afa039ee6f36be7f66dea83d590fc + "@module-federation/sdk": 0.3.5 + checksum: 61ef8a6535e80d583d5d755d33f4edad0b6e4df6118f38296dbab5eb5f23a624c8ca7ceab8c00d6d7d4249179615cff7235f3554476933aabbc9b988321944ae languageName: node linkType: hard -"@module-federation/sdk@npm:0.1.21": - version: 0.1.21 - resolution: "@module-federation/sdk@npm:0.1.21" - checksum: 6856dcfe2ef5ae939890b82010aaad911fa6c4330a05f290ae054c316c9b532d3691456a1f9e176fe05f1df2d6f2d8c7e0c842ca5648a0fd7abf270e44ed9ecb +"@module-federation/sdk@npm:0.3.5": + version: 0.3.5 + resolution: "@module-federation/sdk@npm:0.3.5" + checksum: 80f720af685def16bd80d6104dd7d831df03b1b3eedb11674a95f0e4420dbbaf732d4f619fc5e06421b36549483ab31484ad8a0490ac3033ed85ac300172be7d languageName: node linkType: hard -"@module-federation/third-party-dts-extractor@npm:0.1.21": - version: 0.1.21 - resolution: "@module-federation/third-party-dts-extractor@npm:0.1.21" +"@module-federation/third-party-dts-extractor@npm:0.3.5": + version: 0.3.5 + resolution: "@module-federation/third-party-dts-extractor@npm:0.3.5" dependencies: find-pkg: 2.0.0 fs-extra: 9.1.0 resolve: 1.22.8 - checksum: e394fd7c2e6dbdf8df6937628680e7356ac897ee6f1309d7fbc38c00bcf4be9c0363f8bc1a75c29f7987a5a2f11f7855481813889b18e8b444ee9006aeb4a299 + checksum: f7413bee4bf77fa8576dce31580fd91a636d0db6cffa17cd5f485039c5470254410005386f4b4160298b0fced985b9d1768411a64cc96f90a0b73f2e7d1a463f languageName: node linkType: hard -"@module-federation/webpack-bundler-runtime@npm:0.1.21": - version: 0.1.21 - resolution: "@module-federation/webpack-bundler-runtime@npm:0.1.21" +"@module-federation/webpack-bundler-runtime@npm:0.3.5": + version: 0.3.5 + resolution: "@module-federation/webpack-bundler-runtime@npm:0.3.5" dependencies: - "@module-federation/runtime": 0.1.21 - "@module-federation/sdk": 0.1.21 - checksum: 7d96002066e63bdb503964fd5fb2798be25f4135a599d87721f4d26ebe1de1affbf447c56b082f7ee850ae7798d0ac637f6a486f58591269065e114051b466e5 + "@module-federation/runtime": 0.3.5 + "@module-federation/sdk": 0.3.5 + checksum: a4ba483be2ae1a157bcbaf1e895bbbe4c6cfe3039f6403ce543aa5163add4207c69d03f98a2b2910f21fbf61086f56c1f14ff19e44b36bb201a12ddf54ee3491 languageName: node linkType: hard @@ -22372,6 +22392,15 @@ __metadata: languageName: node linkType: hard +"btoa@npm:^1.2.1": + version: 1.2.1 + resolution: "btoa@npm:1.2.1" + bin: + btoa: bin/btoa.js + checksum: afbf004fb1b1d530e053ffa66ef5bd3878b101c59d808ac947fcff96810b4452abba2b54be687adadea2ba9efc7af48b04228742789bf824ef93f103767e690c + languageName: node + linkType: hard + "buffer-crc32@npm:^0.2.1, buffer-crc32@npm:^0.2.13, buffer-crc32@npm:~0.2.3": version: 0.2.13 resolution: "buffer-crc32@npm:0.2.13" @@ -45058,9 +45087,9 @@ __metadata: languageName: node linkType: hard -"ws@npm:8.17.0": - version: 8.17.0 - resolution: "ws@npm:8.17.0" +"ws@npm:8.17.1": + version: 8.17.1 + resolution: "ws@npm:8.17.1" peerDependencies: bufferutil: ^4.0.1 utf-8-validate: ">=5.0.2" @@ -45069,7 +45098,7 @@ __metadata: optional: true utf-8-validate: optional: true - checksum: 147ef9eab0251364e1d2c55338ad0efb15e6913923ccbfdf20f7a8a6cb8f88432bcd7f4d8f66977135bfad35575644f9983201c1a361019594a4e53977bf6d4e + checksum: 442badcce1f1178ec87a0b5372ae2e9771e07c4929a3180321901f226127f252441e8689d765aa5cfba5f50ac60dd830954afc5aeae81609aefa11d3ddf5cecf languageName: node linkType: hard From a65cfc814916f985d6a2b3a06a8b3fea3bd6557f Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 8 Aug 2024 16:19:54 +0200 Subject: [PATCH 181/372] frontend-plugin-api: add support for accessing extensions from plugin instance Signed-off-by: Patrik Oldsberg --- .changeset/old-tools-smell.md | 5 + .../app-next-example-plugin/api-report.md | 2 +- packages/frontend-plugin-api/api-report.md | 172 ++++++++++++++---- .../src/wiring/createExtension.ts | 149 ++++++++++----- .../src/wiring/createExtensionBlueprint.ts | 70 ++++--- .../src/wiring/createPlugin.test.ts | 8 +- .../src/wiring/createPlugin.ts | 67 ++++--- .../wiring/resolveExtensionDefinition.test.ts | 105 ++++++++++- .../src/wiring/resolveExtensionDefinition.ts | 30 +++ .../frontend-plugin-api/src/wiring/types.ts | 18 +- plugins/api-docs/api-report-alpha.md | 3 +- plugins/app-visualizer/api-report.md | 2 +- plugins/catalog-graph/api-report-alpha.md | 3 +- plugins/catalog-import/api-report-alpha.md | 1 + plugins/catalog-react/api-report-alpha.md | 15 +- plugins/catalog/api-report-alpha.md | 13 +- plugins/devtools/api-report-alpha.md | 1 + plugins/home/api-report-alpha.md | 2 +- plugins/kubernetes/api-report-alpha.md | 1 + plugins/org/api-report-alpha.md | 3 +- plugins/scaffolder/api-report-alpha.md | 3 +- plugins/search-react/api-report-alpha.md | 10 +- plugins/search/api-report-alpha.md | 21 ++- plugins/techdocs/api-report-alpha.md | 6 +- plugins/user-settings/api-report-alpha.md | 6 +- 25 files changed, 564 insertions(+), 152 deletions(-) create mode 100644 .changeset/old-tools-smell.md diff --git a/.changeset/old-tools-smell.md b/.changeset/old-tools-smell.md new file mode 100644 index 0000000000..4dbd65e779 --- /dev/null +++ b/.changeset/old-tools-smell.md @@ -0,0 +1,5 @@ +--- +'@backstage/frontend-plugin-api': patch +--- + +Add support for accessing extensions definitions provided by a plugin via `plugin.getExtension(...)`. For this to work the extensions must be defined using the v2 format, typically using an extension blueprint. diff --git a/packages/app-next-example-plugin/api-report.md b/packages/app-next-example-plugin/api-report.md index c89a7b599b..962b1473a8 100644 --- a/packages/app-next-example-plugin/api-report.md +++ b/packages/app-next-example-plugin/api-report.md @@ -7,7 +7,7 @@ import { BackstagePlugin } from '@backstage/frontend-plugin-api'; import { default as React_2 } from 'react'; // @public (undocumented) -const examplePlugin: BackstagePlugin<{}, {}>; +const examplePlugin: BackstagePlugin<{}, {}, {}>; export default examplePlugin; // @public (undocumented) diff --git a/packages/frontend-plugin-api/api-report.md b/packages/frontend-plugin-api/api-report.md index 325dbd193e..a8f8ce591b 100644 --- a/packages/frontend-plugin-api/api-report.md +++ b/packages/frontend-plugin-api/api-report.md @@ -275,17 +275,22 @@ export { BackstageIdentityResponse }; // @public (undocumented) export interface BackstagePlugin< - Routes extends AnyRoutes = AnyRoutes, - ExternalRoutes extends AnyExternalRoutes = AnyExternalRoutes, + TRoutes extends AnyRoutes = AnyRoutes, + TExternalRoutes extends AnyExternalRoutes = AnyExternalRoutes, + TExtensionMap extends { + [id in string]: ExtensionDefinition; + } = {}, > { // (undocumented) readonly $$type: '@backstage/BackstagePlugin'; // (undocumented) - readonly externalRoutes: ExternalRoutes; + readonly externalRoutes: TExternalRoutes; + // (undocumented) + getExtension(id: TId): TExtensionMap[TId]; // (undocumented) readonly id: string; // (undocumented) - readonly routes: Routes; + readonly routes: TRoutes; } export { BackstageUserIdentity }; @@ -396,7 +401,15 @@ export function createApiExtension< configSchema?: PortableSchema; inputs?: TInputs; }, -): ExtensionDefinition; +): ExtensionDefinition< + TConfig, + TConfig, + never, + never, + string | undefined, + string | undefined, + string | undefined +>; // @public (undocumented) export namespace createApiExtension { @@ -492,7 +505,15 @@ export function createComponentExtension< inputs: Expand>; }) => ComponentType; }; -}): ExtensionDefinition; +}): ExtensionDefinition< + TConfig, + TConfig, + never, + never, + string | undefined, + string | undefined, + string | undefined +>; // @public (undocumented) export namespace createComponentExtension { @@ -528,8 +549,14 @@ export function createExtension< [key: string]: (zImpl: typeof z) => z.ZodType; }, UFactoryOutput extends ExtensionDataValue, + const TKind extends string | undefined = undefined, + const TNamespace extends string | undefined = undefined, + const TName extends string | undefined = undefined, >( options: CreateExtensionOptions< + TKind, + TNamespace, + TName, UOutput, TInputs, TConfigSchema, @@ -545,7 +572,10 @@ export function createExtension< }> >, UOutput, - TInputs + TInputs, + string | undefined extends TKind ? undefined : TKind, + string | undefined extends TNamespace ? undefined : TNamespace, + string | undefined extends TName ? undefined : TName >; // @public @deprecated (undocumented) @@ -580,11 +610,17 @@ export function createExtensionBlueprint< [key in string]: (zImpl: typeof z) => z.ZodType; }, UFactoryOutput extends ExtensionDataValue, + TKind extends string, + TNamespace extends string | undefined = undefined, + TName extends string | undefined = undefined, TDataRefs extends { [name in string]: AnyExtensionDataRef; } = never, >( options: CreateExtensionBlueprintOptions< + TKind, + TNamespace, + TName, TParams, UOutput, TInputs, @@ -593,6 +629,9 @@ export function createExtensionBlueprint< TDataRefs >, ): ExtensionBlueprint< + TKind, + TNamespace, + TName, TParams, UOutput, string extends keyof TInputs ? {} : TInputs, @@ -613,6 +652,9 @@ export function createExtensionBlueprint< // @public (undocumented) export type CreateExtensionBlueprintOptions< + TKind extends string, + TNamespace extends string | undefined, + TName extends string | undefined, TParams, UOutput extends AnyExtensionDataRef, TInputs extends { @@ -632,8 +674,8 @@ export type CreateExtensionBlueprintOptions< [name in string]: AnyExtensionDataRef; }, > = { - kind: string; - namespace?: string | ((params: TParams) => string); + kind: TKind; + namespace?: TNamespace | ((params: TParams) => TNamespace); attachTo: { id: string; input: string; @@ -641,7 +683,7 @@ export type CreateExtensionBlueprintOptions< disabled?: boolean; inputs?: TInputs; output: Array; - name?: string | ((params: TParams) => string); + name?: TName | ((params: TParams) => TName); config?: { schema: TConfigSchema | ((params: TParams) => TConfigSchema); }; @@ -714,6 +756,9 @@ export function createExtensionInput< // @public (undocumented) export type CreateExtensionOptions< + TKind extends string | undefined, + TNamespace extends string | undefined, + TName extends string | undefined, UOutput extends AnyExtensionDataRef, TInputs extends { [inputName in string]: ExtensionInput< @@ -729,9 +774,9 @@ export type CreateExtensionOptions< }, UFactoryOutput extends ExtensionDataValue, > = { - kind?: string; - namespace?: string; - name?: string; + kind?: TKind; + namespace?: TNamespace; + name?: TName; attachTo: { id: string; input: string; @@ -794,7 +839,10 @@ export function createNavItemExtension(options: { title?: string | undefined; }, never, - never + never, + string | undefined, + string | undefined, + string | undefined >; // @public (undocumented) @@ -817,7 +865,15 @@ export function createNavLogoExtension(options: { namespace?: string; logoIcon: JSX.Element; logoFull: JSX.Element; -}): ExtensionDefinition; +}): ExtensionDefinition< + unknown, + unknown, + never, + never, + string | undefined, + string | undefined, + string | undefined +>; // @public (undocumented) export namespace createNavLogoExtension { @@ -865,11 +921,22 @@ export function createPageExtension< // @public (undocumented) export function createPlugin< - Routes extends AnyRoutes = {}, - ExternalRoutes extends AnyExternalRoutes = {}, + TId extends string, + TRoutes extends AnyRoutes = {}, + TExternalRoutes extends AnyExternalRoutes = {}, + TExtensions extends readonly ExtensionDefinition[] = [], >( - options: PluginOptions, -): BackstagePlugin; + options: PluginOptions, +): BackstagePlugin< + TRoutes, + TExternalRoutes, + { + [KExtension in TExtensions[number] as ResolveExtensionId< + KExtension, + TId + >]: KExtension; + } +>; // @public export function createRouteRef< @@ -972,7 +1039,15 @@ export function createSubRouteRef< // @public (undocumented) export function createThemeExtension( theme: AppTheme, -): ExtensionDefinition; +): ExtensionDefinition< + unknown, + unknown, + never, + never, + string | undefined, + string | undefined, + string | undefined +>; // @public (undocumented) export namespace createThemeExtension { @@ -988,7 +1063,15 @@ export namespace createThemeExtension { export function createTranslationExtension(options: { name?: string; resource: TranslationResource | TranslationMessages; -}): ExtensionDefinition; +}): ExtensionDefinition< + unknown, + unknown, + never, + never, + string | undefined, + string | undefined, + string | undefined +>; // @public (undocumented) export namespace createTranslationExtension { @@ -1044,6 +1127,9 @@ export interface Extension { // @public (undocumented) export interface ExtensionBlueprint< + TKind extends string, + TNamespace extends string | undefined, + TName extends string | undefined, TParams, UOutput extends AnyExtensionDataRef, TInputs extends { @@ -1068,6 +1154,8 @@ export interface ExtensionBlueprint< // (undocumented) dataRefs: TDataRefs; make< + TNewNamespace extends string | undefined, + TNewName extends string | undefined, TExtensionConfigSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType; }, @@ -1084,8 +1172,8 @@ export interface ExtensionBlueprint< }, >( args: { - namespace?: string; - name?: string; + namespace?: TNewNamespace; + name?: TNewName; attachTo?: { id: string; input: string; @@ -1143,7 +1231,12 @@ export interface ExtensionBlueprint< >; }> > & - TConfigInput + TConfigInput, + AnyExtensionDataRef extends UNewOutput ? UOutput : UNewOutput, + TInputs & TExtraInputs, + TKind, + string | undefined extends TNewNamespace ? TNamespace : TNewNamespace, + string | undefined extends TNewName ? TName : TNewName >; } @@ -1239,6 +1332,9 @@ export interface ExtensionDefinition< } >; } = {}, + TKind extends string | undefined = string | undefined, + TNamespace extends string | undefined = string | undefined, + TName extends string | undefined = string | undefined, > { // (undocumented) $$type: '@backstage/ExtensionDefinition'; @@ -1252,11 +1348,11 @@ export interface ExtensionDefinition< // (undocumented) readonly disabled: boolean; // (undocumented) - readonly kind?: string; + readonly kind?: TKind; // (undocumented) - readonly name?: string; + readonly name?: TName; // (undocumented) - readonly namespace?: string; + readonly namespace?: TNamespace; // (undocumented) override< TExtensionConfigSchema extends { @@ -1325,7 +1421,10 @@ export interface ExtensionDefinition< > & TConfigInput, AnyExtensionDataRef extends UNewOutput ? UOutput : UNewOutput, - TInputs & TExtraInputs + TInputs & TExtraInputs, + TKind, + TNamespace, + TName >; } @@ -1405,6 +1504,9 @@ export { googleAuthApiRef }; // @public (undocumented) export const IconBundleBlueprint: ExtensionBlueprint< + 'icon-bundle', + 'app', + undefined, { icons: { [x: string]: IconComponent; @@ -1536,19 +1638,21 @@ export { PendingOAuthRequest }; // @public (undocumented) export interface PluginOptions< - Routes extends AnyRoutes, - ExternalRoutes extends AnyExternalRoutes, + TId extends string, + TRoutes extends AnyRoutes, + TExternalRoutes extends AnyExternalRoutes, + TExtensions extends readonly ExtensionDefinition[], > { // (undocumented) - extensions?: ExtensionDefinition[]; + extensions?: TExtensions; // (undocumented) - externalRoutes?: ExternalRoutes; + externalRoutes?: TExternalRoutes; // (undocumented) featureFlags?: FeatureFlagConfig[]; // (undocumented) - id: string; + id: TId; // (undocumented) - routes?: Routes; + routes?: TRoutes; } // @public (undocumented) diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.ts b/packages/frontend-plugin-api/src/wiring/createExtension.ts index 600b96ebe0..f2d3d906ab 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.ts @@ -174,6 +174,9 @@ export type VerifyExtensionFactoryOutput< /** @public */ export type CreateExtensionOptions< + TKind extends string | undefined, + TNamespace extends string | undefined, + TName extends string | undefined, UOutput extends AnyExtensionDataRef, TInputs extends { [inputName in string]: ExtensionInput< @@ -184,9 +187,9 @@ export type CreateExtensionOptions< TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType }, UFactoryOutput extends ExtensionDataValue, > = { - kind?: string; - namespace?: string; - name?: string; + kind?: TKind; + namespace?: TNamespace; + name?: TName; attachTo: { id: string; input: string }; disabled?: boolean; inputs?: TInputs; @@ -214,11 +217,14 @@ export interface ExtensionDefinition< { optional: boolean; singleton: boolean } >; } = {}, + TKind extends string | undefined = string | undefined, + TNamespace extends string | undefined = string | undefined, + TName extends string | undefined = string | undefined, > { $$type: '@backstage/ExtensionDefinition'; - readonly kind?: string; - readonly namespace?: string; - readonly name?: string; + readonly kind?: TKind; + readonly namespace?: TNamespace; + readonly name?: TName; readonly attachTo: { id: string; input: string }; readonly disabled: boolean; readonly configSchema?: PortableSchema; @@ -284,45 +290,68 @@ export interface ExtensionDefinition< > & TConfigInput, AnyExtensionDataRef extends UNewOutput ? UOutput : UNewOutput, - TInputs & TExtraInputs + TInputs & TExtraInputs, + TKind, + TNamespace, + TName >; } /** @internal */ -export type InternalExtensionDefinition = - ExtensionDefinition & - ( - | { - readonly version: 'v1'; - readonly inputs: AnyExtensionInputMap; - readonly output: AnyExtensionDataMap; - factory(context: { - node: AppNode; - config: TConfig; - inputs: ResolvedExtensionInputs; - }): ExtensionDataValues; - } - | { - readonly version: 'v2'; - readonly inputs: { +export type InternalExtensionDefinition< + TConfig, + TConfigInput = TConfig, + UOutput extends AnyExtensionDataRef = AnyExtensionDataRef, + TInputs extends { + [inputName in string]: ExtensionInput< + AnyExtensionDataRef, + { optional: boolean; singleton: boolean } + >; + } = {}, + TKind extends string | undefined = string | undefined, + TNamespace extends string | undefined = string | undefined, + TName extends string | undefined = string | undefined, +> = ExtensionDefinition< + TConfig, + TConfigInput, + UOutput, + TInputs, + TKind, + TNamespace, + TName +> & + ( + | { + readonly version: 'v1'; + readonly inputs: AnyExtensionInputMap; + readonly output: AnyExtensionDataMap; + factory(context: { + node: AppNode; + config: TConfig; + inputs: ResolvedExtensionInputs; + }): ExtensionDataValues; + } + | { + readonly version: 'v2'; + readonly inputs: { + [inputName in string]: ExtensionInput< + AnyExtensionDataRef, + { optional: boolean; singleton: boolean } + >; + }; + readonly output: Array; + factory(context: { + node: AppNode; + config: TConfig; + inputs: ResolvedExtensionInputs<{ [inputName in string]: ExtensionInput< AnyExtensionDataRef, { optional: boolean; singleton: boolean } >; - }; - readonly output: Array; - factory(context: { - node: AppNode; - config: TConfig; - inputs: ResolvedExtensionInputs<{ - [inputName in string]: ExtensionInput< - AnyExtensionDataRef, - { optional: boolean; singleton: boolean } - >; - }>; - }): Iterable>; - } - ); + }>; + }): Iterable>; + } + ); /** @internal */ export function toInternalExtensionDefinition( @@ -357,8 +386,14 @@ export function createExtension< }, TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType }, UFactoryOutput extends ExtensionDataValue, + const TKind extends string | undefined = undefined, + const TNamespace extends string | undefined = undefined, + const TName extends string | undefined = undefined, >( options: CreateExtensionOptions< + TKind, + TNamespace, + TName, UOutput, TInputs, TConfigSchema, @@ -374,7 +409,10 @@ export function createExtension< }> >, UOutput, - TInputs + TInputs, + string | undefined extends TKind ? undefined : TKind, + string | undefined extends TNamespace ? undefined : TNamespace, + string | undefined extends TName ? undefined : TName >; /** * @public @@ -394,6 +432,9 @@ export function createExtension< >, ): ExtensionDefinition; export function createExtension< + const TKind extends string | undefined, + const TNamespace extends string | undefined, + const TName extends string | undefined, UOutput extends AnyExtensionDataRef, TInputs extends { [inputName in string]: ExtensionInput< @@ -408,7 +449,15 @@ export function createExtension< UFactoryOutput extends ExtensionDataValue, >( options: - | CreateExtensionOptions + | CreateExtensionOptions< + TKind, + TNamespace, + TName, + UOutput, + TInputs, + TConfigSchema, + UFactoryOutput + > | LegacyCreateExtensionOptions< AnyExtensionDataMap, TLegacyInputs, @@ -431,7 +480,10 @@ export function createExtension< }> >), UOutput, - TInputs + TInputs, + TKind, + TNamespace, + TName > { if ('configSchema' in options && 'config' in options) { throw new Error(`Cannot provide both configSchema and config.schema`); @@ -542,7 +594,10 @@ export function createExtension< > >, AnyExtensionDataRef extends UNewOutput ? UOutput : UNewOutput, - TInputs & TExtraInputs + TInputs & TExtraInputs, + TKind, + TNamespace, + TName > => { if (!Array.isArray(options.output)) { throw new Error( @@ -550,6 +605,9 @@ export function createExtension< ); } const newOptions = options as CreateExtensionOptions< + TKind, + TNamespace, + TName, UOutput, TInputs, TConfigSchema, @@ -612,7 +670,7 @@ export function createExtension< return deduplicatedResult.values() as Iterable; }, - } as CreateExtensionOptions); + } as CreateExtensionOptions); }, } as InternalExtensionDefinition< TConfig & @@ -630,6 +688,11 @@ export function createExtension< z.ZodObject<{ [key in keyof TConfigSchema]: ReturnType; }> - >) + >), + UOutput, + TInputs, + TKind, + TNamespace, + TName >; } diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts index a8bf42c7f8..81137f47e2 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts @@ -36,6 +36,9 @@ import { * @public */ export type CreateExtensionBlueprintOptions< + TKind extends string, + TNamespace extends string | undefined, + TName extends string | undefined, TParams, UOutput extends AnyExtensionDataRef, TInputs extends { @@ -48,13 +51,13 @@ export type CreateExtensionBlueprintOptions< UFactoryOutput extends ExtensionDataValue, TDataRefs extends { [name in string]: AnyExtensionDataRef }, > = { - kind: string; - namespace?: string | ((params: TParams) => string); + kind: TKind; + namespace?: TNamespace | ((params: TParams) => TNamespace); attachTo: { id: string; input: string }; disabled?: boolean; inputs?: TInputs; output: Array; - name?: string | ((params: TParams) => string); + name?: TName | ((params: TParams) => TName); config?: { schema: TConfigSchema | ((params: TParams) => TConfigSchema); }; @@ -76,6 +79,9 @@ export type CreateExtensionBlueprintOptions< * @public */ export interface ExtensionBlueprint< + TKind extends string, + TNamespace extends string | undefined, + TName extends string | undefined, TParams, UOutput extends AnyExtensionDataRef, TInputs extends { @@ -97,6 +103,8 @@ export interface ExtensionBlueprint< * optionally call the original factory with the same params. */ make< + TNewNamespace extends string | undefined, + TNewName extends string | undefined, TExtensionConfigSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType; }, @@ -110,8 +118,8 @@ export interface ExtensionBlueprint< }, >( args: { - namespace?: string; - name?: string; + namespace?: TNewNamespace; + name?: TNewName; attachTo?: { id: string; input: string }; disabled?: boolean; inputs?: TExtraInputs & { @@ -166,7 +174,12 @@ export interface ExtensionBlueprint< >; }> > & - TConfigInput + TConfigInput, + AnyExtensionDataRef extends UNewOutput ? UOutput : UNewOutput, + TInputs & TExtraInputs, + TKind, + string | undefined extends TNewNamespace ? TNamespace : TNewNamespace, + string | undefined extends TNewName ? TName : TNewName >; } @@ -198,6 +211,9 @@ export function createDataContainer( * @internal */ class ExtensionBlueprintImpl< + TKind extends string, + TNamespace extends string | undefined, + TName extends string | undefined, TParams, UOutput extends AnyExtensionDataRef, TInputs extends { @@ -211,6 +227,9 @@ class ExtensionBlueprintImpl< > { constructor( private readonly options: CreateExtensionBlueprintOptions< + TKind, + TNamespace, + TName, TParams, UOutput, TInputs, @@ -236,9 +255,11 @@ class ExtensionBlueprintImpl< { optional: boolean; singleton: boolean } >; }, + TNewNamespace extends string | undefined = undefined, + TNewName extends string | undefined = undefined, >(args: { - namespace?: string; - name?: string; + namespace?: TNewNamespace; + name?: TNewName; attachTo?: { id: string; input: string }; disabled?: boolean; inputs?: TExtraInputs; @@ -360,26 +381,7 @@ class ExtensionBlueprintImpl< } throw new Error('Either params or factory must be provided'); }, - } as CreateExtensionOptions) as ExtensionDefinition< - { - [key in keyof TExtensionConfigSchema]: z.infer< - ReturnType - >; - } & { - [key in keyof TConfigSchema]: z.infer>; - }, - z.input< - z.ZodObject< - { - [key in keyof TExtensionConfigSchema]: ReturnType< - TExtensionConfigSchema[key] - >; - } & { - [key in keyof TConfigSchema]: ReturnType; - } - > - > - >; + } as CreateExtensionOptions); } } @@ -400,9 +402,15 @@ export function createExtensionBlueprint< }, TConfigSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType }, UFactoryOutput extends ExtensionDataValue, + TKind extends string, + TNamespace extends string | undefined = undefined, + TName extends string | undefined = undefined, TDataRefs extends { [name in string]: AnyExtensionDataRef } = never, >( options: CreateExtensionBlueprintOptions< + TKind, + TNamespace, + TName, TParams, UOutput, TInputs, @@ -411,6 +419,9 @@ export function createExtensionBlueprint< TDataRefs >, ): ExtensionBlueprint< + TKind, + TNamespace, + TName, TParams, UOutput, string extends keyof TInputs ? {} : TInputs, @@ -427,6 +438,9 @@ export function createExtensionBlueprint< TDataRefs > { return new ExtensionBlueprintImpl(options) as ExtensionBlueprint< + TKind, + TNamespace, + TName, TParams, UOutput, string extends keyof TInputs ? {} : TInputs, diff --git a/packages/frontend-plugin-api/src/wiring/createPlugin.test.ts b/packages/frontend-plugin-api/src/wiring/createPlugin.test.ts index bb9bdc2107..0242e2961a 100644 --- a/packages/frontend-plugin-api/src/wiring/createPlugin.test.ts +++ b/packages/frontend-plugin-api/src/wiring/createPlugin.test.ts @@ -34,11 +34,9 @@ const nameExtensionDataRef = createExtensionDataRef().with({ const Extension1 = createExtension({ name: '1', attachTo: { id: 'test/output', input: 'names' }, - output: { - name: nameExtensionDataRef, - }, + output: [nameExtensionDataRef], factory() { - return { name: 'extension-1' }; + return [nameExtensionDataRef('extension-1')]; }, }); @@ -150,6 +148,8 @@ describe('createPlugin', () => { }); expect(plugin).toBeDefined(); + expect(plugin.getExtension('test/1')).toBe(Extension1); + await renderWithEffects( createTestAppRoot({ features: [plugin], diff --git a/packages/frontend-plugin-api/src/wiring/createPlugin.ts b/packages/frontend-plugin-api/src/wiring/createPlugin.ts index b671d95d2f..1d2a12ffe2 100644 --- a/packages/frontend-plugin-api/src/wiring/createPlugin.ts +++ b/packages/frontend-plugin-api/src/wiring/createPlugin.ts @@ -17,6 +17,7 @@ import { ExtensionDefinition } from './createExtension'; import { Extension, + ResolveExtensionId, resolveExtensionDefinition, } from './resolveExtensionDefinition'; import { @@ -28,21 +29,23 @@ import { /** @public */ export interface PluginOptions< - Routes extends AnyRoutes, - ExternalRoutes extends AnyExternalRoutes, + TId extends string, + TRoutes extends AnyRoutes, + TExternalRoutes extends AnyExternalRoutes, + TExtensions extends readonly ExtensionDefinition[], > { - id: string; - routes?: Routes; - externalRoutes?: ExternalRoutes; - extensions?: ExtensionDefinition[]; + id: TId; + routes?: TRoutes; + externalRoutes?: TExternalRoutes; + extensions?: TExtensions; featureFlags?: FeatureFlagConfig[]; } /** @public */ export interface InternalBackstagePlugin< - Routes extends AnyRoutes = AnyRoutes, - ExternalRoutes extends AnyExternalRoutes = AnyExternalRoutes, -> extends BackstagePlugin { + TRoutes extends AnyRoutes = AnyRoutes, + TExternalRoutes extends AnyExternalRoutes = AnyExternalRoutes, +> extends BackstagePlugin { readonly version: 'v1'; readonly extensions: Extension[]; readonly featureFlags: FeatureFlagConfig[]; @@ -50,17 +53,36 @@ export interface InternalBackstagePlugin< /** @public */ export function createPlugin< - Routes extends AnyRoutes = {}, - ExternalRoutes extends AnyExternalRoutes = {}, + TId extends string, + TRoutes extends AnyRoutes = {}, + TExternalRoutes extends AnyExternalRoutes = {}, + TExtensions extends readonly ExtensionDefinition[] = [], >( - options: PluginOptions, -): BackstagePlugin { - const extensions = (options.extensions ?? []).map(def => - resolveExtensionDefinition(def, { namespace: options.id }), - ); + options: PluginOptions, +): BackstagePlugin< + TRoutes, + TExternalRoutes, + { + [KExtension in TExtensions[number] as ResolveExtensionId< + KExtension, + TId + >]: KExtension; + } +> { + const extensions = new Array>(); + const extensionDefinitionsById = new Map< + string, + ExtensionDefinition + >(); - const extensionIds = extensions.map(e => e.id); - if (extensionIds.length !== new Set(extensionIds).size) { + for (const def of options.extensions ?? []) { + const ext = resolveExtensionDefinition(def, { namespace: options.id }); + extensions.push(ext); + extensionDefinitionsById.set(ext.id, def); + } + + if (extensions.length !== extensionDefinitionsById.size) { + const extensionIds = extensions.map(e => e.id); const duplicates = Array.from( new Set( extensionIds.filter((id, index) => extensionIds.indexOf(id) !== index), @@ -78,14 +100,17 @@ export function createPlugin< $$type: '@backstage/BackstagePlugin', version: 'v1', id: options.id, - routes: options.routes ?? ({} as Routes), - externalRoutes: options.externalRoutes ?? ({} as ExternalRoutes), + routes: options.routes ?? ({} as TRoutes), + externalRoutes: options.externalRoutes ?? ({} as TExternalRoutes), featureFlags: options.featureFlags ?? [], extensions, + getExtension(id) { + return extensionDefinitionsById.get(id); + }, toString() { return `Plugin{id=${options.id}}`; }, - } as InternalBackstagePlugin; + } as InternalBackstagePlugin; } /** @internal */ diff --git a/packages/frontend-plugin-api/src/wiring/resolveExtensionDefinition.test.ts b/packages/frontend-plugin-api/src/wiring/resolveExtensionDefinition.test.ts index 74d081e95d..5a42e9100e 100644 --- a/packages/frontend-plugin-api/src/wiring/resolveExtensionDefinition.test.ts +++ b/packages/frontend-plugin-api/src/wiring/resolveExtensionDefinition.test.ts @@ -15,7 +15,10 @@ */ import { ExtensionDefinition } from './createExtension'; -import { resolveExtensionDefinition } from './resolveExtensionDefinition'; +import { + ResolveExtensionId, + resolveExtensionDefinition, +} from './resolveExtensionDefinition'; describe('resolveExtensionDefinition', () => { const baseDef = { @@ -98,3 +101,103 @@ describe('old resolveExtensionDefinition', () => { ); }); }); + +describe('ResolveExtensionId', () => { + it('should resolve extension IDs correctly', () => { + type NamedExtension< + TKind extends string | undefined, + TNamespace extends string | undefined, + TName extends string | undefined, + > = ExtensionDefinition; + + const id1: 'k:ns' = {} as ResolveExtensionId< + NamedExtension<'k', 'ns', undefined>, + undefined + >; + const id2: 'k:n' = {} as ResolveExtensionId< + NamedExtension<'k', undefined, 'n'>, + undefined + >; + const id3: 'ns/n' = {} as ResolveExtensionId< + NamedExtension, + undefined + >; + const id4: never = {} as ResolveExtensionId< + NamedExtension<'k', undefined, undefined>, + undefined + >; + const id5: 'ns' = {} as ResolveExtensionId< + NamedExtension, + undefined + >; + const id6: 'n' = {} as ResolveExtensionId< + NamedExtension, + undefined + >; + const id7: 'k:ns/n' = {} as ResolveExtensionId< + NamedExtension<'k', 'ns', 'n'>, + undefined + >; + const id8: 'k:ns2' = {} as ResolveExtensionId< + NamedExtension<'k', 'ns', undefined>, + 'ns2' + >; + const id9: 'k:ns2/n' = {} as ResolveExtensionId< + NamedExtension<'k', undefined, 'n'>, + 'ns2' + >; + const ida: 'ns2/n' = {} as ResolveExtensionId< + NamedExtension, + 'ns2' + >; + const idb: 'k:ns2' = {} as ResolveExtensionId< + NamedExtension<'k', undefined, undefined>, + 'ns2' + >; + const idc: 'ns2' = {} as ResolveExtensionId< + NamedExtension, + 'ns2' + >; + const idd: 'ns2/n' = {} as ResolveExtensionId< + NamedExtension, + 'ns2' + >; + const ide: 'k:ns2/n' = {} as ResolveExtensionId< + NamedExtension<'k', 'ns', 'n'>, + 'ns2' + >; + + const invalid1: never = {} as ResolveExtensionId< + NamedExtension, + undefined + >; + const invalid2: never = {} as ResolveExtensionId< + NamedExtension<'k', string | undefined, 'n'>, + undefined + >; + const invalid3: never = {} as ResolveExtensionId< + NamedExtension<'k', 'ns', string | undefined>, + undefined + >; + + expect([ + id1, + id2, + id3, + id4, + id5, + id6, + id7, + id8, + id9, + ida, + idb, + idc, + idd, + ide, + invalid1, + invalid2, + invalid3, + ]).toBeDefined(); + }); +}); diff --git a/packages/frontend-plugin-api/src/wiring/resolveExtensionDefinition.ts b/packages/frontend-plugin-api/src/wiring/resolveExtensionDefinition.ts index 0c8a7959f7..35bf9c6b05 100644 --- a/packages/frontend-plugin-api/src/wiring/resolveExtensionDefinition.ts +++ b/packages/frontend-plugin-api/src/wiring/resolveExtensionDefinition.ts @@ -94,6 +94,36 @@ export function toInternalExtension( return internal; } +/** @ignore */ +export type ResolveExtensionId< + TExtension extends ExtensionDefinition, + TDefaultNamespace extends string | undefined, +> = TExtension extends ExtensionDefinition< + any, + any, + any, + any, + infer IKind, + infer INamespace, + infer IName +> + ? [string | undefined] extends [IKind | INamespace | IName] + ? never + : ( + ( + undefined extends TDefaultNamespace ? INamespace : TDefaultNamespace + ) extends infer ISelectedNamespace extends string + ? undefined extends IName + ? ISelectedNamespace + : `${ISelectedNamespace}/${IName}` + : IName + ) extends infer INamePart extends string + ? IKind extends string + ? `${IKind}:${INamePart}` + : INamePart + : never + : never; + /** @internal */ export function resolveExtensionDefinition( definition: ExtensionDefinition, diff --git a/packages/frontend-plugin-api/src/wiring/types.ts b/packages/frontend-plugin-api/src/wiring/types.ts index 7e0650e06c..b1afd4e7ea 100644 --- a/packages/frontend-plugin-api/src/wiring/types.ts +++ b/packages/frontend-plugin-api/src/wiring/types.ts @@ -15,6 +15,7 @@ */ import { ExternalRouteRef, RouteRef, SubRouteRef } from '../routing'; +import { ExtensionDefinition } from './createExtension'; /** * Feature flag configuration. @@ -32,15 +33,24 @@ export type AnyRoutes = { [name in string]: RouteRef | SubRouteRef }; /** @public */ export type AnyExternalRoutes = { [name in string]: ExternalRouteRef }; +/** @public */ +export type ExtensionMap< + TExtensionMap extends { [id in string]: ExtensionDefinition }, +> = { + get(id: TId): TExtensionMap[TId]; +}; + /** @public */ export interface BackstagePlugin< - Routes extends AnyRoutes = AnyRoutes, - ExternalRoutes extends AnyExternalRoutes = AnyExternalRoutes, + TRoutes extends AnyRoutes = AnyRoutes, + TExternalRoutes extends AnyExternalRoutes = AnyExternalRoutes, + TExtensionMap extends { [id in string]: ExtensionDefinition } = {}, > { readonly $$type: '@backstage/BackstagePlugin'; readonly id: string; - readonly routes: Routes; - readonly externalRoutes: ExternalRoutes; + readonly routes: TRoutes; + readonly externalRoutes: TExternalRoutes; + getExtension(id: TId): TExtensionMap[TId]; } /** @public */ diff --git a/plugins/api-docs/api-report-alpha.md b/plugins/api-docs/api-report-alpha.md index f17ba0fa3c..6003056cb3 100644 --- a/plugins/api-docs/api-report-alpha.md +++ b/plugins/api-docs/api-report-alpha.md @@ -14,7 +14,8 @@ const _default: BackstagePlugin< }, { registerApi: ExternalRouteRef; - } + }, + {} >; export default _default; diff --git a/plugins/app-visualizer/api-report.md b/plugins/app-visualizer/api-report.md index 764caa7190..fd3749b159 100644 --- a/plugins/app-visualizer/api-report.md +++ b/plugins/app-visualizer/api-report.md @@ -6,7 +6,7 @@ import { BackstagePlugin } from '@backstage/frontend-plugin-api'; // @public (undocumented) -const visualizerPlugin: BackstagePlugin<{}, {}>; +const visualizerPlugin: BackstagePlugin<{}, {}, {}>; export default visualizerPlugin; // (No @packageDocumentation comment for this package) diff --git a/plugins/catalog-graph/api-report-alpha.md b/plugins/catalog-graph/api-report-alpha.md index 88b3a38b76..e651946463 100644 --- a/plugins/catalog-graph/api-report-alpha.md +++ b/plugins/catalog-graph/api-report-alpha.md @@ -18,7 +18,8 @@ const _default: BackstagePlugin< kind: string; namespace: string; }>; - } + }, + {} >; export default _default; diff --git a/plugins/catalog-import/api-report-alpha.md b/plugins/catalog-import/api-report-alpha.md index 63e2cda339..51e3d99fd7 100644 --- a/plugins/catalog-import/api-report-alpha.md +++ b/plugins/catalog-import/api-report-alpha.md @@ -11,6 +11,7 @@ const _default: BackstagePlugin< { importPage: RouteRef; }, + {}, {} >; export default _default; diff --git a/plugins/catalog-react/api-report-alpha.md b/plugins/catalog-react/api-report-alpha.md index 3ff0788b04..edfa183903 100644 --- a/plugins/catalog-react/api-report-alpha.md +++ b/plugins/catalog-react/api-report-alpha.md @@ -115,7 +115,15 @@ export function createEntityCardExtension< config: TConfig; inputs: Expand>; }) => Promise; -}): ExtensionDefinition; +}): ExtensionDefinition< + TConfig, + TConfig, + never, + never, + string | undefined, + string | undefined, + string | undefined +>; // @alpha (undocumented) export function createEntityContentExtension< @@ -150,7 +158,10 @@ export function createEntityContentExtension< path?: string | undefined; }, never, - never + never, + string | undefined, + string | undefined, + string | undefined >; // @alpha diff --git a/plugins/catalog/api-report-alpha.md b/plugins/catalog/api-report-alpha.md index 726ee80573..5019fc25ea 100644 --- a/plugins/catalog/api-report-alpha.md +++ b/plugins/catalog/api-report-alpha.md @@ -108,7 +108,15 @@ export function createCatalogFilterExtension< inputs?: TInputs; configSchema?: PortableSchema; loader: (options: { config: TConfig }) => Promise; -}): ExtensionDefinition; +}): ExtensionDefinition< + TConfig, + TConfig, + never, + never, + string | undefined, + string | undefined, + string | undefined +>; // @alpha (undocumented) const _default: BackstagePlugin< @@ -132,7 +140,8 @@ const _default: BackstagePlugin< templateName: string; }>; unregisterRedirect: ExternalRouteRef; - } + }, + {} >; export default _default; diff --git a/plugins/devtools/api-report-alpha.md b/plugins/devtools/api-report-alpha.md index 59aefd3698..23ede8144c 100644 --- a/plugins/devtools/api-report-alpha.md +++ b/plugins/devtools/api-report-alpha.md @@ -11,6 +11,7 @@ const _default: BackstagePlugin< { root: RouteRef; }, + {}, {} >; export default _default; diff --git a/plugins/home/api-report-alpha.md b/plugins/home/api-report-alpha.md index eb693a8e6f..0f9b980a78 100644 --- a/plugins/home/api-report-alpha.md +++ b/plugins/home/api-report-alpha.md @@ -7,7 +7,7 @@ import { BackstagePlugin } from '@backstage/frontend-plugin-api'; import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api'; // @alpha (undocumented) -const _default: BackstagePlugin<{}, {}>; +const _default: BackstagePlugin<{}, {}, {}>; export default _default; // @alpha (undocumented) diff --git a/plugins/kubernetes/api-report-alpha.md b/plugins/kubernetes/api-report-alpha.md index 8bd6e98baa..befbcf379a 100644 --- a/plugins/kubernetes/api-report-alpha.md +++ b/plugins/kubernetes/api-report-alpha.md @@ -11,6 +11,7 @@ const _default: BackstagePlugin< { kubernetes: RouteRef; }, + {}, {} >; export default _default; diff --git a/plugins/org/api-report-alpha.md b/plugins/org/api-report-alpha.md index e7c4db2c6d..be74cde141 100644 --- a/plugins/org/api-report-alpha.md +++ b/plugins/org/api-report-alpha.md @@ -11,7 +11,8 @@ const _default: BackstagePlugin< {}, { catalogIndex: ExternalRouteRef; - } + }, + {} >; export default _default; diff --git a/plugins/scaffolder/api-report-alpha.md b/plugins/scaffolder/api-report-alpha.md index 4628563be2..de0fc463a9 100644 --- a/plugins/scaffolder/api-report-alpha.md +++ b/plugins/scaffolder/api-report-alpha.md @@ -36,7 +36,8 @@ const _default: BackstagePlugin< kind: string; namespace: string; }>; - } + }, + {} >; export default _default; diff --git a/plugins/search-react/api-report-alpha.md b/plugins/search-react/api-report-alpha.md index 56c0b6eab9..4bcdbb3f78 100644 --- a/plugins/search-react/api-report-alpha.md +++ b/plugins/search-react/api-report-alpha.md @@ -25,7 +25,15 @@ export function createSearchResultListItemExtension< }, >( options: SearchResultItemExtensionOptions, -): ExtensionDefinition; +): ExtensionDefinition< + TConfig, + TConfig, + never, + never, + string | undefined, + string | undefined, + string | undefined +>; // @alpha (undocumented) export namespace createSearchResultListItemExtension { diff --git a/plugins/search/api-report-alpha.md b/plugins/search/api-report-alpha.md index bb670522e4..e6f91d6d19 100644 --- a/plugins/search/api-report-alpha.md +++ b/plugins/search/api-report-alpha.md @@ -13,12 +13,21 @@ const _default: BackstagePlugin< { root: RouteRef; }, + {}, {} >; export default _default; // @alpha (undocumented) -export const searchApi: ExtensionDefinition<{}, {}, never, never>; +export const searchApi: ExtensionDefinition< + {}, + {}, + never, + never, + string | undefined, + string | undefined, + string | undefined +>; // @alpha (undocumented) export const searchNavItem: ExtensionDefinition< @@ -29,7 +38,10 @@ export const searchNavItem: ExtensionDefinition< title?: string | undefined; }, never, - never + never, + string | undefined, + string | undefined, + string | undefined >; // @alpha (undocumented) @@ -43,7 +55,10 @@ export const searchPage: ExtensionDefinition< noTrack: boolean; }, AnyExtensionDataRef, - {} + {}, + string | undefined, + string | undefined, + string | undefined >; // (No @packageDocumentation comment for this package) diff --git a/plugins/techdocs/api-report-alpha.md b/plugins/techdocs/api-report-alpha.md index e3c48ba214..f7c6679139 100644 --- a/plugins/techdocs/api-report-alpha.md +++ b/plugins/techdocs/api-report-alpha.md @@ -18,6 +18,7 @@ const _default: BackstagePlugin< }>; entityContent: RouteRef; }, + {}, {} >; export default _default; @@ -39,7 +40,10 @@ export const techDocsSearchResultListItemExtension: ExtensionDefinition< title?: string | undefined; }, never, - never + never, + string | undefined, + string | undefined, + string | undefined >; // (No @packageDocumentation comment for this package) diff --git a/plugins/user-settings/api-report-alpha.md b/plugins/user-settings/api-report-alpha.md index d0fad90e08..700e06a7ad 100644 --- a/plugins/user-settings/api-report-alpha.md +++ b/plugins/user-settings/api-report-alpha.md @@ -13,6 +13,7 @@ const _default: BackstagePlugin< { root: RouteRef; }, + {}, {} >; export default _default; @@ -26,7 +27,10 @@ export const settingsNavItem: ExtensionDefinition< title?: string | undefined; }, never, - never + never, + string | undefined, + string | undefined, + string | undefined >; // @alpha (undocumented) From 7e8463743aa6853781733bcc01f528b9b31c9d9b Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 9 Aug 2024 10:26:24 +0200 Subject: [PATCH 182/372] frontend-plugin-api: add test to make sure getExtension complains if ID is unknown Signed-off-by: Patrik Oldsberg --- packages/frontend-plugin-api/src/wiring/createPlugin.test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/frontend-plugin-api/src/wiring/createPlugin.test.ts b/packages/frontend-plugin-api/src/wiring/createPlugin.test.ts index 0242e2961a..76cc030be3 100644 --- a/packages/frontend-plugin-api/src/wiring/createPlugin.test.ts +++ b/packages/frontend-plugin-api/src/wiring/createPlugin.test.ts @@ -149,6 +149,8 @@ describe('createPlugin', () => { expect(plugin).toBeDefined(); expect(plugin.getExtension('test/1')).toBe(Extension1); + // @ts-expect-error + expect(plugin.getExtension('nonexistent')).toBeUndefined(); await renderWithEffects( createTestAppRoot({ From d1191ee2d76a95a25bebe3860ca564032a6b3378 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 1 Aug 2024 14:52:04 +0200 Subject: [PATCH 183/372] feat: added a new PageBlueprint Signed-off-by: blam Signed-off-by: blam --- .../src/extensions/PageBlueprint.test.tsx | 154 ++++++++++++++++++ .../src/extensions/PageBlueprint.tsx | 71 ++++++++ 2 files changed, 225 insertions(+) create mode 100644 packages/frontend-plugin-api/src/extensions/PageBlueprint.test.tsx create mode 100644 packages/frontend-plugin-api/src/extensions/PageBlueprint.tsx diff --git a/packages/frontend-plugin-api/src/extensions/PageBlueprint.test.tsx b/packages/frontend-plugin-api/src/extensions/PageBlueprint.test.tsx new file mode 100644 index 0000000000..abe2d96a85 --- /dev/null +++ b/packages/frontend-plugin-api/src/extensions/PageBlueprint.test.tsx @@ -0,0 +1,154 @@ +/* + * Copyright 2024 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 { createRouteRef } from '../routing'; +import { PageBlueprint } from './PageBlueprint'; +import { createExtensionTester } from '@backstage/frontend-test-utils'; +import { + coreExtensionData, + createExtensionBlueprint, + createExtensionInput, +} from '../wiring'; +import { waitFor } from '@testing-library/react'; + +describe('PageBlueprint', () => { + const mockRouteRef = createRouteRef(); + + it('should return an extension when calling make with sensible defaults', () => { + const myPage = PageBlueprint.make({ + name: 'test-page', + params: { + loader: () => Promise.resolve(
    Test
    ), + defaultPath: '/test', + routeRef: mockRouteRef, + }, + }); + + expect(myPage).toMatchInlineSnapshot(` + { + "$$type": "@backstage/ExtensionDefinition", + "attachTo": { + "id": "app/routes", + "input": "routes", + }, + "configSchema": { + "parse": [Function], + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "additionalProperties": false, + "properties": { + "path": { + "type": "string", + }, + }, + "type": "object", + }, + }, + "disabled": false, + "factory": [Function], + "inputs": {}, + "kind": "page", + "name": "test-page", + "namespace": undefined, + "output": [ + [Function], + [Function], + { + "$$type": "@backstage/ExtensionDataRef", + "config": { + "optional": true, + }, + "id": "core.routing.ref", + "optional": [Function], + "toString": [Function], + }, + ], + "toString": [Function], + "version": "v2", + } + `); + }); + + it('should output a routeRef with the input routeRef', async () => { + const myPage = PageBlueprint.make({ + name: 'test-page', + params: { + loader: () => Promise.resolve(
    Test
    ), + defaultPath: '/test', + routeRef: mockRouteRef, + }, + }); + + const tester = createExtensionTester(myPage); + + // TODO(blam): test for the routePath output doesn't work. + // expect(tester.data(coreExtensionData.routePath)).toBe('/test'); + + expect(tester.data(coreExtensionData.routeRef)).toBe(mockRouteRef); + + const { getByTestId } = tester.render(); + + await waitFor(() => expect(getByTestId('test')).toBeInTheDocument()); + }); + + it('should allow defining additional inputs to the extension', async () => { + const myPage = PageBlueprint.make({ + name: 'test-page', + params: { + loader: async ({ inputs }) => { + return ( +
    + {/* todo(blam): need to fix the typescript here, as inputs is not the right type */} + {inputs.cards.map(c => c.get(coreExtensionData.reactElement))} +
    + ); + }, + defaultPath: '/test', + routeRef: mockRouteRef, + }, + inputs: { + cards: createExtensionInput([coreExtensionData.reactElement], { + optional: false, + singleton: false, + }), + }, + }); + + const CardBlueprint = createExtensionBlueprint({ + kind: 'card', + attachTo: { id: 'page:test-page', input: 'cards' }, + output: [coreExtensionData.reactElement], + factory() { + return [ + coreExtensionData.reactElement( +
    I'm a lovely card
    , + ), + ]; + }, + }); + + const tester = createExtensionTester(myPage).add( + CardBlueprint.make({ name: 'card', params: {} }), + ); + + const { getByTestId, getByText } = tester.render(); + + await waitFor(() => expect(getByTestId('card')).toBeInTheDocument()); + await waitFor(() => + expect(getByText("I'm a lovely card")).toBeInTheDocument(), + ); + }); +}); diff --git a/packages/frontend-plugin-api/src/extensions/PageBlueprint.tsx b/packages/frontend-plugin-api/src/extensions/PageBlueprint.tsx new file mode 100644 index 0000000000..7ae26cf387 --- /dev/null +++ b/packages/frontend-plugin-api/src/extensions/PageBlueprint.tsx @@ -0,0 +1,71 @@ +/* + * Copyright 2024 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, { lazy } from 'react'; +import { RouteRef } from '../routing'; +import { coreExtensionData, createExtensionBlueprint } from '../wiring'; +import { ExtensionBoundary } from '../components'; + +export const PageBlueprint = createExtensionBlueprint({ + kind: 'page', + attachTo: { id: 'app/routes', input: 'routes' }, + output: [ + coreExtensionData.routePath, + coreExtensionData.reactElement, + coreExtensionData.routeRef.optional(), + ], + config: { + schema: { + path: z => z.string().optional(), + }, + }, + factory( + { + defaultPath, + loader, + routeRef, + }: { + defaultPath?: string; + loader: (opts: { + config: typeof config; + inputs: typeof inputs; + }) => Promise; + routeRef?: RouteRef; + }, + { config, inputs, node }, + ) { + const ExtensionComponent = lazy(() => + loader({ config, inputs }).then(element => ({ default: () => element })), + ); + + // TODO(blam): this is a little awkward for optional returns. + // I wonder if we should be using generators or yield instead + // for a better API here. + const outputs = [ + coreExtensionData.routePath(config.path ?? defaultPath!), + coreExtensionData.reactElement( + + + , + ), + ]; + + if (routeRef) { + return [...outputs, coreExtensionData.routeRef(routeRef)]; + } + + return outputs; + }, +}); From 8897c29ecc13ec2aa70dec12baeb6b944f33aad8 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 1 Aug 2024 15:46:39 +0200 Subject: [PATCH 184/372] chore: migrate ThemeCreator Signed-off-by: blam --- .../src/extensions/ThemeBlueprint.test.ts | 64 +++++++++++++++++++ .../src/extensions/ThemeBlueprint.ts | 32 ++++++++++ 2 files changed, 96 insertions(+) create mode 100644 packages/frontend-plugin-api/src/extensions/ThemeBlueprint.test.ts create mode 100644 packages/frontend-plugin-api/src/extensions/ThemeBlueprint.ts diff --git a/packages/frontend-plugin-api/src/extensions/ThemeBlueprint.test.ts b/packages/frontend-plugin-api/src/extensions/ThemeBlueprint.test.ts new file mode 100644 index 0000000000..d3d05a5e68 --- /dev/null +++ b/packages/frontend-plugin-api/src/extensions/ThemeBlueprint.test.ts @@ -0,0 +1,64 @@ +/* + * Copyright 2024 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 { AppTheme } from '@backstage/core-plugin-api'; +import { ThemeBlueprint } from './ThemeBlueprint'; +import { createExtensionTester } from '@backstage/frontend-test-utils'; + +describe('ThemeBlueprint', () => { + const theme = { + id: 'light', + colors: { primary: 'blue' }, + variant: 'dark', + title: 'lols', + Provider: (_: { children: React.ReactNode }) => null, + } as AppTheme; + + it('should create an extension with sensible defaults', () => { + expect( + // todo(blam): we can't inject theme.id as the name here like the old extension creator. + // Wonder if theres a better solution. + ThemeBlueprint.make({ name: 'blob', params: { theme } }), + ).toMatchInlineSnapshot(` + { + "$$type": "@backstage/ExtensionDefinition", + "attachTo": { + "id": "app", + "input": "themes", + }, + "configSchema": undefined, + "disabled": false, + "factory": [Function], + "inputs": {}, + "kind": "theme", + "name": "blob", + "namespace": "app", + "output": [ + [Function], + ], + "toString": [Function], + "version": "v2", + } + `); + }); + + it('should return the theme as an themeDataRef', async () => { + const extension = ThemeBlueprint.make({ name: 'blob', params: { theme } }); + + expect( + createExtensionTester(extension).data(ThemeBlueprint.dataRefs.theme), + ).toEqual(theme); + }); +}); diff --git a/packages/frontend-plugin-api/src/extensions/ThemeBlueprint.ts b/packages/frontend-plugin-api/src/extensions/ThemeBlueprint.ts new file mode 100644 index 0000000000..4ddb5a298a --- /dev/null +++ b/packages/frontend-plugin-api/src/extensions/ThemeBlueprint.ts @@ -0,0 +1,32 @@ +/* + * Copyright 2024 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 { AppTheme } from '@backstage/core-plugin-api'; +import { createExtensionBlueprint } from '../wiring'; +import { createThemeExtension } from './createThemeExtension'; + +export const ThemeBlueprint = createExtensionBlueprint({ + kind: 'theme', + namespace: 'app', + attachTo: { id: 'app', input: 'themes' }, + output: [createThemeExtension.themeDataRef], + dataRefs: { + theme: createThemeExtension.themeDataRef, + }, + factory: ({ theme }: { theme: AppTheme }) => [ + createThemeExtension.themeDataRef(theme), + ], +}); From da75ca4e4702b057b8c3bd23bd6e6e514b8a8e77 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 1 Aug 2024 16:21:57 +0200 Subject: [PATCH 185/372] chore: migration translation extension creator Signed-off-by: blam --- .../extensions/TranslationBlueprint.test.ts | 81 +++++++++++++++++++ .../src/extensions/TranslationBlueprint.ts | 33 ++++++++ 2 files changed, 114 insertions(+) create mode 100644 packages/frontend-plugin-api/src/extensions/TranslationBlueprint.test.ts create mode 100644 packages/frontend-plugin-api/src/extensions/TranslationBlueprint.ts diff --git a/packages/frontend-plugin-api/src/extensions/TranslationBlueprint.test.ts b/packages/frontend-plugin-api/src/extensions/TranslationBlueprint.test.ts new file mode 100644 index 0000000000..fe7aeba59d --- /dev/null +++ b/packages/frontend-plugin-api/src/extensions/TranslationBlueprint.test.ts @@ -0,0 +1,81 @@ +/* + * Copyright 2024 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 { createExtensionTester } from '@backstage/frontend-test-utils'; +import { + createTranslationMessages, + createTranslationRef, +} from '../translation'; +import { TranslationBlueprint } from './TranslationBlueprint'; + +describe('TranslationBlueprint', () => { + const translationRef = createTranslationRef({ + id: 'test', + messages: { + test: 'test', + }, + }); + + const messages = createTranslationMessages({ + ref: translationRef, + messages: { + test: 'test2', + }, + }); + + it('should return an extension instance with sane defaults', () => { + expect( + TranslationBlueprint.make({ + params: { + resource: messages, + }, + }), + ).toMatchInlineSnapshot(` + { + "$$type": "@backstage/ExtensionDefinition", + "attachTo": { + "id": "app", + "input": "translations", + }, + "configSchema": undefined, + "disabled": false, + "factory": [Function], + "inputs": {}, + "kind": "translation", + "name": undefined, + "namespace": undefined, + "output": [ + [Function], + ], + "toString": [Function], + "version": "v2", + } + `); + }); + + it('should output a translation data ref', () => { + const extension = TranslationBlueprint.make({ + params: { + resource: messages, + }, + }); + + expect( + createExtensionTester(extension).data( + TranslationBlueprint.dataRefs.translation, + ), + ).toBe(messages); + }); +}); diff --git a/packages/frontend-plugin-api/src/extensions/TranslationBlueprint.ts b/packages/frontend-plugin-api/src/extensions/TranslationBlueprint.ts new file mode 100644 index 0000000000..23cb5da6a6 --- /dev/null +++ b/packages/frontend-plugin-api/src/extensions/TranslationBlueprint.ts @@ -0,0 +1,33 @@ +/* + * Copyright 2024 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 { createExtensionBlueprint } from '../wiring'; +import { createTranslationExtension } from './createTranslationExtension'; +import { TranslationMessages, TranslationResource } from '../translation'; + +export const TranslationBlueprint = createExtensionBlueprint({ + kind: 'translation', + attachTo: { id: 'app', input: 'translations' }, + output: [createTranslationExtension.translationDataRef], + dataRefs: { + translation: createTranslationExtension.translationDataRef, + }, + factory: ({ + resource, + }: { + resource: TranslationResource | TranslationMessages; + }) => [createTranslationExtension.translationDataRef(resource)], +}); From 48b4304c46a62052ad2245b52def395ca0256aee Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 1 Aug 2024 16:28:33 +0200 Subject: [PATCH 186/372] chore: fix Signed-off-by: blam Signed-off-by: blam --- .../src/extensions/TranslationBlueprint.test.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/frontend-plugin-api/src/extensions/TranslationBlueprint.test.ts b/packages/frontend-plugin-api/src/extensions/TranslationBlueprint.test.ts index fe7aeba59d..658c0c9709 100644 --- a/packages/frontend-plugin-api/src/extensions/TranslationBlueprint.test.ts +++ b/packages/frontend-plugin-api/src/extensions/TranslationBlueprint.test.ts @@ -38,6 +38,10 @@ describe('TranslationBlueprint', () => { it('should return an extension instance with sane defaults', () => { expect( TranslationBlueprint.make({ + // todo(blam): we can't set the namespace dynamically based of the ResourceType. + // work out if we should wrap this up or another solution. + namespace: messages.id, + name: 'test', params: { resource: messages, }, @@ -54,8 +58,8 @@ describe('TranslationBlueprint', () => { "factory": [Function], "inputs": {}, "kind": "translation", - "name": undefined, - "namespace": undefined, + "name": "test", + "namespace": "test", "output": [ [Function], ], From 1f4029b9d877885db10ba63a57afee368bb906a5 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 7 Aug 2024 08:50:47 +0200 Subject: [PATCH 187/372] chore: refactor a little bit and use some new features to remove todos Signed-off-by: blam --- .../src/extensions/PageBlueprint.test.tsx | 4 ++-- .../src/extensions/PageBlueprint.tsx | 23 +++++++------------ .../src/extensions/ThemeBlueprint.test.ts | 10 +++----- .../src/extensions/ThemeBlueprint.ts | 1 + .../extensions/TranslationBlueprint.test.ts | 12 ++++------ .../src/extensions/TranslationBlueprint.ts | 1 + 6 files changed, 20 insertions(+), 31 deletions(-) diff --git a/packages/frontend-plugin-api/src/extensions/PageBlueprint.test.tsx b/packages/frontend-plugin-api/src/extensions/PageBlueprint.test.tsx index abe2d96a85..e020167f43 100644 --- a/packages/frontend-plugin-api/src/extensions/PageBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/extensions/PageBlueprint.test.tsx @@ -94,7 +94,7 @@ describe('PageBlueprint', () => { const tester = createExtensionTester(myPage); - // TODO(blam): test for the routePath output doesn't work. + // TODO(blam): test for the routePath output doesn't work, due to the the way the test harness works // expect(tester.data(coreExtensionData.routePath)).toBe('/test'); expect(tester.data(coreExtensionData.routeRef)).toBe(mockRouteRef); @@ -111,7 +111,6 @@ describe('PageBlueprint', () => { loader: async ({ inputs }) => { return (
    - {/* todo(blam): need to fix the typescript here, as inputs is not the right type */} {inputs.cards.map(c => c.get(coreExtensionData.reactElement))}
    ); @@ -119,6 +118,7 @@ describe('PageBlueprint', () => { defaultPath: '/test', routeRef: mockRouteRef, }, + /* todo(blam): need to fix the typescript here, as inputs is not the right type, wont let me merge without specifying parent opts */ inputs: { cards: createExtensionInput([coreExtensionData.reactElement], { optional: false, diff --git a/packages/frontend-plugin-api/src/extensions/PageBlueprint.tsx b/packages/frontend-plugin-api/src/extensions/PageBlueprint.tsx index 7ae26cf387..4ee26321b7 100644 --- a/packages/frontend-plugin-api/src/extensions/PageBlueprint.tsx +++ b/packages/frontend-plugin-api/src/extensions/PageBlueprint.tsx @@ -31,7 +31,7 @@ export const PageBlueprint = createExtensionBlueprint({ path: z => z.string().optional(), }, }, - factory( + *factory( { defaultPath, loader, @@ -50,22 +50,15 @@ export const PageBlueprint = createExtensionBlueprint({ loader({ config, inputs }).then(element => ({ default: () => element })), ); - // TODO(blam): this is a little awkward for optional returns. - // I wonder if we should be using generators or yield instead - // for a better API here. - const outputs = [ - coreExtensionData.routePath(config.path ?? defaultPath!), - coreExtensionData.reactElement( - - - , - ), - ]; + yield coreExtensionData.routePath(config.path ?? defaultPath!); + yield coreExtensionData.reactElement( + + + , + ); if (routeRef) { - return [...outputs, coreExtensionData.routeRef(routeRef)]; + yield coreExtensionData.routeRef(routeRef); } - - return outputs; }, }); diff --git a/packages/frontend-plugin-api/src/extensions/ThemeBlueprint.test.ts b/packages/frontend-plugin-api/src/extensions/ThemeBlueprint.test.ts index d3d05a5e68..5bc3a8f7c3 100644 --- a/packages/frontend-plugin-api/src/extensions/ThemeBlueprint.test.ts +++ b/packages/frontend-plugin-api/src/extensions/ThemeBlueprint.test.ts @@ -27,11 +27,7 @@ describe('ThemeBlueprint', () => { } as AppTheme; it('should create an extension with sensible defaults', () => { - expect( - // todo(blam): we can't inject theme.id as the name here like the old extension creator. - // Wonder if theres a better solution. - ThemeBlueprint.make({ name: 'blob', params: { theme } }), - ).toMatchInlineSnapshot(` + expect(ThemeBlueprint.make({ params: { theme } })).toMatchInlineSnapshot(` { "$$type": "@backstage/ExtensionDefinition", "attachTo": { @@ -43,7 +39,7 @@ describe('ThemeBlueprint', () => { "factory": [Function], "inputs": {}, "kind": "theme", - "name": "blob", + "name": "light", "namespace": "app", "output": [ [Function], @@ -55,7 +51,7 @@ describe('ThemeBlueprint', () => { }); it('should return the theme as an themeDataRef', async () => { - const extension = ThemeBlueprint.make({ name: 'blob', params: { theme } }); + const extension = ThemeBlueprint.make({ params: { theme } }); expect( createExtensionTester(extension).data(ThemeBlueprint.dataRefs.theme), diff --git a/packages/frontend-plugin-api/src/extensions/ThemeBlueprint.ts b/packages/frontend-plugin-api/src/extensions/ThemeBlueprint.ts index 4ddb5a298a..500946713b 100644 --- a/packages/frontend-plugin-api/src/extensions/ThemeBlueprint.ts +++ b/packages/frontend-plugin-api/src/extensions/ThemeBlueprint.ts @@ -21,6 +21,7 @@ import { createThemeExtension } from './createThemeExtension'; export const ThemeBlueprint = createExtensionBlueprint({ kind: 'theme', namespace: 'app', + name: ({ theme }) => theme.id, attachTo: { id: 'app', input: 'themes' }, output: [createThemeExtension.themeDataRef], dataRefs: { diff --git a/packages/frontend-plugin-api/src/extensions/TranslationBlueprint.test.ts b/packages/frontend-plugin-api/src/extensions/TranslationBlueprint.test.ts index 658c0c9709..a059189044 100644 --- a/packages/frontend-plugin-api/src/extensions/TranslationBlueprint.test.ts +++ b/packages/frontend-plugin-api/src/extensions/TranslationBlueprint.test.ts @@ -22,7 +22,7 @@ import { TranslationBlueprint } from './TranslationBlueprint'; describe('TranslationBlueprint', () => { const translationRef = createTranslationRef({ - id: 'test', + id: 'translationRefId', messages: { test: 'test', }, @@ -38,10 +38,7 @@ describe('TranslationBlueprint', () => { it('should return an extension instance with sane defaults', () => { expect( TranslationBlueprint.make({ - // todo(blam): we can't set the namespace dynamically based of the ResourceType. - // work out if we should wrap this up or another solution. - namespace: messages.id, - name: 'test', + name: 'blob', params: { resource: messages, }, @@ -58,8 +55,8 @@ describe('TranslationBlueprint', () => { "factory": [Function], "inputs": {}, "kind": "translation", - "name": "test", - "namespace": "test", + "name": "blob", + "namespace": "translationRefId", "output": [ [Function], ], @@ -71,6 +68,7 @@ describe('TranslationBlueprint', () => { it('should output a translation data ref', () => { const extension = TranslationBlueprint.make({ + name: 'blob', params: { resource: messages, }, diff --git a/packages/frontend-plugin-api/src/extensions/TranslationBlueprint.ts b/packages/frontend-plugin-api/src/extensions/TranslationBlueprint.ts index 23cb5da6a6..581f4d176a 100644 --- a/packages/frontend-plugin-api/src/extensions/TranslationBlueprint.ts +++ b/packages/frontend-plugin-api/src/extensions/TranslationBlueprint.ts @@ -20,6 +20,7 @@ import { TranslationMessages, TranslationResource } from '../translation'; export const TranslationBlueprint = createExtensionBlueprint({ kind: 'translation', + namespace: ({ resource }) => resource.id, attachTo: { id: 'app', input: 'translations' }, output: [createTranslationExtension.translationDataRef], dataRefs: { From 593fdd4e007c072c37a7d3ba94734dad0ad115b0 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 7 Aug 2024 09:14:05 +0200 Subject: [PATCH 188/372] chore: added SignInPageBlueprint Signed-off-by: blam --- .../extensions/SignInPageBlueprint.test.tsx | 67 +++++++++++++++++++ .../src/extensions/SignInPageBlueprint.tsx | 50 ++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.test.tsx create mode 100644 packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.tsx diff --git a/packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.test.tsx b/packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.test.tsx new file mode 100644 index 0000000000..7bbeb4e5d7 --- /dev/null +++ b/packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.test.tsx @@ -0,0 +1,67 @@ +/* + * Copyright 2024 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 { SignInPageBlueprint } from './SignInPageBlueprint'; +import { createExtensionTester } from '@backstage/frontend-test-utils'; +import { waitFor } from '@testing-library/react'; + +describe('SignInPageBlueprint', () => { + it('should create an extension with sensible defaults', () => { + expect( + SignInPageBlueprint.make({ + params: { loader: async () => () =>
    }, + }), + ).toMatchInlineSnapshot(` + { + "$$type": "@backstage/ExtensionDefinition", + "attachTo": { + "id": "app/root", + "input": "signInPage", + }, + "configSchema": undefined, + "disabled": false, + "factory": [Function], + "inputs": {}, + "kind": "sign-in-page", + "name": undefined, + "namespace": undefined, + "output": [ + [Function], + ], + "toString": [Function], + "version": "v2", + } + `); + }); + + it('should return the component as the componentRef', async () => { + const MockSignInPage = () =>
    MockSignInPage
    ; + + const extension = SignInPageBlueprint.make({ + params: { loader: async () => () => }, + }); + + const tester = createExtensionTester(extension); + expect(tester.data(SignInPageBlueprint.dataRefs.component)).toBeDefined(); + + const { getByText } = tester.render(); + + // todo(blam): need a better way to test this, currently fails. + await waitFor(() => { + expect(getByText('MockSignInPage')).toBeInTheDocument(); + }); + }); +}); diff --git a/packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.tsx b/packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.tsx new file mode 100644 index 0000000000..01ba174efe --- /dev/null +++ b/packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.tsx @@ -0,0 +1,50 @@ +/* + * Copyright 2024 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, { ComponentType, lazy } from 'react'; +import { createExtensionBlueprint } from '../wiring'; +import { createSignInPageExtension } from './createSignInPageExtension'; +import { SignInPageProps } from '@backstage/core-plugin-api'; +import { ExtensionBoundary } from '../components'; + +export const SignInPageBlueprint = createExtensionBlueprint({ + kind: 'sign-in-page', + attachTo: { id: 'app/root', input: 'signInPage' }, + output: [createSignInPageExtension.componentDataRef], + dataRefs: { + component: createSignInPageExtension.componentDataRef, + }, + *factory( + { + loader, + }: { + loader: (opts: { + config: typeof config; + inputs: typeof inputs; + }) => Promise>; + }, + { config, inputs, node }, + ) { + const ExtensionComponent = lazy(() => + loader({ config, inputs }).then(component => ({ default: component })), + ); + + yield createSignInPageExtension.componentDataRef(props => ( + + + + )); + }, +}); From ac136771b2ca4331b6f54f32cea3657d9b52f827 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 7 Aug 2024 09:34:12 +0200 Subject: [PATCH 189/372] feat: added RouterBlueprint Signed-off-by: blam --- .../src/extensions/RouterBlueprint.test.tsx | 167 ++++++++++++++++++ .../src/extensions/RouterBlueprint.tsx | 45 +++++ 2 files changed, 212 insertions(+) create mode 100644 packages/frontend-plugin-api/src/extensions/RouterBlueprint.test.tsx create mode 100644 packages/frontend-plugin-api/src/extensions/RouterBlueprint.tsx diff --git a/packages/frontend-plugin-api/src/extensions/RouterBlueprint.test.tsx b/packages/frontend-plugin-api/src/extensions/RouterBlueprint.test.tsx new file mode 100644 index 0000000000..3abc967fd8 --- /dev/null +++ b/packages/frontend-plugin-api/src/extensions/RouterBlueprint.test.tsx @@ -0,0 +1,167 @@ +/* + * Copyright 2024 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 { RouterBlueprint } from './RouterBlueprint'; +import { MemoryRouter } from 'react-router-dom'; +import { render, waitFor } from '@testing-library/react'; +import { createSpecializedApp } from '@backstage/frontend-app-api'; +import { + coreExtensionData, + createExtension, + createExtensionInput, + createExtensionOverrides, +} from '../wiring'; +import { MockConfigApi } from '@backstage/test-utils'; +import { PageBlueprint } from './PageBlueprint'; + +describe('RouterBlueprint', () => { + it('should return an extension when calling make with sensible defaults', () => { + const extension = RouterBlueprint.make({ + params: { + Component: props =>
    {props.children}
    , + }, + }); + + expect(extension).toMatchInlineSnapshot(` + { + "$$type": "@backstage/ExtensionDefinition", + "attachTo": { + "id": "app/root", + "input": "router", + }, + "configSchema": undefined, + "disabled": false, + "factory": [Function], + "inputs": {}, + "kind": "app-router-component", + "name": undefined, + "namespace": undefined, + "output": [ + [Function], + ], + "toString": [Function], + "version": "v2", + } + `); + }); + + it('should work with simple options', async () => { + const extension = RouterBlueprint.make({ + namespace: 'test', + params: { + Component: ({ children }) => ( + +
    {children}
    +
    + ), + }, + }); + + const app = createSpecializedApp({ + features: [ + createExtensionOverrides({ + extensions: [ + extension, + PageBlueprint.make({ + namespace: 'test', + params: { + defaultPath: '/', + loader: async () =>
    , + }, + }), + ], + }), + ], + }); + + const { getByTestId } = render(app.createRoot()); + + await waitFor(() => { + expect(getByTestId('test-contents')).toBeInTheDocument(); + expect(getByTestId('test-router')).toBeInTheDocument(); + }); + }); + + it('should work with complex options and props', async () => { + const extension = RouterBlueprint.make({ + namespace: 'test', + name: 'test', + config: { + schema: { + name: z => z.string(), + }, + }, + inputs: { + children: createExtensionInput([coreExtensionData.reactElement]), + }, + params: { + Component: ({ inputs, children, config }) => ( + +
    + {children} +
    +
    + ), + }, + }); + + const app = createSpecializedApp({ + features: [ + createExtensionOverrides({ + extensions: [ + extension, + createExtension({ + namespace: 'test', + attachTo: { + id: 'app-router-component:test/test', + input: 'children', + }, + output: [coreExtensionData.reactElement], + *factory() { + yield coreExtensionData.reactElement(
    ); + }, + }), + PageBlueprint.make({ + namespace: 'test', + params: { + defaultPath: '/', + loader: async () =>
    , + }, + }), + ], + }), + ], + config: new MockConfigApi({ + app: { + extensions: [ + { + 'app-router-component:test/test': { config: { name: 'Robin' } }, + }, + ], + }, + }), + }); + + const { getByTestId } = render(app.createRoot()); + + await waitFor(() => { + expect(getByTestId('test-contents')).toBeInTheDocument(); + expect(getByTestId('test-router-Robin-1')).toBeInTheDocument(); + }); + }); +}); diff --git a/packages/frontend-plugin-api/src/extensions/RouterBlueprint.tsx b/packages/frontend-plugin-api/src/extensions/RouterBlueprint.tsx new file mode 100644 index 0000000000..9e9cddbdd1 --- /dev/null +++ b/packages/frontend-plugin-api/src/extensions/RouterBlueprint.tsx @@ -0,0 +1,45 @@ +/* + * Copyright 2024 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, { ComponentType, PropsWithChildren } from 'react'; +import { createExtensionBlueprint } from '../wiring'; +import { createRouterExtension } from './createRouterExtension'; + +export const RouterBlueprint = createExtensionBlueprint({ + kind: 'app-router-component', + attachTo: { id: 'app/root', input: 'router' }, + output: [createRouterExtension.componentDataRef], + *factory( + { + Component, + }: { + Component: ComponentType< + PropsWithChildren<{ + inputs: typeof inputs; + config: typeof config; + }> + >; + }, + { config, inputs }, + ) { + const Wrapper = (props: PropsWithChildren<{}>) => ( + + {props.children} + + ); + + yield createRouterExtension.componentDataRef(Wrapper); + }, +}); From b7506f214ea83a5e833261de20e30ec8e92bbe7b Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 7 Aug 2024 09:53:02 +0200 Subject: [PATCH 190/372] feat: added NavLogoBlueprint Signed-off-by: blam --- .../src/extensions/NavLogoBlueprint.test.tsx | 71 +++++++++++++++++++ .../src/extensions/NavLogoBlueprint.ts | 39 ++++++++++ .../src/extensions/RouterBlueprint.tsx | 3 + .../extensions/SignInPageBlueprint.test.tsx | 6 +- 4 files changed, 116 insertions(+), 3 deletions(-) create mode 100644 packages/frontend-plugin-api/src/extensions/NavLogoBlueprint.test.tsx create mode 100644 packages/frontend-plugin-api/src/extensions/NavLogoBlueprint.ts diff --git a/packages/frontend-plugin-api/src/extensions/NavLogoBlueprint.test.tsx b/packages/frontend-plugin-api/src/extensions/NavLogoBlueprint.test.tsx new file mode 100644 index 0000000000..fa01862785 --- /dev/null +++ b/packages/frontend-plugin-api/src/extensions/NavLogoBlueprint.test.tsx @@ -0,0 +1,71 @@ +/* + * Copyright 2024 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 { NavLogoBlueprint } from './NavLogoBlueprint'; +import { createExtensionTester } from '@backstage/frontend-test-utils'; + +describe('NavLogoBlueprint', () => { + it('should create an extension with sensible defaults', () => { + const extension = NavLogoBlueprint.make({ + params: { + logoFull:
    Logo Full
    , + logoIcon:
    Logo Icon
    , + }, + }); + + expect(extension).toMatchInlineSnapshot(` + { + "$$type": "@backstage/ExtensionDefinition", + "attachTo": { + "id": "app/nav", + "input": "logos", + }, + "configSchema": undefined, + "disabled": false, + "factory": [Function], + "inputs": {}, + "kind": "nav-logo", + "name": undefined, + "namespace": undefined, + "output": [ + [Function], + ], + "toString": [Function], + "version": "v2", + } + `); + }); + + it('should return a valid component ref', () => { + const logoFull =
    Logo Full
    ; + const logoIcon =
    Logo Icon
    ; + + const extension = NavLogoBlueprint.make({ + name: 'test', + params: { + logoFull, + logoIcon, + }, + }); + + const tester = createExtensionTester(extension); + + expect(tester.data(NavLogoBlueprint.dataRefs.logoElements)).toEqual({ + logoFull, + logoIcon, + }); + }); +}); diff --git a/packages/frontend-plugin-api/src/extensions/NavLogoBlueprint.ts b/packages/frontend-plugin-api/src/extensions/NavLogoBlueprint.ts new file mode 100644 index 0000000000..d119287f29 --- /dev/null +++ b/packages/frontend-plugin-api/src/extensions/NavLogoBlueprint.ts @@ -0,0 +1,39 @@ +/* + * Copyright 2024 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 { createExtensionBlueprint } from '../wiring'; +import { createNavLogoExtension } from './createNavLogoExtension'; + +export const NavLogoBlueprint = createExtensionBlueprint({ + kind: 'nav-logo', + attachTo: { id: 'app/nav', input: 'logos' }, + output: [createNavLogoExtension.logoElementsDataRef], + dataRefs: { + logoElements: createNavLogoExtension.logoElementsDataRef, + }, + *factory({ + logoIcon, + logoFull, + }: { + logoIcon: JSX.Element; + logoFull: JSX.Element; + }) { + yield createNavLogoExtension.logoElementsDataRef({ + logoIcon, + logoFull, + }); + }, +}); diff --git a/packages/frontend-plugin-api/src/extensions/RouterBlueprint.tsx b/packages/frontend-plugin-api/src/extensions/RouterBlueprint.tsx index 9e9cddbdd1..bf910eb944 100644 --- a/packages/frontend-plugin-api/src/extensions/RouterBlueprint.tsx +++ b/packages/frontend-plugin-api/src/extensions/RouterBlueprint.tsx @@ -21,6 +21,9 @@ export const RouterBlueprint = createExtensionBlueprint({ kind: 'app-router-component', attachTo: { id: 'app/root', input: 'router' }, output: [createRouterExtension.componentDataRef], + dataRefs: { + component: createRouterExtension.componentDataRef, + }, *factory( { Component, diff --git a/packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.test.tsx b/packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.test.tsx index 7bbeb4e5d7..11fe1420f1 100644 --- a/packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.test.tsx @@ -48,7 +48,7 @@ describe('SignInPageBlueprint', () => { }); it('should return the component as the componentRef', async () => { - const MockSignInPage = () =>
    MockSignInPage
    ; + const MockSignInPage = () =>
    ; const extension = SignInPageBlueprint.make({ params: { loader: async () => () => }, @@ -57,11 +57,11 @@ describe('SignInPageBlueprint', () => { const tester = createExtensionTester(extension); expect(tester.data(SignInPageBlueprint.dataRefs.component)).toBeDefined(); - const { getByText } = tester.render(); + const { getByTestId } = tester.render(); // todo(blam): need a better way to test this, currently fails. await waitFor(() => { - expect(getByText('MockSignInPage')).toBeInTheDocument(); + expect(getByTestId('mock-sign-in')).toBeInTheDocument(); }); }); }); From b284ecb010272dd725ad043e36cf39e1136e3793 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 7 Aug 2024 11:33:26 +0200 Subject: [PATCH 191/372] chore: reworking how to override the page component Signed-off-by: blam --- .../src/extensions/NavItemBlueprint.ts | 51 +++++++++++++++++++ .../src/extensions/PageBlueprint.test.tsx | 23 ++++----- 2 files changed, 62 insertions(+), 12 deletions(-) create mode 100644 packages/frontend-plugin-api/src/extensions/NavItemBlueprint.ts diff --git a/packages/frontend-plugin-api/src/extensions/NavItemBlueprint.ts b/packages/frontend-plugin-api/src/extensions/NavItemBlueprint.ts new file mode 100644 index 0000000000..568431c0f5 --- /dev/null +++ b/packages/frontend-plugin-api/src/extensions/NavItemBlueprint.ts @@ -0,0 +1,51 @@ +/* + * Copyright 2024 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 { IconComponent } from '@backstage/core-plugin-api'; +import { RouteRef } from '../routing'; +import { createExtensionBlueprint } from '../wiring'; +import { createNavItemExtension } from './createNavItemExtension'; + +export const NavItemBlueprint = createExtensionBlueprint({ + kind: 'nav-item', + attachTo: { id: 'app/nav', input: 'items' }, + output: [createNavItemExtension.targetDataRef], + dataRefs: { + target: createNavItemExtension.targetDataRef, + }, + factory: ( + { + icon, + routeRef, + }: { + title: string; + icon: IconComponent; + routeRef: RouteRef; + }, + { config }, + ) => [ + createNavItemExtension.targetDataRef({ + title: config.title, + icon, + routeRef, + }), + ], + config: { + schema: ({ title }) => ({ + title: z => z.string().default(title), + }), + }, +}); diff --git a/packages/frontend-plugin-api/src/extensions/PageBlueprint.test.tsx b/packages/frontend-plugin-api/src/extensions/PageBlueprint.test.tsx index e020167f43..5e1d6b7601 100644 --- a/packages/frontend-plugin-api/src/extensions/PageBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/extensions/PageBlueprint.test.tsx @@ -107,24 +107,23 @@ describe('PageBlueprint', () => { it('should allow defining additional inputs to the extension', async () => { const myPage = PageBlueprint.make({ name: 'test-page', - params: { - loader: async ({ inputs }) => { - return ( -
    - {inputs.cards.map(c => c.get(coreExtensionData.reactElement))} -
    - ); - }, - defaultPath: '/test', - routeRef: mockRouteRef, - }, - /* todo(blam): need to fix the typescript here, as inputs is not the right type, wont let me merge without specifying parent opts */ inputs: { cards: createExtensionInput([coreExtensionData.reactElement], { optional: false, singleton: false, }), }, + factory(originalFactory, { inputs }) { + return originalFactory({ + loader: async () => ( +
    + {inputs.cards.map(c => c.get(coreExtensionData.reactElement))} +
    + ), + defaultPath: '/test', + routeRef: mockRouteRef, + }); + }, }); const CardBlueprint = createExtensionBlueprint({ From 60d1832ce3138cd0e2769f8feaeb33940596ae6d Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 7 Aug 2024 13:23:11 +0200 Subject: [PATCH 192/372] chore: added NavItemBlueprint Signed-off-by: blam --- .../src/extensions/NavItemBlueprint.test.tsx | 106 ++++++++++++++++++ .../extensions/SignInPageBlueprint.test.tsx | 2 +- 2 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 packages/frontend-plugin-api/src/extensions/NavItemBlueprint.test.tsx diff --git a/packages/frontend-plugin-api/src/extensions/NavItemBlueprint.test.tsx b/packages/frontend-plugin-api/src/extensions/NavItemBlueprint.test.tsx new file mode 100644 index 0000000000..ba7643eee7 --- /dev/null +++ b/packages/frontend-plugin-api/src/extensions/NavItemBlueprint.test.tsx @@ -0,0 +1,106 @@ +/* + * Copyright 2024 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 { createExtensionTester } from '@backstage/frontend-test-utils'; +import { createRouteRef } from '../routing'; +import { NavItemBlueprint } from './NavItemBlueprint'; + +describe('NavItemBlueprint', () => { + const mockRouteRef = createRouteRef(); + const MockIcon = () => null; + + it('should return an extension with sensible defaults', () => { + const extension = NavItemBlueprint.make({ + params: { + icon: MockIcon, + routeRef: mockRouteRef, + title: 'TEST', + }, + }); + + expect(extension).toMatchInlineSnapshot(` + { + "$$type": "@backstage/ExtensionDefinition", + "attachTo": { + "id": "app/nav", + "input": "items", + }, + "configSchema": { + "parse": [Function], + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "additionalProperties": false, + "properties": { + "title": { + "default": "TEST", + "type": "string", + }, + }, + "type": "object", + }, + }, + "disabled": false, + "factory": [Function], + "inputs": {}, + "kind": "nav-item", + "name": undefined, + "namespace": undefined, + "output": [ + [Function], + ], + "toString": [Function], + "version": "v2", + } + `); + }); + + it('should return the correct extension data', () => { + const extension = NavItemBlueprint.make({ + params: { + icon: MockIcon, + routeRef: mockRouteRef, + title: 'TEST', + }, + }); + + const tester = createExtensionTester(extension); + + expect(tester.data(NavItemBlueprint.dataRefs.target)).toEqual({ + title: 'TEST', + icon: MockIcon, + routeRef: mockRouteRef, + }); + }); + + it('should allow overriding of the title using config', () => { + const extension = NavItemBlueprint.make({ + params: { + icon: MockIcon, + routeRef: mockRouteRef, + title: 'TEST', + }, + }); + + const tester = createExtensionTester(extension, { + config: { title: 'OVERRIDDEN' }, + }); + + expect(tester.data(NavItemBlueprint.dataRefs.target)).toEqual({ + title: 'OVERRIDDEN', + icon: MockIcon, + routeRef: mockRouteRef, + }); + }); +}); diff --git a/packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.test.tsx b/packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.test.tsx index 11fe1420f1..5ffdd3175b 100644 --- a/packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.test.tsx @@ -48,7 +48,7 @@ describe('SignInPageBlueprint', () => { }); it('should return the component as the componentRef', async () => { - const MockSignInPage = () =>
    ; + const MockSignInPage = () =>
    ; const extension = SignInPageBlueprint.make({ params: { loader: async () => () => }, From 8d5049b5a5515ec4415fac6d7c4847fe6107f1b2 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 7 Aug 2024 13:44:04 +0200 Subject: [PATCH 193/372] chore: wip Signed-off-by: blam --- .../src/extensions/ComponentBlueprint.tsx | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 packages/frontend-plugin-api/src/extensions/ComponentBlueprint.tsx diff --git a/packages/frontend-plugin-api/src/extensions/ComponentBlueprint.tsx b/packages/frontend-plugin-api/src/extensions/ComponentBlueprint.tsx new file mode 100644 index 0000000000..614196fc09 --- /dev/null +++ b/packages/frontend-plugin-api/src/extensions/ComponentBlueprint.tsx @@ -0,0 +1,69 @@ +/* + * Copyright 2024 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 { ComponentRef } from '../components'; +import { createExtensionBlueprint } from '../wiring'; +import { createComponentExtension } from './createComponentExtension'; +import { lazy, ComponentType } from 'react'; + +// this is hard to do with blueprints... no TProps for the elements +export const ComponentBlueprint = createExtensionBlueprint({ + kind: 'component', + attachTo: { id: 'app', input: 'components' }, + output: [createComponentExtension.componentDataRef], + dataRefs: { + component: createComponentExtension.componentDataRef, + }, + factory( + { + ref, + loader, + }: { + ref: ComponentRef; + loader: + | { + lazy: (values: any) => Promise>; + } + | { + sync: (values: any) => ComponentType; + }; + }, + { config, inputs }, + ) { + if ('sync' in loader) { + return [ + createComponentExtension.componentDataRef({ + ref, + impl: loader.sync({ config, inputs }), + }), + ]; + } + + const lazyLoader = loader.lazy; + const ExtensionComponent = lazy(() => + lazyLoader({ config, inputs }).then(Component => ({ + default: Component, + })), + ); + + return [ + createComponentExtension.componentDataRef({ + ref, + impl: ExtensionComponent, + }), + ]; + }, +}); From 7a4eb9bcb5e213d1b5b018caf751ad14ef025387 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 8 Aug 2024 11:30:24 +0200 Subject: [PATCH 194/372] chore: more work for migrating Signed-off-by: blam --- .../src/extensions/ApiBlueprint.test.ts | 66 +++++++++++++++++++ .../src/extensions/ApiBlueprint.ts | 50 ++++++++++++++ .../src/extensions/PageBlueprint.tsx | 9 +-- 3 files changed, 119 insertions(+), 6 deletions(-) create mode 100644 packages/frontend-plugin-api/src/extensions/ApiBlueprint.test.ts create mode 100644 packages/frontend-plugin-api/src/extensions/ApiBlueprint.ts diff --git a/packages/frontend-plugin-api/src/extensions/ApiBlueprint.test.ts b/packages/frontend-plugin-api/src/extensions/ApiBlueprint.test.ts new file mode 100644 index 0000000000..99369c6acd --- /dev/null +++ b/packages/frontend-plugin-api/src/extensions/ApiBlueprint.test.ts @@ -0,0 +1,66 @@ +/* + * Copyright 2024 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 { createExtensionInput } from '../wiring'; +import { ApiBlueprint } from './ApiBlueprint'; +import { createApiFactory, createApiRef } from '@backstage/core-plugin-api'; + +describe('ApiBlueprint', () => { + it('should create an extension with sensible defaults', () => { + const api = createApiRef<{ foo: string }>({ id: 'test' }); + const factory = createApiFactory({ + api, + deps: {}, + factory: () => ({ foo: 'bar' }), + }); + + const extension = ApiBlueprint.make({ + params: { + factory, + }, + }); + + expect(extension).toMatchInlineSnapshot(); + }); + + it('should create an extension with custom factory', () => { + const api = createApiRef<{ foo: string }>({ id: 'test' }); + const factory = jest.fn(() => ({ foo: 'bar' })); + + const extension = ApiBlueprint.make({ + config: { + schema: { + test: z => z.string().default('test'), + }, + }, + inputs: { + test: createExtensionInput([ApiBlueprint.dataRefs.factory]), + }, + factory(originalFactory, { config: _config, inputs: _inputs }) { + return originalFactory({ + api, + factory: () => + createApiFactory({ + api, + deps: {}, + factory, + }), + }); + }, + }); + + expect(extension).toMatchInlineSnapshot(); + }); +}); diff --git a/packages/frontend-plugin-api/src/extensions/ApiBlueprint.ts b/packages/frontend-plugin-api/src/extensions/ApiBlueprint.ts new file mode 100644 index 0000000000..dd2130f2cb --- /dev/null +++ b/packages/frontend-plugin-api/src/extensions/ApiBlueprint.ts @@ -0,0 +1,50 @@ +/* + * Copyright 2024 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 { createExtensionBlueprint } from '../wiring'; +import { createApiExtension } from './createApiExtension'; +import { AnyApiFactory, AnyApiRef } from '@backstage/core-plugin-api'; + +export const ApiBlueprint = createExtensionBlueprint({ + kind: 'api', + attachTo: { id: 'app', input: 'apis' }, + output: [createApiExtension.factoryDataRef], + dataRefs: { + factory: createApiExtension.factoryDataRef, + }, + *factory( + params: // remove this form. + | { + api: AnyApiRef; + factory: (params: unknown) => AnyApiFactory; + } + | { + factory: AnyApiFactory; + }, + { config, inputs }, + ) { + yield createApiExtension.factoryDataRef( + typeof params.factory === 'function' + ? params.factory({ config, inputs }) + : params.factory, + ); + }, + namespace: params => { + const apiRef = + 'api' in params ? params.api : (params.factory as { api: AnyApiRef }).api; + + return apiRef.id; + }, +}); diff --git a/packages/frontend-plugin-api/src/extensions/PageBlueprint.tsx b/packages/frontend-plugin-api/src/extensions/PageBlueprint.tsx index 4ee26321b7..506301ffdf 100644 --- a/packages/frontend-plugin-api/src/extensions/PageBlueprint.tsx +++ b/packages/frontend-plugin-api/src/extensions/PageBlueprint.tsx @@ -38,16 +38,13 @@ export const PageBlueprint = createExtensionBlueprint({ routeRef, }: { defaultPath?: string; - loader: (opts: { - config: typeof config; - inputs: typeof inputs; - }) => Promise; + loader: () => Promise; routeRef?: RouteRef; }, - { config, inputs, node }, + { config, node }, ) { const ExtensionComponent = lazy(() => - loader({ config, inputs }).then(element => ({ default: () => element })), + loader().then(element => ({ default: () => element })), ); yield coreExtensionData.routePath(config.path ?? defaultPath!); From d3cfdc6e4dcda5393d61c7db87a388068db50086 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 8 Aug 2024 13:15:56 +0200 Subject: [PATCH 195/372] chore: updating API blueprint Signed-off-by: blam Signed-off-by: blam --- .../src/extensions/ApiBlueprint.test.ts | 81 ++++++++++++++++--- .../src/extensions/ApiBlueprint.ts | 27 +------ .../AppRootElementBlueprint.test.tsx | 48 +++++++++++ .../src/extensions/AppRootElementBlueprint.ts | 27 +++++++ .../src/extensions/ComponentBlueprint.tsx | 69 ---------------- .../src/extensions/RouterBlueprint.test.tsx | 22 ++--- .../src/extensions/RouterBlueprint.tsx | 24 +----- .../src/extensions/SignInPageBlueprint.tsx | 9 +-- .../src/wiring/createExtensionBlueprint.ts | 14 ++-- 9 files changed, 176 insertions(+), 145 deletions(-) create mode 100644 packages/frontend-plugin-api/src/extensions/AppRootElementBlueprint.test.tsx create mode 100644 packages/frontend-plugin-api/src/extensions/AppRootElementBlueprint.ts delete mode 100644 packages/frontend-plugin-api/src/extensions/ComponentBlueprint.tsx diff --git a/packages/frontend-plugin-api/src/extensions/ApiBlueprint.test.ts b/packages/frontend-plugin-api/src/extensions/ApiBlueprint.test.ts index 99369c6acd..c85c021c08 100644 --- a/packages/frontend-plugin-api/src/extensions/ApiBlueprint.test.ts +++ b/packages/frontend-plugin-api/src/extensions/ApiBlueprint.test.ts @@ -32,7 +32,27 @@ describe('ApiBlueprint', () => { }, }); - expect(extension).toMatchInlineSnapshot(); + expect(extension).toMatchInlineSnapshot(` + { + "$$type": "@backstage/ExtensionDefinition", + "attachTo": { + "id": "app", + "input": "apis", + }, + "configSchema": undefined, + "disabled": false, + "factory": [Function], + "inputs": {}, + "kind": "api", + "name": undefined, + "namespace": "test", + "output": [ + [Function], + ], + "toString": [Function], + "version": "v2", + } + `); }); it('should create an extension with custom factory', () => { @@ -48,19 +68,62 @@ describe('ApiBlueprint', () => { inputs: { test: createExtensionInput([ApiBlueprint.dataRefs.factory]), }, + namespace: api.id, factory(originalFactory, { config: _config, inputs: _inputs }) { return originalFactory({ - api, - factory: () => - createApiFactory({ - api, - deps: {}, - factory, - }), + factory: createApiFactory({ + api, + deps: {}, + factory, + }), }); }, }); - expect(extension).toMatchInlineSnapshot(); + expect(extension).toMatchInlineSnapshot(` + { + "$$type": "@backstage/ExtensionDefinition", + "attachTo": { + "id": "app", + "input": "apis", + }, + "configSchema": { + "parse": [Function], + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "additionalProperties": false, + "properties": { + "test": { + "default": "test", + "type": "string", + }, + }, + "type": "object", + }, + }, + "disabled": false, + "factory": [Function], + "inputs": { + "test": { + "$$type": "@backstage/ExtensionInput", + "config": { + "optional": false, + "singleton": false, + }, + "extensionData": [ + [Function], + ], + }, + }, + "kind": "api", + "name": undefined, + "namespace": "test", + "output": [ + [Function], + ], + "toString": [Function], + "version": "v2", + } + `); }); }); diff --git a/packages/frontend-plugin-api/src/extensions/ApiBlueprint.ts b/packages/frontend-plugin-api/src/extensions/ApiBlueprint.ts index dd2130f2cb..16a20b5130 100644 --- a/packages/frontend-plugin-api/src/extensions/ApiBlueprint.ts +++ b/packages/frontend-plugin-api/src/extensions/ApiBlueprint.ts @@ -15,7 +15,7 @@ */ import { createExtensionBlueprint } from '../wiring'; import { createApiExtension } from './createApiExtension'; -import { AnyApiFactory, AnyApiRef } from '@backstage/core-plugin-api'; +import { AnyApiFactory } from '@backstage/core-plugin-api'; export const ApiBlueprint = createExtensionBlueprint({ kind: 'api', @@ -24,27 +24,8 @@ export const ApiBlueprint = createExtensionBlueprint({ dataRefs: { factory: createApiExtension.factoryDataRef, }, - *factory( - params: // remove this form. - | { - api: AnyApiRef; - factory: (params: unknown) => AnyApiFactory; - } - | { - factory: AnyApiFactory; - }, - { config, inputs }, - ) { - yield createApiExtension.factoryDataRef( - typeof params.factory === 'function' - ? params.factory({ config, inputs }) - : params.factory, - ); - }, - namespace: params => { - const apiRef = - 'api' in params ? params.api : (params.factory as { api: AnyApiRef }).api; - - return apiRef.id; + *factory(params: { factory: AnyApiFactory }) { + yield createApiExtension.factoryDataRef(params.factory); }, + namespace: ({ factory }) => factory.api.id, }); diff --git a/packages/frontend-plugin-api/src/extensions/AppRootElementBlueprint.test.tsx b/packages/frontend-plugin-api/src/extensions/AppRootElementBlueprint.test.tsx new file mode 100644 index 0000000000..d9c7d296cc --- /dev/null +++ b/packages/frontend-plugin-api/src/extensions/AppRootElementBlueprint.test.tsx @@ -0,0 +1,48 @@ +/* + * Copyright 2024 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 { AppRootElementBlueprint } from './AppRootElementBlueprint'; + +describe('AppRootElementBlueprint', () => { + it('should create an extension with sensible defaults', () => { + const extension = AppRootElementBlueprint.make({ + params: { + element:
    , + }, + }); + expect(extension).toMatchInlineSnapshot(` + { + "$$type": "@backstage/ExtensionDefinition", + "attachTo": { + "id": "app/root", + "input": "elements", + }, + "configSchema": undefined, + "disabled": false, + "factory": [Function], + "inputs": {}, + "kind": "app-root-element", + "name": undefined, + "namespace": undefined, + "output": [ + [Function], + ], + "toString": [Function], + "version": "v2", + } + `); + }); +}); diff --git a/packages/frontend-plugin-api/src/extensions/AppRootElementBlueprint.ts b/packages/frontend-plugin-api/src/extensions/AppRootElementBlueprint.ts new file mode 100644 index 0000000000..1048d531ab --- /dev/null +++ b/packages/frontend-plugin-api/src/extensions/AppRootElementBlueprint.ts @@ -0,0 +1,27 @@ +/* + * Copyright 2024 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 { coreExtensionData, createExtensionBlueprint } from '../wiring'; + +export const AppRootElementBlueprint = createExtensionBlueprint({ + kind: 'app-root-element', + attachTo: { id: 'app/root', input: 'elements' }, + output: [coreExtensionData.reactElement], + *factory(params: { element: JSX.Element | (() => JSX.Element) }) { + yield coreExtensionData.reactElement( + typeof params.element === 'function' ? params.element() : params.element, + ); + }, +}); diff --git a/packages/frontend-plugin-api/src/extensions/ComponentBlueprint.tsx b/packages/frontend-plugin-api/src/extensions/ComponentBlueprint.tsx deleted file mode 100644 index 614196fc09..0000000000 --- a/packages/frontend-plugin-api/src/extensions/ComponentBlueprint.tsx +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2024 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 { ComponentRef } from '../components'; -import { createExtensionBlueprint } from '../wiring'; -import { createComponentExtension } from './createComponentExtension'; -import { lazy, ComponentType } from 'react'; - -// this is hard to do with blueprints... no TProps for the elements -export const ComponentBlueprint = createExtensionBlueprint({ - kind: 'component', - attachTo: { id: 'app', input: 'components' }, - output: [createComponentExtension.componentDataRef], - dataRefs: { - component: createComponentExtension.componentDataRef, - }, - factory( - { - ref, - loader, - }: { - ref: ComponentRef; - loader: - | { - lazy: (values: any) => Promise>; - } - | { - sync: (values: any) => ComponentType; - }; - }, - { config, inputs }, - ) { - if ('sync' in loader) { - return [ - createComponentExtension.componentDataRef({ - ref, - impl: loader.sync({ config, inputs }), - }), - ]; - } - - const lazyLoader = loader.lazy; - const ExtensionComponent = lazy(() => - lazyLoader({ config, inputs }).then(Component => ({ - default: Component, - })), - ); - - return [ - createComponentExtension.componentDataRef({ - ref, - impl: ExtensionComponent, - }), - ]; - }, -}); diff --git a/packages/frontend-plugin-api/src/extensions/RouterBlueprint.test.tsx b/packages/frontend-plugin-api/src/extensions/RouterBlueprint.test.tsx index 3abc967fd8..ba4123138f 100644 --- a/packages/frontend-plugin-api/src/extensions/RouterBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/extensions/RouterBlueprint.test.tsx @@ -107,16 +107,18 @@ describe('RouterBlueprint', () => { inputs: { children: createExtensionInput([coreExtensionData.reactElement]), }, - params: { - Component: ({ inputs, children, config }) => ( - -
    - {children} -
    -
    - ), + *factory(originalFactory, { inputs, config }) { + yield* originalFactory({ + Component: ({ children }) => ( + +
    + {children} +
    +
    + ), + }); }, }); diff --git a/packages/frontend-plugin-api/src/extensions/RouterBlueprint.tsx b/packages/frontend-plugin-api/src/extensions/RouterBlueprint.tsx index bf910eb944..e584a5654c 100644 --- a/packages/frontend-plugin-api/src/extensions/RouterBlueprint.tsx +++ b/packages/frontend-plugin-api/src/extensions/RouterBlueprint.tsx @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import React, { ComponentType, PropsWithChildren } from 'react'; +import { ComponentType, PropsWithChildren } from 'react'; import { createExtensionBlueprint } from '../wiring'; import { createRouterExtension } from './createRouterExtension'; @@ -24,25 +24,7 @@ export const RouterBlueprint = createExtensionBlueprint({ dataRefs: { component: createRouterExtension.componentDataRef, }, - *factory( - { - Component, - }: { - Component: ComponentType< - PropsWithChildren<{ - inputs: typeof inputs; - config: typeof config; - }> - >; - }, - { config, inputs }, - ) { - const Wrapper = (props: PropsWithChildren<{}>) => ( - - {props.children} - - ); - - yield createRouterExtension.componentDataRef(Wrapper); + *factory({ Component }: { Component: ComponentType> }) { + yield createRouterExtension.componentDataRef(Component); }, }); diff --git a/packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.tsx b/packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.tsx index 01ba174efe..fc779f58ab 100644 --- a/packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.tsx +++ b/packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.tsx @@ -30,15 +30,12 @@ export const SignInPageBlueprint = createExtensionBlueprint({ { loader, }: { - loader: (opts: { - config: typeof config; - inputs: typeof inputs; - }) => Promise>; + loader: () => Promise>; }, - { config, inputs, node }, + { node }, ) { const ExtensionComponent = lazy(() => - loader({ config, inputs }).then(component => ({ default: component })), + loader().then(component => ({ default: component })), ); yield createSignInPageExtension.componentDataRef(props => ( diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts index 81137f47e2..f749f7d412 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts @@ -312,9 +312,9 @@ class ExtensionBlueprintImpl< > > > { - const optionsSchema = - typeof this.options.config?.schema === 'function' - ? this.options.config?.schema(args.params!) + const optionsSchema = // can remove this args.params check with the split apart of .make + typeof this.options.config?.schema === 'function' && args.params + ? this.options.config?.schema(args.params) : this.options.config?.schema; const schema = { @@ -323,13 +323,13 @@ class ExtensionBlueprintImpl< } as TConfigSchema & TExtensionConfigSchema; const namespace = - typeof this.options.namespace === 'function' - ? this.options.namespace(args.params!) + typeof this.options.namespace === 'function' && args.params + ? this.options.namespace(args.params) : this.options.namespace; const name = - typeof this.options.name === 'function' - ? this.options.name(args.params!) + typeof this.options.name === 'function' && args.params + ? this.options.name(args.params) : this.options.name; return createExtension({ From ab70dc33d7d313729c69f849c0bdae6c2d20abfe Mon Sep 17 00:00:00 2001 From: blam Date: Fri, 9 Aug 2024 08:11:00 +0200 Subject: [PATCH 196/372] chore: implementing the last of the blueprints Signed-off-by: blam --- .../AppRootWrapperBlueprint.test.tsx | 127 ++++++++++++++++++ .../extensions/AppRootWrapperBlueprint.tsx | 36 +++++ 2 files changed, 163 insertions(+) create mode 100644 packages/frontend-plugin-api/src/extensions/AppRootWrapperBlueprint.test.tsx create mode 100644 packages/frontend-plugin-api/src/extensions/AppRootWrapperBlueprint.tsx diff --git a/packages/frontend-plugin-api/src/extensions/AppRootWrapperBlueprint.test.tsx b/packages/frontend-plugin-api/src/extensions/AppRootWrapperBlueprint.test.tsx new file mode 100644 index 0000000000..b67fc3664d --- /dev/null +++ b/packages/frontend-plugin-api/src/extensions/AppRootWrapperBlueprint.test.tsx @@ -0,0 +1,127 @@ +/* + * Copyright 2024 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 { AppRootWrapperBlueprint } from './AppRootWrapperBlueprint'; +import { createExtensionTester } from '@backstage/frontend-test-utils'; +import { PageBlueprint } from './PageBlueprint'; +import { waitFor } from '@testing-library/react'; +import { + coreExtensionData, + createExtension, + createExtensionInput, +} from '../wiring'; +import { each } from 'lodash'; + +describe('AppRootWrapperBlueprint', () => { + it('should return an extension with sensible defaults', () => { + const extension = AppRootWrapperBlueprint.make({ + params: { + Component: () =>
    Hello
    , + }, + }); + + expect(extension).toMatchInlineSnapshot(` + { + "$$type": "@backstage/ExtensionDefinition", + "attachTo": { + "id": "app/root", + "input": "elements", + }, + "configSchema": undefined, + "disabled": false, + "factory": [Function], + "inputs": {}, + "kind": "app-root-wrapper", + "name": undefined, + "namespace": undefined, + "output": [ + [Function], + ], + "toString": [Function], + "version": "v2", + } + `); + }); + + it('should render the simple component wrapper', async () => { + const extension = AppRootWrapperBlueprint.make({ + params: { + Component: () =>
    Hello
    , + }, + }); + + const { getByText } = createExtensionTester( + PageBlueprint.make({ + params: { + defaultPath: '/', + loader: async () =>
    , + }, + }), + ) + .add(extension) + .render(); + + await waitFor(() => expect(getByText('Hello')).toBeInTheDocument()); + }); + + it('should render the complex component wrapper', async () => { + const extension = AppRootWrapperBlueprint.make({ + namespace: 'ns', + name: 'test', + config: { + schema: { + name: z => z.string(), + }, + }, + inputs: { + children: createExtensionInput([coreExtensionData.reactElement]), + }, + *factory(originalFactory, { inputs, config }) { + yield* originalFactory({ + Component: ({ children }) => ( +
    + {children} +
    + ), + }); + }, + }); + + const { getByText, getByTestId } = createExtensionTester( + PageBlueprint.make({ + params: { + defaultPath: '/', + loader: async () =>
    Hi
    , + }, + }), + ) + .add(extension, { config: { name: 'Robin' } }) + .add( + createExtension({ + attachTo: { id: 'app-root-wrapper:ns/test', input: 'children' }, + output: [coreExtensionData.reactElement], + factory: () => [coreExtensionData.reactElement(
    Its Me
    )], + }), + ) + .render(); + + await waitFor(() => { + expect(getByText('Its Me')).toBeInTheDocument(); + expect(getByText('Hi')).toBeInTheDocument(); + expect(getByTestId('Robin-1')).toBeInTheDocument(); + }); + }); +}); diff --git a/packages/frontend-plugin-api/src/extensions/AppRootWrapperBlueprint.tsx b/packages/frontend-plugin-api/src/extensions/AppRootWrapperBlueprint.tsx new file mode 100644 index 0000000000..5bcbaa49bd --- /dev/null +++ b/packages/frontend-plugin-api/src/extensions/AppRootWrapperBlueprint.tsx @@ -0,0 +1,36 @@ +/* + * Copyright 2024 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 { ComponentType, PropsWithChildren } from 'react'; +import { createExtensionBlueprint } from '../wiring'; +import { createAppRootWrapperExtension } from './createAppRootWrapperExtension'; + +export const AppRootWrapperBlueprint = createExtensionBlueprint({ + kind: 'app-root-wrapper', + attachTo: { id: 'app/root', input: 'elements' }, + output: [createAppRootWrapperExtension.componentDataRef], + dataRefs: { + component: createAppRootWrapperExtension.componentDataRef, + }, + *factory(params: { Component: ComponentType> }) { + // todo(blam): not sure that this wrapping is even necessary anymore. + const Component = (props: PropsWithChildren<{}>) => { + return {props.children}; + }; + + yield createAppRootWrapperExtension.componentDataRef(Component); + }, +}); From 4bc224cc832e8bc9958b585d45b96b0e2bd4d376 Mon Sep 17 00:00:00 2001 From: blam Date: Fri, 9 Aug 2024 11:21:16 +0200 Subject: [PATCH 197/372] chore: updating tests and making them work properly Signed-off-by: blam --- .../src/extensions/ApiBlueprint.test.ts | 2 ++ .../AppRootElementBlueprint.test.tsx | 1 + .../AppRootWrapperBlueprint.test.tsx | 4 ++-- .../extensions/AppRootWrapperBlueprint.tsx | 3 ++- .../src/extensions/NavItemBlueprint.test.tsx | 1 + .../src/extensions/NavLogoBlueprint.test.tsx | 1 + .../src/extensions/PageBlueprint.test.tsx | 1 + .../src/extensions/RouterBlueprint.test.tsx | 1 + .../extensions/SignInPageBlueprint.test.tsx | 23 +++++++++++++++---- .../src/extensions/ThemeBlueprint.test.ts | 1 + .../extensions/TranslationBlueprint.test.ts | 1 + 11 files changed, 32 insertions(+), 7 deletions(-) diff --git a/packages/frontend-plugin-api/src/extensions/ApiBlueprint.test.ts b/packages/frontend-plugin-api/src/extensions/ApiBlueprint.test.ts index c85c021c08..f070956e96 100644 --- a/packages/frontend-plugin-api/src/extensions/ApiBlueprint.test.ts +++ b/packages/frontend-plugin-api/src/extensions/ApiBlueprint.test.ts @@ -49,6 +49,7 @@ describe('ApiBlueprint', () => { "output": [ [Function], ], + "override": [Function], "toString": [Function], "version": "v2", } @@ -121,6 +122,7 @@ describe('ApiBlueprint', () => { "output": [ [Function], ], + "override": [Function], "toString": [Function], "version": "v2", } diff --git a/packages/frontend-plugin-api/src/extensions/AppRootElementBlueprint.test.tsx b/packages/frontend-plugin-api/src/extensions/AppRootElementBlueprint.test.tsx index d9c7d296cc..3fb8d7b37a 100644 --- a/packages/frontend-plugin-api/src/extensions/AppRootElementBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/extensions/AppRootElementBlueprint.test.tsx @@ -40,6 +40,7 @@ describe('AppRootElementBlueprint', () => { "output": [ [Function], ], + "override": [Function], "toString": [Function], "version": "v2", } diff --git a/packages/frontend-plugin-api/src/extensions/AppRootWrapperBlueprint.test.tsx b/packages/frontend-plugin-api/src/extensions/AppRootWrapperBlueprint.test.tsx index b67fc3664d..2ff46f0785 100644 --- a/packages/frontend-plugin-api/src/extensions/AppRootWrapperBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/extensions/AppRootWrapperBlueprint.test.tsx @@ -23,7 +23,6 @@ import { createExtension, createExtensionInput, } from '../wiring'; -import { each } from 'lodash'; describe('AppRootWrapperBlueprint', () => { it('should return an extension with sensible defaults', () => { @@ -38,7 +37,7 @@ describe('AppRootWrapperBlueprint', () => { "$$type": "@backstage/ExtensionDefinition", "attachTo": { "id": "app/root", - "input": "elements", + "input": "wrappers", }, "configSchema": undefined, "disabled": false, @@ -50,6 +49,7 @@ describe('AppRootWrapperBlueprint', () => { "output": [ [Function], ], + "override": [Function], "toString": [Function], "version": "v2", } diff --git a/packages/frontend-plugin-api/src/extensions/AppRootWrapperBlueprint.tsx b/packages/frontend-plugin-api/src/extensions/AppRootWrapperBlueprint.tsx index 5bcbaa49bd..4e8cab8f1b 100644 --- a/packages/frontend-plugin-api/src/extensions/AppRootWrapperBlueprint.tsx +++ b/packages/frontend-plugin-api/src/extensions/AppRootWrapperBlueprint.tsx @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import React from 'react'; import { ComponentType, PropsWithChildren } from 'react'; import { createExtensionBlueprint } from '../wiring'; @@ -20,7 +21,7 @@ import { createAppRootWrapperExtension } from './createAppRootWrapperExtension'; export const AppRootWrapperBlueprint = createExtensionBlueprint({ kind: 'app-root-wrapper', - attachTo: { id: 'app/root', input: 'elements' }, + attachTo: { id: 'app/root', input: 'wrappers' }, output: [createAppRootWrapperExtension.componentDataRef], dataRefs: { component: createAppRootWrapperExtension.componentDataRef, diff --git a/packages/frontend-plugin-api/src/extensions/NavItemBlueprint.test.tsx b/packages/frontend-plugin-api/src/extensions/NavItemBlueprint.test.tsx index ba7643eee7..90c9cdf9b4 100644 --- a/packages/frontend-plugin-api/src/extensions/NavItemBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/extensions/NavItemBlueprint.test.tsx @@ -60,6 +60,7 @@ describe('NavItemBlueprint', () => { "output": [ [Function], ], + "override": [Function], "toString": [Function], "version": "v2", } diff --git a/packages/frontend-plugin-api/src/extensions/NavLogoBlueprint.test.tsx b/packages/frontend-plugin-api/src/extensions/NavLogoBlueprint.test.tsx index fa01862785..4a96475cf5 100644 --- a/packages/frontend-plugin-api/src/extensions/NavLogoBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/extensions/NavLogoBlueprint.test.tsx @@ -43,6 +43,7 @@ describe('NavLogoBlueprint', () => { "output": [ [Function], ], + "override": [Function], "toString": [Function], "version": "v2", } diff --git a/packages/frontend-plugin-api/src/extensions/PageBlueprint.test.tsx b/packages/frontend-plugin-api/src/extensions/PageBlueprint.test.tsx index 5e1d6b7601..c1350b3ddb 100644 --- a/packages/frontend-plugin-api/src/extensions/PageBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/extensions/PageBlueprint.test.tsx @@ -76,6 +76,7 @@ describe('PageBlueprint', () => { "toString": [Function], }, ], + "override": [Function], "toString": [Function], "version": "v2", } diff --git a/packages/frontend-plugin-api/src/extensions/RouterBlueprint.test.tsx b/packages/frontend-plugin-api/src/extensions/RouterBlueprint.test.tsx index ba4123138f..018c3fc570 100644 --- a/packages/frontend-plugin-api/src/extensions/RouterBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/extensions/RouterBlueprint.test.tsx @@ -52,6 +52,7 @@ describe('RouterBlueprint', () => { "output": [ [Function], ], + "override": [Function], "toString": [Function], "version": "v2", } diff --git a/packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.test.tsx b/packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.test.tsx index 5ffdd3175b..f97798a64c 100644 --- a/packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.test.tsx @@ -13,10 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import React from 'react'; import { SignInPageBlueprint } from './SignInPageBlueprint'; import { createExtensionTester } from '@backstage/frontend-test-utils'; -import { waitFor } from '@testing-library/react'; +import { screen, waitFor } from '@testing-library/react'; +import { coreExtensionData, createExtension } from '../wiring'; describe('SignInPageBlueprint', () => { it('should create an extension with sensible defaults', () => { @@ -41,6 +43,7 @@ describe('SignInPageBlueprint', () => { "output": [ [Function], ], + "override": [Function], "toString": [Function], "version": "v2", } @@ -51,17 +54,29 @@ describe('SignInPageBlueprint', () => { const MockSignInPage = () =>
    ; const extension = SignInPageBlueprint.make({ + name: 'test', params: { loader: async () => () => }, }); const tester = createExtensionTester(extension); + expect(tester.data(SignInPageBlueprint.dataRefs.component)).toBeDefined(); - const { getByTestId } = tester.render(); + createExtensionTester( + createExtension({ + name: 'dummy', + attachTo: { id: 'ignored', input: 'ignored' }, + output: { + element: coreExtensionData.reactElement, + }, + factory: () => ({ element:
    }), + }), + ) + .add(extension) + .render(); - // todo(blam): need a better way to test this, currently fails. await waitFor(() => { - expect(getByTestId('mock-sign-in')).toBeInTheDocument(); + expect(screen.getByTestId('mock-sign-in')).toBeInTheDocument(); }); }); }); diff --git a/packages/frontend-plugin-api/src/extensions/ThemeBlueprint.test.ts b/packages/frontend-plugin-api/src/extensions/ThemeBlueprint.test.ts index 5bc3a8f7c3..92acd8eeba 100644 --- a/packages/frontend-plugin-api/src/extensions/ThemeBlueprint.test.ts +++ b/packages/frontend-plugin-api/src/extensions/ThemeBlueprint.test.ts @@ -44,6 +44,7 @@ describe('ThemeBlueprint', () => { "output": [ [Function], ], + "override": [Function], "toString": [Function], "version": "v2", } diff --git a/packages/frontend-plugin-api/src/extensions/TranslationBlueprint.test.ts b/packages/frontend-plugin-api/src/extensions/TranslationBlueprint.test.ts index a059189044..e2a979c097 100644 --- a/packages/frontend-plugin-api/src/extensions/TranslationBlueprint.test.ts +++ b/packages/frontend-plugin-api/src/extensions/TranslationBlueprint.test.ts @@ -60,6 +60,7 @@ describe('TranslationBlueprint', () => { "output": [ [Function], ], + "override": [Function], "toString": [Function], "version": "v2", } From 40808de76787f4564ee3fa47d72756b04c61ec8e Mon Sep 17 00:00:00 2001 From: Joe Van Alstyne Date: Wed, 5 Jun 2024 17:30:20 +0900 Subject: [PATCH 198/372] Add spec.type to Domain model Signed-off-by: Joe Van Alstyne --- .../examples/domains/artists-domain.yaml | 1 + .../examples/domains/playback-domain.yaml | 1 + .../src/kinds/DomainEntityV1alpha1.test.ts | 11 +++++++++++ .../catalog-model/src/kinds/DomainEntityV1alpha1.ts | 1 + .../src/schema/kinds/Domain.v1alpha1.schema.json | 9 ++++++++- 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/catalog-model/examples/domains/artists-domain.yaml b/packages/catalog-model/examples/domains/artists-domain.yaml index 598f8500aa..02370d9a14 100644 --- a/packages/catalog-model/examples/domains/artists-domain.yaml +++ b/packages/catalog-model/examples/domains/artists-domain.yaml @@ -13,3 +13,4 @@ metadata: spec: owner: team-a subdomainOf: audio + type: product-group diff --git a/packages/catalog-model/examples/domains/playback-domain.yaml b/packages/catalog-model/examples/domains/playback-domain.yaml index 58b5afe56e..e058ebf0a2 100644 --- a/packages/catalog-model/examples/domains/playback-domain.yaml +++ b/packages/catalog-model/examples/domains/playback-domain.yaml @@ -6,3 +6,4 @@ metadata: spec: owner: user:frank.tiernan subdomainOf: audio + type: product-group diff --git a/packages/catalog-model/src/kinds/DomainEntityV1alpha1.test.ts b/packages/catalog-model/src/kinds/DomainEntityV1alpha1.test.ts index 3c1e7f0a6d..181a696192 100644 --- a/packages/catalog-model/src/kinds/DomainEntityV1alpha1.test.ts +++ b/packages/catalog-model/src/kinds/DomainEntityV1alpha1.test.ts @@ -32,6 +32,7 @@ describe('DomainV1alpha1Validator', () => { spec: { owner: 'me', subdomainOf: 'parent-domain', + type: 'domain-type', }, }; }); @@ -84,4 +85,14 @@ describe('DomainV1alpha1Validator', () => { (entity as any).spec.subdomainOf = ''; await expect(validator.check(entity)).rejects.toThrow(/subdomainOf/); }); + + it('accepts missing type', async () => { + delete (entity as any).spec.type; + await expect(validator.check(entity)).resolves.toBe(true); + }); + + it('rejects empty type', async () => { + (entity as any).spec.type = ''; + await expect(validator.check(entity)).rejects.toThrow(/type/); + }); }); diff --git a/packages/catalog-model/src/kinds/DomainEntityV1alpha1.ts b/packages/catalog-model/src/kinds/DomainEntityV1alpha1.ts index 1fe3dfb522..765329abb4 100644 --- a/packages/catalog-model/src/kinds/DomainEntityV1alpha1.ts +++ b/packages/catalog-model/src/kinds/DomainEntityV1alpha1.ts @@ -33,6 +33,7 @@ export interface DomainEntityV1alpha1 extends Entity { spec: { owner: string; subdomainOf?: string; + type?: string; }; } diff --git a/packages/catalog-model/src/schema/kinds/Domain.v1alpha1.schema.json b/packages/catalog-model/src/schema/kinds/Domain.v1alpha1.schema.json index 7d0d7e25ff..e4a6c29dd1 100644 --- a/packages/catalog-model/src/schema/kinds/Domain.v1alpha1.schema.json +++ b/packages/catalog-model/src/schema/kinds/Domain.v1alpha1.schema.json @@ -12,7 +12,8 @@ }, "spec": { "owner": "artist-relations-team", - "subdomainOf": "audio" + "subdomainOf": "audio", + "type": "product-group" } } ], @@ -45,6 +46,12 @@ "description": "An entity reference to another domain of which the domain is a part.", "examples": ["audio"], "minLength": 1 + }, + "type": { + "type": "string", + "description": "The type of domain. There is currently no enforced set of values for this field, so it is left up to the adopting organization to choose a nomenclature that matches their catalog hierarchy.", + "examples": ["product-group", "bundle"], + "minLength": 1 } } } From 218abd5473183912064c5b86cccbd3c92147fe01 Mon Sep 17 00:00:00 2001 From: Joe Van Alstyne Date: Wed, 5 Jun 2024 17:34:36 +0900 Subject: [PATCH 199/372] Update api-report.md Signed-off-by: Joe Van Alstyne --- packages/catalog-model/api-report.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/catalog-model/api-report.md b/packages/catalog-model/api-report.md index 2d91fa44a5..7b06e80fc5 100644 --- a/packages/catalog-model/api-report.md +++ b/packages/catalog-model/api-report.md @@ -123,6 +123,7 @@ interface DomainEntityV1alpha1 extends Entity { spec: { owner: string; subdomainOf?: string; + type?: string; }; } export { DomainEntityV1alpha1 as DomainEntity }; From 34fa803f2961136a6ab367c8e362f34f86404bc3 Mon Sep 17 00:00:00 2001 From: Joe Van Alstyne Date: Wed, 5 Jun 2024 17:36:17 +0900 Subject: [PATCH 200/372] Add changeset Signed-off-by: Joe Van Alstyne --- .changeset/young-birds-push.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/young-birds-push.md diff --git a/.changeset/young-birds-push.md b/.changeset/young-birds-push.md new file mode 100644 index 0000000000..5b8ab3a81f --- /dev/null +++ b/.changeset/young-birds-push.md @@ -0,0 +1,5 @@ +--- +'@backstage/catalog-model': minor +--- + +Introduce an optional spec.type attribute on the Domain entity kind From 4e392ebdc49d3afbfa35bd767757bdcf839516d8 Mon Sep 17 00:00:00 2001 From: Joe Van Alstyne Date: Wed, 5 Jun 2024 17:42:20 +0900 Subject: [PATCH 201/372] Update documentation Signed-off-by: Joe Van Alstyne --- docs/features/software-catalog/descriptor-format.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/features/software-catalog/descriptor-format.md b/docs/features/software-catalog/descriptor-format.md index 416eb27fbd..1287a0780e 100644 --- a/docs/features/software-catalog/descriptor-format.md +++ b/docs/features/software-catalog/descriptor-format.md @@ -1303,6 +1303,18 @@ which the domain is a part, e.g. `audio`. This field is optional. | --------------------------------------- | ------------------------------------------ | ----------------------------------------------------------------------------- | | [`Domain`](#kind-domain) (default) | Same as this entity, typically `default` | [`partOf`, and reverse `hasPart`](well-known-relations.md#partof-and-haspart) | +### `spec.type` [optional] + +The type of domain. There is currently no enforced set of values for this field, +so it is left up to the adopting organization to choose a nomenclature that +matches their catalog hierarchy. This field is optional. + +Some common values for this field could be: + +- `product-area` +- `product-group` +- `bundle` + ## Kind: Location Describes the following entity kind: From ccb514f24d0c0d0b7e0d5d14bc33c94583ff68e4 Mon Sep 17 00:00:00 2001 From: Joe Van Alstyne Date: Mon, 10 Jun 2024 18:54:32 +0900 Subject: [PATCH 202/372] Add spec.type to Sytem model Signed-off-by: Joe Van Alstyne --- .../systems/artist-engagement-portal-system.yaml | 1 + .../examples/systems/audio-playback-system.yaml | 1 + .../examples/systems/podcast-system.yaml | 1 + .../src/kinds/SystemEntityV1alpha1.test.ts | 11 +++++++++++ .../catalog-model/src/kinds/SystemEntityV1alpha1.ts | 1 + .../src/schema/kinds/System.v1alpha1.schema.json | 9 ++++++++- 6 files changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/catalog-model/examples/systems/artist-engagement-portal-system.yaml b/packages/catalog-model/examples/systems/artist-engagement-portal-system.yaml index 8de3c00880..17fe21ba69 100644 --- a/packages/catalog-model/examples/systems/artist-engagement-portal-system.yaml +++ b/packages/catalog-model/examples/systems/artist-engagement-portal-system.yaml @@ -8,3 +8,4 @@ metadata: spec: owner: team-a domain: artists + type: service diff --git a/packages/catalog-model/examples/systems/audio-playback-system.yaml b/packages/catalog-model/examples/systems/audio-playback-system.yaml index 7430ae2ff5..f1edb7f17d 100644 --- a/packages/catalog-model/examples/systems/audio-playback-system.yaml +++ b/packages/catalog-model/examples/systems/audio-playback-system.yaml @@ -6,3 +6,4 @@ metadata: spec: owner: team-c domain: playback + type: feature-set diff --git a/packages/catalog-model/examples/systems/podcast-system.yaml b/packages/catalog-model/examples/systems/podcast-system.yaml index 47a2f7ac9f..77f53925c1 100644 --- a/packages/catalog-model/examples/systems/podcast-system.yaml +++ b/packages/catalog-model/examples/systems/podcast-system.yaml @@ -6,3 +6,4 @@ metadata: spec: owner: team-b domain: playback + type: feature-set diff --git a/packages/catalog-model/src/kinds/SystemEntityV1alpha1.test.ts b/packages/catalog-model/src/kinds/SystemEntityV1alpha1.test.ts index fd78633a89..915f455e79 100644 --- a/packages/catalog-model/src/kinds/SystemEntityV1alpha1.test.ts +++ b/packages/catalog-model/src/kinds/SystemEntityV1alpha1.test.ts @@ -32,6 +32,7 @@ describe('SystemV1alpha1Validator', () => { spec: { owner: 'me', domain: 'domain', + type: 'system-type', }, }; }); @@ -84,4 +85,14 @@ describe('SystemV1alpha1Validator', () => { (entity as any).spec.domain = ''; await expect(validator.check(entity)).rejects.toThrow(/domain/); }); + + it('accepts missing type', async () => { + delete (entity as any).spec.type; + await expect(validator.check(entity)).resolves.toBe(true); + }); + + it('rejects empty type', async () => { + (entity as any).spec.type = ''; + await expect(validator.check(entity)).rejects.toThrow(/type/); + }); }); diff --git a/packages/catalog-model/src/kinds/SystemEntityV1alpha1.ts b/packages/catalog-model/src/kinds/SystemEntityV1alpha1.ts index 88d405ec5b..37ecee8f6c 100644 --- a/packages/catalog-model/src/kinds/SystemEntityV1alpha1.ts +++ b/packages/catalog-model/src/kinds/SystemEntityV1alpha1.ts @@ -33,6 +33,7 @@ export interface SystemEntityV1alpha1 extends Entity { spec: { owner: string; domain?: string; + type?: string; }; } diff --git a/packages/catalog-model/src/schema/kinds/System.v1alpha1.schema.json b/packages/catalog-model/src/schema/kinds/System.v1alpha1.schema.json index 2cdbc37076..f91fe751dc 100644 --- a/packages/catalog-model/src/schema/kinds/System.v1alpha1.schema.json +++ b/packages/catalog-model/src/schema/kinds/System.v1alpha1.schema.json @@ -12,7 +12,8 @@ }, "spec": { "owner": "artist-relations-team", - "domain": "artists" + "domain": "artists", + "type": "service" } } ], @@ -45,6 +46,12 @@ "description": "An entity reference to the domain that the system belongs to.", "examples": ["artists"], "minLength": 1 + }, + "type": { + "type": "string", + "description": "The type of system. There is currently no enforced set of values for this field, so it is left up to the adopting organization to choose a nomenclature that matches their catalog hierarchy.", + "examples": ["product", "service", "feature-set"], + "minLength": 1 } } } From 2d6003457426d4a9caf8d12df421e9865bb6f482 Mon Sep 17 00:00:00 2001 From: Joe Van Alstyne Date: Mon, 10 Jun 2024 18:58:00 +0900 Subject: [PATCH 203/372] Update documentation Signed-off-by: Joe Van Alstyne --- docs/features/software-catalog/descriptor-format.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/features/software-catalog/descriptor-format.md b/docs/features/software-catalog/descriptor-format.md index 1287a0780e..57c2283586 100644 --- a/docs/features/software-catalog/descriptor-format.md +++ b/docs/features/software-catalog/descriptor-format.md @@ -1243,6 +1243,18 @@ system belongs to, e.g. `artists`. This field is optional. | --------------------------------------- | ------------------------------------------ | ----------------------------------------------------------------------------- | | [`Domain`](#kind-domain) (default) | Same as this entity, typically `default` | [`partOf`, and reverse `hasPart`](well-known-relations.md#partof-and-haspart) | +### `spec.type` [optional] + +The type of system. There is currently no enforced set of values for this field, +so it is left up to the adopting organization to choose a nomenclature that +matches their catalog hierarchy. This field is optional. + +Some common values for this field could be: + +- `product` +- `service` +- `feature-set` + ## Kind: Domain Describes the following entity kind: From 55a5ef2c3212c2aca2221cc94716f1b18a9d18c2 Mon Sep 17 00:00:00 2001 From: Joe Van Alstyne Date: Mon, 10 Jun 2024 19:03:17 +0900 Subject: [PATCH 204/372] Update changeset Signed-off-by: Joe Van Alstyne --- .changeset/young-birds-push.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/young-birds-push.md b/.changeset/young-birds-push.md index 5b8ab3a81f..54afa48aaf 100644 --- a/.changeset/young-birds-push.md +++ b/.changeset/young-birds-push.md @@ -2,4 +2,4 @@ '@backstage/catalog-model': minor --- -Introduce an optional spec.type attribute on the Domain entity kind +Introduce an optional spec.type attribute on the Domain and System entity kinds From ef71b00bbe0b2878379c73d67747751961e7cba2 Mon Sep 17 00:00:00 2001 From: Joe Van Alstyne Date: Mon, 10 Jun 2024 19:09:37 +0900 Subject: [PATCH 205/372] Update api-report.md Signed-off-by: Joe Van Alstyne --- packages/catalog-model/api-report.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/catalog-model/api-report.md b/packages/catalog-model/api-report.md index 7b06e80fc5..de941e2502 100644 --- a/packages/catalog-model/api-report.md +++ b/packages/catalog-model/api-report.md @@ -455,6 +455,7 @@ interface SystemEntityV1alpha1 extends Entity { spec: { owner: string; domain?: string; + type?: string; }; } export { SystemEntityV1alpha1 as SystemEntity }; From 1a0d955bb526e47ef8d635e267adb56868207e25 Mon Sep 17 00:00:00 2001 From: Joe Van Alstyne Date: Fri, 9 Aug 2024 18:17:19 +0900 Subject: [PATCH 206/372] Add test to DomainEntityV1alpha1.test.ts Signed-off-by: Joe Van Alstyne --- .../catalog-model/src/kinds/DomainEntityV1alpha1.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/catalog-model/src/kinds/DomainEntityV1alpha1.test.ts b/packages/catalog-model/src/kinds/DomainEntityV1alpha1.test.ts index 181a696192..ce35441fc8 100644 --- a/packages/catalog-model/src/kinds/DomainEntityV1alpha1.test.ts +++ b/packages/catalog-model/src/kinds/DomainEntityV1alpha1.test.ts @@ -95,4 +95,9 @@ describe('DomainV1alpha1Validator', () => { (entity as any).spec.type = ''; await expect(validator.check(entity)).rejects.toThrow(/type/); }); + + it('rejects wrong type', async () => { + (entity as any).spec.type = 7; + await expect(validator.check(entity)).rejects.toThrow(/type/); + }); }); From 33489f73abe9032304c37c5777fbb5e91bba6b53 Mon Sep 17 00:00:00 2001 From: Joe Van Alstyne Date: Fri, 9 Aug 2024 18:17:33 +0900 Subject: [PATCH 207/372] Add test to SystemEntityV1alpha1.test.ts Signed-off-by: Joe Van Alstyne --- .../catalog-model/src/kinds/SystemEntityV1alpha1.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/catalog-model/src/kinds/SystemEntityV1alpha1.test.ts b/packages/catalog-model/src/kinds/SystemEntityV1alpha1.test.ts index 915f455e79..6ea295f190 100644 --- a/packages/catalog-model/src/kinds/SystemEntityV1alpha1.test.ts +++ b/packages/catalog-model/src/kinds/SystemEntityV1alpha1.test.ts @@ -95,4 +95,9 @@ describe('SystemV1alpha1Validator', () => { (entity as any).spec.type = ''; await expect(validator.check(entity)).rejects.toThrow(/type/); }); + + it('rejects wrong type', async () => { + (entity as any).spec.type = 7; + await expect(validator.check(entity)).rejects.toThrow(/type/); + }); }); From 30e13a6b822d0c9db7bec55411b0e7cb43d9b9c6 Mon Sep 17 00:00:00 2001 From: Joe Van Alstyne Date: Fri, 9 Aug 2024 18:25:16 +0900 Subject: [PATCH 208/372] Fix test order in DomainEntityV1alpha1.test.ts, SystemEntityV1alpha1.test.ts Signed-off-by: Joe Van Alstyne --- .../src/kinds/DomainEntityV1alpha1.test.ts | 10 +++++----- .../src/kinds/SystemEntityV1alpha1.test.ts | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/catalog-model/src/kinds/DomainEntityV1alpha1.test.ts b/packages/catalog-model/src/kinds/DomainEntityV1alpha1.test.ts index ce35441fc8..61408b7e80 100644 --- a/packages/catalog-model/src/kinds/DomainEntityV1alpha1.test.ts +++ b/packages/catalog-model/src/kinds/DomainEntityV1alpha1.test.ts @@ -91,13 +91,13 @@ describe('DomainV1alpha1Validator', () => { await expect(validator.check(entity)).resolves.toBe(true); }); - it('rejects empty type', async () => { - (entity as any).spec.type = ''; - await expect(validator.check(entity)).rejects.toThrow(/type/); - }); - it('rejects wrong type', async () => { (entity as any).spec.type = 7; await expect(validator.check(entity)).rejects.toThrow(/type/); }); + + it('rejects empty type', async () => { + (entity as any).spec.type = ''; + await expect(validator.check(entity)).rejects.toThrow(/type/); + }); }); diff --git a/packages/catalog-model/src/kinds/SystemEntityV1alpha1.test.ts b/packages/catalog-model/src/kinds/SystemEntityV1alpha1.test.ts index 6ea295f190..828fe7a648 100644 --- a/packages/catalog-model/src/kinds/SystemEntityV1alpha1.test.ts +++ b/packages/catalog-model/src/kinds/SystemEntityV1alpha1.test.ts @@ -91,13 +91,13 @@ describe('SystemV1alpha1Validator', () => { await expect(validator.check(entity)).resolves.toBe(true); }); - it('rejects empty type', async () => { - (entity as any).spec.type = ''; - await expect(validator.check(entity)).rejects.toThrow(/type/); - }); - it('rejects wrong type', async () => { (entity as any).spec.type = 7; await expect(validator.check(entity)).rejects.toThrow(/type/); }); + + it('rejects empty type', async () => { + (entity as any).spec.type = ''; + await expect(validator.check(entity)).rejects.toThrow(/type/); + }); }); From 5394a94efa772bfba3ded5e79528427529cf9bf0 Mon Sep 17 00:00:00 2001 From: Joe Van Alstyne Date: Tue, 4 Jun 2024 17:09:45 +0900 Subject: [PATCH 209/372] Add columns prop to ConsumingComponentsCard and ProvidingComponentsCard Signed-off-by: Joe Van Alstyne --- .../components/ComponentsCards/ConsumingComponentsCard.tsx | 7 +++++-- .../components/ComponentsCards/ProvidingComponentsCard.tsx | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/api-docs/src/components/ComponentsCards/ConsumingComponentsCard.tsx b/plugins/api-docs/src/components/ComponentsCards/ConsumingComponentsCard.tsx index 5feb1c96e4..8e461bb08a 100644 --- a/plugins/api-docs/src/components/ComponentsCards/ConsumingComponentsCard.tsx +++ b/plugins/api-docs/src/components/ComponentsCards/ConsumingComponentsCard.tsx @@ -31,6 +31,7 @@ import { InfoCardVariants, Link, Progress, + TableColumn, WarningPanel, } from '@backstage/core-components'; @@ -39,8 +40,10 @@ import { */ export const ConsumingComponentsCard = (props: { variant?: InfoCardVariants; + columns?: TableColumn[]; }) => { - const { variant = 'gridItem' } = props; + const { variant = 'gridItem', columns = EntityTable.componentEntityColumns } = + props; const { entity } = useEntity(); const { entities, loading, error } = useRelatedEntities(entity, { type: RELATION_API_CONSUMED_BY, @@ -82,7 +85,7 @@ export const ConsumingComponentsCard = (props: {
    } - columns={EntityTable.componentEntityColumns} + columns={columns} entities={entities as ComponentEntity[]} /> ); diff --git a/plugins/api-docs/src/components/ComponentsCards/ProvidingComponentsCard.tsx b/plugins/api-docs/src/components/ComponentsCards/ProvidingComponentsCard.tsx index ef7f2e1071..33dc7217d4 100644 --- a/plugins/api-docs/src/components/ComponentsCards/ProvidingComponentsCard.tsx +++ b/plugins/api-docs/src/components/ComponentsCards/ProvidingComponentsCard.tsx @@ -31,14 +31,17 @@ import { InfoCardVariants, Link, Progress, + TableColumn, WarningPanel, } from '@backstage/core-components'; /** @public */ export const ProvidingComponentsCard = (props: { variant?: InfoCardVariants; + columns?: TableColumn[]; }) => { - const { variant = 'gridItem' } = props; + const { variant = 'gridItem', columns = EntityTable.componentEntityColumns } = + props; const { entity } = useEntity(); const { entities, loading, error } = useRelatedEntities(entity, { type: RELATION_API_PROVIDED_BY, @@ -80,7 +83,7 @@ export const ProvidingComponentsCard = (props: {
    } - columns={EntityTable.componentEntityColumns} + columns={columns} entities={entities as ComponentEntity[]} /> ); From 770ba02d32c0ca365b360b516ddbd298142b55f7 Mon Sep 17 00:00:00 2001 From: Joe Van Alstyne Date: Tue, 4 Jun 2024 17:17:21 +0900 Subject: [PATCH 210/372] Add changeset Signed-off-by: Joe Van Alstyne --- .changeset/forty-geckos-change.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/forty-geckos-change.md diff --git a/.changeset/forty-geckos-change.md b/.changeset/forty-geckos-change.md new file mode 100644 index 0000000000..e7ac112f57 --- /dev/null +++ b/.changeset/forty-geckos-change.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-api-docs': patch +--- + +Custom columns can now be optionally provided to ConsumingComponentsCard and ProvidingComponentsCard From 74c0e7712e803c8fcdf22ab59a725a22394e3dbe Mon Sep 17 00:00:00 2001 From: Joe Van Alstyne Date: Tue, 4 Jun 2024 17:20:09 +0900 Subject: [PATCH 211/372] Update api-report.md Signed-off-by: Joe Van Alstyne --- plugins/api-docs/api-report.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/api-docs/api-report.md b/plugins/api-docs/api-report.md index 2fc852777b..65cc421b78 100644 --- a/plugins/api-docs/api-report.md +++ b/plugins/api-docs/api-report.md @@ -9,6 +9,7 @@ import { ApiEntity } from '@backstage/catalog-model'; import { ApiRef } from '@backstage/core-plugin-api'; import { BackstagePlugin } from '@backstage/core-plugin-api'; import { CatalogTableRow } from '@backstage/plugin-catalog'; +import { ComponentEntity } from '@backstage/catalog-model'; import { EntityOwnerPickerProps } from '@backstage/plugin-catalog-react'; import { ExternalRouteRef } from '@backstage/core-plugin-api'; import { InfoCardVariants } from '@backstage/core-components'; @@ -94,6 +95,7 @@ export const ConsumedApisCard: (props: { // @public (undocumented) export const ConsumingComponentsCard: (props: { variant?: InfoCardVariants; + columns?: TableColumn[]; }) => React_2.JSX.Element; // @public @@ -124,6 +126,7 @@ export const EntityConsumedApisCard: (props: { // @public (undocumented) export const EntityConsumingComponentsCard: (props: { variant?: InfoCardVariants | undefined; + columns?: TableColumn[] | undefined; }) => JSX_2.Element; // @public (undocumented) @@ -141,6 +144,7 @@ export const EntityProvidedApisCard: (props: { // @public (undocumented) export const EntityProvidingComponentsCard: (props: { variant?: InfoCardVariants | undefined; + columns?: TableColumn[] | undefined; }) => JSX_2.Element; // @public (undocumented) @@ -191,6 +195,7 @@ export const ProvidedApisCard: (props: { // @public (undocumented) export const ProvidingComponentsCard: (props: { variant?: InfoCardVariants; + columns?: TableColumn[]; }) => React_2.JSX.Element; // @public (undocumented) From 2881a03ebb35cb9e2becf199b90f252d0dedef59 Mon Sep 17 00:00:00 2001 From: Joe Van Alstyne Date: Tue, 4 Jun 2024 17:32:31 +0900 Subject: [PATCH 212/372] Update changeset Signed-off-by: Joe Van Alstyne --- .changeset/forty-geckos-change.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/forty-geckos-change.md b/.changeset/forty-geckos-change.md index e7ac112f57..484a485670 100644 --- a/.changeset/forty-geckos-change.md +++ b/.changeset/forty-geckos-change.md @@ -2,4 +2,4 @@ '@backstage/plugin-api-docs': patch --- -Custom columns can now be optionally provided to ConsumingComponentsCard and ProvidingComponentsCard +`ConsumingComponentsCard` and `ProvidingComponentsCard` will now optionally accept `columns` to override which table columns are displayed From e6c763f76b6d19865a320c86a361fbb3ef5035f9 Mon Sep 17 00:00:00 2001 From: blam Date: Fri, 9 Aug 2024 15:12:47 +0200 Subject: [PATCH 213/372] chore: getting the tests working MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Patrik Oldsberg Co-authored-by: Fredrik Adelöw Co-authored-by: Camila Belo Signed-off-by: blam --- packages/frontend-plugin-api/api-report.md | 410 +++++++++++++++--- .../ApiBlueprint.test.ts | 3 +- .../ApiBlueprint.ts | 4 +- .../AppRootElementBlueprint.test.tsx | 0 .../AppRootElementBlueprint.ts | 1 + .../AppRootWrapperBlueprint.test.tsx | 7 +- .../AppRootWrapperBlueprint.tsx | 3 +- .../IconBundleBlueprint.ts | 0 .../NavItemBlueprint.test.tsx | 1 - .../NavItemBlueprint.ts | 12 +- .../NavLogoBlueprint.test.tsx | 0 .../NavLogoBlueprint.ts | 3 +- .../PageBlueprint.test.tsx | 2 +- .../PageBlueprint.tsx | 5 +- .../RouterBlueprint.test.tsx | 2 +- .../RouterBlueprint.tsx | 3 +- .../SignInPageBlueprint.test.tsx | 0 .../SignInPageBlueprint.tsx | 3 +- .../ThemeBlueprint.test.ts | 3 +- .../ThemeBlueprint.ts | 4 +- .../TranslationBlueprint.test.ts | 2 +- .../TranslationBlueprint.ts | 4 +- .../src/blueprints/index.ts | 27 ++ .../src/extensions/createApiExtension.ts | 5 +- .../createAppRootElementExtension.ts | 1 + .../createAppRootWrapperExtension.tsx | 1 + .../src/extensions/createNavItemExtension.tsx | 2 + .../src/extensions/createNavLogoExtension.tsx | 2 + .../src/extensions/createPageExtension.tsx | 1 + .../src/extensions/createRouterExtension.tsx | 1 + .../extensions/createSignInPageExtension.tsx | 1 + .../src/extensions/createThemeExtension.ts | 10 +- .../extensions/createTranslationExtension.ts | 10 +- .../src/extensions/index.ts | 1 - packages/frontend-plugin-api/src/index.ts | 1 + .../wiring/createExtensionBlueprint.test.tsx | 95 +--- .../src/wiring/createExtensionBlueprint.ts | 224 +++++----- .../src/app/createExtensionTester.tsx | 5 +- 38 files changed, 578 insertions(+), 281 deletions(-) rename packages/frontend-plugin-api/src/{extensions => blueprints}/ApiBlueprint.test.ts (97%) rename packages/frontend-plugin-api/src/{extensions => blueprints}/ApiBlueprint.ts (91%) rename packages/frontend-plugin-api/src/{extensions => blueprints}/AppRootElementBlueprint.test.tsx (100%) rename packages/frontend-plugin-api/src/{extensions => blueprints}/AppRootElementBlueprint.ts (98%) rename packages/frontend-plugin-api/src/{extensions => blueprints}/AppRootWrapperBlueprint.test.tsx (95%) rename packages/frontend-plugin-api/src/{extensions => blueprints}/AppRootWrapperBlueprint.tsx (92%) rename packages/frontend-plugin-api/src/{extensions => blueprints}/IconBundleBlueprint.ts (100%) rename packages/frontend-plugin-api/src/{extensions => blueprints}/NavItemBlueprint.test.tsx (98%) rename packages/frontend-plugin-api/src/{extensions => blueprints}/NavItemBlueprint.ts (86%) rename packages/frontend-plugin-api/src/{extensions => blueprints}/NavLogoBlueprint.test.tsx (100%) rename packages/frontend-plugin-api/src/{extensions => blueprints}/NavLogoBlueprint.ts (92%) rename packages/frontend-plugin-api/src/{extensions => blueprints}/PageBlueprint.test.tsx (98%) rename packages/frontend-plugin-api/src/{extensions => blueprints}/PageBlueprint.tsx (97%) rename packages/frontend-plugin-api/src/{extensions => blueprints}/RouterBlueprint.test.tsx (98%) rename packages/frontend-plugin-api/src/{extensions => blueprints}/RouterBlueprint.tsx (92%) rename packages/frontend-plugin-api/src/{extensions => blueprints}/SignInPageBlueprint.test.tsx (100%) rename packages/frontend-plugin-api/src/{extensions => blueprints}/SignInPageBlueprint.tsx (93%) rename packages/frontend-plugin-api/src/{extensions => blueprints}/ThemeBlueprint.test.ts (94%) rename packages/frontend-plugin-api/src/{extensions => blueprints}/ThemeBlueprint.ts (91%) rename packages/frontend-plugin-api/src/{extensions => blueprints}/TranslationBlueprint.test.ts (98%) rename packages/frontend-plugin-api/src/{extensions => blueprints}/TranslationBlueprint.ts (90%) create mode 100644 packages/frontend-plugin-api/src/blueprints/index.ts diff --git a/packages/frontend-plugin-api/api-report.md b/packages/frontend-plugin-api/api-report.md index a8f8ce591b..2d3f1d3278 100644 --- a/packages/frontend-plugin-api/api-report.md +++ b/packages/frontend-plugin-api/api-report.md @@ -189,6 +189,27 @@ export type AnyRoutes = { [name in string]: RouteRef | SubRouteRef; }; +// @public (undocumented) +export const ApiBlueprint: ExtensionBlueprint< + 'api', + undefined, + undefined, + { + factory: AnyApiFactory; + }, + ConfigurableExtensionDataRef, + {}, + {}, + {}, + { + factory: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + } +>; + export { ApiFactory }; export { ApiHolder }; @@ -240,6 +261,50 @@ export interface AppNodeSpec { readonly source?: BackstagePlugin; } +// @public (undocumented) +export const AppRootElementBlueprint: ExtensionBlueprint< + 'app-root-element', + undefined, + undefined, + { + element: JSX.Element | (() => JSX.Element); + }, + ConfigurableExtensionDataRef, + {}, + {}, + {}, + never +>; + +// @public (undocumented) +export const AppRootWrapperBlueprint: ExtensionBlueprint< + 'app-root-wrapper', + undefined, + undefined, + { + Component: ComponentType>; + }, + ConfigurableExtensionDataRef< + React_2.ComponentType<{ + children?: React_2.ReactNode; + }>, + 'app.root.wrapper', + {} + >, + {}, + {}, + {}, + { + component: ConfigurableExtensionDataRef< + React_2.ComponentType<{ + children?: React_2.ReactNode; + }>, + 'app.root.wrapper', + {} + >; + } +>; + export { AppTheme }; export { AppThemeApi }; @@ -381,7 +446,7 @@ export type CoreNotFoundErrorPageProps = { // @public (undocumented) export type CoreProgressProps = {}; -// @public (undocumented) +// @public @deprecated (undocumented) export function createApiExtension< TConfig extends {}, TInputs extends AnyExtensionInputMap, @@ -425,7 +490,7 @@ export { createApiFactory }; export { createApiRef }; -// @public +// @public @deprecated export function createAppRootElementExtension< TConfig extends {}, TInputs extends AnyExtensionInputMap, @@ -447,7 +512,7 @@ export function createAppRootElementExtension< }) => JSX_2.Element); }): ExtensionDefinition; -// @public +// @public @deprecated export function createAppRootWrapperExtension< TConfig extends {}, TInputs extends AnyExtensionInputMap, @@ -675,7 +740,7 @@ export type CreateExtensionBlueprintOptions< }, > = { kind: TKind; - namespace?: TNamespace | ((params: TParams) => TNamespace); + namespace?: TNamespace; attachTo: { id: string; input: string; @@ -683,9 +748,9 @@ export type CreateExtensionBlueprintOptions< disabled?: boolean; inputs?: TInputs; output: Array; - name?: TName | ((params: TParams) => TName); + name?: TName; config?: { - schema: TConfigSchema | ((params: TParams) => TConfigSchema); + schema: TConfigSchema; }; factory( params: TParams, @@ -824,7 +889,7 @@ export function createExternalRouteRef< } >; -// @public +// @public @deprecated export function createNavItemExtension(options: { namespace?: string; name?: string; @@ -859,7 +924,7 @@ export namespace createNavItemExtension { >; } -// @public +// @public @deprecated export function createNavLogoExtension(options: { name?: string; namespace?: string; @@ -888,7 +953,7 @@ export namespace createNavLogoExtension { >; } -// @public +// @public @deprecated export function createPageExtension< TConfig extends { path: string; @@ -958,7 +1023,7 @@ export function createRouteRef< } >; -// @public +// @public @deprecated export function createRouterExtension< TConfig extends {}, TInputs extends AnyExtensionInputMap, @@ -997,7 +1062,7 @@ export function createSchemaFromZod( schemaCreator: (zImpl: typeof z) => ZodSchema, ): PortableSchema; -// @public (undocumented) +// @public @deprecated (undocumented) export function createSignInPageExtension< TConfig extends {}, TInputs extends AnyExtensionInputMap, @@ -1036,7 +1101,7 @@ export function createSubRouteRef< parent: RouteRef; }): MakeSubRouteRef, ParentParams>; -// @public (undocumented) +// @public @deprecated (undocumented) export function createThemeExtension( theme: AppTheme, ): ExtensionDefinition< @@ -1049,7 +1114,7 @@ export function createThemeExtension( string | undefined >; -// @public (undocumented) +// @public @deprecated (undocumented) export namespace createThemeExtension { const // (undocumented) themeDataRef: ConfigurableExtensionDataRef< @@ -1059,7 +1124,7 @@ export namespace createThemeExtension { >; } -// @public (undocumented) +// @public @deprecated (undocumented) export function createTranslationExtension(options: { name?: string; resource: TranslationResource | TranslationMessages; @@ -1073,7 +1138,7 @@ export function createTranslationExtension(options: { string | undefined >; -// @public (undocumented) +// @public @deprecated (undocumented) export namespace createTranslationExtension { const // (undocumented) translationDataRef: ConfigurableExtensionDataRef< @@ -1153,9 +1218,31 @@ export interface ExtensionBlueprint< > { // (undocumented) dataRefs: TDataRefs; + // (undocumented) make< TNewNamespace extends string | undefined, TNewName extends string | undefined, + >(args: { + namespace?: TNewNamespace; + name?: TNewName; + attachTo?: { + id: string; + input: string; + }; + disabled?: boolean; + params: TParams; + }): ExtensionDefinition< + TConfig, + TConfigInput, + UOutput, + TInputs, + TKind, + string | undefined extends TNewNamespace ? TNamespace : TNewNamespace, + string | undefined extends TNewName ? TName : TNewName + >; + makeWithOverrides< + TNewNamespace extends string | undefined, + TNewName extends string | undefined, TExtensionConfigSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType; }, @@ -1170,55 +1257,48 @@ export interface ExtensionBlueprint< } >; }, - >( - args: { - namespace?: TNewNamespace; - name?: TNewName; - attachTo?: { - id: string; - input: string; + >(args: { + namespace?: TNewNamespace; + name?: TNewName; + attachTo?: { + id: string; + input: string; + }; + disabled?: boolean; + inputs?: TExtraInputs & { + [KName in keyof TInputs]?: `Error: Input '${KName & + string}' is already defined in parent definition`; + }; + output?: Array; + config?: { + schema: TExtensionConfigSchema & { + [KName in keyof TConfig]?: `Error: Config key '${KName & + string}' is already defined in parent schema`; }; - disabled?: boolean; - inputs?: TExtraInputs & { - [KName in keyof TInputs]?: `Error: Input '${KName & - string}' is already defined in parent definition`; - }; - output?: Array; - config?: { - schema: TExtensionConfigSchema & { - [KName in keyof TConfig]?: `Error: Config key '${KName & - string}' is already defined in parent schema`; + }; + factory( + originalFactory: ( + params: TParams, + context?: { + config?: TConfig; + inputs?: Expand>; + }, + ) => ExtensionDataContainer, + context: { + node: AppNode; + config: TConfig & { + [key in keyof TExtensionConfigSchema]: z.infer< + ReturnType + >; }; - }; - } & ( - | ({ - factory( - originalFactory: ( - params: TParams, - context?: { - config?: TConfig; - inputs?: Expand>; - }, - ) => ExtensionDataContainer, - context: { - node: AppNode; - config: TConfig & { - [key in keyof TExtensionConfigSchema]: z.infer< - ReturnType - >; - }; - inputs: Expand>; - }, - ): Iterable; - } & VerifyExtensionFactoryOutput< - AnyExtensionDataRef extends UNewOutput ? UOutput : UNewOutput, - UFactoryOutput - >) - | { - params: TParams; - } - ), - ): ExtensionDefinition< + inputs: Expand>; + }, + ): Iterable & + VerifyExtensionFactoryOutput< + AnyExtensionDataRef extends UNewOutput ? UOutput : UNewOutput, + UFactoryOutput + >; + }): ExtensionDefinition< { [key in keyof TExtensionConfigSchema]: z.infer< ReturnType @@ -1616,6 +1696,73 @@ export interface LegacyExtensionInput< export { microsoftAuthApiRef }; +// @public (undocumented) +export const NavItemBlueprint: ExtensionBlueprint< + 'nav-item', + undefined, + undefined, + { + title: string; + icon: IconComponent_2; + routeRef: RouteRef; + }, + ConfigurableExtensionDataRef< + { + title: string; + icon: IconComponent_2; + routeRef: RouteRef; + }, + 'core.nav-item.target', + {} + >, + {}, + {}, + {}, + { + target: ConfigurableExtensionDataRef< + { + title: string; + icon: IconComponent_2; + routeRef: RouteRef; + }, + 'core.nav-item.target', + {} + >; + } +>; + +// @public (undocumented) +export const NavLogoBlueprint: ExtensionBlueprint< + 'nav-logo', + undefined, + undefined, + { + logoIcon: JSX.Element; + logoFull: JSX.Element; + }, + ConfigurableExtensionDataRef< + { + logoIcon?: JSX.Element | undefined; + logoFull?: JSX.Element | undefined; + }, + 'core.nav-logo.logo-elements', + {} + >, + {}, + {}, + {}, + { + logoElements: ConfigurableExtensionDataRef< + { + logoIcon?: JSX.Element | undefined; + logoFull?: JSX.Element | undefined; + }, + 'core.nav-logo.logo-elements', + {} + >; + } +>; + export { OAuthApi }; export { OAuthRequestApi }; @@ -1634,6 +1781,35 @@ export { oneloginAuthApiRef }; export { OpenIdConnectApi }; +// @public (undocumented) +export const PageBlueprint: ExtensionBlueprint< + 'page', + undefined, + undefined, + { + defaultPath: string; + loader: () => Promise; + routeRef?: RouteRef | undefined; + }, + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + RouteRef, + 'core.routing.ref', + RouteRef & { + optional: true; + } + >, + {}, + { + path: string | undefined; + }, + { + path?: string | undefined; + }, + never +>; + export { PendingOAuthRequest }; // @public (undocumented) @@ -1699,6 +1875,35 @@ export type RouteFunc = ( : readonly [params: TParams] ) => string; +// @public (undocumented) +export const RouterBlueprint: ExtensionBlueprint< + 'app-router-component', + undefined, + undefined, + { + Component: ComponentType>; + }, + ConfigurableExtensionDataRef< + ComponentType<{ + children?: ReactNode; + }>, + 'app.router.wrapper', + {} + >, + {}, + {}, + {}, + { + component: ConfigurableExtensionDataRef< + ComponentType<{ + children?: ReactNode; + }>, + 'app.router.wrapper', + {} + >; + } +>; + // @public export interface RouteRef< TParams extends AnyRouteRefParams = AnyRouteRefParams, @@ -1733,6 +1938,31 @@ export { SessionApi }; export { SessionState }; +// @public (undocumented) +export const SignInPageBlueprint: ExtensionBlueprint< + 'sign-in-page', + undefined, + undefined, + { + loader: () => Promise>; + }, + ConfigurableExtensionDataRef< + React_2.ComponentType, + 'core.sign-in-page.component', + {} + >, + {}, + {}, + {}, + { + component: ConfigurableExtensionDataRef< + React_2.ComponentType, + 'core.sign-in-page.component', + {} + >; + } +>; + export { StorageApi }; export { storageApiRef }; @@ -1751,6 +1981,62 @@ export interface SubRouteRef< readonly T: TParams; } +// @public (undocumented) +export const ThemeBlueprint: ExtensionBlueprint< + 'theme', + 'app', + undefined, + { + theme: AppTheme; + }, + ConfigurableExtensionDataRef, + {}, + {}, + {}, + { + theme: ConfigurableExtensionDataRef; + } +>; + +// @public (undocumented) +export const TranslationBlueprint: ExtensionBlueprint< + 'translation', + undefined, + undefined, + { + resource: TranslationResource | TranslationMessages; + }, + ConfigurableExtensionDataRef< + | TranslationResource + | TranslationMessages< + string, + { + [x: string]: string; + }, + boolean + >, + 'core.translation.translation', + {} + >, + {}, + {}, + {}, + { + translation: ConfigurableExtensionDataRef< + | TranslationResource + | TranslationMessages< + string, + { + [x: string]: string; + }, + boolean + >, + 'core.translation.translation', + {} + >; + } +>; + export { TranslationMessages }; export { TranslationMessagesOptions }; diff --git a/packages/frontend-plugin-api/src/extensions/ApiBlueprint.test.ts b/packages/frontend-plugin-api/src/blueprints/ApiBlueprint.test.ts similarity index 97% rename from packages/frontend-plugin-api/src/extensions/ApiBlueprint.test.ts rename to packages/frontend-plugin-api/src/blueprints/ApiBlueprint.test.ts index f070956e96..3b865a78bb 100644 --- a/packages/frontend-plugin-api/src/extensions/ApiBlueprint.test.ts +++ b/packages/frontend-plugin-api/src/blueprints/ApiBlueprint.test.ts @@ -30,6 +30,7 @@ describe('ApiBlueprint', () => { params: { factory, }, + namespace: 'test', }); expect(extension).toMatchInlineSnapshot(` @@ -60,7 +61,7 @@ describe('ApiBlueprint', () => { const api = createApiRef<{ foo: string }>({ id: 'test' }); const factory = jest.fn(() => ({ foo: 'bar' })); - const extension = ApiBlueprint.make({ + const extension = ApiBlueprint.makeWithOverrides({ config: { schema: { test: z => z.string().default('test'), diff --git a/packages/frontend-plugin-api/src/extensions/ApiBlueprint.ts b/packages/frontend-plugin-api/src/blueprints/ApiBlueprint.ts similarity index 91% rename from packages/frontend-plugin-api/src/extensions/ApiBlueprint.ts rename to packages/frontend-plugin-api/src/blueprints/ApiBlueprint.ts index 16a20b5130..da12faef1a 100644 --- a/packages/frontend-plugin-api/src/extensions/ApiBlueprint.ts +++ b/packages/frontend-plugin-api/src/blueprints/ApiBlueprint.ts @@ -14,9 +14,10 @@ * limitations under the License. */ import { createExtensionBlueprint } from '../wiring'; -import { createApiExtension } from './createApiExtension'; +import { createApiExtension } from '../extensions/createApiExtension'; import { AnyApiFactory } from '@backstage/core-plugin-api'; +/** @public */ export const ApiBlueprint = createExtensionBlueprint({ kind: 'api', attachTo: { id: 'app', input: 'apis' }, @@ -27,5 +28,4 @@ export const ApiBlueprint = createExtensionBlueprint({ *factory(params: { factory: AnyApiFactory }) { yield createApiExtension.factoryDataRef(params.factory); }, - namespace: ({ factory }) => factory.api.id, }); diff --git a/packages/frontend-plugin-api/src/extensions/AppRootElementBlueprint.test.tsx b/packages/frontend-plugin-api/src/blueprints/AppRootElementBlueprint.test.tsx similarity index 100% rename from packages/frontend-plugin-api/src/extensions/AppRootElementBlueprint.test.tsx rename to packages/frontend-plugin-api/src/blueprints/AppRootElementBlueprint.test.tsx diff --git a/packages/frontend-plugin-api/src/extensions/AppRootElementBlueprint.ts b/packages/frontend-plugin-api/src/blueprints/AppRootElementBlueprint.ts similarity index 98% rename from packages/frontend-plugin-api/src/extensions/AppRootElementBlueprint.ts rename to packages/frontend-plugin-api/src/blueprints/AppRootElementBlueprint.ts index 1048d531ab..e44942979d 100644 --- a/packages/frontend-plugin-api/src/extensions/AppRootElementBlueprint.ts +++ b/packages/frontend-plugin-api/src/blueprints/AppRootElementBlueprint.ts @@ -15,6 +15,7 @@ */ import { coreExtensionData, createExtensionBlueprint } from '../wiring'; +/** @public */ export const AppRootElementBlueprint = createExtensionBlueprint({ kind: 'app-root-element', attachTo: { id: 'app/root', input: 'elements' }, diff --git a/packages/frontend-plugin-api/src/extensions/AppRootWrapperBlueprint.test.tsx b/packages/frontend-plugin-api/src/blueprints/AppRootWrapperBlueprint.test.tsx similarity index 95% rename from packages/frontend-plugin-api/src/extensions/AppRootWrapperBlueprint.test.tsx rename to packages/frontend-plugin-api/src/blueprints/AppRootWrapperBlueprint.test.tsx index 2ff46f0785..f7feab1d46 100644 --- a/packages/frontend-plugin-api/src/extensions/AppRootWrapperBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/blueprints/AppRootWrapperBlueprint.test.tsx @@ -78,7 +78,7 @@ describe('AppRootWrapperBlueprint', () => { }); it('should render the complex component wrapper', async () => { - const extension = AppRootWrapperBlueprint.make({ + const extension = AppRootWrapperBlueprint.makeWithOverrides({ namespace: 'ns', name: 'test', config: { @@ -94,6 +94,9 @@ describe('AppRootWrapperBlueprint', () => { Component: ({ children }) => (
    {children} + {inputs.children.flatMap(c => + c.get(coreExtensionData.reactElement), + )}
    ), }); @@ -119,9 +122,9 @@ describe('AppRootWrapperBlueprint', () => { .render(); await waitFor(() => { - expect(getByText('Its Me')).toBeInTheDocument(); expect(getByText('Hi')).toBeInTheDocument(); expect(getByTestId('Robin-1')).toBeInTheDocument(); + expect(getByText('Its Me')).toBeInTheDocument(); }); }); }); diff --git a/packages/frontend-plugin-api/src/extensions/AppRootWrapperBlueprint.tsx b/packages/frontend-plugin-api/src/blueprints/AppRootWrapperBlueprint.tsx similarity index 92% rename from packages/frontend-plugin-api/src/extensions/AppRootWrapperBlueprint.tsx rename to packages/frontend-plugin-api/src/blueprints/AppRootWrapperBlueprint.tsx index 4e8cab8f1b..db63550880 100644 --- a/packages/frontend-plugin-api/src/extensions/AppRootWrapperBlueprint.tsx +++ b/packages/frontend-plugin-api/src/blueprints/AppRootWrapperBlueprint.tsx @@ -17,8 +17,9 @@ import React from 'react'; import { ComponentType, PropsWithChildren } from 'react'; import { createExtensionBlueprint } from '../wiring'; -import { createAppRootWrapperExtension } from './createAppRootWrapperExtension'; +import { createAppRootWrapperExtension } from '../extensions/createAppRootWrapperExtension'; +/** @public */ export const AppRootWrapperBlueprint = createExtensionBlueprint({ kind: 'app-root-wrapper', attachTo: { id: 'app/root', input: 'wrappers' }, diff --git a/packages/frontend-plugin-api/src/extensions/IconBundleBlueprint.ts b/packages/frontend-plugin-api/src/blueprints/IconBundleBlueprint.ts similarity index 100% rename from packages/frontend-plugin-api/src/extensions/IconBundleBlueprint.ts rename to packages/frontend-plugin-api/src/blueprints/IconBundleBlueprint.ts diff --git a/packages/frontend-plugin-api/src/extensions/NavItemBlueprint.test.tsx b/packages/frontend-plugin-api/src/blueprints/NavItemBlueprint.test.tsx similarity index 98% rename from packages/frontend-plugin-api/src/extensions/NavItemBlueprint.test.tsx rename to packages/frontend-plugin-api/src/blueprints/NavItemBlueprint.test.tsx index 90c9cdf9b4..94b9e7b8e6 100644 --- a/packages/frontend-plugin-api/src/extensions/NavItemBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/blueprints/NavItemBlueprint.test.tsx @@ -44,7 +44,6 @@ describe('NavItemBlueprint', () => { "additionalProperties": false, "properties": { "title": { - "default": "TEST", "type": "string", }, }, diff --git a/packages/frontend-plugin-api/src/extensions/NavItemBlueprint.ts b/packages/frontend-plugin-api/src/blueprints/NavItemBlueprint.ts similarity index 86% rename from packages/frontend-plugin-api/src/extensions/NavItemBlueprint.ts rename to packages/frontend-plugin-api/src/blueprints/NavItemBlueprint.ts index 568431c0f5..5391d0dec2 100644 --- a/packages/frontend-plugin-api/src/extensions/NavItemBlueprint.ts +++ b/packages/frontend-plugin-api/src/blueprints/NavItemBlueprint.ts @@ -17,8 +17,9 @@ import { IconComponent } from '@backstage/core-plugin-api'; import { RouteRef } from '../routing'; import { createExtensionBlueprint } from '../wiring'; -import { createNavItemExtension } from './createNavItemExtension'; +import { createNavItemExtension } from '../extensions/createNavItemExtension'; +/** @public */ export const NavItemBlueprint = createExtensionBlueprint({ kind: 'nav-item', attachTo: { id: 'app/nav', input: 'items' }, @@ -30,6 +31,7 @@ export const NavItemBlueprint = createExtensionBlueprint({ { icon, routeRef, + title, }: { title: string; icon: IconComponent; @@ -38,14 +40,14 @@ export const NavItemBlueprint = createExtensionBlueprint({ { config }, ) => [ createNavItemExtension.targetDataRef({ - title: config.title, + title: config.title ?? title, icon, routeRef, }), ], config: { - schema: ({ title }) => ({ - title: z => z.string().default(title), - }), + schema: { + title: z => z.string().optional(), + }, }, }); diff --git a/packages/frontend-plugin-api/src/extensions/NavLogoBlueprint.test.tsx b/packages/frontend-plugin-api/src/blueprints/NavLogoBlueprint.test.tsx similarity index 100% rename from packages/frontend-plugin-api/src/extensions/NavLogoBlueprint.test.tsx rename to packages/frontend-plugin-api/src/blueprints/NavLogoBlueprint.test.tsx diff --git a/packages/frontend-plugin-api/src/extensions/NavLogoBlueprint.ts b/packages/frontend-plugin-api/src/blueprints/NavLogoBlueprint.ts similarity index 92% rename from packages/frontend-plugin-api/src/extensions/NavLogoBlueprint.ts rename to packages/frontend-plugin-api/src/blueprints/NavLogoBlueprint.ts index d119287f29..f31b3cec9b 100644 --- a/packages/frontend-plugin-api/src/extensions/NavLogoBlueprint.ts +++ b/packages/frontend-plugin-api/src/blueprints/NavLogoBlueprint.ts @@ -15,8 +15,9 @@ */ import { createExtensionBlueprint } from '../wiring'; -import { createNavLogoExtension } from './createNavLogoExtension'; +import { createNavLogoExtension } from '../extensions/createNavLogoExtension'; +/** @public */ export const NavLogoBlueprint = createExtensionBlueprint({ kind: 'nav-logo', attachTo: { id: 'app/nav', input: 'logos' }, diff --git a/packages/frontend-plugin-api/src/extensions/PageBlueprint.test.tsx b/packages/frontend-plugin-api/src/blueprints/PageBlueprint.test.tsx similarity index 98% rename from packages/frontend-plugin-api/src/extensions/PageBlueprint.test.tsx rename to packages/frontend-plugin-api/src/blueprints/PageBlueprint.test.tsx index c1350b3ddb..c4bcb4b467 100644 --- a/packages/frontend-plugin-api/src/extensions/PageBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/blueprints/PageBlueprint.test.tsx @@ -106,7 +106,7 @@ describe('PageBlueprint', () => { }); it('should allow defining additional inputs to the extension', async () => { - const myPage = PageBlueprint.make({ + const myPage = PageBlueprint.makeWithOverrides({ name: 'test-page', inputs: { cards: createExtensionInput([coreExtensionData.reactElement], { diff --git a/packages/frontend-plugin-api/src/extensions/PageBlueprint.tsx b/packages/frontend-plugin-api/src/blueprints/PageBlueprint.tsx similarity index 97% rename from packages/frontend-plugin-api/src/extensions/PageBlueprint.tsx rename to packages/frontend-plugin-api/src/blueprints/PageBlueprint.tsx index 506301ffdf..bfcf4a7934 100644 --- a/packages/frontend-plugin-api/src/extensions/PageBlueprint.tsx +++ b/packages/frontend-plugin-api/src/blueprints/PageBlueprint.tsx @@ -18,6 +18,7 @@ import { RouteRef } from '../routing'; import { coreExtensionData, createExtensionBlueprint } from '../wiring'; import { ExtensionBoundary } from '../components'; +/** @public */ export const PageBlueprint = createExtensionBlueprint({ kind: 'page', attachTo: { id: 'app/routes', input: 'routes' }, @@ -37,7 +38,7 @@ export const PageBlueprint = createExtensionBlueprint({ loader, routeRef, }: { - defaultPath?: string; + defaultPath: string; loader: () => Promise; routeRef?: RouteRef; }, @@ -47,7 +48,7 @@ export const PageBlueprint = createExtensionBlueprint({ loader().then(element => ({ default: () => element })), ); - yield coreExtensionData.routePath(config.path ?? defaultPath!); + yield coreExtensionData.routePath(config.path ?? defaultPath); yield coreExtensionData.reactElement( diff --git a/packages/frontend-plugin-api/src/extensions/RouterBlueprint.test.tsx b/packages/frontend-plugin-api/src/blueprints/RouterBlueprint.test.tsx similarity index 98% rename from packages/frontend-plugin-api/src/extensions/RouterBlueprint.test.tsx rename to packages/frontend-plugin-api/src/blueprints/RouterBlueprint.test.tsx index 018c3fc570..fe40aaa8d7 100644 --- a/packages/frontend-plugin-api/src/extensions/RouterBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/blueprints/RouterBlueprint.test.tsx @@ -97,7 +97,7 @@ describe('RouterBlueprint', () => { }); it('should work with complex options and props', async () => { - const extension = RouterBlueprint.make({ + const extension = RouterBlueprint.makeWithOverrides({ namespace: 'test', name: 'test', config: { diff --git a/packages/frontend-plugin-api/src/extensions/RouterBlueprint.tsx b/packages/frontend-plugin-api/src/blueprints/RouterBlueprint.tsx similarity index 92% rename from packages/frontend-plugin-api/src/extensions/RouterBlueprint.tsx rename to packages/frontend-plugin-api/src/blueprints/RouterBlueprint.tsx index e584a5654c..24ee805659 100644 --- a/packages/frontend-plugin-api/src/extensions/RouterBlueprint.tsx +++ b/packages/frontend-plugin-api/src/blueprints/RouterBlueprint.tsx @@ -15,8 +15,9 @@ */ import { ComponentType, PropsWithChildren } from 'react'; import { createExtensionBlueprint } from '../wiring'; -import { createRouterExtension } from './createRouterExtension'; +import { createRouterExtension } from '../extensions/createRouterExtension'; +/** @public */ export const RouterBlueprint = createExtensionBlueprint({ kind: 'app-router-component', attachTo: { id: 'app/root', input: 'router' }, diff --git a/packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.test.tsx b/packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.test.tsx similarity index 100% rename from packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.test.tsx rename to packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.test.tsx diff --git a/packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.tsx b/packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.tsx similarity index 93% rename from packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.tsx rename to packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.tsx index fc779f58ab..2727335d8a 100644 --- a/packages/frontend-plugin-api/src/extensions/SignInPageBlueprint.tsx +++ b/packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.tsx @@ -15,10 +15,11 @@ */ import React, { ComponentType, lazy } from 'react'; import { createExtensionBlueprint } from '../wiring'; -import { createSignInPageExtension } from './createSignInPageExtension'; +import { createSignInPageExtension } from '../extensions/createSignInPageExtension'; import { SignInPageProps } from '@backstage/core-plugin-api'; import { ExtensionBoundary } from '../components'; +/** @public */ export const SignInPageBlueprint = createExtensionBlueprint({ kind: 'sign-in-page', attachTo: { id: 'app/root', input: 'signInPage' }, diff --git a/packages/frontend-plugin-api/src/extensions/ThemeBlueprint.test.ts b/packages/frontend-plugin-api/src/blueprints/ThemeBlueprint.test.ts similarity index 94% rename from packages/frontend-plugin-api/src/extensions/ThemeBlueprint.test.ts rename to packages/frontend-plugin-api/src/blueprints/ThemeBlueprint.test.ts index 92acd8eeba..40323b6a31 100644 --- a/packages/frontend-plugin-api/src/extensions/ThemeBlueprint.test.ts +++ b/packages/frontend-plugin-api/src/blueprints/ThemeBlueprint.test.ts @@ -27,7 +27,8 @@ describe('ThemeBlueprint', () => { } as AppTheme; it('should create an extension with sensible defaults', () => { - expect(ThemeBlueprint.make({ params: { theme } })).toMatchInlineSnapshot(` + expect(ThemeBlueprint.make({ name: 'light', params: { theme } })) + .toMatchInlineSnapshot(` { "$$type": "@backstage/ExtensionDefinition", "attachTo": { diff --git a/packages/frontend-plugin-api/src/extensions/ThemeBlueprint.ts b/packages/frontend-plugin-api/src/blueprints/ThemeBlueprint.ts similarity index 91% rename from packages/frontend-plugin-api/src/extensions/ThemeBlueprint.ts rename to packages/frontend-plugin-api/src/blueprints/ThemeBlueprint.ts index 500946713b..cd97e0437f 100644 --- a/packages/frontend-plugin-api/src/extensions/ThemeBlueprint.ts +++ b/packages/frontend-plugin-api/src/blueprints/ThemeBlueprint.ts @@ -16,12 +16,12 @@ import { AppTheme } from '@backstage/core-plugin-api'; import { createExtensionBlueprint } from '../wiring'; -import { createThemeExtension } from './createThemeExtension'; +import { createThemeExtension } from '../extensions/createThemeExtension'; +/** @public */ export const ThemeBlueprint = createExtensionBlueprint({ kind: 'theme', namespace: 'app', - name: ({ theme }) => theme.id, attachTo: { id: 'app', input: 'themes' }, output: [createThemeExtension.themeDataRef], dataRefs: { diff --git a/packages/frontend-plugin-api/src/extensions/TranslationBlueprint.test.ts b/packages/frontend-plugin-api/src/blueprints/TranslationBlueprint.test.ts similarity index 98% rename from packages/frontend-plugin-api/src/extensions/TranslationBlueprint.test.ts rename to packages/frontend-plugin-api/src/blueprints/TranslationBlueprint.test.ts index e2a979c097..dfb918053a 100644 --- a/packages/frontend-plugin-api/src/extensions/TranslationBlueprint.test.ts +++ b/packages/frontend-plugin-api/src/blueprints/TranslationBlueprint.test.ts @@ -56,7 +56,7 @@ describe('TranslationBlueprint', () => { "inputs": {}, "kind": "translation", "name": "blob", - "namespace": "translationRefId", + "namespace": undefined, "output": [ [Function], ], diff --git a/packages/frontend-plugin-api/src/extensions/TranslationBlueprint.ts b/packages/frontend-plugin-api/src/blueprints/TranslationBlueprint.ts similarity index 90% rename from packages/frontend-plugin-api/src/extensions/TranslationBlueprint.ts rename to packages/frontend-plugin-api/src/blueprints/TranslationBlueprint.ts index 581f4d176a..c70ca56f6b 100644 --- a/packages/frontend-plugin-api/src/extensions/TranslationBlueprint.ts +++ b/packages/frontend-plugin-api/src/blueprints/TranslationBlueprint.ts @@ -15,12 +15,12 @@ */ import { createExtensionBlueprint } from '../wiring'; -import { createTranslationExtension } from './createTranslationExtension'; +import { createTranslationExtension } from '../extensions/createTranslationExtension'; import { TranslationMessages, TranslationResource } from '../translation'; +/** @public */ export const TranslationBlueprint = createExtensionBlueprint({ kind: 'translation', - namespace: ({ resource }) => resource.id, attachTo: { id: 'app', input: 'translations' }, output: [createTranslationExtension.translationDataRef], dataRefs: { diff --git a/packages/frontend-plugin-api/src/blueprints/index.ts b/packages/frontend-plugin-api/src/blueprints/index.ts new file mode 100644 index 0000000000..85f7a99a2c --- /dev/null +++ b/packages/frontend-plugin-api/src/blueprints/index.ts @@ -0,0 +1,27 @@ +/* + * Copyright 2024 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 { ApiBlueprint } from './ApiBlueprint'; +export { AppRootElementBlueprint } from './AppRootElementBlueprint'; +export { AppRootWrapperBlueprint } from './AppRootWrapperBlueprint'; +export { IconBundleBlueprint } from './IconBundleBlueprint'; +export { NavItemBlueprint } from './NavItemBlueprint'; +export { NavLogoBlueprint } from './NavLogoBlueprint'; +export { PageBlueprint } from './PageBlueprint'; +export { RouterBlueprint } from './RouterBlueprint'; +export { SignInPageBlueprint } from './SignInPageBlueprint'; +export { ThemeBlueprint } from './ThemeBlueprint'; +export { TranslationBlueprint } from './TranslationBlueprint'; diff --git a/packages/frontend-plugin-api/src/extensions/createApiExtension.ts b/packages/frontend-plugin-api/src/extensions/createApiExtension.ts index 93346f1ec9..b1db2a0106 100644 --- a/packages/frontend-plugin-api/src/extensions/createApiExtension.ts +++ b/packages/frontend-plugin-api/src/extensions/createApiExtension.ts @@ -24,7 +24,10 @@ import { import { AnyExtensionInputMap } from '../wiring/createExtension'; import { Expand } from '../types'; -/** @public */ +/** + * @public + * @deprecated Use {@link ApiBlueprint} instead. + */ export function createApiExtension< TConfig extends {}, TInputs extends AnyExtensionInputMap, diff --git a/packages/frontend-plugin-api/src/extensions/createAppRootElementExtension.ts b/packages/frontend-plugin-api/src/extensions/createAppRootElementExtension.ts index 8be82d5540..c8f7bdc366 100644 --- a/packages/frontend-plugin-api/src/extensions/createAppRootElementExtension.ts +++ b/packages/frontend-plugin-api/src/extensions/createAppRootElementExtension.ts @@ -30,6 +30,7 @@ import { * the app layout. This is useful for example for shared popups and similar. * * @public + * @deprecated Use {@link AppRootElementBlueprint} instead. */ export function createAppRootElementExtension< TConfig extends {}, diff --git a/packages/frontend-plugin-api/src/extensions/createAppRootWrapperExtension.tsx b/packages/frontend-plugin-api/src/extensions/createAppRootWrapperExtension.tsx index ce2eb89f25..4f70f29470 100644 --- a/packages/frontend-plugin-api/src/extensions/createAppRootWrapperExtension.tsx +++ b/packages/frontend-plugin-api/src/extensions/createAppRootWrapperExtension.tsx @@ -31,6 +31,7 @@ import { Expand } from '../types'; * and similar. * * @public + * @deprecated Use {@link AppRootWrapperBlueprint} instead. */ export function createAppRootWrapperExtension< TConfig extends {}, diff --git a/packages/frontend-plugin-api/src/extensions/createNavItemExtension.tsx b/packages/frontend-plugin-api/src/extensions/createNavItemExtension.tsx index 2a2c47835a..d694440427 100644 --- a/packages/frontend-plugin-api/src/extensions/createNavItemExtension.tsx +++ b/packages/frontend-plugin-api/src/extensions/createNavItemExtension.tsx @@ -21,7 +21,9 @@ import { RouteRef } from '../routing'; /** * Helper for creating extensions for a nav item. + * * @public + * @deprecated Use {@link NavItemBlueprint} instead. */ export function createNavItemExtension(options: { namespace?: string; diff --git a/packages/frontend-plugin-api/src/extensions/createNavLogoExtension.tsx b/packages/frontend-plugin-api/src/extensions/createNavLogoExtension.tsx index 1f2419bd02..02c32e7f34 100644 --- a/packages/frontend-plugin-api/src/extensions/createNavLogoExtension.tsx +++ b/packages/frontend-plugin-api/src/extensions/createNavLogoExtension.tsx @@ -18,7 +18,9 @@ import { createExtension, createExtensionDataRef } from '../wiring'; /** * Helper for creating extensions for a nav logos. + * * @public + * @deprecated Use {@link NavLogoBlueprint} instead. */ export function createNavLogoExtension(options: { name?: string; diff --git a/packages/frontend-plugin-api/src/extensions/createPageExtension.tsx b/packages/frontend-plugin-api/src/extensions/createPageExtension.tsx index cd434a3ffc..bef642e465 100644 --- a/packages/frontend-plugin-api/src/extensions/createPageExtension.tsx +++ b/packages/frontend-plugin-api/src/extensions/createPageExtension.tsx @@ -31,6 +31,7 @@ import { ExtensionDefinition } from '../wiring/createExtension'; * Helper for creating extensions for a routable React page component. * * @public + * @deprecated Use {@link PageBlueprint} instead. */ export function createPageExtension< TConfig extends { path: string }, diff --git a/packages/frontend-plugin-api/src/extensions/createRouterExtension.tsx b/packages/frontend-plugin-api/src/extensions/createRouterExtension.tsx index 12f946e8a7..943711f5e0 100644 --- a/packages/frontend-plugin-api/src/extensions/createRouterExtension.tsx +++ b/packages/frontend-plugin-api/src/extensions/createRouterExtension.tsx @@ -31,6 +31,7 @@ import { Expand } from '../types'; * MemoryRouter in tests, or to add additional props to a BrowserRouter. * * @public + * @deprecated Use {@link RouterBlueprint} instead. */ export function createRouterExtension< TConfig extends {}, diff --git a/packages/frontend-plugin-api/src/extensions/createSignInPageExtension.tsx b/packages/frontend-plugin-api/src/extensions/createSignInPageExtension.tsx index 312d30c78c..3f41202f11 100644 --- a/packages/frontend-plugin-api/src/extensions/createSignInPageExtension.tsx +++ b/packages/frontend-plugin-api/src/extensions/createSignInPageExtension.tsx @@ -30,6 +30,7 @@ import { SignInPageProps } from '@backstage/core-plugin-api'; /** * * @public + * @deprecated Use {@link SignInPageBlueprint} instead. */ export function createSignInPageExtension< TConfig extends {}, diff --git a/packages/frontend-plugin-api/src/extensions/createThemeExtension.ts b/packages/frontend-plugin-api/src/extensions/createThemeExtension.ts index 1740f05a5a..e523fd9c05 100644 --- a/packages/frontend-plugin-api/src/extensions/createThemeExtension.ts +++ b/packages/frontend-plugin-api/src/extensions/createThemeExtension.ts @@ -17,7 +17,10 @@ import { createExtension, createExtensionDataRef } from '../wiring'; import { AppTheme } from '@backstage/core-plugin-api'; -/** @public */ +/** + * @public + * @deprecated Use {@link ThemeBlueprint} instead. + */ export function createThemeExtension(theme: AppTheme) { return createExtension({ kind: 'theme', @@ -31,7 +34,10 @@ export function createThemeExtension(theme: AppTheme) { }); } -/** @public */ +/** + * @public + * @deprecated Use {@link ThemeBlueprint} instead. + */ export namespace createThemeExtension { export const themeDataRef = createExtensionDataRef().with({ id: 'core.theme.theme', diff --git a/packages/frontend-plugin-api/src/extensions/createTranslationExtension.ts b/packages/frontend-plugin-api/src/extensions/createTranslationExtension.ts index 9445e32e24..c4d2f6037d 100644 --- a/packages/frontend-plugin-api/src/extensions/createTranslationExtension.ts +++ b/packages/frontend-plugin-api/src/extensions/createTranslationExtension.ts @@ -17,7 +17,10 @@ import { TranslationMessages, TranslationResource } from '../translation'; import { createExtension, createExtensionDataRef } from '../wiring'; -/** @public */ +/** + * @public + * @deprecated Use {@link TranslationBlueprint} instead. + */ export function createTranslationExtension(options: { name?: string; resource: TranslationResource | TranslationMessages; @@ -34,7 +37,10 @@ export function createTranslationExtension(options: { }); } -/** @public */ +/** + * @public + * @deprecated Use {@link TranslationBlueprint} instead. + */ export namespace createTranslationExtension { export const translationDataRef = createExtensionDataRef< TranslationResource | TranslationMessages diff --git a/packages/frontend-plugin-api/src/extensions/index.ts b/packages/frontend-plugin-api/src/extensions/index.ts index 267201db81..562cb728cb 100644 --- a/packages/frontend-plugin-api/src/extensions/index.ts +++ b/packages/frontend-plugin-api/src/extensions/index.ts @@ -25,4 +25,3 @@ export { createSignInPageExtension } from './createSignInPageExtension'; export { createThemeExtension } from './createThemeExtension'; export { createComponentExtension } from './createComponentExtension'; export { createTranslationExtension } from './createTranslationExtension'; -export { IconBundleBlueprint } from './IconBundleBlueprint'; diff --git a/packages/frontend-plugin-api/src/index.ts b/packages/frontend-plugin-api/src/index.ts index 263380b1f8..957ca50bba 100644 --- a/packages/frontend-plugin-api/src/index.ts +++ b/packages/frontend-plugin-api/src/index.ts @@ -22,6 +22,7 @@ export * from './analytics'; export * from './apis'; +export * from './blueprints'; export * from './components'; export * from './extensions'; export * from './icons'; diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx index 924eba2cba..b9d1475074 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx @@ -127,7 +127,7 @@ describe('createExtensionBlueprint', () => { }, }); - const extension = TestExtensionBlueprint.make({ + const extension = TestExtensionBlueprint.makeWithOverrides({ name: 'my-extension', factory(origFactory) { return origFactory({ @@ -185,11 +185,8 @@ describe('createExtensionBlueprint', () => { }, }); - const extension = TestExtensionBlueprint.make({ + const extension = TestExtensionBlueprint.makeWithOverrides({ name: 'my-extension', - params: { - text: 'Hello, world!', - }, config: { schema: { something: z => z.string(), @@ -236,7 +233,7 @@ describe('createExtensionBlueprint', () => { }, }); - TestExtensionBlueprint.make({ + TestExtensionBlueprint.makeWithOverrides({ name: 'my-extension', params: { text: 'Hello, world!', @@ -266,11 +263,8 @@ describe('createExtensionBlueprint', () => { }, }); - const extension = TestExtensionBlueprint.make({ + const extension = TestExtensionBlueprint.makeWithOverrides({ name: 'my-extension', - params: { - text: 'Hello, world!', - }, config: { schema: { something: z => z.string(), @@ -341,65 +335,6 @@ describe('createExtensionBlueprint', () => { expect(true).toBe(true); }); - it('should allow providing callback for properties to set with params', () => { - type TestParams = { test: string }; - - const Blueprint = createExtensionBlueprint({ - kind: 'test-extension', - attachTo: { id: 'test', input: 'default' }, - name: (params: TestParams) => `${params.test}-name`, - output: [coreExtensionData.reactElement], - namespace: (props: TestParams) => props.test, - config: { - schema: (props: TestParams) => ({ - test: z => z.string().default(props.test), - }), - }, - factory(params: TestParams) { - return [coreExtensionData.reactElement(
    {params.test}
    )]; - }, - }); - - expect(Blueprint.make({ params: { test: 'hello' } })) - .toMatchInlineSnapshot(` - { - "$$type": "@backstage/ExtensionDefinition", - "attachTo": { - "id": "test", - "input": "default", - }, - "configSchema": { - "parse": [Function], - "schema": { - "$schema": "http://json-schema.org/draft-07/schema#", - "additionalProperties": false, - "properties": { - "test": { - "default": "hello", - "type": "string", - }, - }, - "type": "object", - }, - }, - "disabled": false, - "factory": [Function], - "inputs": {}, - "kind": "test-extension", - "name": "hello-name", - "namespace": "hello", - "output": [ - [Function], - ], - "override": [Function], - "toString": [Function], - "version": "v2", - } - `); - - expect(true).toBe(true); - }); - it('should allow merging of inputs', () => { const blueprint = createExtensionBlueprint({ kind: 'test-extension', @@ -418,7 +353,7 @@ describe('createExtensionBlueprint', () => { }, }); - blueprint.make({ + blueprint.makeWithOverrides({ inputs: { test2: createExtensionInput([coreExtensionData.reactElement], { singleton: true, @@ -453,7 +388,7 @@ describe('createExtensionBlueprint', () => { }, }); - blueprint.make({ + blueprint.makeWithOverrides({ inputs: { // @ts-expect-error test: createExtensionInput([]), // Overrides are not allowed @@ -480,7 +415,7 @@ describe('createExtensionBlueprint', () => { }); const ext = toInternalExtensionDefinition( - blueprint.make({ + blueprint.makeWithOverrides({ output: [testDataRef2], factory(origFactory) { const parent = origFactory({}); @@ -509,7 +444,7 @@ describe('createExtensionBlueprint', () => { expect( factoryOutput( - blueprint.make({ + blueprint.makeWithOverrides({ output: [testDataRef1, testDataRef2], *factory(origFactory) { yield* origFactory({}); @@ -521,7 +456,7 @@ describe('createExtensionBlueprint', () => { expect( factoryOutput( - blueprint.make({ + blueprint.makeWithOverrides({ output: [testDataRef1, testDataRef2], factory(origFactory) { return [...origFactory({}), testDataRef2('bar')]; @@ -544,9 +479,9 @@ describe('createExtensionBlueprint', () => { }, }); - // @ts-expect-error - blueprint.make({ + blueprint.makeWithOverrides({ output: [testDataRef2.optional()], + // @ts-expect-error *factory() { yield testDataRef1('foo'); yield testDataRef2('bar'); @@ -555,7 +490,7 @@ describe('createExtensionBlueprint', () => { expect( factoryOutput( - blueprint.make({ + blueprint.makeWithOverrides({ output: [testDataRef2.optional()], *factory() { yield testDataRef2('bar'); @@ -578,9 +513,9 @@ describe('createExtensionBlueprint', () => { }, }); - // @ts-expect-error - blueprint.make({ + blueprint.makeWithOverrides({ output: [testDataRef1, testDataRef2], + // @ts-expect-error *factory(origFactory) { yield* origFactory({}); }, @@ -588,7 +523,7 @@ describe('createExtensionBlueprint', () => { expect( factoryOutput( - blueprint.make({ + blueprint.makeWithOverrides({ output: [testDataRef1, testDataRef2], *factory(origFactory) { yield* origFactory({}); diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts index f749f7d412..656e681a2b 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts @@ -52,14 +52,14 @@ export type CreateExtensionBlueprintOptions< TDataRefs extends { [name in string]: AnyExtensionDataRef }, > = { kind: TKind; - namespace?: TNamespace | ((params: TParams) => TNamespace); + namespace?: TNamespace; attachTo: { id: string; input: string }; disabled?: boolean; inputs?: TInputs; output: Array; - name?: TName | ((params: TParams) => TName); + name?: TName; config?: { - schema: TConfigSchema | ((params: TParams) => TConfigSchema); + schema: TConfigSchema; }; factory( params: TParams, @@ -96,13 +96,32 @@ export interface ExtensionBlueprint< > { dataRefs: TDataRefs; + make< + TNewNamespace extends string | undefined, + TNewName extends string | undefined, + >(args: { + namespace?: TNewNamespace; + name?: TNewName; + attachTo?: { id: string; input: string }; + disabled?: boolean; + params: TParams; + }): ExtensionDefinition< + TConfig, + TConfigInput, + UOutput, + TInputs, + TKind, + string | undefined extends TNewNamespace ? TNamespace : TNewNamespace, + string | undefined extends TNewName ? TName : TNewName + >; + /** * Creates a new extension from the blueprint. * * You must either pass `params` directly, or define a `factory` that can * optionally call the original factory with the same params. */ - make< + makeWithOverrides< TNewNamespace extends string | undefined, TNewName extends string | undefined, TExtensionConfigSchema extends { @@ -116,52 +135,45 @@ export interface ExtensionBlueprint< { optional: boolean; singleton: boolean } >; }, - >( - args: { - namespace?: TNewNamespace; - name?: TNewName; - attachTo?: { id: string; input: string }; - disabled?: boolean; - inputs?: TExtraInputs & { - [KName in keyof TInputs]?: `Error: Input '${KName & - string}' is already defined in parent definition`; + >(args: { + namespace?: TNewNamespace; + name?: TNewName; + attachTo?: { id: string; input: string }; + disabled?: boolean; + inputs?: TExtraInputs & { + [KName in keyof TInputs]?: `Error: Input '${KName & + string}' is already defined in parent definition`; + }; + output?: Array; + config?: { + schema: TExtensionConfigSchema & { + [KName in keyof TConfig]?: `Error: Config key '${KName & + string}' is already defined in parent schema`; }; - output?: Array; - config?: { - schema: TExtensionConfigSchema & { - [KName in keyof TConfig]?: `Error: Config key '${KName & - string}' is already defined in parent schema`; + }; + factory( + originalFactory: ( + params: TParams, + context?: { + config?: TConfig; + inputs?: Expand>; + }, + ) => ExtensionDataContainer, + context: { + node: AppNode; + config: TConfig & { + [key in keyof TExtensionConfigSchema]: z.infer< + ReturnType + >; }; - }; - } & ( - | ({ - factory( - originalFactory: ( - params: TParams, - context?: { - config?: TConfig; - inputs?: Expand>; - }, - ) => ExtensionDataContainer, - context: { - node: AppNode; - config: TConfig & { - [key in keyof TExtensionConfigSchema]: z.infer< - ReturnType - >; - }; - inputs: Expand>; - }, - ): Iterable; - } & VerifyExtensionFactoryOutput< - AnyExtensionDataRef extends UNewOutput ? UOutput : UNewOutput, - UFactoryOutput - >) - | { - params: TParams; - } - ), - ): ExtensionDefinition< + inputs: Expand>; + }, + ): Iterable & + VerifyExtensionFactoryOutput< + AnyExtensionDataRef extends UNewOutput ? UOutput : UNewOutput, + UFactoryOutput + >; + }): ExtensionDefinition< { [key in keyof TExtensionConfigSchema]: z.infer< ReturnType @@ -243,7 +255,7 @@ class ExtensionBlueprintImpl< dataRefs: TDataRefs; - public make< + public makeWithOverrides< TExtensionConfigSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType; }, @@ -264,11 +276,10 @@ class ExtensionBlueprintImpl< disabled?: boolean; inputs?: TExtraInputs; output?: Array; - params?: TParams; config?: { schema: TExtensionConfigSchema; }; - factory?( + factory( originalFactory: ( params: TParams, context?: { @@ -312,77 +323,82 @@ class ExtensionBlueprintImpl< > > > { - const optionsSchema = // can remove this args.params check with the split apart of .make - typeof this.options.config?.schema === 'function' && args.params - ? this.options.config?.schema(args.params) - : this.options.config?.schema; - const schema = { - ...optionsSchema, + ...this.options.config?.schema, ...args.config?.schema, } as TConfigSchema & TExtensionConfigSchema; - const namespace = - typeof this.options.namespace === 'function' && args.params - ? this.options.namespace(args.params) - : this.options.namespace; - - const name = - typeof this.options.name === 'function' && args.params - ? this.options.name(args.params) - : this.options.name; - return createExtension({ kind: this.options.kind, - namespace: args.namespace ?? namespace, - name: args.name ?? name, + namespace: args.namespace ?? this.options.namespace, + name: args.name ?? this.options.name, attachTo: args.attachTo ?? this.options.attachTo, disabled: args.disabled ?? this.options.disabled, inputs: { ...args.inputs, ...this.options.inputs }, output: args.output ?? this.options.output, config: Object.keys(schema).length === 0 ? undefined : { schema }, factory: ({ node, config, inputs }) => { - if (args.factory) { - return args.factory( - ( - innerParams: TParams, - innerContext?: { - config?: { - [key in keyof TConfigSchema]: z.infer< - ReturnType - >; - }; - inputs?: Expand>; - }, - ): ExtensionDataContainer => { - return createDataContainer( - this.options.factory(innerParams, { - node, - config: innerContext?.config ?? config, - inputs: (innerContext?.inputs ?? inputs) as any, // TODO: Fix the way input values are overridden - }), - ); + return args.factory( + ( + innerParams: TParams, + innerContext?: { + config?: { + [key in keyof TConfigSchema]: z.infer< + ReturnType + >; + }; + inputs?: Expand>; }, - { - node, - config, - inputs, - }, - ); - } else if (args.params) { - return this.options.factory(args.params, { + ): ExtensionDataContainer => { + return createDataContainer( + this.options.factory(innerParams, { + node, + config: innerContext?.config ?? config, + inputs: (innerContext?.inputs ?? inputs) as any, // TODO: Fix the way input values are overridden + }), + ); + }, + { node, config, - // TODO: Figure out types once legacy data map input type is gone - inputs: inputs as unknown as Expand< - ResolvedExtensionInputs - >, - }); - } - throw new Error('Either params or factory must be provided'); + inputs, + }, + ); }, } as CreateExtensionOptions); } + + public make< + TNewNamespace extends string | undefined = undefined, + TNewName extends string | undefined = undefined, + >(args: { + namespace?: TNewNamespace; + name?: TNewName; + attachTo?: { id: string; input: string }; + disabled?: boolean; + params: TParams; + }): ExtensionDefinition< + { + [key in keyof TConfigSchema]: z.infer>; + }, + z.input< + z.ZodObject<{ + [key in keyof TConfigSchema]: ReturnType; + }> + > + > { + return createExtension({ + kind: this.options.kind, + namespace: args.namespace ?? this.options.namespace, + name: args.name ?? this.options.name, + attachTo: args.attachTo ?? this.options.attachTo, + disabled: args.disabled ?? this.options.disabled, + inputs: this.options.inputs, + output: this.options.output, + config: this.options.config, + factory: ctx => this.options.factory(args.params, ctx), + } as CreateExtensionOptions); + } } /** diff --git a/packages/frontend-test-utils/src/app/createExtensionTester.tsx b/packages/frontend-test-utils/src/app/createExtensionTester.tsx index ce7da3701d..4bfc8392cb 100644 --- a/packages/frontend-test-utils/src/app/createExtensionTester.tsx +++ b/packages/frontend-test-utils/src/app/createExtensionTester.tsx @@ -19,7 +19,6 @@ import { MemoryRouter, Link } from 'react-router-dom'; import { RenderResult, render } from '@testing-library/react'; import { createSpecializedApp } from '@backstage/frontend-app-api'; import { - ExtensionDataValue, AppNode, AppTree, Extension, @@ -169,9 +168,7 @@ export class ExtensionTester { : [...internal.output, coreExtensionData.routePath], factory: params => { const parentOutput = Array.from( - internal.factory(params as any) as Iterable< - ExtensionDataValue - >, + internal.factory(params as any), ).filter(val => val.id !== coreExtensionData.routePath.id); return [...parentOutput, coreExtensionData.routePath('/')]; From 264e10f9cd1ae5cf0666f5e5f207d17e91a5b476 Mon Sep 17 00:00:00 2001 From: blam Date: Fri, 9 Aug 2024 15:43:33 +0200 Subject: [PATCH 214/372] chore: added changeset Signed-off-by: blam --- .changeset/tiny-dodos-prove-2.md | 5 +++++ .changeset/tiny-dodos-prove.md | 9 +++++++++ 2 files changed, 14 insertions(+) create mode 100644 .changeset/tiny-dodos-prove-2.md create mode 100644 .changeset/tiny-dodos-prove.md diff --git a/.changeset/tiny-dodos-prove-2.md b/.changeset/tiny-dodos-prove-2.md new file mode 100644 index 0000000000..91ac021c67 --- /dev/null +++ b/.changeset/tiny-dodos-prove-2.md @@ -0,0 +1,5 @@ +--- +'@backstage/frontend-test-utils': patch +--- + +Deprecate existing `ExtensionCreators` in favour of their new Blueprint counterparts. diff --git a/.changeset/tiny-dodos-prove.md b/.changeset/tiny-dodos-prove.md new file mode 100644 index 0000000000..6392e5050e --- /dev/null +++ b/.changeset/tiny-dodos-prove.md @@ -0,0 +1,9 @@ +--- +'@backstage/frontend-test-utils': patch +--- + +Refactor `.make` method on Blueprints into two different methods, `.make` and `.makeWithOverrides`. + +When using `createExtensionBlueprint` you can define parameters for the factory function, if you wish to take advantage of these parameters you should use `.make` when creating an extension instance of a Blueprint. If you wish to override more things other than the standard `attachTo`, `name`, `namespace` then you should use `.makeWithOverrides` instead. + +`.make` is reserved for simple creation of extension instances from Blueprints using higher level parameters, whereas `.makeWithOverrides` is lower level and you have more control over the final extension. From 0e615076857067573e03b8d13ea0e250083ae54e Mon Sep 17 00:00:00 2001 From: blam Date: Fri, 9 Aug 2024 15:45:57 +0200 Subject: [PATCH 215/372] chore: updating api-reports and documentation for exported blueprints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Patrik Oldsberg Co-authored-by: Fredrik Adelöw Co-authored-by: Camila Belo Signed-off-by: blam --- packages/frontend-plugin-api/api-report.md | 18 +++++++++--------- .../src/blueprints/ApiBlueprint.ts | 7 ++++++- .../src/blueprints/AppRootElementBlueprint.ts | 7 ++++++- .../src/blueprints/AppRootWrapperBlueprint.tsx | 8 +++++++- .../src/blueprints/NavItemBlueprint.ts | 6 +++++- .../src/blueprints/NavLogoBlueprint.ts | 6 +++++- .../src/blueprints/PageBlueprint.tsx | 6 +++++- .../src/blueprints/SignInPageBlueprint.tsx | 6 +++++- .../src/blueprints/ThemeBlueprint.ts | 6 +++++- .../src/blueprints/TranslationBlueprint.ts | 6 +++++- 10 files changed, 58 insertions(+), 18 deletions(-) diff --git a/packages/frontend-plugin-api/api-report.md b/packages/frontend-plugin-api/api-report.md index 2d3f1d3278..f39add924a 100644 --- a/packages/frontend-plugin-api/api-report.md +++ b/packages/frontend-plugin-api/api-report.md @@ -189,7 +189,7 @@ export type AnyRoutes = { [name in string]: RouteRef | SubRouteRef; }; -// @public (undocumented) +// @public export const ApiBlueprint: ExtensionBlueprint< 'api', undefined, @@ -261,7 +261,7 @@ export interface AppNodeSpec { readonly source?: BackstagePlugin; } -// @public (undocumented) +// @public export const AppRootElementBlueprint: ExtensionBlueprint< 'app-root-element', undefined, @@ -276,7 +276,7 @@ export const AppRootElementBlueprint: ExtensionBlueprint< never >; -// @public (undocumented) +// @public export const AppRootWrapperBlueprint: ExtensionBlueprint< 'app-root-wrapper', undefined, @@ -1696,7 +1696,7 @@ export interface LegacyExtensionInput< export { microsoftAuthApiRef }; -// @public (undocumented) +// @public export const NavItemBlueprint: ExtensionBlueprint< 'nav-item', undefined, @@ -1731,7 +1731,7 @@ export const NavItemBlueprint: ExtensionBlueprint< } >; -// @public (undocumented) +// @public export const NavLogoBlueprint: ExtensionBlueprint< 'nav-logo', undefined, @@ -1781,7 +1781,7 @@ export { oneloginAuthApiRef }; export { OpenIdConnectApi }; -// @public (undocumented) +// @public export const PageBlueprint: ExtensionBlueprint< 'page', undefined, @@ -1938,7 +1938,7 @@ export { SessionApi }; export { SessionState }; -// @public (undocumented) +// @public export const SignInPageBlueprint: ExtensionBlueprint< 'sign-in-page', undefined, @@ -1981,7 +1981,7 @@ export interface SubRouteRef< readonly T: TParams; } -// @public (undocumented) +// @public export const ThemeBlueprint: ExtensionBlueprint< 'theme', 'app', @@ -1998,7 +1998,7 @@ export const ThemeBlueprint: ExtensionBlueprint< } >; -// @public (undocumented) +// @public export const TranslationBlueprint: ExtensionBlueprint< 'translation', undefined, diff --git a/packages/frontend-plugin-api/src/blueprints/ApiBlueprint.ts b/packages/frontend-plugin-api/src/blueprints/ApiBlueprint.ts index da12faef1a..b5ba9e05f6 100644 --- a/packages/frontend-plugin-api/src/blueprints/ApiBlueprint.ts +++ b/packages/frontend-plugin-api/src/blueprints/ApiBlueprint.ts @@ -13,11 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import { createExtensionBlueprint } from '../wiring'; import { createApiExtension } from '../extensions/createApiExtension'; import { AnyApiFactory } from '@backstage/core-plugin-api'; -/** @public */ +/** + * Creates utility API extensions. + * + * @public + */ export const ApiBlueprint = createExtensionBlueprint({ kind: 'api', attachTo: { id: 'app', input: 'apis' }, diff --git a/packages/frontend-plugin-api/src/blueprints/AppRootElementBlueprint.ts b/packages/frontend-plugin-api/src/blueprints/AppRootElementBlueprint.ts index e44942979d..bc6304923a 100644 --- a/packages/frontend-plugin-api/src/blueprints/AppRootElementBlueprint.ts +++ b/packages/frontend-plugin-api/src/blueprints/AppRootElementBlueprint.ts @@ -15,7 +15,12 @@ */ import { coreExtensionData, createExtensionBlueprint } from '../wiring'; -/** @public */ +/** + * Creates extensions that render a React element at the app root, outside of + * the app layout. This is useful for example for shared popups and similar. + * + * @public + */ export const AppRootElementBlueprint = createExtensionBlueprint({ kind: 'app-root-element', attachTo: { id: 'app/root', input: 'elements' }, diff --git a/packages/frontend-plugin-api/src/blueprints/AppRootWrapperBlueprint.tsx b/packages/frontend-plugin-api/src/blueprints/AppRootWrapperBlueprint.tsx index db63550880..c54686f54f 100644 --- a/packages/frontend-plugin-api/src/blueprints/AppRootWrapperBlueprint.tsx +++ b/packages/frontend-plugin-api/src/blueprints/AppRootWrapperBlueprint.tsx @@ -19,7 +19,13 @@ import { ComponentType, PropsWithChildren } from 'react'; import { createExtensionBlueprint } from '../wiring'; import { createAppRootWrapperExtension } from '../extensions/createAppRootWrapperExtension'; -/** @public */ +/** + * Creates a extensions that render a React wrapper at the app root, enclosing + * the app layout. This is useful for example for adding global React contexts + * and similar. + * + * @public + */ export const AppRootWrapperBlueprint = createExtensionBlueprint({ kind: 'app-root-wrapper', attachTo: { id: 'app/root', input: 'wrappers' }, diff --git a/packages/frontend-plugin-api/src/blueprints/NavItemBlueprint.ts b/packages/frontend-plugin-api/src/blueprints/NavItemBlueprint.ts index 5391d0dec2..20f57421c7 100644 --- a/packages/frontend-plugin-api/src/blueprints/NavItemBlueprint.ts +++ b/packages/frontend-plugin-api/src/blueprints/NavItemBlueprint.ts @@ -19,7 +19,11 @@ import { RouteRef } from '../routing'; import { createExtensionBlueprint } from '../wiring'; import { createNavItemExtension } from '../extensions/createNavItemExtension'; -/** @public */ +/** + * Creates extensions that make up the items of the nav bar. + * + * @public + */ export const NavItemBlueprint = createExtensionBlueprint({ kind: 'nav-item', attachTo: { id: 'app/nav', input: 'items' }, diff --git a/packages/frontend-plugin-api/src/blueprints/NavLogoBlueprint.ts b/packages/frontend-plugin-api/src/blueprints/NavLogoBlueprint.ts index f31b3cec9b..8066646ca3 100644 --- a/packages/frontend-plugin-api/src/blueprints/NavLogoBlueprint.ts +++ b/packages/frontend-plugin-api/src/blueprints/NavLogoBlueprint.ts @@ -17,7 +17,11 @@ import { createExtensionBlueprint } from '../wiring'; import { createNavLogoExtension } from '../extensions/createNavLogoExtension'; -/** @public */ +/** + * Creates an extension that replaces the logo in the nav bar with your own. + * + * @public + */ export const NavLogoBlueprint = createExtensionBlueprint({ kind: 'nav-logo', attachTo: { id: 'app/nav', input: 'logos' }, diff --git a/packages/frontend-plugin-api/src/blueprints/PageBlueprint.tsx b/packages/frontend-plugin-api/src/blueprints/PageBlueprint.tsx index bfcf4a7934..b224ea491e 100644 --- a/packages/frontend-plugin-api/src/blueprints/PageBlueprint.tsx +++ b/packages/frontend-plugin-api/src/blueprints/PageBlueprint.tsx @@ -18,7 +18,11 @@ import { RouteRef } from '../routing'; import { coreExtensionData, createExtensionBlueprint } from '../wiring'; import { ExtensionBoundary } from '../components'; -/** @public */ +/** + * Createx extensions that are routable React page components. + * + * @public + */ export const PageBlueprint = createExtensionBlueprint({ kind: 'page', attachTo: { id: 'app/routes', input: 'routes' }, diff --git a/packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.tsx b/packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.tsx index 2727335d8a..f87ae91452 100644 --- a/packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.tsx +++ b/packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.tsx @@ -19,7 +19,11 @@ import { createSignInPageExtension } from '../extensions/createSignInPageExtensi import { SignInPageProps } from '@backstage/core-plugin-api'; import { ExtensionBoundary } from '../components'; -/** @public */ +/** + * Creates an extension that replaces the sign in page. + * + * @public + */ export const SignInPageBlueprint = createExtensionBlueprint({ kind: 'sign-in-page', attachTo: { id: 'app/root', input: 'signInPage' }, diff --git a/packages/frontend-plugin-api/src/blueprints/ThemeBlueprint.ts b/packages/frontend-plugin-api/src/blueprints/ThemeBlueprint.ts index cd97e0437f..686c498c06 100644 --- a/packages/frontend-plugin-api/src/blueprints/ThemeBlueprint.ts +++ b/packages/frontend-plugin-api/src/blueprints/ThemeBlueprint.ts @@ -18,7 +18,11 @@ import { AppTheme } from '@backstage/core-plugin-api'; import { createExtensionBlueprint } from '../wiring'; import { createThemeExtension } from '../extensions/createThemeExtension'; -/** @public */ +/** + * Creates an extension that adds/replaces an app theme. + * + * @public + */ export const ThemeBlueprint = createExtensionBlueprint({ kind: 'theme', namespace: 'app', diff --git a/packages/frontend-plugin-api/src/blueprints/TranslationBlueprint.ts b/packages/frontend-plugin-api/src/blueprints/TranslationBlueprint.ts index c70ca56f6b..bdb36e2191 100644 --- a/packages/frontend-plugin-api/src/blueprints/TranslationBlueprint.ts +++ b/packages/frontend-plugin-api/src/blueprints/TranslationBlueprint.ts @@ -18,7 +18,11 @@ import { createExtensionBlueprint } from '../wiring'; import { createTranslationExtension } from '../extensions/createTranslationExtension'; import { TranslationMessages, TranslationResource } from '../translation'; -/** @public */ +/** + * Creates an extension that adds translations to your app. + * + * @public + */ export const TranslationBlueprint = createExtensionBlueprint({ kind: 'translation', attachTo: { id: 'app', input: 'translations' }, From 3a35172d2ebdc977b6d5f91834f0072001761b00 Mon Sep 17 00:00:00 2001 From: Heikki Hellgren Date: Fri, 9 Aug 2024 14:18:22 +0300 Subject: [PATCH 216/372] fix: EventEmitter memory leak in development utilities Signed-off-by: Heikki Hellgren --- .changeset/new-knives-fly.md | 5 +++ packages/backend-dev-utils/src/ipcClient.ts | 43 ++++++++++++++------- 2 files changed, 33 insertions(+), 15 deletions(-) create mode 100644 .changeset/new-knives-fly.md diff --git a/.changeset/new-knives-fly.md b/.changeset/new-knives-fly.md new file mode 100644 index 0000000000..f9ac945cad --- /dev/null +++ b/.changeset/new-knives-fly.md @@ -0,0 +1,5 @@ +--- +'@backstage/backend-dev-utils': patch +--- + +Fix `EventEmitter` memory leak in the development utilities diff --git a/packages/backend-dev-utils/src/ipcClient.ts b/packages/backend-dev-utils/src/ipcClient.ts index d9ec7821de..6e1d3d181e 100644 --- a/packages/backend-dev-utils/src/ipcClient.ts +++ b/packages/backend-dev-utils/src/ipcClient.ts @@ -35,6 +35,8 @@ type Response = error: Error; }; +type ResponseHandler = (response: Response) => void; + const requestType = '@backstage/cli/channel/request'; const responseType = '@backstage/cli/channel/response'; @@ -48,21 +50,40 @@ const IPC_TIMEOUT_MS = 5000; export class BackstageIpcClient { #messageId = 0; #sendMessage: SendMessage; + #handlers: Map = new Map(); /** * Creates a new client if we're in a child process with IPC and BACKSTAGE_CLI_CHANNEL is set. */ static create(): BackstageIpcClient | undefined { const sendMessage = process.send?.bind(process); - return sendMessage && process.env.BACKSTAGE_CLI_CHANNEL - ? new BackstageIpcClient(sendMessage) - : undefined; + const client = + sendMessage && process.env.BACKSTAGE_CLI_CHANNEL + ? new BackstageIpcClient(sendMessage) + : undefined; + + if (client) { + process.on('message', (message, _sendHandle) => + client.handleMessage(message, _sendHandle), + ); + } + + return client; } constructor(sendMessage: SendMessage) { this.#sendMessage = sendMessage; } + private handleMessage(message: unknown, _sendHandle: unknown) { + const isResponse = (msg: unknown): msg is Response => + (msg as Response)?.type === responseType; + + if (isResponse(message)) { + this.#handlers.get(message.id)?.(message); + } + } + /** * Send a request to the parent process and wait for a response. */ @@ -82,17 +103,10 @@ export class BackstageIpcClient { let timeout: NodeJS.Timeout | undefined = undefined; - const messageHandler = (response: Response) => { - if (response?.type !== responseType) { - return; - } - if (response.id !== id) { - return; - } - + const responseHandler: ResponseHandler = (response: Response) => { clearTimeout(timeout); timeout = undefined; - process.removeListener('message', messageHandler); + this.#handlers.delete(id); if ('error' in response) { const error = new Error(response.error.message); @@ -107,12 +121,11 @@ export class BackstageIpcClient { timeout = setTimeout(() => { reject(new Error(`IPC request '${method}' with ID ${id} timed out`)); - process.removeListener('message', messageHandler); + this.#handlers.delete(id); }, IPC_TIMEOUT_MS); timeout.unref(); - process.addListener('message', messageHandler as () => void); - + this.#handlers.set(id, responseHandler); this.#sendMessage(request, (e: Error) => { if (e) { reject(e); From 6d898d847533eb8eb5c065f20f409d8c501e386d Mon Sep 17 00:00:00 2001 From: Tim Hansen Date: Fri, 9 Aug 2024 12:07:10 -0600 Subject: [PATCH 217/372] Switch process polyfill to require.resolve Signed-off-by: Tim Hansen --- .changeset/funny-bears-sort.md | 5 +++++ packages/cli/src/lib/bundler/config.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/funny-bears-sort.md diff --git a/.changeset/funny-bears-sort.md b/.changeset/funny-bears-sort.md new file mode 100644 index 0000000000..a3dad0f489 --- /dev/null +++ b/.changeset/funny-bears-sort.md @@ -0,0 +1,5 @@ +--- +'@backstage/cli': patch +--- + +Switched the `process` polyfill to use `require.resolve` for greater compatability. diff --git a/packages/cli/src/lib/bundler/config.ts b/packages/cli/src/lib/bundler/config.ts index 42cdae24e3..da7b378fbd 100644 --- a/packages/cli/src/lib/bundler/config.ts +++ b/packages/cli/src/lib/bundler/config.ts @@ -180,7 +180,7 @@ export async function createConfig( // to remove this eventually! plugins.push( new ProvidePlugin({ - process: 'process/browser', + process: require.resolve('process/browser'), Buffer: ['buffer', 'Buffer'], }), ); From 27794d1089ba154b3bd7625ca55429d75d20a58b Mon Sep 17 00:00:00 2001 From: Sydney Achinger <78113809+squid-ney@users.noreply.github.com> Date: Fri, 9 Aug 2024 14:33:47 -0400 Subject: [PATCH 218/372] Add ability to override theme options for the TechDocsReaderPage. (#25956) * Add ability to override theme options for the TechDocsReaderPage. --------- Signed-off-by: Sydney Achinger --- .changeset/healthy-fireants-jump.md | 5 ++ plugins/techdocs/api-report.md | 2 + .../TechDocsReaderPage.test.tsx | 26 ++++++++ .../TechDocsReaderPage/TechDocsReaderPage.tsx | 59 +++++++++++-------- 4 files changed, 69 insertions(+), 23 deletions(-) create mode 100644 .changeset/healthy-fireants-jump.md diff --git a/.changeset/healthy-fireants-jump.md b/.changeset/healthy-fireants-jump.md new file mode 100644 index 0000000000..7a11015b80 --- /dev/null +++ b/.changeset/healthy-fireants-jump.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs': patch +--- + +Allow for more granular control of TechDocsReaderPage styling. Theme overrides can now be provided to TechDocs without affecting the theme in other areas of Backstage. diff --git a/plugins/techdocs/api-report.md b/plugins/techdocs/api-report.md index 90834c6fcb..781d8db422 100644 --- a/plugins/techdocs/api-report.md +++ b/plugins/techdocs/api-report.md @@ -30,6 +30,7 @@ import { TechDocsApi as TechDocsApi_2 } from '@backstage/plugin-techdocs-react'; import { TechDocsEntityMetadata as TechDocsEntityMetadata_2 } from '@backstage/plugin-techdocs-react'; import { TechDocsMetadata as TechDocsMetadata_2 } from '@backstage/plugin-techdocs-react'; import { TechDocsStorageApi as TechDocsStorageApi_2 } from '@backstage/plugin-techdocs-react'; +import { ThemeOptions } from '@material-ui/core/styles'; import { ToolbarProps } from '@material-ui/core/Toolbar'; import { UserListFilterKind } from '@backstage/plugin-catalog-react'; @@ -389,6 +390,7 @@ export type TechDocsReaderPageHeaderProps = PropsWithChildren<{ export type TechDocsReaderPageProps = { entityRef?: CompoundEntityRef; children?: TechDocsReaderPageRenderFunction | ReactNode; + overrideThemeOptions?: Partial; }; // @public diff --git a/plugins/techdocs/src/reader/components/TechDocsReaderPage/TechDocsReaderPage.test.tsx b/plugins/techdocs/src/reader/components/TechDocsReaderPage/TechDocsReaderPage.test.tsx index ed8b05c661..5e8cd7af27 100644 --- a/plugins/techdocs/src/reader/components/TechDocsReaderPage/TechDocsReaderPage.test.tsx +++ b/plugins/techdocs/src/reader/components/TechDocsReaderPage/TechDocsReaderPage.test.tsx @@ -252,4 +252,30 @@ describe('', () => { expect(rendered.getByText('the page')).toBeInTheDocument(); }); + + it('should apply overrideThemeOptions', async () => { + const overrideThemeOptions = { + typography: { fontFamily: 'Comic Sans MS' }, + }; + + const rendered = await renderInTestApp( + + + , + { + mountedRoutes, + }, + ); + + const text = rendered.getAllByText(mockTechDocsMetadata.site_name)[0]; + + expect(text).toHaveStyle('fontFamily: Comic Sans MS'); + }); }); diff --git a/plugins/techdocs/src/reader/components/TechDocsReaderPage/TechDocsReaderPage.tsx b/plugins/techdocs/src/reader/components/TechDocsReaderPage/TechDocsReaderPage.tsx index b1b9ecb13b..0f48df7f39 100644 --- a/plugins/techdocs/src/reader/components/TechDocsReaderPage/TechDocsReaderPage.tsx +++ b/plugins/techdocs/src/reader/components/TechDocsReaderPage/TechDocsReaderPage.tsx @@ -37,6 +37,8 @@ import { } from '@backstage/core-plugin-api'; import { CookieAuthRefreshProvider } from '@backstage/plugin-auth-react'; +import { ThemeOptions } from '@material-ui/core/styles'; +import { createTheme, ThemeProvider, useTheme } from '@material-ui/core/styles'; /* An explanation for the multiple ways of customizing the TechDocs reader page @@ -151,6 +153,7 @@ export const TechDocsReaderLayout = (props: TechDocsReaderLayoutProps) => { export type TechDocsReaderPageProps = { entityRef?: CompoundEntityRef; children?: TechDocsReaderPageRenderFunction | ReactNode; + overrideThemeOptions?: Partial; }; /** @@ -159,6 +162,12 @@ export type TechDocsReaderPageProps = { * @public */ export const TechDocsReaderPage = (props: TechDocsReaderPageProps) => { + const currentTheme = useTheme(); + + const readerPageTheme = createTheme({ + ...currentTheme, + ...(props.overrideThemeOptions || {}), + }); const { kind, name, namespace } = useRouteRefParams(rootDocsRouteRef); const { children, entityRef = { kind, name, namespace } } = props; @@ -179,33 +188,37 @@ export const TechDocsReaderPage = (props: TechDocsReaderPageProps) => { // As explained above, "page" is configuration 4 and is 1 return ( - - - {(page as JSX.Element) || } - - + + + + {(page as JSX.Element) || } + + + ); } // As explained above, a render function is configuration 3 and React element is 2 return ( - - - {({ metadata, entityMetadata, onReady }) => ( -
    - - {children instanceof Function - ? children({ - entityRef, - techdocsMetadataValue: metadata.value, - entityMetadataValue: entityMetadata.value, - onReady, - }) - : children} - -
    - )} -
    -
    + + + + {({ metadata, entityMetadata, onReady }) => ( +
    + + {children instanceof Function + ? children({ + entityRef, + techdocsMetadataValue: metadata.value, + entityMetadataValue: entityMetadata.value, + onReady, + }) + : children} + +
    + )} +
    +
    +
    ); }; From c33f8df6ebc6516706cb6c7a04b2b33c67836118 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 9 Aug 2024 16:34:52 +0200 Subject: [PATCH 219/372] frontend-plugin-api: initial support for blueprint input overrides Signed-off-by: Patrik Oldsberg --- .../wiring/createExtensionBlueprint.test.tsx | 246 +++++++++++++++++- .../src/wiring/createExtensionBlueprint.ts | 134 +++++++++- 2 files changed, 372 insertions(+), 8 deletions(-) diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx index b9d1475074..003090668b 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx @@ -16,9 +16,15 @@ import React from 'react'; import { coreExtensionData } from './coreExtensionData'; -import { createExtensionBlueprint } from './createExtensionBlueprint'; +import { + createDataContainer, + createExtensionBlueprint, +} from './createExtensionBlueprint'; import { createExtensionTester } from '@backstage/frontend-test-utils'; -import { createExtensionDataRef } from './createExtensionDataRef'; +import { + ExtensionDataValue, + createExtensionDataRef, +} from './createExtensionDataRef'; import { createExtensionInput } from './createExtensionInput'; import { RouteRef } from '../routing'; import { @@ -28,12 +34,15 @@ import { function unused(..._any: any[]) {} -function factoryOutput(ext: ExtensionDefinition) { +function factoryOutput( + ext: ExtensionDefinition, + inputs: unknown = undefined, +) { const int = toInternalExtensionDefinition(ext); if (int.version !== 'v2') { throw new Error('Expected v2 extension'); } - return Array.from(int.factory({} as any)); + return Array.from(int.factory({ inputs } as any)); } describe('createExtensionBlueprint', () => { @@ -335,6 +344,235 @@ describe('createExtensionBlueprint', () => { expect(true).toBe(true); }); + it('should be able to override inputs when calling original factory', () => { + const outputRef = createExtensionDataRef().with({ id: 'output' }); + const testDataRef1 = createExtensionDataRef().with({ id: 'test1' }); + const testDataRef2 = createExtensionDataRef().with({ id: 'test2' }); + + const Blueprint = createExtensionBlueprint({ + kind: 'test-extension', + attachTo: { id: 'test', input: 'default' }, + inputs: { + opt: createExtensionInput([testDataRef1.optional()], { + singleton: true, + optional: true, + }), + single: createExtensionInput([testDataRef1, testDataRef2.optional()], { + singleton: true, + }), + multi: createExtensionInput([testDataRef1]), + }, + output: [outputRef], + factory(_, { inputs }) { + return [ + outputRef({ + opt: inputs.opt?.get(testDataRef1) ?? 'none', + single: inputs.single.get(testDataRef1), + singleOpt: inputs.single.get(testDataRef2) ?? 'none', + multi: inputs.multi.map(i => i.get(testDataRef1)).join(','), + }), + ]; + }, + }); + + const mockInput = (node: string, ...data: ExtensionDataValue[]) => + Object.assign(createDataContainer(data), { + node, + }); + const mockParentInputs = { + opt: mockInput('node-opt', testDataRef1('orig-opt')), + single: mockInput('node-single', testDataRef1('orig-single')), + multi: [ + mockInput('node-multi1', testDataRef1('orig-multi1')), + mockInput('node-multi2', testDataRef1('orig-multi2')), + ], + }; + + // All values provided + expect( + factoryOutput( + Blueprint.makeWithOverrides({ + factory(origFactory) { + return origFactory( + {}, + { + inputs: { + opt: [testDataRef1('opt')], + single: [testDataRef1('single'), testDataRef2('singleOpt')], + multi: [[testDataRef1('multi1')], [testDataRef1('multi2')]], + }, + }, + ); + }, + }), + mockParentInputs, + ), + ).toEqual([ + outputRef({ + opt: 'opt', + single: 'single', + singleOpt: 'singleOpt', + multi: 'multi1,multi2', + }), + ]); + + // Minimal values provided + expect( + factoryOutput( + Blueprint.makeWithOverrides({ + factory(origFactory) { + return origFactory( + {}, + { + inputs: { + single: [testDataRef1('single')], + multi: [[testDataRef1('multi1')], [testDataRef1('multi2')]], + }, + }, + ); + }, + }), + mockParentInputs, + ), + ).toEqual([ + outputRef({ + opt: 'none', + single: 'single', + singleOpt: 'none', + multi: 'multi1,multi2', + }), + ]); + + // Not enough values provided, checked at runtime + expect(() => + factoryOutput( + Blueprint.makeWithOverrides({ + factory(origFactory) { + return origFactory( + {}, + { + inputs: { + single: [], + multi: [], + }, + }, + ); + }, + }), + mockParentInputs, + ), + ).toThrowErrorMatchingInlineSnapshot( + `"Invalid override provided for input 'multi', when overriding the input data the length must match the original input data"`, + ); + + // Wrong value provided + expect(() => + factoryOutput( + Blueprint.makeWithOverrides({ + factory(origFactory) { + return origFactory( + {}, + { + inputs: { + // @ts-expect-error + opt: [testDataRef2('opt')], + // @ts-expect-error + single: [testDataRef1('single'), outputRef({})], + multi: [ + // @ts-expect-error + [testDataRef2('multi1')], + ], + }, + }, + ); + }, + }), + mockParentInputs, + ), + ).toThrowErrorMatchingInlineSnapshot( + `"Invalid override provided for input 'multi', when overriding the input data the length must match the original input data"`, + ); + + // Forwarding entire inputs object + expect( + factoryOutput( + Blueprint.makeWithOverrides({ + factory(origFactory, { inputs }) { + return origFactory({}, { inputs }); + }, + }), + mockParentInputs, + ), + ).toEqual([ + outputRef({ + opt: 'orig-opt', + single: 'orig-single', + singleOpt: 'none', + multi: 'orig-multi1,orig-multi2', + }), + ]); + + // Forwarding individual outputs + expect( + factoryOutput( + Blueprint.makeWithOverrides({ + factory(origFactory, { inputs }) { + return origFactory( + {}, + { + inputs: { + opt: inputs.opt, + single: inputs.single, + multi: inputs.multi, + }, + }, + ); + }, + }), + mockParentInputs, + ), + ).toEqual([ + outputRef({ + opt: 'orig-opt', + single: 'orig-single', + singleOpt: 'none', + multi: 'orig-multi1,orig-multi2', + }), + ]); + + // Overriding based on original input + expect( + factoryOutput( + Blueprint.makeWithOverrides({ + factory(origFactory, { inputs }) { + return origFactory( + {}, + { + inputs: { + single: [ + testDataRef1(`override-${inputs.single.get(testDataRef1)}`), + testDataRef2('new-singleOpt'), + ], + multi: inputs.multi.map(i => [ + testDataRef1(`override-${i.get(testDataRef1)}`), + ]), + }, + }, + ); + }, + }), + mockParentInputs, + ), + ).toEqual([ + outputRef({ + opt: 'none', + single: 'override-orig-single', + singleOpt: 'new-singleOpt', + multi: 'override-orig-multi1,override-orig-multi2', + }), + ]); + }); + it('should allow merging of inputs', () => { const blueprint = createExtensionBlueprint({ kind: 'test-extension', diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts index 656e681a2b..2bc5fda43d 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts @@ -20,6 +20,7 @@ import { CreateExtensionOptions, ExtensionDataContainer, ExtensionDefinition, + ResolvedExtensionInput, ResolvedExtensionInputs, VerifyExtensionFactoryOutput, createExtension, @@ -29,6 +30,7 @@ import { ExtensionInput } from './createExtensionInput'; import { AnyExtensionDataRef, ExtensionDataRef, + ExtensionDataRefToValue, ExtensionDataValue, } from './createExtensionDataRef'; @@ -75,6 +77,61 @@ export type CreateExtensionBlueprintOptions< dataRefs?: TDataRefs; } & VerifyExtensionFactoryOutput; +/** @ignore */ +type ResolveInputValueOverrides< + TInputs extends { + [inputName in string]: ExtensionInput< + AnyExtensionDataRef, + { optional: boolean; singleton: boolean } + >; + } = { + [inputName in string]: ExtensionInput< + AnyExtensionDataRef, + { optional: boolean; singleton: boolean } + >; + }, +> = Expand< + { + [KName in keyof TInputs as TInputs[KName] extends ExtensionInput< + any, + { + optional: infer IOptional extends boolean; + singleton: boolean; + } + > + ? IOptional extends true + ? never + : KName + : never]: TInputs[KName] extends ExtensionInput< + infer IDataRefs, + { optional: boolean; singleton: infer ISingleton extends boolean } + > + ? ISingleton extends true + ? Iterable> + : Array>> + : never; + } & { + [KName in keyof TInputs as TInputs[KName] extends ExtensionInput< + any, + { + optional: infer IOptional extends boolean; + singleton: boolean; + } + > + ? IOptional extends true + ? KName + : never + : never]?: TInputs[KName] extends ExtensionInput< + infer IDataRefs, + { optional: boolean; singleton: infer ISingleton extends boolean } + > + ? ISingleton extends true + ? Iterable> + : Array>> + : never; + } +>; + /** * @public */ @@ -156,7 +213,7 @@ export interface ExtensionBlueprint< params: TParams, context?: { config?: TConfig; - inputs?: Expand>; + inputs?: ResolveInputValueOverrides; }, ) => ExtensionDataContainer, context: { @@ -288,7 +345,7 @@ class ExtensionBlueprintImpl< ReturnType >; }; - inputs?: Expand>; + inputs?: ResolveInputValueOverrides; }, ) => ExtensionDataContainer, context: { @@ -347,14 +404,83 @@ class ExtensionBlueprintImpl< ReturnType >; }; - inputs?: Expand>; + inputs?: ResolveInputValueOverrides; }, ): ExtensionDataContainer => { + const overrideInputs = innerContext?.inputs; + const declaredInputs = this.options.inputs; + + let forwardedInputs = inputs; + if (overrideInputs && declaredInputs) { + const newInputs = {} as { + [KName in keyof TInputs]?: + | ({ node: AppNode } & ExtensionDataContainer) + | Array<{ node: AppNode } & ExtensionDataContainer>; + }; + forwardedInputs = newInputs as typeof inputs; + + for (const name in declaredInputs) { + if (!Object.hasOwn(declaredInputs, name)) { + continue; + } + const declaredInput = declaredInputs[name]; + const providedData = overrideInputs[name]; + if (declaredInput.config.singleton) { + // We know the passed in input will match the declared inputs, so this case is safe + const originalInput = ( + inputs as Record< + string, + { node: AppNode } & ExtensionDataContainer + > + )[name]; + if (providedData) { + const providedContainer = createDataContainer( + providedData as Iterable>, + ); + if (!originalInput) { + throw new Error( + `A data override was provided for input '${name}', but no original input was present.`, + ); + } + newInputs[name] = Object.assign(providedContainer, { + name: (originalInput as ResolvedExtensionInput).node, + }) as any; + } + } else { + // We know the passed in input will match the declared inputs, so this case is safe + const originalInput = ( + inputs as Record< + string, + Array<{ node: AppNode } & ExtensionDataContainer> + > + )[name]; + if (!Array.isArray(providedData)) { + throw new Error( + `Invalid override provided for input '${name}', expected an array`, + ); + } + if (originalInput.length !== providedData.length) { + throw new Error( + `Invalid override provided for input '${name}', when overriding the input data the length must match the original input data`, + ); + } + newInputs[name] = providedData.map((data, i) => { + const providedContainer = createDataContainer( + data as Iterable>, + ); + return Object.assign(providedContainer, { + name: (originalInput[i] as ResolvedExtensionInput) + .node, + }) as any; + }); + } + } + } return createDataContainer( this.options.factory(innerParams, { node, config: innerContext?.config ?? config, - inputs: (innerContext?.inputs ?? inputs) as any, // TODO: Fix the way input values are overridden + inputs: forwardedInputs as any, // TODO: Might be able to improve this once legacy inputs are gone }), ); }, From eab84be9336594fa19ef1698b7a7f2ed906bce09 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sat, 10 Aug 2024 13:56:03 +0200 Subject: [PATCH 220/372] frontend-plugin-api: validate input override values Signed-off-by: Patrik Oldsberg --- .../wiring/createExtensionBlueprint.test.tsx | 32 ++++++++++++++++--- .../src/wiring/createExtensionBlueprint.ts | 23 +++++++++++++ 2 files changed, 50 insertions(+), 5 deletions(-) diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx index 003090668b..fa85cbf981 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx @@ -443,17 +443,17 @@ describe('createExtensionBlueprint', () => { }), ]); - // Not enough values provided, checked at runtime + // Mismatched input override length expect(() => factoryOutput( Blueprint.makeWithOverrides({ - factory(origFactory) { + factory(origFactory, { inputs }) { return origFactory( {}, { inputs: { - single: [], - multi: [], + ...inputs, + multi: [[testDataRef1('multi1')]], }, }, ); @@ -465,6 +465,28 @@ describe('createExtensionBlueprint', () => { `"Invalid override provided for input 'multi', when overriding the input data the length must match the original input data"`, ); + // Required input not provided + expect(() => + factoryOutput( + Blueprint.makeWithOverrides({ + factory(origFactory, { inputs }) { + return origFactory( + {}, + { + inputs: { + ...inputs, + single: [testDataRef2('singleOpt')], + }, + }, + ); + }, + }), + mockParentInputs, + ), + ).toThrowErrorMatchingInlineSnapshot( + `"Missing required data values for 'test1'"`, + ); + // Wrong value provided expect(() => factoryOutput( @@ -490,7 +512,7 @@ describe('createExtensionBlueprint', () => { mockParentInputs, ), ).toThrowErrorMatchingInlineSnapshot( - `"Invalid override provided for input 'multi', when overriding the input data the length must match the original input data"`, + `"Invalid data value provided, 'test2' was not declared"`, ); // Forwarding entire inputs object diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts index 2bc5fda43d..2ad58e2ef9 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts @@ -259,13 +259,34 @@ export function createDataContainer( ? ExtensionDataValue : never >, + declaredRefs?: ExtensionDataRef[], ): ExtensionDataContainer { const container = new Map>(); + const verifyRefs = + declaredRefs && new Map(declaredRefs.map(ref => [ref.id, ref])); for (const output of values) { + if (verifyRefs) { + if (!verifyRefs.delete(output.id)) { + throw new Error( + `Invalid data value provided, '${output.id}' was not declared`, + ); + } + } container.set(output.id, output); } + const remainingRefs = + verifyRefs && + Array.from(verifyRefs.values()).filter(ref => !ref.config.optional); + if (remainingRefs && remainingRefs.length > 0) { + throw new Error( + `Missing required data values for '${remainingRefs + .map(ref => ref.id) + .join(', ')}'`, + ); + } + return { get(ref) { return container.get(ref.id)?.value; @@ -436,6 +457,7 @@ class ExtensionBlueprintImpl< if (providedData) { const providedContainer = createDataContainer( providedData as Iterable>, + declaredInput.extensionData, ); if (!originalInput) { throw new Error( @@ -467,6 +489,7 @@ class ExtensionBlueprintImpl< newInputs[name] = providedData.map((data, i) => { const providedContainer = createDataContainer( data as Iterable>, + declaredInput.extensionData, ); return Object.assign(providedContainer, { name: (originalInput[i] as ResolvedExtensionInput) From 51b271f4d387cd5e1f72d7d70e110270a91b8ed1 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sat, 10 Aug 2024 17:48:36 +0200 Subject: [PATCH 221/372] frontend-plugin-api: validate blueprint original factory output Signed-off-by: Patrik Oldsberg --- .../wiring/createExtensionBlueprint.test.tsx | 37 +++++++++++++++++++ .../src/wiring/createExtensionBlueprint.ts | 1 + 2 files changed, 38 insertions(+) diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx index fa85cbf981..efca17459b 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx @@ -689,6 +689,43 @@ describe('createExtensionBlueprint', () => { expect(factoryOutput(ext)).toEqual([testDataRef2('foobar')]); }); + it('should reject invalid output from original factory', () => { + const testDataRef1 = createExtensionDataRef().with({ id: 'test1' }); + const testDataRef2 = createExtensionDataRef().with({ id: 'test2' }); + + expect(() => + factoryOutput( + // @ts-expect-error + createExtensionBlueprint({ + kind: 'test-extension', + attachTo: { id: 'test', input: 'default' }, + output: [testDataRef1], + factory() { + return [testDataRef2('foo')]; + }, + }).makeWithOverrides({ factory: orig => orig({}) }), + ), + ).toThrowErrorMatchingInlineSnapshot( + `"Invalid data value provided, 'test2' was not declared"`, + ); + + expect(() => + factoryOutput( + // @ts-expect-error + createExtensionBlueprint({ + kind: 'test-extension', + attachTo: { id: 'test', input: 'default' }, + output: [testDataRef1], + factory() { + return []; + }, + }).makeWithOverrides({ factory: orig => orig({}) }), + ), + ).toThrowErrorMatchingInlineSnapshot( + `"Missing required data values for 'test1'"`, + ); + }); + it('should allow returning of the parent data container', () => { const testDataRef1 = createExtensionDataRef().with({ id: 'test1' }); const testDataRef2 = createExtensionDataRef().with({ id: 'test2' }); diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts index 2ad58e2ef9..8ce3dab4d5 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts @@ -505,6 +505,7 @@ class ExtensionBlueprintImpl< config: innerContext?.config ?? config, inputs: forwardedInputs as any, // TODO: Might be able to improve this once legacy inputs are gone }), + this.options.output, ); }, { From 9f476d1687e805cd3a5edec426c25bf51c5b9217 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sun, 11 Aug 2024 12:54:01 +0200 Subject: [PATCH 222/372] frontend-plugin-api: refactor out blueprint input overrides Signed-off-by: Patrik Oldsberg --- .../src/wiring/createExtensionBlueprint.ts | 152 +++++++++--------- 1 file changed, 80 insertions(+), 72 deletions(-) diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts index 8ce3dab4d5..88f3a6e9dd 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts @@ -297,6 +297,81 @@ export function createDataContainer( } as ExtensionDataContainer; } +function expectArray(value: T | T[]): T[] { + return value as T[]; +} +function expectItem(value: T | T[]): T { + return value as T; +} + +/** @internal */ +export function resolveInputOverrides( + declaredInputs?: { + [inputName in string]: ExtensionInput< + AnyExtensionDataRef, + { optional: boolean; singleton: boolean } + >; + }, + inputs?: { + [KName in string]?: + | ({ node: AppNode } & ExtensionDataContainer) + | Array<{ node: AppNode } & ExtensionDataContainer>; + }, + inputOverrides?: ResolveInputValueOverrides, +) { + if (!declaredInputs || !inputs || !inputOverrides) { + return inputs; + } + + const newInputs: typeof inputs = {}; + for (const name in declaredInputs) { + if (!Object.hasOwn(declaredInputs, name)) { + continue; + } + const declaredInput = declaredInputs[name]; + const providedData = inputOverrides[name]; + if (declaredInput.config.singleton) { + const originalInput = expectItem(inputs[name]); + if (providedData) { + const providedContainer = createDataContainer( + providedData as Iterable>, + declaredInput.extensionData, + ); + if (!originalInput) { + throw new Error( + `A data override was provided for input '${name}', but no original input was present.`, + ); + } + newInputs[name] = Object.assign(providedContainer, { + name: (originalInput as ResolvedExtensionInput).node, + }) as any; + } + } else { + const originalInput = expectArray(inputs[name]); + if (!Array.isArray(providedData)) { + throw new Error( + `Invalid override provided for input '${name}', expected an array`, + ); + } + if (originalInput.length !== providedData.length) { + throw new Error( + `Invalid override provided for input '${name}', when overriding the input data the length must match the original input data`, + ); + } + newInputs[name] = providedData.map((data, i) => { + const providedContainer = createDataContainer( + data as Iterable>, + declaredInput.extensionData, + ); + return Object.assign(providedContainer, { + name: (originalInput[i] as ResolvedExtensionInput).node, + }) as any; + }); + } + } + return newInputs; +} + /** * @internal */ @@ -428,82 +503,15 @@ class ExtensionBlueprintImpl< inputs?: ResolveInputValueOverrides; }, ): ExtensionDataContainer => { - const overrideInputs = innerContext?.inputs; - const declaredInputs = this.options.inputs; - - let forwardedInputs = inputs; - if (overrideInputs && declaredInputs) { - const newInputs = {} as { - [KName in keyof TInputs]?: - | ({ node: AppNode } & ExtensionDataContainer) - | Array<{ node: AppNode } & ExtensionDataContainer>; - }; - forwardedInputs = newInputs as typeof inputs; - - for (const name in declaredInputs) { - if (!Object.hasOwn(declaredInputs, name)) { - continue; - } - const declaredInput = declaredInputs[name]; - const providedData = overrideInputs[name]; - if (declaredInput.config.singleton) { - // We know the passed in input will match the declared inputs, so this case is safe - const originalInput = ( - inputs as Record< - string, - { node: AppNode } & ExtensionDataContainer - > - )[name]; - if (providedData) { - const providedContainer = createDataContainer( - providedData as Iterable>, - declaredInput.extensionData, - ); - if (!originalInput) { - throw new Error( - `A data override was provided for input '${name}', but no original input was present.`, - ); - } - newInputs[name] = Object.assign(providedContainer, { - name: (originalInput as ResolvedExtensionInput).node, - }) as any; - } - } else { - // We know the passed in input will match the declared inputs, so this case is safe - const originalInput = ( - inputs as Record< - string, - Array<{ node: AppNode } & ExtensionDataContainer> - > - )[name]; - if (!Array.isArray(providedData)) { - throw new Error( - `Invalid override provided for input '${name}', expected an array`, - ); - } - if (originalInput.length !== providedData.length) { - throw new Error( - `Invalid override provided for input '${name}', when overriding the input data the length must match the original input data`, - ); - } - newInputs[name] = providedData.map((data, i) => { - const providedContainer = createDataContainer( - data as Iterable>, - declaredInput.extensionData, - ); - return Object.assign(providedContainer, { - name: (originalInput[i] as ResolvedExtensionInput) - .node, - }) as any; - }); - } - } - } return createDataContainer( this.options.factory(innerParams, { node, config: innerContext?.config ?? config, - inputs: forwardedInputs as any, // TODO: Might be able to improve this once legacy inputs are gone + inputs: resolveInputOverrides( + this.options.inputs, + inputs, + innerContext?.inputs, + ) as any, // TODO: Might be able to improve this once legacy inputs are gone }), this.options.output, ); From 66c6bbcef5d0fe0b904f5841141ce50a65d1961b Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sun, 11 Aug 2024 19:57:06 +0200 Subject: [PATCH 223/372] frontend-app-api: fix for input extension data containers not being iterable at runtime Signed-off-by: Patrik Oldsberg --- .../src/tree/instantiateAppNodeTree.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/frontend-app-api/src/tree/instantiateAppNodeTree.ts b/packages/frontend-app-api/src/tree/instantiateAppNodeTree.ts index 65626e0be1..c70e351105 100644 --- a/packages/frontend-app-api/src/tree/instantiateAppNodeTree.ts +++ b/packages/frontend-app-api/src/tree/instantiateAppNodeTree.ts @@ -92,6 +92,16 @@ function resolveInputDataContainer( get(ref) { return dataMap.get(ref.id); }, + *[Symbol.iterator]() { + for (const [id, value] of dataMap) { + // TODO: Would be better to be able to create a new instance using the ref here instead + yield { + $$type: '@backstage/ExtensionDataValue', + id, + value, + }; + } + }, } as { node: AppNode } & ExtensionDataContainer; } From cea81165f45f3cb9c6488ce66f18cda7d07c5c91 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sun, 11 Aug 2024 19:57:42 +0200 Subject: [PATCH 224/372] frontend-plugin-api: add support for overriding input values when overriding extensions Signed-off-by: Patrik Oldsberg --- .../src/wiring/createExtension.test.ts | 292 ++++++++++++++++++ .../src/wiring/createExtension.ts | 19 +- .../src/wiring/createExtensionBlueprint.ts | 2 +- 3 files changed, 307 insertions(+), 6 deletions(-) diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts index f9e39e98de..9d2aff5d99 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts @@ -732,5 +732,297 @@ describe('createExtension', () => { }).data(stringDataRef), ).toBe('foo-hello-override-world'); }); + + it('should be able to override input values', () => { + const outputRef = createExtensionDataRef().with({ + id: 'output', + }); + const testDataRef1 = createExtensionDataRef().with({ + id: 'test1', + }); + const testDataRef2 = createExtensionDataRef().with({ + id: 'test2', + }); + + const subject = createExtension({ + name: 'subject', + attachTo: { id: 'ignored', input: 'ignored' }, + inputs: { + opt: createExtensionInput([testDataRef1.optional()], { + singleton: true, + optional: true, + }), + single: createExtensionInput( + [testDataRef1, testDataRef2.optional()], + { + singleton: true, + }, + ), + multi: createExtensionInput([testDataRef1]), + }, + output: [outputRef], + factory({ inputs }) { + return [ + outputRef({ + opt: inputs.opt?.get(testDataRef1) ?? 'none', + single: inputs.single.get(testDataRef1), + singleOpt: inputs.single.get(testDataRef2) ?? 'none', + multi: inputs.multi.map(i => i.get(testDataRef1)).join(','), + }), + ]; + }, + }); + + const optExt = createExtension({ + name: 'opt', + attachTo: { id: 'subject', input: 'opt' }, + output: [testDataRef1], + factory: () => [testDataRef1('orig-opt')], + }); + + const singleExt = createExtension({ + name: 'single', + attachTo: { id: 'subject', input: 'single' }, + output: [testDataRef1, testDataRef2.optional()], + factory: () => [testDataRef1('orig-single')], + }); + + const multi1Ext = createExtension({ + name: 'multi1', + attachTo: { id: 'subject', input: 'multi' }, + output: [testDataRef1], + factory: () => [testDataRef1('orig-multi1')], + }); + + const multi2Ext = createExtension({ + name: 'multi2', + attachTo: { id: 'subject', input: 'multi' }, + output: [testDataRef1], + factory: () => [testDataRef1('orig-multi2')], + }); + + expect( + createExtensionTester(subject) + .add(optExt) + .add(singleExt) + .add(multi1Ext) + .add(multi2Ext) + .data(outputRef), + ).toEqual({ + opt: 'orig-opt', + single: 'orig-single', + singleOpt: 'none', + multi: 'orig-multi1,orig-multi2', + }); + + // All values provided + expect( + createExtensionTester( + subject.override({ + factory(originalFactory) { + return originalFactory({ + inputs: { + opt: [testDataRef1('opt')], + single: [testDataRef1('single'), testDataRef2('singleOpt')], + multi: [[testDataRef1('multi1')], [testDataRef1('multi2')]], + }, + }); + }, + }), + ) + .add(optExt) + .add(singleExt) + .add(multi1Ext) + .add(multi2Ext) + .data(outputRef), + ).toEqual({ + opt: 'opt', + single: 'single', + singleOpt: 'singleOpt', + multi: 'multi1,multi2', + }); + + // Minimal values provided + expect( + createExtensionTester( + subject.override({ + factory(originalFactory) { + return originalFactory({ + inputs: { + single: [testDataRef1('single')], + multi: [[testDataRef1('multi1')], [testDataRef1('multi2')]], + }, + }); + }, + }), + ) + .add(optExt) + .add(singleExt) + .add(multi1Ext) + .add(multi2Ext) + .data(outputRef), + ).toEqual({ + opt: 'none', + single: 'single', + singleOpt: 'none', + multi: 'multi1,multi2', + }); + + // Forward inputs directly + expect( + createExtensionTester( + subject.override({ + factory(originalFactory, { inputs }) { + return originalFactory({ + inputs, + }); + }, + }), + ) + .add(optExt) + .add(singleExt) + .add(multi1Ext) + .add(multi2Ext) + .data(outputRef), + ).toEqual({ + opt: 'orig-opt', + single: 'orig-single', + singleOpt: 'none', + multi: 'orig-multi1,orig-multi2', + }); + + // Forward inputs separately + expect( + createExtensionTester( + subject.override({ + factory(originalFactory, { inputs }) { + return originalFactory({ + inputs: { + opt: inputs.opt, + single: inputs.single, + multi: inputs.multi, + }, + }); + }, + }), + ) + .add(optExt) + .add(singleExt) + .add(multi1Ext) + .add(multi2Ext) + .data(outputRef), + ).toEqual({ + opt: 'orig-opt', + single: 'orig-single', + singleOpt: 'none', + multi: 'orig-multi1,orig-multi2', + }); + + // Overriding based on original input + expect( + createExtensionTester( + subject.override({ + factory(originalFactory, { inputs }) { + return originalFactory({ + inputs: { + single: [ + testDataRef1(`override-${inputs.single.get(testDataRef1)}`), + testDataRef2('new-singleOpt'), + ], + multi: inputs.multi.map(i => [ + testDataRef1(`override-${i.get(testDataRef1)}`), + ]), + }, + }); + }, + }), + ) + .add(optExt) + .add(singleExt) + .add(multi1Ext) + .add(multi2Ext) + .data(outputRef), + ).toEqual({ + opt: 'none', + single: 'override-orig-single', + singleOpt: 'new-singleOpt', + multi: 'override-orig-multi1,override-orig-multi2', + }); + + // Mismatched input override length + expect(() => + createExtensionTester( + subject.override({ + factory(originalFactory, { inputs }) { + return originalFactory({ + inputs: { + ...inputs, + multi: [[testDataRef1('multi1')]], + }, + }); + }, + }), + ) + .add(optExt) + .add(singleExt) + .add(multi1Ext) + .add(multi2Ext) + .data(outputRef), + ).toThrowErrorMatchingInlineSnapshot( + `"Failed to instantiate extension 'subject', Invalid override provided for input 'multi', when overriding the input data the length must match the original input data"`, + ); + + // Required input not provided + expect(() => + createExtensionTester( + subject.override({ + factory(originalFactory, { inputs }) { + return originalFactory({ + inputs: { + ...inputs, + single: [testDataRef2('singleOpt')], + }, + }); + }, + }), + ) + .add(optExt) + .add(singleExt) + .add(multi1Ext) + .add(multi2Ext) + .data(outputRef), + ).toThrowErrorMatchingInlineSnapshot( + `"Failed to instantiate extension 'subject', Missing required data values for 'test1'"`, + ); + + // Wrong value provided + expect(() => + createExtensionTester( + subject.override({ + factory(originalFactory) { + return originalFactory({ + inputs: { + // @ts-expect-error + opt: [testDataRef2('opt')], + // @ts-expect-error + single: [testDataRef1('single'), outputRef({})], + multi: [ + // @ts-expect-error + [testDataRef2('multi1')], + ], + }, + }); + }, + }), + ) + .add(optExt) + .add(singleExt) + .add(multi1Ext) + .add(multi2Ext) + .data(outputRef), + ).toThrowErrorMatchingInlineSnapshot( + `"Failed to instantiate extension 'subject', Invalid data value provided, 'test2' was not declared"`, + ); + }); }); }); diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.ts b/packages/frontend-plugin-api/src/wiring/createExtension.ts index f2d3d906ab..55d71e0d2f 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.ts @@ -17,7 +17,11 @@ import { AppNode } from '../apis'; import { PortableSchema, createSchemaFromZod } from '../schema'; import { Expand } from '../types'; -import { createDataContainer } from './createExtensionBlueprint'; +import { + ResolveInputValueOverrides, + createDataContainer, + resolveInputOverrides, +} from './createExtensionBlueprint'; import { AnyExtensionDataRef, ExtensionDataRef, @@ -259,7 +263,7 @@ export interface ExtensionDefinition< factory( originalFactory: (context?: { config?: TConfig; - inputs?: Expand>; + inputs?: ResolveInputValueOverrides; }) => ExtensionDataContainer, context: { node: AppNode; @@ -558,7 +562,7 @@ export function createExtension< ReturnType >; }; - inputs?: Expand>; + inputs?: ResolveInputValueOverrides; }) => ExtensionDataContainer, context: { node: AppNode; @@ -646,14 +650,19 @@ export function createExtension< ReturnType >; }; - inputs?: Expand>; + inputs?: ResolveInputValueOverrides; }): ExtensionDataContainer => { return createDataContainer( newOptions.factory({ node, config: innerContext?.config ?? config, - inputs: (innerContext?.inputs ?? inputs) as any, // TODO: Fix the way input values are overridden + inputs: resolveInputOverrides( + newOptions.inputs, + inputs, + innerContext?.inputs, + ) as any, // TODO: Might be able to improve this once legacy inputs are gone }) as Iterable, + newOptions.output, ); }, { diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts index 88f3a6e9dd..cd6c0d6968 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts @@ -78,7 +78,7 @@ export type CreateExtensionBlueprintOptions< } & VerifyExtensionFactoryOutput; /** @ignore */ -type ResolveInputValueOverrides< +export type ResolveInputValueOverrides< TInputs extends { [inputName in string]: ExtensionInput< AnyExtensionDataRef, From 3d7d38d94f3ef904062461ebbf9ef1c638d8a0ad Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sun, 11 Aug 2024 20:04:48 +0200 Subject: [PATCH 225/372] frontend-plugin-api: clean up error messages for input overrides Signed-off-by: Patrik Oldsberg --- .../src/wiring/createExtension.test.ts | 6 +++--- .../src/wiring/createExtensionBlueprint.test.tsx | 10 +++++----- .../src/wiring/createExtensionBlueprint.ts | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts index 9d2aff5d99..d6e2599138 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts @@ -969,7 +969,7 @@ describe('createExtension', () => { .add(multi2Ext) .data(outputRef), ).toThrowErrorMatchingInlineSnapshot( - `"Failed to instantiate extension 'subject', Invalid override provided for input 'multi', when overriding the input data the length must match the original input data"`, + `"Failed to instantiate extension 'subject', override data provided for input 'multi' must match the length of the original inputs"`, ); // Required input not provided @@ -992,7 +992,7 @@ describe('createExtension', () => { .add(multi2Ext) .data(outputRef), ).toThrowErrorMatchingInlineSnapshot( - `"Failed to instantiate extension 'subject', Missing required data values for 'test1'"`, + `"Failed to instantiate extension 'subject', missing required extension data value(s) 'test1'"`, ); // Wrong value provided @@ -1021,7 +1021,7 @@ describe('createExtension', () => { .add(multi2Ext) .data(outputRef), ).toThrowErrorMatchingInlineSnapshot( - `"Failed to instantiate extension 'subject', Invalid data value provided, 'test2' was not declared"`, + `"Failed to instantiate extension 'subject', extension data 'test2' was provided but not declared"`, ); }); }); diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx index efca17459b..508000acbb 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx @@ -462,7 +462,7 @@ describe('createExtensionBlueprint', () => { mockParentInputs, ), ).toThrowErrorMatchingInlineSnapshot( - `"Invalid override provided for input 'multi', when overriding the input data the length must match the original input data"`, + `"override data provided for input 'multi' must match the length of the original inputs"`, ); // Required input not provided @@ -484,7 +484,7 @@ describe('createExtensionBlueprint', () => { mockParentInputs, ), ).toThrowErrorMatchingInlineSnapshot( - `"Missing required data values for 'test1'"`, + `"missing required extension data value(s) 'test1'"`, ); // Wrong value provided @@ -512,7 +512,7 @@ describe('createExtensionBlueprint', () => { mockParentInputs, ), ).toThrowErrorMatchingInlineSnapshot( - `"Invalid data value provided, 'test2' was not declared"`, + `"extension data 'test2' was provided but not declared"`, ); // Forwarding entire inputs object @@ -706,7 +706,7 @@ describe('createExtensionBlueprint', () => { }).makeWithOverrides({ factory: orig => orig({}) }), ), ).toThrowErrorMatchingInlineSnapshot( - `"Invalid data value provided, 'test2' was not declared"`, + `"extension data 'test2' was provided but not declared"`, ); expect(() => @@ -722,7 +722,7 @@ describe('createExtensionBlueprint', () => { }).makeWithOverrides({ factory: orig => orig({}) }), ), ).toThrowErrorMatchingInlineSnapshot( - `"Missing required data values for 'test1'"`, + `"missing required extension data value(s) 'test1'"`, ); }); diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts index cd6c0d6968..74d4426207 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts @@ -269,7 +269,7 @@ export function createDataContainer( if (verifyRefs) { if (!verifyRefs.delete(output.id)) { throw new Error( - `Invalid data value provided, '${output.id}' was not declared`, + `extension data '${output.id}' was provided but not declared`, ); } } @@ -281,7 +281,7 @@ export function createDataContainer( Array.from(verifyRefs.values()).filter(ref => !ref.config.optional); if (remainingRefs && remainingRefs.length > 0) { throw new Error( - `Missing required data values for '${remainingRefs + `missing required extension data value(s) '${remainingRefs .map(ref => ref.id) .join(', ')}'`, ); @@ -339,7 +339,7 @@ export function resolveInputOverrides( ); if (!originalInput) { throw new Error( - `A data override was provided for input '${name}', but no original input was present.`, + `attempted to override data of input '${name}' but it is not present in the original inputs`, ); } newInputs[name] = Object.assign(providedContainer, { @@ -350,12 +350,12 @@ export function resolveInputOverrides( const originalInput = expectArray(inputs[name]); if (!Array.isArray(providedData)) { throw new Error( - `Invalid override provided for input '${name}', expected an array`, + `override data provided for input '${name}' must be an array`, ); } if (originalInput.length !== providedData.length) { throw new Error( - `Invalid override provided for input '${name}', when overriding the input data the length must match the original input data`, + `override data provided for input '${name}' must match the length of the original inputs`, ); } newInputs[name] = providedData.map((data, i) => { From 553015651769c44c750a8b6012178f4231c3f8dd Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Sun, 11 Aug 2024 11:46:59 +0100 Subject: [PATCH 226/372] Update .changeset/five-mangos-agree.md Co-authored-by: Ben Lambert Signed-off-by: Brian Fletcher --- .changeset/five-mangos-agree.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/five-mangos-agree.md b/.changeset/five-mangos-agree.md index 1ad9b6b04c..f5ecb2891b 100644 --- a/.changeset/five-mangos-agree.md +++ b/.changeset/five-mangos-agree.md @@ -2,4 +2,4 @@ '@backstage/plugin-scaffolder-backend-module-bitbucket-cloud': patch --- -Add abilty to set the initial commit message when initializing a repository using the scaffolder action. +Add ability to set the initial commit message when initializing a repository using the scaffolder action. From a40904dc7d38419ed9a693992b73026634d726fc Mon Sep 17 00:00:00 2001 From: Julien Date: Mon, 12 Aug 2024 09:33:13 +0200 Subject: [PATCH 227/372] fix: add link to mui docs + fix typo in changeset Signed-off-by: Julien --- .changeset/perfect-cars-jam.md | 2 +- plugins/scaffolder/src/components/fields/VirtualizedListbox.tsx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.changeset/perfect-cars-jam.md b/.changeset/perfect-cars-jam.md index a22791034a..45166ac823 100644 --- a/.changeset/perfect-cars-jam.md +++ b/.changeset/perfect-cars-jam.md @@ -2,4 +2,4 @@ '@backstage/plugin-scaffolder': minor --- -Changed the way to display entities in `MyGroupsPicker` to use entityPresentationApi and make it consistent across scaffolder pickers +Changed the way to display entities in `MyGroupsPicker` to use `entityPresentationApi` and make it consistent across scaffolder pickers diff --git a/plugins/scaffolder/src/components/fields/VirtualizedListbox.tsx b/plugins/scaffolder/src/components/fields/VirtualizedListbox.tsx index b2bd611cec..2fad510918 100644 --- a/plugins/scaffolder/src/components/fields/VirtualizedListbox.tsx +++ b/plugins/scaffolder/src/components/fields/VirtualizedListbox.tsx @@ -22,6 +22,7 @@ const renderRow = (props: ListChildComponentProps) => { return React.cloneElement(data[index], { style }); }; +// Context needed to keep Autocomplete working correctly : https://v4.mui.com/components/autocomplete/#virtualization const OuterElementContext = React.createContext({}); const OuterElementType = React.forwardRef((props, ref) => { From 11ffdbd7f3e4cf516a682ac2eeb029b62875ac85 Mon Sep 17 00:00:00 2001 From: Julien Date: Mon, 12 Aug 2024 09:34:37 +0200 Subject: [PATCH 228/372] fix: add correct link to mui docs for Virtualization Signed-off-by: Julien --- plugins/scaffolder/src/components/fields/VirtualizedListbox.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/scaffolder/src/components/fields/VirtualizedListbox.tsx b/plugins/scaffolder/src/components/fields/VirtualizedListbox.tsx index 2fad510918..61e96cd7a9 100644 --- a/plugins/scaffolder/src/components/fields/VirtualizedListbox.tsx +++ b/plugins/scaffolder/src/components/fields/VirtualizedListbox.tsx @@ -22,7 +22,7 @@ const renderRow = (props: ListChildComponentProps) => { return React.cloneElement(data[index], { style }); }; -// Context needed to keep Autocomplete working correctly : https://v4.mui.com/components/autocomplete/#virtualization +// Context needed to keep Autocomplete working correctly : https://v4.mui.com/components/autocomplete/#Virtualize.tsx const OuterElementContext = React.createContext({}); const OuterElementType = React.forwardRef((props, ref) => { From c60b3b7af82103cc32606e021680a0213aa3efcd Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 26 Mar 2024 15:28:07 +0100 Subject: [PATCH 229/372] chore: creating the initial bep Signed-off-by: blam --- .../README.md | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 beps/NNNN-scaffolder-templating-in-parameters/README.md diff --git a/beps/NNNN-scaffolder-templating-in-parameters/README.md b/beps/NNNN-scaffolder-templating-in-parameters/README.md new file mode 100644 index 0000000000..49ec16d8ed --- /dev/null +++ b/beps/NNNN-scaffolder-templating-in-parameters/README.md @@ -0,0 +1,100 @@ +--- +title: Supporting templating syntax in `parameters` +status: provisional +authors: + - '@benjdlambert' +owners: + - '@benjdlambert' + - '@backstage/scaffolder-maintainers' +project-areas: + - scaffolder +creation-date: 2024-03-26 +--- + + + +# BEP: + + + +[**Discussion Issue**](https://github.com/backstage/backstage/issues/NNNNN) + +- [Summary](#summary) +- [Motivation](#motivation) + - [Goals](#goals) + - [Non-Goals](#non-goals) +- [Proposal](#proposal) +- [Design Details](#design-details) +- [Release Plan](#release-plan) +- [Dependencies](#dependencies) +- [Alternatives](#alternatives) + +## Summary + + + +## Motivation + + + +### Goals + + + +### Non-Goals + + + +## Proposal + + + +## Design Details + + + +## Release Plan + + + +## Dependencies + + + +## Alternatives + + From 8f6356169c85bb6f14b8ae0d5fdeb1838df5dbe1 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 28 Mar 2024 17:45:53 +0100 Subject: [PATCH 230/372] chore: starting to write some more for the bep Signed-off-by: blam Signed-off-by: blam --- .../README.md | 46 +++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/beps/NNNN-scaffolder-templating-in-parameters/README.md b/beps/NNNN-scaffolder-templating-in-parameters/README.md index 49ec16d8ed..71f92e9b64 100644 --- a/beps/NNNN-scaffolder-templating-in-parameters/README.md +++ b/beps/NNNN-scaffolder-templating-in-parameters/README.md @@ -1,5 +1,5 @@ --- -title: Supporting templating syntax in `parameters` +title: Supporting templating syntax in `parameters` schema status: provisional authors: - '@benjdlambert' @@ -17,11 +17,11 @@ creation-date: 2024-03-26 When editing BEPs, aim for tightly-scoped, single-topic PRs to keep discussions focused. If you disagree with what is already in a document, open a new PR with suggested changes. --> -# BEP: +# BEP: Supporting templating syntax in `parameters` schema -[**Discussion Issue**](https://github.com/backstage/backstage/issues/NNNNN) +[**Discussion Issue**](https://github.com/backstage/backstage/issues/16275) - [Summary](#summary) - [Motivation](#motivation) @@ -39,6 +39,30 @@ When editing BEPs, aim for tightly-scoped, single-topic PRs to keep discussions The summary of the BEP is a few paragraphs long and give a high-level overview of the features to be implemented. It should be possible to read *only* the summary and understand what the BEP is proposing to accomplish and what impact it has for users. --> +This BEP proposes to add support for templating syntax in the `parameters` schema of a scaffolder template. +This will allow users to define properties in the JSON Schema which are templated from current values that have been collected from the user already. +This can be useful when you want to use a value that has already been collected as a default value in another field. + +For example: + +```yaml +apiVersion: scaffolder.backstage.io/v1beta3 +kind: Template +metadata: + name: my-template +spec: + parameters: + - title: Some input + description: Get some info from the user + properties: + name: + type: string + default: Test + description: + type: string + default: ${{ parameters.name or "unknown" }}-description +``` + ## Motivation +Inclusive of the initial RFC there's been a swarm of issues that are requesting this feature, and we want to align on the implementation and design of this feature. + +See the following: + +- https://github.com/backstage/backstage/issues/16275 +- https://github.com/backstage/backstage/pull/23283 +- https://github.com/backstage/backstage/issues/19597 +- https://github.com/backstage/backstage/issues/20533 +- https://github.com/backstage/backstage/pull/17746 + +There's some ideas for introducing a templating syntax for both templating into the `parameters` schema, and also being able to pass through some templating strings to underlying field extensions that can use those templating strings. +We want to align here so that we're not going to have those conflict or compete, and create a standard for how to achieve templating in both circumstances. + ### Goals +- This BEP will settle the implementation for the templating of fields into the JSON Schema in the `parameters` section in the scaffolder templates. +- This BEP will settle how to pass through templating strings to underlying field extensions in a non-conflicting way. + ### Non-Goals +The proposal is to be able to decorate the template schema server side with a context and use that to drive the form rendering client side. + +We can extend the `/parameter-schema` endpoint to accept a `formData` context query parameter which will be a JSON object of the current `formData` state. + +```diff +export interface ScaffolderApi { + getTemplateParameterSchema( + templateRef: string, ++ formData?: string, + ): Promise; +} +``` + +```diff + router + .get( + '/v2/templates/:namespace/:kind/:name/parameter-schema', + async (req, res) => { + const credentials = await httpAuth.credentials(req); + const { token } = await auth.getPluginRequestToken({ + onBehalfOf: credentials, + targetPluginId: 'catalog', + }); + const template = await authorizeTemplate( + req.params, + token, + credentials, + ); + + const parameters = [template.spec.parameters ?? []].flat(); ++ const secureTemplater = await SecureTemplater.loadRenderer({ ++ templateFilters: { ++ ...createDefaultFilters({ integrations }), ++ ...additionalTemplateFilters, ++ }, ++ templateGlobals: additionalTemplateGlobals, ++ }); ++ ++ const templatedParameters = parameters.map(parameter => ++ renderTemplateString( ++ parameter, ++ { ++ parameters: req.query.formData, ++ }, ++ secureTemplater, ++ logger, ++ ), ++ ); +``` + +You can see a quick implementation of this in this [branch](https://github.com/backstage/backstage/compare/master...blam/templating-in-parameters) ## Design Details - +There's a slight issue with the implementation of the `react-jsonschema-form`, which makes things like live updating on things like the `default` field slightly more difficult. +Currently, on first render, the default value is populated and then stored in the `formData` object or the current state, and the default value is never re-evaluated again at a later stage. + +This means that if end users are wanting to set default values with `${{ parameters.myOtherProperty }}`, then they would need to ensure that they are on different steps in the form +as the form would need to be re-rendered, and for performance reasons, we don't want to re-render the form on every `formData` update. + +We could fix this, by implementing custom logic for when the `parameter-schema` is updated, if the updated field is in a `default: *` field, then we replace the previous value with the new value in the `formData` automatically. +This is a pretty ugly workaround, but maybe the only option we have. Also at this point, pretty unsure if this affects any other parts of the `JSONSchema`, and we would also have to implement it for those fields if they exist. + +Perhaps we just accept this as a limitation, and document it as such. ## Release Plan @@ -125,6 +175,8 @@ This section should describe the rollout process for any new features. It must t If there is any particular feedback to be gathered during the rollout, this should be described here as well. --> +This change is backwards compatible, and can be released in a minor release. There's no breaking changes to worry about here. + ## Dependencies + +#### Templating client side + +- This could lead to confusion as `filters` such as `parseRepoUrl` and `pick` and any custom filters which you define in the backend would not be available in the client side. +- Also with the limitations of the `default` value being updated only on first render and never re-evaluated, there's no performance benefit of doing things client side anymore. From 8db1ba1508ee0db37cb8c2690e59df43a018adee Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 27 May 2024 09:49:25 +0200 Subject: [PATCH 234/372] chore: give the bep a number and feelings Signed-off-by: blam --- .../README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename beps/{NNNN-scaffolder-templating-in-parameters => 0009-scaffolder-templating-in-parameters}/README.md (100%) diff --git a/beps/NNNN-scaffolder-templating-in-parameters/README.md b/beps/0009-scaffolder-templating-in-parameters/README.md similarity index 100% rename from beps/NNNN-scaffolder-templating-in-parameters/README.md rename to beps/0009-scaffolder-templating-in-parameters/README.md From 1c94fb14db0fd4df52356636f54dcafd5fd64c92 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 25 Jul 2024 08:52:31 +0200 Subject: [PATCH 235/372] chore: fix Signed-off-by: blam --- .../README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/beps/0009-scaffolder-templating-in-parameters/README.md b/beps/0009-scaffolder-templating-in-parameters/README.md index 450538ab8a..d5fc78497c 100644 --- a/beps/0009-scaffolder-templating-in-parameters/README.md +++ b/beps/0009-scaffolder-templating-in-parameters/README.md @@ -167,6 +167,20 @@ This is a pretty ugly workaround, but maybe the only option we have. Also at thi Perhaps we just accept this as a limitation, and document it as such. +Templating for `errorMessages` has been solved by using the `ajv-errors` library https://github.com/backstage/backstage/pull/25624, you can see more about [backrefs and pointers here](https://ajv.js.org/packages/ajv-errors.html). Any other template strings that will be passed through the underlying components and to be left untemplated should be encapsulated with options instead of passing through raw strings. The below example illustrates an `entityAndName` format, which under the hood, might do something like `${{ parameters.entity }} - ${{ parameters.name }}`, but this implementation never leaks out to the templating language. + +```yaml +parameters: + properties: + ... + description: + type: string + default: Test-description + ui:field: CustomDisplayField + ui:options: + format: entityAndName +``` + ## Release Plan -#### Templating client side +### Templating client side - This could lead to confusion as `filters` such as `parseRepoUrl` and `pick` and any custom filters which you define in the backend would not be available in the client side. - Also with the limitations of the `default` value being updated only on first render and never re-evaluated, there's no performance benefit of doing things client side anymore. + +### Accept limitation of the `default` field + +Rather than using a workaround to support re-evaluating the `default` field, we could instead accept it as a limitation, and document it as such. + +This is not desirable, as it is likely a very common use-case to want to template the `default` field, leading to a poor template creation experience. From 87b6e03693198482f257280297320bcef9236742 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 14 Aug 2024 12:08:37 +0200 Subject: [PATCH 266/372] docs/frontend-system: make space in architecture docs Signed-off-by: Patrik Oldsberg --- .../architecture/{01-index.md => 00-index.md} | 0 .../architecture/{02-app.md => 10-app.md} | 6 +++--- .../architecture/{04-plugins.md => 15-plugins.md} | 0 .../{03-extensions.md => 20-extensions.md} | 4 ++-- ...sion-overrides.md => 25-extension-overrides.md} | 2 +- .../{08-references.md => 30-references.md} | 0 .../{06-utility-apis.md => 33-utility-apis.md} | 2 +- .../architecture/{07-routes.md => 36-routes.md} | 0 ...08-naming-patterns.md => 50-naming-patterns.md} | 0 docs/frontend-system/building-apps/01-index.md | 4 ++-- .../building-apps/03-built-in-extensions.md | 2 +- docs/frontend-system/building-apps/08-migrating.md | 14 +++++++------- docs/frontend-system/building-plugins/01-index.md | 14 +++++++------- .../frontend-system/building-plugins/02-testing.md | 2 +- .../building-plugins/03-extension-types.md | 2 +- .../building-plugins/04-built-in-data-refs.md | 2 +- docs/frontend-system/utility-apis/01-index.md | 2 +- docs/frontend-system/utility-apis/02-creating.md | 2 +- .../frontend-system/utility-apis/04-configuring.md | 4 ++-- docs/plugins/composability.md | 4 ++-- microsite/sidebars.json | 6 +++--- 21 files changed, 36 insertions(+), 36 deletions(-) rename docs/frontend-system/architecture/{01-index.md => 00-index.md} (100%) rename docs/frontend-system/architecture/{02-app.md => 10-app.md} (95%) rename docs/frontend-system/architecture/{04-plugins.md => 15-plugins.md} (100%) rename docs/frontend-system/architecture/{03-extensions.md => 20-extensions.md} (99%) rename docs/frontend-system/architecture/{05-extension-overrides.md => 25-extension-overrides.md} (99%) rename docs/frontend-system/architecture/{08-references.md => 30-references.md} (100%) rename docs/frontend-system/architecture/{06-utility-apis.md => 33-utility-apis.md} (97%) rename docs/frontend-system/architecture/{07-routes.md => 36-routes.md} (100%) rename docs/frontend-system/architecture/{08-naming-patterns.md => 50-naming-patterns.md} (100%) diff --git a/docs/frontend-system/architecture/01-index.md b/docs/frontend-system/architecture/00-index.md similarity index 100% rename from docs/frontend-system/architecture/01-index.md rename to docs/frontend-system/architecture/00-index.md diff --git a/docs/frontend-system/architecture/02-app.md b/docs/frontend-system/architecture/10-app.md similarity index 95% rename from docs/frontend-system/architecture/02-app.md rename to docs/frontend-system/architecture/10-app.md index 3b839d4232..532971d124 100644 --- a/docs/frontend-system/architecture/02-app.md +++ b/docs/frontend-system/architecture/10-app.md @@ -33,13 +33,13 @@ const rootEl = document.getElementById('root')!; ReactDOM.createRoot(rootEl).render(app); ``` -We call `createApp` to create a new app instance, which is responsible for wiring together all of the features that we provide to the app. It also provides a set of built-in [Extensions](./03-extensions.md) that help build out the foundations of the app, as well as defaults for many other systems such as [Utility API](./06-utility-apis.md) implementations, components, icons, themes, and how to load configuration. No real work is done at the point of creating the app though, it's all deferred to the rendering of the element returned from `app.createRoot()`. +We call `createApp` to create a new app instance, which is responsible for wiring together all of the features that we provide to the app. It also provides a set of built-in [Extensions](./20-extensions.md) that help build out the foundations of the app, as well as defaults for many other systems such as [Utility API](./33-utility-apis.md) implementations, components, icons, themes, and how to load configuration. No real work is done at the point of creating the app though, it's all deferred to the rendering of the element returned from `app.createRoot()`. -It is possible to explicitly install features when creating the app, although typically these will instead be discovered automatically which we'll explore later on. Nevertheless these features are what build out the actual functionality of the app by providing [Extensions](./03-extensions.md). These extensions are wired together by the app into a tree structure known as the app extension tree. Each node in this tree receives data from its child nodes, and passes along data to its parent. The following diagram illustrates the shape of a small app extension tree. +It is possible to explicitly install features when creating the app, although typically these will instead be discovered automatically which we'll explore later on. Nevertheless these features are what build out the actual functionality of the app by providing [Extensions](./20-extensions.md). These extensions are wired together by the app into a tree structure known as the app extension tree. Each node in this tree receives data from its child nodes, and passes along data to its parent. The following diagram illustrates the shape of a small app extension tree. ![frontend system app structure diagram](../../assets/frontend-system/architecture-app.drawio.svg) -Each node in this tree is an extension with a parent node and children. The colored shapes represent extension data inputs and output, where each color is one unique type of data. You can see that there are both extensions that output data that is ignored by the parent, as well as extensions that accept inputs but do not have any children. There are a couple of different tools at your disposal when creating and extension that lets you define different requirements for your inputs and output, which we will cover in greater details in the [Extensions](./03-extensions.md) section. +Each node in this tree is an extension with a parent node and children. The colored shapes represent extension data inputs and output, where each color is one unique type of data. You can see that there are both extensions that output data that is ignored by the parent, as well as extensions that accept inputs but do not have any children. There are a couple of different tools at your disposal when creating and extension that lets you define different requirements for your inputs and output, which we will cover in greater details in the [Extensions](./20-extensions.md) section. A common type of data that is shared between extensions is React elements and components. These can in turn be rendered by each other in their own React components, which ends up forming a parallel tree of React components that is similar in shape to that of the app extension tree. At the top of the app extension tree is a built-in root extension that among other things outputs a React element. This element also ends up being the root of the parallel React tree, and is rendered by the React element returned by `app.createRoot()`. diff --git a/docs/frontend-system/architecture/04-plugins.md b/docs/frontend-system/architecture/15-plugins.md similarity index 100% rename from docs/frontend-system/architecture/04-plugins.md rename to docs/frontend-system/architecture/15-plugins.md diff --git a/docs/frontend-system/architecture/03-extensions.md b/docs/frontend-system/architecture/20-extensions.md similarity index 99% rename from docs/frontend-system/architecture/03-extensions.md rename to docs/frontend-system/architecture/20-extensions.md index 2f3daba6f8..eec9947c97 100644 --- a/docs/frontend-system/architecture/03-extensions.md +++ b/docs/frontend-system/architecture/20-extensions.md @@ -8,7 +8,7 @@ description: Frontend extensions > **NOTE: The new frontend system is in alpha and is only supported by a small number of plugins.** -As mentioned in the [previous section](./02-app.md), Backstage apps are built up from a tree of extensions. This section will go into more detail about what extensions are, how to create and use them, and how to create your own extensibility patterns. +As mentioned in the [previous section](./10-app.md), Backstage apps are built up from a tree of extensions. This section will go into more detail about what extensions are, how to create and use them, and how to create your own extensibility patterns. ## Extension Structure @@ -317,7 +317,7 @@ The `id` of the extension is then build out of `namespace`, `name` & `kind` like id: kind:namespace/name ``` -For more information on naming of extension refer to the [naming patterns documentation](./08-naming-patterns.md). +For more information on naming of extension refer to the [naming patterns documentation](./50-naming-patterns.md). ### Extension Creators in libraries diff --git a/docs/frontend-system/architecture/05-extension-overrides.md b/docs/frontend-system/architecture/25-extension-overrides.md similarity index 99% rename from docs/frontend-system/architecture/05-extension-overrides.md rename to docs/frontend-system/architecture/25-extension-overrides.md index 41702e6823..42a7f365a1 100644 --- a/docs/frontend-system/architecture/05-extension-overrides.md +++ b/docs/frontend-system/architecture/25-extension-overrides.md @@ -89,7 +89,7 @@ Note that it can still be a good idea to split your overrides out into separate To override an extension that is provided by a plugin, you need to provide a new extension that has the same ID as the existing extension. That is, all kind, namespace, and name options must match the extension you want to replace. This means that you typically need to provide an explicit `namespace` when overriding extensions from a plugin. :::info -We recommend that plugin developers share the extension IDs in their plugin documentation, but usually you can infer the ID by following the [naming patterns](./08-naming-patterns.md) documentation. +We recommend that plugin developers share the extension IDs in their plugin documentation, but usually you can infer the ID by following the [naming patterns](./50-naming-patterns.md) documentation. ::: ### Example diff --git a/docs/frontend-system/architecture/08-references.md b/docs/frontend-system/architecture/30-references.md similarity index 100% rename from docs/frontend-system/architecture/08-references.md rename to docs/frontend-system/architecture/30-references.md diff --git a/docs/frontend-system/architecture/06-utility-apis.md b/docs/frontend-system/architecture/33-utility-apis.md similarity index 97% rename from docs/frontend-system/architecture/06-utility-apis.md rename to docs/frontend-system/architecture/33-utility-apis.md index 49e5854b65..c20936f819 100644 --- a/docs/frontend-system/architecture/06-utility-apis.md +++ b/docs/frontend-system/architecture/33-utility-apis.md @@ -10,7 +10,7 @@ description: Utility APIs ## Overview -Utility APIs are pieces of standalone functionality, interfaces that can be requested by plugins to use. They are defined by a TypeScript interface as well as a reference (an "API ref") used to access its implementation. They can be provided both by plugins and the core framework, and are themselves [extensions](../architecture/03-extensions.md) that can have inputs, be replaced, and be declaratively configured in your app-config. +Utility APIs are pieces of standalone functionality, interfaces that can be requested by plugins to use. They are defined by a TypeScript interface as well as a reference (an "API ref") used to access its implementation. They can be provided both by plugins and the core framework, and are themselves [extensions](../architecture/20-extensions.md) that can have inputs, be replaced, and be declaratively configured in your app-config. A common example of a utility API is a client interface to interact with the backend part of a plugin, such as the catalog client. Any frontend plugin can then request an implementation of that interface to make requests through. diff --git a/docs/frontend-system/architecture/07-routes.md b/docs/frontend-system/architecture/36-routes.md similarity index 100% rename from docs/frontend-system/architecture/07-routes.md rename to docs/frontend-system/architecture/36-routes.md diff --git a/docs/frontend-system/architecture/08-naming-patterns.md b/docs/frontend-system/architecture/50-naming-patterns.md similarity index 100% rename from docs/frontend-system/architecture/08-naming-patterns.md rename to docs/frontend-system/architecture/50-naming-patterns.md diff --git a/docs/frontend-system/building-apps/01-index.md b/docs/frontend-system/building-apps/01-index.md index ea7fe20948..bb09fb6907 100644 --- a/docs/frontend-system/building-apps/01-index.md +++ b/docs/frontend-system/building-apps/01-index.md @@ -66,7 +66,7 @@ Linking routes from different plugins requires this configuration. You can do th ### Enable feature discovery -Use this setting to enable experimental feature discovery when building your app with `@backstage/cli`. With this configuration your application tries to discover and install package extensions automatically, check [here](../architecture/02-app.md#feature-discovery) for more details. +Use this setting to enable experimental feature discovery when building your app with `@backstage/cli`. With this configuration your application tries to discover and install package extensions automatically, check [here](../architecture/10-app.md#feature-discovery) for more details. :::warning Remember that package extensions that are not auto-discovered must be manually added to the application when creating an app. See [features](#install-features-manually) for more details. @@ -99,7 +99,7 @@ export default app.createRoot(); ``` :::info -You can also pass overrides to the features array, for more details, please read the [extension overrides](../architecture/05-extension-overrides.md) documentation. +You can also pass overrides to the features array, for more details, please read the [extension overrides](../architecture/25-extension-overrides.md) documentation. ::: ### Using an async features loader diff --git a/docs/frontend-system/building-apps/03-built-in-extensions.md b/docs/frontend-system/building-apps/03-built-in-extensions.md index a5e6476eb0..5f74100df0 100644 --- a/docs/frontend-system/building-apps/03-built-in-extensions.md +++ b/docs/frontend-system/building-apps/03-built-in-extensions.md @@ -24,7 +24,7 @@ Be careful when disabling built-in extensions, as there may be other extensions ## Override built-in extensions -You can override any built-in extension whenever their customizations, whether through configuration or input, do not meet a use case for your Backstage instance. Check out [this](../architecture/05-extension-overrides.md) documentation on how to override application extensions. +You can override any built-in extension whenever their customizations, whether through configuration or input, do not meet a use case for your Backstage instance. Check out [this](../architecture/25-extension-overrides.md) documentation on how to override application extensions. :::warning Be aware there could be some implementation requirements to properly override an built-in extension, such as using same apis and do not remove inputs or configurations otherwise you can cause a side effect in other parts of the system that expects same minimal behavior. diff --git a/docs/frontend-system/building-apps/08-migrating.md b/docs/frontend-system/building-apps/08-migrating.md index 716e0da772..5d92478661 100644 --- a/docs/frontend-system/building-apps/08-migrating.md +++ b/docs/frontend-system/building-apps/08-migrating.md @@ -23,7 +23,7 @@ import { createApp } from '@backstage/frontend-app-api'; This immediate switch will lead to a lot of breakages that we need to fix. -Let's start by addressing the change to `app.createRoot(...)`, which no longer accepts any arguments. This represents a fundamental change that the new frontend system introduces. In the old system the app element tree that you passed to `app.createRoot(...)` was the primary way that you installed and configured plugins and features in your app. In the new system this is instead replaced by extensions that are wired together into an extension tree. Much more responsibility has now been shifted to plugins, for example you no longer have to manually provide the route path for each plugin page, but instead only configure it if you want to override the default. For more information on how the new system works, see the [architecture](../architecture/01-index.md) section. +Let's start by addressing the change to `app.createRoot(...)`, which no longer accepts any arguments. This represents a fundamental change that the new frontend system introduces. In the old system the app element tree that you passed to `app.createRoot(...)` was the primary way that you installed and configured plugins and features in your app. In the new system this is instead replaced by extensions that are wired together into an extension tree. Much more responsibility has now been shifted to plugins, for example you no longer have to manually provide the route path for each plugin page, but instead only configure it if you want to override the default. For more information on how the new system works, see the [architecture](../architecture/00-index.md) section. Given that the app element tree is most of what builds up the app, it's likely also going to be the majority of the migration effort. In order to make the migration as smooth as possible we have provided a helper that lets you convert an existing app element tree into plugins that you can install in a new app. This in turn allows for a gradual migration of individual plugins, rather than needing to migrate the entire app structure at once. @@ -95,7 +95,7 @@ At this point the contents of your app should be past the initial migration stag ## Migrating `createApp` Options -Many of the `createApp` options have been migrated to use extensions instead. Each will have their own [extension creator](../architecture/03-extensions.md#extension-creators) that you use to create a custom extension. To add these standalone extensions to the app they need to be passed to `createExtensionOverrides`, which bundles them into a _feature_ that you can install in the app. See the [standalone extensions](../architecture/05-extension-overrides.md#create-standalone-extensions) section for more information. +Many of the `createApp` options have been migrated to use extensions instead. Each will have their own [extension creator](../architecture/20-extensions.md#extension-creators) that you use to create a custom extension. To add these standalone extensions to the app they need to be passed to `createExtensionOverrides`, which bundles them into a _feature_ that you can install in the app. See the [standalone extensions](../architecture/25-extension-overrides.md#create-standalone-extensions) section for more information. For example, assuming you have a `lightTheme` extension that you want to add to your app, you can use the following: @@ -176,7 +176,7 @@ createApp({ }); ``` -Plugins don't even have to be imported manually after installing their package if [features discovery](../architecture/02-app.md#feature-discovery) is enabled. +Plugins don't even have to be imported manually after installing their package if [features discovery](../architecture/10-app.md#feature-discovery) is enabled. ```yaml title="in app-config.yaml" app: @@ -219,7 +219,7 @@ createPlugin({ Many app components are now installed as extensions instead using `createComponentExtension`. See the section on [configuring app components](./01-index.md#configure-your-app) for more information. -The `Router` component is now a built-in extension that you can [override](../architecture/05-extension-overrides.md) using `createRouterExtension`. +The `Router` component is now a built-in extension that you can [override](../architecture/25-extension-overrides.md) using `createRouterExtension`. The Sign-in page is now installed as an extension using the `createSignInPageExtension` instead. @@ -341,7 +341,7 @@ const app = createApp({ ### `bindRoutes` -Route bindings can still be done using this option, but you now also have the ability to bind routes using static configuration instead. See the section on [binding routes](../architecture/07-routes.md#binding-external-route-references) for more information. +Route bindings can still be done using this option, but you now also have the ability to bind routes using static configuration instead. See the section on [binding routes](../architecture/36-routes.md#binding-external-route-references) for more information. Note that if you are binding routes from a legacy plugin that was converted using `convertLegacyApp`, you will need to use the `convertLegacyRouteRefs` and/or `convertLegacyRouteRef` to convert the routes to be compatible with the new system. @@ -470,7 +470,7 @@ const routes = ( ); ``` -If you are using [app feature discovery](../architecture/02-app.md#feature-discovery) the installation step is simple, it's already done! The new version of the scaffolder plugin was already discovered and present in the app, it was simply disabled because the plugin created from the legacy route had higher priority. If you do not use feature discovery, you will instead need to manually install the new scaffolder plugin in your app through the `features` option of `createApp`. +If you are using [app feature discovery](../architecture/10-app.md#feature-discovery) the installation step is simple, it's already done! The new version of the scaffolder plugin was already discovered and present in the app, it was simply disabled because the plugin created from the legacy route had higher priority. If you do not use feature discovery, you will instead need to manually install the new scaffolder plugin in your app through the `features` option of `createApp`. Continue this process for each of your legacy routes until you have migrated all of them. For any plugin with additional extensions installed as children of the `Route`, refer to the plugin READMEs for more detailed instructions. For the entity pages, refer to the [separate section](#entity-pages). @@ -482,7 +482,7 @@ The entity pages are typically defined in `packages/app/src/components/catalog` New apps feature a built-in sidebar extension (`app/nav`) that will render all nav item extensions provided by plugins. This is a placeholder implementation and not intended as a long-term solution. In the future we will aim to provide a more flexible sidebar extension that allows for more customization out of the box. -Because the built-in sidebar is quite limited you may want to override the sidebar with your own custom implementation. To do so, use `createExtension` directly and refer to the [original sidebar implementation](https://github.com/backstage/backstage/blob/master/packages/frontend-app-api/src/extensions/AppNav.tsx). The following is an example of how to take your existing sidebar from the `Root` component that you typically find in `packages/app/src/components/Root.tsx`, and use it in an [extension override](../architecture/05-extension-overrides.md): +Because the built-in sidebar is quite limited you may want to override the sidebar with your own custom implementation. To do so, use `createExtension` directly and refer to the [original sidebar implementation](https://github.com/backstage/backstage/blob/master/packages/frontend-app-api/src/extensions/AppNav.tsx). The following is an example of how to take your existing sidebar from the `Root` component that you typically find in `packages/app/src/components/Root.tsx`, and use it in an [extension override](../architecture/25-extension-overrides.md): ```tsx const nav = createExtension({ diff --git a/docs/frontend-system/building-plugins/01-index.md b/docs/frontend-system/building-plugins/01-index.md index f8d80f9382..618e660f2b 100644 --- a/docs/frontend-system/building-plugins/01-index.md +++ b/docs/frontend-system/building-plugins/01-index.md @@ -8,9 +8,9 @@ description: Building frontend plugins using the new frontend system > **NOTE: The new frontend system is in alpha and is only supported by a small number of plugins.** -This section covers how to build your own frontend [plugins](../architecture/04-plugins.md) and -[overrides](../architecture/05-extension-overrides.md). They are sometimes collectively referred to as -frontend _features_, and what you install to build up a Backstage frontend [app](../architecture/02-app.md). +This section covers how to build your own frontend [plugins](../architecture/15-plugins.md) and +[overrides](../architecture/25-extension-overrides.md). They are sometimes collectively referred to as +frontend _features_, and what you install to build up a Backstage frontend [app](../architecture/10-app.md). ## Creating a new plugin @@ -43,13 +43,13 @@ export { examplePlugin as default } from './plugin'; Note that we export the plugin as the default export of our package from `src/index.ts`. This is important, as it is how users of our plugin are able to seamlessly install the plugin package in a Backstage app without having to reference the plugin instance through code. -The plugin ID should be a lowercase dash-separated string, while the plugin instance variable should be the camel case version of the ID with a `Plugin` suffix. For more details on naming patterns within the frontend system, see [the article on naming patterns](../architecture/08-naming-patterns.md). By sticking to these naming patterns you ensure that users of your plugin more easily recognize the exports and features provided by your plugin. +The plugin ID should be a lowercase dash-separated string, while the plugin instance variable should be the camel case version of the ID with a `Plugin` suffix. For more details on naming patterns within the frontend system, see [the article on naming patterns](../architecture/50-naming-patterns.md). By sticking to these naming patterns you ensure that users of your plugin more easily recognize the exports and features provided by your plugin. ## Adding extensions -The plugin that we created above is empty, and doesn't provide any actual functionality. To add functionality to a plugin you need to create and provide it with one or more [extensions](../architecture/03-extensions.md). Let's continue by adding a standalone page to our plugin, as well as a navigation item that allows users to navigate to the page. +The plugin that we created above is empty, and doesn't provide any actual functionality. To add functionality to a plugin you need to create and provide it with one or more [extensions](../architecture/20-extensions.md). Let's continue by adding a standalone page to our plugin, as well as a navigation item that allows users to navigate to the page. -To create a new extension you typically use pre-defined [extension creators](../architecture/03-extensions.md#extension-creators), provided either by the framework itself or by other plugins. In this case we'll need to use `createPageExtension` and `createNavItemExtension`, both from `@backstage/frontend-plugin-api`. We will also need to [create a route reference](../architecture/07-routes.md#creating-a-route-reference) to use as a reference for out page, allowing us to dynamically create URLs that link to our page. +To create a new extension you typically use pre-defined [extension creators](../architecture/20-extensions.md#extension-creators), provided either by the framework itself or by other plugins. In this case we'll need to use `createPageExtension` and `createNavItemExtension`, both from `@backstage/frontend-plugin-api`. We will also need to [create a route reference](../architecture/36-routes.md#creating-a-route-reference) to use as a reference for out page, allowing us to dynamically create URLs that link to our page. ```tsx title="in src/routes.ts" import { createRouteRef } from '@backstage/frontend-plugin-api'; @@ -106,7 +106,7 @@ export const examplePlugin = createPlugin({ What we've built here is a very common type of plugin. It's a top-level tool that provides a single page, along with a method for navigating to that page. The implementation of the page component, in this case the highlighted `ExamplePage`, can be arbitrarily complex. It can be anything from a single simple information page, to a full-blown application with multiple sub-pages. -We have also provided external access to our route reference by passing it to the plugin `routes` option. This makes it possible for app integrators to bind an external link from a different plugin to our plugin page. You can read more about how this works in the [External Route References](../architecture/07-routes.md#external-route-references) section. +We have also provided external access to our route reference by passing it to the plugin `routes` option. This makes it possible for app integrators to bind an external link from a different plugin to our plugin page. You can read more about how this works in the [External Route References](../architecture/36-routes.md#external-route-references) section. ## Utility APIs diff --git a/docs/frontend-system/building-plugins/02-testing.md b/docs/frontend-system/building-plugins/02-testing.md index 26c9503c6d..f665ed0f0c 100644 --- a/docs/frontend-system/building-plugins/02-testing.md +++ b/docs/frontend-system/building-plugins/02-testing.md @@ -41,7 +41,7 @@ describe('Entity details component', () => { }); ``` -To mock [Utility APIs](../architecture/06-utility-apis.md) that are used by your component you can use the `TestApiProvider` to override individual API implementations. In the snippet below, we wrap the component within a `TestApiProvider` in order to mock the catalog client API: +To mock [Utility APIs](../architecture/33-utility-apis.md) that are used by your component you can use the `TestApiProvider` to override individual API implementations. In the snippet below, we wrap the component within a `TestApiProvider` in order to mock the catalog client API: ```tsx import React from 'react'; diff --git a/docs/frontend-system/building-plugins/03-extension-types.md b/docs/frontend-system/building-plugins/03-extension-types.md index 1f3baaa710..c7c2e2ab1f 100644 --- a/docs/frontend-system/building-plugins/03-extension-types.md +++ b/docs/frontend-system/building-plugins/03-extension-types.md @@ -8,7 +8,7 @@ description: Extension types provided by the frontend system and core features > **NOTE: The new frontend system is in alpha and is only supported by a small number of plugins.** -This section covers many of the [extension types](../architecture/03-extensions.md#extension-creators) available at your disposal when building Backstage frontend plugins. +This section covers many of the [extension types](../architecture/20-extensions.md#extension-creators) available at your disposal when building Backstage frontend plugins. ## Built-in extension types diff --git a/docs/frontend-system/building-plugins/04-built-in-data-refs.md b/docs/frontend-system/building-plugins/04-built-in-data-refs.md index dacbbf30f1..d13e734279 100644 --- a/docs/frontend-system/building-plugins/04-built-in-data-refs.md +++ b/docs/frontend-system/building-plugins/04-built-in-data-refs.md @@ -8,7 +8,7 @@ description: Configuring or overriding built-in extension data references > **NOTE: The new frontend system is in alpha and is only supported by a small number of plugins.** -To have a better understanding of extension data references please read [the corresponding architecture section](../architecture/03-extensions.md#extension-data) first. +To have a better understanding of extension data references please read [the corresponding architecture section](../architecture/20-extensions.md#extension-data) first. ## Built-in extension data references diff --git a/docs/frontend-system/utility-apis/01-index.md b/docs/frontend-system/utility-apis/01-index.md index 37120a5152..07f7dcc2a8 100644 --- a/docs/frontend-system/utility-apis/01-index.md +++ b/docs/frontend-system/utility-apis/01-index.md @@ -8,7 +8,7 @@ description: Working with Utility APIs in the New Frontend System > **NOTE: The new frontend system is in alpha and is only supported by a small number of plugins.** -As described [in the architecture section](../architecture/06-utility-apis.md), utility APIs are pieces of shared functionality - interfaces that can be requested by plugins to use. They are defined by a TypeScript interface as well as a reference (an "API ref") used to access its implementation. They can be provided both by plugins and the core framework, and are themselves [extensions](../architecture/03-extensions.md) that can accept inputs, be declaratively configured in your app-config, or transparently be replaced entirely with custom implementations that fulfill the same contract. +As described [in the architecture section](../architecture/33-utility-apis.md), utility APIs are pieces of shared functionality - interfaces that can be requested by plugins to use. They are defined by a TypeScript interface as well as a reference (an "API ref") used to access its implementation. They can be provided both by plugins and the core framework, and are themselves [extensions](../architecture/20-extensions.md) that can accept inputs, be declaratively configured in your app-config, or transparently be replaced entirely with custom implementations that fulfill the same contract. ## Creating utility APIs diff --git a/docs/frontend-system/utility-apis/02-creating.md b/docs/frontend-system/utility-apis/02-creating.md index fcb7ff1a65..77caaf55f0 100644 --- a/docs/frontend-system/utility-apis/02-creating.md +++ b/docs/frontend-system/utility-apis/02-creating.md @@ -86,7 +86,7 @@ For illustration we make a skeleton implementation class and the API extension a The code also illustrates how the API factory declares a dependency on another utility API - the core storage API in this case. An instance of that utility API is then provided to the factory function. -The resulting extension ID of the work API will be the kind `api:` followed by the plugin ID as the namespace, in this case ending up as `api:plugin.example.work`. Check out [the naming patterns doc](../architecture/08-naming-patterns.md) for more information on how this works. You can now use this ID to refer to the API in app-config and elsewhere. +The resulting extension ID of the work API will be the kind `api:` followed by the plugin ID as the namespace, in this case ending up as `api:plugin.example.work`. Check out [the naming patterns doc](../architecture/50-naming-patterns.md) for more information on how this works. You can now use this ID to refer to the API in app-config and elsewhere. ## Adding configurability diff --git a/docs/frontend-system/utility-apis/04-configuring.md b/docs/frontend-system/utility-apis/04-configuring.md index 7acf23decf..d22e10011b 100644 --- a/docs/frontend-system/utility-apis/04-configuring.md +++ b/docs/frontend-system/utility-apis/04-configuring.md @@ -12,7 +12,7 @@ Utility APIs are extensions and can therefore optionally be amended with configu ## Configuring -To configure your Utility API extension, first you'll need to know its ID. That ID is formed from the API ref ID; check [the naming patterns docs](../architecture/08-naming-patterns.md) for details. +To configure your Utility API extension, first you'll need to know its ID. That ID is formed from the API ref ID; check [the naming patterns docs](../architecture/50-naming-patterns.md) for details. Our example work API from [the creating section](./02-creating.md) would have the ID `api:plugin.example.work`. You configure it and all other extensions under the `app.extensions` section of your app-config. @@ -37,7 +37,7 @@ Well written input-enabled extension often have extension creator functions that ## Replacing a Utility API implementation -Like with other extension types, you replace Utility APIs with your own custom implementation using [extension overrides](../architecture/05-extension-overrides.md). +Like with other extension types, you replace Utility APIs with your own custom implementation using [extension overrides](../architecture/25-extension-overrides.md). ```tsx title="in your app" /* highlight-add-start */ diff --git a/docs/plugins/composability.md b/docs/plugins/composability.md index 1a9c0babf9..a0e0e2d5e6 100644 --- a/docs/plugins/composability.md +++ b/docs/plugins/composability.md @@ -329,7 +329,7 @@ You can also use static configuration to bind routes, removing the need to make changes to the app code. It does however mean that you won't get type safety when binding routes and compile-time validation of the bindings. Static configuration of route bindings is done under the `app.routes.bindings` key in -`app-config.yaml`. It works the same way as [route bindings in the new frontend system](../frontend-system/architecture/07-routes.md#binding-external-route-references), +`app-config.yaml`. It works the same way as [route bindings in the new frontend system](../frontend-system/architecture/36-routes.md#binding-external-route-references), for example: ```yaml @@ -342,7 +342,7 @@ app: ### Default Targets for External Route References Following the `1.28` release of Backstage you can now define default targets for -external route references. They work the same way as [default targets in the new frontend system](../frontend-system/architecture/07-routes.md#default-targets-for-external-route-references), +external route references. They work the same way as [default targets in the new frontend system](../frontend-system/architecture/36-routes.md#default-targets-for-external-route-references), for example: ```ts diff --git a/microsite/sidebars.json b/microsite/sidebars.json index ddccb14c91..be17d76e03 100644 --- a/microsite/sidebars.json +++ b/microsite/sidebars.json @@ -452,13 +452,13 @@ "items": [ "frontend-system/architecture/index", "frontend-system/architecture/app", - "frontend-system/architecture/extensions", "frontend-system/architecture/plugins", + "frontend-system/architecture/extensions", "frontend-system/architecture/extension-overrides", + "frontend-system/architecture/references", "frontend-system/architecture/utility-apis", "frontend-system/architecture/routes", - "frontend-system/architecture/naming-patterns", - "frontend-system/architecture/references" + "frontend-system/architecture/naming-patterns" ] }, { From d61f075df212a78f012bbe3e5a3293a98af74507 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 14 Aug 2024 12:24:59 +0200 Subject: [PATCH 267/372] docs: add placeholder extension blueprints doc Signed-off-by: Patrik Oldsberg --- .../architecture/23-extension-blueprints.md | 11 +++++++++++ microsite/sidebars.json | 1 + 2 files changed, 12 insertions(+) create mode 100644 docs/frontend-system/architecture/23-extension-blueprints.md diff --git a/docs/frontend-system/architecture/23-extension-blueprints.md b/docs/frontend-system/architecture/23-extension-blueprints.md new file mode 100644 index 0000000000..046834c9db --- /dev/null +++ b/docs/frontend-system/architecture/23-extension-blueprints.md @@ -0,0 +1,11 @@ +--- +id: extension-blueprints +title: Frontend Extension Blueprints +sidebar_label: Extensions Blueprints +# prettier-ignore +description: Frontend extensions +--- + +> **NOTE: The new frontend system is in alpha and is only supported by a small number of plugins.** + +TODO diff --git a/microsite/sidebars.json b/microsite/sidebars.json index be17d76e03..de7f39f0c0 100644 --- a/microsite/sidebars.json +++ b/microsite/sidebars.json @@ -454,6 +454,7 @@ "frontend-system/architecture/app", "frontend-system/architecture/plugins", "frontend-system/architecture/extensions", + "frontend-system/architecture/extension-blueprints", "frontend-system/architecture/extension-overrides", "frontend-system/architecture/references", "frontend-system/architecture/utility-apis", From d33c7d78901a25f1d28eb51ff53b8a915ea84522 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 14 Aug 2024 14:18:56 +0200 Subject: [PATCH 268/372] docs/frontend-system: initial extension blueprint docs with usage Signed-off-by: Patrik Oldsberg --- .../architecture/23-extension-blueprints.md | 53 ++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/docs/frontend-system/architecture/23-extension-blueprints.md b/docs/frontend-system/architecture/23-extension-blueprints.md index 046834c9db..43212d4a87 100644 --- a/docs/frontend-system/architecture/23-extension-blueprints.md +++ b/docs/frontend-system/architecture/23-extension-blueprints.md @@ -8,4 +8,55 @@ description: Frontend extensions > **NOTE: The new frontend system is in alpha and is only supported by a small number of plugins.** -TODO +The `createExtension` function and related APIs is considered a low-level building and fairly advanced building block, and is not typically what you would use when building plugins and features. Instead, the core APIs and plugins provide extension blueprints that makes it easier to create extensions for specific usages. These blueprints accept a number of parameters that is up to each blueprint to define, and then creates a new extension using the provided parameters. New blueprints are created using the `createExtensionBlueprint` function, and are by convention exported with the symbol `Blueprint`. If you are curious about what blueprints are available from a plugin or package, look for `*Blueprint` exports in the package's API, for plugins these are typically found in the `*-react` package. + +## Creating an extension from a blueprint + +Every extension blueprint provides a `make` method that can be used to create new extensions. It is a simple way to create a new extension where the base blueprint provides all the necessary functionality. All you need to do is to provide the necessary blueprint parameters, but you also have the ability to provide additional options, for example a `name` for the extension. + +The following is a simple example of how one might use the blueprint `make` method to create a new extension: + +```tsx +const myPageExtension = PageBlueprint.make({ + params: { + defaultPath: '/my-page', + loader: () => import('./components/MyPage').them(m => ), + }, +}); +``` + +The returned `myPageExtension` is an extension which is ready to be used in a plugin. It is the same type of object as is returned by the lower level `createExtension` function. + +## Creating an extension from a blueprint with overrides + +Every extension blueprint also provides a `makeWithOverrides` method. It is useful in cases where you want to provide additional integration points for an extension created with a blueprint. You might for example want to define additional inputs or configuration schema, or use the existing configuration to dynamically compute the parameters passed to the blueprint. + +The following is an example of how one might use the blueprint `makeWithOverrides` method to create a new extension: + +```tsx +const myPageExtension = PageBlueprint.makeWithOverrides({ + config: { + schema: { + layout: z => z.enum(['grid', 'rows']).default('grid'), + }, + }, + // The original blueprint factory is provided as the first argument + factory(originalFactory, { config }) { + // Call and forward the result from the original factory, providing + // the blueprint parameters as the first argument. + return originalFactory({ + defaultPath: '/my-page', + loader: () => + import('./components/MyPage').them(m => ( + // We can now access values from the factory context when providing + // the blueprint parameters, such as config values. + + )), + }); + }, +}); +``` + +When using `makeWithOverrides`, we no longer pass the blueprint parameters directly. Instead, we provide a `factory` function that receives the original blueprint factory as the first argument, and the extension factory context as the second. We can then call the original blueprint factory with the blueprint parameters and forward the result as the return value of out factory. Notice that when passing the blueprint parameters using this pattern we have access to a lot more information than when using the `make` method, at the cost of being more complex. + +Apart from the addition of the blueprint parameters of the first argument to the original factory function, the `makeWithOverrides` method works the same way as [extension overrides](./25-extension-overrides.md). All the same options and rules apply, including the ability to define additional inputs, override outputs, and so on. We therefore defer to the [extension overrides](./25-extension-overrides.md) documentation for more information on how to use the `makeWithOverrides` method. From 285e2b0b4bc138c3175162107bf1e3b5c1000941 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 14 Aug 2024 14:19:18 +0200 Subject: [PATCH 269/372] docs/frontend-system: remove extension creator docs Signed-off-by: Patrik Oldsberg --- .../architecture/20-extensions.md | 36 +++---------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/docs/frontend-system/architecture/20-extensions.md b/docs/frontend-system/architecture/20-extensions.md index eec9947c97..d1024d5e17 100644 --- a/docs/frontend-system/architecture/20-extensions.md +++ b/docs/frontend-system/architecture/20-extensions.md @@ -293,38 +293,6 @@ app: title: 'Backstage' ``` -## Extension Creators - -With creating an extension by using `createExtension(...)` you have the advantage that the extension can be anything in your Backstage application. We realised that this comes with the trade-off of having to repeat boilerplate code for similar building blocks. Here extension creators come into play for covering common building blocks in Backstage like pages using `createPageExtension`, themes using the `createThemeExtension` or items for the navigation using `createNavItemExtension`. - -If we follow the example from above all items of the navigation have similarities, like they all want to be attached to the same extension with the same input as well as rendering the same navigation item component. Therefore `createExtension` can be abstracted for this use case to `createNavItemExtension` and if we add the extension to the app it will end up in the right place & looks like we expect a navigation item to look. - -```tsx -export const HomeNavIcon = createNavItemExtension({ - routeRef: routeRefForTheHomePage, - title: 'Home', - icon: HomeIcon, -}); -``` - -### Extension Kind - -With the example `HomeNavIcon` will end up on the extension input `items` of the extensions with the id `app/nav`. It raises the question what the `id` of the `HomeNavIcon` itself is. The extension creator for the navigation item has a defined `kind`, which by convention matches the own name. So in this example `createNavItemExtension` sets the kind to `nav-item`. - -The `id` of the extension is then build out of `namespace`, `name` & `kind` like the following - where `namespace` & `name` are optional properties that can be passed to the extension creator: - -``` -id: kind:namespace/name -``` - -For more information on naming of extension refer to the [naming patterns documentation](./50-naming-patterns.md). - -### Extension Creators in libraries - -Extension creators should be exported from frontend library packages (e.g. `*-react`) rather than plugin packages. - -If an extension is only for in-house tweaks, it's okay to put it in the plugin package. But if you want other open source plugins to use it, or you already have a `-react` package, always put extension creators in the `-react` package. - ## Extension Boundary The `ExtensionBoundary` wraps extensions with several React contexts for different purposes @@ -370,3 +338,7 @@ export function createSomeExtension< }); } ``` + +### Extension Creators (Deprecated) + +Previous iterations of the frontend system used an "extension creator" pattern, where `createExtension` was wrapped up in a function for creating specific extension kinds. This pattern was similar to [blueprints](./23-extension-blueprints.md), but much harder to implement and maintain. It has been deprecated in favor of the new blueprints API. For example, `createPageExtension` was the extension creator equivalent of `PageBlueprint`. From 24bed625443e991f6c9a1234434c9068f0b2e248 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Tue, 13 Aug 2024 16:03:41 +0200 Subject: [PATCH 270/372] backend-app-api: Remove deprecated service implementations Co-authored-by: Camila Belo Signed-off-by: Johan Haals --- packages/backend-app-api/api-report.md | 207 -------------- packages/backend-app-api/src/http/index.ts | 6 +- .../auth/authServiceFactory.ts | 24 -- .../services/implementations/auth/index.ts | 17 -- .../cache/cacheServiceFactory.ts | 40 --- .../services/implementations/cache/index.ts | 17 -- .../services/implementations/config/index.ts | 18 -- .../config/rootConfigServiceFactory.ts | 61 ----- .../database/databaseServiceFactory.ts | 52 ---- .../implementations/database/index.ts | 17 -- .../services/implementations/deprecated.ts | 24 -- .../discovery/HostDiscovery.test.ts | 257 ------------------ .../discovery/HostDiscovery.ts | 71 ----- .../discovery/discoveryServiceFactory.ts | 35 --- .../implementations/discovery/index.ts | 18 -- .../httpAuth/httpAuthServiceFactory.ts | 24 -- .../implementations/httpAuth/index.ts | 17 -- .../httpRouter/createLifecycleMiddleware.ts | 45 --- .../httpRouter/httpRouterServiceFactory.ts | 30 -- .../implementations/httpRouter/index.ts | 19 -- .../src/services/implementations/index.ts | 10 - .../implementations/lifecycle/index.ts | 17 -- .../lifecycle/lifecycleServiceFactory.ts | 109 -------- .../services/implementations/logger/index.ts | 17 -- .../logger/loggerServiceFactory.ts | 30 -- .../implementations/permissions/index.ts | 17 -- .../permissions/permissionsServiceFactory.ts | 42 --- .../DefaultRootHttpRouter.test.ts | 124 --------- .../rootHttpRouter/DefaultRootHttpRouter.ts | 54 ---- .../implementations/rootHttpRouter/index.ts | 25 -- .../rootHttpRouterServiceFactory.ts | 46 ---- .../implementations/rootLifecycle/index.ts | 17 -- .../rootLifecycleServiceFactory.test.ts | 60 ---- .../rootLifecycleServiceFactory.ts | 124 --------- .../implementations/rootLogger/index.ts | 17 -- .../rootLogger/rootLoggerServiceFactory.ts | 30 -- .../implementations/scheduler/index.ts | 17 -- .../scheduler/schedulerServiceFactory.test.ts | 46 ---- .../scheduler/schedulerServiceFactory.ts | 41 --- .../implementations/urlReader/index.ts | 17 -- .../urlReader/urlReaderServiceFactory.ts | 39 --- .../implementations/userInfo/index.ts | 17 -- .../userInfo/userInfoServiceFactory.ts | 24 -- .../src/compat/legacy/legacy.test.ts | 2 +- .../package.json | 1 + .../src/manager/plugin-manager.test.ts | 6 +- .../src/next/wiring/TestBackend.ts | 10 +- .../src/service/router.credentials.test.ts | 6 +- yarn.lock | 1 + 49 files changed, 14 insertions(+), 1951 deletions(-) delete mode 100644 packages/backend-app-api/src/services/implementations/auth/authServiceFactory.ts delete mode 100644 packages/backend-app-api/src/services/implementations/auth/index.ts delete mode 100644 packages/backend-app-api/src/services/implementations/cache/cacheServiceFactory.ts delete mode 100644 packages/backend-app-api/src/services/implementations/cache/index.ts delete mode 100644 packages/backend-app-api/src/services/implementations/config/index.ts delete mode 100644 packages/backend-app-api/src/services/implementations/config/rootConfigServiceFactory.ts delete mode 100644 packages/backend-app-api/src/services/implementations/database/databaseServiceFactory.ts delete mode 100644 packages/backend-app-api/src/services/implementations/database/index.ts delete mode 100644 packages/backend-app-api/src/services/implementations/deprecated.ts delete mode 100644 packages/backend-app-api/src/services/implementations/discovery/HostDiscovery.test.ts delete mode 100644 packages/backend-app-api/src/services/implementations/discovery/HostDiscovery.ts delete mode 100644 packages/backend-app-api/src/services/implementations/discovery/discoveryServiceFactory.ts delete mode 100644 packages/backend-app-api/src/services/implementations/discovery/index.ts delete mode 100644 packages/backend-app-api/src/services/implementations/httpAuth/httpAuthServiceFactory.ts delete mode 100644 packages/backend-app-api/src/services/implementations/httpAuth/index.ts delete mode 100644 packages/backend-app-api/src/services/implementations/httpRouter/createLifecycleMiddleware.ts delete mode 100644 packages/backend-app-api/src/services/implementations/httpRouter/httpRouterServiceFactory.ts delete mode 100644 packages/backend-app-api/src/services/implementations/httpRouter/index.ts delete mode 100644 packages/backend-app-api/src/services/implementations/lifecycle/index.ts delete mode 100644 packages/backend-app-api/src/services/implementations/lifecycle/lifecycleServiceFactory.ts delete mode 100644 packages/backend-app-api/src/services/implementations/logger/index.ts delete mode 100644 packages/backend-app-api/src/services/implementations/logger/loggerServiceFactory.ts delete mode 100644 packages/backend-app-api/src/services/implementations/permissions/index.ts delete mode 100644 packages/backend-app-api/src/services/implementations/permissions/permissionsServiceFactory.ts delete mode 100644 packages/backend-app-api/src/services/implementations/rootHttpRouter/DefaultRootHttpRouter.test.ts delete mode 100644 packages/backend-app-api/src/services/implementations/rootHttpRouter/DefaultRootHttpRouter.ts delete mode 100644 packages/backend-app-api/src/services/implementations/rootHttpRouter/index.ts delete mode 100644 packages/backend-app-api/src/services/implementations/rootHttpRouter/rootHttpRouterServiceFactory.ts delete mode 100644 packages/backend-app-api/src/services/implementations/rootLifecycle/index.ts delete mode 100644 packages/backend-app-api/src/services/implementations/rootLifecycle/rootLifecycleServiceFactory.test.ts delete mode 100644 packages/backend-app-api/src/services/implementations/rootLifecycle/rootLifecycleServiceFactory.ts delete mode 100644 packages/backend-app-api/src/services/implementations/rootLogger/index.ts delete mode 100644 packages/backend-app-api/src/services/implementations/rootLogger/rootLoggerServiceFactory.ts delete mode 100644 packages/backend-app-api/src/services/implementations/scheduler/index.ts delete mode 100644 packages/backend-app-api/src/services/implementations/scheduler/schedulerServiceFactory.test.ts delete mode 100644 packages/backend-app-api/src/services/implementations/scheduler/schedulerServiceFactory.ts delete mode 100644 packages/backend-app-api/src/services/implementations/urlReader/index.ts delete mode 100644 packages/backend-app-api/src/services/implementations/urlReader/urlReaderServiceFactory.ts delete mode 100644 packages/backend-app-api/src/services/implementations/userInfo/index.ts delete mode 100644 packages/backend-app-api/src/services/implementations/userInfo/userInfoServiceFactory.ts diff --git a/packages/backend-app-api/api-report.md b/packages/backend-app-api/api-report.md index dea309ebb0..e4adcb56f2 100644 --- a/packages/backend-app-api/api-report.md +++ b/packages/backend-app-api/api-report.md @@ -6,52 +6,25 @@ /// import type { AppConfig } from '@backstage/config'; -import { AuthService } from '@backstage/backend-plugin-api'; import { BackendFeature } from '@backstage/backend-plugin-api'; -import { CacheService } from '@backstage/backend-plugin-api'; import { Config } from '@backstage/config'; import { ConfigSchema } from '@backstage/config-loader'; import { CorsOptions } from 'cors'; -import { DatabaseService } from '@backstage/backend-plugin-api'; -import { DiscoveryService } from '@backstage/backend-plugin-api'; import { ErrorRequestHandler } from 'express'; -import { Express as Express_2 } from 'express'; import { Format } from 'logform'; -import { Handler } from 'express'; import { HelmetOptions } from 'helmet'; import * as http from 'http'; -import { HttpAuthService } from '@backstage/backend-plugin-api'; -import { HttpRouterService } from '@backstage/backend-plugin-api'; -import { HumanDuration } from '@backstage/types'; import { IdentityService } from '@backstage/backend-plugin-api'; import { JsonObject } from '@backstage/types'; -import { LifecycleService } from '@backstage/backend-plugin-api'; import { LoadConfigOptionsRemote } from '@backstage/config-loader'; import { LoggerService } from '@backstage/backend-plugin-api'; -import { PermissionsService } from '@backstage/backend-plugin-api'; -import { RemoteConfigSourceOptions } from '@backstage/config-loader'; import { RequestHandler } from 'express'; -import { RequestListener } from 'http'; import { RootConfigService } from '@backstage/backend-plugin-api'; -import { RootHttpRouterService } from '@backstage/backend-plugin-api'; -import { RootLifecycleService } from '@backstage/backend-plugin-api'; import { RootLoggerService } from '@backstage/backend-plugin-api'; -import { SchedulerService } from '@backstage/backend-plugin-api'; -import type { Server } from 'node:http'; import { ServiceFactory } from '@backstage/backend-plugin-api'; import { ServiceFactoryCompat } from '@backstage/backend-plugin-api'; import { TokenManagerService } from '@backstage/backend-plugin-api'; import { transport } from 'winston'; -import { UrlReaderService } from '@backstage/backend-plugin-api'; -import { UserInfoService } from '@backstage/backend-plugin-api'; - -// @public @deprecated (undocumented) -export const authServiceFactory: ServiceFactoryCompat< - AuthService, - 'plugin', - 'singleton', - undefined ->; // @public (undocumented) export interface Backend { @@ -77,29 +50,11 @@ export interface Backend { stop(): Promise; } -// @public @deprecated (undocumented) -export const cacheServiceFactory: ServiceFactoryCompat< - CacheService, - 'plugin', - 'singleton', - undefined ->; - // Warning: (ae-forgotten-export) The symbol "createConfigSecretEnumerator_2" needs to be exported by the entry point index.d.ts // // @public @deprecated (undocumented) export const createConfigSecretEnumerator: typeof createConfigSecretEnumerator_2; -// Warning: (ae-forgotten-export) The symbol "createHttpServer_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export const createHttpServer: typeof createHttpServer_2; - -// Warning: (ae-forgotten-export) The symbol "createLifecycleMiddleware_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated -export const createLifecycleMiddleware: typeof createLifecycleMiddleware_2; - // @public (undocumented) export function createSpecializedBackend( options: CreateSpecializedBackendOptions, @@ -111,72 +66,11 @@ export interface CreateSpecializedBackendOptions { defaultServiceFactories: ServiceFactory[]; } -// @public @deprecated (undocumented) -export const databaseServiceFactory: ServiceFactoryCompat< - DatabaseService, - 'plugin', - 'singleton', - undefined ->; - -// @public @deprecated -export class DefaultRootHttpRouter implements RootHttpRouterService { - // (undocumented) - static create(options?: DefaultRootHttpRouterOptions): DefaultRootHttpRouter; - // (undocumented) - handler(): Handler; - // (undocumented) - use(path: string, handler: Handler): void; -} - -// Warning: (ae-forgotten-export) The symbol "DefaultRootHttpRouterOptions_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated -export type DefaultRootHttpRouterOptions = DefaultRootHttpRouterOptions_2; - -// @public @deprecated (undocumented) -export const discoveryServiceFactory: ServiceFactoryCompat< - DiscoveryService, - 'plugin', - 'singleton', - undefined ->; - // Warning: (ae-forgotten-export) The symbol "ExtendedHttpServer_2" needs to be exported by the entry point index.d.ts // // @public @deprecated (undocumented) export type ExtendedHttpServer = ExtendedHttpServer_2; -// @public @deprecated -export class HostDiscovery implements DiscoveryService { - static fromConfig( - config: Config, - options?: { - basePath?: string; - }, - ): HostDiscovery; - // (undocumented) - getBaseUrl(pluginId: string): Promise; - // (undocumented) - getExternalBaseUrl(pluginId: string): Promise; -} - -// @public @deprecated (undocumented) -export const httpAuthServiceFactory: ServiceFactoryCompat< - HttpAuthService, - 'plugin', - 'singleton', - undefined ->; - -// @public @deprecated -export const httpRouterServiceFactory: ServiceFactoryCompat< - HttpRouterService, - 'plugin', - 'singleton', - undefined ->; - // Warning: (ae-forgotten-export) The symbol "HttpServerCertificateOptions_2" needs to be exported by the entry point index.d.ts // // @public @deprecated (undocumented) @@ -201,19 +95,6 @@ export const identityServiceFactory: ServiceFactoryCompat< IdentityFactoryOptions >; -// Warning: (ae-forgotten-export) The symbol "LifecycleMiddlewareOptions_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated -export type LifecycleMiddlewareOptions = LifecycleMiddlewareOptions_2; - -// @public @deprecated -export const lifecycleServiceFactory: ServiceFactoryCompat< - LifecycleService, - 'plugin', - 'singleton', - undefined ->; - // @public @deprecated export function loadBackendConfig(options: { remote?: LoadConfigOptionsRemote; @@ -224,14 +105,6 @@ export function loadBackendConfig(options: { config: Config; }>; -// @public @deprecated -export const loggerServiceFactory: ServiceFactoryCompat< - LoggerService, - 'plugin', - 'singleton', - undefined ->; - // @public @deprecated (undocumented) export class MiddlewareFactory { compression(): RequestHandler; @@ -253,14 +126,6 @@ export type MiddlewareFactoryErrorOptions = MiddlewareFactoryErrorOptions_2; // @public @deprecated (undocumented) export type MiddlewareFactoryOptions = MiddlewareFactoryOptions_2; -// @public @deprecated (undocumented) -export const permissionsServiceFactory: ServiceFactoryCompat< - PermissionsService, - 'plugin', - 'singleton', - undefined ->; - // Warning: (ae-forgotten-export) The symbol "readCorsOptions_2" needs to be exported by the entry point index.d.ts // // @public @deprecated (undocumented) @@ -276,62 +141,6 @@ export const readHelmetOptions: typeof readHelmetOptions_2; // @public @deprecated (undocumented) export const readHttpServerOptions: typeof readHttpServerOptions_2; -// @public @deprecated (undocumented) -export interface RootConfigFactoryOptions { - argv?: string[]; - remote?: Pick; - // (undocumented) - watch?: boolean; -} - -// @public @deprecated (undocumented) -export const rootConfigServiceFactory: ServiceFactoryCompat< - RootConfigService, - 'root', - 'singleton', - RootConfigFactoryOptions ->; - -// Warning: (ae-forgotten-export) The symbol "RootHttpRouterConfigureContext_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export type RootHttpRouterConfigureContext = RootHttpRouterConfigureContext_2; - -// Warning: (ae-forgotten-export) The symbol "RootHttpRouterFactoryOptions_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated -export type RootHttpRouterFactoryOptions = RootHttpRouterFactoryOptions_2; - -// @public @deprecated (undocumented) -export const rootHttpRouterServiceFactory: (( - options?: RootHttpRouterFactoryOptions_2 | undefined, -) => ServiceFactory) & - ServiceFactory; - -// @public @deprecated -export const rootLifecycleServiceFactory: ServiceFactoryCompat< - RootLifecycleService, - 'root', - 'singleton', - undefined ->; - -// @public @deprecated -export const rootLoggerServiceFactory: ServiceFactoryCompat< - RootLoggerService, - 'root', - 'singleton', - undefined ->; - -// @public @deprecated (undocumented) -export const schedulerServiceFactory: ServiceFactoryCompat< - SchedulerService, - 'plugin', - 'singleton', - undefined ->; - // @public @deprecated (undocumented) export const tokenManagerServiceFactory: ServiceFactoryCompat< TokenManagerService, @@ -340,22 +149,6 @@ export const tokenManagerServiceFactory: ServiceFactoryCompat< undefined >; -// @public @deprecated (undocumented) -export const urlReaderServiceFactory: ServiceFactoryCompat< - UrlReaderService, - 'plugin', - 'singleton', - undefined ->; - -// @public @deprecated (undocumented) -export const userInfoServiceFactory: ServiceFactoryCompat< - UserInfoService, - 'plugin', - 'singleton', - undefined ->; - // @public @deprecated export class WinstonLogger implements RootLoggerService { // (undocumented) diff --git a/packages/backend-app-api/src/http/index.ts b/packages/backend-app-api/src/http/index.ts index a056ed2d61..2ff62209f7 100644 --- a/packages/backend-app-api/src/http/index.ts +++ b/packages/backend-app-api/src/http/index.ts @@ -34,11 +34,7 @@ import { * @deprecated Please import from `@backstage/backend-defaults/rootHttpRouter` instead. */ export const readHttpServerOptions = _readHttpServerOptions; -/** - * @public - * @deprecated Please import from `@backstage/backend-defaults/rootHttpRouter` instead. - */ -export const createHttpServer = _createHttpServer; + /** * @public * @deprecated Please import from `@backstage/backend-defaults/rootHttpRouter` instead. diff --git a/packages/backend-app-api/src/services/implementations/auth/authServiceFactory.ts b/packages/backend-app-api/src/services/implementations/auth/authServiceFactory.ts deleted file mode 100644 index 988b907b4c..0000000000 --- a/packages/backend-app-api/src/services/implementations/auth/authServiceFactory.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2024 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. - */ - -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { authServiceFactory as _authServiceFactory } from '../../../../../backend-defaults/src/entrypoints/auth'; - -/** - * @public - * @deprecated Please import from `@backstage/backend-defaults/auth` instead. - */ -export const authServiceFactory = _authServiceFactory; diff --git a/packages/backend-app-api/src/services/implementations/auth/index.ts b/packages/backend-app-api/src/services/implementations/auth/index.ts deleted file mode 100644 index 1b55d46a83..0000000000 --- a/packages/backend-app-api/src/services/implementations/auth/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2024 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 { authServiceFactory } from './authServiceFactory'; diff --git a/packages/backend-app-api/src/services/implementations/cache/cacheServiceFactory.ts b/packages/backend-app-api/src/services/implementations/cache/cacheServiceFactory.ts deleted file mode 100644 index 9b5e5ab16a..0000000000 --- a/packages/backend-app-api/src/services/implementations/cache/cacheServiceFactory.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2022 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 { CacheManager } from '@backstage/backend-common'; -import { - coreServices, - createServiceFactory, -} from '@backstage/backend-plugin-api'; - -/** - * @public - * @deprecated Please import from `@backstage/backend-defaults/cache` instead. - */ -export const cacheServiceFactory = createServiceFactory({ - service: coreServices.cache, - deps: { - config: coreServices.rootConfig, - logger: coreServices.rootLogger, - plugin: coreServices.pluginMetadata, - }, - async createRootContext({ config, logger }) { - return CacheManager.fromConfig(config, { logger }); - }, - async factory({ plugin }, manager) { - return manager.forPlugin(plugin.getId()).getClient(); - }, -}); diff --git a/packages/backend-app-api/src/services/implementations/cache/index.ts b/packages/backend-app-api/src/services/implementations/cache/index.ts deleted file mode 100644 index f96ee77182..0000000000 --- a/packages/backend-app-api/src/services/implementations/cache/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * 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 { cacheServiceFactory } from './cacheServiceFactory'; diff --git a/packages/backend-app-api/src/services/implementations/config/index.ts b/packages/backend-app-api/src/services/implementations/config/index.ts deleted file mode 100644 index 1775ef2efc..0000000000 --- a/packages/backend-app-api/src/services/implementations/config/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * 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 { rootConfigServiceFactory } from './rootConfigServiceFactory'; -export type { RootConfigFactoryOptions } from './rootConfigServiceFactory'; diff --git a/packages/backend-app-api/src/services/implementations/config/rootConfigServiceFactory.ts b/packages/backend-app-api/src/services/implementations/config/rootConfigServiceFactory.ts deleted file mode 100644 index c74474e629..0000000000 --- a/packages/backend-app-api/src/services/implementations/config/rootConfigServiceFactory.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2022 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 { - coreServices, - createServiceFactory, -} from '@backstage/backend-plugin-api'; -import { - ConfigSources, - RemoteConfigSourceOptions, -} from '@backstage/config-loader'; - -/** - * @public - * @deprecated Please import from `@backstage/backend-defaults/rootConfig` instead. - */ -export interface RootConfigFactoryOptions { - /** - * Process arguments to use instead of the default `process.argv()`. - */ - argv?: string[]; - - /** - * Enables and sets options for remote configuration loading. - */ - remote?: Pick; - watch?: boolean; -} - -/** - * @public - * @deprecated Please import from `@backstage/backend-defaults/rootConfig` instead. - */ -export const rootConfigServiceFactory = createServiceFactory( - (options?: RootConfigFactoryOptions) => ({ - service: coreServices.rootConfig, - deps: {}, - async factory() { - const source = ConfigSources.default({ - argv: options?.argv, - remote: options?.remote, - watch: options?.watch, - }); - console.log(`Loading config from ${source}`); - return await ConfigSources.toConfig(source); - }, - }), -); diff --git a/packages/backend-app-api/src/services/implementations/database/databaseServiceFactory.ts b/packages/backend-app-api/src/services/implementations/database/databaseServiceFactory.ts deleted file mode 100644 index 972d8dd4ec..0000000000 --- a/packages/backend-app-api/src/services/implementations/database/databaseServiceFactory.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2022 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 { DatabaseManager } from '@backstage/backend-common'; -import { - coreServices, - createServiceFactory, -} from '@backstage/backend-plugin-api'; -import { ConfigReader } from '@backstage/config'; - -/** - * @public - * @deprecated Please import from `@backstage/backend-defaults/database` instead. - */ -export const databaseServiceFactory = createServiceFactory({ - service: coreServices.database, - deps: { - config: coreServices.rootConfig, - lifecycle: coreServices.lifecycle, - pluginMetadata: coreServices.pluginMetadata, - }, - async createRootContext({ config }) { - return config.getOptional('backend.database') - ? DatabaseManager.fromConfig(config) - : DatabaseManager.fromConfig( - new ConfigReader({ - backend: { - database: { client: 'better-sqlite3', connection: ':memory:' }, - }, - }), - ); - }, - async factory({ pluginMetadata, lifecycle }, databaseManager) { - return databaseManager.forPlugin(pluginMetadata.getId(), { - pluginMetadata, - lifecycle, - }); - }, -}); diff --git a/packages/backend-app-api/src/services/implementations/database/index.ts b/packages/backend-app-api/src/services/implementations/database/index.ts deleted file mode 100644 index d676c8013e..0000000000 --- a/packages/backend-app-api/src/services/implementations/database/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * 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 { databaseServiceFactory } from './databaseServiceFactory'; diff --git a/packages/backend-app-api/src/services/implementations/deprecated.ts b/packages/backend-app-api/src/services/implementations/deprecated.ts deleted file mode 100644 index 347a968bce..0000000000 --- a/packages/backend-app-api/src/services/implementations/deprecated.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2024 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 * from './auth'; -export * from './httpAuth'; -export * from './httpRouter'; -export * from './logger'; -export * from './rootHttpRouter'; -export * from './rootLogger'; -export * from './scheduler'; -export * from './userInfo'; diff --git a/packages/backend-app-api/src/services/implementations/discovery/HostDiscovery.test.ts b/packages/backend-app-api/src/services/implementations/discovery/HostDiscovery.test.ts deleted file mode 100644 index 4e6aff5853..0000000000 --- a/packages/backend-app-api/src/services/implementations/discovery/HostDiscovery.test.ts +++ /dev/null @@ -1,257 +0,0 @@ -/* - * 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 { ConfigReader } from '@backstage/config'; -import { HostDiscovery } from './HostDiscovery'; - -describe('HostDiscovery', () => { - it('is created from config', async () => { - const discovery = HostDiscovery.fromConfig( - new ConfigReader({ - backend: { - baseUrl: 'http://localhost:40', - listen: { port: 80, host: 'localhost' }, - }, - }), - ); - - await expect(discovery.getBaseUrl('catalog')).resolves.toBe( - 'http://localhost:80/api/catalog', - ); - await expect(discovery.getExternalBaseUrl('catalog')).resolves.toBe( - 'http://localhost:40/api/catalog', - ); - }); - - it('strips trailing slashes in config', async () => { - const discovery = HostDiscovery.fromConfig( - new ConfigReader({ - backend: { - baseUrl: 'http://localhost:40//', - listen: { port: 80, host: 'localhost' }, - }, - }), - ); - - await expect(discovery.getBaseUrl('catalog')).resolves.toBe( - 'http://localhost:80/api/catalog', - ); - await expect(discovery.getExternalBaseUrl('catalog')).resolves.toBe( - 'http://localhost:40/api/catalog', - ); - }); - - it('can configure the base path', async () => { - const discovery = HostDiscovery.fromConfig( - new ConfigReader({ - backend: { - baseUrl: 'http://localhost:40', - listen: { port: 80, host: 'localhost' }, - }, - }), - { basePath: '/service' }, - ); - - await expect(discovery.getBaseUrl('catalog')).resolves.toBe( - 'http://localhost:80/service/catalog', - ); - await expect(discovery.getExternalBaseUrl('catalog')).resolves.toBe( - 'http://localhost:40/service/catalog', - ); - }); - - it.each([ - [{ listen: ':80' }, 'http://localhost:80'], - [{ listen: ':40', https: true }, 'https://localhost:40'], - [{ listen: '127.0.0.1:80' }, 'http://127.0.0.1:80'], - [{ listen: '127.0.0.1:80', https: true }, 'https://127.0.0.1:80'], - [{ listen: '0.0.0.0:40' }, 'http://127.0.0.1:40'], - [{ listen: { port: 80 } }, 'http://localhost:80'], - [{ listen: { port: 8000 } }, 'http://localhost:8000'], - [{ listen: { port: 80, host: '0.0.0.0' } }, 'http://127.0.0.1:80'], - [{ listen: { port: 80, host: '::' } }, 'http://localhost:80'], - [{ listen: { port: 80, host: '::1' } }, 'http://[::1]:80'], - [{ listen: { port: 90, host: '::2' }, https: true }, 'https://[::2]:90'], - ])('resolves internal baseUrl for %j as %s', async (config, expected) => { - const discovery = HostDiscovery.fromConfig( - new ConfigReader({ - backend: { - baseUrl: 'http://localhost:40', - ...config, - }, - }), - ); - - await expect(discovery.getBaseUrl('catalog')).resolves.toBe( - `${expected}/api/catalog`, - ); - }); - - it('uses plugin specific targets from config if provided', async () => { - const discovery = HostDiscovery.fromConfig( - new ConfigReader({ - backend: { - baseUrl: 'http://localhost:40', - listen: { port: 80, host: 'localhost' }, - }, - discovery: { - endpoints: [ - { - target: { - internal: 'http://catalog-backend-internal:8080/api/catalog', - external: 'http://catalog-backend-external:8080/api/catalog', - }, - plugins: ['catalog'], - }, - ], - }, - }), - ); - - await expect(discovery.getBaseUrl('catalog')).resolves.toBe( - 'http://catalog-backend-internal:8080/api/catalog', - ); - await expect(discovery.getExternalBaseUrl('catalog')).resolves.toBe( - 'http://catalog-backend-external:8080/api/catalog', - ); - }); - - it('uses a single target for internal and external for a plugin', async () => { - const discovery = HostDiscovery.fromConfig( - new ConfigReader({ - backend: { - baseUrl: 'http://localhost:40', - listen: { port: 80, host: 'localhost' }, - }, - discovery: { - endpoints: [ - { - target: 'http://catalog-backend:8080/api/catalog', - plugins: ['catalog'], - }, - ], - }, - }), - ); - - await expect(discovery.getBaseUrl('catalog')).resolves.toBe( - 'http://catalog-backend:8080/api/catalog', - ); - await expect(discovery.getExternalBaseUrl('catalog')).resolves.toBe( - 'http://catalog-backend:8080/api/catalog', - ); - }); - - it('defaults to the backend baseUrl when there is not an endpoint for a plugin', async () => { - const discovery = HostDiscovery.fromConfig( - new ConfigReader({ - backend: { - baseUrl: 'http://localhost:40', - listen: { port: 80, host: 'localhost' }, - }, - discovery: { - endpoints: [ - { - target: 'http://catalog-backend:8080/api/catalog', - plugins: ['catalog'], - }, - ], - }, - }), - ); - - await expect(discovery.getBaseUrl('scaffolder')).resolves.toBe( - 'http://localhost:80/api/scaffolder', - ); - await expect(discovery.getExternalBaseUrl('scaffolder')).resolves.toBe( - 'http://localhost:40/api/scaffolder', - ); - }); - - it('replaces {{pluginId}} or {{ pluginId }} in the target', async () => { - const discovery = HostDiscovery.fromConfig( - new ConfigReader({ - backend: { - baseUrl: 'http://localhost:40', - listen: { port: 80, host: 'localhost' }, - }, - discovery: { - endpoints: [ - { - target: 'http://common-backend:8080/api/{{pluginId}}', - plugins: ['catalog', 'docs'], - }, - { - target: { - internal: 'http://scaffolder-internal:8080/api/{{ pluginId }}', - external: 'http://scaffolder-external:8080/api/{{ pluginId }}', - }, - plugins: ['scaffolder'], - }, - ], - }, - }), - ); - - await expect(discovery.getBaseUrl('catalog')).resolves.toBe( - 'http://common-backend:8080/api/catalog', - ); - await expect(discovery.getExternalBaseUrl('catalog')).resolves.toBe( - 'http://common-backend:8080/api/catalog', - ); - await expect(discovery.getBaseUrl('docs')).resolves.toBe( - 'http://common-backend:8080/api/docs', - ); - await expect(discovery.getExternalBaseUrl('docs')).resolves.toBe( - 'http://common-backend:8080/api/docs', - ); - await expect(discovery.getBaseUrl('scaffolder')).resolves.toBe( - 'http://scaffolder-internal:8080/api/scaffolder', - ); - await expect(discovery.getExternalBaseUrl('scaffolder')).resolves.toBe( - 'http://scaffolder-external:8080/api/scaffolder', - ); - }); - - it('encodes the pluginId', async () => { - const discovery = HostDiscovery.fromConfig( - new ConfigReader({ - backend: { - baseUrl: 'http://localhost:40', - listen: { port: 80, host: 'localhost' }, - }, - discovery: { - endpoints: [ - { - target: 'http://common-backend:8080/api/{{pluginId}}', - plugins: ['plugin/beta'], - }, - ], - }, - }), - ); - - await expect(discovery.getBaseUrl('plugin/beta')).resolves.toBe( - 'http://common-backend:8080/api/plugin%2Fbeta', - ); - await expect(discovery.getBaseUrl('plugin/alpha')).resolves.toBe( - 'http://localhost:80/api/plugin%2Falpha', - ); - await expect(discovery.getExternalBaseUrl('plugin/alpha')).resolves.toBe( - 'http://localhost:40/api/plugin%2Falpha', - ); - }); -}); diff --git a/packages/backend-app-api/src/services/implementations/discovery/HostDiscovery.ts b/packages/backend-app-api/src/services/implementations/discovery/HostDiscovery.ts deleted file mode 100644 index 5909dd1ae6..0000000000 --- a/packages/backend-app-api/src/services/implementations/discovery/HostDiscovery.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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 { Config } from '@backstage/config'; -import { DiscoveryService } from '@backstage/backend-plugin-api'; -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { HostDiscovery as _HostDiscovery } from '../../../../../backend-defaults/src/entrypoints/discovery'; - -/** - * HostDiscovery is a basic PluginEndpointDiscovery implementation - * that can handle plugins that are hosted in a single or multiple deployments. - * - * The deployment may be scaled horizontally, as long as the external URL - * is the same for all instances. However, internal URLs will always be - * resolved to the same host, so there won't be any balancing of internal traffic. - * - * @public - * @deprecated Please import from `@backstage/backend-defaults/discovery` instead. - */ -export class HostDiscovery implements DiscoveryService { - /** - * Creates a new HostDiscovery discovery instance by reading - * from the `backend` config section, specifically the `.baseUrl` for - * discovering the external URL, and the `.listen` and `.https` config - * for the internal one. - * - * Can be overridden in config by providing a target and corresponding plugins in `discovery.endpoints`. - * eg. - * ```yaml - * discovery: - * endpoints: - * - target: https://internal.example.com/internal-catalog - * plugins: [catalog] - * - target: https://internal.example.com/secure/api/{{pluginId}} - * plugins: [auth, permission] - * - target: - * internal: https://internal.example.com/search - * external: https://example.com/search - * plugins: [search] - * ``` - * - * The basePath defaults to `/api`, meaning the default full internal - * path for the `catalog` plugin will be `http://localhost:7007/api/catalog`. - */ - static fromConfig(config: Config, options?: { basePath?: string }) { - return new HostDiscovery(_HostDiscovery.fromConfig(config, options)); - } - - private constructor(private readonly impl: _HostDiscovery) {} - - async getBaseUrl(pluginId: string): Promise { - return this.impl.getBaseUrl(pluginId); - } - - async getExternalBaseUrl(pluginId: string): Promise { - return this.impl.getExternalBaseUrl(pluginId); - } -} diff --git a/packages/backend-app-api/src/services/implementations/discovery/discoveryServiceFactory.ts b/packages/backend-app-api/src/services/implementations/discovery/discoveryServiceFactory.ts deleted file mode 100644 index b29a589438..0000000000 --- a/packages/backend-app-api/src/services/implementations/discovery/discoveryServiceFactory.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2022 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 { - coreServices, - createServiceFactory, -} from '@backstage/backend-plugin-api'; -import { HostDiscovery } from './HostDiscovery'; - -/** - * @public - * @deprecated Please import from `@backstage/backend-defaults/discovery` instead. - */ -export const discoveryServiceFactory = createServiceFactory({ - service: coreServices.discovery, - deps: { - config: coreServices.rootConfig, - }, - async factory({ config }) { - return HostDiscovery.fromConfig(config); - }, -}); diff --git a/packages/backend-app-api/src/services/implementations/discovery/index.ts b/packages/backend-app-api/src/services/implementations/discovery/index.ts deleted file mode 100644 index ee4851271a..0000000000 --- a/packages/backend-app-api/src/services/implementations/discovery/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * 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 { discoveryServiceFactory } from './discoveryServiceFactory'; -export { HostDiscovery } from './HostDiscovery'; diff --git a/packages/backend-app-api/src/services/implementations/httpAuth/httpAuthServiceFactory.ts b/packages/backend-app-api/src/services/implementations/httpAuth/httpAuthServiceFactory.ts deleted file mode 100644 index 373dd10ead..0000000000 --- a/packages/backend-app-api/src/services/implementations/httpAuth/httpAuthServiceFactory.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2024 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. - */ - -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { httpAuthServiceFactory as _httpAuthServiceFactory } from '../../../../../backend-defaults/src/entrypoints/httpAuth'; - -/** - * @public - * @deprecated Please import from `@backstage/backend-defaults/httpAuth` instead. - */ -export const httpAuthServiceFactory = _httpAuthServiceFactory; diff --git a/packages/backend-app-api/src/services/implementations/httpAuth/index.ts b/packages/backend-app-api/src/services/implementations/httpAuth/index.ts deleted file mode 100644 index edd7e53026..0000000000 --- a/packages/backend-app-api/src/services/implementations/httpAuth/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2024 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 { httpAuthServiceFactory } from './httpAuthServiceFactory'; diff --git a/packages/backend-app-api/src/services/implementations/httpRouter/createLifecycleMiddleware.ts b/packages/backend-app-api/src/services/implementations/httpRouter/createLifecycleMiddleware.ts deleted file mode 100644 index d4864a23a6..0000000000 --- a/packages/backend-app-api/src/services/implementations/httpRouter/createLifecycleMiddleware.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2022 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. - */ - -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { - createLifecycleMiddleware as _createLifecycleMiddleware, - type LifecycleMiddlewareOptions as _LifecycleMiddlewareOptions, -} from '../../../../../backend-defaults/src/entrypoints/httpRouter/createLifecycleMiddleware'; - -/** - * Options for {@link createLifecycleMiddleware}. - * @public - * @deprecated Please import from `@backstage/backend-defaults/httpRouter` instead. - */ -export type LifecycleMiddlewareOptions = _LifecycleMiddlewareOptions; - -/** - * Creates a middleware that pauses requests until the service has started. - * - * @remarks - * - * Requests that arrive before the service has started will be paused until startup is complete. - * If the service does not start within the provided timeout, the request will be rejected with a - * {@link @backstage/errors#ServiceUnavailableError}. - * - * If the service is shutting down, all requests will be rejected with a - * {@link @backstage/errors#ServiceUnavailableError}. - * - * @public - * @deprecated Please import from `@backstage/backend-defaults/httpRouter` instead. - */ -export const createLifecycleMiddleware = _createLifecycleMiddleware; diff --git a/packages/backend-app-api/src/services/implementations/httpRouter/httpRouterServiceFactory.ts b/packages/backend-app-api/src/services/implementations/httpRouter/httpRouterServiceFactory.ts deleted file mode 100644 index 0088e53f98..0000000000 --- a/packages/backend-app-api/src/services/implementations/httpRouter/httpRouterServiceFactory.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2022 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. - */ - -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { httpRouterServiceFactory as _httpRouterServiceFactory } from '../../../../../backend-defaults/src/entrypoints/httpRouter/httpRouterServiceFactory'; - -/** - * HTTP route registration for plugins. - * - * See {@link @backstage/code-plugin-api#HttpRouterService} - * and {@link https://backstage.io/docs/backend-system/core-services/http-router | the service docs} - * for more information. - * - * @public - * @deprecated Please import from `@backstage/backend-defaults/httpRouter` instead. - */ -export const httpRouterServiceFactory = _httpRouterServiceFactory; diff --git a/packages/backend-app-api/src/services/implementations/httpRouter/index.ts b/packages/backend-app-api/src/services/implementations/httpRouter/index.ts deleted file mode 100644 index bc12480ae8..0000000000 --- a/packages/backend-app-api/src/services/implementations/httpRouter/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -/* - * 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 { httpRouterServiceFactory } from './httpRouterServiceFactory'; -export { createLifecycleMiddleware } from './createLifecycleMiddleware'; -export type { LifecycleMiddlewareOptions } from './createLifecycleMiddleware'; diff --git a/packages/backend-app-api/src/services/implementations/index.ts b/packages/backend-app-api/src/services/implementations/index.ts index 3a2fe819ed..5f9bb9479a 100644 --- a/packages/backend-app-api/src/services/implementations/index.ts +++ b/packages/backend-app-api/src/services/implementations/index.ts @@ -14,15 +14,5 @@ * limitations under the License. */ -export * from './cache'; -export * from './config'; -export * from './database'; -export * from './discovery'; export * from './identity'; -export * from './lifecycle'; -export * from './permissions'; -export * from './rootLifecycle'; export * from './tokenManager'; -export * from './urlReader'; - -export * from './deprecated'; diff --git a/packages/backend-app-api/src/services/implementations/lifecycle/index.ts b/packages/backend-app-api/src/services/implementations/lifecycle/index.ts deleted file mode 100644 index 8dac4c26b4..0000000000 --- a/packages/backend-app-api/src/services/implementations/lifecycle/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * 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 { lifecycleServiceFactory } from './lifecycleServiceFactory'; diff --git a/packages/backend-app-api/src/services/implementations/lifecycle/lifecycleServiceFactory.ts b/packages/backend-app-api/src/services/implementations/lifecycle/lifecycleServiceFactory.ts deleted file mode 100644 index b3b0135a7c..0000000000 --- a/packages/backend-app-api/src/services/implementations/lifecycle/lifecycleServiceFactory.ts +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright 2022 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 { - LifecycleService, - LifecycleServiceShutdownHook, - LifecycleServiceShutdownOptions, - LifecycleServiceStartupHook, - LifecycleServiceStartupOptions, - LoggerService, - PluginMetadataService, - RootLifecycleService, - coreServices, - createServiceFactory, -} from '@backstage/backend-plugin-api'; - -/** - * @internal - * @deprecated - */ -export class BackendPluginLifecycleImpl implements LifecycleService { - constructor( - private readonly logger: LoggerService, - private readonly rootLifecycle: RootLifecycleService, - private readonly pluginMetadata: PluginMetadataService, - ) {} - - #hasStarted = false; - #startupTasks: Array<{ - hook: LifecycleServiceStartupHook; - options?: LifecycleServiceStartupOptions; - }> = []; - - addStartupHook( - hook: LifecycleServiceStartupHook, - options?: LifecycleServiceStartupOptions, - ): void { - if (this.#hasStarted) { - throw new Error('Attempted to add startup hook after startup'); - } - this.#startupTasks.push({ hook, options }); - } - - async startup(): Promise { - if (this.#hasStarted) { - return; - } - this.#hasStarted = true; - - this.logger.debug( - `Running ${this.#startupTasks.length} plugin startup tasks...`, - ); - await Promise.all( - this.#startupTasks.map(async ({ hook, options }) => { - const logger = options?.logger ?? this.logger; - try { - await hook(); - logger.debug(`Plugin startup hook succeeded`); - } catch (error) { - logger.error(`Plugin startup hook failed, ${error}`); - } - }), - ); - } - - addShutdownHook( - hook: LifecycleServiceShutdownHook, - options?: LifecycleServiceShutdownOptions, - ): void { - const plugin = this.pluginMetadata.getId(); - this.rootLifecycle.addShutdownHook(hook, { - logger: options?.logger?.child({ plugin }) ?? this.logger, - }); - } -} - -/** - * Allows plugins to register shutdown hooks that are run when the process is about to exit. - * - * @public - * @deprecated Please import from `@backstage/backend-defaults/lifecycle` instead. - */ -export const lifecycleServiceFactory = createServiceFactory({ - service: coreServices.lifecycle, - deps: { - logger: coreServices.logger, - rootLifecycle: coreServices.rootLifecycle, - pluginMetadata: coreServices.pluginMetadata, - }, - async factory({ rootLifecycle, logger, pluginMetadata }) { - return new BackendPluginLifecycleImpl( - logger, - rootLifecycle, - pluginMetadata, - ); - }, -}); diff --git a/packages/backend-app-api/src/services/implementations/logger/index.ts b/packages/backend-app-api/src/services/implementations/logger/index.ts deleted file mode 100644 index ca52bf5193..0000000000 --- a/packages/backend-app-api/src/services/implementations/logger/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * 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 { loggerServiceFactory } from './loggerServiceFactory'; diff --git a/packages/backend-app-api/src/services/implementations/logger/loggerServiceFactory.ts b/packages/backend-app-api/src/services/implementations/logger/loggerServiceFactory.ts deleted file mode 100644 index 7e7b4b98b0..0000000000 --- a/packages/backend-app-api/src/services/implementations/logger/loggerServiceFactory.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2022 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. - */ - -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { loggerServiceFactory as _loggerServiceFactory } from '../../../../../backend-defaults/src/entrypoints/logger/loggerServiceFactory'; - -/** - * Plugin-level logging. - * - * See {@link @backstage/code-plugin-api#LoggerService} - * and {@link https://backstage.io/docs/backend-system/core-services/logger | the service docs} - * for more information. - * - * @public - * @deprecated Please import from `@backstage/backend-defaults/logger` instead. - */ -export const loggerServiceFactory = _loggerServiceFactory; diff --git a/packages/backend-app-api/src/services/implementations/permissions/index.ts b/packages/backend-app-api/src/services/implementations/permissions/index.ts deleted file mode 100644 index 781dda31a0..0000000000 --- a/packages/backend-app-api/src/services/implementations/permissions/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * 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 { permissionsServiceFactory } from './permissionsServiceFactory'; diff --git a/packages/backend-app-api/src/services/implementations/permissions/permissionsServiceFactory.ts b/packages/backend-app-api/src/services/implementations/permissions/permissionsServiceFactory.ts deleted file mode 100644 index c8fa0e7bbf..0000000000 --- a/packages/backend-app-api/src/services/implementations/permissions/permissionsServiceFactory.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2022 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 { - coreServices, - createServiceFactory, -} from '@backstage/backend-plugin-api'; -import { ServerPermissionClient } from '@backstage/plugin-permission-node'; - -/** - * @public - * @deprecated Please import from `@backstage/backend-defaults/permissions` instead. - */ -export const permissionsServiceFactory = createServiceFactory({ - service: coreServices.permissions, - deps: { - auth: coreServices.auth, - config: coreServices.rootConfig, - discovery: coreServices.discovery, - tokenManager: coreServices.tokenManager, - }, - async factory({ auth, config, discovery, tokenManager }) { - return ServerPermissionClient.fromConfig(config, { - auth, - discovery, - tokenManager, - }); - }, -}); diff --git a/packages/backend-app-api/src/services/implementations/rootHttpRouter/DefaultRootHttpRouter.test.ts b/packages/backend-app-api/src/services/implementations/rootHttpRouter/DefaultRootHttpRouter.test.ts deleted file mode 100644 index fc1de9b205..0000000000 --- a/packages/backend-app-api/src/services/implementations/rootHttpRouter/DefaultRootHttpRouter.test.ts +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2022 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 express from 'express'; -import request from 'supertest'; -import { DefaultRootHttpRouter } from './DefaultRootHttpRouter'; - -describe('DefaultRootHttpRouter', () => { - it.each([ - [['/b'], '/a'], - [['/a'], '/aa/b'], - [['/aa'], '/a/b'], - [['/a/b'], '/aa'], - [['/b/a'], '/a'], - [['/a'], '/aa'], - ])(`with existing paths %s, adds %s without conflict`, (existing, added) => { - const router = DefaultRootHttpRouter.create(); - for (const path of existing) { - router.use(path, () => {}); - } - expect(() => router.use(added, () => {})).not.toThrow(); - }); - - it.each([ - [['/a'], '/a', '/a'], - [['/a'], '/a/b', '/a'], - [['/a/b'], '/a', '/a/b'], - ])( - `find conflict when existing paths %s, adds %s`, - (existing, added, conflict) => { - const router = DefaultRootHttpRouter.create(); - for (const path of existing) { - router.use(path, () => {}); - } - expect(() => router.use(added, () => {})).toThrow( - `Path ${added} conflicts with the existing path ${conflict}`, - ); - }, - ); - - it('should not be possible to supply an empty indexPath', () => { - expect(() => DefaultRootHttpRouter.create({ indexPath: '' })).toThrow( - 'indexPath option may not be an empty string', - ); - }); - - it('will always prioritize non-index paths', async () => { - const router = DefaultRootHttpRouter.create({ indexPath: '/x' }); - const app = express(); - app.use(router.handler()); - - const routerX = express.Router(); - routerX.get('/a', (_req, res) => res.status(201).end()); - - const routerY = express.Router(); - routerY.get('/a', (_req, res) => res.status(202).end()); - - await request(app).get('/').expect(404); - await request(app).get('/a').expect(404); - await request(app).get('/x/a').expect(404); - await request(app).get('/y/a').expect(404); - - router.use('/x', routerX); - - await request(app).get('/').expect(404); - await request(app).get('/a').expect(201); - await request(app).get('/x/a').expect(201); - await request(app).get('/y/a').expect(404); - - router.use('/y', routerY); - - await request(app).get('/').expect(404); - await request(app).get('/a').expect(201); - await request(app).get('/x/a').expect(201); - await request(app).get('/y/a').expect(202); - - expect('test').toBe('test'); - }); - - it('should treat unknown /api/ routes as 404', async () => { - const router = DefaultRootHttpRouter.create(); - const app = express(); - app.use(router.handler()); - - router.use('/api/app', (_req, res) => res.status(201).end()); - router.use('/api/catalog', (_req, res) => res.status(202).end()); - - await request(app).get('/').expect(201); - await request(app).get('/api/catalog').expect(202); - await request(app).get('/unknown').expect(201); - await request(app).get('/api/unknown').expect(404); - - expect('test').toBe('test'); - }); - - it('should treat unknown /api/ routes as 404 without an index path', async () => { - const router = DefaultRootHttpRouter.create({ indexPath: false }); - const app = express(); - app.use(router.handler()); - - router.use('/api/app', (_req, res) => res.status(201).end()); - router.use('/api/catalog', (_req, res) => res.status(202).end()); - - await request(app).get('/').expect(404); - await request(app).get('/api/catalog').expect(202); - await request(app).get('/unknown').expect(404); - await request(app).get('/api/unknown').expect(404); - - expect('test').toBe('test'); - }); -}); diff --git a/packages/backend-app-api/src/services/implementations/rootHttpRouter/DefaultRootHttpRouter.ts b/packages/backend-app-api/src/services/implementations/rootHttpRouter/DefaultRootHttpRouter.ts deleted file mode 100644 index 617d5055db..0000000000 --- a/packages/backend-app-api/src/services/implementations/rootHttpRouter/DefaultRootHttpRouter.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 { RootHttpRouterService } from '@backstage/backend-plugin-api'; -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { - DefaultRootHttpRouter as _DefaultRootHttpRouter, - DefaultRootHttpRouterOptions as _DefaultRootHttpRouterOptions, -} from '../../../../../backend-defaults/src/entrypoints/rootHttpRouter/DefaultRootHttpRouter'; -import { Handler } from 'express'; - -/** - * Options for the {@link DefaultRootHttpRouter} class. - * - * @public - * @deprecated Please import from `@backstage/backend-defaults/rootHttpRouter` instead. - */ -export type DefaultRootHttpRouterOptions = _DefaultRootHttpRouterOptions; - -/** - * The default implementation of the {@link @backstage/backend-plugin-api#RootHttpRouterService} interface for - * {@link @backstage/backend-plugin-api#coreServices.rootHttpRouter}. - * - * @public - * @deprecated Please import from `@backstage/backend-defaults/rootHttpRouter` instead. - */ -export class DefaultRootHttpRouter implements RootHttpRouterService { - static create(options?: DefaultRootHttpRouterOptions) { - return new DefaultRootHttpRouter(_DefaultRootHttpRouter.create(options)); - } - - private constructor(private readonly impl: RootHttpRouterService) {} - - use(path: string, handler: Handler) { - this.impl.use(path, handler); - } - - handler(): Handler { - return (this.impl as any).handler(); - } -} diff --git a/packages/backend-app-api/src/services/implementations/rootHttpRouter/index.ts b/packages/backend-app-api/src/services/implementations/rootHttpRouter/index.ts deleted file mode 100644 index 8437399fec..0000000000 --- a/packages/backend-app-api/src/services/implementations/rootHttpRouter/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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 { - rootHttpRouterServiceFactory, - type RootHttpRouterFactoryOptions, - type RootHttpRouterConfigureContext, -} from './rootHttpRouterServiceFactory'; -export { - DefaultRootHttpRouter, - type DefaultRootHttpRouterOptions, -} from './DefaultRootHttpRouter'; diff --git a/packages/backend-app-api/src/services/implementations/rootHttpRouter/rootHttpRouterServiceFactory.ts b/packages/backend-app-api/src/services/implementations/rootHttpRouter/rootHttpRouterServiceFactory.ts deleted file mode 100644 index bef1913645..0000000000 --- a/packages/backend-app-api/src/services/implementations/rootHttpRouter/rootHttpRouterServiceFactory.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2022 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. - */ - -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { - rootHttpRouterServiceFactory as _rootHttpRouterServiceFactory, - RootHttpRouterFactoryOptions as _RootHttpRouterFactoryOptions, - RootHttpRouterConfigureContext as _RootHttpRouterConfigureContext, -} from '../../../../../backend-defaults/src/entrypoints/rootHttpRouter/rootHttpRouterServiceFactory'; - -/** - * @public - * @deprecated Please import from `@backstage/backend-defaults/rootHttpRouter` instead. - */ -export type RootHttpRouterConfigureContext = _RootHttpRouterConfigureContext; - -/** - * HTTP route registration for root services. - * - * See {@link @backstage/code-plugin-api#RootHttpRouterService} - * and {@link https://backstage.io/docs/backend-system/core-services/root-http-router | the service docs} - * for more information. - * - * @public - * @deprecated Please import from `@backstage/backend-defaults/rootHttpRouter` instead. - */ -export type RootHttpRouterFactoryOptions = _RootHttpRouterFactoryOptions; - -/** - * @public - * @deprecated Please import from `@backstage/backend-defaults/rootHttpRouter` instead. - */ -export const rootHttpRouterServiceFactory = _rootHttpRouterServiceFactory; diff --git a/packages/backend-app-api/src/services/implementations/rootLifecycle/index.ts b/packages/backend-app-api/src/services/implementations/rootLifecycle/index.ts deleted file mode 100644 index 86589cd23e..0000000000 --- a/packages/backend-app-api/src/services/implementations/rootLifecycle/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * 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 { rootLifecycleServiceFactory } from './rootLifecycleServiceFactory'; diff --git a/packages/backend-app-api/src/services/implementations/rootLifecycle/rootLifecycleServiceFactory.test.ts b/packages/backend-app-api/src/services/implementations/rootLifecycle/rootLifecycleServiceFactory.test.ts deleted file mode 100644 index 5992e38d50..0000000000 --- a/packages/backend-app-api/src/services/implementations/rootLifecycle/rootLifecycleServiceFactory.test.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2022 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 { BackendLifecycleImpl } from './rootLifecycleServiceFactory'; -import { mockServices } from '@backstage/backend-test-utils'; - -describe('lifecycleService', () => { - it('should execute registered shutdown hook', async () => { - const service = new BackendLifecycleImpl(mockServices.logger.mock()); - const hook = jest.fn(); - service.addShutdownHook(() => hook()); - // should not execute the hook more than once. - await service.shutdown(); - await service.shutdown(); - await service.shutdown(); - expect(hook).toHaveBeenCalledTimes(1); - }); - - it('should not throw errors', async () => { - const service = new BackendLifecycleImpl(mockServices.logger.mock()); - service.addShutdownHook(() => { - throw new Error('oh no'); - }); - await expect(service.shutdown()).resolves.toBeUndefined(); - }); - - it('should not throw async errors', async () => { - const service = new BackendLifecycleImpl(mockServices.logger.mock()); - service.addShutdownHook(async () => { - throw new Error('oh no'); - }); - await expect(service.shutdown()).resolves.toBeUndefined(); - }); - - it('should reject hooks after trigger', async () => { - const service = new BackendLifecycleImpl(mockServices.logger.mock()); - await service.startup(); - expect(() => { - service.addStartupHook(() => {}); - }).toThrow('Attempted to add startup hook after startup'); - - await service.shutdown(); - expect(() => { - service.addShutdownHook(() => {}); - }).toThrow('Attempted to add shutdown hook after shutdown'); - }); -}); diff --git a/packages/backend-app-api/src/services/implementations/rootLifecycle/rootLifecycleServiceFactory.ts b/packages/backend-app-api/src/services/implementations/rootLifecycle/rootLifecycleServiceFactory.ts deleted file mode 100644 index bf5dc09b80..0000000000 --- a/packages/backend-app-api/src/services/implementations/rootLifecycle/rootLifecycleServiceFactory.ts +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2022 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 { - createServiceFactory, - coreServices, - LifecycleServiceStartupHook, - LifecycleServiceStartupOptions, - LifecycleServiceShutdownHook, - LifecycleServiceShutdownOptions, - RootLifecycleService, - LoggerService, -} from '@backstage/backend-plugin-api'; - -/** - * @internal - * @deprecated - */ -export class BackendLifecycleImpl implements RootLifecycleService { - constructor(private readonly logger: LoggerService) {} - - #hasStarted = false; - #startupTasks: Array<{ - hook: LifecycleServiceStartupHook; - options?: LifecycleServiceStartupOptions; - }> = []; - - addStartupHook( - hook: LifecycleServiceStartupHook, - options?: LifecycleServiceStartupOptions, - ): void { - if (this.#hasStarted) { - throw new Error('Attempted to add startup hook after startup'); - } - this.#startupTasks.push({ hook, options }); - } - - async startup(): Promise { - if (this.#hasStarted) { - return; - } - this.#hasStarted = true; - - this.logger.debug(`Running ${this.#startupTasks.length} startup tasks...`); - await Promise.all( - this.#startupTasks.map(async ({ hook, options }) => { - const logger = options?.logger ?? this.logger; - try { - await hook(); - logger.debug(`Startup hook succeeded`); - } catch (error) { - logger.error(`Startup hook failed, ${error}`); - } - }), - ); - } - - #hasShutdown = false; - #shutdownTasks: Array<{ - hook: LifecycleServiceShutdownHook; - options?: LifecycleServiceShutdownOptions; - }> = []; - - addShutdownHook( - hook: LifecycleServiceShutdownHook, - options?: LifecycleServiceShutdownOptions, - ): void { - if (this.#hasShutdown) { - throw new Error('Attempted to add shutdown hook after shutdown'); - } - this.#shutdownTasks.push({ hook, options }); - } - - async shutdown(): Promise { - if (this.#hasShutdown) { - return; - } - this.#hasShutdown = true; - - this.logger.debug( - `Running ${this.#shutdownTasks.length} shutdown tasks...`, - ); - await Promise.all( - this.#shutdownTasks.map(async ({ hook, options }) => { - const logger = options?.logger ?? this.logger; - try { - await hook(); - logger.debug(`Shutdown hook succeeded`); - } catch (error) { - logger.error(`Shutdown hook failed, ${error}`); - } - }), - ); - } -} - -/** - * Allows plugins to register shutdown hooks that are run when the process is about to exit. - * - * @public - * @deprecated Please import from `@backstage/backend-defaults/rootLifecycle` instead. - */ -export const rootLifecycleServiceFactory = createServiceFactory({ - service: coreServices.rootLifecycle, - deps: { - logger: coreServices.rootLogger, - }, - async factory({ logger }) { - return new BackendLifecycleImpl(logger); - }, -}); diff --git a/packages/backend-app-api/src/services/implementations/rootLogger/index.ts b/packages/backend-app-api/src/services/implementations/rootLogger/index.ts deleted file mode 100644 index 366cd53163..0000000000 --- a/packages/backend-app-api/src/services/implementations/rootLogger/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * 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 { rootLoggerServiceFactory } from './rootLoggerServiceFactory'; diff --git a/packages/backend-app-api/src/services/implementations/rootLogger/rootLoggerServiceFactory.ts b/packages/backend-app-api/src/services/implementations/rootLogger/rootLoggerServiceFactory.ts deleted file mode 100644 index af1931c438..0000000000 --- a/packages/backend-app-api/src/services/implementations/rootLogger/rootLoggerServiceFactory.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2022 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. - */ - -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { rootLoggerServiceFactory as _rootLoggerServiceFactory } from '../../../../../backend-defaults/src/entrypoints/rootLogger/rootLoggerServiceFactory'; - -/** - * Root-level logging. - * - * See {@link @backstage/code-plugin-api#RootLoggerService} - * and {@link https://backstage.io/docs/backend-system/core-services/root-logger | the service docs} - * for more information. - * - * @public - * @deprecated Please import from `@backstage/backend-defaults/rootLogger` instead. - */ -export const rootLoggerServiceFactory = _rootLoggerServiceFactory; diff --git a/packages/backend-app-api/src/services/implementations/scheduler/index.ts b/packages/backend-app-api/src/services/implementations/scheduler/index.ts deleted file mode 100644 index 8b67006a4d..0000000000 --- a/packages/backend-app-api/src/services/implementations/scheduler/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * 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 { schedulerServiceFactory } from './schedulerServiceFactory'; diff --git a/packages/backend-app-api/src/services/implementations/scheduler/schedulerServiceFactory.test.ts b/packages/backend-app-api/src/services/implementations/scheduler/schedulerServiceFactory.test.ts deleted file mode 100644 index b16509cf96..0000000000 --- a/packages/backend-app-api/src/services/implementations/scheduler/schedulerServiceFactory.test.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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 { coreServices } from '@backstage/backend-plugin-api'; -import { ServiceFactoryTester } from '@backstage/backend-test-utils'; -import { schedulerServiceFactory } from './schedulerServiceFactory'; - -describe('schedulerFactory', () => { - it('creates sidecar database features', async () => { - const tester = ServiceFactoryTester.from(schedulerServiceFactory()); - - const scheduler = await tester.getSubject(); - await scheduler.scheduleTask({ - id: 'task1', - timeout: { seconds: 1 }, - frequency: { seconds: 1 }, - fn: async () => {}, - }); - - const database = await tester.getService(coreServices.database); - - const client = await database.getClient(); - await expect( - client.from('backstage_backend_tasks__tasks').count(), - ).resolves.toEqual([{ 'count(*)': 1 }]); - await expect( - client.from('backstage_backend_tasks__knex_migrations').count(), - ).resolves.toEqual([{ 'count(*)': expect.any(Number) }]); - await expect( - client.from('backstage_backend_tasks__knex_migrations_lock').count(), - ).resolves.toEqual([{ 'count(*)': expect.any(Number) }]); - }); -}); diff --git a/packages/backend-app-api/src/services/implementations/scheduler/schedulerServiceFactory.ts b/packages/backend-app-api/src/services/implementations/scheduler/schedulerServiceFactory.ts deleted file mode 100644 index b4370761d9..0000000000 --- a/packages/backend-app-api/src/services/implementations/scheduler/schedulerServiceFactory.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2022 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 { - coreServices, - createServiceFactory, -} from '@backstage/backend-plugin-api'; -import { TaskScheduler } from '@backstage/backend-tasks'; - -/** - * @public - * @deprecated Please import from `@backstage/backend-defaults/scheduler` instead. - */ -export const schedulerServiceFactory = createServiceFactory({ - service: coreServices.scheduler, - deps: { - plugin: coreServices.pluginMetadata, - databaseManager: coreServices.database, - logger: coreServices.logger, - }, - async factory({ plugin, databaseManager, logger }) { - return TaskScheduler.forPlugin({ - pluginId: plugin.getId(), - databaseManager, - logger, - }); - }, -}); diff --git a/packages/backend-app-api/src/services/implementations/urlReader/index.ts b/packages/backend-app-api/src/services/implementations/urlReader/index.ts deleted file mode 100644 index 6a4b9f65be..0000000000 --- a/packages/backend-app-api/src/services/implementations/urlReader/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * 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 { urlReaderServiceFactory } from './urlReaderServiceFactory'; diff --git a/packages/backend-app-api/src/services/implementations/urlReader/urlReaderServiceFactory.ts b/packages/backend-app-api/src/services/implementations/urlReader/urlReaderServiceFactory.ts deleted file mode 100644 index 44caf25ad6..0000000000 --- a/packages/backend-app-api/src/services/implementations/urlReader/urlReaderServiceFactory.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2022 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 { UrlReaders } from '@backstage/backend-common'; -import { - coreServices, - createServiceFactory, -} from '@backstage/backend-plugin-api'; - -/** - * @public - * @deprecated Please import from `@backstage/backend-defaults/urlReader` instead. - */ -export const urlReaderServiceFactory = createServiceFactory({ - service: coreServices.urlReader, - deps: { - config: coreServices.rootConfig, - logger: coreServices.logger, - }, - async factory({ config, logger }) { - return UrlReaders.default({ - config, - logger, - }); - }, -}); diff --git a/packages/backend-app-api/src/services/implementations/userInfo/index.ts b/packages/backend-app-api/src/services/implementations/userInfo/index.ts deleted file mode 100644 index 13b42f053c..0000000000 --- a/packages/backend-app-api/src/services/implementations/userInfo/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2024 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 { userInfoServiceFactory } from './userInfoServiceFactory'; diff --git a/packages/backend-app-api/src/services/implementations/userInfo/userInfoServiceFactory.ts b/packages/backend-app-api/src/services/implementations/userInfo/userInfoServiceFactory.ts deleted file mode 100644 index 746f480c41..0000000000 --- a/packages/backend-app-api/src/services/implementations/userInfo/userInfoServiceFactory.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2024 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. - */ - -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { userInfoServiceFactory as _userInfoServiceFactory } from '../../../../../backend-defaults/src/entrypoints/userInfo'; - -/** - * @public - * @deprecated Please import from `@backstage/backend-defaults/userInfo` instead. - */ -export const userInfoServiceFactory = _userInfoServiceFactory; diff --git a/packages/backend-common/src/compat/legacy/legacy.test.ts b/packages/backend-common/src/compat/legacy/legacy.test.ts index e5d395a8f9..08a645f660 100644 --- a/packages/backend-common/src/compat/legacy/legacy.test.ts +++ b/packages/backend-common/src/compat/legacy/legacy.test.ts @@ -24,7 +24,7 @@ import { Router } from 'express'; import { createLegacyAuthAdapters } from '..'; import { legacyPlugin } from './legacy'; // eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { authServiceFactory } from '../../../../backend-app-api/src/services/implementations/auth'; +import { authServiceFactory } from '../../../../backend-defaults/src/entrypoints/auth'; // eslint-disable-next-line @backstage/no-relative-monorepo-imports import { tokenManagerServiceFactory } from '../../../../backend-app-api/src/services/implementations/tokenManager'; diff --git a/packages/backend-dynamic-feature-service/package.json b/packages/backend-dynamic-feature-service/package.json index 4fdb93ee3a..f4a3237762 100644 --- a/packages/backend-dynamic-feature-service/package.json +++ b/packages/backend-dynamic-feature-service/package.json @@ -70,6 +70,7 @@ "winston": "^3.2.1" }, "devDependencies": { + "@backstage/backend-defaults": "workspace:^", "@backstage/backend-test-utils": "workspace:^", "@backstage/cli": "workspace:^", "wait-for-expect": "^3.0.2" diff --git a/packages/backend-dynamic-feature-service/src/manager/plugin-manager.test.ts b/packages/backend-dynamic-feature-service/src/manager/plugin-manager.test.ts index 8531624509..bd5bf1168a 100644 --- a/packages/backend-dynamic-feature-service/src/manager/plugin-manager.test.ts +++ b/packages/backend-dynamic-feature-service/src/manager/plugin-manager.test.ts @@ -37,15 +37,13 @@ import { import { ScannedPluginManifest, ScannedPluginPackage } from '../scanner/types'; import { randomUUID } from 'crypto'; import { TemplateAction } from '@backstage/plugin-scaffolder-node'; -import { - createSpecializedBackend, - rootLifecycleServiceFactory, -} from '@backstage/backend-app-api'; +import { createSpecializedBackend } from '@backstage/backend-app-api'; import { ConfigSources } from '@backstage/config-loader'; import { Logs, MockedLogger, LogContent } from '../__testUtils__/testUtils'; import { PluginScanner } from '../scanner/plugin-scanner'; import { findPaths } from '@backstage/cli-common'; import { createMockDirectory } from '@backstage/backend-test-utils'; +import { rootLifecycleServiceFactory } from '@backstage/backend-defaults'; describe('backend-dynamic-feature-service', () => { const mockDir = createMockDirectory(); diff --git a/packages/backend-test-utils/src/next/wiring/TestBackend.ts b/packages/backend-test-utils/src/next/wiring/TestBackend.ts index cf98c25e4a..09ecfab955 100644 --- a/packages/backend-test-utils/src/next/wiring/TestBackend.ts +++ b/packages/backend-test-utils/src/next/wiring/TestBackend.ts @@ -18,10 +18,7 @@ import { Backend, createSpecializedBackend, MiddlewareFactory, - createHttpServer, ExtendedHttpServer, - HostDiscovery, - DefaultRootHttpRouter, } from '@backstage/backend-app-api'; import { createServiceFactory, @@ -40,7 +37,12 @@ import { InternalBackendFeature, InternalBackendRegistrations, } from '@backstage/backend-plugin-api/src/wiring/types'; -import { createHealthRouter } from '@backstage/backend-defaults/rootHttpRouter'; +import { + DefaultRootHttpRouter, + createHealthRouter, + createHttpServer, +} from '@backstage/backend-defaults/rootHttpRouter'; +import { HostDiscovery } from '@backstage/backend-defaults/discovery'; /** @public */ export interface TestBackendOptions { diff --git a/plugins/proxy-backend/src/service/router.credentials.test.ts b/plugins/proxy-backend/src/service/router.credentials.test.ts index ac32179ef3..a363e7c632 100644 --- a/plugins/proxy-backend/src/service/router.credentials.test.ts +++ b/plugins/proxy-backend/src/service/router.credentials.test.ts @@ -14,10 +14,8 @@ * limitations under the License. */ -import { - authServiceFactory, - httpAuthServiceFactory, -} from '@backstage/backend-app-api'; +import { authServiceFactory } from '@backstage/backend-defaults/auth'; +import { httpAuthServiceFactory } from '@backstage/backend-defaults/httpAuth'; import { mockServices, registerMswTestHooks, diff --git a/yarn.lock b/yarn.lock index 9c292f5903..4a13ea1184 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3715,6 +3715,7 @@ __metadata: dependencies: "@backstage/backend-app-api": "workspace:^" "@backstage/backend-common": "workspace:^" + "@backstage/backend-defaults": "workspace:^" "@backstage/backend-plugin-api": "workspace:^" "@backstage/backend-tasks": "workspace:^" "@backstage/backend-test-utils": "workspace:^" From d45026fbf1b8b7ac02029293b500558842fcaba0 Mon Sep 17 00:00:00 2001 From: Camila Belo Date: Tue, 13 Aug 2024 16:32:51 +0200 Subject: [PATCH 271/372] fix(backend-dynamic-feature-service): fix root lifecycle service factory import Signed-off-by: Camila Belo Signed-off-by: Johan Haals --- .../src/manager/plugin-manager.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend-dynamic-feature-service/src/manager/plugin-manager.test.ts b/packages/backend-dynamic-feature-service/src/manager/plugin-manager.test.ts index bd5bf1168a..9c45cc53f6 100644 --- a/packages/backend-dynamic-feature-service/src/manager/plugin-manager.test.ts +++ b/packages/backend-dynamic-feature-service/src/manager/plugin-manager.test.ts @@ -43,7 +43,7 @@ import { Logs, MockedLogger, LogContent } from '../__testUtils__/testUtils'; import { PluginScanner } from '../scanner/plugin-scanner'; import { findPaths } from '@backstage/cli-common'; import { createMockDirectory } from '@backstage/backend-test-utils'; -import { rootLifecycleServiceFactory } from '@backstage/backend-defaults'; +import { rootLifecycleServiceFactory } from '@backstage/backend-defaults/rootLifecycle'; describe('backend-dynamic-feature-service', () => { const mockDir = createMockDirectory(); From 0ad13df777123b852078466b9fcffcc43cda33a0 Mon Sep 17 00:00:00 2001 From: Camila Belo Date: Tue, 13 Aug 2024 16:34:02 +0200 Subject: [PATCH 272/372] refactor: remove deprecated url reader service types Signed-off-by: Camila Belo Signed-off-by: Johan Haals --- packages/backend-common/api-report.md | 36 ----------- .../backend-common/src/deprecated/index.ts | 63 ------------------- packages/backend-plugin-api/api-report.md | 28 --------- .../services/definitions/UrlReaderService.ts | 47 -------------- .../src/services/definitions/index.ts | 9 --- plugins/search-backend-node/api-report.md | 4 +- plugins/search-backend-node/package.json | 3 +- ...ewlineDelimitedJsonCollatorFactory.test.ts | 14 +++-- .../NewlineDelimitedJsonCollatorFactory.ts | 7 +-- plugins/techdocs-node/src/helpers.test.ts | 24 +++---- yarn.lock | 2 +- 11 files changed, 27 insertions(+), 210 deletions(-) diff --git a/packages/backend-common/api-report.md b/packages/backend-common/api-report.md index 23ed13b62c..e63ff83318 100644 --- a/packages/backend-common/api-report.md +++ b/packages/backend-common/api-report.md @@ -48,21 +48,12 @@ import { PluginMetadataService } from '@backstage/backend-plugin-api'; import { PushResult } from 'isomorphic-git'; import { Readable } from 'stream'; import { ReadCommitResult } from 'isomorphic-git'; -import { ReadTreeOptions as ReadTreeOptions_2 } from '@backstage/backend-plugin-api'; -import { ReadTreeResponse as ReadTreeResponse_2 } from '@backstage/backend-plugin-api'; -import { ReadTreeResponseDirOptions as ReadTreeResponseDirOptions_2 } from '@backstage/backend-plugin-api'; -import { ReadTreeResponseFile as ReadTreeResponseFile_2 } from '@backstage/backend-plugin-api'; -import { ReadUrlOptions as ReadUrlOptions_2 } from '@backstage/backend-plugin-api'; -import { ReadUrlResponse as ReadUrlResponse_2 } from '@backstage/backend-plugin-api'; import { RequestHandler } from 'express'; import { resolvePackagePath as resolvePackagePath_2 } from '@backstage/backend-plugin-api'; import { resolveSafeChildPath as resolveSafeChildPath_2 } from '@backstage/backend-plugin-api'; import { RootConfigService } from '@backstage/backend-plugin-api'; import { Router } from 'express'; import { SchedulerService } from '@backstage/backend-plugin-api'; -import { SearchOptions as SearchOptions_2 } from '@backstage/backend-plugin-api'; -import { SearchResponse as SearchResponse_2 } from '@backstage/backend-plugin-api'; -import { SearchResponseFile as SearchResponseFile_2 } from '@backstage/backend-plugin-api'; import { Server } from 'http'; import { ServiceRef } from '@backstage/backend-plugin-api'; import { TokenManagerService } from '@backstage/backend-plugin-api'; @@ -505,15 +496,6 @@ export interface PullOptions { // @public @deprecated (undocumented) export type ReaderFactory = ReaderFactory_2; -// @public @deprecated (undocumented) -export type ReadTreeOptions = ReadTreeOptions_2; - -// @public @deprecated (undocumented) -export type ReadTreeResponse = ReadTreeResponse_2; - -// @public @deprecated (undocumented) -export type ReadTreeResponseDirOptions = ReadTreeResponseDirOptions_2; - // Warning: (ae-forgotten-export) The symbol "ReadTreeResponseFactory_2" needs to be exported by the entry point index.d.ts // // @public @deprecated (undocumented) @@ -524,15 +506,6 @@ export type ReadTreeResponseFactory = ReadTreeResponseFactory_2; // @public @deprecated (undocumented) export type ReadTreeResponseFactoryOptions = ReadTreeResponseFactoryOptions_2; -// @public @deprecated (undocumented) -export type ReadTreeResponseFile = ReadTreeResponseFile_2; - -// @public @deprecated (undocumented) -export type ReadUrlOptions = ReadUrlOptions_2; - -// @public @deprecated (undocumented) -export type ReadUrlResponse = ReadUrlResponse_2; - // Warning: (ae-forgotten-export) The symbol "ReadUrlResponseFactory_2" needs to be exported by the entry point index.d.ts // // @public @deprecated (undocumented) @@ -577,15 +550,6 @@ export type RunContainerOptions = { pullOptions?: PullOptions; }; -// @public @deprecated (undocumented) -export type SearchOptions = SearchOptions_2; - -// @public @deprecated (undocumented) -export type SearchResponse = SearchResponse_2; - -// @public @deprecated (undocumented) -export type SearchResponseFile = SearchResponseFile_2; - // @public @deprecated export class ServerTokenManager implements TokenManager { // (undocumented) diff --git a/packages/backend-common/src/deprecated/index.ts b/packages/backend-common/src/deprecated/index.ts index e3e4101d25..8c37017eb7 100644 --- a/packages/backend-common/src/deprecated/index.ts +++ b/packages/backend-common/src/deprecated/index.ts @@ -85,15 +85,6 @@ import { resolvePackagePath as _resolvePackagePath, resolveSafeChildPath as _resolveSafeChildPath, isChildPath as _isChildPath, - ReadTreeOptions as _ReadTreeOptions, - ReadTreeResponse as _ReadTreeResponse, - ReadTreeResponseFile as _ReadTreeResponseFile, - ReadTreeResponseDirOptions as _ReadTreeResponseDirOptions, - ReadUrlOptions as _ReadUrlOptions, - ReadUrlResponse as _ReadUrlResponse, - SearchOptions as _SearchOptions, - SearchResponse as _SearchResponse, - SearchResponseFile as _SearchResponseFile, UrlReaderService as _UrlReaderService, LifecycleService, PluginMetadataService, @@ -412,60 +403,6 @@ export type ReadUrlResponseFactoryFromStreamOptions = */ export type UrlReaderPredicateTuple = _UrlReaderPredicateTuple; -/** - * @public - * @deprecated Use `UrlReaderServiceReadTreeOptions` from `@backstage/backend-plugin-api` instead - */ -export type ReadTreeOptions = _ReadTreeOptions; - -/** - * @public - * @deprecated Use `UrlReaderServiceReadTreeResponse` from `@backstage/backend-plugin-api` instead - */ -export type ReadTreeResponse = _ReadTreeResponse; - -/** - * @public - * @deprecated Use `UrlReaderServiceReadTreeResponseFile` from `@backstage/backend-plugin-api` instead - */ -export type ReadTreeResponseFile = _ReadTreeResponseFile; - -/** - * @public - * @deprecated Use `UrlReaderServiceReadTreeResponseDirOptions` from `@backstage/backend-plugin-api` instead - */ -export type ReadTreeResponseDirOptions = _ReadTreeResponseDirOptions; - -/** - * @public - * @deprecated Use `UrlReaderServiceReadUrlOptions` from `@backstage/backend-plugin-api` instead - */ -export type ReadUrlOptions = _ReadUrlOptions; - -/** - * @public - * @deprecated Use `UrlReaderServiceReadUrlResponse` from `@backstage/backend-plugin-api` instead - */ -export type ReadUrlResponse = _ReadUrlResponse; - -/** - * @public - * @deprecated Use `UrlReaderServiceSearchOptions` from `@backstage/backend-plugin-api` instead - */ -export type SearchOptions = _SearchOptions; - -/** - * @public - * @deprecated Use `UrlReaderServiceSearchResponse` from `@backstage/backend-plugin-api` instead - */ -export type SearchResponse = _SearchResponse; - -/** - * @public - * @deprecated Use `UrlReaderServiceSearchResponseFile` from `@backstage/backend-plugin-api` instead - */ -export type SearchResponseFile = _SearchResponseFile; - /** * @public * @deprecated Use `UrlReaderService` from `@backstage/backend-plugin-api` instead diff --git a/packages/backend-plugin-api/api-report.md b/packages/backend-plugin-api/api-report.md index 319ddf0bc6..0864064625 100644 --- a/packages/backend-plugin-api/api-report.md +++ b/packages/backend-plugin-api/api-report.md @@ -553,25 +553,6 @@ export function readSchedulerServiceTaskScheduleDefinitionFromConfig( config: Config, ): SchedulerServiceTaskScheduleDefinition; -// @public @deprecated (undocumented) -export type ReadTreeOptions = UrlReaderServiceReadTreeOptions; - -// @public @deprecated (undocumented) -export type ReadTreeResponse = UrlReaderServiceReadTreeResponse; - -// @public @deprecated (undocumented) -export type ReadTreeResponseDirOptions = - UrlReaderServiceReadTreeResponseDirOptions; - -// @public @deprecated (undocumented) -export type ReadTreeResponseFile = UrlReaderServiceReadTreeResponseFile; - -// @public @deprecated (undocumented) -export type ReadUrlOptions = UrlReaderServiceReadUrlOptions; - -// @public @deprecated (undocumented) -export type ReadUrlResponse = UrlReaderServiceReadUrlResponse; - // @public export function resolvePackagePath(name: string, ...paths: string[]): string; @@ -707,15 +688,6 @@ export interface SchedulerServiceTaskScheduleDefinitionConfig { timeout: string | HumanDuration; } -// @public @deprecated (undocumented) -export type SearchOptions = UrlReaderServiceSearchOptions; - -// @public @deprecated (undocumented) -export type SearchResponse = UrlReaderServiceSearchResponse; - -// @public @deprecated (undocumented) -export type SearchResponseFile = UrlReaderServiceSearchResponseFile; - // @public (undocumented) export interface ServiceFactory< TService = unknown, diff --git a/packages/backend-plugin-api/src/services/definitions/UrlReaderService.ts b/packages/backend-plugin-api/src/services/definitions/UrlReaderService.ts index 25b787107e..9b327cfbf0 100644 --- a/packages/backend-plugin-api/src/services/definitions/UrlReaderService.ts +++ b/packages/backend-plugin-api/src/services/definitions/UrlReaderService.ts @@ -368,50 +368,3 @@ export type UrlReaderServiceSearchResponseFile = { */ lastModifiedAt?: Date; }; - -/** - * @public - * @deprecated Use `UrlReaderServiceReadTreeOptions` instead - */ -export type ReadTreeOptions = UrlReaderServiceReadTreeOptions; -/** - * @public - * @deprecated Use `UrlReaderServiceReadTreeResponse` instead - */ -export type ReadTreeResponse = UrlReaderServiceReadTreeResponse; -/** - * @public - * @deprecated Use `UrlReaderServiceReadTreeResponseDirOptions` instead - */ -export type ReadTreeResponseDirOptions = - UrlReaderServiceReadTreeResponseDirOptions; -/** - * @public - * @deprecated Use `UrlReaderServiceReadTreeResponseFile` instead - */ -export type ReadTreeResponseFile = UrlReaderServiceReadTreeResponseFile; -/** - * @public - * @deprecated Use `UrlReaderServiceReadUrlResponse` instead - */ -export type ReadUrlResponse = UrlReaderServiceReadUrlResponse; -/** - * @public - * @deprecated Use `UrlReaderServiceReadUrlOptions` instead - */ -export type ReadUrlOptions = UrlReaderServiceReadUrlOptions; -/** - * @public - * @deprecated Use `UrlReaderServiceSearchOptions` instead - */ -export type SearchOptions = UrlReaderServiceSearchOptions; -/** - * @public - * @deprecated Use `UrlReaderServiceSearchResponse` instead - */ -export type SearchResponse = UrlReaderServiceSearchResponse; -/** - * @public - * @deprecated Use `UrlReaderServiceSearchResponseFile` instead - */ -export type SearchResponseFile = UrlReaderServiceSearchResponseFile; diff --git a/packages/backend-plugin-api/src/services/definitions/index.ts b/packages/backend-plugin-api/src/services/definitions/index.ts index 5e30d444fd..194658dc0e 100644 --- a/packages/backend-plugin-api/src/services/definitions/index.ts +++ b/packages/backend-plugin-api/src/services/definitions/index.ts @@ -66,15 +66,6 @@ export type { } from './SchedulerService'; export type { TokenManagerService } from './TokenManagerService'; export type { - ReadTreeOptions, - ReadTreeResponse, - ReadTreeResponseDirOptions, - ReadTreeResponseFile, - ReadUrlResponse, - ReadUrlOptions, - SearchOptions, - SearchResponse, - SearchResponseFile, UrlReaderServiceReadTreeOptions, UrlReaderServiceReadTreeResponse, UrlReaderServiceReadTreeResponseDirOptions, diff --git a/plugins/search-backend-node/api-report.md b/plugins/search-backend-node/api-report.md index 5e8961a65e..03269c72e8 100644 --- a/plugins/search-backend-node/api-report.md +++ b/plugins/search-backend-node/api-report.md @@ -20,7 +20,7 @@ import { SearchQuery } from '@backstage/plugin-search-common'; import { TaskFunction } from '@backstage/backend-tasks'; import { TaskRunner } from '@backstage/backend-tasks'; import { Transform } from 'stream'; -import { UrlReader } from '@backstage/backend-common'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; import { Writable } from 'stream'; // @public @@ -138,7 +138,7 @@ export class NewlineDelimitedJsonCollatorFactory export type NewlineDelimitedJsonCollatorFactoryOptions = { type: string; searchPattern: string; - reader: UrlReader; + reader: UrlReaderService; logger: LoggerService; visibilityPermission?: Permission; }; diff --git a/plugins/search-backend-node/package.json b/plugins/search-backend-node/package.json index d7a7191faa..c8a833e92a 100644 --- a/plugins/search-backend-node/package.json +++ b/plugins/search-backend-node/package.json @@ -53,7 +53,7 @@ "test": "backstage-cli package test" }, "dependencies": { - "@backstage/backend-common": "workspace:^", + "@backstage/backend-defaults": "workspace:^", "@backstage/backend-plugin-api": "workspace:^", "@backstage/backend-tasks": "workspace:^", "@backstage/config": "workspace:^", @@ -67,7 +67,6 @@ "uuid": "^9.0.0" }, "devDependencies": { - "@backstage/backend-common": "workspace:^", "@backstage/backend-test-utils": "workspace:^", "@backstage/cli": "workspace:^", "@types/ndjson": "^2.0.1" diff --git a/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.test.ts b/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.test.ts index 45cc98e9ba..45f3635232 100644 --- a/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.test.ts +++ b/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.test.ts @@ -14,16 +14,16 @@ * limitations under the License. */ -import { - ReadUrlResponse, - UrlReader, - UrlReaders, -} from '@backstage/backend-common'; import { ConfigReader } from '@backstage/config'; import { Readable } from 'stream'; import { NewlineDelimitedJsonCollatorFactory } from './NewlineDelimitedJsonCollatorFactory'; import { TestPipeline } from '../test-utils'; import { mockServices } from '@backstage/backend-test-utils'; +import { + UrlReaderService, + UrlReaderServiceReadUrlResponse, +} from '@backstage/backend-plugin-api'; +import { UrlReaders } from '@backstage/backend-defaults/urlReader'; describe('DefaultCatalogCollatorFactory', () => { const config = new ConfigReader({}); @@ -42,7 +42,9 @@ describe('DefaultCatalogCollatorFactory', () => { describe('getCollator', () => { let readable: Readable; let reader: jest.Mocked< - UrlReader & { readUrl: jest.Mock> } + UrlReaderService & { + readUrl: jest.Mock>; + } >; let factory: NewlineDelimitedJsonCollatorFactory; diff --git a/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.ts b/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.ts index e7d749dd41..bf78b98040 100644 --- a/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.ts +++ b/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.ts @@ -18,9 +18,8 @@ import { Config } from '@backstage/config'; import { DocumentCollatorFactory } from '@backstage/plugin-search-common'; import { Permission } from '@backstage/plugin-permission-common'; import { Readable } from 'stream'; -import { UrlReader } from '@backstage/backend-common'; import { parse as parseNdjson } from 'ndjson'; -import { LoggerService } from '@backstage/backend-plugin-api'; +import { LoggerService, UrlReaderService } from '@backstage/backend-plugin-api'; /** * Options for instantiate NewlineDelimitedJsonCollatorFactory @@ -29,7 +28,7 @@ import { LoggerService } from '@backstage/backend-plugin-api'; export type NewlineDelimitedJsonCollatorFactoryOptions = { type: string; searchPattern: string; - reader: UrlReader; + reader: UrlReaderService; logger: LoggerService; visibilityPermission?: Permission; }; @@ -73,7 +72,7 @@ export class NewlineDelimitedJsonCollatorFactory private constructor( type: string, private readonly searchPattern: string, - private readonly reader: UrlReader, + private readonly reader: UrlReaderService, private readonly logger: LoggerService, visibilityPermission: Permission | undefined, ) { diff --git a/plugins/techdocs-node/src/helpers.test.ts b/plugins/techdocs-node/src/helpers.test.ts index 4f77a5432b..e0c9ac41ca 100644 --- a/plugins/techdocs-node/src/helpers.test.ts +++ b/plugins/techdocs-node/src/helpers.test.ts @@ -14,13 +14,6 @@ * limitations under the License. */ -import { - ReadTreeResponse, - ReadUrlOptions, - ReadUrlResponse, - SearchResponse, - UrlReader, -} from '@backstage/backend-common'; import { Entity, getEntitySourceLocation } from '@backstage/catalog-model'; import { ConfigReader } from '@backstage/config'; import { ScmIntegrations } from '@backstage/integration'; @@ -34,6 +27,13 @@ import { parseReferenceAnnotation, transformDirLocation, } from './helpers'; +import { + UrlReaderService, + UrlReaderServiceReadTreeResponse, + UrlReaderServiceReadUrlOptions, + UrlReaderServiceReadUrlResponse, + UrlReaderServiceSearchResponse, +} from '@backstage/backend-plugin-api'; jest.mock('@backstage/catalog-model', () => ({ ...jest.requireActual('@backstage/catalog-model'), @@ -290,19 +290,19 @@ describe('getLocationForEntity', () => { describe('getDocFilesFromRepository', () => { it('should read a remote directory using UrlReader.readTree', async () => { - class MockUrlReader implements UrlReader { + class MockUrlReader implements UrlReaderService { async read() { return Buffer.from('mock'); } async readUrl( _url: string, - _options?: ReadUrlOptions | undefined, - ): Promise { + _options?: UrlReaderServiceReadUrlOptions | undefined, + ): Promise { throw new Error('Method not implemented.'); } - async readTree(): Promise { + async readTree(): Promise { return { dir: async () => { return '/tmp/testfolder'; @@ -317,7 +317,7 @@ describe('getDocFilesFromRepository', () => { }; } - async search(): Promise { + async search(): Promise { return { etag: '', files: [], diff --git a/yarn.lock b/yarn.lock index 4a13ea1184..b6cfe624cc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7553,7 +7553,7 @@ __metadata: version: 0.0.0-use.local resolution: "@backstage/plugin-search-backend-node@workspace:plugins/search-backend-node" dependencies: - "@backstage/backend-common": "workspace:^" + "@backstage/backend-defaults": "workspace:^" "@backstage/backend-plugin-api": "workspace:^" "@backstage/backend-tasks": "workspace:^" "@backstage/backend-test-utils": "workspace:^" From 29ee082ed6bfe1298778675a7d221dc515512e2f Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Wed, 14 Aug 2024 09:36:59 +0200 Subject: [PATCH 273/372] backend-app-api: Remove deprecated MiddlewareFactory Signed-off-by: Johan Haals --- packages/backend-app-api/api-report.md | 61 +----- packages/backend-app-api/src/http/index.ts | 183 ------------------ packages/backend-app-api/src/index.ts | 1 - packages/backend-test-utils/api-report.md | 2 +- .../src/next/wiring/TestBackend.ts | 9 +- plugins/kubernetes-backend/package.json | 1 + .../src/routes/resourceRoutes.test.ts | 2 +- .../src/service/KubernetesBuilder.test.ts | 2 +- plugins/kubernetes-node/package.json | 1 + .../src/auth/PinnipedHelper.test.ts | 2 +- plugins/scaffolder-backend/package.json | 1 + .../src/service/router.test.ts | 2 +- yarn.lock | 3 + 13 files changed, 15 insertions(+), 255 deletions(-) delete mode 100644 packages/backend-app-api/src/http/index.ts diff --git a/packages/backend-app-api/api-report.md b/packages/backend-app-api/api-report.md index e4adcb56f2..ba2a8734b0 100644 --- a/packages/backend-app-api/api-report.md +++ b/packages/backend-app-api/api-report.md @@ -3,23 +3,15 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -/// - import type { AppConfig } from '@backstage/config'; import { BackendFeature } from '@backstage/backend-plugin-api'; -import { Config } from '@backstage/config'; +import type { Config } from '@backstage/config'; import { ConfigSchema } from '@backstage/config-loader'; -import { CorsOptions } from 'cors'; -import { ErrorRequestHandler } from 'express'; import { Format } from 'logform'; -import { HelmetOptions } from 'helmet'; -import * as http from 'http'; import { IdentityService } from '@backstage/backend-plugin-api'; import { JsonObject } from '@backstage/types'; import { LoadConfigOptionsRemote } from '@backstage/config-loader'; import { LoggerService } from '@backstage/backend-plugin-api'; -import { RequestHandler } from 'express'; -import { RootConfigService } from '@backstage/backend-plugin-api'; import { RootLoggerService } from '@backstage/backend-plugin-api'; import { ServiceFactory } from '@backstage/backend-plugin-api'; import { ServiceFactoryCompat } from '@backstage/backend-plugin-api'; @@ -66,21 +58,6 @@ export interface CreateSpecializedBackendOptions { defaultServiceFactories: ServiceFactory[]; } -// Warning: (ae-forgotten-export) The symbol "ExtendedHttpServer_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export type ExtendedHttpServer = ExtendedHttpServer_2; - -// Warning: (ae-forgotten-export) The symbol "HttpServerCertificateOptions_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export type HttpServerCertificateOptions = HttpServerCertificateOptions_2; - -// Warning: (ae-forgotten-export) The symbol "HttpServerOptions_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export type HttpServerOptions = HttpServerOptions_2; - // @public @deprecated export type IdentityFactoryOptions = { issuer?: string; @@ -105,42 +82,6 @@ export function loadBackendConfig(options: { config: Config; }>; -// @public @deprecated (undocumented) -export class MiddlewareFactory { - compression(): RequestHandler; - cors(): RequestHandler; - static create(options: MiddlewareFactoryOptions): MiddlewareFactory; - error(options?: MiddlewareFactoryErrorOptions): ErrorRequestHandler; - helmet(): RequestHandler; - logging(): RequestHandler; - notFound(): RequestHandler; -} - -// Warning: (ae-forgotten-export) The symbol "MiddlewareFactoryErrorOptions_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export type MiddlewareFactoryErrorOptions = MiddlewareFactoryErrorOptions_2; - -// Warning: (ae-forgotten-export) The symbol "MiddlewareFactoryOptions_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export type MiddlewareFactoryOptions = MiddlewareFactoryOptions_2; - -// Warning: (ae-forgotten-export) The symbol "readCorsOptions_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export const readCorsOptions: typeof readCorsOptions_2; - -// Warning: (ae-forgotten-export) The symbol "readHelmetOptions_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export const readHelmetOptions: typeof readHelmetOptions_2; - -// Warning: (ae-forgotten-export) The symbol "readHttpServerOptions_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export const readHttpServerOptions: typeof readHttpServerOptions_2; - // @public @deprecated (undocumented) export const tokenManagerServiceFactory: ServiceFactoryCompat< TokenManagerService, diff --git a/packages/backend-app-api/src/http/index.ts b/packages/backend-app-api/src/http/index.ts deleted file mode 100644 index 2ff62209f7..0000000000 --- a/packages/backend-app-api/src/http/index.ts +++ /dev/null @@ -1,183 +0,0 @@ -/* - * 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 { ErrorRequestHandler, RequestHandler } from 'express'; -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { - readHttpServerOptions as _readHttpServerOptions, - createHttpServer as _createHttpServer, - MiddlewareFactory as _MiddlewareFactory, - readCorsOptions as _readCorsOptions, - readHelmetOptions as _readHelmetOptions, - type MiddlewareFactoryErrorOptions as _MiddlewareFactoryErrorOptions, - type MiddlewareFactoryOptions as _MiddlewareFactoryOptions, - type ExtendedHttpServer as _ExtendedHttpServer, - type HttpServerCertificateOptions as _HttpServerCertificateOptions, - type HttpServerOptions as _HttpServerOptions, -} from '../../../backend-defaults/src/entrypoints/rootHttpRouter/http'; - -/** - * @public - * @deprecated Please import from `@backstage/backend-defaults/rootHttpRouter` instead. - */ -export const readHttpServerOptions = _readHttpServerOptions; - -/** - * @public - * @deprecated Please import from `@backstage/backend-defaults/rootHttpRouter` instead. - */ -export const readCorsOptions = _readCorsOptions; -/** - * @public - * @deprecated Please import from `@backstage/backend-defaults/rootHttpRouter` instead. - */ -export const readHelmetOptions = _readHelmetOptions; -/** - * @public - * @deprecated Please import from `@backstage/backend-defaults/rootHttpRouter` instead. - */ -export class MiddlewareFactory { - /** - * Creates a new {@link MiddlewareFactory}. - */ - static create(options: MiddlewareFactoryOptions) { - return new MiddlewareFactory(_MiddlewareFactory.create(options)); - } - - private constructor(private readonly impl: _MiddlewareFactory) {} - - /** - * Returns a middleware that unconditionally produces a 404 error response. - * - * @remarks - * - * Typically you want to place this middleware at the end of the chain, such - * that it's the last one attempted after no other routes matched. - * - * @returns An Express request handler - */ - notFound(): RequestHandler { - return this.impl.notFound(); - } - - /** - * Returns the compression middleware. - * - * @remarks - * - * The middleware will attempt to compress response bodies for all requests - * that traverse through the middleware. - */ - compression(): RequestHandler { - return this.impl.compression(); - } - - /** - * Returns a request logging middleware. - * - * @remarks - * - * Typically you want to place this middleware at the start of the chain, such - * that it always logs requests whether they are "caught" by handlers farther - * down or not. - * - * @returns An Express request handler - */ - logging(): RequestHandler { - return this.impl.logging(); - } - - /** - * Returns a middleware that implements the helmet library. - * - * @remarks - * - * This middleware applies security policies to incoming requests and outgoing - * responses. It is configured using config keys such as `backend.csp`. - * - * @see {@link https://helmetjs.github.io/} - * - * @returns An Express request handler - */ - helmet(): RequestHandler { - return this.impl.helmet(); - } - - /** - * Returns a middleware that implements the cors library. - * - * @remarks - * - * This middleware handles CORS. It is configured using the config key - * `backend.cors`. - * - * @see {@link https://github.com/expressjs/cors} - * - * @returns An Express request handler - */ - cors(): RequestHandler { - return this.impl.cors(); - } - - /** - * Express middleware to handle errors during request processing. - * - * @remarks - * - * This is commonly the very last middleware in the chain. - * - * Its primary purpose is not to do translation of business logic exceptions, - * but rather to be a global catch-all for uncaught "fatal" errors that are - * expected to result in a 500 error. However, it also does handle some common - * error types (such as http-error exceptions, and the well-known error types - * in the `@backstage/errors` package) and returns the enclosed status code - * accordingly. - * - * It will also produce a response body with a serialized form of the error, - * unless a previous handler already did send a body. See - * {@link @backstage/errors#ErrorResponseBody} for the response shape used. - * - * @returns An Express error request handler - */ - error(options: MiddlewareFactoryErrorOptions = {}): ErrorRequestHandler { - return this.impl.error(options); - } -} -/** - * @public - * @deprecated Please import from `@backstage/backend-defaults/rootHttpRouter` instead. - */ -export type MiddlewareFactoryErrorOptions = _MiddlewareFactoryErrorOptions; -/** - * @public - * @deprecated Please import from `@backstage/backend-defaults/rootHttpRouter` instead. - */ -export type MiddlewareFactoryOptions = _MiddlewareFactoryOptions; -/** - * @public - * @deprecated Please import from `@backstage/backend-defaults/rootHttpRouter` instead. - */ -export type ExtendedHttpServer = _ExtendedHttpServer; -/** - * @public - * @deprecated Please import from `@backstage/backend-defaults/rootHttpRouter` instead. - */ -export type HttpServerCertificateOptions = _HttpServerCertificateOptions; -/** - * @public - * @deprecated Please import from `@backstage/backend-defaults/rootHttpRouter` instead. - */ -export type HttpServerOptions = _HttpServerOptions; diff --git a/packages/backend-app-api/src/index.ts b/packages/backend-app-api/src/index.ts index 13864a3470..9fead85fe8 100644 --- a/packages/backend-app-api/src/index.ts +++ b/packages/backend-app-api/src/index.ts @@ -21,7 +21,6 @@ */ export * from './config'; -export * from './http'; export * from './logging'; export * from './wiring'; export * from './services/implementations'; diff --git a/packages/backend-test-utils/api-report.md b/packages/backend-test-utils/api-report.md index 584fedb1f5..4937a7810c 100644 --- a/packages/backend-test-utils/api-report.md +++ b/packages/backend-test-utils/api-report.md @@ -19,7 +19,7 @@ import { CacheService } from '@backstage/backend-plugin-api'; import { DatabaseService } from '@backstage/backend-plugin-api'; import { DiscoveryService } from '@backstage/backend-plugin-api'; import { EventsService } from '@backstage/plugin-events-node'; -import { ExtendedHttpServer } from '@backstage/backend-app-api'; +import { ExtendedHttpServer } from '@backstage/backend-defaults/rootHttpRouter'; import { ExtensionPoint } from '@backstage/backend-plugin-api'; import { HttpAuthService } from '@backstage/backend-plugin-api'; import { HttpRouterService } from '@backstage/backend-plugin-api'; diff --git a/packages/backend-test-utils/src/next/wiring/TestBackend.ts b/packages/backend-test-utils/src/next/wiring/TestBackend.ts index 09ecfab955..6b4110d4de 100644 --- a/packages/backend-test-utils/src/next/wiring/TestBackend.ts +++ b/packages/backend-test-utils/src/next/wiring/TestBackend.ts @@ -14,12 +14,7 @@ * limitations under the License. */ -import { - Backend, - createSpecializedBackend, - MiddlewareFactory, - ExtendedHttpServer, -} from '@backstage/backend-app-api'; +import { Backend, createSpecializedBackend } from '@backstage/backend-app-api'; import { createServiceFactory, BackendFeature, @@ -39,6 +34,8 @@ import { } from '@backstage/backend-plugin-api/src/wiring/types'; import { DefaultRootHttpRouter, + ExtendedHttpServer, + MiddlewareFactory, createHealthRouter, createHttpServer, } from '@backstage/backend-defaults/rootHttpRouter'; diff --git a/plugins/kubernetes-backend/package.json b/plugins/kubernetes-backend/package.json index c5c6dc05eb..0b1271636b 100644 --- a/plugins/kubernetes-backend/package.json +++ b/plugins/kubernetes-backend/package.json @@ -99,6 +99,7 @@ }, "devDependencies": { "@backstage/backend-app-api": "workspace:^", + "@backstage/backend-defaults": "workspace:^", "@backstage/backend-test-utils": "workspace:^", "@backstage/cli": "workspace:^", "@backstage/plugin-permission-backend": "workspace:^", diff --git a/plugins/kubernetes-backend/src/routes/resourceRoutes.test.ts b/plugins/kubernetes-backend/src/routes/resourceRoutes.test.ts index cfa89a6bfd..d041fdc40b 100644 --- a/plugins/kubernetes-backend/src/routes/resourceRoutes.test.ts +++ b/plugins/kubernetes-backend/src/routes/resourceRoutes.test.ts @@ -20,7 +20,7 @@ import { mockServices, startTestBackend, } from '@backstage/backend-test-utils'; -import { ExtendedHttpServer } from '@backstage/backend-app-api'; +import { ExtendedHttpServer } from '@backstage/backend-defaults'; import { kubernetesObjectsProviderExtensionPoint } from '@backstage/plugin-kubernetes-node'; import { createBackendModule } from '@backstage/backend-plugin-api'; import { Entity } from '@backstage/catalog-model'; diff --git a/plugins/kubernetes-backend/src/service/KubernetesBuilder.test.ts b/plugins/kubernetes-backend/src/service/KubernetesBuilder.test.ts index 5edb8845d4..60683a74f3 100644 --- a/plugins/kubernetes-backend/src/service/KubernetesBuilder.test.ts +++ b/plugins/kubernetes-backend/src/service/KubernetesBuilder.test.ts @@ -56,7 +56,7 @@ import { kubernetesFetcherExtensionPoint, kubernetesServiceLocatorExtensionPoint, } from '@backstage/plugin-kubernetes-node'; -import { ExtendedHttpServer } from '@backstage/backend-app-api'; +import { ExtendedHttpServer } from '@backstage/backend-defaults/rootHttpRouter'; describe('API integration tests', () => { let app: ExtendedHttpServer; diff --git a/plugins/kubernetes-node/package.json b/plugins/kubernetes-node/package.json index 92ece79c6d..4873e277c1 100644 --- a/plugins/kubernetes-node/package.json +++ b/plugins/kubernetes-node/package.json @@ -49,6 +49,7 @@ "devDependencies": { "@backstage/backend-app-api": "workspace:^", "@backstage/backend-common": "workspace:^", + "@backstage/backend-defaults": "workspace:^", "@backstage/backend-test-utils": "workspace:^", "@backstage/cli": "workspace:^", "@backstage/plugin-kubernetes-backend": "workspace:^", diff --git a/plugins/kubernetes-node/src/auth/PinnipedHelper.test.ts b/plugins/kubernetes-node/src/auth/PinnipedHelper.test.ts index 24cd459fde..65e48affc0 100644 --- a/plugins/kubernetes-node/src/auth/PinnipedHelper.test.ts +++ b/plugins/kubernetes-node/src/auth/PinnipedHelper.test.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import { ExtendedHttpServer } from '@backstage/backend-app-api'; import { ClusterDetails } from '../types'; import { mockServices, @@ -37,6 +36,7 @@ import { JsonObject } from '@backstage/types'; import { rest } from 'msw'; import { setupServer } from 'msw/node'; import { loggerToWinstonLogger } from '@backstage/backend-common'; +import { ExtendedHttpServer } from '@backstage/backend-defaults/rootHttpRouter'; describe('Pinniped - tokenCredentialRequest', () => { let app: ExtendedHttpServer; diff --git a/plugins/scaffolder-backend/package.json b/plugins/scaffolder-backend/package.json index f3d10ba478..a8413f9931 100644 --- a/plugins/scaffolder-backend/package.json +++ b/plugins/scaffolder-backend/package.json @@ -115,6 +115,7 @@ }, "devDependencies": { "@backstage/backend-app-api": "workspace:^", + "@backstage/backend-defaults": "workspace:^", "@backstage/backend-test-utils": "workspace:^", "@backstage/cli": "workspace:^", "@backstage/plugin-scaffolder-node-test-utils": "workspace:^", diff --git a/plugins/scaffolder-backend/src/service/router.test.ts b/plugins/scaffolder-backend/src/service/router.test.ts index 01a2fba6e8..e53f3a5dd9 100644 --- a/plugins/scaffolder-backend/src/service/router.test.ts +++ b/plugins/scaffolder-backend/src/service/router.test.ts @@ -47,7 +47,7 @@ import { } from '@backstage/plugin-permission-common'; import { mockCredentials, mockServices } from '@backstage/backend-test-utils'; import { AutocompleteHandler } from '@backstage/plugin-scaffolder-node/alpha'; -import { MiddlewareFactory } from '@backstage/backend-app-api'; +import { MiddlewareFactory } from '@backstage/backend-defaults/rootHttpRouter'; const mockAccess = jest.fn(); diff --git a/yarn.lock b/yarn.lock index b6cfe624cc..e34246fd58 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6332,6 +6332,7 @@ __metadata: "@azure/identity": ^4.0.0 "@backstage/backend-app-api": "workspace:^" "@backstage/backend-common": "workspace:^" + "@backstage/backend-defaults": "workspace:^" "@backstage/backend-plugin-api": "workspace:^" "@backstage/backend-test-utils": "workspace:^" "@backstage/catalog-client": "workspace:^" @@ -6431,6 +6432,7 @@ __metadata: dependencies: "@backstage/backend-app-api": "workspace:^" "@backstage/backend-common": "workspace:^" + "@backstage/backend-defaults": "workspace:^" "@backstage/backend-plugin-api": "workspace:^" "@backstage/backend-test-utils": "workspace:^" "@backstage/catalog-model": "workspace:^" @@ -7179,6 +7181,7 @@ __metadata: dependencies: "@backstage/backend-app-api": "workspace:^" "@backstage/backend-common": "workspace:^" + "@backstage/backend-defaults": "workspace:^" "@backstage/backend-plugin-api": "workspace:^" "@backstage/backend-tasks": "workspace:^" "@backstage/backend-test-utils": "workspace:^" From 0c40cd7d40e48c4371098edd88d7a1833abcb2d7 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Wed, 14 Aug 2024 10:59:55 +0200 Subject: [PATCH 274/372] chore: Update imports Signed-off-by: Johan Haals --- plugins/kubernetes-backend/src/routes/resourceRoutes.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/kubernetes-backend/src/routes/resourceRoutes.test.ts b/plugins/kubernetes-backend/src/routes/resourceRoutes.test.ts index d041fdc40b..5264e762b6 100644 --- a/plugins/kubernetes-backend/src/routes/resourceRoutes.test.ts +++ b/plugins/kubernetes-backend/src/routes/resourceRoutes.test.ts @@ -20,10 +20,10 @@ import { mockServices, startTestBackend, } from '@backstage/backend-test-utils'; -import { ExtendedHttpServer } from '@backstage/backend-defaults'; import { kubernetesObjectsProviderExtensionPoint } from '@backstage/plugin-kubernetes-node'; import { createBackendModule } from '@backstage/backend-plugin-api'; import { Entity } from '@backstage/catalog-model'; +import { ExtendedHttpServer } from '@backstage/backend-defaults/rootHttpRouter'; describe('resourcesRoutes', () => { let app: ExtendedHttpServer; From f24ba909bfdc4f6a86b0f3b712a8385e14df5828 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Wed, 14 Aug 2024 11:34:39 +0200 Subject: [PATCH 275/372] backend-app-api: Move deprecated loadBackendConfig to backend-common Co-authored-by: Camila Belo Signed-off-by: Johan Haals --- packages/backend-app-api/api-report.md | 19 ------- packages/backend-app-api/src/index.ts | 1 - packages/backend-common/api-report.md | 6 +++ .../backend-common/src/deprecated/config.ts | 54 ------------------- .../config/ObservableConfigProxy.test.ts | 0 .../config/ObservableConfigProxy.ts | 0 .../src/deprecated}/config/config.test.ts | 2 +- .../src/deprecated}/config/config.ts | 31 +++++++++-- .../src/deprecated}/config/index.ts | 2 +- .../src/deprecated/config}/urls.test.ts | 0 .../src/deprecated/config}/urls.ts | 0 .../src/schemas/rootLoggerServiceFactory.ts | 2 +- 12 files changed, 36 insertions(+), 81 deletions(-) delete mode 100644 packages/backend-common/src/deprecated/config.ts rename packages/{backend-app-api/src => backend-common/src/deprecated}/config/ObservableConfigProxy.test.ts (100%) rename packages/{backend-app-api/src => backend-common/src/deprecated}/config/ObservableConfigProxy.ts (100%) rename packages/{backend-app-api/src => backend-common/src/deprecated}/config/config.test.ts (100%) rename packages/{backend-app-api/src => backend-common/src/deprecated}/config/config.ts (76%) rename packages/{backend-app-api/src => backend-common/src/deprecated}/config/index.ts (94%) rename packages/{backend-app-api/src/lib => backend-common/src/deprecated/config}/urls.test.ts (100%) rename packages/{backend-app-api/src/lib => backend-common/src/deprecated/config}/urls.ts (100%) diff --git a/packages/backend-app-api/api-report.md b/packages/backend-app-api/api-report.md index ba2a8734b0..bec20dff16 100644 --- a/packages/backend-app-api/api-report.md +++ b/packages/backend-app-api/api-report.md @@ -3,14 +3,10 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -import type { AppConfig } from '@backstage/config'; import { BackendFeature } from '@backstage/backend-plugin-api'; -import type { Config } from '@backstage/config'; -import { ConfigSchema } from '@backstage/config-loader'; import { Format } from 'logform'; import { IdentityService } from '@backstage/backend-plugin-api'; import { JsonObject } from '@backstage/types'; -import { LoadConfigOptionsRemote } from '@backstage/config-loader'; import { LoggerService } from '@backstage/backend-plugin-api'; import { RootLoggerService } from '@backstage/backend-plugin-api'; import { ServiceFactory } from '@backstage/backend-plugin-api'; @@ -42,11 +38,6 @@ export interface Backend { stop(): Promise; } -// Warning: (ae-forgotten-export) The symbol "createConfigSecretEnumerator_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export const createConfigSecretEnumerator: typeof createConfigSecretEnumerator_2; - // @public (undocumented) export function createSpecializedBackend( options: CreateSpecializedBackendOptions, @@ -72,16 +63,6 @@ export const identityServiceFactory: ServiceFactoryCompat< IdentityFactoryOptions >; -// @public @deprecated -export function loadBackendConfig(options: { - remote?: LoadConfigOptionsRemote; - argv: string[]; - additionalConfigs?: AppConfig[]; - watch?: boolean; -}): Promise<{ - config: Config; -}>; - // @public @deprecated (undocumented) export const tokenManagerServiceFactory: ServiceFactoryCompat< TokenManagerService, diff --git a/packages/backend-app-api/src/index.ts b/packages/backend-app-api/src/index.ts index 9fead85fe8..869cd64968 100644 --- a/packages/backend-app-api/src/index.ts +++ b/packages/backend-app-api/src/index.ts @@ -20,7 +20,6 @@ * @packageDocumentation */ -export * from './config'; export * from './logging'; export * from './wiring'; export * from './services/implementations'; diff --git a/packages/backend-common/api-report.md b/packages/backend-common/api-report.md index e63ff83318..32fdf769c7 100644 --- a/packages/backend-common/api-report.md +++ b/packages/backend-common/api-report.md @@ -21,6 +21,7 @@ import { CacheService } from '@backstage/backend-plugin-api'; import { CacheServiceOptions } from '@backstage/backend-plugin-api'; import { CacheServiceSetOptions } from '@backstage/backend-plugin-api'; import { Config } from '@backstage/config'; +import { ConfigSchema } from '@backstage/config-loader'; import cors from 'cors'; import { DatabaseService } from '@backstage/backend-plugin-api'; import { DiscoveryService } from '@backstage/backend-plugin-api'; @@ -133,6 +134,11 @@ export interface ContainerRunner { runContainer(opts: RunContainerOptions): Promise; } +// Warning: (ae-forgotten-export) The symbol "createConfigSecretEnumerator_2" needs to be exported by the entry point index.d.ts +// +// @public @deprecated (undocumented) +export const createConfigSecretEnumerator: typeof createConfigSecretEnumerator_2; + // @public @deprecated export function createLegacyAuthAdapters< TOptions extends { diff --git a/packages/backend-common/src/deprecated/config.ts b/packages/backend-common/src/deprecated/config.ts deleted file mode 100644 index 2d06ca2072..0000000000 --- a/packages/backend-common/src/deprecated/config.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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. - */ - -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { - createConfigSecretEnumerator, - loadBackendConfig as newLoadBackendConfig, -} from '../../../backend-app-api/src/config'; -import { LoggerService } from '@backstage/backend-plugin-api'; -import { AppConfig, Config } from '@backstage/config'; -import { LoadConfigOptionsRemote } from '@backstage/config-loader'; -import { setRootLoggerRedactionList } from './logging/createRootLogger'; - -/** - * Load configuration for a Backend. - * - * This function should only be called once, during the initialization of the backend. - * - * @public - * @deprecated Use {@link @backstage/backend-app-api#loadBackendConfig} instead. - */ -export async function loadBackendConfig(options: { - logger: LoggerService; - // process.argv or any other overrides - remote?: LoadConfigOptionsRemote; - additionalConfigs?: AppConfig[]; - argv: string[]; - watch?: boolean; -}): Promise { - const secretEnumerator = await createConfigSecretEnumerator({ - logger: options.logger, - }); - const { config } = await newLoadBackendConfig(options); - - setRootLoggerRedactionList(secretEnumerator(config)); - config.subscribe?.(() => - setRootLoggerRedactionList(secretEnumerator(config)), - ); - - return config; -} diff --git a/packages/backend-app-api/src/config/ObservableConfigProxy.test.ts b/packages/backend-common/src/deprecated/config/ObservableConfigProxy.test.ts similarity index 100% rename from packages/backend-app-api/src/config/ObservableConfigProxy.test.ts rename to packages/backend-common/src/deprecated/config/ObservableConfigProxy.test.ts diff --git a/packages/backend-app-api/src/config/ObservableConfigProxy.ts b/packages/backend-common/src/deprecated/config/ObservableConfigProxy.ts similarity index 100% rename from packages/backend-app-api/src/config/ObservableConfigProxy.ts rename to packages/backend-common/src/deprecated/config/ObservableConfigProxy.ts diff --git a/packages/backend-app-api/src/config/config.test.ts b/packages/backend-common/src/deprecated/config/config.test.ts similarity index 100% rename from packages/backend-app-api/src/config/config.test.ts rename to packages/backend-common/src/deprecated/config/config.test.ts index 8828c557e0..865b1b4d60 100644 --- a/packages/backend-app-api/src/config/config.test.ts +++ b/packages/backend-common/src/deprecated/config/config.test.ts @@ -15,8 +15,8 @@ */ import { loadConfigSchema } from '@backstage/config-loader'; -import { createConfigSecretEnumerator } from './config'; import { mockServices } from '@backstage/backend-test-utils'; +import { createConfigSecretEnumerator } from './config'; describe('createConfigSecretEnumerator', () => { it('should enumerate secrets', async () => { diff --git a/packages/backend-app-api/src/config/config.ts b/packages/backend-common/src/deprecated/config/config.ts similarity index 76% rename from packages/backend-app-api/src/config/config.ts rename to packages/backend-common/src/deprecated/config/config.ts index 957997849e..d50476a9f2 100644 --- a/packages/backend-app-api/src/config/config.ts +++ b/packages/backend-common/src/deprecated/config/config.ts @@ -14,8 +14,11 @@ * limitations under the License. */ +import { LoggerService } from '@backstage/backend-plugin-api'; +import { AppConfig, Config } from '@backstage/config'; +import { setRootLoggerRedactionList } from '../logging/createRootLogger'; // eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { createConfigSecretEnumerator as _createConfigSecretEnumerator } from '../../../backend-defaults/src/entrypoints/rootConfig/createConfigSecretEnumerator'; +import { createConfigSecretEnumerator as _createConfigSecretEnumerator } from '../../../../backend-defaults/src/entrypoints/rootConfig/createConfigSecretEnumerator'; import { resolve as resolvePath } from 'path'; import parseArgs from 'minimist'; @@ -26,13 +29,12 @@ import { LoadConfigOptionsRemote, } from '@backstage/config-loader'; import { ConfigReader } from '@backstage/config'; -import type { Config, AppConfig } from '@backstage/config'; import { ObservableConfigProxy } from './ObservableConfigProxy'; -import { isValidUrl } from '../lib/urls'; +import { isValidUrl } from './urls'; /** * @public - * @deprecated Please import from `@backstage/backend-defaults/rootConfig` instead. + * @deprecated Please migrate to the new backend system and use `coreServices.rootConfig` instead, or the {@link @backstage/config-loader#ConfigSources} facilities if required. */ export const createConfigSecretEnumerator = _createConfigSecretEnumerator; @@ -45,6 +47,27 @@ export const createConfigSecretEnumerator = _createConfigSecretEnumerator; * @deprecated Please migrate to the new backend system and use `coreServices.rootConfig` instead, or the {@link @backstage/config-loader#ConfigSources} facilities if required. */ export async function loadBackendConfig(options: { + logger: LoggerService; + // process.argv or any other overrides + remote?: LoadConfigOptionsRemote; + additionalConfigs?: AppConfig[]; + argv: string[]; + watch?: boolean; +}): Promise { + const secretEnumerator = await createConfigSecretEnumerator({ + logger: options.logger, + }); + const { config } = await newLoadBackendConfig(options); + + setRootLoggerRedactionList(secretEnumerator(config)); + config.subscribe?.(() => + setRootLoggerRedactionList(secretEnumerator(config)), + ); + + return config; +} + +async function newLoadBackendConfig(options: { remote?: LoadConfigOptionsRemote; argv: string[]; additionalConfigs?: AppConfig[]; diff --git a/packages/backend-app-api/src/config/index.ts b/packages/backend-common/src/deprecated/config/index.ts similarity index 94% rename from packages/backend-app-api/src/config/index.ts rename to packages/backend-common/src/deprecated/config/index.ts index 0ed8d2bc93..c87193876c 100644 --- a/packages/backend-app-api/src/config/index.ts +++ b/packages/backend-common/src/deprecated/config/index.ts @@ -1,5 +1,5 @@ /* - * Copyright 2023 The Backstage Authors + * Copyright 2024 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. diff --git a/packages/backend-app-api/src/lib/urls.test.ts b/packages/backend-common/src/deprecated/config/urls.test.ts similarity index 100% rename from packages/backend-app-api/src/lib/urls.test.ts rename to packages/backend-common/src/deprecated/config/urls.test.ts diff --git a/packages/backend-app-api/src/lib/urls.ts b/packages/backend-common/src/deprecated/config/urls.ts similarity index 100% rename from packages/backend-app-api/src/lib/urls.ts rename to packages/backend-common/src/deprecated/config/urls.ts diff --git a/packages/backend-dynamic-feature-service/src/schemas/rootLoggerServiceFactory.ts b/packages/backend-dynamic-feature-service/src/schemas/rootLoggerServiceFactory.ts index 6681a65a75..bf37ac4a32 100644 --- a/packages/backend-dynamic-feature-service/src/schemas/rootLoggerServiceFactory.ts +++ b/packages/backend-dynamic-feature-service/src/schemas/rootLoggerServiceFactory.ts @@ -20,7 +20,7 @@ import { } from '@backstage/backend-plugin-api'; import { WinstonLogger } from '@backstage/backend-app-api'; import { transports, format } from 'winston'; -import { createConfigSecretEnumerator } from '@backstage/backend-app-api'; +import { createConfigSecretEnumerator } from '@backstage/backend-common'; import { loadConfigSchema } from '@backstage/config-loader'; import { getPackages } from '@manypkg/get-packages'; import { dynamicPluginsSchemasServiceRef } from './schemas'; From 87cd3d0b9ec6d4ef8ea3797d7e0a8d237334c0cb Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Wed, 14 Aug 2024 13:41:17 +0200 Subject: [PATCH 276/372] backend-defaults: Added deprecation warning for the dangerouslyDisableDefaultAuthPolicy config option Co-authored-by: Camila Belo Signed-off-by: Johan Haals --- docs/tutorials/auth-service-migration.md | 2 ++ .../src/entrypoints/auth/DefaultAuthService.ts | 5 +++++ .../src/entrypoints/auth/authServiceFactory.ts | 1 + 3 files changed, 8 insertions(+) diff --git a/docs/tutorials/auth-service-migration.md b/docs/tutorials/auth-service-migration.md index 9e2633a12a..d12b0d5906 100644 --- a/docs/tutorials/auth-service-migration.md +++ b/docs/tutorials/auth-service-migration.md @@ -24,6 +24,8 @@ backend: dangerouslyDisableDefaultAuthPolicy: true ``` +Please note that this functionality will be removed in a future release, and you should migrate to using the new auth services as soon as possible or you would have to support your own service for issuing tokens. + In short, this will allow requests through to plugins in your backend, even if they do not include any credentials. The requests will still be treated as unauthenticated however, which not all plugin endpoints may accept. For more information on the impact of this configuration, see the [auth service documentation](../backend-system/core-services/auth.md). ### Migrating the backend diff --git a/packages/backend-defaults/src/entrypoints/auth/DefaultAuthService.ts b/packages/backend-defaults/src/entrypoints/auth/DefaultAuthService.ts index 159da79435..1b2077e9a8 100644 --- a/packages/backend-defaults/src/entrypoints/auth/DefaultAuthService.ts +++ b/packages/backend-defaults/src/entrypoints/auth/DefaultAuthService.ts @@ -22,6 +22,7 @@ import { BackstagePrincipalTypes, BackstageServicePrincipal, BackstageUserPrincipal, + LoggerService, } from '@backstage/backend-plugin-api'; import { AuthenticationError, ForwardedError } from '@backstage/errors'; import { JsonObject } from '@backstage/types'; @@ -47,6 +48,7 @@ export class DefaultAuthService implements AuthService { private readonly pluginId: string, private readonly disableDefaultAuthPolicy: boolean, private readonly pluginKeySource: PluginKeySource, + private readonly logger: LoggerService, ) {} async authenticate( @@ -166,6 +168,9 @@ export class DefaultAuthService implements AuthService { }); } // If the target plugin does not support the new auth service, fall back to using old token format + this.logger.warn( + 'tokenManager is DEPRECATED, please migrate to the new auth service, see https://backstage.io/docs/tutorials/auth-service-migration for more information', + ); return this.tokenManager.getToken().catch(error => { throw new ForwardedError( `Unable to generate legacy token for communication with the '${targetPluginId}' plugin. ` + diff --git a/packages/backend-defaults/src/entrypoints/auth/authServiceFactory.ts b/packages/backend-defaults/src/entrypoints/auth/authServiceFactory.ts index e275e2be00..b66ba7227f 100644 --- a/packages/backend-defaults/src/entrypoints/auth/authServiceFactory.ts +++ b/packages/backend-defaults/src/entrypoints/auth/authServiceFactory.ts @@ -88,6 +88,7 @@ export const authServiceFactory = createServiceFactory({ plugin.getId(), disableDefaultAuthPolicy, keySource, + logger, ); }, }); From 70e14b8ed21bff553ec6fadb9497d03cafecd114 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Wed, 14 Aug 2024 13:52:45 +0200 Subject: [PATCH 277/372] backend-defaults: Stop accepting callback BackendFeatures for `backend.add` Co-authored-by: Camila Belo Signed-off-by: Johan Haals --- packages/backend-app-api/api-report.md | 8 ------- .../src/wiring/BackstageBackend.ts | 21 +++---------------- packages/backend-app-api/src/wiring/types.ts | 12 ----------- 3 files changed, 3 insertions(+), 38 deletions(-) diff --git a/packages/backend-app-api/api-report.md b/packages/backend-app-api/api-report.md index bec20dff16..46d7d9615f 100644 --- a/packages/backend-app-api/api-report.md +++ b/packages/backend-app-api/api-report.md @@ -24,14 +24,6 @@ export interface Backend { default: BackendFeature; }>, ): void; - // @deprecated (undocumented) - add( - feature: - | (() => BackendFeature) - | Promise<{ - default: () => BackendFeature; - }>, - ): void; // (undocumented) start(): Promise; // (undocumented) diff --git a/packages/backend-app-api/src/wiring/BackstageBackend.ts b/packages/backend-app-api/src/wiring/BackstageBackend.ts index 0dd3ba4423..9df7549bcb 100644 --- a/packages/backend-app-api/src/wiring/BackstageBackend.ts +++ b/packages/backend-app-api/src/wiring/BackstageBackend.ts @@ -25,12 +25,7 @@ export class BackstageBackend implements Backend { this.#initializer = new BackendInitializer(defaultServiceFactories); } - add( - feature: - | BackendFeature - | (() => BackendFeature) - | Promise<{ default: BackendFeature | (() => BackendFeature) }>, - ): void { + add(feature: BackendFeature | Promise<{ default: BackendFeature }>): void { if (isPromise(feature)) { this.#initializer.add(feature.then(f => unwrapFeature(f.default))); } else { @@ -57,15 +52,8 @@ function isPromise(value: unknown | Promise): value is Promise { } function unwrapFeature( - feature: - | BackendFeature - | (() => BackendFeature) - | { default: BackendFeature | (() => BackendFeature) }, + feature: BackendFeature | { default: BackendFeature }, ): BackendFeature { - if (typeof feature === 'function') { - return feature(); - } - if ('$$type' in feature) { return feature; } @@ -75,10 +63,7 @@ function unwrapFeature( // when importing using a dynamic import. // TODO: This is a broader issue than just this piece of code, and should move away from CommonJS. if ('default' in feature) { - const defaultFeature = feature.default; - return typeof defaultFeature === 'function' - ? defaultFeature() - : defaultFeature; + return feature.default; } return feature; diff --git a/packages/backend-app-api/src/wiring/types.ts b/packages/backend-app-api/src/wiring/types.ts index 075eb58b3f..bd761ff3c8 100644 --- a/packages/backend-app-api/src/wiring/types.ts +++ b/packages/backend-app-api/src/wiring/types.ts @@ -26,18 +26,6 @@ import { */ export interface Backend { add(feature: BackendFeature | Promise<{ default: BackendFeature }>): void; - /** - * @deprecated The ability to add features defined as a callback is being - * removed. Please update the installed feature to no longer be defined as a - * callback, typically this means updating it to use the latest version of - * `@backstage/backend-plugin-api`. If the feature is from a third-party - * package, please reach out to the package maintainer to update it. - */ - add( - feature: - | (() => BackendFeature) - | Promise<{ default: () => BackendFeature }>, - ): void; start(): Promise; stop(): Promise; } From 070828a4f40fb03c779ed1f4de41115df151bd77 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Wed, 14 Aug 2024 14:07:29 +0200 Subject: [PATCH 278/372] backend-defaults: remove unused dependencies Co-authored-by: Camila Belo Signed-off-by: Johan Haals --- packages/backend-app-api/package.json | 2 -- yarn.lock | 2 -- 2 files changed, 4 deletions(-) diff --git a/packages/backend-app-api/package.json b/packages/backend-app-api/package.json index 76261adcd2..588a969390 100644 --- a/packages/backend-app-api/package.json +++ b/packages/backend-app-api/package.json @@ -62,8 +62,6 @@ "@backstage/plugin-permission-node": "workspace:^", "@backstage/types": "workspace:^", "@manypkg/get-packages": "^1.1.3", - "@types/cors": "^2.8.6", - "@types/express": "^4.17.6", "compression": "^1.7.4", "cookie": "^0.6.0", "cors": "^2.8.5", diff --git a/yarn.lock b/yarn.lock index e34246fd58..edab1f5580 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3478,8 +3478,6 @@ __metadata: "@backstage/types": "workspace:^" "@manypkg/get-packages": ^1.1.3 "@types/compression": ^1.7.0 - "@types/cors": ^2.8.6 - "@types/express": ^4.17.6 "@types/fs-extra": ^11.0.0 "@types/http-errors": ^2.0.0 "@types/minimist": ^1.2.0 From 5cee28573e9112b1d2b33b117dab5b855a64eb8e Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Wed, 14 Aug 2024 14:11:05 +0200 Subject: [PATCH 279/372] Delete WinstonLogger from backend-defaults, instead import from backend-defaults Co-authored-by: Camila Belo Signed-off-by: Johan Haals --- packages/backend-app-api/api-report.md | 32 ------- packages/backend-app-api/src/index.ts | 1 - .../src/logging/WinstonLogger.ts | 92 ------------------- packages/backend-app-api/src/logging/index.ts | 18 ---- .../deprecated/logging/createRootLogger.ts | 2 +- .../package.json | 31 +++---- .../src/schemas/rootLoggerServiceFactory.ts | 2 +- 7 files changed, 16 insertions(+), 162 deletions(-) delete mode 100644 packages/backend-app-api/src/logging/WinstonLogger.ts delete mode 100644 packages/backend-app-api/src/logging/index.ts diff --git a/packages/backend-app-api/api-report.md b/packages/backend-app-api/api-report.md index 46d7d9615f..c7b47cb1a0 100644 --- a/packages/backend-app-api/api-report.md +++ b/packages/backend-app-api/api-report.md @@ -4,15 +4,10 @@ ```ts import { BackendFeature } from '@backstage/backend-plugin-api'; -import { Format } from 'logform'; import { IdentityService } from '@backstage/backend-plugin-api'; -import { JsonObject } from '@backstage/types'; -import { LoggerService } from '@backstage/backend-plugin-api'; -import { RootLoggerService } from '@backstage/backend-plugin-api'; import { ServiceFactory } from '@backstage/backend-plugin-api'; import { ServiceFactoryCompat } from '@backstage/backend-plugin-api'; import { TokenManagerService } from '@backstage/backend-plugin-api'; -import { transport } from 'winston'; // @public (undocumented) export interface Backend { @@ -62,31 +57,4 @@ export const tokenManagerServiceFactory: ServiceFactoryCompat< 'singleton', undefined >; - -// @public @deprecated -export class WinstonLogger implements RootLoggerService { - // (undocumented) - addRedactions(redactions: Iterable): void; - // (undocumented) - child(meta: JsonObject): LoggerService; - static colorFormat(): Format; - static create(options: WinstonLoggerOptions): WinstonLogger; - // (undocumented) - debug(message: string, meta?: JsonObject): void; - // (undocumented) - error(message: string, meta?: JsonObject): void; - // (undocumented) - info(message: string, meta?: JsonObject): void; - static redacter(): { - format: Format; - add: (redactions: Iterable) => void; - }; - // (undocumented) - warn(message: string, meta?: JsonObject): void; -} - -// Warning: (ae-forgotten-export) The symbol "WinstonLoggerOptions_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export type WinstonLoggerOptions = WinstonLoggerOptions_2; ``` diff --git a/packages/backend-app-api/src/index.ts b/packages/backend-app-api/src/index.ts index 869cd64968..02633f3732 100644 --- a/packages/backend-app-api/src/index.ts +++ b/packages/backend-app-api/src/index.ts @@ -20,6 +20,5 @@ * @packageDocumentation */ -export * from './logging'; export * from './wiring'; export * from './services/implementations'; diff --git a/packages/backend-app-api/src/logging/WinstonLogger.ts b/packages/backend-app-api/src/logging/WinstonLogger.ts deleted file mode 100644 index e5403906ce..0000000000 --- a/packages/backend-app-api/src/logging/WinstonLogger.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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. - */ - -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { - WinstonLogger as _WinstonLogger, - type WinstonLoggerOptions as _WinstonLoggerOptions, -} from '../../../backend-defaults/src/entrypoints/rootLogger'; - -import { - LoggerService, - RootLoggerService, -} from '@backstage/backend-plugin-api'; -import { JsonObject } from '@backstage/types'; -import { Format } from 'logform'; - -/** - * @public - * @deprecated Please import from `@backstage/backend-defaults/rootLogger` instead. - */ -export type WinstonLoggerOptions = _WinstonLoggerOptions; - -/** - * A {@link @backstage/backend-plugin-api#LoggerService} implementation based on winston. - * - * @public - * @deprecated Please import from `@backstage/backend-defaults/rootLogger` instead. - */ -export class WinstonLogger implements RootLoggerService { - /** - * Creates a {@link WinstonLogger} instance. - */ - static create(options: WinstonLoggerOptions): WinstonLogger { - return new WinstonLogger(_WinstonLogger.create(options)); - } - - /** - * Creates a winston log formatter for redacting secrets. - */ - static redacter(): { - format: Format; - add: (redactions: Iterable) => void; - } { - return _WinstonLogger.redacter(); - } - - /** - * Creates a pretty printed winston log formatter. - */ - static colorFormat(): Format { - return _WinstonLogger.colorFormat(); - } - - private constructor(private readonly impl: _WinstonLogger) {} - - error(message: string, meta?: JsonObject): void { - this.impl.error(message, meta); - } - - warn(message: string, meta?: JsonObject): void { - this.impl.warn(message, meta); - } - - info(message: string, meta?: JsonObject): void { - this.impl.info(message, meta); - } - - debug(message: string, meta?: JsonObject): void { - this.impl.debug(message, meta); - } - - child(meta: JsonObject): LoggerService { - return this.impl.child(meta); - } - - addRedactions(redactions: Iterable) { - this.impl.addRedactions(redactions); - } -} diff --git a/packages/backend-app-api/src/logging/index.ts b/packages/backend-app-api/src/logging/index.ts deleted file mode 100644 index 14fe33f898..0000000000 --- a/packages/backend-app-api/src/logging/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * 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 { WinstonLogger } from './WinstonLogger'; -export type { WinstonLoggerOptions } from './WinstonLogger'; diff --git a/packages/backend-common/src/deprecated/logging/createRootLogger.ts b/packages/backend-common/src/deprecated/logging/createRootLogger.ts index b177024601..04b3799381 100644 --- a/packages/backend-common/src/deprecated/logging/createRootLogger.ts +++ b/packages/backend-common/src/deprecated/logging/createRootLogger.ts @@ -15,7 +15,7 @@ */ // eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { WinstonLogger } from '../../../../backend-app-api/src/logging/WinstonLogger'; +import { WinstonLogger } from '../../../../backend-defaults/src/entrypoints/rootLogger/WinstonLogger'; import { merge } from 'lodash'; import * as winston from 'winston'; import { format, LoggerOptions } from 'winston'; diff --git a/packages/backend-dynamic-feature-service/package.json b/packages/backend-dynamic-feature-service/package.json index f4a3237762..a4a4a1cdb5 100644 --- a/packages/backend-dynamic-feature-service/package.json +++ b/packages/backend-dynamic-feature-service/package.json @@ -7,14 +7,16 @@ "publishConfig": { "access": "public" }, + "keywords": [ + "backstage" + ], + "homepage": "https://backstage.io", "repository": { "type": "git", "url": "https://github.com/backstage/backstage", "directory": "packages/backend-dynamic-feature-service" }, - "backstage": { - "role": "node-library" - }, + "license": "Apache-2.0", "exports": { ".": "./src/index.ts", "./package.json": "./package.json" @@ -26,23 +28,23 @@ ] } }, - "homepage": "https://backstage.io", - "keywords": [ - "backstage" + "files": [ + "dist", + "config.d.ts" ], - "license": "Apache-2.0", "scripts": { "build": "backstage-cli package build", + "clean": "backstage-cli package clean", "lint": "backstage-cli package lint", - "test": "backstage-cli package test", "prepack": "backstage-cli package prepack", "postpack": "backstage-cli package postpack", - "clean": "backstage-cli package clean", - "start": "backstage-cli package start" + "start": "backstage-cli package start", + "test": "backstage-cli package test" }, "dependencies": { "@backstage/backend-app-api": "workspace:^", "@backstage/backend-common": "workspace:^", + "@backstage/backend-defaults": "workspace:^", "@backstage/backend-plugin-api": "workspace:^", "@backstage/backend-tasks": "workspace:^", "@backstage/cli-common": "workspace:^", @@ -70,13 +72,8 @@ "winston": "^3.2.1" }, "devDependencies": { - "@backstage/backend-defaults": "workspace:^", "@backstage/backend-test-utils": "workspace:^", "@backstage/cli": "workspace:^", "wait-for-expect": "^3.0.2" - }, - "files": [ - "dist", - "config.d.ts" - ] -} + } +} \ No newline at end of file diff --git a/packages/backend-dynamic-feature-service/src/schemas/rootLoggerServiceFactory.ts b/packages/backend-dynamic-feature-service/src/schemas/rootLoggerServiceFactory.ts index bf37ac4a32..00d5c85e6e 100644 --- a/packages/backend-dynamic-feature-service/src/schemas/rootLoggerServiceFactory.ts +++ b/packages/backend-dynamic-feature-service/src/schemas/rootLoggerServiceFactory.ts @@ -18,7 +18,7 @@ import { createServiceFactory, coreServices, } from '@backstage/backend-plugin-api'; -import { WinstonLogger } from '@backstage/backend-app-api'; +import { WinstonLogger } from '@backstage/backend-defaults/rootLogger'; import { transports, format } from 'winston'; import { createConfigSecretEnumerator } from '@backstage/backend-common'; import { loadConfigSchema } from '@backstage/config-loader'; From da4fde5cc241ee7833b5450d9bde31bd4397fd73 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Wed, 14 Aug 2024 14:26:43 +0200 Subject: [PATCH 280/372] backend-app-api: Add changeset Co-authored-by: Camila Belo Signed-off-by: Johan Haals --- .changeset/brown-mails-drum.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/brown-mails-drum.md diff --git a/.changeset/brown-mails-drum.md b/.changeset/brown-mails-drum.md new file mode 100644 index 0000000000..0c87a5cbaf --- /dev/null +++ b/.changeset/brown-mails-drum.md @@ -0,0 +1,5 @@ +--- +'@backstage/backend-app-api': minor +--- + +Removed several deprecated service factories. These can instead be imported from `@backstage/backend-defaults` package. From bfdfac62305473373e87582d84655841b6c1c6d3 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Wed, 14 Aug 2024 14:26:53 +0200 Subject: [PATCH 281/372] Revert "refactor: remove deprecated url reader service types" This reverts commit c32b5f3467cf6d0bcd355fde0fb0e4bce77f1b38. Signed-off-by: Johan Haals --- packages/backend-common/api-report.md | 36 +++++++++++ .../backend-common/src/deprecated/index.ts | 63 +++++++++++++++++++ packages/backend-plugin-api/api-report.md | 28 +++++++++ .../services/definitions/UrlReaderService.ts | 47 ++++++++++++++ .../src/services/definitions/index.ts | 9 +++ plugins/search-backend-node/api-report.md | 4 +- plugins/search-backend-node/package.json | 3 +- ...ewlineDelimitedJsonCollatorFactory.test.ts | 14 ++--- .../NewlineDelimitedJsonCollatorFactory.ts | 7 ++- plugins/techdocs-node/src/helpers.test.ts | 24 +++---- yarn.lock | 2 +- 11 files changed, 210 insertions(+), 27 deletions(-) diff --git a/packages/backend-common/api-report.md b/packages/backend-common/api-report.md index 32fdf769c7..11a5befad4 100644 --- a/packages/backend-common/api-report.md +++ b/packages/backend-common/api-report.md @@ -49,12 +49,21 @@ import { PluginMetadataService } from '@backstage/backend-plugin-api'; import { PushResult } from 'isomorphic-git'; import { Readable } from 'stream'; import { ReadCommitResult } from 'isomorphic-git'; +import { ReadTreeOptions as ReadTreeOptions_2 } from '@backstage/backend-plugin-api'; +import { ReadTreeResponse as ReadTreeResponse_2 } from '@backstage/backend-plugin-api'; +import { ReadTreeResponseDirOptions as ReadTreeResponseDirOptions_2 } from '@backstage/backend-plugin-api'; +import { ReadTreeResponseFile as ReadTreeResponseFile_2 } from '@backstage/backend-plugin-api'; +import { ReadUrlOptions as ReadUrlOptions_2 } from '@backstage/backend-plugin-api'; +import { ReadUrlResponse as ReadUrlResponse_2 } from '@backstage/backend-plugin-api'; import { RequestHandler } from 'express'; import { resolvePackagePath as resolvePackagePath_2 } from '@backstage/backend-plugin-api'; import { resolveSafeChildPath as resolveSafeChildPath_2 } from '@backstage/backend-plugin-api'; import { RootConfigService } from '@backstage/backend-plugin-api'; import { Router } from 'express'; import { SchedulerService } from '@backstage/backend-plugin-api'; +import { SearchOptions as SearchOptions_2 } from '@backstage/backend-plugin-api'; +import { SearchResponse as SearchResponse_2 } from '@backstage/backend-plugin-api'; +import { SearchResponseFile as SearchResponseFile_2 } from '@backstage/backend-plugin-api'; import { Server } from 'http'; import { ServiceRef } from '@backstage/backend-plugin-api'; import { TokenManagerService } from '@backstage/backend-plugin-api'; @@ -502,6 +511,15 @@ export interface PullOptions { // @public @deprecated (undocumented) export type ReaderFactory = ReaderFactory_2; +// @public @deprecated (undocumented) +export type ReadTreeOptions = ReadTreeOptions_2; + +// @public @deprecated (undocumented) +export type ReadTreeResponse = ReadTreeResponse_2; + +// @public @deprecated (undocumented) +export type ReadTreeResponseDirOptions = ReadTreeResponseDirOptions_2; + // Warning: (ae-forgotten-export) The symbol "ReadTreeResponseFactory_2" needs to be exported by the entry point index.d.ts // // @public @deprecated (undocumented) @@ -512,6 +530,15 @@ export type ReadTreeResponseFactory = ReadTreeResponseFactory_2; // @public @deprecated (undocumented) export type ReadTreeResponseFactoryOptions = ReadTreeResponseFactoryOptions_2; +// @public @deprecated (undocumented) +export type ReadTreeResponseFile = ReadTreeResponseFile_2; + +// @public @deprecated (undocumented) +export type ReadUrlOptions = ReadUrlOptions_2; + +// @public @deprecated (undocumented) +export type ReadUrlResponse = ReadUrlResponse_2; + // Warning: (ae-forgotten-export) The symbol "ReadUrlResponseFactory_2" needs to be exported by the entry point index.d.ts // // @public @deprecated (undocumented) @@ -556,6 +583,15 @@ export type RunContainerOptions = { pullOptions?: PullOptions; }; +// @public @deprecated (undocumented) +export type SearchOptions = SearchOptions_2; + +// @public @deprecated (undocumented) +export type SearchResponse = SearchResponse_2; + +// @public @deprecated (undocumented) +export type SearchResponseFile = SearchResponseFile_2; + // @public @deprecated export class ServerTokenManager implements TokenManager { // (undocumented) diff --git a/packages/backend-common/src/deprecated/index.ts b/packages/backend-common/src/deprecated/index.ts index 8c37017eb7..e3e4101d25 100644 --- a/packages/backend-common/src/deprecated/index.ts +++ b/packages/backend-common/src/deprecated/index.ts @@ -85,6 +85,15 @@ import { resolvePackagePath as _resolvePackagePath, resolveSafeChildPath as _resolveSafeChildPath, isChildPath as _isChildPath, + ReadTreeOptions as _ReadTreeOptions, + ReadTreeResponse as _ReadTreeResponse, + ReadTreeResponseFile as _ReadTreeResponseFile, + ReadTreeResponseDirOptions as _ReadTreeResponseDirOptions, + ReadUrlOptions as _ReadUrlOptions, + ReadUrlResponse as _ReadUrlResponse, + SearchOptions as _SearchOptions, + SearchResponse as _SearchResponse, + SearchResponseFile as _SearchResponseFile, UrlReaderService as _UrlReaderService, LifecycleService, PluginMetadataService, @@ -403,6 +412,60 @@ export type ReadUrlResponseFactoryFromStreamOptions = */ export type UrlReaderPredicateTuple = _UrlReaderPredicateTuple; +/** + * @public + * @deprecated Use `UrlReaderServiceReadTreeOptions` from `@backstage/backend-plugin-api` instead + */ +export type ReadTreeOptions = _ReadTreeOptions; + +/** + * @public + * @deprecated Use `UrlReaderServiceReadTreeResponse` from `@backstage/backend-plugin-api` instead + */ +export type ReadTreeResponse = _ReadTreeResponse; + +/** + * @public + * @deprecated Use `UrlReaderServiceReadTreeResponseFile` from `@backstage/backend-plugin-api` instead + */ +export type ReadTreeResponseFile = _ReadTreeResponseFile; + +/** + * @public + * @deprecated Use `UrlReaderServiceReadTreeResponseDirOptions` from `@backstage/backend-plugin-api` instead + */ +export type ReadTreeResponseDirOptions = _ReadTreeResponseDirOptions; + +/** + * @public + * @deprecated Use `UrlReaderServiceReadUrlOptions` from `@backstage/backend-plugin-api` instead + */ +export type ReadUrlOptions = _ReadUrlOptions; + +/** + * @public + * @deprecated Use `UrlReaderServiceReadUrlResponse` from `@backstage/backend-plugin-api` instead + */ +export type ReadUrlResponse = _ReadUrlResponse; + +/** + * @public + * @deprecated Use `UrlReaderServiceSearchOptions` from `@backstage/backend-plugin-api` instead + */ +export type SearchOptions = _SearchOptions; + +/** + * @public + * @deprecated Use `UrlReaderServiceSearchResponse` from `@backstage/backend-plugin-api` instead + */ +export type SearchResponse = _SearchResponse; + +/** + * @public + * @deprecated Use `UrlReaderServiceSearchResponseFile` from `@backstage/backend-plugin-api` instead + */ +export type SearchResponseFile = _SearchResponseFile; + /** * @public * @deprecated Use `UrlReaderService` from `@backstage/backend-plugin-api` instead diff --git a/packages/backend-plugin-api/api-report.md b/packages/backend-plugin-api/api-report.md index 0864064625..319ddf0bc6 100644 --- a/packages/backend-plugin-api/api-report.md +++ b/packages/backend-plugin-api/api-report.md @@ -553,6 +553,25 @@ export function readSchedulerServiceTaskScheduleDefinitionFromConfig( config: Config, ): SchedulerServiceTaskScheduleDefinition; +// @public @deprecated (undocumented) +export type ReadTreeOptions = UrlReaderServiceReadTreeOptions; + +// @public @deprecated (undocumented) +export type ReadTreeResponse = UrlReaderServiceReadTreeResponse; + +// @public @deprecated (undocumented) +export type ReadTreeResponseDirOptions = + UrlReaderServiceReadTreeResponseDirOptions; + +// @public @deprecated (undocumented) +export type ReadTreeResponseFile = UrlReaderServiceReadTreeResponseFile; + +// @public @deprecated (undocumented) +export type ReadUrlOptions = UrlReaderServiceReadUrlOptions; + +// @public @deprecated (undocumented) +export type ReadUrlResponse = UrlReaderServiceReadUrlResponse; + // @public export function resolvePackagePath(name: string, ...paths: string[]): string; @@ -688,6 +707,15 @@ export interface SchedulerServiceTaskScheduleDefinitionConfig { timeout: string | HumanDuration; } +// @public @deprecated (undocumented) +export type SearchOptions = UrlReaderServiceSearchOptions; + +// @public @deprecated (undocumented) +export type SearchResponse = UrlReaderServiceSearchResponse; + +// @public @deprecated (undocumented) +export type SearchResponseFile = UrlReaderServiceSearchResponseFile; + // @public (undocumented) export interface ServiceFactory< TService = unknown, diff --git a/packages/backend-plugin-api/src/services/definitions/UrlReaderService.ts b/packages/backend-plugin-api/src/services/definitions/UrlReaderService.ts index 9b327cfbf0..25b787107e 100644 --- a/packages/backend-plugin-api/src/services/definitions/UrlReaderService.ts +++ b/packages/backend-plugin-api/src/services/definitions/UrlReaderService.ts @@ -368,3 +368,50 @@ export type UrlReaderServiceSearchResponseFile = { */ lastModifiedAt?: Date; }; + +/** + * @public + * @deprecated Use `UrlReaderServiceReadTreeOptions` instead + */ +export type ReadTreeOptions = UrlReaderServiceReadTreeOptions; +/** + * @public + * @deprecated Use `UrlReaderServiceReadTreeResponse` instead + */ +export type ReadTreeResponse = UrlReaderServiceReadTreeResponse; +/** + * @public + * @deprecated Use `UrlReaderServiceReadTreeResponseDirOptions` instead + */ +export type ReadTreeResponseDirOptions = + UrlReaderServiceReadTreeResponseDirOptions; +/** + * @public + * @deprecated Use `UrlReaderServiceReadTreeResponseFile` instead + */ +export type ReadTreeResponseFile = UrlReaderServiceReadTreeResponseFile; +/** + * @public + * @deprecated Use `UrlReaderServiceReadUrlResponse` instead + */ +export type ReadUrlResponse = UrlReaderServiceReadUrlResponse; +/** + * @public + * @deprecated Use `UrlReaderServiceReadUrlOptions` instead + */ +export type ReadUrlOptions = UrlReaderServiceReadUrlOptions; +/** + * @public + * @deprecated Use `UrlReaderServiceSearchOptions` instead + */ +export type SearchOptions = UrlReaderServiceSearchOptions; +/** + * @public + * @deprecated Use `UrlReaderServiceSearchResponse` instead + */ +export type SearchResponse = UrlReaderServiceSearchResponse; +/** + * @public + * @deprecated Use `UrlReaderServiceSearchResponseFile` instead + */ +export type SearchResponseFile = UrlReaderServiceSearchResponseFile; diff --git a/packages/backend-plugin-api/src/services/definitions/index.ts b/packages/backend-plugin-api/src/services/definitions/index.ts index 194658dc0e..5e30d444fd 100644 --- a/packages/backend-plugin-api/src/services/definitions/index.ts +++ b/packages/backend-plugin-api/src/services/definitions/index.ts @@ -66,6 +66,15 @@ export type { } from './SchedulerService'; export type { TokenManagerService } from './TokenManagerService'; export type { + ReadTreeOptions, + ReadTreeResponse, + ReadTreeResponseDirOptions, + ReadTreeResponseFile, + ReadUrlResponse, + ReadUrlOptions, + SearchOptions, + SearchResponse, + SearchResponseFile, UrlReaderServiceReadTreeOptions, UrlReaderServiceReadTreeResponse, UrlReaderServiceReadTreeResponseDirOptions, diff --git a/plugins/search-backend-node/api-report.md b/plugins/search-backend-node/api-report.md index 03269c72e8..5e8961a65e 100644 --- a/plugins/search-backend-node/api-report.md +++ b/plugins/search-backend-node/api-report.md @@ -20,7 +20,7 @@ import { SearchQuery } from '@backstage/plugin-search-common'; import { TaskFunction } from '@backstage/backend-tasks'; import { TaskRunner } from '@backstage/backend-tasks'; import { Transform } from 'stream'; -import { UrlReaderService } from '@backstage/backend-plugin-api'; +import { UrlReader } from '@backstage/backend-common'; import { Writable } from 'stream'; // @public @@ -138,7 +138,7 @@ export class NewlineDelimitedJsonCollatorFactory export type NewlineDelimitedJsonCollatorFactoryOptions = { type: string; searchPattern: string; - reader: UrlReaderService; + reader: UrlReader; logger: LoggerService; visibilityPermission?: Permission; }; diff --git a/plugins/search-backend-node/package.json b/plugins/search-backend-node/package.json index c8a833e92a..d7a7191faa 100644 --- a/plugins/search-backend-node/package.json +++ b/plugins/search-backend-node/package.json @@ -53,7 +53,7 @@ "test": "backstage-cli package test" }, "dependencies": { - "@backstage/backend-defaults": "workspace:^", + "@backstage/backend-common": "workspace:^", "@backstage/backend-plugin-api": "workspace:^", "@backstage/backend-tasks": "workspace:^", "@backstage/config": "workspace:^", @@ -67,6 +67,7 @@ "uuid": "^9.0.0" }, "devDependencies": { + "@backstage/backend-common": "workspace:^", "@backstage/backend-test-utils": "workspace:^", "@backstage/cli": "workspace:^", "@types/ndjson": "^2.0.1" diff --git a/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.test.ts b/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.test.ts index 45f3635232..45cc98e9ba 100644 --- a/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.test.ts +++ b/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.test.ts @@ -14,16 +14,16 @@ * limitations under the License. */ +import { + ReadUrlResponse, + UrlReader, + UrlReaders, +} from '@backstage/backend-common'; import { ConfigReader } from '@backstage/config'; import { Readable } from 'stream'; import { NewlineDelimitedJsonCollatorFactory } from './NewlineDelimitedJsonCollatorFactory'; import { TestPipeline } from '../test-utils'; import { mockServices } from '@backstage/backend-test-utils'; -import { - UrlReaderService, - UrlReaderServiceReadUrlResponse, -} from '@backstage/backend-plugin-api'; -import { UrlReaders } from '@backstage/backend-defaults/urlReader'; describe('DefaultCatalogCollatorFactory', () => { const config = new ConfigReader({}); @@ -42,9 +42,7 @@ describe('DefaultCatalogCollatorFactory', () => { describe('getCollator', () => { let readable: Readable; let reader: jest.Mocked< - UrlReaderService & { - readUrl: jest.Mock>; - } + UrlReader & { readUrl: jest.Mock> } >; let factory: NewlineDelimitedJsonCollatorFactory; diff --git a/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.ts b/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.ts index bf78b98040..e7d749dd41 100644 --- a/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.ts +++ b/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.ts @@ -18,8 +18,9 @@ import { Config } from '@backstage/config'; import { DocumentCollatorFactory } from '@backstage/plugin-search-common'; import { Permission } from '@backstage/plugin-permission-common'; import { Readable } from 'stream'; +import { UrlReader } from '@backstage/backend-common'; import { parse as parseNdjson } from 'ndjson'; -import { LoggerService, UrlReaderService } from '@backstage/backend-plugin-api'; +import { LoggerService } from '@backstage/backend-plugin-api'; /** * Options for instantiate NewlineDelimitedJsonCollatorFactory @@ -28,7 +29,7 @@ import { LoggerService, UrlReaderService } from '@backstage/backend-plugin-api'; export type NewlineDelimitedJsonCollatorFactoryOptions = { type: string; searchPattern: string; - reader: UrlReaderService; + reader: UrlReader; logger: LoggerService; visibilityPermission?: Permission; }; @@ -72,7 +73,7 @@ export class NewlineDelimitedJsonCollatorFactory private constructor( type: string, private readonly searchPattern: string, - private readonly reader: UrlReaderService, + private readonly reader: UrlReader, private readonly logger: LoggerService, visibilityPermission: Permission | undefined, ) { diff --git a/plugins/techdocs-node/src/helpers.test.ts b/plugins/techdocs-node/src/helpers.test.ts index e0c9ac41ca..4f77a5432b 100644 --- a/plugins/techdocs-node/src/helpers.test.ts +++ b/plugins/techdocs-node/src/helpers.test.ts @@ -14,6 +14,13 @@ * limitations under the License. */ +import { + ReadTreeResponse, + ReadUrlOptions, + ReadUrlResponse, + SearchResponse, + UrlReader, +} from '@backstage/backend-common'; import { Entity, getEntitySourceLocation } from '@backstage/catalog-model'; import { ConfigReader } from '@backstage/config'; import { ScmIntegrations } from '@backstage/integration'; @@ -27,13 +34,6 @@ import { parseReferenceAnnotation, transformDirLocation, } from './helpers'; -import { - UrlReaderService, - UrlReaderServiceReadTreeResponse, - UrlReaderServiceReadUrlOptions, - UrlReaderServiceReadUrlResponse, - UrlReaderServiceSearchResponse, -} from '@backstage/backend-plugin-api'; jest.mock('@backstage/catalog-model', () => ({ ...jest.requireActual('@backstage/catalog-model'), @@ -290,19 +290,19 @@ describe('getLocationForEntity', () => { describe('getDocFilesFromRepository', () => { it('should read a remote directory using UrlReader.readTree', async () => { - class MockUrlReader implements UrlReaderService { + class MockUrlReader implements UrlReader { async read() { return Buffer.from('mock'); } async readUrl( _url: string, - _options?: UrlReaderServiceReadUrlOptions | undefined, - ): Promise { + _options?: ReadUrlOptions | undefined, + ): Promise { throw new Error('Method not implemented.'); } - async readTree(): Promise { + async readTree(): Promise { return { dir: async () => { return '/tmp/testfolder'; @@ -317,7 +317,7 @@ describe('getDocFilesFromRepository', () => { }; } - async search(): Promise { + async search(): Promise { return { etag: '', files: [], diff --git a/yarn.lock b/yarn.lock index edab1f5580..4c47bc5771 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7554,7 +7554,7 @@ __metadata: version: 0.0.0-use.local resolution: "@backstage/plugin-search-backend-node@workspace:plugins/search-backend-node" dependencies: - "@backstage/backend-defaults": "workspace:^" + "@backstage/backend-common": "workspace:^" "@backstage/backend-plugin-api": "workspace:^" "@backstage/backend-tasks": "workspace:^" "@backstage/backend-test-utils": "workspace:^" From 30691778a450c1143be3c3d22cc2329cb483cfd9 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Wed, 14 Aug 2024 14:29:02 +0200 Subject: [PATCH 282/372] chore: fix newline Co-authored-by: Camila Belo Signed-off-by: Johan Haals --- packages/backend-dynamic-feature-service/package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/backend-dynamic-feature-service/package.json b/packages/backend-dynamic-feature-service/package.json index a4a4a1cdb5..18501623a3 100644 --- a/packages/backend-dynamic-feature-service/package.json +++ b/packages/backend-dynamic-feature-service/package.json @@ -1,9 +1,7 @@ { "name": "@backstage/backend-dynamic-feature-service", - "description": "Backstage dynamic feature service", "version": "0.2.16-next.3", - "main": "src/index.ts", - "types": "src/index.ts", + "description": "Backstage dynamic feature service", "publishConfig": { "access": "public" }, @@ -21,6 +19,8 @@ ".": "./src/index.ts", "./package.json": "./package.json" }, + "main": "src/index.ts", + "types": "src/index.ts", "typesVersions": { "*": { "package.json": [ @@ -76,4 +76,4 @@ "@backstage/cli": "workspace:^", "wait-for-expect": "^3.0.2" } -} \ No newline at end of file +} From b63d378bb161c964c3e34f470becd6f81bc84aaa Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Wed, 14 Aug 2024 14:35:57 +0200 Subject: [PATCH 283/372] Add changesets Co-authored-by: Camila Belo Signed-off-by: Johan Haals --- .changeset/four-singers-fetch.md | 5 +++++ .changeset/tidy-guests-battle.md | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 .changeset/four-singers-fetch.md create mode 100644 .changeset/tidy-guests-battle.md diff --git a/.changeset/four-singers-fetch.md b/.changeset/four-singers-fetch.md new file mode 100644 index 0000000000..fa3a035c24 --- /dev/null +++ b/.changeset/four-singers-fetch.md @@ -0,0 +1,5 @@ +--- +'@backstage/backend-test-utils': patch +--- + +Update imports diff --git a/.changeset/tidy-guests-battle.md b/.changeset/tidy-guests-battle.md new file mode 100644 index 0000000000..df86b02d1d --- /dev/null +++ b/.changeset/tidy-guests-battle.md @@ -0,0 +1,5 @@ +--- +'@backstage/backend-common': patch +--- + +export `createConfigSecretEnumerator` from `@backstage/backend-common` instead of `@backstage/backend-app-api`. From 3b429fb71cd836e8a7621baf9539f8eb968e10a5 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Wed, 14 Aug 2024 14:40:53 +0200 Subject: [PATCH 284/372] Update changets Co-authored-by: Camila Belo Signed-off-by: Johan Haals --- .changeset/four-singers-fetch.md | 6 +++++- .changeset/friendly-points-approve.md | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changeset/friendly-points-approve.md diff --git a/.changeset/four-singers-fetch.md b/.changeset/four-singers-fetch.md index fa3a035c24..a58f5de8aa 100644 --- a/.changeset/four-singers-fetch.md +++ b/.changeset/four-singers-fetch.md @@ -1,5 +1,9 @@ --- '@backstage/backend-test-utils': patch +'@backstage/plugin-kubernetes-node': patch +'@backstage/plugin-kubernetes-backend': patch +'@backstage/plugin-scaffolder-backend': patch +'@backstage/plugin-proxy-backend': patch --- -Update imports +Update internal imports diff --git a/.changeset/friendly-points-approve.md b/.changeset/friendly-points-approve.md new file mode 100644 index 0000000000..52de593750 --- /dev/null +++ b/.changeset/friendly-points-approve.md @@ -0,0 +1,6 @@ +--- +'@backstage/backend-defaults': patch +--- + +Added deprecation warning to urge users to perform the auth service migration or implement their own token manager service. +See https://backstage.io/docs/tutorials/auth-service-migration for more information. From 7cbaf4aab13f9d0326a5d5d05ecf9be05d302e00 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Wed, 14 Aug 2024 14:44:16 +0200 Subject: [PATCH 285/372] chore: re-add package role Co-authored-by: Camila Belo Signed-off-by: Johan Haals --- packages/backend-dynamic-feature-service/package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/backend-dynamic-feature-service/package.json b/packages/backend-dynamic-feature-service/package.json index 18501623a3..56474e4a65 100644 --- a/packages/backend-dynamic-feature-service/package.json +++ b/packages/backend-dynamic-feature-service/package.json @@ -2,6 +2,9 @@ "name": "@backstage/backend-dynamic-feature-service", "version": "0.2.16-next.3", "description": "Backstage dynamic feature service", + "backstage": { + "role": "node-library" + }, "publishConfig": { "access": "public" }, From 029dab1c67f04fe6bc951d8cc1206e2b1f8c14f7 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Wed, 14 Aug 2024 14:46:08 +0200 Subject: [PATCH 286/372] chore: Add another package to changeset Co-authored-by: Camila Belo Signed-off-by: Johan Haals --- .changeset/four-singers-fetch.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.changeset/four-singers-fetch.md b/.changeset/four-singers-fetch.md index a58f5de8aa..69fe6f77bf 100644 --- a/.changeset/four-singers-fetch.md +++ b/.changeset/four-singers-fetch.md @@ -4,6 +4,7 @@ '@backstage/plugin-kubernetes-backend': patch '@backstage/plugin-scaffolder-backend': patch '@backstage/plugin-proxy-backend': patch +'@backstage/backend-dynamic-feature-service': patch --- Update internal imports From d55b8e317dddcf26870726662c95bdcda3fb5d6f Mon Sep 17 00:00:00 2001 From: Marek Libra Date: Wed, 14 Aug 2024 14:13:18 +0200 Subject: [PATCH 287/372] Avoid false check for broadcast emails Signed-off-by: Marek Libra --- .changeset/flat-guests-behave.md | 6 ++++++ .../src/processor/NotificationsEmailProcessor.ts | 13 ++++++++++--- .../src/service/getUsersForEntityRef.ts | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 .changeset/flat-guests-behave.md diff --git a/.changeset/flat-guests-behave.md b/.changeset/flat-guests-behave.md new file mode 100644 index 0000000000..ad4b238e03 --- /dev/null +++ b/.changeset/flat-guests-behave.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-notifications-backend-module-email': patch +'@backstage/plugin-notifications-backend': patch +--- + +Avoid sending broadcast emails as a fallback in case the entity-typed notification user can not be resolved. diff --git a/plugins/notifications-backend-module-email/src/processor/NotificationsEmailProcessor.ts b/plugins/notifications-backend-module-email/src/processor/NotificationsEmailProcessor.ts index 03388a77a2..a876a548d2 100644 --- a/plugins/notifications-backend-module-email/src/processor/NotificationsEmailProcessor.ts +++ b/plugins/notifications-backend-module-email/src/processor/NotificationsEmailProcessor.ts @@ -207,12 +207,17 @@ export class NotificationsEmailProcessor implements NotificationProcessor { private async getRecipientEmails( notification: Notification, options: NotificationSendOptions, - ) { + ): Promise { let emails: string[]; - if (options.recipients.type === 'broadcast' || notification.user === null) { + if (options.recipients.type === 'broadcast') { emails = await this.getBroadcastEmails(); - } else { + } else if (options.recipients.type === 'entity' && !!notification.user) { emails = await this.getUserEmail(notification.user); + } else { + this.logger.info( + `Unknown notification type ${options.recipients.type} or missing user.`, + ); + return []; } if (this.allowlistEmailAddresses) { @@ -338,6 +343,8 @@ export class NotificationsEmailProcessor implements NotificationProcessor { return; } + this.logger.debug(`Sending notification emails to: ${emails.join(',')}`); + if (!this.templateRenderer) { await this.sendPlainEmail(notification, emails); return; diff --git a/plugins/notifications-backend/src/service/getUsersForEntityRef.ts b/plugins/notifications-backend/src/service/getUsersForEntityRef.ts index fd564d6528..9ced24709b 100644 --- a/plugins/notifications-backend/src/service/getUsersForEntityRef.ts +++ b/plugins/notifications-backend/src/service/getUsersForEntityRef.ts @@ -157,5 +157,5 @@ export const getUsersForEntityRef = async ( users.push(...u); } - return [...new Set(users)]; + return [...new Set(users)].filter(Boolean); }; From 861f162b4a39117b824669d67a951ed1db142e3d Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Wed, 14 Aug 2024 15:17:03 +0200 Subject: [PATCH 288/372] backend-test-utils: Remove deprecations Co-authored-by: Camila Belo Signed-off-by: Johan Haals --- .changeset/late-timers-sort.md | 12 +++++ packages/backend-test-utils/api-report.md | 17 ------- packages/backend-test-utils/src/deprecated.ts | 45 ------------------- packages/backend-test-utils/src/index.ts | 1 - .../src/next/wiring/ServiceFactoryTester.ts | 11 ----- 5 files changed, 12 insertions(+), 74 deletions(-) create mode 100644 .changeset/late-timers-sort.md delete mode 100644 packages/backend-test-utils/src/deprecated.ts diff --git a/.changeset/late-timers-sort.md b/.changeset/late-timers-sort.md new file mode 100644 index 0000000000..1b5221721c --- /dev/null +++ b/.changeset/late-timers-sort.md @@ -0,0 +1,12 @@ +--- +'@backstage/backend-test-utils': minor +--- + +Removed these deprecated helpers: + +- `setupRequestMockHandlers` Use `CreateMockDirectoryOptions` instead. +- `CreateMockDirectoryOptions` Use `registerMswTestHooks` instead. + +Stopped exporting the deprecated and internal `isDockerDisabledForTests` helper. + +Removed `get` method from `ServiceFactoryTester` which is replaced by `getSubject` diff --git a/packages/backend-test-utils/api-report.md b/packages/backend-test-utils/api-report.md index 584fedb1f5..d3a80c419e 100644 --- a/packages/backend-test-utils/api-report.md +++ b/packages/backend-test-utils/api-report.md @@ -55,9 +55,6 @@ export interface CreateMockDirectoryOptions { mockOsTmpDir?: boolean; } -// @public @deprecated (undocumented) -export function isDockerDisabledForTests(): boolean; - // @public (undocumented) export namespace mockCredentials { export function limitedUser( @@ -143,9 +140,6 @@ export interface MockDirectoryContentOptions { shouldReadAsText?: boolean | ((path: string, buffer: Buffer) => boolean); } -// @public @deprecated (undocumented) -export type MockDirectoryOptions = CreateMockDirectoryOptions; - // @public (undocumented) export namespace mockServices { // (undocumented) @@ -475,10 +469,6 @@ export class ServiceFactoryTester< subject: ServiceFactory, options?: ServiceFactoryTesterOptions, ): ServiceFactoryTester; - // @deprecated - get( - ...args: 'root' extends TScope ? [] : [pluginId?: string] - ): Promise; getService< TGetService, TGetScope extends 'root' | 'plugin', @@ -508,13 +498,6 @@ export type ServiceMock = { : TService[Key]; }; -// @public @deprecated (undocumented) -export function setupRequestMockHandlers(worker: { - listen: (t: any) => void; - close: () => void; - resetHandlers: () => void; -}): void; - // @public (undocumented) export function startTestBackend( options: TestBackendOptions, diff --git a/packages/backend-test-utils/src/deprecated.ts b/packages/backend-test-utils/src/deprecated.ts deleted file mode 100644 index 9790580a9c..0000000000 --- a/packages/backend-test-utils/src/deprecated.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2024 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 { registerMswTestHooks } from './msw'; -import { CreateMockDirectoryOptions } from './filesystem'; -import { isDockerDisabledForTests as _isDockerDisabledForTests } from './util'; - -/** - * @public - * @deprecated Use `CreateMockDirectoryOptions` from `@backstage/backend-test-utils` instead. - */ -export type MockDirectoryOptions = CreateMockDirectoryOptions; - -/** - * @public - * @deprecated Use `registerMswTestHooks` from `@backstage/backend-test-utils` instead. - */ -export function setupRequestMockHandlers(worker: { - listen: (t: any) => void; - close: () => void; - resetHandlers: () => void; -}): void { - registerMswTestHooks(worker); -} - -/** - * @public - * @deprecated This is an internal function and will no longer be exported from this package. - */ -export function isDockerDisabledForTests(): boolean { - return _isDockerDisabledForTests(); -} diff --git a/packages/backend-test-utils/src/index.ts b/packages/backend-test-utils/src/index.ts index 4124a861f4..d1d80bf387 100644 --- a/packages/backend-test-utils/src/index.ts +++ b/packages/backend-test-utils/src/index.ts @@ -20,7 +20,6 @@ * @packageDocumentation */ -export * from './deprecated'; export * from './cache'; export * from './database'; export * from './msw'; diff --git a/packages/backend-test-utils/src/next/wiring/ServiceFactoryTester.ts b/packages/backend-test-utils/src/next/wiring/ServiceFactoryTester.ts index e8530f89bf..83a6a42307 100644 --- a/packages/backend-test-utils/src/next/wiring/ServiceFactoryTester.ts +++ b/packages/backend-test-utils/src/next/wiring/ServiceFactoryTester.ts @@ -82,17 +82,6 @@ export class ServiceFactoryTester< this.#registry = registry; } - /** - * Returns the service instance for the subject. - * - * @deprecated Use `getSubject` instead. - */ - async get( - ...args: 'root' extends TScope ? [] : [pluginId?: string] - ): Promise { - return this.getSubject(...args); - } - /** * Returns the service instance for the subject. * From 634a1202cd0088393553053b59f3590dec80a1af Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 14 Aug 2024 15:41:21 +0200 Subject: [PATCH 289/372] docs/frontend-system: initial docs for creating extension blueprints Signed-off-by: Patrik Oldsberg --- .../architecture/23-extension-blueprints.md | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/docs/frontend-system/architecture/23-extension-blueprints.md b/docs/frontend-system/architecture/23-extension-blueprints.md index 43212d4a87..ee09e7fec6 100644 --- a/docs/frontend-system/architecture/23-extension-blueprints.md +++ b/docs/frontend-system/architecture/23-extension-blueprints.md @@ -60,3 +60,83 @@ const myPageExtension = PageBlueprint.makeWithOverrides({ When using `makeWithOverrides`, we no longer pass the blueprint parameters directly. Instead, we provide a `factory` function that receives the original blueprint factory as the first argument, and the extension factory context as the second. We can then call the original blueprint factory with the blueprint parameters and forward the result as the return value of out factory. Notice that when passing the blueprint parameters using this pattern we have access to a lot more information than when using the `make` method, at the cost of being more complex. Apart from the addition of the blueprint parameters of the first argument to the original factory function, the `makeWithOverrides` method works the same way as [extension overrides](./25-extension-overrides.md). All the same options and rules apply, including the ability to define additional inputs, override outputs, and so on. We therefore defer to the [extension overrides](./25-extension-overrides.md) documentation for more information on how to use the `makeWithOverrides` method. + +## Creating an extension blueprint + +To create a new extension blueprint, you use the `createExtensionBlueprint` function. At the surface it is very similar to `createExtension`, but with a few key differences. Firstly you must provide a `kind` option, which will be the kind of all extensions created with the blueprint. See the [naming patterns section](./50-naming-patterns.md) for more information about how to select a good extension kind. Secondly, the `factory` function has a new signature where the first parameter is the blueprint parameters, and the second is the factory context. And finally, rather than returning an extension, `createExtensionBlueprint` returns a blueprint object with the `make` method and friends, which is used as is described above. + +The following is an example of how one might create a new extension blueprint: + +```tsx +export interface MyWidgetBlueprintParams { + defaultTitle: string; + element: JSX.Element; +} + +export const MyWidgetBlueprint = createExtensionBlueprint({ + kind: 'my-widget', + attachTo: { id: 'page:my-plugin', input: 'widgets' }, + config: { + schema: { + title: z.string().optional(), + }, + }, + output: [coreExtensionData.reactElement], + factory(params: MyWidgetBlueprintParams, { config }) { + return [ + // Note that while this is a valid pattern, you might often want to + // return separate pieces of data instead, more on that below. + coreExtensionData.reactElement( + + {params.element} + , + ), + ]; + }, +}); +``` + +This is of course a quite bare-bones example blueprint, but still a very real example. Blueprints can be very simple, there's already a lot of value in encapsulating the extension kind, attachment point, and output in a blueprint. + +Most of the options provided to `createExtensionBlueprint` can be overridden when using `makeWithOverrides` to create an extension from the blueprint. These overrides work the same way as [extension overrides](./25-extension-overrides.md), and we defer to that documentation for more information on how overrides work. + +### Blueprint-specific extension data references + +In some cases you may want to define and provide [extension data reference](./20-extensions.md#extension-data-references) that are specific to your blueprint. In the above example we might want to forward the `title` as data for example, rather than encapsulating it into the `MyWidgetContainer` component. This gives the parent extension more flexibility in the rendering for our example widget extensions. + +To do that, we create a new extension data reference for our widget title. This references is provided via the `dataRefs` options when we create the blueprint, which makes it available for use via `MyWidgetBlueprint.dataRefs.widgetTitle`. + +```tsx +export interface MyWidgetBlueprintParams { + defaultTitle: string; + element: JSX.Element; +} + +const widgetTitleRef = createExtensionDataRef().with({ + id: 'my-plugin.widget.title', +}); + +export const MyWidgetBlueprint = createExtensionBlueprint({ + kind: 'my-widget', + attachTo: { id: 'page:my-plugin', input: 'widgets' }, + config: { + schema: { + title: z.string().optional(), + }, + }, + output: [widgetTitleRef, coreExtensionData.reactElement], + factory(params: MyWidgetBlueprintParams, { config }) { + return [ + widgetTitleRef(config.title ?? params.defaultTitle), + coreExtensionData.reactElement(params.element), + ]; + }, + dataRefs: { + widgetTitle: widgetTitleRef, + }, +}); +``` + +### Extension Blueprints in libraries + +If you are publishing a plugin, the extension creators should always be exported from frontend library packages (e.g. `*-react`) rather than plugin packages. From a376559a2dcb140873846ab78138da57540207b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Wed, 14 Aug 2024 15:55:52 +0200 Subject: [PATCH 290/372] Correct the TConfig type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/curly-clouds-shave.md | 5 +++++ packages/frontend-plugin-api/api-report.md | 4 ++-- .../frontend-plugin-api/src/wiring/createExtensionDataRef.ts | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/curly-clouds-shave.md diff --git a/.changeset/curly-clouds-shave.md b/.changeset/curly-clouds-shave.md new file mode 100644 index 0000000000..0e30f4bba1 --- /dev/null +++ b/.changeset/curly-clouds-shave.md @@ -0,0 +1,5 @@ +--- +'@backstage/frontend-plugin-api': patch +--- + +Correct the `TConfig` type of data references to only contain config diff --git a/packages/frontend-plugin-api/api-report.md b/packages/frontend-plugin-api/api-report.md index f841fc2ce2..399ecb259e 100644 --- a/packages/frontend-plugin-api/api-report.md +++ b/packages/frontend-plugin-api/api-report.md @@ -407,7 +407,7 @@ export interface ConfigurableExtensionDataRef< optional(): ConfigurableExtensionDataRef< TData, TId, - TData & { + TConfig & { optional: true; } >; @@ -1800,7 +1800,7 @@ export const PageBlueprint: ExtensionBlueprint< | ConfigurableExtensionDataRef< RouteRef, 'core.routing.ref', - RouteRef & { + { optional: true; } >, diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionDataRef.ts b/packages/frontend-plugin-api/src/wiring/createExtensionDataRef.ts index c77aa8c394..80413c1688 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionDataRef.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtensionDataRef.ts @@ -55,7 +55,7 @@ export interface ConfigurableExtensionDataRef< optional(): ConfigurableExtensionDataRef< TData, TId, - TData & { optional: true } + TConfig & { optional: true } >; (t: TData): ExtensionDataValue; } From 9b356dcaacc9192f10886d4bf254305aa56e3827 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 14 Aug 2024 16:01:25 +0200 Subject: [PATCH 291/372] frontend-plugin-api: renamed createPlugin to createFrontendPlugin Signed-off-by: Patrik Oldsberg --- .changeset/chilly-numbers-chew.md | 5 +++ .../architecture/15-plugins.md | 10 ++--- .../frontend-system/architecture/36-routes.md | 12 +++--- .../architecture/50-naming-patterns.md | 4 +- .../building-apps/08-migrating.md | 2 +- .../building-plugins/01-index.md | 14 +++---- .../building-plugins/05-migrating.md | 20 +++++----- .../utility-apis/02-creating.md | 4 +- .../app-next-example-plugin/src/plugin.tsx | 4 +- .../app-next/src/examples/pagesPlugin.tsx | 4 +- .../src/collectLegacyRoutes.test.tsx | 2 +- .../src/collectLegacyRoutes.tsx | 4 +- .../compatWrapper/BackwardsCompatProvider.tsx | 2 +- .../src/routing/collectRouteIds.test.ts | 8 +++- .../extractRouteInfoFromAppNode.test.ts | 4 +- .../src/tree/createAppTree.test.ts | 4 +- .../src/tree/resolveAppNodeSpecs.test.ts | 22 +++++++---- .../src/tree/resolveAppNodeSpecs.ts | 2 +- .../src/wiring/createApp.test.tsx | 14 +++---- .../frontend-app-api/src/wiring/createApp.tsx | 2 +- .../src/wiring/discovery.test.ts | 10 ++--- packages/frontend-plugin-api/api-report.md | 39 ++++++++++--------- ...n.test.ts => createFrontendPlugin.test.ts} | 20 +++++----- ...reatePlugin.ts => createFrontendPlugin.ts} | 10 ++++- .../frontend-plugin-api/src/wiring/index.ts | 6 ++- plugins/api-docs/src/alpha.tsx | 4 +- plugins/app-visualizer/src/plugin.tsx | 4 +- plugins/catalog-graph/src/alpha.tsx | 4 +- plugins/catalog-import/src/alpha.tsx | 4 +- plugins/catalog/src/alpha/plugin.tsx | 4 +- plugins/devtools/src/alpha/plugin.tsx | 4 +- plugins/home/src/alpha.tsx | 4 +- plugins/kubernetes/src/alpha/plugin.tsx | 4 +- plugins/org/src/alpha.tsx | 4 +- plugins/scaffolder/src/alpha.tsx | 4 +- plugins/search/src/alpha.tsx | 4 +- plugins/techdocs/src/alpha.tsx | 4 +- plugins/user-settings/src/alpha.tsx | 4 +- 38 files changed, 154 insertions(+), 126 deletions(-) create mode 100644 .changeset/chilly-numbers-chew.md rename packages/frontend-plugin-api/src/wiring/{createPlugin.test.ts => createFrontendPlugin.test.ts} (95%) rename packages/frontend-plugin-api/src/wiring/{createPlugin.ts => createFrontendPlugin.ts} (95%) diff --git a/.changeset/chilly-numbers-chew.md b/.changeset/chilly-numbers-chew.md new file mode 100644 index 0000000000..3ee9e7837f --- /dev/null +++ b/.changeset/chilly-numbers-chew.md @@ -0,0 +1,5 @@ +--- +'@backstage/frontend-plugin-api': patch +--- + +Renamed `createPlugin` to `createFrontendPlugin`. The old symbol is still exported but deprecated. diff --git a/docs/frontend-system/architecture/15-plugins.md b/docs/frontend-system/architecture/15-plugins.md index 042d4fbc36..c1539f0309 100644 --- a/docs/frontend-system/architecture/15-plugins.md +++ b/docs/frontend-system/architecture/15-plugins.md @@ -25,7 +25,7 @@ How to create a simple plugin --> ```ts -export const myPlugin = createPlugin({ +export const myPlugin = createFrontendPlugin({ id: 'my-plugin', }); ``` @@ -48,7 +48,7 @@ link to relevant docs +Each plugin is typically shipped in a separate NPM package, whether that's a published package, or just in the local workspace. The plugins instance should always the `default` export of the package, either via the main entry-point or the `/alpha` sub-path export. Each plugin package is limited to exporting a single plugin instance. In a local workspace you could use a different structure if preferred, but this is considered a non-standard layout and should be avoided in published packages. ## Creating a Plugin - +Frontend plugin instances are created with the `createFrontendPlugin` function, which is provided by the `@backstage/frontend-plugin-api` package. It takes a single options object that provides all of the necessary configuration for the plugin. In particular you will want to provide [extensions](./20-extensions.md) for your plugin, as that is the way that you can provide new functionality to the app. ```ts -export const myPlugin = createFrontendPlugin({ +// This creates a new extension, see "Extension Blueprints" documentation for more details +const myPage = PageBlueprint.make({ + params: { + defaultPath: '/my-page', + }, +}); + +export default createFrontendPlugin({ id: 'my-plugin', + extensions: [myPage], }); ``` - +The plugin ID should generally be part of the of the package name and use kebab-case. See both the [frontend naming patterns section](./50-naming-patterns.md), as well as the [package metadata section](../../tooling/package-metadata.md#name) for more information. -### Plugin ID +### `extensions` option - +### `routes` and `externalRoutes` options -### Plugin Extensions +These are the routes that the plugin exposes to the app. The `routes` option declares all of the target routes that your plugin provides, i.e. routes that other plugins and link to. The `externalRoutes` option instead declares all the outgoing routes, i.e. routes that your plugins links to, which you can bind to the `routes` of other plugins. See the [routes documentation](./36-routes.md) for more information how to set up cross-plugin navigation. - - -### Plugin Routes - - - -### Plugin External Routes - - - -### Plugin Feature Flags - - +This is a list of feature flag declarations that your plugin provides to the app. This makes sure that the feature flags are correctly registered and can be toggled in the app. To read a feature flag you can use the feature flags [Utility API](../architecture/33-utility-apis.md), accessible via `featureFlagsApiRef`. ## Installing a Plugin in an App - +A plugin instance is considered an frontend feature and can be installed directly in any Backstage frontend app. See the [app documentation](./10-app.md) for more information about the different ways in which you can install new features in an app. From c6c95a39aad3497f3a367bc3416b726e836691d6 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 14 Aug 2024 17:09:35 +0200 Subject: [PATCH 304/372] docs/frontend-system: add docs for how to use plugin.withOverrides Signed-off-by: Patrik Oldsberg --- .../architecture/15-plugins.md | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/docs/frontend-system/architecture/15-plugins.md b/docs/frontend-system/architecture/15-plugins.md index 66fea76989..f1a24b5b4d 100644 --- a/docs/frontend-system/architecture/15-plugins.md +++ b/docs/frontend-system/architecture/15-plugins.md @@ -55,3 +55,36 @@ This is a list of feature flag declarations that your plugin provides to the app ## Installing a Plugin in an App A plugin instance is considered an frontend feature and can be installed directly in any Backstage frontend app. See the [app documentation](./10-app.md) for more information about the different ways in which you can install new features in an app. + +## Overriding a Plugin + +A plugin might not always behave exactly the way you want. It could be that you want to remove particular extensions, decorate them a bit, replace them with your own, or simply add new ones. Regardless of your exact use-case, you can use the `plugin.withOverrides` method to create a new copy of the plugin with the desired changes. When doing so you can also access the original extensions provided by the plugin, and use the [extension override](./25-extension-overrides.md) API to make changes to individual extensions: + +```tsx +import plugin from '@backstage/plugin-catalog'; + +export default plugin.withOverrides({ + // These overrides are merged with the original extensions + extensions: [ + // Override the catalog nav item to use a custom icon + plugin.getExtension('nav-item:catalog').override({ + factory: origFactory => [ + NavItemBlueprint.dataRefs.target({ + ...origFactory().get(NavItemBlueprint.dataRefs.target), + icon: CustomCatalogIcon, + }), + ], + }), + // Override the catalog index page with a completely custom implementation + PageBlueprint.make({ + params: { + defaultPath: '/catalog', + routeRef: plugin.routes.catalogIndex, + loader: () => import('./CustomCatalogIndexPage').then(m => ), + }, + }), + ], +}); +``` + +You can keep the plugin override in your app package, but it can often be a good idea to separate it out into its own package, especially if you the overrides are complex or you want distinct ownership of the override. For example, if you are overriding the `@backstage/plugin-catalog` plugin, you might create a new package called `@internal/plugin-catalog` at `plugins/catalog` in your workspace, which exports the overridden plugin instance. From 0e16449207f319ba03f898afa70ca7a496472f43 Mon Sep 17 00:00:00 2001 From: Brian Saltz Jr Date: Wed, 14 Aug 2024 12:20:45 -0400 Subject: [PATCH 305/372] Changing the docs for the sign-in page config from `gcpiap` to `gcpIap`. The router is case-insensitive, so they both work, but this will make everything consistent between backend and frontend. Signed-off-by: Brian Saltz Jr --- docs/auth/google/gcp-iap-auth.md | 2 +- .../src/layout/ProxiedSignInPage/ProxiedSignInPage.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/auth/google/gcp-iap-auth.md b/docs/auth/google/gcp-iap-auth.md index 4976e33e33..298f212399 100644 --- a/docs/auth/google/gcp-iap-auth.md +++ b/docs/auth/google/gcp-iap-auth.md @@ -77,6 +77,6 @@ backend.add(import('@backstage/plugin-auth-backend-module-gcp-iap-provider')); ## Adding the provider to the Backstage frontend -See [Sign-In with Proxy Providers](../index.md#sign-in-with-proxy-providers) for pointers on how to set up the sign-in page, and to also make it work smoothly for local development. You'll use `gcpiap` as the provider name. +See [Sign-In with Proxy Providers](../index.md#sign-in-with-proxy-providers) for pointers on how to set up the sign-in page, and to also make it work smoothly for local development. You'll use `gcpIap` as the provider name. If you [provide a custom sign in resolver](https://backstage.io/docs/auth/identity-resolver#building-custom-resolvers), you can skip the `signIn` block entirely. diff --git a/packages/core-components/src/layout/ProxiedSignInPage/ProxiedSignInPage.tsx b/packages/core-components/src/layout/ProxiedSignInPage/ProxiedSignInPage.tsx index 0338bffbff..df0d256312 100644 --- a/packages/core-components/src/layout/ProxiedSignInPage/ProxiedSignInPage.tsx +++ b/packages/core-components/src/layout/ProxiedSignInPage/ProxiedSignInPage.tsx @@ -34,7 +34,7 @@ import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; */ export type ProxiedSignInPageProps = SignInPageProps & { /** - * The provider to use, e.g. "gcpiap" or "awsalb". This must correspond to + * The provider to use, e.g. "gcpIap" or "awsalb". This must correspond to * a properly configured auth provider ID in the auth backend. */ provider: string; From b77fbf4331338e0142e07c58e7015a3e2db65723 Mon Sep 17 00:00:00 2001 From: Andre Wanlin Date: Wed, 14 Aug 2024 11:40:19 -0500 Subject: [PATCH 306/372] Added back `type: 'local'` to TechDocs config schema Signed-off-by: Andre Wanlin --- .changeset/modern-apes-join.md | 5 +++++ plugins/techdocs-backend/config.d.ts | 25 +++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 .changeset/modern-apes-join.md diff --git a/.changeset/modern-apes-join.md b/.changeset/modern-apes-join.md new file mode 100644 index 0000000000..452896b924 --- /dev/null +++ b/.changeset/modern-apes-join.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs-backend': patch +--- + +Added back `type: 'local'` to TechDocs config schema for `publisher` diff --git a/plugins/techdocs-backend/config.d.ts b/plugins/techdocs-backend/config.d.ts index e22fc549d9..4910d8d76e 100644 --- a/plugins/techdocs-backend/config.d.ts +++ b/plugins/techdocs-backend/config.d.ts @@ -68,14 +68,20 @@ export interface Config { /** * Techdocs publisher information */ - publisher?: { - local?: { - /** - * Directory to store generated static files. - */ - publishDirectory?: string; - }; - } & ( + publisher?: + | { + type: 'local'; + + /** + * Optional when 'type' is set to local + */ + local?: { + /** + * (Optional) Directory to store generated static files. + */ + publishDirectory?: string; + }; + } | { type: 'awsS3'; @@ -258,8 +264,7 @@ export interface Config { */ projectId?: string; }; - } - ); + }; /** * @example http://localhost:7007/api/techdocs From a9a70d266272c14175fdc82b8b786fa7a42ce381 Mon Sep 17 00:00:00 2001 From: Patrick Jungermann Date: Wed, 14 Aug 2024 18:15:00 +0200 Subject: [PATCH 307/372] fix(events,github): fix log messages for repository events Signed-off-by: Patrick Jungermann --- .../src/providers/GithubEntityProvider.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.ts b/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.ts index daade9660a..d5dd88448a 100644 --- a/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.ts +++ b/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.ts @@ -540,7 +540,7 @@ export class GithubEntityProvider implements EntityProvider, EventSubscriber { const matchingTargets = this.matchesFilters([repository]); if (matchingTargets.length === 0) { this.logger.debug( - `skipping repository transferred event for repository ${repository.name} because it didn't match provider filters`, + `skipping repository renamed event for repository ${repository.name} because it didn't match provider filters`, ); return; } @@ -587,7 +587,7 @@ export class GithubEntityProvider implements EntityProvider, EventSubscriber { const matchingTargets = this.matchesFilters([repository]); if (matchingTargets.length === 0) { this.logger.debug( - `skipping repository transferred event for repository ${repository.name} because it didn't match provider filters`, + `skipping repository unarchived event for repository ${repository.name} because it didn't match provider filters`, ); return; } From c1eb809f8b60f82bcca2ed81279e16bfd5f7b4b8 Mon Sep 17 00:00:00 2001 From: Patrick Jungermann Date: Wed, 14 Aug 2024 18:23:30 +0200 Subject: [PATCH 308/372] fix(events,github): reliably extract org name Use `$.organization.login` instead of `$.repository.organization`. The latter is set at `push` events, but not at events of i.e. type `repository`. The replacement is available at both of them. Fixes: #25951 Signed-off-by: Patrick Jungermann --- .changeset/warm-moles-appear.md | 7 +++++++ .../src/providers/GithubEntityProvider.test.ts | 11 ++++++++--- .../src/providers/GithubEntityProvider.ts | 8 ++++---- 3 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 .changeset/warm-moles-appear.md diff --git a/.changeset/warm-moles-appear.md b/.changeset/warm-moles-appear.md new file mode 100644 index 0000000000..66ad1b9cf9 --- /dev/null +++ b/.changeset/warm-moles-appear.md @@ -0,0 +1,7 @@ +--- +'@backstage/plugin-catalog-backend-module-github': patch +--- + +Fix GitHub `repository` event support. + +`$.repository.organization` is only provided for `push` events. Switched to `$.organization.login` instead. diff --git a/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.test.ts b/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.test.ts index 002b2bbfd1..6382391610 100644 --- a/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.test.ts +++ b/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.test.ts @@ -702,6 +702,9 @@ describe('GithubEntityProvider', () => { const event = { ref: options?.ref ?? 'refs/heads/main', repository: repo as PushEvent['repository'], + organization: { + login: organization, + }, created: true, deleted: false, forced: false, @@ -963,7 +966,6 @@ describe('GithubEntityProvider', () => { url: 'https://github.com/test-org/test-repo', default_branch: 'main', master_branch: 'main', - organization: 'test-org', topics: [], archived: action === 'archived', private: action !== 'publicized', @@ -972,6 +974,9 @@ describe('GithubEntityProvider', () => { const event = { action, repository: repo as RepositoryEvent['repository'], + organization: { + login: 'test-org', + }, } as RepositoryEvent; if (action === 'renamed') { @@ -1285,7 +1290,7 @@ describe('GithubEntityProvider', () => { const event = createRepoEvent( 'renamed', ) as EventParams; - const urlOldRepo = `https://github.com/${event.eventPayload.repository.organization}/${event.eventPayload.changes.repository.name.from}/blob/main/catalog-info.yaml`; + const urlOldRepo = `https://github.com/${event.eventPayload.organization?.login}/${event.eventPayload.changes.repository.name.from}/blob/main/catalog-info.yaml`; const expectedEntitiesRemoved = createExpectedEntitiesForUrl(urlOldRepo); @@ -1314,7 +1319,7 @@ describe('GithubEntityProvider', () => { const event = createRepoEvent( 'renamed', ) as EventParams; - const urlOldRepo = `https://github.com/${event.eventPayload.repository.organization}/${event.eventPayload.changes.repository.name.from}/blob/main/catalog-info.yaml`; + const urlOldRepo = `https://github.com/${event.eventPayload.organization?.login}/${event.eventPayload.changes.repository.name.from}/blob/main/catalog-info.yaml`; const expectedEntitiesRemoved = createExpectedEntitiesForUrl(urlOldRepo); const expectedEntitiesAdded = createExpectedEntitiesForEvent(event); diff --git a/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.ts b/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.ts index d5dd88448a..9e3e19d83f 100644 --- a/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.ts +++ b/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.ts @@ -323,9 +323,9 @@ export class GithubEntityProvider implements EntityProvider, EventSubscriber { } private async onPush(event: PushEvent) { - if (this.config.organization !== event.repository.organization) { + if (this.config.organization !== event.organization?.login) { this.logger.debug( - `skipping push event from organization ${event.repository.organization}`, + `skipping push event from organization ${event.organization?.login}`, ); return; } @@ -408,9 +408,9 @@ export class GithubEntityProvider implements EntityProvider, EventSubscriber { } private async onRepoChange(event: RepositoryEvent) { - if (this.config.organization !== event.repository.organization) { + if (this.config.organization !== event.organization?.login) { this.logger.debug( - `skipping repository event from organization ${event.repository.organization}`, + `skipping repository event from organization ${event.organization?.login}`, ); return; } From 9dc9d9c4d5ded50d48781a491d6769ddaa0e0636 Mon Sep 17 00:00:00 2001 From: Patrick Jungermann Date: Wed, 14 Aug 2024 18:41:34 +0200 Subject: [PATCH 309/372] chore(events,github): reword log message Signed-off-by: Patrick Jungermann --- .../src/providers/GithubEntityProvider.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.ts b/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.ts index 9e3e19d83f..f93c5b93af 100644 --- a/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.ts +++ b/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.ts @@ -294,7 +294,7 @@ export class GithubEntityProvider implements EntityProvider, EventSubscriber { /** {@inheritdoc @backstage/plugin-events-node#EventSubscriber.onEvent} */ async onEvent(params: EventParams): Promise { - this.logger.debug(`Received event from ${params.topic}`); + this.logger.debug(`Received event for topic ${params.topic}`); if (EVENT_TOPICS.some(topic => topic === params.topic)) { if (!this.connection) { throw new Error('Not initialized'); From 5152797064b62cae359e9b21de051bc39e0445d0 Mon Sep 17 00:00:00 2001 From: Patrick Jungermann Date: Wed, 14 Aug 2024 18:49:10 +0200 Subject: [PATCH 310/372] fix(events,github): use correct repo URL `$.repository.url` was used, but contained values of pattern `https://api.github.com/repos/{org}/{repo}` for `repository` events and `https://github.com/{org}/{repo}` for `push` events. Fixes: #25951 Signed-off-by: Patrick Jungermann --- .changeset/warm-moles-appear.md | 3 ++- .../providers/GithubEntityProvider.test.ts | 6 ++++-- .../src/providers/GithubEntityProvider.ts | 21 ++++++++++--------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.changeset/warm-moles-appear.md b/.changeset/warm-moles-appear.md index 66ad1b9cf9..c2809e606f 100644 --- a/.changeset/warm-moles-appear.md +++ b/.changeset/warm-moles-appear.md @@ -4,4 +4,5 @@ Fix GitHub `repository` event support. -`$.repository.organization` is only provided for `push` events. Switched to `$.organization.login` instead. +- `$.repository.organization` is only provided for `push` events. Switched to `$.organization.login` instead. +- `$.repository.url` is not always returning the expected and required value. Use `$.repository.html_url` instead. diff --git a/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.test.ts b/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.test.ts index 6382391610..79af5ad5ca 100644 --- a/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.test.ts +++ b/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.test.ts @@ -665,7 +665,7 @@ describe('GithubEntityProvider', () => { event: EventParams, options?: { branch?: string; catalogFilePath?: string }, ): DeferredEntity[] => { - const url = `${event.eventPayload.repository.url}/blob/${ + const url = `${event.eventPayload.repository.html_url}/blob/${ options?.branch ?? 'main' }/${options?.catalogFilePath ?? 'catalog-info.yaml'}`; return createExpectedEntitiesForUrl(url); @@ -687,6 +687,7 @@ describe('GithubEntityProvider', () => { name: 'test-repo', organization, topics: [], + html_url: `https://github.com/${organization}/test-repo`, url: `https://github.com/${organization}/test-repo`, } as Partial; @@ -963,7 +964,8 @@ describe('GithubEntityProvider', () => { ): EventParams => { const repo = { name: 'test-repo', - url: 'https://github.com/test-org/test-repo', + html_url: 'https://github.com/test-org/test-repo', + url: 'https://api.github.com/repos/test-org/test-repo', default_branch: 'main', master_branch: 'main', topics: [], diff --git a/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.ts b/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.ts index f93c5b93af..38008fe03c 100644 --- a/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.ts +++ b/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.ts @@ -331,7 +331,7 @@ export class GithubEntityProvider implements EntityProvider, EventSubscriber { } const repoName = event.repository.name; - const repoUrl = event.repository.url; + const repoUrl = event.repository.html_url; this.logger.debug(`handle github:push event for ${repoName} - ${repoUrl}`); const branch = @@ -356,13 +356,13 @@ export class GithubEntityProvider implements EntityProvider, EventSubscriber { // so we will process the change based in this data // https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#push const added = this.collectDeferredEntitiesFromCommit( - event.repository.url, + repoUrl, branch, event.commits, (commit: Commit) => [...commit.added], ); const removed = this.collectDeferredEntitiesFromCommit( - event.repository.url, + repoUrl, branch, event.commits, (commit: Commit) => [...commit.removed], @@ -381,14 +381,12 @@ export class GithubEntityProvider implements EntityProvider, EventSubscriber { keys: [ ...new Set([ ...modified.map( - filePath => - `url:${event.repository.url}/tree/${branch}/${filePath}`, + filePath => `url:${repoUrl}/tree/${branch}/${filePath}`, ), ...modified.map( - filePath => - `url:${event.repository.url}/blob/${branch}/${filePath}`, + filePath => `url:${repoUrl}/blob/${branch}/${filePath}`, ), - `url:${event.repository.url}/tree/${branch}/${catalogPath}`, + `url:${repoUrl}/tree/${branch}/${catalogPath}`, ]), ], }); @@ -527,7 +525,7 @@ export class GithubEntityProvider implements EntityProvider, EventSubscriber { private async onRepoRenamed(event: RepositoryRenamedEvent) { const repository = this.createRepoFromEvent(event); const oldRepoName = event.changes.repository.name.from; - const urlParts = event.repository.url.split('/'); + const urlParts = repository.url.split('/'); urlParts[urlParts.length - 1] = oldRepoName; const oldRepoUrl = urlParts.join('/'); const oldRepository: Repository = { @@ -632,7 +630,10 @@ export class GithubEntityProvider implements EntityProvider, EventSubscriber { private createRepoFromEvent(event: RepositoryEvent | PushEvent): Repository { return { - url: event.repository.url, + // $.repository.url can be a value like + // "https://api.github.com/repos/{org}/{repo}" + // or "https://github.com/{org}/{repo}" + url: event.repository.html_url, name: event.repository.name, defaultBranchRef: event.repository.default_branch, repositoryTopics: event.repository.topics, From 55f994321b556b340c7f3c828e5ee3d8cbff6845 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 14 Aug 2024 21:22:16 +0200 Subject: [PATCH 311/372] docs/frontend-system: add initial core migration docs Signed-off-by: Patrik Oldsberg --- .../architecture/60-migrations.md | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 docs/frontend-system/architecture/60-migrations.md diff --git a/docs/frontend-system/architecture/60-migrations.md b/docs/frontend-system/architecture/60-migrations.md new file mode 100644 index 0000000000..6ba3c73f0e --- /dev/null +++ b/docs/frontend-system/architecture/60-migrations.md @@ -0,0 +1,74 @@ +--- +id: migrations +title: Frontend System Migrations +sidebar_label: Migrations +# prettier-ignore +description: Migration documentation for different versions of the frontend system core APIs. +--- + +> **NOTE: The new frontend system is in alpha and is only supported by a small number of plugins.** + +## Introduction + +This section provides migration guides for different versions of the frontend system core APIs. Each guide will provide a summary of the changes that have been made for a particular Backstage release, and how to update your usage of the core APIs. + +This guide is intended for app and plugin authors who have already migrated their code to the new frontend system, and are looking to keep it up to date with the latest changes. These guides do not cover trivial migrations that can be explained in a deprecation message, such as a renamed export. + +## 1.30 + +### Reworked extension inputs and outputs + +In previous versions of the frontend system you would define extension inputs and outputs as an "data map" where each named property corresponded to a piece of data that could be accessed via the same name in the extension factory. In order to better support extension overrides and blueprints, as well as reduce the risk of confusion, these data maps have been replaced by an array of data references. + +For example, an extension previously declared like this: + +```tsx +createExtension({ + name: 'example', + attachTo: { id: 'some-extension', input: 'content' }, + inputs: { + header: createExtensionInput( + { element: coreExtensionData.reactElement }, + { + optional: true, + singleton: true, + }, + ), + }, + output: { element: coreExtensionData.reactElement }, + factory({ inputs }) { + return { + element: , + }; + }, +}); +``` + +Would now look like this: + +```tsx +createExtension({ + name: 'example', + attachTo: { id: 'some-extension', input: 'content' }, + inputs: { + header: createExtensionInput([coreExtensionData.reactElement], { + optional: true, + singleton: true, + }), + }, + output: [coreExtensionData.reactElement], + factory({ inputs }) { + return [ + coreExtensionData.reactElement( + , + ), + ]; + }, +}); +``` + +Note the changes to the `inputs` and `output` declarations, as well as how these are used in the factory. Both the `inputs` and `output` now declare their expected data using an array, without names tied to each piece of data. The `get` method on the input object is used to access the input data, and accept a data reference matching the data that was declared for that input. + +The biggest change in practice is how the extension factories output their data. Instead of returning an object with the data values, you instead use each extension data reference to encapsulate a value and return a collection of these encapsulated values from the factory. From dcd6a7923a08c91eeeb8eda63b0c68033a15486c Mon Sep 17 00:00:00 2001 From: "Jonas M. Hansen" Date: Thu, 15 Aug 2024 08:10:29 +0200 Subject: [PATCH 312/372] Added OpenTelemetry support to Scaffolder metrics Signed-off-by: Jonas M. Hansen --- .changeset/large-monkeys-dress.md | 5 + plugins/scaffolder-backend/package.json | 1 + .../tasks/NunjucksWorkflowRunner.ts | 92 ++++++++++++++++--- yarn.lock | 1 + 4 files changed, 87 insertions(+), 12 deletions(-) create mode 100644 .changeset/large-monkeys-dress.md diff --git a/.changeset/large-monkeys-dress.md b/.changeset/large-monkeys-dress.md new file mode 100644 index 0000000000..369a3994c5 --- /dev/null +++ b/.changeset/large-monkeys-dress.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend': minor +--- + +Added OpenTelemetry support to Scaffolder metrics diff --git a/plugins/scaffolder-backend/package.json b/plugins/scaffolder-backend/package.json index f3d10ba478..d9023f3711 100644 --- a/plugins/scaffolder-backend/package.json +++ b/plugins/scaffolder-backend/package.json @@ -86,6 +86,7 @@ "@backstage/plugin-scaffolder-common": "workspace:^", "@backstage/plugin-scaffolder-node": "workspace:^", "@backstage/types": "workspace:^", + "@opentelemetry/api": "^1.3.0", "@types/express": "^4.17.6", "@types/luxon": "^3.0.0", "concat-stream": "^2.0.0", diff --git a/plugins/scaffolder-backend/src/scaffolder/tasks/NunjucksWorkflowRunner.ts b/plugins/scaffolder-backend/src/scaffolder/tasks/NunjucksWorkflowRunner.ts index 3b88fd0f10..3d7d8b8b1d 100644 --- a/plugins/scaffolder-backend/src/scaffolder/tasks/NunjucksWorkflowRunner.ts +++ b/plugins/scaffolder-backend/src/scaffolder/tasks/NunjucksWorkflowRunner.ts @@ -26,6 +26,7 @@ import { PassThrough } from 'stream'; import { generateExampleOutput, isTruthy } from './helper'; import { validate as validateJsonSchema } from 'jsonschema'; import { TemplateActionRegistry } from '../actions'; +import { metrics } from '@opentelemetry/api'; import { SecureTemplater, SecureTemplateRenderer, @@ -520,36 +521,62 @@ export class NunjucksWorkflowRunner implements WorkflowRunner { } function scaffoldingTracker() { - const taskCount = createCounterMetric({ + // prom-client metrics are deprecated in favour of OpenTelemetry metrics. + const promTaskCount = createCounterMetric({ name: 'scaffolder_task_count', help: 'Count of task runs', labelNames: ['template', 'user', 'result'], }); - const taskDuration = createHistogramMetric({ + const promTaskDuration = createHistogramMetric({ name: 'scaffolder_task_duration', help: 'Duration of a task run', labelNames: ['template', 'result'], }); - const stepCount = createCounterMetric({ + const promtStepCount = createCounterMetric({ name: 'scaffolder_step_count', help: 'Count of step runs', labelNames: ['template', 'step', 'result'], }); - const stepDuration = createHistogramMetric({ + const promStepDuration = createHistogramMetric({ name: 'scaffolder_step_duration', help: 'Duration of a step runs', labelNames: ['template', 'step', 'result'], }); + const meter = metrics.getMeter('default'); + const taskCount = meter.createCounter('scaffolder.task.count', { + description: 'Count of task runs', + }); + + const taskDuration = meter.createHistogram('scaffolder.task.duration', { + description: 'Duration of a task run', + unit: 'seconds', + }); + + const stepCount = meter.createCounter('scaffolder.step.count', { + description: 'Count of step runs', + }); + + const stepDuration = meter.createHistogram('scaffolder.step.duration', { + description: 'Duration of a step runs', + unit: 'seconds', + }); + async function taskStart(task: TaskContext) { await task.emitLog(`Starting up task with ${task.spec.steps.length} steps`); const template = task.spec.templateInfo?.entityRef || ''; const user = task.spec.user?.ref || ''; - const taskTimer = taskDuration.startTimer({ + const startTime = process.hrtime(); + const taskTimer = promTaskDuration.startTimer({ template, }); + function endTime() { + const delta = process.hrtime(startTime); + return delta[0] + delta[1] / 1e9; + } + async function skipDryRun( step: TaskStep, action: TemplateAction, @@ -561,12 +588,17 @@ function scaffoldingTracker() { } async function markSuccessful() { - taskCount.inc({ + promTaskCount.inc({ template, user, result: 'ok', }); taskTimer({ result: 'ok' }); + + taskCount.add(1, { template, user, result: 'ok' }); + taskDuration.record(endTime(), { + result: 'ok', + }); } async function markFailed(step: TaskStep, err: Error) { @@ -574,12 +606,17 @@ function scaffoldingTracker() { stepId: step.id, status: 'failed', }); - taskCount.inc({ + promTaskCount.inc({ template, user, result: 'failed', }); taskTimer({ result: 'failed' }); + + taskCount.add(1, { template, user, result: 'failed' }); + taskDuration.record(endTime(), { + result: 'failed', + }); } async function markCancelled(step: TaskStep) { @@ -587,12 +624,17 @@ function scaffoldingTracker() { stepId: step.id, status: 'cancelled', }); - taskCount.inc({ + promTaskCount.inc({ template, user, result: 'cancelled', }); taskTimer({ result: 'cancelled' }); + + taskCount.add(1, { template, user, result: 'cancelled' }); + taskDuration.record(endTime(), { + result: 'cancelled', + }); } return { @@ -610,40 +652,61 @@ function scaffoldingTracker() { }); const template = task.spec.templateInfo?.entityRef || ''; - const stepTimer = stepDuration.startTimer({ + const startTime = process.hrtime(); + const stepTimer = promStepDuration.startTimer({ template, step: step.name, }); + function endTime() { + const delta = process.hrtime(startTime); + return delta[0] + delta[1] / 1e9; + } + async function markSuccessful() { await task.emitLog(`Finished step ${step.name}`, { stepId: step.id, status: 'completed', }); - stepCount.inc({ + promtStepCount.inc({ template, step: step.name, result: 'ok', }); stepTimer({ result: 'ok' }); + + stepCount.add(1, { template, step: step.name, result: 'ok' }); + stepDuration.record(endTime(), { + result: 'ok', + }); } async function markCancelled() { - stepCount.inc({ + promtStepCount.inc({ template, step: step.name, result: 'cancelled', }); stepTimer({ result: 'cancelled' }); + + stepCount.add(1, { template, step: step.name, result: 'cancelled' }); + stepDuration.record(endTime(), { + result: 'cancelled', + }); } async function markFailed() { - stepCount.inc({ + promtStepCount.inc({ template, step: step.name, result: 'failed', }); stepTimer({ result: 'failed' }); + + stepCount.add(1, { template, step: step.name, result: 'failed' }); + stepDuration.record(endTime(), { + result: 'failed', + }); } async function skipFalsy() { @@ -652,6 +715,11 @@ function scaffoldingTracker() { { stepId: step.id, status: 'skipped' }, ); stepTimer({ result: 'skipped' }); + + stepCount.add(1, { template, step: step.name, result: 'skipped' }); + stepDuration.record(endTime(), { + result: 'skipped', + }); } return { diff --git a/yarn.lock b/yarn.lock index 9c292f5903..3d5f6c4cb6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7205,6 +7205,7 @@ __metadata: "@backstage/plugin-scaffolder-node": "workspace:^" "@backstage/plugin-scaffolder-node-test-utils": "workspace:^" "@backstage/types": "workspace:^" + "@opentelemetry/api": ^1.3.0 "@types/express": ^4.17.6 "@types/fs-extra": ^11.0.0 "@types/luxon": ^3.0.0 From 1129e946b821eae77ccff23f71248c7860d5e349 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 14 Aug 2024 13:06:32 +0200 Subject: [PATCH 313/372] chore: migrate some of the catalog plugin to blueprints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fredrik Adelöw Signed-off-by: blam --- plugins/catalog/package.json | 1 + .../CatalogFilterBlueprint.test.tsx | 102 +++++++++++++ .../blueprints/CatalogFilterBlueprint.tsx | 44 ++++++ .../{alpha.ts => alpha/blueprints/index.ts} | 8 +- .../alpha/createCatalogFilterExtension.tsx | 5 +- plugins/catalog/src/alpha/entityCards.tsx | 140 ++++++++++-------- plugins/catalog/src/alpha/entityContents.tsx | 53 ++++--- plugins/catalog/src/alpha/index.ts | 3 + .../catalog/src/{ => alpha}/translation.ts | 0 .../src/components/AboutCard/AboutCard.tsx | 2 +- .../src/components/AboutCard/AboutContent.tsx | 2 +- .../CatalogPage/DefaultCatalogPage.tsx | 2 +- .../CatalogSearchResultListItem.tsx | 2 +- .../components/CatalogTable/CatalogTable.tsx | 2 +- .../DependencyOfComponentsCard.tsx | 2 +- .../DependsOnComponentsCard.tsx | 2 +- .../DependsOnResourcesCard.tsx | 2 +- .../EntityContextMenu/EntityContextMenu.tsx | 2 +- .../EntityContextMenu/UnregisterEntity.tsx | 2 +- .../EntityLabelsCard/EntityLabelsCard.tsx | 2 +- .../EntityLabelsEmptyState.tsx | 2 +- .../components/EntityLayout/EntityLayout.tsx | 2 +- .../EntityLinksCard/EntityLinksCard.tsx | 2 +- .../EntityLinksCard/EntityLinksEmptyState.tsx | 2 +- .../EntityNotFound/EntityNotFound.tsx | 2 +- .../DeleteEntityDialog.tsx | 2 +- .../EntityOrphanWarning.tsx | 2 +- .../EntityProcessingErrorsPanel.tsx | 2 +- .../EntityRelationWarning.tsx | 2 +- .../HasComponentsCard/HasComponentsCard.tsx | 2 +- .../HasResourcesCard/HasResourcesCard.tsx | 2 +- .../HasSubcomponentsCard.tsx | 2 +- .../HasSubdomainsCard/HasSubdomainsCard.tsx | 2 +- .../HasSystemsCard/HasSystemsCard.tsx | 2 +- .../RelatedEntitiesCard.tsx | 2 +- .../SystemDiagramCard/SystemDiagramCard.tsx | 2 +- 36 files changed, 295 insertions(+), 115 deletions(-) create mode 100644 plugins/catalog/src/alpha/blueprints/CatalogFilterBlueprint.test.tsx create mode 100644 plugins/catalog/src/alpha/blueprints/CatalogFilterBlueprint.tsx rename plugins/catalog/src/{alpha.ts => alpha/blueprints/index.ts} (73%) rename plugins/catalog/src/{ => alpha}/translation.ts (100%) diff --git a/plugins/catalog/package.json b/plugins/catalog/package.json index aaef0ab951..2f6d3cf65c 100644 --- a/plugins/catalog/package.json +++ b/plugins/catalog/package.json @@ -90,6 +90,7 @@ "@backstage/cli": "workspace:^", "@backstage/core-app-api": "workspace:^", "@backstage/dev-utils": "workspace:^", + "@backstage/frontend-test-utils": "workspace:^", "@backstage/plugin-permission-common": "workspace:^", "@backstage/test-utils": "workspace:^", "@testing-library/dom": "^10.0.0", diff --git a/plugins/catalog/src/alpha/blueprints/CatalogFilterBlueprint.test.tsx b/plugins/catalog/src/alpha/blueprints/CatalogFilterBlueprint.test.tsx new file mode 100644 index 0000000000..de8d037adc --- /dev/null +++ b/plugins/catalog/src/alpha/blueprints/CatalogFilterBlueprint.test.tsx @@ -0,0 +1,102 @@ +/* + * Copyright 2024 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 { CatalogFilterBlueprint } from './CatalogFilterBlueprint'; +import { + coreExtensionData, + createExtension, + createExtensionInput, +} from '@backstage/frontend-plugin-api'; +import { createExtensionTester } from '@backstage/frontend-test-utils'; +import { waitFor, screen } from '@testing-library/react'; + +describe('CatalogFilterBlueprint', () => { + it('should create an extension with sane defaults', () => { + const extension = CatalogFilterBlueprint.make({ + params: { + loader: async () =>
    , + }, + }); + expect(extension).toMatchInlineSnapshot(` + { + "$$type": "@backstage/ExtensionDefinition", + "attachTo": { + "id": "page:catalog", + "input": "filters", + }, + "configSchema": undefined, + "disabled": false, + "factory": [Function], + "inputs": {}, + "kind": "catalog-filter", + "name": undefined, + "namespace": undefined, + "output": [ + [Function], + ], + "override": [Function], + "toString": [Function], + "version": "v2", + } + `); + }); + + it('should allow overrding of inputs and config', async () => { + const extension = CatalogFilterBlueprint.makeWithOverrides({ + name: 'test-name', + inputs: { + mock: createExtensionInput([coreExtensionData.reactElement]), + }, + config: { + schema: { + test: z => z.string(), + }, + }, + factory(originalFactory, { config, inputs }) { + return originalFactory({ + loader: async () => ( +
    + config: {config.test} +
    + {inputs.mock.map(i => i.get(coreExtensionData.reactElement))} +
    +
    + ), + }); + }, + }); + + const mockExtension = createExtension({ + attachTo: { id: 'catalog-filter:test-name', input: 'mock' }, + output: [coreExtensionData.reactElement], + factory() { + return [coreExtensionData.reactElement(
    im a mock
    )]; + }, + }); + + createExtensionTester(extension, { config: { test: 'mock test config' } }) + .add(mockExtension) + .render(); + + await waitFor(() => { + expect(screen.getByTestId('test')).toBeInTheDocument(); + expect(screen.getByTestId('test')).toHaveTextContent( + 'config: mock test config', + ); + expect(screen.getByTestId('contents')).toHaveTextContent('im a mock'); + }); + }); +}); diff --git a/plugins/catalog/src/alpha/blueprints/CatalogFilterBlueprint.tsx b/plugins/catalog/src/alpha/blueprints/CatalogFilterBlueprint.tsx new file mode 100644 index 0000000000..e8d6df55d2 --- /dev/null +++ b/plugins/catalog/src/alpha/blueprints/CatalogFilterBlueprint.tsx @@ -0,0 +1,44 @@ +/* + * Copyright 2024 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, { lazy } from 'react'; +import { + ExtensionBoundary, + coreExtensionData, + createExtensionBlueprint, +} from '@backstage/frontend-plugin-api'; + +/** + * Creates Catalog Filter Extensions + * @alpha + */ +export const CatalogFilterBlueprint = createExtensionBlueprint({ + kind: 'catalog-filter', + attachTo: { id: 'page:catalog', input: 'filters' }, + output: [coreExtensionData.reactElement], + factory(params: { loader: () => Promise }, { node }) { + const ExtensionComponent = lazy(() => + params.loader().then(element => ({ default: () => element })), + ); + return [ + coreExtensionData.reactElement( + + + , + ), + ]; + }, +}); diff --git a/plugins/catalog/src/alpha.ts b/plugins/catalog/src/alpha/blueprints/index.ts similarity index 73% rename from plugins/catalog/src/alpha.ts rename to plugins/catalog/src/alpha/blueprints/index.ts index b78a5e6225..a3a7bcb33f 100644 --- a/plugins/catalog/src/alpha.ts +++ b/plugins/catalog/src/alpha/blueprints/index.ts @@ -1,5 +1,5 @@ /* - * Copyright 2023 The Backstage Authors + * Copyright 2024 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. @@ -13,8 +13,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -export * from './alpha/index'; -export { default } from './alpha/index'; -export { catalogTranslationRef } from './translation'; -export * from './translation'; +export { CatalogFilterBlueprint } from './CatalogFilterBlueprint'; diff --git a/plugins/catalog/src/alpha/createCatalogFilterExtension.tsx b/plugins/catalog/src/alpha/createCatalogFilterExtension.tsx index d8a218f8f3..eb6d58f424 100644 --- a/plugins/catalog/src/alpha/createCatalogFilterExtension.tsx +++ b/plugins/catalog/src/alpha/createCatalogFilterExtension.tsx @@ -23,7 +23,10 @@ import { createExtension, } from '@backstage/frontend-plugin-api'; -/** @alpha */ +/** + * @alpha + * @deprecated Use {@link CatalogFilterExtensionBlueprint} instead + */ export function createCatalogFilterExtension< TInputs extends AnyExtensionInputMap, TConfig, diff --git a/plugins/catalog/src/alpha/entityCards.tsx b/plugins/catalog/src/alpha/entityCards.tsx index 8a18efabde..5f8ee16f87 100644 --- a/plugins/catalog/src/alpha/entityCards.tsx +++ b/plugins/catalog/src/alpha/entityCards.tsx @@ -15,96 +15,116 @@ */ import React from 'react'; -import { createEntityCardExtension } from '@backstage/plugin-catalog-react/alpha'; +import { EntityCardBlueprint } from '@backstage/plugin-catalog-react/alpha'; import { compatWrapper } from '@backstage/core-compat-api'; -export const catalogAboutEntityCard = createEntityCardExtension({ +export const catalogAboutEntityCard = EntityCardBlueprint.make({ name: 'about', - loader: async () => - import('../components/AboutCard').then(m => - compatWrapper(), - ), + params: { + loader: async () => + import('../components/AboutCard').then(m => + compatWrapper(), + ), + }, }); -export const catalogLinksEntityCard = createEntityCardExtension({ +export const catalogLinksEntityCard = EntityCardBlueprint.make({ name: 'links', - filter: 'has:links', - loader: async () => - import('../components/EntityLinksCard').then(m => - compatWrapper(), - ), + params: { + filter: 'has:links', + loader: async () => + import('../components/EntityLinksCard').then(m => + compatWrapper(), + ), + }, }); -export const catalogLabelsEntityCard = createEntityCardExtension({ +export const catalogLabelsEntityCard = EntityCardBlueprint.make({ name: 'labels', - filter: 'has:labels', - loader: async () => - import('../components/EntityLabelsCard').then(m => - compatWrapper(), - ), + params: { + filter: 'has:labels', + loader: async () => + import('../components/EntityLabelsCard').then(m => + compatWrapper(), + ), + }, }); -export const catalogDependsOnComponentsEntityCard = createEntityCardExtension({ +export const catalogDependsOnComponentsEntityCard = EntityCardBlueprint.make({ name: 'depends-on-components', - filter: 'kind:component', - loader: async () => - import('../components/DependsOnComponentsCard').then(m => - compatWrapper(), - ), + params: { + filter: 'kind:component', + loader: async () => + import('../components/DependsOnComponentsCard').then(m => + compatWrapper(), + ), + }, }); -export const catalogDependsOnResourcesEntityCard = createEntityCardExtension({ +export const catalogDependsOnResourcesEntityCard = EntityCardBlueprint.make({ name: 'depends-on-resources', - filter: 'kind:component', - loader: async () => - import('../components/DependsOnResourcesCard').then(m => - compatWrapper(), - ), + params: { + filter: 'kind:component', + loader: async () => + import('../components/DependsOnResourcesCard').then(m => + compatWrapper(), + ), + }, }); -export const catalogHasComponentsEntityCard = createEntityCardExtension({ +export const catalogHasComponentsEntityCard = EntityCardBlueprint.make({ name: 'has-components', - filter: 'kind:system', - loader: async () => - import('../components/HasComponentsCard').then(m => - compatWrapper(), - ), + params: { + filter: 'kind:system', + loader: async () => + import('../components/HasComponentsCard').then(m => + compatWrapper(), + ), + }, }); -export const catalogHasResourcesEntityCard = createEntityCardExtension({ +export const catalogHasResourcesEntityCard = EntityCardBlueprint.make({ name: 'has-resources', - filter: 'kind:system', - loader: async () => - import('../components/HasResourcesCard').then(m => - compatWrapper(), - ), + params: { + filter: 'kind:system', + loader: async () => + import('../components/HasResourcesCard').then(m => + compatWrapper(), + ), + }, }); -export const catalogHasSubcomponentsEntityCard = createEntityCardExtension({ +export const catalogHasSubcomponentsEntityCard = EntityCardBlueprint.make({ name: 'has-subcomponents', - filter: 'kind:component', - loader: async () => - import('../components/HasSubcomponentsCard').then(m => - compatWrapper(), - ), + params: { + filter: 'kind:component', + loader: async () => + import('../components/HasSubcomponentsCard').then(m => + compatWrapper(), + ), + }, }); -export const catalogHasSubdomainsEntityCard = createEntityCardExtension({ +export const catalogHasSubdomainsEntityCard = EntityCardBlueprint.make({ name: 'has-subdomains', - filter: 'kind:domain', - loader: async () => - import('../components/HasSubdomainsCard').then(m => - compatWrapper(), - ), + params: { + filter: 'kind:domain', + loader: async () => + import('../components/HasSubdomainsCard').then(m => + compatWrapper(), + ), + }, }); -export const catalogHasSystemsEntityCard = createEntityCardExtension({ +export const catalogHasSystemsEntityCard = EntityCardBlueprint.make({ name: 'has-systems', - filter: 'kind:domain', - loader: async () => - import('../components/HasSystemsCard').then(m => - compatWrapper(), - ), + params: { + filter: 'kind:domain', + loader: async () => + import('../components/HasSystemsCard').then(m => + compatWrapper(), + ), + }, }); export default [ diff --git a/plugins/catalog/src/alpha/entityContents.tsx b/plugins/catalog/src/alpha/entityContents.tsx index 75c3fef49f..259b92492c 100644 --- a/plugins/catalog/src/alpha/entityContents.tsx +++ b/plugins/catalog/src/alpha/entityContents.tsx @@ -19,27 +19,38 @@ import { coreExtensionData, createExtensionInput, } from '@backstage/frontend-plugin-api'; -import { - createEntityContentExtension, - catalogExtensionData, -} from '@backstage/plugin-catalog-react/alpha'; +import { EntityContentBlueprint } from '@backstage/plugin-catalog-react/alpha'; -export const catalogOverviewEntityContent = createEntityContentExtension({ - name: 'overview', - defaultPath: '/', - defaultTitle: 'Overview', - disabled: false, - inputs: { - cards: createExtensionInput({ - element: coreExtensionData.reactElement, - filterFunction: catalogExtensionData.entityFilterFunction.optional(), - filterExpression: catalogExtensionData.entityFilterExpression.optional(), - }), - }, - loader: async ({ inputs }) => - import('./EntityOverviewPage').then(m => ( - c.output)} /> - )), -}); +export const catalogOverviewEntityContent = + EntityContentBlueprint.makeWithOverrides({ + name: 'overview', + inputs: { + cards: createExtensionInput([ + coreExtensionData.reactElement, + EntityContentBlueprint.dataRefs.filterFunction.optional(), + EntityContentBlueprint.dataRefs.filterExpression.optional(), + ]), + }, + factory: (originalFactory, { inputs }) => { + return originalFactory({ + defaultPath: '/', + defaultTitle: 'Overview', + loader: async () => + import('./EntityOverviewPage').then(m => ( + ({ + element: c.get(coreExtensionData.reactElement), + filterFunction: c.get( + EntityContentBlueprint.dataRefs.filterFunction, + ), + filterExpression: c.get( + EntityContentBlueprint.dataRefs.filterExpression, + ), + }))} + /> + )), + }); + }, + }); export default [catalogOverviewEntityContent]; diff --git a/plugins/catalog/src/alpha/index.ts b/plugins/catalog/src/alpha/index.ts index 06a78ec6ea..f004c4f19e 100644 --- a/plugins/catalog/src/alpha/index.ts +++ b/plugins/catalog/src/alpha/index.ts @@ -16,3 +16,6 @@ export { default } from './plugin'; export { createCatalogFilterExtension } from './createCatalogFilterExtension'; + +export * from './blueprints'; +export * from './translation'; diff --git a/plugins/catalog/src/translation.ts b/plugins/catalog/src/alpha/translation.ts similarity index 100% rename from plugins/catalog/src/translation.ts rename to plugins/catalog/src/alpha/translation.ts diff --git a/plugins/catalog/src/components/AboutCard/AboutCard.tsx b/plugins/catalog/src/components/AboutCard/AboutCard.tsx index ff5d7fc801..cf4a3c2d43 100644 --- a/plugins/catalog/src/components/AboutCard/AboutCard.tsx +++ b/plugins/catalog/src/components/AboutCard/AboutCard.tsx @@ -64,7 +64,7 @@ import { catalogEntityRefreshPermission } from '@backstage/plugin-catalog-common import { useSourceTemplateCompoundEntityRef } from './hooks'; import { taskCreatePermission } from '@backstage/plugin-scaffolder-common/alpha'; import { usePermission } from '@backstage/plugin-permission-react'; -import { catalogTranslationRef } from '../../translation'; +import { catalogTranslationRef } from '../../alpha/translation'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; const TECHDOCS_ANNOTATION = 'backstage.io/techdocs-ref'; diff --git a/plugins/catalog/src/components/AboutCard/AboutContent.tsx b/plugins/catalog/src/components/AboutCard/AboutContent.tsx index 3f781f4759..f6d2d80264 100644 --- a/plugins/catalog/src/components/AboutCard/AboutContent.tsx +++ b/plugins/catalog/src/components/AboutCard/AboutContent.tsx @@ -33,7 +33,7 @@ import React from 'react'; import { AboutField } from './AboutField'; import { LinksGridList } from '../EntityLinksCard/LinksGridList'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; -import { catalogTranslationRef } from '../../translation'; +import { catalogTranslationRef } from '../../alpha/translation'; const useStyles = makeStyles({ description: { diff --git a/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.tsx b/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.tsx index db765b9145..a46a552b8d 100644 --- a/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.tsx +++ b/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.tsx @@ -33,7 +33,7 @@ import { import React, { ReactNode } from 'react'; import { createComponentRouteRef } from '../../routes'; import { CatalogTable, CatalogTableRow } from '../CatalogTable'; -import { catalogTranslationRef } from '../../translation'; +import { catalogTranslationRef } from '../../alpha/translation'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; import { CatalogTableColumnsFunc } from '../CatalogTable/types'; diff --git a/plugins/catalog/src/components/CatalogSearchResultListItem/CatalogSearchResultListItem.tsx b/plugins/catalog/src/components/CatalogSearchResultListItem/CatalogSearchResultListItem.tsx index 1a596f8b9b..f4501bd795 100644 --- a/plugins/catalog/src/components/CatalogSearchResultListItem/CatalogSearchResultListItem.tsx +++ b/plugins/catalog/src/components/CatalogSearchResultListItem/CatalogSearchResultListItem.tsx @@ -27,7 +27,7 @@ import { ResultHighlight, } from '@backstage/plugin-search-common'; import { HighlightedSearchResultText } from '@backstage/plugin-search-react'; -import { catalogTranslationRef } from '../../translation'; +import { catalogTranslationRef } from '../../alpha/translation'; import { useTranslationRef } from '@backstage/frontend-plugin-api'; const useStyles = makeStyles( diff --git a/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx b/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx index e18467249a..1026dc5d26 100644 --- a/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx +++ b/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx @@ -49,7 +49,7 @@ import { CatalogTableColumnsFunc, CatalogTableRow } from './types'; import { PaginatedCatalogTable } from './PaginatedCatalogTable'; import { defaultCatalogTableColumnsFunc } from './defaultCatalogTableColumnsFunc'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; -import { catalogTranslationRef } from '../../translation'; +import { catalogTranslationRef } from '../../alpha/translation'; /** * Props for {@link CatalogTable}. diff --git a/plugins/catalog/src/components/DependencyOfComponentsCard/DependencyOfComponentsCard.tsx b/plugins/catalog/src/components/DependencyOfComponentsCard/DependencyOfComponentsCard.tsx index 2f0557d11e..6c6f811cc1 100644 --- a/plugins/catalog/src/components/DependencyOfComponentsCard/DependencyOfComponentsCard.tsx +++ b/plugins/catalog/src/components/DependencyOfComponentsCard/DependencyOfComponentsCard.tsx @@ -30,7 +30,7 @@ import { componentEntityHelpLink, RelatedEntitiesCard, } from '../RelatedEntitiesCard'; -import { catalogTranslationRef } from '../../translation'; +import { catalogTranslationRef } from '../../alpha/translation'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; /** @public */ diff --git a/plugins/catalog/src/components/DependsOnComponentsCard/DependsOnComponentsCard.tsx b/plugins/catalog/src/components/DependsOnComponentsCard/DependsOnComponentsCard.tsx index fe56ea582b..eafa33346d 100644 --- a/plugins/catalog/src/components/DependsOnComponentsCard/DependsOnComponentsCard.tsx +++ b/plugins/catalog/src/components/DependsOnComponentsCard/DependsOnComponentsCard.tsx @@ -27,7 +27,7 @@ import { componentEntityHelpLink, RelatedEntitiesCard, } from '../RelatedEntitiesCard'; -import { catalogTranslationRef } from '../../translation'; +import { catalogTranslationRef } from '../../alpha/translation'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; /** @public */ diff --git a/plugins/catalog/src/components/DependsOnResourcesCard/DependsOnResourcesCard.tsx b/plugins/catalog/src/components/DependsOnResourcesCard/DependsOnResourcesCard.tsx index 281bfd8766..723b87cc29 100644 --- a/plugins/catalog/src/components/DependsOnResourcesCard/DependsOnResourcesCard.tsx +++ b/plugins/catalog/src/components/DependsOnResourcesCard/DependsOnResourcesCard.tsx @@ -27,7 +27,7 @@ import { RelatedEntitiesCard, resourceEntityColumns, } from '../RelatedEntitiesCard'; -import { catalogTranslationRef } from '../../translation'; +import { catalogTranslationRef } from '../../alpha/translation'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; /** @public */ diff --git a/plugins/catalog/src/components/EntityContextMenu/EntityContextMenu.tsx b/plugins/catalog/src/components/EntityContextMenu/EntityContextMenu.tsx index 5b740038a1..77f934e7de 100644 --- a/plugins/catalog/src/components/EntityContextMenu/EntityContextMenu.tsx +++ b/plugins/catalog/src/components/EntityContextMenu/EntityContextMenu.tsx @@ -33,7 +33,7 @@ import { catalogEntityDeletePermission } from '@backstage/plugin-catalog-common/ import { UnregisterEntity, UnregisterEntityOptions } from './UnregisterEntity'; import { useApi, alertApiRef } from '@backstage/core-plugin-api'; import useCopyToClipboard from 'react-use/esm/useCopyToClipboard'; -import { catalogTranslationRef } from '../../translation'; +import { catalogTranslationRef } from '../../alpha/translation'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; /** @public */ diff --git a/plugins/catalog/src/components/EntityContextMenu/UnregisterEntity.tsx b/plugins/catalog/src/components/EntityContextMenu/UnregisterEntity.tsx index 08496d4819..63247d0c62 100644 --- a/plugins/catalog/src/components/EntityContextMenu/UnregisterEntity.tsx +++ b/plugins/catalog/src/components/EntityContextMenu/UnregisterEntity.tsx @@ -19,7 +19,7 @@ import ListItemIcon from '@material-ui/core/ListItemIcon'; import ListItemText from '@material-ui/core/ListItemText'; import MenuItem from '@material-ui/core/MenuItem'; import CancelIcon from '@material-ui/icons/Cancel'; -import { catalogTranslationRef } from '../../translation'; +import { catalogTranslationRef } from '../../alpha/translation'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; type VisibleType = 'visible' | 'hidden' | 'disable'; diff --git a/plugins/catalog/src/components/EntityLabelsCard/EntityLabelsCard.tsx b/plugins/catalog/src/components/EntityLabelsCard/EntityLabelsCard.tsx index d48b45f054..c4557b6774 100644 --- a/plugins/catalog/src/components/EntityLabelsCard/EntityLabelsCard.tsx +++ b/plugins/catalog/src/components/EntityLabelsCard/EntityLabelsCard.tsx @@ -25,7 +25,7 @@ import { import { EntityLabelsEmptyState } from './EntityLabelsEmptyState'; import Typography from '@material-ui/core/Typography'; import { makeStyles } from '@material-ui/core/styles'; -import { catalogTranslationRef } from '../../translation'; +import { catalogTranslationRef } from '../../alpha/translation'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; /** @public */ diff --git a/plugins/catalog/src/components/EntityLabelsCard/EntityLabelsEmptyState.tsx b/plugins/catalog/src/components/EntityLabelsCard/EntityLabelsEmptyState.tsx index 16d0a3a897..d78be2d2ce 100644 --- a/plugins/catalog/src/components/EntityLabelsCard/EntityLabelsEmptyState.tsx +++ b/plugins/catalog/src/components/EntityLabelsCard/EntityLabelsEmptyState.tsx @@ -19,7 +19,7 @@ import Typography from '@material-ui/core/Typography'; import { makeStyles } from '@material-ui/core/styles'; import React from 'react'; import { CodeSnippet } from '@backstage/core-components'; -import { catalogTranslationRef } from '../../translation'; +import { catalogTranslationRef } from '../../alpha/translation'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; const ENTITY_YAML = `metadata: diff --git a/plugins/catalog/src/components/EntityLayout/EntityLayout.tsx b/plugins/catalog/src/components/EntityLayout/EntityLayout.tsx index bbc7792acb..e8b957497d 100644 --- a/plugins/catalog/src/components/EntityLayout/EntityLayout.tsx +++ b/plugins/catalog/src/components/EntityLayout/EntityLayout.tsx @@ -53,7 +53,7 @@ import React, { useEffect, useState } from 'react'; import { useLocation, useNavigate } from 'react-router-dom'; import { EntityContextMenu } from '../EntityContextMenu/EntityContextMenu'; import { rootRouteRef, unregisterRedirectRouteRef } from '../../routes'; -import { catalogTranslationRef } from '../../translation'; +import { catalogTranslationRef } from '../../alpha/translation'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; /** @public */ diff --git a/plugins/catalog/src/components/EntityLinksCard/EntityLinksCard.tsx b/plugins/catalog/src/components/EntityLinksCard/EntityLinksCard.tsx index b5d8269a0b..59e1f6d252 100644 --- a/plugins/catalog/src/components/EntityLinksCard/EntityLinksCard.tsx +++ b/plugins/catalog/src/components/EntityLinksCard/EntityLinksCard.tsx @@ -23,7 +23,7 @@ import { ColumnBreakpoints } from './types'; import { IconComponent, useApp } from '@backstage/core-plugin-api'; import { InfoCard, InfoCardVariants } from '@backstage/core-components'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; -import { catalogTranslationRef } from '../../translation'; +import { catalogTranslationRef } from '../../alpha/translation'; /** @public */ export interface EntityLinksCardProps { diff --git a/plugins/catalog/src/components/EntityLinksCard/EntityLinksEmptyState.tsx b/plugins/catalog/src/components/EntityLinksCard/EntityLinksEmptyState.tsx index 09362385f9..513183677d 100644 --- a/plugins/catalog/src/components/EntityLinksCard/EntityLinksEmptyState.tsx +++ b/plugins/catalog/src/components/EntityLinksCard/EntityLinksEmptyState.tsx @@ -20,7 +20,7 @@ import { makeStyles } from '@material-ui/core/styles'; import React from 'react'; import { CodeSnippet } from '@backstage/core-components'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; -import { catalogTranslationRef } from '../../translation'; +import { catalogTranslationRef } from '../../alpha/translation'; const ENTITY_YAML = `metadata: name: example diff --git a/plugins/catalog/src/components/EntityNotFound/EntityNotFound.tsx b/plugins/catalog/src/components/EntityNotFound/EntityNotFound.tsx index 252005dff5..a033199ffd 100644 --- a/plugins/catalog/src/components/EntityNotFound/EntityNotFound.tsx +++ b/plugins/catalog/src/components/EntityNotFound/EntityNotFound.tsx @@ -20,7 +20,7 @@ import Button from '@material-ui/core/Button'; import Typography from '@material-ui/core/Typography'; import { makeStyles } from '@material-ui/core/styles'; import { Illo } from './Illo'; -import { catalogTranslationRef } from '../../translation'; +import { catalogTranslationRef } from '../../alpha/translation'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; const useStyles = makeStyles(theme => ({ diff --git a/plugins/catalog/src/components/EntityOrphanWarning/DeleteEntityDialog.tsx b/plugins/catalog/src/components/EntityOrphanWarning/DeleteEntityDialog.tsx index c9c24a14a1..b1a7afbb50 100644 --- a/plugins/catalog/src/components/EntityOrphanWarning/DeleteEntityDialog.tsx +++ b/plugins/catalog/src/components/EntityOrphanWarning/DeleteEntityDialog.tsx @@ -23,7 +23,7 @@ import DialogTitle from '@material-ui/core/DialogTitle'; import React, { useState } from 'react'; import { alertApiRef, useApi } from '@backstage/core-plugin-api'; import { assertError } from '@backstage/errors'; -import { catalogTranslationRef } from '../../translation'; +import { catalogTranslationRef } from '../../alpha/translation'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; interface DeleteEntityDialogProps { diff --git a/plugins/catalog/src/components/EntityOrphanWarning/EntityOrphanWarning.tsx b/plugins/catalog/src/components/EntityOrphanWarning/EntityOrphanWarning.tsx index 10a10e54fd..eb561f9c19 100644 --- a/plugins/catalog/src/components/EntityOrphanWarning/EntityOrphanWarning.tsx +++ b/plugins/catalog/src/components/EntityOrphanWarning/EntityOrphanWarning.tsx @@ -22,7 +22,7 @@ import { useNavigate } from 'react-router-dom'; import { DeleteEntityDialog } from './DeleteEntityDialog'; import { useRouteRef } from '@backstage/core-plugin-api'; import { rootRouteRef } from '../../routes'; -import { catalogTranslationRef } from '../../translation'; +import { catalogTranslationRef } from '../../alpha/translation'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; /** diff --git a/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.tsx b/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.tsx index bd49785abe..3c7c5bb2e3 100644 --- a/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.tsx +++ b/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.tsx @@ -31,7 +31,7 @@ import { import { useApi, ApiHolder } from '@backstage/core-plugin-api'; import useAsync from 'react-use/esm/useAsync'; import { SerializedError } from '@backstage/errors'; -import { catalogTranslationRef } from '../../translation'; +import { catalogTranslationRef } from '../../alpha/translation'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; const errorFilter = (i: EntityStatusItem) => diff --git a/plugins/catalog/src/components/EntityRelationWarning/EntityRelationWarning.tsx b/plugins/catalog/src/components/EntityRelationWarning/EntityRelationWarning.tsx index 2ce9120bf0..ed816bfc75 100644 --- a/plugins/catalog/src/components/EntityRelationWarning/EntityRelationWarning.tsx +++ b/plugins/catalog/src/components/EntityRelationWarning/EntityRelationWarning.tsx @@ -26,7 +26,7 @@ import useAsync from 'react-use/esm/useAsync'; import Box from '@material-ui/core/Box'; import { ResponseErrorPanel } from '@backstage/core-components'; import { useApi, ApiHolder } from '@backstage/core-plugin-api'; -import { catalogTranslationRef } from '../../translation'; +import { catalogTranslationRef } from '../../alpha/translation'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; async function getRelationWarnings(entity: Entity, catalogApi: CatalogApi) { diff --git a/plugins/catalog/src/components/HasComponentsCard/HasComponentsCard.tsx b/plugins/catalog/src/components/HasComponentsCard/HasComponentsCard.tsx index 13a9e75928..2fc6cde81b 100644 --- a/plugins/catalog/src/components/HasComponentsCard/HasComponentsCard.tsx +++ b/plugins/catalog/src/components/HasComponentsCard/HasComponentsCard.tsx @@ -27,7 +27,7 @@ import { componentEntityHelpLink, RelatedEntitiesCard, } from '../RelatedEntitiesCard'; -import { catalogTranslationRef } from '../../translation'; +import { catalogTranslationRef } from '../../alpha/translation'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; /** @public */ diff --git a/plugins/catalog/src/components/HasResourcesCard/HasResourcesCard.tsx b/plugins/catalog/src/components/HasResourcesCard/HasResourcesCard.tsx index b99bca1716..6b90ce0443 100644 --- a/plugins/catalog/src/components/HasResourcesCard/HasResourcesCard.tsx +++ b/plugins/catalog/src/components/HasResourcesCard/HasResourcesCard.tsx @@ -27,7 +27,7 @@ import { resourceEntityColumns, resourceEntityHelpLink, } from '../RelatedEntitiesCard'; -import { catalogTranslationRef } from '../../translation'; +import { catalogTranslationRef } from '../../alpha/translation'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; /** @public */ diff --git a/plugins/catalog/src/components/HasSubcomponentsCard/HasSubcomponentsCard.tsx b/plugins/catalog/src/components/HasSubcomponentsCard/HasSubcomponentsCard.tsx index ceea839ef4..ceab037a45 100644 --- a/plugins/catalog/src/components/HasSubcomponentsCard/HasSubcomponentsCard.tsx +++ b/plugins/catalog/src/components/HasSubcomponentsCard/HasSubcomponentsCard.tsx @@ -26,7 +26,7 @@ import { componentEntityColumns, RelatedEntitiesCard, } from '../RelatedEntitiesCard'; -import { catalogTranslationRef } from '../../translation'; +import { catalogTranslationRef } from '../../alpha/translation'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; /** @public */ diff --git a/plugins/catalog/src/components/HasSubdomainsCard/HasSubdomainsCard.tsx b/plugins/catalog/src/components/HasSubdomainsCard/HasSubdomainsCard.tsx index 811f74d820..71705ea90f 100644 --- a/plugins/catalog/src/components/HasSubdomainsCard/HasSubdomainsCard.tsx +++ b/plugins/catalog/src/components/HasSubdomainsCard/HasSubdomainsCard.tsx @@ -22,7 +22,7 @@ import { componentEntityColumns, RelatedEntitiesCard, } from '../RelatedEntitiesCard'; -import { catalogTranslationRef } from '../../translation'; +import { catalogTranslationRef } from '../../alpha/translation'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; /** @public */ diff --git a/plugins/catalog/src/components/HasSystemsCard/HasSystemsCard.tsx b/plugins/catalog/src/components/HasSystemsCard/HasSystemsCard.tsx index 15b4f933ba..48742f9d28 100644 --- a/plugins/catalog/src/components/HasSystemsCard/HasSystemsCard.tsx +++ b/plugins/catalog/src/components/HasSystemsCard/HasSystemsCard.tsx @@ -27,7 +27,7 @@ import { systemEntityColumns, systemEntityHelpLink, } from '../RelatedEntitiesCard'; -import { catalogTranslationRef } from '../../translation'; +import { catalogTranslationRef } from '../../alpha/translation'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; /** @public */ diff --git a/plugins/catalog/src/components/RelatedEntitiesCard/RelatedEntitiesCard.tsx b/plugins/catalog/src/components/RelatedEntitiesCard/RelatedEntitiesCard.tsx index e6e375646d..a2814527cc 100644 --- a/plugins/catalog/src/components/RelatedEntitiesCard/RelatedEntitiesCard.tsx +++ b/plugins/catalog/src/components/RelatedEntitiesCard/RelatedEntitiesCard.tsx @@ -42,7 +42,7 @@ import { systemEntityColumns, systemEntityHelpLink, } from './presets'; -import { catalogTranslationRef } from '../../translation'; +import { catalogTranslationRef } from '../../alpha/translation'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; /** @public */ diff --git a/plugins/catalog/src/components/SystemDiagramCard/SystemDiagramCard.tsx b/plugins/catalog/src/components/SystemDiagramCard/SystemDiagramCard.tsx index 5e485d672b..879a5076b1 100644 --- a/plugins/catalog/src/components/SystemDiagramCard/SystemDiagramCard.tsx +++ b/plugins/catalog/src/components/SystemDiagramCard/SystemDiagramCard.tsx @@ -46,7 +46,7 @@ import { } from '@backstage/core-components'; import { useApi, useRouteRef } from '@backstage/core-plugin-api'; -import { catalogTranslationRef } from '../../translation'; +import { catalogTranslationRef } from '../../alpha/translation'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; /** @public */ From 52a2e398020e1cf658bad6f6294b4263a1cee1e4 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 14 Aug 2024 13:08:01 +0200 Subject: [PATCH 314/372] chore: fix package.json export Signed-off-by: blam --- plugins/catalog/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/catalog/package.json b/plugins/catalog/package.json index 2f6d3cf65c..b8f8864f3c 100644 --- a/plugins/catalog/package.json +++ b/plugins/catalog/package.json @@ -29,7 +29,7 @@ "sideEffects": false, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts", + "./alpha": "./src/alpha/index.ts", "./package.json": "./package.json" }, "main": "src/index.ts", @@ -37,7 +37,7 @@ "typesVersions": { "*": { "alpha": [ - "src/alpha.ts" + "src/alpha/index.ts" ], "package.json": [ "package.json" From 7999f618077a05b92e1715d44b5516922bfcb81e Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 14 Aug 2024 13:50:25 +0200 Subject: [PATCH 315/372] chore: tidy up the last of the catalog tests Signed-off-by: blam --- .../blueprints/CatalogFilterBlueprint.test.tsx | 4 +++- plugins/catalog/src/setupTests.ts | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/plugins/catalog/src/alpha/blueprints/CatalogFilterBlueprint.test.tsx b/plugins/catalog/src/alpha/blueprints/CatalogFilterBlueprint.test.tsx index de8d037adc..9cf8b65957 100644 --- a/plugins/catalog/src/alpha/blueprints/CatalogFilterBlueprint.test.tsx +++ b/plugins/catalog/src/alpha/blueprints/CatalogFilterBlueprint.test.tsx @@ -71,7 +71,9 @@ describe('CatalogFilterBlueprint', () => {
    config: {config.test}
    - {inputs.mock.map(i => i.get(coreExtensionData.reactElement))} + {inputs.mock.map((i, k) => ( +
    {i.get(coreExtensionData.reactElement)}
    + ))}
    ), diff --git a/plugins/catalog/src/setupTests.ts b/plugins/catalog/src/setupTests.ts index 963c0f188b..dae4360fd3 100644 --- a/plugins/catalog/src/setupTests.ts +++ b/plugins/catalog/src/setupTests.ts @@ -15,3 +15,18 @@ */ import '@testing-library/jest-dom'; + +// eslint-disable-next-line no-console +const originalConsoleWarn = console.warn; +// eslint-disable-next-line no-console +console.warn = (...args: any[]) => { + const message = args[0]; + if ( + typeof message === 'string' && + (message.includes('CSSOM.parse is not a function') || + message.includes('[JSS]')) + ) { + return; + } + originalConsoleWarn(...args); +}; From 1612837c8ebe678f4b3825151c55794dca1d2a05 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 14 Aug 2024 13:50:46 +0200 Subject: [PATCH 316/372] chore: updating catalog react Signed-off-by: blam --- plugins/catalog-react/package.json | 5 +- .../blueprints/EntityCardBlueprint.test.tsx | 178 ++++++++++++++ .../alpha/blueprints/EntityCardBlueprint.tsx | 75 ++++++ .../EntityContentBlueprint.test.tsx | 226 ++++++++++++++++++ .../blueprints/EntityContentBlueprint.tsx | 99 ++++++++ .../src/alpha/blueprints/index.ts | 17 ++ .../src/{alpha.tsx => alpha/extensions.tsx} | 23 +- plugins/catalog-react/src/alpha/index.ts | 17 ++ plugins/catalog-react/src/setupTests.ts | 15 ++ 9 files changed, 646 insertions(+), 9 deletions(-) create mode 100644 plugins/catalog-react/src/alpha/blueprints/EntityCardBlueprint.test.tsx create mode 100644 plugins/catalog-react/src/alpha/blueprints/EntityCardBlueprint.tsx create mode 100644 plugins/catalog-react/src/alpha/blueprints/EntityContentBlueprint.test.tsx create mode 100644 plugins/catalog-react/src/alpha/blueprints/EntityContentBlueprint.tsx create mode 100644 plugins/catalog-react/src/alpha/blueprints/index.ts rename plugins/catalog-react/src/{alpha.tsx => alpha/extensions.tsx} (93%) create mode 100644 plugins/catalog-react/src/alpha/index.ts diff --git a/plugins/catalog-react/package.json b/plugins/catalog-react/package.json index e6b6acae3a..ef5d924200 100644 --- a/plugins/catalog-react/package.json +++ b/plugins/catalog-react/package.json @@ -29,7 +29,7 @@ "sideEffects": false, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.tsx", + "./alpha": "./src/alpha/index.ts", "./package.json": "./package.json" }, "main": "src/index.ts", @@ -37,7 +37,7 @@ "typesVersions": { "*": { "alpha": [ - "src/alpha.tsx" + "src/alpha/index.ts" ], "package.json": [ "package.json" @@ -85,6 +85,7 @@ "devDependencies": { "@backstage/cli": "workspace:^", "@backstage/core-app-api": "workspace:^", + "@backstage/frontend-test-utils": "workspace:^", "@backstage/plugin-catalog-common": "workspace:^", "@backstage/plugin-scaffolder-common": "workspace:^", "@backstage/test-utils": "workspace:^", diff --git a/plugins/catalog-react/src/alpha/blueprints/EntityCardBlueprint.test.tsx b/plugins/catalog-react/src/alpha/blueprints/EntityCardBlueprint.test.tsx new file mode 100644 index 0000000000..db787766fd --- /dev/null +++ b/plugins/catalog-react/src/alpha/blueprints/EntityCardBlueprint.test.tsx @@ -0,0 +1,178 @@ +/* + * Copyright 2024 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 { EntityCardBlueprint } from './EntityCardBlueprint'; +import { + coreExtensionData, + createExtension, + createExtensionInput, +} from '@backstage/frontend-plugin-api'; +import { createExtensionTester } from '@backstage/frontend-test-utils'; +import { waitFor, screen } from '@testing-library/react'; +import { Entity } from '@backstage/catalog-model'; + +describe('EntityCardBlueprint', () => { + it('should return an extension with sensible defaults', () => { + const extension = EntityCardBlueprint.make({ + name: 'test', + params: { + filter: 'has:labels', + loader: async () =>
    im a card
    , + }, + }); + + expect(extension).toMatchInlineSnapshot(` + { + "$$type": "@backstage/ExtensionDefinition", + "attachTo": { + "id": "entity-content:catalog/overview", + "input": "cards", + }, + "configSchema": { + "parse": [Function], + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "additionalProperties": false, + "properties": { + "filter": { + "type": "string", + }, + }, + "type": "object", + }, + }, + "disabled": false, + "factory": [Function], + "inputs": {}, + "kind": "entity-card", + "name": "test", + "namespace": undefined, + "output": [ + [Function], + { + "$$type": "@backstage/ExtensionDataRef", + "config": { + "optional": true, + }, + "id": "catalog.entity-filter-function", + "optional": [Function], + "toString": [Function], + }, + { + "$$type": "@backstage/ExtensionDataRef", + "config": { + "optional": true, + }, + "id": "catalog.entity-filter-expression", + "optional": [Function], + "toString": [Function], + }, + ], + "override": [Function], + "toString": [Function], + "version": "v2", + } + `); + }); + + it('should output the correct filter output', () => { + const mockFilter = (_entity: Entity) => true; + + expect( + createExtensionTester( + EntityCardBlueprint.make({ + name: 'test', + params: { + loader: async () =>
    Test!
    , + filter: 'test', + }, + }), + ).data(EntityCardBlueprint.dataRefs.filterExpression), + ).toBe('test'); + + expect( + createExtensionTester( + EntityCardBlueprint.make({ + name: 'test', + params: { + loader: async () =>
    Test!
    , + }, + }), + { config: { filter: 'test' } }, + ).data(EntityCardBlueprint.dataRefs.filterExpression), + ).toBe('test'); + + expect( + createExtensionTester( + EntityCardBlueprint.make({ + name: 'test', + params: { + filter: mockFilter, + loader: async () =>
    Test!
    , + }, + }), + ).data(EntityCardBlueprint.dataRefs.filterFunction), + ).toBe(mockFilter); + }); + + it('should allow overriding config and inputs', async () => { + const extension = EntityCardBlueprint.makeWithOverrides({ + name: 'test', + inputs: { + mock: createExtensionInput([coreExtensionData.reactElement]), + }, + config: { + schema: { + mock: z => z.string(), + }, + }, + factory(originalFactory, { inputs, config }) { + return originalFactory({ + loader: async () => ( +
    + config: {config.mock} +
    + {inputs.mock.map((i, k) => ( +
    {i.get(coreExtensionData.reactElement)}
    + ))} +
    +
    + ), + }); + }, + }); + + const mockExtension = createExtension({ + attachTo: { id: 'entity-card:test', input: 'mock' }, + output: [coreExtensionData.reactElement], + factory() { + return [coreExtensionData.reactElement(
    im a mock
    )]; + }, + }); + + createExtensionTester(extension, { config: { mock: 'mock test config' } }) + .add(mockExtension) + .render(); + + await waitFor(() => { + expect(screen.getByTestId('test')).toBeInTheDocument(); + expect(screen.getByTestId('test')).toHaveTextContent( + 'config: mock test config', + ); + expect(screen.getByTestId('contents')).toHaveTextContent('im a mock'); + }); + }); +}); diff --git a/plugins/catalog-react/src/alpha/blueprints/EntityCardBlueprint.tsx b/plugins/catalog-react/src/alpha/blueprints/EntityCardBlueprint.tsx new file mode 100644 index 0000000000..c3153b6059 --- /dev/null +++ b/plugins/catalog-react/src/alpha/blueprints/EntityCardBlueprint.tsx @@ -0,0 +1,75 @@ +/* + * Copyright 2024 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, { lazy } from 'react'; +import { + ExtensionBoundary, + coreExtensionData, + createExtensionBlueprint, +} from '@backstage/frontend-plugin-api'; +import { catalogExtensionData } from '../extensions'; + +/** + * @alpha + * A blueprint for creating cards for the entity pages in the catalog. + */ +export const EntityCardBlueprint = createExtensionBlueprint({ + kind: 'entity-card', + attachTo: { id: 'entity-content:catalog/overview', input: 'cards' }, + output: [ + coreExtensionData.reactElement, + catalogExtensionData.entityFilterFunction.optional(), + catalogExtensionData.entityFilterExpression.optional(), + ], + dataRefs: { + filterFunction: catalogExtensionData.entityFilterFunction, + filterExpression: catalogExtensionData.entityFilterExpression, + }, + config: { + schema: { + filter: z => z.string().optional(), + }, + }, + *factory( + { + loader, + filter, + }: { + loader: () => Promise; + filter?: + | typeof catalogExtensionData.entityFilterFunction.T + | typeof catalogExtensionData.entityFilterExpression.T; + }, + { node, config }, + ) { + const ExtensionComponent = lazy(() => + loader().then(element => ({ default: () => element })), + ); + + yield coreExtensionData.reactElement( + + + , + ); + + if (config.filter) { + yield catalogExtensionData.entityFilterExpression(config.filter); + } else if (typeof filter === 'string') { + yield catalogExtensionData.entityFilterExpression(filter); + } else if (typeof filter === 'function') { + yield catalogExtensionData.entityFilterFunction(filter); + } + }, +}); diff --git a/plugins/catalog-react/src/alpha/blueprints/EntityContentBlueprint.test.tsx b/plugins/catalog-react/src/alpha/blueprints/EntityContentBlueprint.test.tsx new file mode 100644 index 0000000000..dab6013bab --- /dev/null +++ b/plugins/catalog-react/src/alpha/blueprints/EntityContentBlueprint.test.tsx @@ -0,0 +1,226 @@ +/* + * Copyright 2024 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 { EntityContentBlueprint } from './EntityContentBlueprint'; +import { createExtensionTester } from '@backstage/frontend-test-utils'; +import { + coreExtensionData, + createExtension, + createExtensionInput, + createRouteRef, +} from '@backstage/frontend-plugin-api'; +import { Entity } from '@backstage/catalog-model'; +import { waitFor, screen } from '@testing-library/react'; + +describe('EntityContentBlueprint', () => { + it('should return an extension with sane defaults', () => { + const extension = EntityContentBlueprint.make({ + name: 'test', + params: { + defaultPath: '/test', + defaultTitle: 'Test', + loader: async () =>
    Test!
    , + }, + }); + + expect(extension).toMatchInlineSnapshot(` + { + "$$type": "@backstage/ExtensionDefinition", + "attachTo": { + "id": "page:catalog/entity", + "input": "contents", + }, + "configSchema": { + "parse": [Function], + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "additionalProperties": false, + "properties": { + "filter": { + "type": "string", + }, + "path": { + "type": "string", + }, + "title": { + "type": "string", + }, + }, + "type": "object", + }, + }, + "disabled": false, + "factory": [Function], + "inputs": {}, + "kind": "entity-content", + "name": "test", + "namespace": undefined, + "output": [ + [Function], + [Function], + [Function], + { + "$$type": "@backstage/ExtensionDataRef", + "config": { + "optional": true, + }, + "id": "core.routing.ref", + "optional": [Function], + "toString": [Function], + }, + { + "$$type": "@backstage/ExtensionDataRef", + "config": { + "optional": true, + }, + "id": "catalog.entity-filter-function", + "optional": [Function], + "toString": [Function], + }, + { + "$$type": "@backstage/ExtensionDataRef", + "config": { + "optional": true, + }, + "id": "catalog.entity-filter-expression", + "optional": [Function], + "toString": [Function], + }, + ], + "override": [Function], + "toString": [Function], + "version": "v2", + } + `); + }); + + it('should emit the correct defaults', () => { + const mockRouteRef = createRouteRef(); + const extension = EntityContentBlueprint.make({ + name: 'test', + params: { + defaultPath: '/test', + defaultTitle: 'Test', + routeRef: mockRouteRef, + loader: async () =>
    Test!
    , + }, + }); + + const tester = createExtensionTester(extension); + + // todo(blam): route paths are always set to / in the createExtensionTester. This will work eventually. + // expect(tester.data(coreExtensionData.routePath)).toBe('/test'); + + expect(tester.data(coreExtensionData.routeRef)).toBe(mockRouteRef); + expect(tester.data(EntityContentBlueprint.dataRefs.title)).toBe('Test'); + }); + + it('should emit the correct filter output', () => { + const mockFilter = (_entity: Entity) => true; + + expect( + createExtensionTester( + EntityContentBlueprint.make({ + name: 'test', + params: { + defaultPath: '/test', + defaultTitle: 'Test', + loader: async () =>
    Test!
    , + filter: 'test', + }, + }), + ).data(EntityContentBlueprint.dataRefs.filterExpression), + ).toBe('test'); + + expect( + createExtensionTester( + EntityContentBlueprint.make({ + name: 'test', + params: { + defaultPath: '/test', + defaultTitle: 'Test', + loader: async () =>
    Test!
    , + }, + }), + { config: { filter: 'test' } }, + ).data(EntityContentBlueprint.dataRefs.filterExpression), + ).toBe('test'); + + expect( + createExtensionTester( + EntityContentBlueprint.make({ + name: 'test', + params: { + defaultPath: '/test', + defaultTitle: 'Test', + filter: mockFilter, + loader: async () =>
    Test!
    , + }, + }), + ).data(EntityContentBlueprint.dataRefs.filterFunction), + ).toBe(mockFilter); + }); + + it('should allow overriding config and inputs', async () => { + const extension = EntityContentBlueprint.makeWithOverrides({ + name: 'test', + inputs: { + mock: createExtensionInput([coreExtensionData.reactElement]), + }, + config: { + schema: { + mock: z => z.string(), + }, + }, + factory(originalFactory, { inputs, config }) { + return originalFactory({ + defaultPath: '/test', + defaultTitle: 'Test', + loader: async () => ( +
    + config: {config.mock} +
    + {inputs.mock.map((i, k) => ( +
    {i.get(coreExtensionData.reactElement)}
    + ))} +
    +
    + ), + }); + }, + }); + + const mockExtension = createExtension({ + attachTo: { id: 'entity-content:test', input: 'mock' }, + output: [coreExtensionData.reactElement], + factory() { + return [coreExtensionData.reactElement(
    im a mock
    )]; + }, + }); + + createExtensionTester(extension, { config: { mock: 'mock test config' } }) + .add(mockExtension) + .render(); + + await waitFor(() => { + expect(screen.getByTestId('test')).toBeInTheDocument(); + expect(screen.getByTestId('test')).toHaveTextContent( + 'config: mock test config', + ); + expect(screen.getByTestId('contents')).toHaveTextContent('im a mock'); + }); + }); +}); diff --git a/plugins/catalog-react/src/alpha/blueprints/EntityContentBlueprint.tsx b/plugins/catalog-react/src/alpha/blueprints/EntityContentBlueprint.tsx new file mode 100644 index 0000000000..7c7a6c43b7 --- /dev/null +++ b/plugins/catalog-react/src/alpha/blueprints/EntityContentBlueprint.tsx @@ -0,0 +1,99 @@ +/* + * Copyright 2024 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, { lazy } from 'react'; +import { + coreExtensionData, + createExtensionBlueprint, + ExtensionBoundary, + RouteRef, +} from '@backstage/frontend-plugin-api'; +import { catalogExtensionData } from '../extensions'; + +/** + * @alpha + * Creates an EntityContent extension. + */ +export const EntityContentBlueprint = createExtensionBlueprint({ + kind: 'entity-content', + attachTo: { id: 'page:catalog/entity', input: 'contents' }, + output: [ + coreExtensionData.reactElement, + coreExtensionData.routePath, + catalogExtensionData.entityContentTitle, + coreExtensionData.routeRef.optional(), + catalogExtensionData.entityFilterFunction.optional(), + catalogExtensionData.entityFilterExpression.optional(), + ], + dataRefs: { + title: catalogExtensionData.entityContentTitle, + filterFunction: catalogExtensionData.entityFilterFunction, + filterExpression: catalogExtensionData.entityFilterExpression, + }, + config: { + schema: { + path: z => z.string().optional(), + title: z => z.string().optional(), + filter: z => z.string().optional(), + }, + }, + *factory( + { + loader, + defaultPath, + defaultTitle, + filter, + routeRef, + }: { + loader: () => Promise; + defaultPath: string; + defaultTitle: string; + routeRef?: RouteRef; + filter?: + | typeof catalogExtensionData.entityFilterFunction.T + | typeof catalogExtensionData.entityFilterExpression.T; + }, + { node, config }, + ) { + const path = config.path ?? defaultPath; + const title = config.title ?? defaultTitle; + + const ExtensionComponent = lazy(() => + loader().then(element => ({ default: () => element })), + ); + + yield coreExtensionData.reactElement( + + + , + ); + + yield coreExtensionData.routePath(path); + + yield catalogExtensionData.entityContentTitle(title); + + if (routeRef) { + yield coreExtensionData.routeRef(routeRef); + } + + if (config.filter) { + yield catalogExtensionData.entityFilterExpression(config.filter); + } else if (typeof filter === 'string') { + yield catalogExtensionData.entityFilterExpression(filter); + } else if (typeof filter === 'function') { + yield catalogExtensionData.entityFilterFunction(filter); + } + }, +}); diff --git a/plugins/catalog-react/src/alpha/blueprints/index.ts b/plugins/catalog-react/src/alpha/blueprints/index.ts new file mode 100644 index 0000000000..dccaf28cd9 --- /dev/null +++ b/plugins/catalog-react/src/alpha/blueprints/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2024 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 { EntityCardBlueprint } from './EntityCardBlueprint'; +export { EntityContentBlueprint } from './EntityContentBlueprint'; diff --git a/plugins/catalog-react/src/alpha.tsx b/plugins/catalog-react/src/alpha/extensions.tsx similarity index 93% rename from plugins/catalog-react/src/alpha.tsx rename to plugins/catalog-react/src/alpha/extensions.tsx index 42d69726b6..fa91494bd4 100644 --- a/plugins/catalog-react/src/alpha.tsx +++ b/plugins/catalog-react/src/alpha/extensions.tsx @@ -28,13 +28,16 @@ import { import React, { lazy } from 'react'; import { Entity } from '@backstage/catalog-model'; // eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { Expand } from '../../../packages/frontend-plugin-api/src/types'; +import { Expand } from '../../../../packages/frontend-plugin-api/src/types'; -export { useEntityPermission } from './hooks/useEntityPermission'; -export { isOwnerOf } from './utils'; -export * from './translation'; +export { useEntityPermission } from '../hooks/useEntityPermission'; +export { isOwnerOf } from '../utils'; +export * from '../translation'; -/** @alpha */ +/** + * @alpha + * @deprecated use `dataRefs` on the blueprints instead + */ export const catalogExtensionData = { entityContentTitle: createExtensionDataRef().with({ id: 'catalog.entity-content-title', @@ -48,7 +51,10 @@ export const catalogExtensionData = { }; // TODO: Figure out how to merge with provided config schema -/** @alpha */ +/** + * @alpha + * @deprecated use {@link EntityCardBlueprint} instead + */ export function createEntityCardExtension< TConfig extends { filter?: string }, TInputs extends AnyExtensionInputMap, @@ -110,7 +116,10 @@ export function createEntityCardExtension< }); } -/** @alpha */ +/** + * @alpha + * @deprecated use {@link EntityContentBlueprint} instead + */ export function createEntityContentExtension< TInputs extends AnyExtensionInputMap, >(options: { diff --git a/plugins/catalog-react/src/alpha/index.ts b/plugins/catalog-react/src/alpha/index.ts new file mode 100644 index 0000000000..132b288008 --- /dev/null +++ b/plugins/catalog-react/src/alpha/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2024 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 * from './blueprints'; +export * from './extensions'; diff --git a/plugins/catalog-react/src/setupTests.ts b/plugins/catalog-react/src/setupTests.ts index 963c0f188b..dae4360fd3 100644 --- a/plugins/catalog-react/src/setupTests.ts +++ b/plugins/catalog-react/src/setupTests.ts @@ -15,3 +15,18 @@ */ import '@testing-library/jest-dom'; + +// eslint-disable-next-line no-console +const originalConsoleWarn = console.warn; +// eslint-disable-next-line no-console +console.warn = (...args: any[]) => { + const message = args[0]; + if ( + typeof message === 'string' && + (message.includes('CSSOM.parse is not a function') || + message.includes('[JSS]')) + ) { + return; + } + originalConsoleWarn(...args); +}; From 8f8519d94e227c7d0cab59c4cdddee5499cee283 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 14 Aug 2024 14:27:47 +0200 Subject: [PATCH 317/372] feat: implement search Signed-off-by: blam --- .../catalog-react/src/alpha/extensions.tsx | 2 +- plugins/search-react/src/alpha.tsx | 51 +++----- .../SearchResultListItemBlueprint.test.tsx | 123 ++++++++++++++++++ .../SearchResultListItemBlueprint.tsx | 81 ++++++++++++ plugins/search-react/src/blueprints/index.ts | 25 ++++ plugins/search-react/src/blueprints/types.ts | 42 ++++++ plugins/search-react/src/setupTests.ts | 15 +++ yarn.lock | 2 + 8 files changed, 310 insertions(+), 31 deletions(-) create mode 100644 plugins/search-react/src/blueprints/SearchResultListItemBlueprint.test.tsx create mode 100644 plugins/search-react/src/blueprints/SearchResultListItemBlueprint.tsx create mode 100644 plugins/search-react/src/blueprints/index.ts create mode 100644 plugins/search-react/src/blueprints/types.ts diff --git a/plugins/catalog-react/src/alpha/extensions.tsx b/plugins/catalog-react/src/alpha/extensions.tsx index fa91494bd4..e527edc355 100644 --- a/plugins/catalog-react/src/alpha/extensions.tsx +++ b/plugins/catalog-react/src/alpha/extensions.tsx @@ -36,7 +36,7 @@ export * from '../translation'; /** * @alpha - * @deprecated use `dataRefs` on the blueprints instead + * @deprecated use `dataRefs` property on either {@link EntityCardBlueprint} or {@link EntityContentBlueprint} instead */ export const catalogExtensionData = { entityContentTitle: createExtensionDataRef().with({ diff --git a/plugins/search-react/src/alpha.tsx b/plugins/search-react/src/alpha.tsx index a22eaf4244..53bf76f775 100644 --- a/plugins/search-react/src/alpha.tsx +++ b/plugins/search-react/src/alpha.tsx @@ -15,39 +15,25 @@ */ import React, { lazy } from 'react'; - -import { ListItemProps } from '@material-ui/core/ListItem'; - import { ExtensionBoundary, PortableSchema, createExtension, - createExtensionDataRef, createSchemaFromZod, } from '@backstage/frontend-plugin-api'; -import { SearchDocument, SearchResult } from '@backstage/plugin-search-common'; - import { SearchResultListItemExtension } from './extensions'; +import { + SearchResultItemExtensionComponent, + SearchResultItemExtensionPredicate, + searchResultListItemDataRef, +} from './blueprints/types'; -/** @alpha */ -export type BaseSearchResultListItemProps = T & { - rank?: number; - result?: SearchDocument; -} & Omit; +export * from './blueprints'; -/** @alpha */ -export type SearchResultItemExtensionComponent = < - P extends BaseSearchResultListItemProps, ->( - props: P, -) => JSX.Element | null; - -/** @alpha */ -export type SearchResultItemExtensionPredicate = ( - result: SearchResult, -) => boolean; - -/** @alpha */ +/** + * @alpha + * @deprecated Use {@link SearchResultListItemBlueprint} instead + */ export type SearchResultItemExtensionOptions< TConfig extends { noTrack?: boolean }, > = { @@ -80,7 +66,12 @@ export type SearchResultItemExtensionOptions< predicate?: SearchResultItemExtensionPredicate; }; -/** @alpha */ +/** + * Creates items for the search result list. + * + * @alpha + * @deprecated Use {@link SearchResultListItemBlueprint} instead + */ export function createSearchResultListItemExtension< TConfig extends { noTrack?: boolean }, >(options: SearchResultItemExtensionOptions) { @@ -132,10 +123,10 @@ export function createSearchResultListItemExtension< }); } -/** @alpha */ +/** + * @alpha + * @deprecated Use {@link SearchResultListItemBlueprint} instead + */ export namespace createSearchResultListItemExtension { - export const itemDataRef = createExtensionDataRef<{ - predicate?: SearchResultItemExtensionPredicate; - component: SearchResultItemExtensionComponent; - }>().with({ id: 'search.search-result-list-item.item' }); + export const itemDataRef = searchResultListItemDataRef; } diff --git a/plugins/search-react/src/blueprints/SearchResultListItemBlueprint.test.tsx b/plugins/search-react/src/blueprints/SearchResultListItemBlueprint.test.tsx new file mode 100644 index 0000000000..4f3b7501b4 --- /dev/null +++ b/plugins/search-react/src/blueprints/SearchResultListItemBlueprint.test.tsx @@ -0,0 +1,123 @@ +/* + * Copyright 2024 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 { SearchResultListItemBlueprint } from './SearchResultListItemBlueprint'; +import { createExtensionTester } from '@backstage/frontend-test-utils'; +import { + PageBlueprint, + createExtensionInput, +} from '@backstage/frontend-plugin-api'; +import { searchResultListItemDataRef } from './types'; +import _ from 'lodash'; + +describe('SearchResultListItemBlueprint', () => { + it('should return an extension with sane defaults', () => { + const extension = SearchResultListItemBlueprint.make({ + name: 'test', + params: { + component: async () => () =>
    Hello
    , + predicate: () => true, + }, + }); + + expect(extension).toMatchInlineSnapshot(` + { + "$$type": "@backstage/ExtensionDefinition", + "attachTo": { + "id": "page:search", + "input": "items", + }, + "configSchema": { + "parse": [Function], + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "additionalProperties": false, + "properties": { + "noTrack": { + "default": false, + "type": "boolean", + }, + }, + "type": "object", + }, + }, + "disabled": false, + "factory": [Function], + "inputs": {}, + "kind": "search-result-list-item", + "name": "test", + "namespace": undefined, + "output": [ + [Function], + ], + "override": [Function], + "toString": [Function], + "version": "v2", + } + `); + }); + + it('defaults and passes on config properly', async () => { + const extension = SearchResultListItemBlueprint.make({ + name: 'test', + params: { + component: + async ({ config: { noTrack } }) => + () => +
    noTrack: {String(noTrack)}
    , + }, + }); + + const mockSearchPage = PageBlueprint.makeWithOverrides({ + namespace: 'search', + inputs: { + items: createExtensionInput([searchResultListItemDataRef]), + }, + factory(originalFactory, { inputs }) { + return originalFactory({ + defaultPath: '/', + loader: async () => { + const items = inputs.items.map(i => + i.get(searchResultListItemDataRef), + ); + return ( +
    + {items.map((item, i) => ( + + ))} +
    + ); + }, + }); + }, + }); + + await expect( + createExtensionTester(mockSearchPage) + .add(extension) + .render() + .findByText('noTrack: false'), + ).resolves.toBeInTheDocument(); + + await expect( + createExtensionTester(mockSearchPage) + .add(extension, { config: { noTrack: true } }) + .render() + .findByText('noTrack: true'), + ).resolves.toBeInTheDocument(); + }); +}); diff --git a/plugins/search-react/src/blueprints/SearchResultListItemBlueprint.tsx b/plugins/search-react/src/blueprints/SearchResultListItemBlueprint.tsx new file mode 100644 index 0000000000..bea52b7f45 --- /dev/null +++ b/plugins/search-react/src/blueprints/SearchResultListItemBlueprint.tsx @@ -0,0 +1,81 @@ +/* + * Copyright 2024 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, { lazy } from 'react'; +import { + createExtensionBlueprint, + ExtensionBoundary, +} from '@backstage/frontend-plugin-api'; +import { + SearchResultItemExtensionComponent, + SearchResultItemExtensionPredicate, + searchResultListItemDataRef, +} from './types'; +import { + SearchResultListItemExtension, + SearchResultListItemExtensionProps, +} from '../extensions'; + +export interface SearchResultListItemBlueprintParams { + /** + * The extension component. + */ + component: (options: { + config: { noTrack?: boolean }; + }) => Promise; + /** + * When an extension defines a predicate, it returns true if the result should be rendered by that extension. + * Defaults to a predicate that returns true, which means it renders all sorts of results. + */ + predicate?: SearchResultItemExtensionPredicate; +} + +export const SearchResultListItemBlueprint = createExtensionBlueprint({ + kind: 'search-result-list-item', + attachTo: { + id: 'page:search', + input: 'items', + }, + config: { + schema: { + noTrack: z => z.boolean().default(false), + }, + }, + output: [searchResultListItemDataRef], + dataRefs: { + item: searchResultListItemDataRef, + }, + *factory(params: SearchResultListItemBlueprintParams, { config, node }) { + const ExtensionComponent = lazy(() => + params.component({ config }).then(component => ({ default: component })), + ); + + yield searchResultListItemDataRef({ + predicate: params.predicate, + component: (props: SearchResultListItemExtensionProps) => ( + + + + + + ), + }); + }, +}); diff --git a/plugins/search-react/src/blueprints/index.ts b/plugins/search-react/src/blueprints/index.ts new file mode 100644 index 0000000000..b9bbf1012e --- /dev/null +++ b/plugins/search-react/src/blueprints/index.ts @@ -0,0 +1,25 @@ +/* + * Copyright 2024 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 { + SearchResultListItemBlueprint, + type SearchResultListItemBlueprintParams, +} from './SearchResultListItemBlueprint'; +export { + type BaseSearchResultListItemProps, + type SearchResultItemExtensionComponent, + type SearchResultItemExtensionPredicate, +} from './types'; diff --git a/plugins/search-react/src/blueprints/types.ts b/plugins/search-react/src/blueprints/types.ts new file mode 100644 index 0000000000..abfed4aba6 --- /dev/null +++ b/plugins/search-react/src/blueprints/types.ts @@ -0,0 +1,42 @@ +/* + * Copyright 2024 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 { ListItemProps } from '@material-ui/core/ListItem'; +import { SearchDocument, SearchResult } from '@backstage/plugin-search-common'; +import { createExtensionDataRef } from '@backstage/frontend-plugin-api'; + +/** @alpha */ +export type BaseSearchResultListItemProps = T & { + rank?: number; + result?: SearchDocument; +} & Omit; + +/** @alpha */ +export type SearchResultItemExtensionComponent = < + P extends BaseSearchResultListItemProps, +>( + props: P, +) => JSX.Element | null; + +/** @alpha */ +export type SearchResultItemExtensionPredicate = ( + result: SearchResult, +) => boolean; + +export const searchResultListItemDataRef = createExtensionDataRef<{ + predicate?: SearchResultItemExtensionPredicate; + component: SearchResultItemExtensionComponent; +}>().with({ id: 'search.search-result-list-item.item' }); diff --git a/plugins/search-react/src/setupTests.ts b/plugins/search-react/src/setupTests.ts index 992b60d3a4..c47fc7a427 100644 --- a/plugins/search-react/src/setupTests.ts +++ b/plugins/search-react/src/setupTests.ts @@ -15,3 +15,18 @@ */ import '@testing-library/jest-dom'; + +// eslint-disable-next-line no-console +const originalConsoleWarn = console.warn; +// eslint-disable-next-line no-console +console.warn = (...args: any[]) => { + const message = args[0]; + if ( + typeof message === 'string' && + (message.includes('CSSOM.parse is not a function') || + message.includes('[JSS]')) + ) { + return; + } + originalConsoleWarn(...args); +}; diff --git a/yarn.lock b/yarn.lock index 9c292f5903..dea942a3b4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5921,6 +5921,7 @@ __metadata: "@backstage/core-plugin-api": "workspace:^" "@backstage/errors": "workspace:^" "@backstage/frontend-plugin-api": "workspace:^" + "@backstage/frontend-test-utils": "workspace:^" "@backstage/integration-react": "workspace:^" "@backstage/plugin-catalog-common": "workspace:^" "@backstage/plugin-permission-common": "workspace:^" @@ -6001,6 +6002,7 @@ __metadata: "@backstage/dev-utils": "workspace:^" "@backstage/errors": "workspace:^" "@backstage/frontend-plugin-api": "workspace:^" + "@backstage/frontend-test-utils": "workspace:^" "@backstage/integration-react": "workspace:^" "@backstage/plugin-catalog-common": "workspace:^" "@backstage/plugin-catalog-react": "workspace:^" From 4c39af89021284494227c9b03fd982241c54ea2c Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 14 Aug 2024 14:44:13 +0200 Subject: [PATCH 318/372] feat: small refactor for the search package MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fredrik Adelöw Signed-off-by: blam --- plugins/catalog-react/api-report-alpha.md | 120 +++++- plugins/catalog/api-report-alpha.md | 365 +++++++++++++++++- plugins/search-react/api-report-alpha.md | 52 ++- plugins/search-react/package.json | 4 +- .../SearchResultListItemBlueprint.test.tsx | 0 .../SearchResultListItemBlueprint.tsx | 7 +- .../src/{ => alpha}/blueprints/index.ts | 0 .../src/{ => alpha}/blueprints/types.ts | 0 .../extensions.test.tsx} | 6 +- .../src/{alpha.tsx => alpha/extensions.tsx} | 11 +- plugins/search-react/src/alpha/index.ts | 17 + 11 files changed, 561 insertions(+), 21 deletions(-) rename plugins/search-react/src/{ => alpha}/blueprints/SearchResultListItemBlueprint.test.tsx (100%) rename plugins/search-react/src/{ => alpha}/blueprints/SearchResultListItemBlueprint.tsx (96%) rename plugins/search-react/src/{ => alpha}/blueprints/index.ts (100%) rename plugins/search-react/src/{ => alpha}/blueprints/types.ts (100%) rename plugins/search-react/src/{alpha.test.tsx => alpha/extensions.test.tsx} (97%) rename plugins/search-react/src/{alpha.tsx => alpha/extensions.tsx} (93%) create mode 100644 plugins/search-react/src/alpha/index.ts diff --git a/plugins/catalog-react/api-report-alpha.md b/plugins/catalog-react/api-report-alpha.md index edfa183903..f3d251dd0e 100644 --- a/plugins/catalog-react/api-report-alpha.md +++ b/plugins/catalog-react/api-report-alpha.md @@ -6,16 +6,19 @@ /// import { AnyExtensionInputMap } from '@backstage/frontend-plugin-api'; +import { AnyRouteRefParams } from '@backstage/frontend-plugin-api'; import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api'; import { Entity } from '@backstage/catalog-model'; +import { ExtensionBlueprint } from '@backstage/frontend-plugin-api'; import { ExtensionDefinition } from '@backstage/frontend-plugin-api'; import { PortableSchema } from '@backstage/frontend-plugin-api'; +import { default as React_2 } from 'react'; import { ResolvedExtensionInputs } from '@backstage/frontend-plugin-api'; import { ResourcePermission } from '@backstage/plugin-permission-common'; import { RouteRef } from '@backstage/frontend-plugin-api'; import { TranslationRef } from '@backstage/core-plugin-api/alpha'; -// @alpha (undocumented) +// @alpha @deprecated (undocumented) export const catalogExtensionData: { entityContentTitle: ConfigurableExtensionDataRef< string, @@ -92,7 +95,7 @@ export const catalogReactTranslationRef: TranslationRef< } >; -// @alpha (undocumented) +// @alpha @deprecated (undocumented) export function createEntityCardExtension< TConfig extends { filter?: string; @@ -125,7 +128,7 @@ export function createEntityCardExtension< string | undefined >; -// @alpha (undocumented) +// @alpha @deprecated (undocumented) export function createEntityContentExtension< TInputs extends AnyExtensionInputMap, >(options: { @@ -164,6 +167,117 @@ export function createEntityContentExtension< string | undefined >; +// @alpha +export const EntityCardBlueprint: ExtensionBlueprint< + 'entity-card', + undefined, + undefined, + { + loader: () => Promise; + filter?: string | ((entity: Entity) => boolean) | undefined; + }, + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + ((entity: Entity) => boolean) & { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + string & { + optional: true; + } + >, + {}, + { + filter: string | undefined; + }, + { + filter?: string | undefined; + }, + { + filterFunction: ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + {} + >; + filterExpression: ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + {} + >; + } +>; + +// @alpha +export const EntityContentBlueprint: ExtensionBlueprint< + 'entity-content', + undefined, + undefined, + { + loader: () => Promise; + defaultPath: string; + defaultTitle: string; + routeRef?: RouteRef | undefined; + filter?: string | ((entity: Entity) => boolean) | undefined; + }, + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + RouteRef, + 'core.routing.ref', + RouteRef & { + optional: true; + } + > + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + ((entity: Entity) => boolean) & { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + string & { + optional: true; + } + >, + {}, + { + path: string | undefined; + title: string | undefined; + filter: string | undefined; + }, + { + filter?: string | undefined; + title?: string | undefined; + path?: string | undefined; + }, + { + title: ConfigurableExtensionDataRef< + string, + 'catalog.entity-content-title', + {} + >; + filterFunction: ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + {} + >; + filterExpression: ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + {} + >; + } +>; + // @alpha export function isOwnerOf(owner: Entity, entity: Entity): boolean; diff --git a/plugins/catalog/api-report-alpha.md b/plugins/catalog/api-report-alpha.md index 5019fc25ea..7c2f490939 100644 --- a/plugins/catalog/api-report-alpha.md +++ b/plugins/catalog/api-report-alpha.md @@ -6,13 +6,35 @@ /// import { AnyExtensionInputMap } from '@backstage/frontend-plugin-api'; +import { AnyRouteRefParams } from '@backstage/frontend-plugin-api'; import { BackstagePlugin } from '@backstage/frontend-plugin-api'; +import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api'; +import { Entity } from '@backstage/catalog-model'; +import { ExtensionBlueprint } from '@backstage/frontend-plugin-api'; import { ExtensionDefinition } from '@backstage/frontend-plugin-api'; +import { ExtensionInput } from '@backstage/frontend-plugin-api'; import { ExternalRouteRef } from '@backstage/frontend-plugin-api'; +import { JSX as JSX_2 } from 'react'; import { PortableSchema } from '@backstage/frontend-plugin-api'; +import { default as React_2 } from 'react'; import { RouteRef } from '@backstage/frontend-plugin-api'; import { TranslationRef } from '@backstage/core-plugin-api/alpha'; +// @alpha +export const CatalogFilterBlueprint: ExtensionBlueprint< + 'catalog-filter', + undefined, + undefined, + { + loader: () => Promise; + }, + ConfigurableExtensionDataRef, + {}, + {}, + {}, + never +>; + // @alpha (undocumented) export const catalogTranslationRef: TranslationRef< 'catalog', @@ -98,7 +120,9 @@ export const catalogTranslationRef: TranslationRef< } >; -// @alpha (undocumented) +// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@backstage/plugin-catalog" does not have an export "CatalogFilterExtensionBlueprint" +// +// @alpha @deprecated (undocumented) export function createCatalogFilterExtension< TInputs extends AnyExtensionInputMap, TConfig, @@ -141,7 +165,344 @@ const _default: BackstagePlugin< }>; unregisterRedirect: ExternalRouteRef; }, - {} + { + 'entity-card:catalog/about': ExtensionDefinition< + { + filter: string | undefined; + }, + { + filter?: string | undefined; + }, + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + ((entity: Entity) => boolean) & { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + string & { + optional: true; + } + >, + {}, + 'entity-card', + undefined, + 'about' + >; + 'entity-card:catalog/links': ExtensionDefinition< + { + filter: string | undefined; + }, + { + filter?: string | undefined; + }, + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + ((entity: Entity) => boolean) & { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + string & { + optional: true; + } + >, + {}, + 'entity-card', + undefined, + 'links' + >; + 'entity-card:catalog/labels': ExtensionDefinition< + { + filter: string | undefined; + }, + { + filter?: string | undefined; + }, + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + ((entity: Entity) => boolean) & { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + string & { + optional: true; + } + >, + {}, + 'entity-card', + undefined, + 'labels' + >; + 'entity-card:catalog/depends-on-components': ExtensionDefinition< + { + filter: string | undefined; + }, + { + filter?: string | undefined; + }, + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + ((entity: Entity) => boolean) & { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + string & { + optional: true; + } + >, + {}, + 'entity-card', + undefined, + 'depends-on-components' + >; + 'entity-card:catalog/depends-on-resources': ExtensionDefinition< + { + filter: string | undefined; + }, + { + filter?: string | undefined; + }, + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + ((entity: Entity) => boolean) & { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + string & { + optional: true; + } + >, + {}, + 'entity-card', + undefined, + 'depends-on-resources' + >; + 'entity-card:catalog/has-components': ExtensionDefinition< + { + filter: string | undefined; + }, + { + filter?: string | undefined; + }, + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + ((entity: Entity) => boolean) & { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + string & { + optional: true; + } + >, + {}, + 'entity-card', + undefined, + 'has-components' + >; + 'entity-card:catalog/has-resources': ExtensionDefinition< + { + filter: string | undefined; + }, + { + filter?: string | undefined; + }, + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + ((entity: Entity) => boolean) & { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + string & { + optional: true; + } + >, + {}, + 'entity-card', + undefined, + 'has-resources' + >; + 'entity-card:catalog/has-subcomponents': ExtensionDefinition< + { + filter: string | undefined; + }, + { + filter?: string | undefined; + }, + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + ((entity: Entity) => boolean) & { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + string & { + optional: true; + } + >, + {}, + 'entity-card', + undefined, + 'has-subcomponents' + >; + 'entity-card:catalog/has-subdomains': ExtensionDefinition< + { + filter: string | undefined; + }, + { + filter?: string | undefined; + }, + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + ((entity: Entity) => boolean) & { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + string & { + optional: true; + } + >, + {}, + 'entity-card', + undefined, + 'has-subdomains' + >; + 'entity-card:catalog/has-systems': ExtensionDefinition< + { + filter: string | undefined; + }, + { + filter?: string | undefined; + }, + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + ((entity: Entity) => boolean) & { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + string & { + optional: true; + } + >, + {}, + 'entity-card', + undefined, + 'has-systems' + >; + 'entity-content:catalog/overview': ExtensionDefinition< + { + [x: string]: any; + } & { + path: string | undefined; + title: string | undefined; + filter: string | undefined; + }, + { + [x: string]: any; + } & { + filter?: string | undefined; + title?: string | undefined; + path?: string | undefined; + }, + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + RouteRef, + 'core.routing.ref', + RouteRef & { + optional: true; + } + > + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + ((entity: Entity) => boolean) & { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + string & { + optional: true; + } + >, + { + cards: ExtensionInput< + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + ((entity: Entity) => boolean) & { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + string & { + optional: true; + } + >, + { + singleton: false; + optional: false; + } + >; + }, + 'entity-content', + undefined, + 'overview' + >; + } >; export default _default; diff --git a/plugins/search-react/api-report-alpha.md b/plugins/search-react/api-report-alpha.md index 4bcdbb3f78..0126fdc590 100644 --- a/plugins/search-react/api-report-alpha.md +++ b/plugins/search-react/api-report-alpha.md @@ -6,6 +6,7 @@ /// import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api'; +import { ExtensionBlueprint } from '@backstage/frontend-plugin-api'; import { ExtensionDefinition } from '@backstage/frontend-plugin-api'; import { ListItemProps } from '@material-ui/core/ListItem'; import { PortableSchema } from '@backstage/frontend-plugin-api'; @@ -18,7 +19,7 @@ export type BaseSearchResultListItemProps = T & { result?: SearchDocument; } & Omit; -// @alpha (undocumented) +// @alpha @deprecated export function createSearchResultListItemExtension< TConfig extends { noTrack?: boolean; @@ -35,9 +36,9 @@ export function createSearchResultListItemExtension< string | undefined >; -// @alpha (undocumented) +// @alpha @deprecated (undocumented) export namespace createSearchResultListItemExtension { - const // (undocumented) + const // @deprecated (undocumented) itemDataRef: ConfigurableExtensionDataRef< { predicate?: SearchResultItemExtensionPredicate | undefined; @@ -55,7 +56,7 @@ export type SearchResultItemExtensionComponent = < props: P, ) => JSX.Element | null; -// @alpha (undocumented) +// @alpha @deprecated (undocumented) export type SearchResultItemExtensionOptions< TConfig extends { noTrack?: boolean; @@ -79,5 +80,48 @@ export type SearchResultItemExtensionPredicate = ( result: SearchResult, ) => boolean; +// @alpha +export const SearchResultListItemBlueprint: ExtensionBlueprint< + 'search-result-list-item', + undefined, + undefined, + SearchResultListItemBlueprintParams, + ConfigurableExtensionDataRef< + { + predicate?: SearchResultItemExtensionPredicate | undefined; + component: SearchResultItemExtensionComponent; + }, + 'search.search-result-list-item.item', + {} + >, + {}, + { + noTrack: boolean; + }, + { + noTrack?: boolean | undefined; + }, + { + item: ConfigurableExtensionDataRef< + { + predicate?: SearchResultItemExtensionPredicate | undefined; + component: SearchResultItemExtensionComponent; + }, + 'search.search-result-list-item.item', + {} + >; + } +>; + +// @alpha (undocumented) +export interface SearchResultListItemBlueprintParams { + component: (options: { + config: { + noTrack?: boolean; + }; + }) => Promise; + predicate?: SearchResultItemExtensionPredicate; +} + // (No @packageDocumentation comment for this package) ``` diff --git a/plugins/search-react/package.json b/plugins/search-react/package.json index e16430c55b..887b41cb83 100644 --- a/plugins/search-react/package.json +++ b/plugins/search-react/package.json @@ -28,7 +28,7 @@ "sideEffects": false, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.tsx", + "./alpha": "./src/alpha/index.ts", "./package.json": "./package.json" }, "main": "src/index.ts", @@ -36,7 +36,7 @@ "typesVersions": { "*": { "alpha": [ - "src/alpha.tsx" + "src/alpha/index.ts" ], "package.json": [ "package.json" diff --git a/plugins/search-react/src/blueprints/SearchResultListItemBlueprint.test.tsx b/plugins/search-react/src/alpha/blueprints/SearchResultListItemBlueprint.test.tsx similarity index 100% rename from plugins/search-react/src/blueprints/SearchResultListItemBlueprint.test.tsx rename to plugins/search-react/src/alpha/blueprints/SearchResultListItemBlueprint.test.tsx diff --git a/plugins/search-react/src/blueprints/SearchResultListItemBlueprint.tsx b/plugins/search-react/src/alpha/blueprints/SearchResultListItemBlueprint.tsx similarity index 96% rename from plugins/search-react/src/blueprints/SearchResultListItemBlueprint.tsx rename to plugins/search-react/src/alpha/blueprints/SearchResultListItemBlueprint.tsx index bea52b7f45..b9a7b71719 100644 --- a/plugins/search-react/src/blueprints/SearchResultListItemBlueprint.tsx +++ b/plugins/search-react/src/alpha/blueprints/SearchResultListItemBlueprint.tsx @@ -27,8 +27,9 @@ import { import { SearchResultListItemExtension, SearchResultListItemExtensionProps, -} from '../extensions'; +} from '../../extensions'; +/** @alpha */ export interface SearchResultListItemBlueprintParams { /** * The extension component. @@ -43,6 +44,10 @@ export interface SearchResultListItemBlueprintParams { predicate?: SearchResultItemExtensionPredicate; } +/** + * @alpha + * Creates SearchResultListItem extensions + */ export const SearchResultListItemBlueprint = createExtensionBlueprint({ kind: 'search-result-list-item', attachTo: { diff --git a/plugins/search-react/src/blueprints/index.ts b/plugins/search-react/src/alpha/blueprints/index.ts similarity index 100% rename from plugins/search-react/src/blueprints/index.ts rename to plugins/search-react/src/alpha/blueprints/index.ts diff --git a/plugins/search-react/src/blueprints/types.ts b/plugins/search-react/src/alpha/blueprints/types.ts similarity index 100% rename from plugins/search-react/src/blueprints/types.ts rename to plugins/search-react/src/alpha/blueprints/types.ts diff --git a/plugins/search-react/src/alpha.test.tsx b/plugins/search-react/src/alpha/extensions.test.tsx similarity index 97% rename from plugins/search-react/src/alpha.test.tsx rename to plugins/search-react/src/alpha/extensions.test.tsx index 6d77b5af97..5194fadd1c 100644 --- a/plugins/search-react/src/alpha.test.tsx +++ b/plugins/search-react/src/alpha/extensions.test.tsx @@ -23,10 +23,8 @@ import { createExtensionTester } from '@backstage/frontend-test-utils'; import { SearchResult } from '@backstage/plugin-search-common'; import { screen } from '@testing-library/react'; import React from 'react'; -import { - BaseSearchResultListItemProps, - createSearchResultListItemExtension, -} from './alpha'; +import { createSearchResultListItemExtension } from './extensions'; +import { BaseSearchResultListItemProps } from './blueprints'; describe('createSearchResultListItemExtension', () => { it('Should use the correct result component', async () => { diff --git a/plugins/search-react/src/alpha.tsx b/plugins/search-react/src/alpha/extensions.tsx similarity index 93% rename from plugins/search-react/src/alpha.tsx rename to plugins/search-react/src/alpha/extensions.tsx index 53bf76f775..db09510a1e 100644 --- a/plugins/search-react/src/alpha.tsx +++ b/plugins/search-react/src/alpha/extensions.tsx @@ -21,14 +21,12 @@ import { createExtension, createSchemaFromZod, } from '@backstage/frontend-plugin-api'; -import { SearchResultListItemExtension } from './extensions'; import { SearchResultItemExtensionComponent, SearchResultItemExtensionPredicate, - searchResultListItemDataRef, -} from './blueprints/types'; - -export * from './blueprints'; +} from './blueprints'; +import { SearchResultListItemExtension } from '../extensions'; +import { searchResultListItemDataRef } from './blueprints/types'; /** * @alpha @@ -128,5 +126,8 @@ export function createSearchResultListItemExtension< * @deprecated Use {@link SearchResultListItemBlueprint} instead */ export namespace createSearchResultListItemExtension { + /** + * @deprecated Use {@link SearchResultListItemBlueprint#dataRefs.item} instead + */ export const itemDataRef = searchResultListItemDataRef; } diff --git a/plugins/search-react/src/alpha/index.ts b/plugins/search-react/src/alpha/index.ts new file mode 100644 index 0000000000..04026d629d --- /dev/null +++ b/plugins/search-react/src/alpha/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2024 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 * from './extensions'; +export * from './blueprints'; From 7bd27e1743039fcb0405330f355bc669f4675979 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 14 Aug 2024 14:45:34 +0200 Subject: [PATCH 319/372] chore: changeset Signed-off-by: blam --- .changeset/curly-cars-relax.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changeset/curly-cars-relax.md diff --git a/.changeset/curly-cars-relax.md b/.changeset/curly-cars-relax.md new file mode 100644 index 0000000000..de1b4c3d89 --- /dev/null +++ b/.changeset/curly-cars-relax.md @@ -0,0 +1,7 @@ +--- +'@backstage/plugin-catalog-react': patch +'@backstage/plugin-search-react': patch +'@backstage/plugin-catalog': patch +--- + +Deprecate the old pattern of `create*Extension`, and replace it with the equivalent Blueprint implementation instead. From 896a84bce572dbf0789d72581d3ca109f9b178c1 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 14 Aug 2024 14:49:51 +0200 Subject: [PATCH 320/372] chore: small fix Signed-off-by: blam --- plugins/catalog/api-report-alpha.md | 2 -- plugins/catalog/src/alpha/createCatalogFilterExtension.tsx | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/catalog/api-report-alpha.md b/plugins/catalog/api-report-alpha.md index 7c2f490939..57560ad6a0 100644 --- a/plugins/catalog/api-report-alpha.md +++ b/plugins/catalog/api-report-alpha.md @@ -120,8 +120,6 @@ export const catalogTranslationRef: TranslationRef< } >; -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@backstage/plugin-catalog" does not have an export "CatalogFilterExtensionBlueprint" -// // @alpha @deprecated (undocumented) export function createCatalogFilterExtension< TInputs extends AnyExtensionInputMap, diff --git a/plugins/catalog/src/alpha/createCatalogFilterExtension.tsx b/plugins/catalog/src/alpha/createCatalogFilterExtension.tsx index eb6d58f424..85d911ef3b 100644 --- a/plugins/catalog/src/alpha/createCatalogFilterExtension.tsx +++ b/plugins/catalog/src/alpha/createCatalogFilterExtension.tsx @@ -25,7 +25,7 @@ import { /** * @alpha - * @deprecated Use {@link CatalogFilterExtensionBlueprint} instead + * @deprecated Use {@link CatalogFilterBlueprint} instead */ export function createCatalogFilterExtension< TInputs extends AnyExtensionInputMap, From 45a469fc3bd4ebe703cf8af5a9ebc9ec6aa402f9 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 14 Aug 2024 16:25:56 +0200 Subject: [PATCH 321/372] chore: update apireports Signed-off-by: blam --- plugins/catalog-react/api-report-alpha.md | 10 ++--- plugins/catalog/api-report-alpha.md | 50 +++++++++++------------ 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/plugins/catalog-react/api-report-alpha.md b/plugins/catalog-react/api-report-alpha.md index f3d251dd0e..c5dc632946 100644 --- a/plugins/catalog-react/api-report-alpha.md +++ b/plugins/catalog-react/api-report-alpha.md @@ -180,14 +180,14 @@ export const EntityCardBlueprint: ExtensionBlueprint< | ConfigurableExtensionDataRef< (entity: Entity) => boolean, 'catalog.entity-filter-function', - ((entity: Entity) => boolean) & { + { optional: true; } > | ConfigurableExtensionDataRef< string, 'catalog.entity-filter-expression', - string & { + { optional: true; } >, @@ -229,7 +229,7 @@ export const EntityContentBlueprint: ExtensionBlueprint< | ConfigurableExtensionDataRef< RouteRef, 'core.routing.ref', - RouteRef & { + { optional: true; } > @@ -237,14 +237,14 @@ export const EntityContentBlueprint: ExtensionBlueprint< | ConfigurableExtensionDataRef< (entity: Entity) => boolean, 'catalog.entity-filter-function', - ((entity: Entity) => boolean) & { + { optional: true; } > | ConfigurableExtensionDataRef< string, 'catalog.entity-filter-expression', - string & { + { optional: true; } >, diff --git a/plugins/catalog/api-report-alpha.md b/plugins/catalog/api-report-alpha.md index 57560ad6a0..399580d6a2 100644 --- a/plugins/catalog/api-report-alpha.md +++ b/plugins/catalog/api-report-alpha.md @@ -175,14 +175,14 @@ const _default: BackstagePlugin< | ConfigurableExtensionDataRef< (entity: Entity) => boolean, 'catalog.entity-filter-function', - ((entity: Entity) => boolean) & { + { optional: true; } > | ConfigurableExtensionDataRef< string, 'catalog.entity-filter-expression', - string & { + { optional: true; } >, @@ -202,14 +202,14 @@ const _default: BackstagePlugin< | ConfigurableExtensionDataRef< (entity: Entity) => boolean, 'catalog.entity-filter-function', - ((entity: Entity) => boolean) & { + { optional: true; } > | ConfigurableExtensionDataRef< string, 'catalog.entity-filter-expression', - string & { + { optional: true; } >, @@ -229,14 +229,14 @@ const _default: BackstagePlugin< | ConfigurableExtensionDataRef< (entity: Entity) => boolean, 'catalog.entity-filter-function', - ((entity: Entity) => boolean) & { + { optional: true; } > | ConfigurableExtensionDataRef< string, 'catalog.entity-filter-expression', - string & { + { optional: true; } >, @@ -256,14 +256,14 @@ const _default: BackstagePlugin< | ConfigurableExtensionDataRef< (entity: Entity) => boolean, 'catalog.entity-filter-function', - ((entity: Entity) => boolean) & { + { optional: true; } > | ConfigurableExtensionDataRef< string, 'catalog.entity-filter-expression', - string & { + { optional: true; } >, @@ -283,14 +283,14 @@ const _default: BackstagePlugin< | ConfigurableExtensionDataRef< (entity: Entity) => boolean, 'catalog.entity-filter-function', - ((entity: Entity) => boolean) & { + { optional: true; } > | ConfigurableExtensionDataRef< string, 'catalog.entity-filter-expression', - string & { + { optional: true; } >, @@ -310,14 +310,14 @@ const _default: BackstagePlugin< | ConfigurableExtensionDataRef< (entity: Entity) => boolean, 'catalog.entity-filter-function', - ((entity: Entity) => boolean) & { + { optional: true; } > | ConfigurableExtensionDataRef< string, 'catalog.entity-filter-expression', - string & { + { optional: true; } >, @@ -337,14 +337,14 @@ const _default: BackstagePlugin< | ConfigurableExtensionDataRef< (entity: Entity) => boolean, 'catalog.entity-filter-function', - ((entity: Entity) => boolean) & { + { optional: true; } > | ConfigurableExtensionDataRef< string, 'catalog.entity-filter-expression', - string & { + { optional: true; } >, @@ -364,14 +364,14 @@ const _default: BackstagePlugin< | ConfigurableExtensionDataRef< (entity: Entity) => boolean, 'catalog.entity-filter-function', - ((entity: Entity) => boolean) & { + { optional: true; } > | ConfigurableExtensionDataRef< string, 'catalog.entity-filter-expression', - string & { + { optional: true; } >, @@ -391,14 +391,14 @@ const _default: BackstagePlugin< | ConfigurableExtensionDataRef< (entity: Entity) => boolean, 'catalog.entity-filter-function', - ((entity: Entity) => boolean) & { + { optional: true; } > | ConfigurableExtensionDataRef< string, 'catalog.entity-filter-expression', - string & { + { optional: true; } >, @@ -418,14 +418,14 @@ const _default: BackstagePlugin< | ConfigurableExtensionDataRef< (entity: Entity) => boolean, 'catalog.entity-filter-function', - ((entity: Entity) => boolean) & { + { optional: true; } > | ConfigurableExtensionDataRef< string, 'catalog.entity-filter-expression', - string & { + { optional: true; } >, @@ -454,7 +454,7 @@ const _default: BackstagePlugin< | ConfigurableExtensionDataRef< RouteRef, 'core.routing.ref', - RouteRef & { + { optional: true; } > @@ -462,14 +462,14 @@ const _default: BackstagePlugin< | ConfigurableExtensionDataRef< (entity: Entity) => boolean, 'catalog.entity-filter-function', - ((entity: Entity) => boolean) & { + { optional: true; } > | ConfigurableExtensionDataRef< string, 'catalog.entity-filter-expression', - string & { + { optional: true; } >, @@ -479,14 +479,14 @@ const _default: BackstagePlugin< | ConfigurableExtensionDataRef< (entity: Entity) => boolean, 'catalog.entity-filter-function', - ((entity: Entity) => boolean) & { + { optional: true; } > | ConfigurableExtensionDataRef< string, 'catalog.entity-filter-expression', - string & { + { optional: true; } >, From 954a5939db56fc12d3cdc4f3ab6c03e1e71f945f Mon Sep 17 00:00:00 2001 From: Deepankumar Date: Thu, 15 Aug 2024 10:10:48 +0200 Subject: [PATCH 322/372] Liveness probe added in ContainerCard component (#25958) * Liveness probe added in ContainerCard component Signed-off-by: Deepankumar Loganathan * liveness probe shows only if available Signed-off-by: Deepankumar Loganathan * changed return object from variable Signed-off-by: Deepankumar Loganathan --------- Signed-off-by: Deepankumar Loganathan --- .changeset/eight-moose-pull.md | 5 ++++ .../Pods/PodDrawer/ContainerCard.test.tsx | 1 + .../Pods/PodDrawer/ContainerCard.tsx | 27 +++++++++++-------- 3 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 .changeset/eight-moose-pull.md diff --git a/.changeset/eight-moose-pull.md b/.changeset/eight-moose-pull.md new file mode 100644 index 0000000000..c5bc5ee66e --- /dev/null +++ b/.changeset/eight-moose-pull.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-kubernetes-react': patch +--- + +`Liveness Probe` added in ContainerCard Component of PodDrawer diff --git a/plugins/kubernetes-react/src/components/Pods/PodDrawer/ContainerCard.test.tsx b/plugins/kubernetes-react/src/components/Pods/PodDrawer/ContainerCard.test.tsx index 6d64b8ad5b..3b131a617c 100644 --- a/plugins/kubernetes-react/src/components/Pods/PodDrawer/ContainerCard.test.tsx +++ b/plugins/kubernetes-react/src/components/Pods/PodDrawer/ContainerCard.test.tsx @@ -40,6 +40,7 @@ describe('ContainerCard', () => { }, containerSpec: { readinessProbe: {}, + livenessProbe: {}, }, containerStatus: { name: 'some-name', diff --git a/plugins/kubernetes-react/src/components/Pods/PodDrawer/ContainerCard.tsx b/plugins/kubernetes-react/src/components/Pods/PodDrawer/ContainerCard.tsx index cabda69b2c..1919bc112d 100644 --- a/plugins/kubernetes-react/src/components/Pods/PodDrawer/ContainerCard.tsx +++ b/plugins/kubernetes-react/src/components/Pods/PodDrawer/ContainerCard.tsx @@ -35,20 +35,25 @@ const getContainerHealthChecks = ( containerSpec: IContainer, containerStatus: IContainerStatus, ): { [key: string]: boolean } => { - if (containerStatus.state?.terminated?.reason === 'Completed') { - return { - 'not waiting to start': containerStatus.state?.waiting === undefined, - 'no restarts': containerStatus.restartCount === 0, - }; - } - return { + const healthCheck = { 'not waiting to start': containerStatus.state?.waiting === undefined, - started: !!containerStatus.started, - ready: containerStatus.ready, 'no restarts': containerStatus.restartCount === 0, - 'readiness probe set': - containerSpec && containerSpec?.readinessProbe !== undefined, }; + if (containerStatus.state?.terminated?.reason === 'Completed') { + return healthCheck; + } + Object.assign( + healthCheck, + { started: !!containerStatus.started }, + { ready: containerStatus.ready }, + { 'readiness probe set': containerSpec?.readinessProbe !== undefined }, + ); + if (containerSpec && containerSpec?.livenessProbe !== undefined) { + Object.assign(healthCheck, { + 'liveness probe set': containerSpec.livenessProbe, + }); + } + return healthCheck; }; const getCurrentState = (containerStatus: IContainerStatus): string => { From 232eea92e6c1160664278bd099889139835ea39b Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 15 Aug 2024 10:18:22 +0200 Subject: [PATCH 323/372] docs/frontend-system: migration docs for extension creators Signed-off-by: Patrik Oldsberg --- docs/frontend-system/architecture/20-extensions.md | 4 ---- docs/frontend-system/architecture/60-migrations.md | 8 ++++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/frontend-system/architecture/20-extensions.md b/docs/frontend-system/architecture/20-extensions.md index d1024d5e17..b43be74dbc 100644 --- a/docs/frontend-system/architecture/20-extensions.md +++ b/docs/frontend-system/architecture/20-extensions.md @@ -338,7 +338,3 @@ export function createSomeExtension< }); } ``` - -### Extension Creators (Deprecated) - -Previous iterations of the frontend system used an "extension creator" pattern, where `createExtension` was wrapped up in a function for creating specific extension kinds. This pattern was similar to [blueprints](./23-extension-blueprints.md), but much harder to implement and maintain. It has been deprecated in favor of the new blueprints API. For example, `createPageExtension` was the extension creator equivalent of `PageBlueprint`. diff --git a/docs/frontend-system/architecture/60-migrations.md b/docs/frontend-system/architecture/60-migrations.md index 6ba3c73f0e..1c1e61e4d7 100644 --- a/docs/frontend-system/architecture/60-migrations.md +++ b/docs/frontend-system/architecture/60-migrations.md @@ -72,3 +72,11 @@ createExtension({ Note the changes to the `inputs` and `output` declarations, as well as how these are used in the factory. Both the `inputs` and `output` now declare their expected data using an array, without names tied to each piece of data. The `get` method on the input object is used to access the input data, and accept a data reference matching the data that was declared for that input. The biggest change in practice is how the extension factories output their data. Instead of returning an object with the data values, you instead use each extension data reference to encapsulate a value and return a collection of these encapsulated values from the factory. + +### Blueprints instead of extension creators + +The "extension creator" pattern where `createExtension` was wrapped up in a function for creating specific kind of extensions has been replaced by [extension blueprints](./23-extension-blueprints.md). Extension creators were hard to implement and to maintain, with blueprints providing a much more consistent and powerful API surface for both plugin builders and integrators. For example, `createPageExtension` was the extension creator equivalent of `PageBlueprint`. + +Replace all existing usages of extension creators in your plugin or app with the corresponding blueprint. For a given extension creator `createExtension`, the blueprint equivalent is `Blueprint`. There might be slight differences in the API between the two, but most often you just need to move the kind-specific options of the extension creator to be passed as parameters to the blueprint. Note that if your extension declared any additional inputs or config you'll need to use the [`.makeWithOverrides`](./23-extension-blueprints.md#creating-an-extension-from-a-blueprint-with-overrides) method of the blueprint. + +If your plugin exports and extension creators, these should be migrated to blueprints instead. From d4076c7d08365037b235fa491f6ff9af0f9f8441 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 15 Aug 2024 10:24:19 +0200 Subject: [PATCH 324/372] docs/frontend-system: migration docs for extension tester Signed-off-by: Patrik Oldsberg --- docs/frontend-system/architecture/60-migrations.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/frontend-system/architecture/60-migrations.md b/docs/frontend-system/architecture/60-migrations.md index 1c1e61e4d7..0d6ef39209 100644 --- a/docs/frontend-system/architecture/60-migrations.md +++ b/docs/frontend-system/architecture/60-migrations.md @@ -80,3 +80,9 @@ The "extension creator" pattern where `createExtension` was wrapped up in a func Replace all existing usages of extension creators in your plugin or app with the corresponding blueprint. For a given extension creator `createExtension`, the blueprint equivalent is `Blueprint`. There might be slight differences in the API between the two, but most often you just need to move the kind-specific options of the extension creator to be passed as parameters to the blueprint. Note that if your extension declared any additional inputs or config you'll need to use the [`.makeWithOverrides`](./23-extension-blueprints.md#creating-an-extension-from-a-blueprint-with-overrides) method of the blueprint. If your plugin exports and extension creators, these should be migrated to blueprints instead. + +### Extension tester rework + +The `createExtensionTester` from the `@backstage/frontend-test-utils` package has been reworked to better support testing of extensions. The new API allows access to extension output directly using the new `.get(ref)` method, and also provides access to all tested extensions through the new `.query(id/extension)` method. + +The `.render()` method that used to render the test subject in a test app has been deprecated. The extension tester no longer constructs a full app tree, but instead only instantiates the tree for the extensions under test. If you want to test the rendering of an extension that outputs in an app, you can instead use the `renderInTestApp` utility in combination with the new `.reactElement()` method of the extension tester: `renderInTestApp(tester.reactElement())`. From 160c55181a62f76c8722d5886a5bc3ed8c89e45a Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 15 Aug 2024 10:27:11 +0200 Subject: [PATCH 325/372] docs/frontend-system: migration docs for extension data refs Signed-off-by: Patrik Oldsberg --- .../architecture/60-migrations.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/frontend-system/architecture/60-migrations.md b/docs/frontend-system/architecture/60-migrations.md index 0d6ef39209..a1ab0197f7 100644 --- a/docs/frontend-system/architecture/60-migrations.md +++ b/docs/frontend-system/architecture/60-migrations.md @@ -86,3 +86,19 @@ If your plugin exports and extension creators, these should be migrated to bluep The `createExtensionTester` from the `@backstage/frontend-test-utils` package has been reworked to better support testing of extensions. The new API allows access to extension output directly using the new `.get(ref)` method, and also provides access to all tested extensions through the new `.query(id/extension)` method. The `.render()` method that used to render the test subject in a test app has been deprecated. The extension tester no longer constructs a full app tree, but instead only instantiates the tree for the extensions under test. If you want to test the rendering of an extension that outputs in an app, you can instead use the `renderInTestApp` utility in combination with the new `.reactElement()` method of the extension tester: `renderInTestApp(tester.reactElement())`. + +### Extension data references update + +The way that extension data references are declared has been changed to allow for type inference of the ID. This requires the declaration to be split into two separate function calls, one to supply the type and the other to infer any options. For example, a reference that was previously declared like this: + +```ts +export const myExtension = createExtensionDataRef('my-plugin.my-data'); +``` + +Should be updated to the following: + +```ts +export const myExtension = createExtensionDataRef().with({ + id: 'my-plugin.my-data', +}); +``` From 4109dfb00afcf96e51847fe86d3524a7bc6c0d89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Thu, 15 Aug 2024 10:53:56 +0200 Subject: [PATCH 326/372] bump the elliptic dependency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 4c47bc5771..18e6b613a8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -25756,8 +25756,8 @@ __metadata: linkType: hard "elliptic@npm:^6.0.0, elliptic@npm:^6.5.4": - version: 6.5.4 - resolution: "elliptic@npm:6.5.4" + version: 6.5.7 + resolution: "elliptic@npm:6.5.7" dependencies: bn.js: ^4.11.9 brorand: ^1.1.0 @@ -25766,7 +25766,7 @@ __metadata: inherits: ^2.0.4 minimalistic-assert: ^1.0.1 minimalistic-crypto-utils: ^1.0.1 - checksum: d56d21fd04e97869f7ffcc92e18903b9f67f2d4637a23c860492fbbff5a3155fd9ca0184ce0c865dd6eb2487d234ce9551335c021c376cd2d3b7cb749c7d10f4 + checksum: af0ffddffdbc2fea4eeec74388cd73e62ed5a0eac6711568fb28071566319785df529c968b0bf1250ba4bc628e074b2d64c54a633e034aa6f0c6b152ceb49ab8 languageName: node linkType: hard From 5590f4ec7b2067876652472996af28738327c949 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 15 Aug 2024 12:44:35 +0200 Subject: [PATCH 327/372] docs/frontend-system: update extension docs Signed-off-by: Patrik Oldsberg --- .../architecture/20-extensions.md | 227 +++++++++--------- .../architecture/50-naming-patterns.md | 2 +- 2 files changed, 118 insertions(+), 111 deletions(-) diff --git a/docs/frontend-system/architecture/20-extensions.md b/docs/frontend-system/architecture/20-extensions.md index b43be74dbc..ac55a42827 100644 --- a/docs/frontend-system/architecture/20-extensions.md +++ b/docs/frontend-system/architecture/20-extensions.md @@ -18,12 +18,12 @@ Each extensions has a number of different properties that define how it behaves ### ID - - The ID of an extension is used to uniquely identity it, and it should ideally be unique across the entire Backstage ecosystem. For each frontend app instance there can only be a single extension for any given ID. Installing multiple extensions with the same ID will either result in an error or one of the extensions will override the others. The ID is also used to reference the extensions from other extensions, in configuration, and in other places such as developer tools and analytics. +When creating an extension do not provide the ID directly. Instead, you indirectly or directly provide the kind, namespace, and name parts that make up the ID. The kind is always provided by the [extension blueprint](./23-extension-blueprints.md), the only exception is if you use [`createExtension`](#creating-an-extensions) directly. Any extension that is provided by a plugin will by default have its namespace set to the plugin ID, so you generally only need to provide an explicit namespace if you want to override an existing extension. The name is also optional, and primarily used to distinguish between multiple extensions of the same kind and namespace. If a plugin doesn't need to distinguish between different extensions of the same kind, the name can be omitted. + +The extension ID will be constructed using the pattern `[:][][/][]`, where the separating `/` is only present if both a namespace and name are defined. + ### Output The output of an extension is the data that it provides to its parent extension, and ultimately its contribution to the app. The output itself comes in the form of a collection of arbitrary values, anything that can be represented as a TypeScript type. However, each individual output value must be associated with a shared reference known as an extension data reference. You must also use these same references to be able to access individual output values of an extension. @@ -32,7 +32,7 @@ The output of an extension is the data that it provides to its parent extension, The inputs of an extension define the data that it received from its children. Each extension can have multiple different inputs identified by an input name. These inputs each have their own set of data that they expect, which is defined as a collection of extension data references. An extension will only have access to the data that it has explicitly requested from each input. -### Attachment Point +### Attachment point The attachment point of an extension decides where in the app extension tree it will be located. It is defined by the ID of the parent extension, as well as the name of the input to attach to. Through the attachment point the extension will share its own output as inputs to the parent extension. An extension can only be attached to an input that matches its own output, it is an error to try to attach an extension to an input the requires data that the extension does not provide in its output. @@ -44,7 +44,7 @@ Each extension in the app can be disabled, meaning it will not be instantiated a The ordering of extensions is sometimes very important, as it may for example affect in which order they show up in the UI. When an extension is toggled from disabled to enabled through configuration it resets the ordering of the extension, pushing it to the end of the list. It is generally recommended to leave extensions as disabled by default if their order is important, allowing for the order in which their are enabled in the configuration to determine their order in the app. -### Configuration & Configuration Schema +### Configuration & configuration schema Each extension can define a configuration schema that describes the configuration that it accepts. This schema is used to validate the configuration provided by integrators, but also to fill in default configuration values. The configuration itself is provided by integrators in order to customize the extension. It is not possible to provide a default configuration of an extension, this must instead be done through defaults in the configuration schema. This allows for a simpler configuration logic where multiple configurations of the same extension completely replace each other rather than being merged. @@ -54,7 +54,7 @@ The extension factory is the implementation of the extension itself. It is a fun Extension factories should be lean and not do any heavy lifting or async work, as they are called during the initialization of the app. For example, if you need to do an expensive computation to generate your output, then prefer outputting a callback that does the computation instead. This allows the parent extension to defer the computation for later so that you avoid blocking the app startup. -## Creating an Extensions +## Creating an extension Extensions are created using the `createExtension` function from `@backstage/frontend-plugin-api`. At minimum you need to provide an ID, attachment point, output definition, and a factory function. The following example shows the creation of a minimal extension: @@ -64,28 +64,22 @@ const extension = createExtension({ // This is the attachment point, `id` is the ID of the parent extension, // while `input` is the name of the input to attach to. attachTo: { id: 'my-parent', input: 'content' }, - // The output map defines the outputs of the extension. The object keys - // are only used internally to map the outputs of the factory and do - // not need to match the keys of the input. - output: { - element: coreExtensionData.reactElement, - }, + // The output option defines the allowed and required outputs of the extension factory. + output: [coreExtensionData.reactElement], // This factory is called to instantiate the extensions and produce its output. factory() { - return { - element:
    Hello World
    , - }; + return [coreExtensionData.reactElement(
    Hello World
    )]; }, }); ``` -Note that while the `createExtension` is public API and used in many places, it is not typically what you use when building plugins and features. Instead there are many extension creator functions exported by both the core APIs and plugins that make it easier to create extensions for more specific usages. +Note that while the `createExtension` is public API and used in many places, it is not typically what you use when building plugins and features. Instead there are many [extension blueprints](./23-extension-blueprints.md) exported by both the core APIs and plugins that make it easier to create extensions for more specific usages. -## Extension Data +## Extension data Communication between extensions happens in one direction, from one child extension through the attachment point to its parent. The child extension outputs data which is then passed as inputs to the parent extension. This data is called Extension Data, where the shape of each individual piece of data is described by an Extension Data Reference. These references are created separately from the extensions themselves, and can be shared across multiple different kinds of extensions. Each reference consists of an ID and a TypeScript type that the data needs to conform to, and represents one type of data that can be shared between extensions. -### Extension Data References +### Extension data references To create a new extension data reference to represent a type of shared extension data you use the `createExtensionDataRef` function. When defining a new reference you need to provide an ID and a TypeScript type, for example: @@ -101,59 +95,55 @@ The `ExtensionDataRef` can then be used to describe an output property of the ex ```tsx const extension = createExtension({ // ... - output: { - element: reactElementExtensionDataRef, - }, + output: [reactElementExtensionDataRef], factory() { - return { - element:
    Hello World
    , - }; + return [reactElementExtensionDataRef(
    Hello World
    )]; }, }); ``` -### Extension Data Uniqueness +### Extension data uniqueness -Note that the key used in the output map, in this case `element`, is only used internally within the definition of the extension itself. That actual identifier for the data when consumed by other extensions is the ID of the reference, in this case [`core.reactElement`](https://github.com/backstage/backstage/blob/916da47e8abdb880877daa18881eb8fdbb33e70a/packages/frontend-plugin-api/src/wiring/coreExtensionData.ts#L23). This means that you can not output multiple different values for the same extension data reference, as they would conflict with each other. That in turn makes overly generic extension data references a bad idea, for example a generic "string" type. Instead create separate references for each type of data that you want to share. +Note that you are **not** allowed to repeat the same data reference in the outputs, or return multiple values for the same reference. Multiple outputs for the same reference will conflict with each other and cause an error. If you want to output multiple values of the same TypeScript type you should create separate references for each value. That in turn means that overly generic extension data references a bad idea, for example a generic "string" type. Instead create separate references for each type of data that you want to share. ```tsx const extension = createExtension({ // ... - output: { - // ❌ Bad example - outputting values of same type - element1: reactElementExtensionDataRef, - element2: reactElementExtensionDataRef, - }, + output: [ + // ❌ Bad example - duplicate output declaration + reactElementExtensionDataRef, + reactElementExtensionDataRef, + ], factory() { - return { - element1:
    Hello World
    , - element2:
    Hello World
    , - }; + return [ + // ❌ Bad example - duplicate output values + reactElementExtensionDataRef(
    Hello
    ), + reactElementExtensionDataRef(
    World
    ), + ]; }, }); ``` -### Core Extension Data +### Core extension data We provide default `coreExtensionData`, which provides commonly used `ExtensionDataRef`s - e.g. for `React.JSX.Element` and `RouteRef`. They can be used when creating your own extension. For example, the React Element extension data that we defined above is already provided as `coreExtensionData.reactElement`. For a full list and explanations of all types of core extension data, see the [core extension data reference](../building-plugins/04-built-in-data-refs.md). -### Optional Extension Data +### Optional extension data By default all extension data is required, meaning that the extension factory must provide a value for each output. However, it is possible to make extension data optional by calling the `.optional()` method. This makes it optional for the factory function to return a value as part of its output. When calling the `.optional()` method you create a new copy of the extension data reference, it does not mutate the existing reference. ```tsx const extension = createExtension({ // ... - output: { - element: coreExtensionData.reactElement.optional(), - }, + output: [coreExtensionData.reactElement.optional()], factory() { - return { - element: + return [ + coreExtensionData.reactElement.optional()( Math.random() < 0.5 ? : undefined, - }; + ), + ]; }, }); ``` @@ -167,17 +157,19 @@ const navigationExtension = createExtension({ // ... inputs: { // [1]: Input - logo: createExtensionInput( - { - element: coreExtensionData.reactElement, - }, - { singleton: true, optional: true }, - ), + logo: createExtensionInput([coreExtensionData.reactElement], { + singleton: true, + optional: true, + }), }, factory({ inputs }) { return { element: ( - + ), }; }, @@ -193,10 +185,9 @@ So how can we now attach the output to the parent extension's input? If we think const navigationItemExtension = createExtension({ // ... attachTo: { id: 'app/nav', input: 'items' }, + output: [coreExtensionData.reactElement], factory() { - return { - element: Home, - }; + return [coreExtensionData.reactElement(Home)]; }, }); @@ -205,26 +196,22 @@ const navigationExtension = createExtension({ // [2]: Extension `id` will be `app/nav` following the extension naming pattern namespace: 'app', name: 'nav', - output: { - element: coreExtensionData.reactElement, - }, + output: [coreExtensionData.reactElement], inputs: { - items: createExtensionInput({ - element: coreExtensionData.reactElement, - }), + items: createExtensionInput([coreExtensionData.reactElement]), }, factory({ inputs }) { - return { - element: ( + return [ + coreExtensionData.reactElement( + , ), - }; + ]; }, // ... }); @@ -232,27 +219,27 @@ const navigationExtension = createExtension({ In this case the extension input `items` is an array, where each individual item is an extension that attached itself to the extension inputs of this `id`. -With the `inputs` not only the `output` of an extensions item is passed to the extension, but also the `node`. However, it is discouraged to consume the `node` here unless needed. If we are looking at the `factory` function from the example above we could access the `node` like the following: +In addition to being able to access data passed through the input, you also have access to the underlying app `node`. This can be useful if you for example want to get the ID of the attached extension. However, avoid using the `node` unless needed, it is generally better to stick to only consuming the provided data. If we are looking at the `factory` function from the example above we could access the `node` like the following: ```tsx // ... factory({ inputs }) { - return { - element: ( + return [ + coreExtensionData.reactElement( ), - }; + ]; }, ``` -## Extension Configuration +## Extension configuration With the `app-config.yaml` there is already the option to pass configuration to plugins or the app to e.g. define the `baseURL` of your app. For extensions this concept would be limiting as an extension can be independent of the plugin & initiated several times. Therefore we created a possibility to configure each extension individually through config. The extension config schema is created using the [`zod`](https://zod.dev/) library, which in addition to TypeScript type checking also provides runtime validation and coercion. If we continue with the example of the `navigationExtension` and now want it to contain a configurable title, we could make it available like the following: @@ -262,20 +249,20 @@ const navigationExtension = createExtension({ namespace: 'app', name: 'nav', // [3]: Extension `id` will be `app/nav` following the extension naming pattern - configSchema: createSchemaFromZod(z => - z.object({ - title: z.string().default('Sidebar Title'), - }), - ), + config: { + schema: { + title: z => z.string().default('Sidebar Title'), + }, + }, factory({ config }) { - return { - element: ( + return [ + coreExtensionData.reactElement( + , ), - }; + ]; }, // ... }); @@ -293,15 +280,40 @@ app: title: 'Backstage' ``` -## Extension Boundary +## Extension factory as a generator function + +In all examples so far we have defined the extension factory as a regular function that returns its output in an array. However, the only requirement is that the factory function returns an iterable of extension data value. This means that you can also define the factory function as a generator function, which allows you to yield values one by one. This is particularly useful if you want to conditionally output values. + +For example, this is how we could define an extension where its output depends on the configuration: + +```tsx +const exampleExtension = createExtension({ + // ... + config: { + schema: { + disableIcon: z.boolean().default(false), + }, + }, + output: [coreExtensionData.reactElement, iconDataRef.optional()], + *factory({ config }) { + yield coreExtensionData.reactElement(
    Hello World
    ); + + if (!config.disableIcon) { + yield iconDataRef(); + } + }, +}); +``` + +## Extension boundary The `ExtensionBoundary` wraps extensions with several React contexts for different purposes ### Suspense -All React elements rendered by extension creators should be wrapped in the extension boundary. With `Suspense` the extension can than load resources asynchronously with having a loading fallback. It also allows to lazy load the whole extension similar to how plugins are currently lazy loaded in Backstage. +Most React elements rendered by extensions should be wrapped in the extension boundary. With `Suspense` the extension can than load resources asynchronously with having a loading fallback. It also allows to lazy load the whole extension similar to how plugins are currently lazy loaded in Backstage. -### Error Boundary +### Error boundary Similar to plugins the `ErrorBoundary` for extension allows to pass in a fallback component in case there is an uncaught error inside of the component. With this the error can be isolated & it would prevent the rest of the plugin to crash. @@ -309,32 +321,27 @@ Similar to plugins the `ErrorBoundary` for extension allows to pass in a fallbac Analytics information are provided through the `AnalyticsContext`, which will give `extensionId` & `pluginId` as context to analytics event fired inside of the extension. Additionally `RouteTracker` will capture an analytics event for routable extension to inform which extension metadata gets associated with a navigation event when the route navigated to is a gathered `mountPoint`. Whether an extension is routable is inferred from its outputs, but you can also explicitly control this behavior by passing the `routable` prop to `ExtensionBoundary`. -The `ExtensionBoundary` can be used like the following in an extension creator: +The `ExtensionBoundary` can be used like the following in an extension: ```tsx -export function createSomeExtension< - TConfig extends {}, - TInputs extends AnyExtensionInputMap, ->(options): ExtensionDefinition { - return createExtension({ - // ... - factory({ config, inputs, node }) { - const ExtensionComponent = lazy(() => - options - .loader({ config, inputs }) - .then(element => ({ default: () => element })), - ); +const routableExtension = createExtension({ + // ... + factory({ config, inputs, node }) { + const ExtensionComponent = lazy(() => + options + .loader({ config, inputs }) + .then(element => ({ default: () => element })), + ); - return { - path: config.path, - routeRef: options.routeRef, - element: ( - - - - ), - }; - }, - }); -} + return [ + coreExtensionData.path(config.path), + coreExtensionData.routeRef(options.routeRef), + coreExtensionData.reactElement( + + + , + ), + ]; + }, +}); ``` diff --git a/docs/frontend-system/architecture/50-naming-patterns.md b/docs/frontend-system/architecture/50-naming-patterns.md index b21a01c0d2..11e0b8e733 100644 --- a/docs/frontend-system/architecture/50-naming-patterns.md +++ b/docs/frontend-system/architecture/50-naming-patterns.md @@ -42,7 +42,7 @@ Note that while we use this naming pattern for the plugin instance this is only | ID | `[:][/]` | `'core.nav'`, `'page:user-settings'`, `'entity-card:catalog/about'` | | Symbol | `[][]` | `coreNav`, `userSettingsPage`, `catalogAboutEntityCard` | -When you create a new extension you never provide the ID directly. Instead, you indirectly or directly provide the kind, namespace, and name parts that make up the ID. The kind is always provided by the blueprint creator, the only exception is if you use `createExtension` directly. Any extension that is provided by a plugin will by default have its namespace set to the plugin ID, so you generally only need to provide an explicit namespace if you want to override an existing extension. The name is also optional, and primarily used to distinguish between multiple extensions of the same kind and namespace. If a plugin doesn't need to distinguish between different extensions of the same kind, the name can be omitted. +When you create a new extension you never provide the ID directly. Instead, you indirectly or directly provide the kind, namespace, and name parts that make up the ID. The kind is always provided by the extension blueprint, the only exception is if you use `createExtension` directly. Any extension that is provided by a plugin will by default have its namespace set to the plugin ID, so you generally only need to provide an explicit namespace if you want to override an existing extension. The name is also optional, and primarily used to distinguish between multiple extensions of the same kind and namespace. If a plugin doesn't need to distinguish between different extensions of the same kind, the name can be omitted. Example: From 4bc4cd969c953185d90d1a82ec4fb3ca9b361f51 Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 13 Aug 2024 14:49:56 +0200 Subject: [PATCH 328/372] chore: wip MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Patrik Oldsberg Co-authored-by: Fredrik Adelöw Co-authored-by: Camila Belo Co-authored-by: Johan Haals Signed-off-by: blam --- .../blueprints/SignInPageBlueprint.test.tsx | 23 ++-- .../src/app/createExtensionTester.tsx | 71 +++-------- .../src/app/renderInTestApp.tsx | 113 ++++++++++++++++-- 3 files changed, 128 insertions(+), 79 deletions(-) diff --git a/packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.test.tsx b/packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.test.tsx index f97798a64c..61b23e56f9 100644 --- a/packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.test.tsx @@ -16,9 +16,11 @@ import React from 'react'; import { SignInPageBlueprint } from './SignInPageBlueprint'; -import { createExtensionTester } from '@backstage/frontend-test-utils'; +import { + createExtensionTester, + renderInTestApp, +} from '@backstage/frontend-test-utils'; import { screen, waitFor } from '@testing-library/react'; -import { coreExtensionData, createExtension } from '../wiring'; describe('SignInPageBlueprint', () => { it('should create an extension with sensible defaults', () => { @@ -60,20 +62,11 @@ describe('SignInPageBlueprint', () => { const tester = createExtensionTester(extension); - expect(tester.data(SignInPageBlueprint.dataRefs.component)).toBeDefined(); + const Element = tester.data(SignInPageBlueprint.dataRefs.component)!; - createExtensionTester( - createExtension({ - name: 'dummy', - attachTo: { id: 'ignored', input: 'ignored' }, - output: { - element: coreExtensionData.reactElement, - }, - factory: () => ({ element:
    }), - }), - ) - .add(extension) - .render(); + expect(Element).toBeDefined(); + + renderInTestApp( {}} />); await waitFor(() => { expect(screen.getByTestId('mock-sign-in')).toBeInTheDocument(); diff --git a/packages/frontend-test-utils/src/app/createExtensionTester.tsx b/packages/frontend-test-utils/src/app/createExtensionTester.tsx index 4bfc8392cb..2d842062fc 100644 --- a/packages/frontend-test-utils/src/app/createExtensionTester.tsx +++ b/packages/frontend-test-utils/src/app/createExtensionTester.tsx @@ -49,57 +49,6 @@ import { instantiateAppNodeTree } from '../../../frontend-app-api/src/tree/insta // eslint-disable-next-line @backstage/no-relative-monorepo-imports import { readAppExtensionsConfig } from '../../../frontend-app-api/src/tree/readAppExtensionsConfig'; -const NavItem = (props: { - routeRef: RouteRef; - title: string; - icon: IconComponent; -}) => { - const { routeRef, title, icon: Icon } = props; - const link = useRouteRef(routeRef); - if (!link) { - return null; - } - return ( -
  • - - {title} - -
  • - ); -}; - -const TestAppNavExtension = createExtension({ - namespace: 'app', - name: 'nav', - attachTo: { id: 'app/layout', input: 'nav' }, - inputs: { - items: createExtensionInput({ - target: createNavItemExtension.targetDataRef, - }), - }, - output: { - element: coreExtensionData.reactElement, - }, - factory({ inputs }) { - return { - element: ( - - ), - }; - }, -}); - /** @public */ export class ExtensionQuery { #node: AppNode; @@ -245,6 +194,25 @@ export class ExtensionTester { return new ExtensionQuery(node); } + element(): JSX.Element { + const tree = this.#resolveTree(); + + const element = new ExtensionQuery(tree.root).data( + coreExtensionData.reactElement, + ); + + if (!element) { + throw new Error( + 'No element found. Make sure the extension has a `coreExtensionData.reactElement` output, or use the `.get(myComponentDataRef)` method to get the component', + ); + } + + return element; + } + + /** + * @deprecated Switch to using `renderInTestApp` directly and using `.element()` or `.get(myComponentDataRef)` to get the component you would like to wrap up + */ render(options?: { config?: JsonObject }): RenderResult { const { config = {} } = options ?? {}; @@ -260,7 +228,6 @@ export class ExtensionTester { createExtensionOverrides({ extensions: [ ...this.#extensions.map(extension => extension.definition), - TestAppNavExtension, createRouterExtension({ namespace: 'test', Component: ({ children }) => ( diff --git a/packages/frontend-test-utils/src/app/renderInTestApp.tsx b/packages/frontend-test-utils/src/app/renderInTestApp.tsx index e0483f68d8..d828c89f12 100644 --- a/packages/frontend-test-utils/src/app/renderInTestApp.tsx +++ b/packages/frontend-test-utils/src/app/renderInTestApp.tsx @@ -16,11 +16,24 @@ import React from 'react'; import { + ExtensionDefinition, + IconComponent, RouteRef, coreExtensionData, createExtension, + createExtensionInput, + createExtensionOverrides, + createNavItemExtension, + createRouterExtension, + useRouteRef, } from '@backstage/frontend-plugin-api'; -import { createExtensionTester } from './createExtensionTester'; +import { Link, MemoryRouter } from 'react-router-dom'; +import { createSpecializedApp } from '@backstage/frontend-app-api'; +import { render } from '@testing-library/react'; +import { resolveExtensionDefinition } from '@backstage/frontend-plugin-api/src/wiring/resolveExtensionDefinition'; +import { resolve } from 'path'; +import { ConfigReader } from '@backstage/config'; +import { JsonObject } from '@backstage/types'; /** * Options to customize the behavior of the test app. @@ -44,8 +57,64 @@ export type TestAppOptions = { * ``` */ mountedRoutes?: { [path: string]: RouteRef }; + + /** + * Additional configuration passed to the app when rendering elements inside it. + */ + config?: JsonObject; }; +const NavItem = (props: { + routeRef: RouteRef; + title: string; + icon: IconComponent; +}) => { + const { routeRef, title, icon: Icon } = props; + const link = useRouteRef(routeRef); + if (!link) { + return null; + } + return ( +
  • + + {title} + +
  • + ); +}; + +const TestAppNavExtension = createExtension({ + namespace: 'app', + name: 'nav', + attachTo: { id: 'app/layout', input: 'nav' }, + inputs: { + items: createExtensionInput({ + target: createNavItemExtension.targetDataRef, + }), + }, + output: { + element: coreExtensionData.reactElement, + }, + factory({ inputs }) { + return { + element: ( + + ), + }; + }, +}); + /** * @public * Renders the given element in a test app, for use in unit tests. @@ -54,20 +123,28 @@ export function renderInTestApp( element: JSX.Element, options?: TestAppOptions, ) { - const extension = createExtension({ - namespace: 'test', - attachTo: { id: 'app', input: 'root' }, - output: { - element: coreExtensionData.reactElement, - }, - factory: () => ({ element }), - }); - const tester = createExtensionTester(extension); + const extensions: Array> = [ + createExtension({ + namespace: 'test', + attachTo: { id: 'app/routes', input: 'routes' }, + output: [coreExtensionData.reactElement, coreExtensionData.routePath], + factory: () => { + return [ + coreExtensionData.reactElement(element), + coreExtensionData.routePath('/'), + ]; + }, + }), + createRouterExtension({ + namespace: 'test', + Component: ({ children }) => {children}, + }), + ]; if (options?.mountedRoutes) { for (const [path, routeRef] of Object.entries(options.mountedRoutes)) { // TODO(Rugvip): add support for external route refs - tester.add( + extensions.push( createExtension({ kind: 'test-route', name: path, @@ -84,5 +161,17 @@ export function renderInTestApp( ); } } - return tester.render(); + + const app = createSpecializedApp({ + features: [ + createExtensionOverrides({ + extensions, + }), + ], + config: ConfigReader.fromConfigs([ + { context: 'render-config', data: options?.config ?? {} }, + ]), + }); + + return render(app.createRoot()); } From d2d4a80937711780ec9b80ea5c4da5655ee979df Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 13 Aug 2024 15:01:58 +0200 Subject: [PATCH 329/372] feat: some more work on splitting out the render method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Patrik Oldsberg Co-authored-by: Fredrik Adelöw Co-authored-by: Camila Belo Co-authored-by: Johan Haals Signed-off-by: blam --- .../src/app/createExtensionTester.tsx | 10 +-- .../src/app/renderInTestApp.tsx | 69 ++++++++++--------- 2 files changed, 39 insertions(+), 40 deletions(-) diff --git a/packages/frontend-test-utils/src/app/createExtensionTester.tsx b/packages/frontend-test-utils/src/app/createExtensionTester.tsx index 2d842062fc..fb05270eb8 100644 --- a/packages/frontend-test-utils/src/app/createExtensionTester.tsx +++ b/packages/frontend-test-utils/src/app/createExtensionTester.tsx @@ -15,7 +15,7 @@ */ import React from 'react'; -import { MemoryRouter, Link } from 'react-router-dom'; +import { MemoryRouter } from 'react-router-dom'; import { RenderResult, render } from '@testing-library/react'; import { createSpecializedApp } from '@backstage/frontend-app-api'; import { @@ -24,15 +24,10 @@ import { Extension, ExtensionDataRef, ExtensionDefinition, - IconComponent, - RouteRef, coreExtensionData, createExtension, - createExtensionInput, createExtensionOverrides, - createNavItemExtension, createRouterExtension, - useRouteRef, } from '@backstage/frontend-plugin-api'; import { Config, ConfigReader } from '@backstage/config'; import { JsonArray, JsonObject, JsonValue } from '@backstage/types'; @@ -215,14 +210,12 @@ export class ExtensionTester { */ render(options?: { config?: JsonObject }): RenderResult { const { config = {} } = options ?? {}; - const [subject] = this.#extensions; if (!subject) { throw new Error( 'No subject found. At least one extension should be added to the tester.', ); } - const app = createSpecializedApp({ features: [ createExtensionOverrides({ @@ -239,7 +232,6 @@ export class ExtensionTester { ], config: this.#getConfig(config), }); - return render(app.createRoot()); } diff --git a/packages/frontend-test-utils/src/app/renderInTestApp.tsx b/packages/frontend-test-utils/src/app/renderInTestApp.tsx index d828c89f12..85cf1c626c 100644 --- a/packages/frontend-test-utils/src/app/renderInTestApp.tsx +++ b/packages/frontend-test-utils/src/app/renderInTestApp.tsx @@ -15,25 +15,23 @@ */ import React from 'react'; -import { - ExtensionDefinition, - IconComponent, - RouteRef, - coreExtensionData, - createExtension, - createExtensionInput, - createExtensionOverrides, - createNavItemExtension, - createRouterExtension, - useRouteRef, -} from '@backstage/frontend-plugin-api'; import { Link, MemoryRouter } from 'react-router-dom'; import { createSpecializedApp } from '@backstage/frontend-app-api'; import { render } from '@testing-library/react'; -import { resolveExtensionDefinition } from '@backstage/frontend-plugin-api/src/wiring/resolveExtensionDefinition'; -import { resolve } from 'path'; import { ConfigReader } from '@backstage/config'; import { JsonObject } from '@backstage/types'; +import { + createExtension, + createExtensionOverrides, + createRouterExtension, + ExtensionDefinition, + coreExtensionData, + RouteRef, + useRouteRef, + createExtensionInput, + IconComponent, + createNavItemExtension, +} from '@backstage/frontend-plugin-api'; /** * Options to customize the behavior of the test app. @@ -120,26 +118,35 @@ const TestAppNavExtension = createExtension({ * Renders the given element in a test app, for use in unit tests. */ export function renderInTestApp( - element: JSX.Element, + element: JSX.Element | { extensions: ExtensionDefinition[] }, options?: TestAppOptions, ) { - const extensions: Array> = [ - createExtension({ - namespace: 'test', - attachTo: { id: 'app/routes', input: 'routes' }, - output: [coreExtensionData.reactElement, coreExtensionData.routePath], - factory: () => { - return [ - coreExtensionData.reactElement(element), - coreExtensionData.routePath('/'), + const extensions: Array> = + 'extensions' in element + ? element.extensions + : [ + createExtension({ + namespace: 'test', + attachTo: { id: 'app/routes', input: 'routes' }, + output: [ + coreExtensionData.reactElement, + coreExtensionData.routePath, + ], + factory: () => { + return [ + coreExtensionData.reactElement(element), + coreExtensionData.routePath('/'), + ]; + }, + }), + createRouterExtension({ + namespace: 'test', + Component: ({ children }) => ( + {children} + ), + }), + TestAppNavExtension, ]; - }, - }), - createRouterExtension({ - namespace: 'test', - Component: ({ children }) => {children}, - }), - ]; if (options?.mountedRoutes) { for (const [path, routeRef] of Object.entries(options.mountedRoutes)) { From 1d6cf554c635fcc4a85df9756e65ddaa473079ac Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 13 Aug 2024 15:11:53 +0200 Subject: [PATCH 330/372] feat: added api-reports Signed-off-by: blam --- packages/frontend-test-utils/api-report.md | 8 +- .../src/app/renderInTestApp.tsx | 86 +++++++++---------- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/packages/frontend-test-utils/api-report.md b/packages/frontend-test-utils/api-report.md index 3aa9069219..2c16028dd1 100644 --- a/packages/frontend-test-utils/api-report.md +++ b/packages/frontend-test-utils/api-report.md @@ -27,6 +27,7 @@ import { RouteRef } from '@backstage/frontend-plugin-api'; import { TestApiProvider } from '@backstage/test-utils'; import { TestApiProviderProps } from '@backstage/test-utils'; import { TestApiRegistry } from '@backstage/test-utils'; +import { testingLibraryDomTypesQueries } from '@testing-library/dom/types/queries'; import { withLogCollector } from '@backstage/test-utils'; // @public (undocumented) @@ -62,8 +63,10 @@ export class ExtensionTester { // (undocumented) data(ref: ExtensionDataRef): T | undefined; // (undocumented) - query(id: string | ExtensionDefinition): ExtensionQuery; + element(): JSX.Element; // (undocumented) + query(id: string | ExtensionDefinition): ExtensionQuery; + // @deprecated (undocumented) render(options?: { config?: JsonObject }): RenderResult; } @@ -97,7 +100,7 @@ export { registerMswTestHooks }; export function renderInTestApp( element: JSX.Element, options?: TestAppOptions, -): RenderResult; +): RenderResult; // @public @deprecated (undocumented) export function setupRequestMockHandlers(worker: { @@ -117,6 +120,7 @@ export type TestAppOptions = { mountedRoutes?: { [path: string]: RouteRef; }; + config?: JsonObject; }; export { withLogCollector }; diff --git a/packages/frontend-test-utils/src/app/renderInTestApp.tsx b/packages/frontend-test-utils/src/app/renderInTestApp.tsx index 85cf1c626c..73a29ce0bb 100644 --- a/packages/frontend-test-utils/src/app/renderInTestApp.tsx +++ b/packages/frontend-test-utils/src/app/renderInTestApp.tsx @@ -23,7 +23,6 @@ import { JsonObject } from '@backstage/types'; import { createExtension, createExtensionOverrides, - createRouterExtension, ExtensionDefinition, coreExtensionData, RouteRef, @@ -31,6 +30,7 @@ import { createExtensionInput, IconComponent, createNavItemExtension, + RouterBlueprint, } from '@backstage/frontend-plugin-api'; /** @@ -86,30 +86,32 @@ const TestAppNavExtension = createExtension({ name: 'nav', attachTo: { id: 'app/layout', input: 'nav' }, inputs: { - items: createExtensionInput({ - target: createNavItemExtension.targetDataRef, - }), - }, - output: { - element: coreExtensionData.reactElement, + items: createExtensionInput([createNavItemExtension.targetDataRef]), }, + output: [coreExtensionData.reactElement], factory({ inputs }) { - return { - element: ( + return [ + coreExtensionData.reactElement( + , ), - }; + ]; }, }); @@ -118,35 +120,29 @@ const TestAppNavExtension = createExtension({ * Renders the given element in a test app, for use in unit tests. */ export function renderInTestApp( - element: JSX.Element | { extensions: ExtensionDefinition[] }, + element: JSX.Element, options?: TestAppOptions, ) { - const extensions: Array> = - 'extensions' in element - ? element.extensions - : [ - createExtension({ - namespace: 'test', - attachTo: { id: 'app/routes', input: 'routes' }, - output: [ - coreExtensionData.reactElement, - coreExtensionData.routePath, - ], - factory: () => { - return [ - coreExtensionData.reactElement(element), - coreExtensionData.routePath('/'), - ]; - }, - }), - createRouterExtension({ - namespace: 'test', - Component: ({ children }) => ( - {children} - ), - }), - TestAppNavExtension, + const extensions: Array> = [ + createExtension({ + namespace: 'test', + attachTo: { id: 'app/routes', input: 'routes' }, + output: [coreExtensionData.reactElement, coreExtensionData.routePath], + factory: () => { + return [ + coreExtensionData.reactElement(element), + coreExtensionData.routePath('/'), ]; + }, + }), + RouterBlueprint.make({ + namespace: 'test', + params: { + Component: ({ children }) => {children}, + }, + }), + TestAppNavExtension, + ]; if (options?.mountedRoutes) { for (const [path, routeRef] of Object.entries(options.mountedRoutes)) { From c00e1a00f9beb85af31b92ca9f749c2a91a9d629 Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 13 Aug 2024 15:20:12 +0200 Subject: [PATCH 331/372] chore: added changeset Signed-off-by: blam --- .changeset/three-kiwis-turn.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .changeset/three-kiwis-turn.md diff --git a/.changeset/three-kiwis-turn.md b/.changeset/three-kiwis-turn.md new file mode 100644 index 0000000000..25b5e0497b --- /dev/null +++ b/.changeset/three-kiwis-turn.md @@ -0,0 +1,17 @@ +--- +'@backstage/frontend-plugin-api': patch +'@backstage/frontend-test-utils': patch +--- + +Deprecate the `.render` method of the `createExtensionTester` in favour of using `renderInTestApp` directly. + +```tsx +import { renderInTestApp, createExtensionTester } from '@backstage/frontend-test-utils'; + +const tester = createExtensionTester(extension); + +const { getByTestId } = renderInTestApp(tester.element()); + +// or if you're not using `coreExtensionData.reactElement` as the output ref +const { getByTestId } = renderInTestApp(tester.data(myComponentRef))' +``` From 471473f3911a5c90c5936e1e1fa9fec5b5dbda09 Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 13 Aug 2024 15:23:50 +0200 Subject: [PATCH 332/372] chore: ext Signed-off-by: blam Signed-off-by: blam --- .changeset/three-kiwis-turn.md | 1 - 1 file changed, 1 deletion(-) diff --git a/.changeset/three-kiwis-turn.md b/.changeset/three-kiwis-turn.md index 25b5e0497b..48a1ffff33 100644 --- a/.changeset/three-kiwis-turn.md +++ b/.changeset/three-kiwis-turn.md @@ -1,5 +1,4 @@ --- -'@backstage/frontend-plugin-api': patch '@backstage/frontend-test-utils': patch --- From 9eec064aaf317efb9df177fdf4701e8b21047ded Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 13 Aug 2024 15:31:23 +0200 Subject: [PATCH 333/372] chore: small refactor Signed-off-by: blam --- .changeset/three-kiwis-turn.md | 7 +++++-- .../src/blueprints/PageBlueprint.test.tsx | 7 +++++-- packages/frontend-test-utils/api-report.md | 3 +-- .../frontend-test-utils/src/app/createExtensionTester.tsx | 2 ++ packages/frontend-test-utils/src/app/renderInTestApp.tsx | 6 +++--- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.changeset/three-kiwis-turn.md b/.changeset/three-kiwis-turn.md index 48a1ffff33..d5802fa586 100644 --- a/.changeset/three-kiwis-turn.md +++ b/.changeset/three-kiwis-turn.md @@ -5,12 +5,15 @@ Deprecate the `.render` method of the `createExtensionTester` in favour of using `renderInTestApp` directly. ```tsx -import { renderInTestApp, createExtensionTester } from '@backstage/frontend-test-utils'; +import { + renderInTestApp, + createExtensionTester, +} from '@backstage/frontend-test-utils'; const tester = createExtensionTester(extension); const { getByTestId } = renderInTestApp(tester.element()); // or if you're not using `coreExtensionData.reactElement` as the output ref -const { getByTestId } = renderInTestApp(tester.data(myComponentRef))' +const { getByTestId } = renderInTestApp(tester.data(myComponentRef)); ``` diff --git a/packages/frontend-plugin-api/src/blueprints/PageBlueprint.test.tsx b/packages/frontend-plugin-api/src/blueprints/PageBlueprint.test.tsx index c4bcb4b467..d70a426a57 100644 --- a/packages/frontend-plugin-api/src/blueprints/PageBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/blueprints/PageBlueprint.test.tsx @@ -16,7 +16,10 @@ import React from 'react'; import { createRouteRef } from '../routing'; import { PageBlueprint } from './PageBlueprint'; -import { createExtensionTester } from '@backstage/frontend-test-utils'; +import { + createExtensionTester, + renderInTestApp, +} from '@backstage/frontend-test-utils'; import { coreExtensionData, createExtensionBlueprint, @@ -144,7 +147,7 @@ describe('PageBlueprint', () => { CardBlueprint.make({ name: 'card', params: {} }), ); - const { getByTestId, getByText } = tester.render(); + const { getByTestId, getByText } = renderInTestApp(tester.element()); await waitFor(() => expect(getByTestId('card')).toBeInTheDocument()); await waitFor(() => diff --git a/packages/frontend-test-utils/api-report.md b/packages/frontend-test-utils/api-report.md index 2c16028dd1..0cbdace03e 100644 --- a/packages/frontend-test-utils/api-report.md +++ b/packages/frontend-test-utils/api-report.md @@ -27,7 +27,6 @@ import { RouteRef } from '@backstage/frontend-plugin-api'; import { TestApiProvider } from '@backstage/test-utils'; import { TestApiProviderProps } from '@backstage/test-utils'; import { TestApiRegistry } from '@backstage/test-utils'; -import { testingLibraryDomTypesQueries } from '@testing-library/dom/types/queries'; import { withLogCollector } from '@backstage/test-utils'; // @public (undocumented) @@ -100,7 +99,7 @@ export { registerMswTestHooks }; export function renderInTestApp( element: JSX.Element, options?: TestAppOptions, -): RenderResult; +): RenderResult; // @public @deprecated (undocumented) export function setupRequestMockHandlers(worker: { diff --git a/packages/frontend-test-utils/src/app/createExtensionTester.tsx b/packages/frontend-test-utils/src/app/createExtensionTester.tsx index fb05270eb8..83ac2aa600 100644 --- a/packages/frontend-test-utils/src/app/createExtensionTester.tsx +++ b/packages/frontend-test-utils/src/app/createExtensionTester.tsx @@ -43,6 +43,7 @@ import { resolveAppNodeSpecs } from '../../../frontend-app-api/src/tree/resolveA import { instantiateAppNodeTree } from '../../../frontend-app-api/src/tree/instantiateAppNodeTree'; // eslint-disable-next-line @backstage/no-relative-monorepo-imports import { readAppExtensionsConfig } from '../../../frontend-app-api/src/tree/readAppExtensionsConfig'; +import { TestAppNavExtension } from './renderInTestApp'; /** @public */ export class ExtensionQuery { @@ -227,6 +228,7 @@ export class ExtensionTester { {children} ), }), + TestAppNavExtension, ], }), ], diff --git a/packages/frontend-test-utils/src/app/renderInTestApp.tsx b/packages/frontend-test-utils/src/app/renderInTestApp.tsx index 73a29ce0bb..dd03cdd2a2 100644 --- a/packages/frontend-test-utils/src/app/renderInTestApp.tsx +++ b/packages/frontend-test-utils/src/app/renderInTestApp.tsx @@ -17,7 +17,7 @@ import React from 'react'; import { Link, MemoryRouter } from 'react-router-dom'; import { createSpecializedApp } from '@backstage/frontend-app-api'; -import { render } from '@testing-library/react'; +import { RenderResult, render } from '@testing-library/react'; import { ConfigReader } from '@backstage/config'; import { JsonObject } from '@backstage/types'; import { @@ -81,7 +81,7 @@ const NavItem = (props: { ); }; -const TestAppNavExtension = createExtension({ +export const TestAppNavExtension = createExtension({ namespace: 'app', name: 'nav', attachTo: { id: 'app/layout', input: 'nav' }, @@ -122,7 +122,7 @@ const TestAppNavExtension = createExtension({ export function renderInTestApp( element: JSX.Element, options?: TestAppOptions, -) { +): RenderResult { const extensions: Array> = [ createExtension({ namespace: 'test', From f1e9c08f978c078692f8fea69f6bd82fc16842fe Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 14 Aug 2024 15:37:09 +0200 Subject: [PATCH 334/372] chore: code review comments Signed-off-by: blam --- .../src/blueprints/NavItemBlueprint.test.tsx | 4 +- .../src/blueprints/NavLogoBlueprint.test.tsx | 2 +- .../src/blueprints/PageBlueprint.test.tsx | 4 +- .../blueprints/SignInPageBlueprint.test.tsx | 2 +- .../src/blueprints/ThemeBlueprint.test.ts | 2 +- .../blueprints/TranslationBlueprint.test.ts | 2 +- .../src/wiring/createExtension.test.ts | 30 +++---- .../src/app/createExtensionTester.test.tsx | 8 +- .../src/app/createExtensionTester.tsx | 78 ++++++++++++++++--- 9 files changed, 95 insertions(+), 37 deletions(-) diff --git a/packages/frontend-plugin-api/src/blueprints/NavItemBlueprint.test.tsx b/packages/frontend-plugin-api/src/blueprints/NavItemBlueprint.test.tsx index 94b9e7b8e6..daa21f88bb 100644 --- a/packages/frontend-plugin-api/src/blueprints/NavItemBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/blueprints/NavItemBlueprint.test.tsx @@ -77,7 +77,7 @@ describe('NavItemBlueprint', () => { const tester = createExtensionTester(extension); - expect(tester.data(NavItemBlueprint.dataRefs.target)).toEqual({ + expect(tester.get(NavItemBlueprint.dataRefs.target)).toEqual({ title: 'TEST', icon: MockIcon, routeRef: mockRouteRef, @@ -97,7 +97,7 @@ describe('NavItemBlueprint', () => { config: { title: 'OVERRIDDEN' }, }); - expect(tester.data(NavItemBlueprint.dataRefs.target)).toEqual({ + expect(tester.get(NavItemBlueprint.dataRefs.target)).toEqual({ title: 'OVERRIDDEN', icon: MockIcon, routeRef: mockRouteRef, diff --git a/packages/frontend-plugin-api/src/blueprints/NavLogoBlueprint.test.tsx b/packages/frontend-plugin-api/src/blueprints/NavLogoBlueprint.test.tsx index 4a96475cf5..b976196080 100644 --- a/packages/frontend-plugin-api/src/blueprints/NavLogoBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/blueprints/NavLogoBlueprint.test.tsx @@ -64,7 +64,7 @@ describe('NavLogoBlueprint', () => { const tester = createExtensionTester(extension); - expect(tester.data(NavLogoBlueprint.dataRefs.logoElements)).toEqual({ + expect(tester.get(NavLogoBlueprint.dataRefs.logoElements)).toEqual({ logoFull, logoIcon, }); diff --git a/packages/frontend-plugin-api/src/blueprints/PageBlueprint.test.tsx b/packages/frontend-plugin-api/src/blueprints/PageBlueprint.test.tsx index d70a426a57..dedc5454bd 100644 --- a/packages/frontend-plugin-api/src/blueprints/PageBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/blueprints/PageBlueprint.test.tsx @@ -101,7 +101,7 @@ describe('PageBlueprint', () => { // TODO(blam): test for the routePath output doesn't work, due to the the way the test harness works // expect(tester.data(coreExtensionData.routePath)).toBe('/test'); - expect(tester.data(coreExtensionData.routeRef)).toBe(mockRouteRef); + expect(tester.get(coreExtensionData.routeRef)).toBe(mockRouteRef); const { getByTestId } = tester.render(); @@ -147,7 +147,7 @@ describe('PageBlueprint', () => { CardBlueprint.make({ name: 'card', params: {} }), ); - const { getByTestId, getByText } = renderInTestApp(tester.element()); + const { getByTestId, getByText } = renderInTestApp(tester.reactElement()); await waitFor(() => expect(getByTestId('card')).toBeInTheDocument()); await waitFor(() => diff --git a/packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.test.tsx b/packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.test.tsx index 61b23e56f9..064021bba2 100644 --- a/packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.test.tsx @@ -62,7 +62,7 @@ describe('SignInPageBlueprint', () => { const tester = createExtensionTester(extension); - const Element = tester.data(SignInPageBlueprint.dataRefs.component)!; + const Element = tester.get(SignInPageBlueprint.dataRefs.component)!; expect(Element).toBeDefined(); diff --git a/packages/frontend-plugin-api/src/blueprints/ThemeBlueprint.test.ts b/packages/frontend-plugin-api/src/blueprints/ThemeBlueprint.test.ts index 40323b6a31..e6daf510eb 100644 --- a/packages/frontend-plugin-api/src/blueprints/ThemeBlueprint.test.ts +++ b/packages/frontend-plugin-api/src/blueprints/ThemeBlueprint.test.ts @@ -56,7 +56,7 @@ describe('ThemeBlueprint', () => { const extension = ThemeBlueprint.make({ params: { theme } }); expect( - createExtensionTester(extension).data(ThemeBlueprint.dataRefs.theme), + createExtensionTester(extension).get(ThemeBlueprint.dataRefs.theme), ).toEqual(theme); }); }); diff --git a/packages/frontend-plugin-api/src/blueprints/TranslationBlueprint.test.ts b/packages/frontend-plugin-api/src/blueprints/TranslationBlueprint.test.ts index dfb918053a..3c7b271322 100644 --- a/packages/frontend-plugin-api/src/blueprints/TranslationBlueprint.test.ts +++ b/packages/frontend-plugin-api/src/blueprints/TranslationBlueprint.test.ts @@ -76,7 +76,7 @@ describe('TranslationBlueprint', () => { }); expect( - createExtensionTester(extension).data( + createExtensionTester(extension).get( TranslationBlueprint.dataRefs.translation, ), ).toBe(messages); diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts index e33bdcb9a1..5902c5c3e7 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts @@ -688,7 +688,7 @@ describe('createExtension', () => { const tester = createExtensionTester(overridden); - expect(tester.data(numberDataRef)).toBe(43); + expect(tester.get(numberDataRef)).toBe(43); }); it('should work functionally with overrides', () => { @@ -722,14 +722,14 @@ describe('createExtension', () => { }, }); - expect(createExtensionTester(overriden).data(stringDataRef)).toBe( + expect(createExtensionTester(overriden).get(stringDataRef)).toBe( 'foo-boom-override-hello', ); expect( createExtensionTester(overriden, { config: { foo: 'hello', bar: 'world' }, - }).data(stringDataRef), + }).get(stringDataRef), ).toBe('foo-hello-override-world'); }); @@ -809,7 +809,7 @@ describe('createExtension', () => { .add(singleExt) .add(multi1Ext) .add(multi2Ext) - .data(outputRef), + .get(outputRef), ).toEqual({ opt: 'orig-opt', single: 'orig-single', @@ -836,7 +836,7 @@ describe('createExtension', () => { .add(singleExt) .add(multi1Ext) .add(multi2Ext) - .data(outputRef), + .get(outputRef), ).toEqual({ opt: 'opt', single: 'single', @@ -862,7 +862,7 @@ describe('createExtension', () => { .add(singleExt) .add(multi1Ext) .add(multi2Ext) - .data(outputRef), + .get(outputRef), ).toEqual({ opt: 'none', single: 'single', @@ -885,7 +885,7 @@ describe('createExtension', () => { .add(singleExt) .add(multi1Ext) .add(multi2Ext) - .data(outputRef), + .get(outputRef), ).toEqual({ opt: 'orig-opt', single: 'orig-single', @@ -912,7 +912,7 @@ describe('createExtension', () => { .add(singleExt) .add(multi1Ext) .add(multi2Ext) - .data(outputRef), + .get(outputRef), ).toEqual({ opt: 'orig-opt', single: 'orig-single', @@ -939,7 +939,7 @@ describe('createExtension', () => { .add(singleExt) .add(multi1Ext) .add(multi2Ext) - .data(outputRef), + .get(outputRef), ).toEqual({ opt: 'orig-opt', single: 'orig-single', @@ -966,7 +966,7 @@ describe('createExtension', () => { .add(singleExt) .add(multi1Ext) .add(multi2Ext) - .data(outputRef), + .get(outputRef), ).toEqual({ opt: 'orig-opt', single: 'orig-single', @@ -997,7 +997,7 @@ describe('createExtension', () => { .add(singleExt) .add(multi1Ext) .add(multi2Ext) - .data(outputRef), + .get(outputRef), ).toEqual({ opt: 'none', single: 'override-orig-single', @@ -1023,7 +1023,7 @@ describe('createExtension', () => { .add(singleExt) .add(multi1Ext) .add(multi2Ext) - .data(outputRef), + .get(outputRef), ).toThrowErrorMatchingInlineSnapshot( `"Failed to instantiate extension 'subject', override data provided for input 'multi' must match the length of the original inputs"`, ); @@ -1046,7 +1046,7 @@ describe('createExtension', () => { .add(singleExt) .add(multi1Ext) .add(multi2Ext) - .data(outputRef), + .get(outputRef), ).toThrowErrorMatchingInlineSnapshot( `"Failed to instantiate extension 'subject', override data for input 'multi' may not mix forwarded inputs with data overrides"`, ); @@ -1069,7 +1069,7 @@ describe('createExtension', () => { .add(singleExt) .add(multi1Ext) .add(multi2Ext) - .data(outputRef), + .get(outputRef), ).toThrowErrorMatchingInlineSnapshot( `"Failed to instantiate extension 'subject', missing required extension data value(s) 'test1'"`, ); @@ -1098,7 +1098,7 @@ describe('createExtension', () => { .add(singleExt) .add(multi1Ext) .add(multi2Ext) - .data(outputRef), + .get(outputRef), ).toThrowErrorMatchingInlineSnapshot( `"Failed to instantiate extension 'subject', extension data 'test2' was provided but not declared"`, ); diff --git a/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx b/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx index 889c815fc7..540a986733 100644 --- a/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx +++ b/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx @@ -246,7 +246,7 @@ describe('createExtensionTester', () => { const tester = createExtensionTester(extension); - expect(tester.data(stringDataRef)).toBe('test-text'); + expect(tester.get(stringDataRef)).toBe('test-text'); }); it('should throw an error if trying to access an instance not provided to the tester', () => { @@ -328,8 +328,8 @@ describe('createExtensionTester', () => { const tester = createExtensionTester(extension).add(extension2); - expect(tester.query(extension).data(stringDataRef)).toBe('nest-test-text'); - expect(tester.query(extension2).data(stringDataRef)).toBe('test-text'); + expect(tester.query(extension).get(stringDataRef)).toBe('nest-test-text'); + expect(tester.query(extension2).get(stringDataRef)).toBe('test-text'); // @ts-expect-error expect(tester.query(extension).input('input').data(stringDataRef)).toBe( 'nest-test-text', @@ -362,6 +362,6 @@ describe('createExtensionTester', () => { inputs: { input: 'test-text' }, }); - expect(tester.query(extension).data(stringDataRef)).toBe('nest-test-text'); + expect(tester.query(extension).get(stringDataRef)).toBe('nest-test-text'); }); }); diff --git a/packages/frontend-test-utils/src/app/createExtensionTester.tsx b/packages/frontend-test-utils/src/app/createExtensionTester.tsx index 83ac2aa600..1ca65478dc 100644 --- a/packages/frontend-test-utils/src/app/createExtensionTester.tsx +++ b/packages/frontend-test-utils/src/app/createExtensionTester.tsx @@ -15,7 +15,7 @@ */ import React from 'react'; -import { MemoryRouter } from 'react-router-dom'; +import { MemoryRouter, Link } from 'react-router-dom'; import { RenderResult, render } from '@testing-library/react'; import { createSpecializedApp } from '@backstage/frontend-app-api'; import { @@ -24,10 +24,15 @@ import { Extension, ExtensionDataRef, ExtensionDefinition, + IconComponent, + RouteRef, coreExtensionData, createExtension, + createExtensionInput, createExtensionOverrides, + createNavItemExtension, createRouterExtension, + useRouteRef, } from '@backstage/frontend-plugin-api'; import { Config, ConfigReader } from '@backstage/config'; import { JsonArray, JsonObject, JsonValue } from '@backstage/types'; @@ -43,7 +48,57 @@ import { resolveAppNodeSpecs } from '../../../frontend-app-api/src/tree/resolveA import { instantiateAppNodeTree } from '../../../frontend-app-api/src/tree/instantiateAppNodeTree'; // eslint-disable-next-line @backstage/no-relative-monorepo-imports import { readAppExtensionsConfig } from '../../../frontend-app-api/src/tree/readAppExtensionsConfig'; -import { TestAppNavExtension } from './renderInTestApp'; + +const NavItem = (props: { + routeRef: RouteRef; + title: string; + icon: IconComponent; +}) => { + const { routeRef, title, icon: Icon } = props; + const link = useRouteRef(routeRef); + if (!link) { + return null; + } + return ( +
  • + + {title} + +
  • + ); +}; + +const TestAppNavExtension = createExtension({ + namespace: 'app', + name: 'nav', + attachTo: { id: 'app/layout', input: 'nav' }, + inputs: { + items: createExtensionInput({ + target: createNavItemExtension.targetDataRef, + }), + }, + output: { + element: coreExtensionData.reactElement, + }, + factory({ inputs }) { + return { + element: ( + + ), + }; + }, +}); /** @public */ export class ExtensionQuery { @@ -69,7 +124,7 @@ export class ExtensionQuery { return instance; } - data(ref: ExtensionDataRef): T | undefined { + get(ref: ExtensionDataRef): T | undefined { return this.instance.getData(ref); } } @@ -164,10 +219,10 @@ export class ExtensionTester { return this; } - data(ref: ExtensionDataRef): T | undefined { + get(ref: ExtensionDataRef): T | undefined { const tree = this.#resolveTree(); - return new ExtensionQuery(tree.root).data(ref); + return new ExtensionQuery(tree.root).get(ref); } query(id: string | ExtensionDefinition): ExtensionQuery { @@ -190,16 +245,16 @@ export class ExtensionTester { return new ExtensionQuery(node); } - element(): JSX.Element { + reactElement(): JSX.Element { const tree = this.#resolveTree(); - const element = new ExtensionQuery(tree.root).data( + const element = new ExtensionQuery(tree.root).get( coreExtensionData.reactElement, ); if (!element) { throw new Error( - 'No element found. Make sure the extension has a `coreExtensionData.reactElement` output, or use the `.get(myComponentDataRef)` method to get the component', + 'No element found. Make sure the extension has a `coreExtensionData.reactElement` output, or use the `.get(...)` to access output data directly instead', ); } @@ -207,33 +262,36 @@ export class ExtensionTester { } /** - * @deprecated Switch to using `renderInTestApp` directly and using `.element()` or `.get(myComponentDataRef)` to get the component you would like to wrap up + * @deprecated Switch to using `renderInTestApp` directly and using `.reactElement()` or `.get(...)` to get the component you w */ render(options?: { config?: JsonObject }): RenderResult { const { config = {} } = options ?? {}; + const [subject] = this.#extensions; if (!subject) { throw new Error( 'No subject found. At least one extension should be added to the tester.', ); } + const app = createSpecializedApp({ features: [ createExtensionOverrides({ extensions: [ ...this.#extensions.map(extension => extension.definition), + TestAppNavExtension, createRouterExtension({ namespace: 'test', Component: ({ children }) => ( {children} ), }), - TestAppNavExtension, ], }), ], config: this.#getConfig(config), }); + return render(app.createRoot()); } From 52367e47f49784b5b0b8620884ac4eb49f3968b0 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 14 Aug 2024 15:37:46 +0200 Subject: [PATCH 335/372] chore: update changeset Signed-off-by: blam Signed-off-by: blam --- .changeset/three-kiwis-turn.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/three-kiwis-turn.md b/.changeset/three-kiwis-turn.md index d5802fa586..eb67cbbbdc 100644 --- a/.changeset/three-kiwis-turn.md +++ b/.changeset/three-kiwis-turn.md @@ -12,8 +12,8 @@ import { const tester = createExtensionTester(extension); -const { getByTestId } = renderInTestApp(tester.element()); +const { getByTestId } = renderInTestApp(tester.reactElement()); // or if you're not using `coreExtensionData.reactElement` as the output ref -const { getByTestId } = renderInTestApp(tester.data(myComponentRef)); +const { getByTestId } = renderInTestApp(tester.get(myComponentRef)); ``` From 2ffa5d730eafde64eb3c1e7bf1d2bea66a3c7367 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 14 Aug 2024 16:23:38 +0200 Subject: [PATCH 336/372] chore: update api-reports Signed-off-by: blam --- packages/frontend-test-utils/api-report.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/frontend-test-utils/api-report.md b/packages/frontend-test-utils/api-report.md index 0cbdace03e..e0f9c164e9 100644 --- a/packages/frontend-test-utils/api-report.md +++ b/packages/frontend-test-utils/api-report.md @@ -43,7 +43,7 @@ export { ErrorWithContext }; export class ExtensionQuery { constructor(node: AppNode); // (undocumented) - data(ref: ExtensionDataRef): T | undefined; + get(ref: ExtensionDataRef): T | undefined; // (undocumented) get instance(): AppNodeInstance; // (undocumented) @@ -60,11 +60,11 @@ export class ExtensionTester { }, ): ExtensionTester; // (undocumented) - data(ref: ExtensionDataRef): T | undefined; - // (undocumented) - element(): JSX.Element; + get(ref: ExtensionDataRef): T | undefined; // (undocumented) query(id: string | ExtensionDefinition): ExtensionQuery; + // (undocumented) + reactElement(): JSX.Element; // @deprecated (undocumented) render(options?: { config?: JsonObject }): RenderResult; } From 1d58ff6425799055d373789303867a3516e4153a Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 15 Aug 2024 13:19:49 +0200 Subject: [PATCH 337/372] chore: update the types a little bit to help with parsing Signed-off-by: blam Signed-off-by: blam --- .../blueprints/SignInPageBlueprint.test.tsx | 2 +- .../src/app/createExtensionTester.test.tsx | 77 ++++++++++++++++++- .../src/app/createExtensionTester.tsx | 46 +++++++---- 3 files changed, 108 insertions(+), 17 deletions(-) diff --git a/packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.test.tsx b/packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.test.tsx index 064021bba2..b45d8ead15 100644 --- a/packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.test.tsx @@ -62,7 +62,7 @@ describe('SignInPageBlueprint', () => { const tester = createExtensionTester(extension); - const Element = tester.get(SignInPageBlueprint.dataRefs.component)!; + const Element = tester.get(SignInPageBlueprint.dataRefs.component); expect(Element).toBeDefined(); diff --git a/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx b/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx index 540a986733..13bdca1990 100644 --- a/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx +++ b/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx @@ -240,8 +240,8 @@ describe('createExtensionTester', () => { const extension = createExtension({ namespace: 'test', attachTo: { id: 'ignored', input: 'ignored' }, - output: { text: stringDataRef }, - factory: () => ({ text: 'test-text' }), + output: [stringDataRef], + factory: () => [stringDataRef('test-text')], }); const tester = createExtensionTester(extension); @@ -297,6 +297,76 @@ describe('createExtensionTester', () => { ); }); + it('should not allow getting extension data for an output that was not defined in the extension', () => { + const internalRef = createExtensionDataRef().with({ + id: 'test.internal', + }); + + const internalRef2 = createExtensionDataRef().with({ + id: 'test.internal2', + }); + + const extension = createExtension({ + namespace: 'test', + name: 'e1', + attachTo: { id: 'ignored', input: 'ignored' }, + output: [stringDataRef, internalRef.optional()], + factory: () => [stringDataRef('test-text')], + }); + + const tester = createExtensionTester(extension); + + const test: string = tester.get(stringDataRef); + + // @ts-expect-error - internalRef is optional + const test2: number = tester.get(internalRef); + + // @ts-expect-error - internalRef2 is not defined in the extension + const test3: number = tester.get(internalRef2); + + expect([test, test2, test3]).toBeDefined(); + }); + + it('should support getting outputs from a query response', () => { + const internalRef = createExtensionDataRef().with({ + id: 'test.internal', + }); + + const internalRef2 = createExtensionDataRef().with({ + id: 'test.internal2', + }); + + const extension = createExtension({ + namespace: 'test', + name: 'e1', + attachTo: { id: 'ignored', input: 'ignored' }, + output: [coreExtensionData.reactElement], + factory: () => [coreExtensionData.reactElement(
    bob
    )], + }); + + const extraExtension = createExtension({ + namespace: 'test', + name: 'e1', + attachTo: { id: 'ignored', input: 'ignored' }, + output: [stringDataRef, internalRef.optional()], + factory: () => [stringDataRef('test-text')], + }); + + const tester = createExtensionTester(extension) + .add(extraExtension) + .query(extraExtension); + + const test: string = tester.get(stringDataRef); + + // @ts-expect-error - internalRef is optional + const test2: number = tester.get(internalRef); + + // @ts-expect-error - internalRef2 is not defined in the extension + const test3: number = tester.get(internalRef2); + + expect([test, test2, test3]).toBeDefined(); + }); + // TODO: this should be implemented // eslint-disable-next-line jest/no-disabled-tests it.skip('should allow querying an extension and getting outputs', () => { @@ -328,7 +398,9 @@ describe('createExtensionTester', () => { const tester = createExtensionTester(extension).add(extension2); + // @ts-expect-error expect(tester.query(extension).get(stringDataRef)).toBe('nest-test-text'); + // @ts-expect-error expect(tester.query(extension2).get(stringDataRef)).toBe('test-text'); // @ts-expect-error expect(tester.query(extension).input('input').data(stringDataRef)).toBe( @@ -362,6 +434,7 @@ describe('createExtensionTester', () => { inputs: { input: 'test-text' }, }); + // @ts-expect-error expect(tester.query(extension).get(stringDataRef)).toBe('nest-test-text'); }); }); diff --git a/packages/frontend-test-utils/src/app/createExtensionTester.tsx b/packages/frontend-test-utils/src/app/createExtensionTester.tsx index 1ca65478dc..b3c1b385e3 100644 --- a/packages/frontend-test-utils/src/app/createExtensionTester.tsx +++ b/packages/frontend-test-utils/src/app/createExtensionTester.tsx @@ -19,6 +19,7 @@ import { MemoryRouter, Link } from 'react-router-dom'; import { RenderResult, render } from '@testing-library/react'; import { createSpecializedApp } from '@backstage/frontend-app-api'; import { + AnyExtensionDataRef, AppNode, AppTree, Extension, @@ -101,7 +102,7 @@ const TestAppNavExtension = createExtension({ }); /** @public */ -export class ExtensionQuery { +export class ExtensionQuery { #node: AppNode; constructor(node: AppNode) { @@ -124,18 +125,24 @@ export class ExtensionQuery { return instance; } - get(ref: ExtensionDataRef): T | undefined { + get( + ref: ExtensionDataRef, + ): UOutput extends ExtensionDataRef + ? IConfig['optional'] extends true + ? IData | undefined + : IData + : never { return this.instance.getData(ref); } } /** @public */ -export class ExtensionTester { +export class ExtensionTester { /** @internal */ - static forSubject( + static forSubject( subject: ExtensionDefinition, options?: { config?: TConfigInput }, - ): ExtensionTester { + ): ExtensionTester { const tester = new ExtensionTester(); const internal = toInternalExtensionDefinition(subject); @@ -192,7 +199,7 @@ export class ExtensionTester { add( extension: ExtensionDefinition, options?: { config?: TConfigInput }, - ): ExtensionTester { + ): ExtensionTester { if (this.#tree) { throw new Error( 'Cannot add more extensions accessing the extension tree', @@ -219,17 +226,24 @@ export class ExtensionTester { return this; } - get(ref: ExtensionDataRef): T | undefined { + get( + ref: ExtensionDataRef, + ): UOutput extends ExtensionDataRef + ? IConfig['optional'] extends true + ? IData | undefined + : IData + : never { const tree = this.#resolveTree(); return new ExtensionQuery(tree.root).get(ref); } - query(id: string | ExtensionDefinition): ExtensionQuery { + query( + extension: ExtensionDefinition, + ): ExtensionQuery { const tree = this.#resolveTree(); - const actualId = - typeof id === 'string' ? id : resolveExtensionDefinition(id).id; + const actualId = resolveExtensionDefinition(extension).id; const node = tree.nodes.get(actualId); @@ -355,9 +369,13 @@ export class ExtensionTester { } /** @public */ -export function createExtensionTester( - subject: ExtensionDefinition, - options?: { config?: TConfig }, -): ExtensionTester { +export function createExtensionTester< + TConfig, + TConfigInput, + UOutput extends AnyExtensionDataRef, +>( + subject: ExtensionDefinition, + options?: { config?: TConfigInput }, +): ExtensionTester { return ExtensionTester.forSubject(subject, options); } From 025b9fe183aab6f62413da657a40164031632fee Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 15 Aug 2024 13:26:15 +0200 Subject: [PATCH 338/372] chore: reflect a data container Signed-off-by: blam Signed-off-by: blam --- packages/frontend-test-utils/api-report.md | 39 ++++++++++++++----- .../blueprints/EntityCardBlueprint.test.tsx | 6 +-- .../EntityContentBlueprint.test.tsx | 12 +++--- 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/packages/frontend-test-utils/api-report.md b/packages/frontend-test-utils/api-report.md index e0f9c164e9..164c222d84 100644 --- a/packages/frontend-test-utils/api-report.md +++ b/packages/frontend-test-utils/api-report.md @@ -7,6 +7,7 @@ import { AnalyticsApi } from '@backstage/frontend-plugin-api'; import { AnalyticsEvent } from '@backstage/frontend-plugin-api'; +import { AnyExtensionDataRef } from '@backstage/frontend-plugin-api'; import { AppNode } from '@backstage/frontend-plugin-api'; import { AppNodeInstance } from '@backstage/frontend-plugin-api'; import { ErrorWithContext } from '@backstage/test-utils'; @@ -30,20 +31,30 @@ import { TestApiRegistry } from '@backstage/test-utils'; import { withLogCollector } from '@backstage/test-utils'; // @public (undocumented) -export function createExtensionTester( - subject: ExtensionDefinition, +export function createExtensionTester< + TConfig, + TConfigInput, + UOutput extends AnyExtensionDataRef, +>( + subject: ExtensionDefinition, options?: { - config?: TConfig; + config?: TConfigInput; }, -): ExtensionTester; +): ExtensionTester; export { ErrorWithContext }; // @public (undocumented) -export class ExtensionQuery { +export class ExtensionQuery { constructor(node: AppNode); // (undocumented) - get(ref: ExtensionDataRef): T | undefined; + get( + ref: ExtensionDataRef, + ): UOutput extends ExtensionDataRef + ? IConfig['optional'] extends true + ? IData | undefined + : IData + : never; // (undocumented) get instance(): AppNodeInstance; // (undocumented) @@ -51,18 +62,26 @@ export class ExtensionQuery { } // @public (undocumented) -export class ExtensionTester { +export class ExtensionTester { // (undocumented) add( extension: ExtensionDefinition, options?: { config?: TConfigInput; }, - ): ExtensionTester; + ): ExtensionTester; // (undocumented) - get(ref: ExtensionDataRef): T | undefined; + get( + ref: ExtensionDataRef, + ): UOutput extends ExtensionDataRef + ? IConfig['optional'] extends true + ? IData | undefined + : IData + : never; // (undocumented) - query(id: string | ExtensionDefinition): ExtensionQuery; + query( + extension: ExtensionDefinition, + ): ExtensionQuery; // (undocumented) reactElement(): JSX.Element; // @deprecated (undocumented) diff --git a/plugins/catalog-react/src/alpha/blueprints/EntityCardBlueprint.test.tsx b/plugins/catalog-react/src/alpha/blueprints/EntityCardBlueprint.test.tsx index db787766fd..0cb7cdead8 100644 --- a/plugins/catalog-react/src/alpha/blueprints/EntityCardBlueprint.test.tsx +++ b/plugins/catalog-react/src/alpha/blueprints/EntityCardBlueprint.test.tsx @@ -100,7 +100,7 @@ describe('EntityCardBlueprint', () => { filter: 'test', }, }), - ).data(EntityCardBlueprint.dataRefs.filterExpression), + ).get(EntityCardBlueprint.dataRefs.filterExpression), ).toBe('test'); expect( @@ -112,7 +112,7 @@ describe('EntityCardBlueprint', () => { }, }), { config: { filter: 'test' } }, - ).data(EntityCardBlueprint.dataRefs.filterExpression), + ).get(EntityCardBlueprint.dataRefs.filterExpression), ).toBe('test'); expect( @@ -124,7 +124,7 @@ describe('EntityCardBlueprint', () => { loader: async () =>
    Test!
    , }, }), - ).data(EntityCardBlueprint.dataRefs.filterFunction), + ).get(EntityCardBlueprint.dataRefs.filterFunction), ).toBe(mockFilter); }); diff --git a/plugins/catalog-react/src/alpha/blueprints/EntityContentBlueprint.test.tsx b/plugins/catalog-react/src/alpha/blueprints/EntityContentBlueprint.test.tsx index dab6013bab..5d91f402de 100644 --- a/plugins/catalog-react/src/alpha/blueprints/EntityContentBlueprint.test.tsx +++ b/plugins/catalog-react/src/alpha/blueprints/EntityContentBlueprint.test.tsx @@ -122,10 +122,10 @@ describe('EntityContentBlueprint', () => { const tester = createExtensionTester(extension); // todo(blam): route paths are always set to / in the createExtensionTester. This will work eventually. - // expect(tester.data(coreExtensionData.routePath)).toBe('/test'); + // expect(tester.get(coreExtensionData.routePath)).toBe('/test'); - expect(tester.data(coreExtensionData.routeRef)).toBe(mockRouteRef); - expect(tester.data(EntityContentBlueprint.dataRefs.title)).toBe('Test'); + expect(tester.get(coreExtensionData.routeRef)).toBe(mockRouteRef); + expect(tester.get(EntityContentBlueprint.dataRefs.title)).toBe('Test'); }); it('should emit the correct filter output', () => { @@ -142,7 +142,7 @@ describe('EntityContentBlueprint', () => { filter: 'test', }, }), - ).data(EntityContentBlueprint.dataRefs.filterExpression), + ).get(EntityContentBlueprint.dataRefs.filterExpression), ).toBe('test'); expect( @@ -156,7 +156,7 @@ describe('EntityContentBlueprint', () => { }, }), { config: { filter: 'test' } }, - ).data(EntityContentBlueprint.dataRefs.filterExpression), + ).get(EntityContentBlueprint.dataRefs.filterExpression), ).toBe('test'); expect( @@ -170,7 +170,7 @@ describe('EntityContentBlueprint', () => { loader: async () =>
    Test!
    , }, }), - ).data(EntityContentBlueprint.dataRefs.filterFunction), + ).get(EntityContentBlueprint.dataRefs.filterFunction), ).toBe(mockFilter); }); From 38f3827e5a21676f384b374d7a8efe4d63736604 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Wed, 14 Aug 2024 15:59:16 +0200 Subject: [PATCH 339/372] Remove deprecated UrlReaders and update usages Signed-off-by: Johan Haals --- .../backend-common/src/deprecated/index.ts | 230 ------------------ .../src/manager/types.ts | 8 +- packages/backend-legacy/package.json | 2 + packages/backend-legacy/src/index.ts | 2 +- packages/backend-legacy/src/types.ts | 4 +- .../catalog-backend-module-aws/package.json | 1 + .../AwsS3DiscoveryProcessor.test.ts | 2 +- .../src/processors/AwsS3DiscoveryProcessor.ts | 4 +- .../src/types.ts | 9 +- .../src/OpenApiRefProcessor.ts | 8 +- .../modules/codeowners/CodeOwnersProcessor.ts | 9 +- .../src/modules/codeowners/lib/read.ts | 6 +- .../modules/core/PlaceholderProcessor.test.ts | 4 +- .../src/modules/core/PlaceholderProcessor.ts | 4 +- .../modules/core/UrlReaderProcessor.test.ts | 5 +- .../src/modules/core/UrlReaderProcessor.ts | 5 +- .../src/service/CatalogBuilder.ts | 4 +- .../confluenceToMarkdown.examples.test.ts | 5 +- .../confluence/confluenceToMarkdown.test.ts | 5 +- .../confluence/confluenceToMarkdown.ts | 4 +- .../package.json | 1 + .../fetch/cookiecutter.examples.test.ts | 5 +- .../src/actions/fetch/cookiecutter.test.ts | 5 +- .../src/actions/fetch/cookiecutter.ts | 9 +- .../fetch/rails/index.examples.test.ts | 5 +- .../src/actions/fetch/rails/index.test.ts | 5 +- .../src/actions/fetch/rails/index.ts | 5 +- plugins/scaffolder-backend/package.json | 1 + .../actions/builtin/createBuiltinActions.ts | 7 +- .../builtin/fetch/plain.examples.test.ts | 4 +- .../actions/builtin/fetch/plain.test.ts | 4 +- .../scaffolder/actions/builtin/fetch/plain.ts | 8 +- .../builtin/fetch/plainFile.examples.test.ts | 4 +- .../actions/builtin/fetch/plainFile.test.ts | 4 +- .../actions/builtin/fetch/plainFile.ts | 4 +- .../builtin/fetch/template.examples.test.ts | 4 +- .../actions/builtin/fetch/template.test.ts | 8 +- .../actions/builtin/fetch/template.ts | 4 +- .../src/service/router.test.ts | 2 +- .../scaffolder-backend/src/service/router.ts | 4 +- .../scaffolder-node/src/actions/fetch.test.ts | 4 +- plugins/scaffolder-node/src/actions/fetch.ts | 6 +- plugins/techdocs-node/src/helpers.ts | 4 +- .../src/stages/prepare/dir.test.ts | 5 +- .../techdocs-node/src/stages/prepare/dir.ts | 6 +- .../techdocs-node/src/stages/prepare/types.ts | 4 +- .../techdocs-node/src/stages/prepare/url.ts | 6 +- yarn.lock | 4 + 48 files changed, 122 insertions(+), 331 deletions(-) diff --git a/packages/backend-common/src/deprecated/index.ts b/packages/backend-common/src/deprecated/index.ts index e3e4101d25..5dfcd322ed 100644 --- a/packages/backend-common/src/deprecated/index.ts +++ b/packages/backend-common/src/deprecated/index.ts @@ -36,45 +36,6 @@ import { type LegacyRootDatabaseService as _LegacyRootDatabaseService, } from '../../../backend-defaults/src/entrypoints/database/DatabaseManager'; -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { AzureUrlReader as _AzureUrlReader } from '../../../backend-defaults/src/entrypoints/urlReader/lib/AzureUrlReader'; -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { BitbucketCloudUrlReader as _BitbucketCloudUrlReader } from '../../../backend-defaults/src/entrypoints/urlReader/lib/BitbucketCloudUrlReader'; -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { BitbucketUrlReader as _BitbucketUrlReader } from '../../../backend-defaults/src/entrypoints/urlReader/lib/BitbucketUrlReader'; -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { BitbucketServerUrlReader as _BitbucketServerUrlReader } from '../../../backend-defaults/src/entrypoints/urlReader/lib/BitbucketServerUrlReader'; -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { GerritUrlReader as _GerritUrlReader } from '../../../backend-defaults/src/entrypoints/urlReader/lib/GerritUrlReader'; -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { GithubUrlReader as _GithubUrlReader } from '../../../backend-defaults/src/entrypoints/urlReader/lib/GithubUrlReader'; -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { GitlabUrlReader as _GitlabUrlReader } from '../../../backend-defaults/src/entrypoints/urlReader/lib/GitlabUrlReader'; -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { GiteaUrlReader as _GiteaUrlReader } from '../../../backend-defaults/src/entrypoints/urlReader/lib/GiteaUrlReader'; -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { HarnessUrlReader as _HarnessUrlReader } from '../../../backend-defaults/src/entrypoints/urlReader/lib/HarnessUrlReader'; -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { AwsS3UrlReader as _AwsS3UrlReader } from '../../../backend-defaults/src/entrypoints/urlReader/lib/AwsS3UrlReader'; -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { FetchUrlReader as _FetchUrlReader } from '../../../backend-defaults/src/entrypoints/urlReader/lib/FetchUrlReader'; -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { UrlReaders as _UrlReaders } from '../../../backend-defaults/src/entrypoints/urlReader/lib/UrlReaders'; -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { ReadUrlResponseFactory as _ReadUrlResponseFactory } from '../../../backend-defaults/src/entrypoints/urlReader/lib/ReadUrlResponseFactory'; -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import type { UrlReadersOptions as _UrlReadersOptions } from '../../../backend-defaults/src/entrypoints/urlReader/lib/UrlReaders'; -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import type { FromReadableArrayOptions as _FromReadableArrayOptions } from '../../../backend-defaults/src/entrypoints/urlReader/lib/types'; -// eslint-disable-next-line @backstage/no-relative-monorepo-imports -import type { - ReaderFactory as _ReaderFactory, - ReadTreeResponseFactory as _ReadTreeResponseFactory, - ReadTreeResponseFactoryOptions as _ReadTreeResponseFactoryOptions, - ReadUrlResponseFactoryFromStreamOptions as _ReadUrlResponseFactoryFromStreamOptions, - UrlReaderPredicateTuple as _UrlReaderPredicateTuple, -} from '../../../backend-defaults/src/entrypoints/urlReader/lib/types'; - import { DiscoveryService, CacheService, @@ -85,16 +46,6 @@ import { resolvePackagePath as _resolvePackagePath, resolveSafeChildPath as _resolveSafeChildPath, isChildPath as _isChildPath, - ReadTreeOptions as _ReadTreeOptions, - ReadTreeResponse as _ReadTreeResponse, - ReadTreeResponseFile as _ReadTreeResponseFile, - ReadTreeResponseDirOptions as _ReadTreeResponseDirOptions, - ReadUrlOptions as _ReadUrlOptions, - ReadUrlResponse as _ReadUrlResponse, - SearchOptions as _SearchOptions, - SearchResponse as _SearchResponse, - SearchResponseFile as _SearchResponseFile, - UrlReaderService as _UrlReaderService, LifecycleService, PluginMetadataService, } from '@backstage/backend-plugin-api'; @@ -290,184 +241,3 @@ export const resolveSafeChildPath = _resolveSafeChildPath; * Please use the `isChildPath` function from the `@backstage/cli-common` package instead. */ export const isChildPath = _isChildPath; - -/** - * @public - * @deprecated Import from `@backstage/backend-defaults/urlReader` instead - */ -export class AzureUrlReader extends _AzureUrlReader {} - -/** - * @public - * @deprecated Import from `@backstage/backend-defaults/urlReader` instead - */ -export class BitbucketCloudUrlReader extends _BitbucketCloudUrlReader {} - -/** - * @public - * @deprecated Import from `@backstage/backend-defaults/urlReader` instead - */ -export class BitbucketUrlReader extends _BitbucketUrlReader {} - -/** - * @public - * @deprecated Import from `@backstage/backend-defaults/urlReader` instead - */ -export class BitbucketServerUrlReader extends _BitbucketServerUrlReader {} - -/** - * @public - * @deprecated Import from `@backstage/backend-defaults/urlReader` instead - */ -export class GerritUrlReader extends _GerritUrlReader {} - -/** - * @public - * @deprecated Import from `@backstage/backend-defaults/urlReader` instead - */ -export class GithubUrlReader extends _GithubUrlReader {} - -/** - * @public - * @deprecated Import from `@backstage/backend-defaults/urlReader` instead - */ -export class GitlabUrlReader extends _GitlabUrlReader {} - -/** - * @public - * @deprecated Import from `@backstage/backend-defaults/urlReader` instead - */ -export class GiteaUrlReader extends _GiteaUrlReader {} - -/** - * @public - * @deprecated Import from `@backstage/backend-defaults/urlReader` instead - */ -export class HarnessUrlReader extends _HarnessUrlReader {} - -/** - * @public - * @deprecated Import from `@backstage/backend-defaults/urlReader` instead - */ -export class AwsS3UrlReader extends _AwsS3UrlReader {} - -/** - * @public - * @deprecated Import from `@backstage/backend-defaults/urlReader` instead - */ -export class FetchUrlReader extends _FetchUrlReader {} - -/** - * @public - * @deprecated Import from `@backstage/backend-defaults/urlReader` instead - */ -export class UrlReaders extends _UrlReaders {} - -/** - * @public - * @deprecated Import from `@backstage/backend-defaults/urlReader` instead - */ -export class ReadUrlResponseFactory extends _ReadUrlResponseFactory {} - -/** - * @public - * @deprecated Import from `@backstage/backend-defaults/urlReader` instead - */ -export type UrlReadersOptions = _UrlReadersOptions; - -/** - * @public - * @deprecated Import from `@backstage/backend-defaults/urlReader` instead - */ -export type FromReadableArrayOptions = _FromReadableArrayOptions; - -/** - * @public - * @deprecated Import from `@backstage/backend-defaults/urlReader` instead - */ -export type ReaderFactory = _ReaderFactory; - -/** - * @public - * @deprecated Import from `@backstage/backend-defaults/urlReader` instead - */ -export type ReadTreeResponseFactory = _ReadTreeResponseFactory; - -/** - * @public - * @deprecated Import from `@backstage/backend-defaults/urlReader` instead - */ -export type ReadTreeResponseFactoryOptions = _ReadTreeResponseFactoryOptions; - -/** - * @public - * @deprecated Import from `@backstage/backend-defaults/urlReader` instead - */ -export type ReadUrlResponseFactoryFromStreamOptions = - _ReadUrlResponseFactoryFromStreamOptions; - -/** - * @public - * @deprecated Import from `@backstage/backend-defaults/urlReader` instead - */ -export type UrlReaderPredicateTuple = _UrlReaderPredicateTuple; - -/** - * @public - * @deprecated Use `UrlReaderServiceReadTreeOptions` from `@backstage/backend-plugin-api` instead - */ -export type ReadTreeOptions = _ReadTreeOptions; - -/** - * @public - * @deprecated Use `UrlReaderServiceReadTreeResponse` from `@backstage/backend-plugin-api` instead - */ -export type ReadTreeResponse = _ReadTreeResponse; - -/** - * @public - * @deprecated Use `UrlReaderServiceReadTreeResponseFile` from `@backstage/backend-plugin-api` instead - */ -export type ReadTreeResponseFile = _ReadTreeResponseFile; - -/** - * @public - * @deprecated Use `UrlReaderServiceReadTreeResponseDirOptions` from `@backstage/backend-plugin-api` instead - */ -export type ReadTreeResponseDirOptions = _ReadTreeResponseDirOptions; - -/** - * @public - * @deprecated Use `UrlReaderServiceReadUrlOptions` from `@backstage/backend-plugin-api` instead - */ -export type ReadUrlOptions = _ReadUrlOptions; - -/** - * @public - * @deprecated Use `UrlReaderServiceReadUrlResponse` from `@backstage/backend-plugin-api` instead - */ -export type ReadUrlResponse = _ReadUrlResponse; - -/** - * @public - * @deprecated Use `UrlReaderServiceSearchOptions` from `@backstage/backend-plugin-api` instead - */ -export type SearchOptions = _SearchOptions; - -/** - * @public - * @deprecated Use `UrlReaderServiceSearchResponse` from `@backstage/backend-plugin-api` instead - */ -export type SearchResponse = _SearchResponse; - -/** - * @public - * @deprecated Use `UrlReaderServiceSearchResponseFile` from `@backstage/backend-plugin-api` instead - */ -export type SearchResponseFile = _SearchResponseFile; - -/** - * @public - * @deprecated Use `UrlReaderService` from `@backstage/backend-plugin-api` instead - */ -export type UrlReader = _UrlReaderService; diff --git a/packages/backend-dynamic-feature-service/src/manager/types.ts b/packages/backend-dynamic-feature-service/src/manager/types.ts index 60b2eb831e..0234a8b66e 100644 --- a/packages/backend-dynamic-feature-service/src/manager/types.ts +++ b/packages/backend-dynamic-feature-service/src/manager/types.ts @@ -21,7 +21,6 @@ import { PluginDatabaseManager, PluginEndpointDiscovery, TokenManager, - UrlReader, } from '@backstage/backend-common'; import { Router } from 'express'; import { PluginTaskScheduler, TaskRunner } from '@backstage/backend-tasks'; @@ -33,7 +32,10 @@ import { HttpPostIngressOptions, } from '@backstage/plugin-events-node'; -import { BackendFeature } from '@backstage/backend-plugin-api'; +import { + BackendFeature, + UrlReaderService, +} from '@backstage/backend-plugin-api'; import { PackagePlatform, PackageRole } from '@backstage/cli-node'; import { CatalogBuilder } from '@backstage/plugin-catalog-backend'; import { TemplateAction } from '@backstage/plugin-scaffolder-node'; @@ -58,7 +60,7 @@ export type LegacyPluginEnvironment = { cache: PluginCacheManager; database: PluginDatabaseManager; config: Config; - reader: UrlReader; + reader: UrlReaderService; discovery: PluginEndpointDiscovery; tokenManager: TokenManager; permissions: PermissionEvaluator; diff --git a/packages/backend-legacy/package.json b/packages/backend-legacy/package.json index 7e01d94dd7..4fee66d925 100644 --- a/packages/backend-legacy/package.json +++ b/packages/backend-legacy/package.json @@ -29,6 +29,8 @@ }, "dependencies": { "@backstage/backend-common": "workspace:^", + "@backstage/backend-defaults": "workspace:^", + "@backstage/backend-plugin-api": "workspace:^", "@backstage/backend-tasks": "workspace:^", "@backstage/catalog-client": "workspace:^", "@backstage/catalog-model": "workspace:^", diff --git a/packages/backend-legacy/src/index.ts b/packages/backend-legacy/src/index.ts index 33520cba03..e422a67267 100644 --- a/packages/backend-legacy/src/index.ts +++ b/packages/backend-legacy/src/index.ts @@ -32,7 +32,6 @@ import { loadBackendConfig, notFoundHandler, ServerTokenManager, - UrlReaders, useHotMemoize, } from '@backstage/backend-common'; import { TaskScheduler } from '@backstage/backend-tasks'; @@ -57,6 +56,7 @@ import { DefaultIdentityClient } from '@backstage/plugin-auth-node'; import { DefaultEventBroker } from '@backstage/plugin-events-backend'; import { DefaultEventsService } from '@backstage/plugin-events-node'; import { DefaultSignalsService } from '@backstage/plugin-signals-node'; +import { UrlReaders } from '@backstage/backend-defaults/urlReader'; function makeCreateEnv(config: Config) { const root = getRootLogger(); diff --git a/packages/backend-legacy/src/types.ts b/packages/backend-legacy/src/types.ts index a75b1620c4..b2c0f58ee9 100644 --- a/packages/backend-legacy/src/types.ts +++ b/packages/backend-legacy/src/types.ts @@ -21,20 +21,20 @@ import { PluginDatabaseManager, PluginEndpointDiscovery, TokenManager, - UrlReader, } from '@backstage/backend-common'; import { PluginTaskScheduler } from '@backstage/backend-tasks'; import { IdentityApi } from '@backstage/plugin-auth-node'; import { PermissionEvaluator } from '@backstage/plugin-permission-common'; import { EventBroker, EventsService } from '@backstage/plugin-events-node'; import { SignalsService } from '@backstage/plugin-signals-node'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; export type PluginEnvironment = { logger: Logger; cache: PluginCacheManager; database: PluginDatabaseManager; config: Config; - reader: UrlReader; + reader: UrlReaderService; discovery: PluginEndpointDiscovery; tokenManager: TokenManager; permissions: PermissionEvaluator; diff --git a/plugins/catalog-backend-module-aws/package.json b/plugins/catalog-backend-module-aws/package.json index 1313cc0dd5..deff27597b 100644 --- a/plugins/catalog-backend-module-aws/package.json +++ b/plugins/catalog-backend-module-aws/package.json @@ -58,6 +58,7 @@ "@aws-sdk/middleware-endpoint": "^3.347.0", "@aws-sdk/types": "^3.347.0", "@backstage/backend-common": "workspace:^", + "@backstage/backend-defaults": "workspace:^", "@backstage/backend-plugin-api": "workspace:^", "@backstage/backend-tasks": "workspace:^", "@backstage/catalog-model": "workspace:^", diff --git a/plugins/catalog-backend-module-aws/src/processors/AwsS3DiscoveryProcessor.test.ts b/plugins/catalog-backend-module-aws/src/processors/AwsS3DiscoveryProcessor.test.ts index 804a17f4f0..70b4ddf2d4 100644 --- a/plugins/catalog-backend-module-aws/src/processors/AwsS3DiscoveryProcessor.test.ts +++ b/plugins/catalog-backend-module-aws/src/processors/AwsS3DiscoveryProcessor.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { UrlReaders } from '@backstage/backend-common'; +import { UrlReaders } from '@backstage/backend-defaults/urlReader'; import { ConfigReader } from '@backstage/config'; import { AwsS3DiscoveryProcessor } from './AwsS3DiscoveryProcessor'; import { diff --git a/plugins/catalog-backend-module-aws/src/processors/AwsS3DiscoveryProcessor.ts b/plugins/catalog-backend-module-aws/src/processors/AwsS3DiscoveryProcessor.ts index d6722d046e..dfff1f5d4f 100644 --- a/plugins/catalog-backend-module-aws/src/processors/AwsS3DiscoveryProcessor.ts +++ b/plugins/catalog-backend-module-aws/src/processors/AwsS3DiscoveryProcessor.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { UrlReader } from '@backstage/backend-common'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; import { isError } from '@backstage/errors'; import { CatalogProcessor, @@ -34,7 +34,7 @@ import limiterFactory from 'p-limit'; * @deprecated Use the `AwsS3EntityProvider` instead (see https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-aws/CHANGELOG.md#014). */ export class AwsS3DiscoveryProcessor implements CatalogProcessor { - constructor(private readonly reader: UrlReader) {} + constructor(private readonly reader: UrlReaderService) {} getProcessorName(): string { return 'AwsS3DiscoveryProcessor'; diff --git a/plugins/catalog-backend-module-incremental-ingestion/src/types.ts b/plugins/catalog-backend-module-incremental-ingestion/src/types.ts index 78309afb36..7c637de841 100644 --- a/plugins/catalog-backend-module-incremental-ingestion/src/types.ts +++ b/plugins/catalog-backend-module-incremental-ingestion/src/types.ts @@ -14,10 +14,7 @@ * limitations under the License. */ -import type { - PluginDatabaseManager, - UrlReader, -} from '@backstage/backend-common'; +import type { PluginDatabaseManager } from '@backstage/backend-common'; import type { PluginTaskScheduler, TaskFunction, @@ -32,7 +29,7 @@ import type { PermissionEvaluator } from '@backstage/plugin-permission-common'; import type { DurationObjectUnits } from 'luxon'; import type { Logger } from 'winston'; import { IncrementalIngestionDatabaseManager } from './database/IncrementalIngestionDatabaseManager'; -import { LoggerService } from '@backstage/backend-plugin-api'; +import { LoggerService, UrlReaderService } from '@backstage/backend-plugin-api'; /** * Ingest entities into the catalog in bite-sized chunks. @@ -192,7 +189,7 @@ export type PluginEnvironment = { database: PluginDatabaseManager; scheduler: PluginTaskScheduler; config: Config; - reader: UrlReader; + reader: UrlReaderService; permissions: PermissionEvaluator; }; diff --git a/plugins/catalog-backend-module-openapi/src/OpenApiRefProcessor.ts b/plugins/catalog-backend-module-openapi/src/OpenApiRefProcessor.ts index 6b00519b2f..39de58466e 100644 --- a/plugins/catalog-backend-module-openapi/src/OpenApiRefProcessor.ts +++ b/plugins/catalog-backend-module-openapi/src/OpenApiRefProcessor.ts @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { UrlReader } from '@backstage/backend-common'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; import { Entity } from '@backstage/catalog-model'; import { Config } from '@backstage/config'; import { ScmIntegrations } from '@backstage/integration'; @@ -29,11 +29,11 @@ import { Logger } from 'winston'; export class OpenApiRefProcessor implements CatalogProcessor { private readonly integrations: ScmIntegrations; private readonly logger: Logger; - private readonly reader: UrlReader; + private readonly reader: UrlReaderService; static fromConfig( config: Config, - options: { logger: Logger; reader: UrlReader }, + options: { logger: Logger; reader: UrlReaderService }, ) { const integrations = ScmIntegrations.fromConfig(config); @@ -46,7 +46,7 @@ export class OpenApiRefProcessor implements CatalogProcessor { constructor(options: { integrations: ScmIntegrations; logger: Logger; - reader: UrlReader; + reader: UrlReaderService; }) { this.integrations = options.integrations; this.logger = options.logger; diff --git a/plugins/catalog-backend/src/modules/codeowners/CodeOwnersProcessor.ts b/plugins/catalog-backend/src/modules/codeowners/CodeOwnersProcessor.ts index b4ed33d162..9b8d2a3bbf 100644 --- a/plugins/catalog-backend/src/modules/codeowners/CodeOwnersProcessor.ts +++ b/plugins/catalog-backend/src/modules/codeowners/CodeOwnersProcessor.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import { UrlReader } from '@backstage/backend-common'; import { Entity } from '@backstage/catalog-model'; import { Config } from '@backstage/config'; import { @@ -24,7 +23,7 @@ import { import { LocationSpec } from '@backstage/plugin-catalog-common'; import { CatalogProcessor } from '@backstage/plugin-catalog-node'; import { findCodeOwnerByTarget } from './lib'; -import { LoggerService } from '@backstage/backend-plugin-api'; +import { LoggerService, UrlReaderService } from '@backstage/backend-plugin-api'; const ALLOWED_KINDS = ['API', 'Component', 'Domain', 'Resource', 'System']; const ALLOWED_LOCATION_TYPES = ['url']; @@ -33,11 +32,11 @@ const ALLOWED_LOCATION_TYPES = ['url']; export class CodeOwnersProcessor implements CatalogProcessor { private readonly integrations: ScmIntegrationRegistry; private readonly logger: LoggerService; - private readonly reader: UrlReader; + private readonly reader: UrlReaderService; static fromConfig( config: Config, - options: { logger: LoggerService; reader: UrlReader }, + options: { logger: LoggerService; reader: UrlReaderService }, ) { const integrations = ScmIntegrations.fromConfig(config); @@ -50,7 +49,7 @@ export class CodeOwnersProcessor implements CatalogProcessor { constructor(options: { integrations: ScmIntegrationRegistry; logger: LoggerService; - reader: UrlReader; + reader: UrlReaderService; }) { this.integrations = options.integrations; this.logger = options.logger; diff --git a/plugins/catalog-backend/src/modules/codeowners/lib/read.ts b/plugins/catalog-backend/src/modules/codeowners/lib/read.ts index 6a5234c94f..155405ddf8 100644 --- a/plugins/catalog-backend/src/modules/codeowners/lib/read.ts +++ b/plugins/catalog-backend/src/modules/codeowners/lib/read.ts @@ -14,15 +14,15 @@ * limitations under the License. */ -import { UrlReader } from '@backstage/backend-common'; import { NotFoundError } from '@backstage/errors'; import { ScmIntegration } from '@backstage/integration'; import 'core-js/features/promise'; // NOTE: This can be removed when ES2021 is implemented import { resolveCodeOwner } from './resolve'; import { scmCodeOwnersPaths } from './scm'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; export async function readCodeOwners( - reader: UrlReader, + reader: UrlReaderService, sourceUrl: string, codeownersPaths: string[], ): Promise { @@ -49,7 +49,7 @@ export async function readCodeOwners( } export async function findCodeOwnerByTarget( - reader: UrlReader, + reader: UrlReaderService, targetUrl: string, scmIntegration: ScmIntegration, ): Promise { diff --git a/plugins/catalog-backend/src/modules/core/PlaceholderProcessor.test.ts b/plugins/catalog-backend/src/modules/core/PlaceholderProcessor.test.ts index 094f8f1df8..c2c49ea1cb 100644 --- a/plugins/catalog-backend/src/modules/core/PlaceholderProcessor.test.ts +++ b/plugins/catalog-backend/src/modules/core/PlaceholderProcessor.test.ts @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { UrlReader } from '@backstage/backend-common'; import { Entity } from '@backstage/catalog-model'; import { ConfigReader } from '@backstage/config'; import { ScmIntegrations } from '@backstage/integration'; @@ -29,11 +28,12 @@ import { textPlaceholderResolver, yamlPlaceholderResolver, } from './PlaceholderProcessor'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; const integrations = ScmIntegrations.fromConfig(new ConfigReader({})); describe('PlaceholderProcessor', () => { - const reader: jest.Mocked = { + const reader: jest.Mocked = { readTree: jest.fn(), search: jest.fn(), readUrl: jest.fn(), diff --git a/plugins/catalog-backend/src/modules/core/PlaceholderProcessor.ts b/plugins/catalog-backend/src/modules/core/PlaceholderProcessor.ts index f6431cc9f5..bdbb0433d7 100644 --- a/plugins/catalog-backend/src/modules/core/PlaceholderProcessor.ts +++ b/plugins/catalog-backend/src/modules/core/PlaceholderProcessor.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import { UrlReader } from '@backstage/backend-common'; import { Entity } from '@backstage/catalog-model'; import { JsonValue } from '@backstage/types'; import { ScmIntegrationRegistry } from '@backstage/integration'; @@ -27,11 +26,12 @@ import { PlaceholderResolverParams, processingResult, } from '@backstage/plugin-catalog-node'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; /** @public */ export type PlaceholderProcessorOptions = { resolvers: Record; - reader: UrlReader; + reader: UrlReaderService; integrations: ScmIntegrationRegistry; }; diff --git a/plugins/catalog-backend/src/modules/core/UrlReaderProcessor.test.ts b/plugins/catalog-backend/src/modules/core/UrlReaderProcessor.test.ts index 7d1578db00..7e895c5344 100644 --- a/plugins/catalog-backend/src/modules/core/UrlReaderProcessor.test.ts +++ b/plugins/catalog-backend/src/modules/core/UrlReaderProcessor.test.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import { UrlReader, UrlReaders } from '@backstage/backend-common'; import { mockServices, registerMswTestHooks, @@ -31,6 +30,8 @@ import { } from '@backstage/plugin-catalog-node'; import { defaultEntityDataParser } from '../util/parse'; import { UrlReaderProcessor } from './UrlReaderProcessor'; +import { UrlReaders } from '@backstage/backend-defaults/urlReader'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; describe('UrlReaderProcessor', () => { const mockApiOrigin = 'http://localhost'; @@ -192,7 +193,7 @@ describe('UrlReaderProcessor', () => { it('uses search when there are globs', async () => { const logger = mockServices.logger.mock(); - const reader: jest.Mocked = { + const reader: jest.Mocked = { readUrl: jest.fn(), readTree: jest.fn(), search: jest.fn().mockImplementation(async () => []), diff --git a/plugins/catalog-backend/src/modules/core/UrlReaderProcessor.ts b/plugins/catalog-backend/src/modules/core/UrlReaderProcessor.ts index 89f9e74685..b623098171 100644 --- a/plugins/catalog-backend/src/modules/core/UrlReaderProcessor.ts +++ b/plugins/catalog-backend/src/modules/core/UrlReaderProcessor.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import { UrlReader } from '@backstage/backend-common'; import { Entity } from '@backstage/catalog-model'; import { assertError } from '@backstage/errors'; import limiterFactory from 'p-limit'; @@ -29,7 +28,7 @@ import { CatalogProcessorResult, processingResult, } from '@backstage/plugin-catalog-node'; -import { LoggerService } from '@backstage/backend-plugin-api'; +import { LoggerService, UrlReaderService } from '@backstage/backend-plugin-api'; const CACHE_KEY = 'v1'; @@ -47,7 +46,7 @@ type CacheItem = { export class UrlReaderProcessor implements CatalogProcessor { constructor( private readonly options: { - reader: UrlReader; + reader: UrlReaderService; logger: LoggerService; }, ) {} diff --git a/plugins/catalog-backend/src/service/CatalogBuilder.ts b/plugins/catalog-backend/src/service/CatalogBuilder.ts index aabef51195..344c231f7c 100644 --- a/plugins/catalog-backend/src/service/CatalogBuilder.ts +++ b/plugins/catalog-backend/src/service/CatalogBuilder.ts @@ -18,7 +18,6 @@ import { createLegacyAuthAdapters, HostDiscovery, PluginDatabaseManager, - UrlReader, } from '@backstage/backend-common'; import { PluginTaskScheduler } from '@backstage/backend-tasks'; import { @@ -112,6 +111,7 @@ import { HttpAuthService, LoggerService, PermissionsService, + UrlReaderService, } from '@backstage/backend-plugin-api'; /** @@ -128,7 +128,7 @@ export type CatalogEnvironment = { logger: LoggerService; database: PluginDatabaseManager; config: Config; - reader: UrlReader; + reader: UrlReaderService; permissions: PermissionsService | PermissionAuthorizer; scheduler?: PluginTaskScheduler; discovery?: DiscoveryService; diff --git a/plugins/scaffolder-backend-module-confluence-to-markdown/src/actions/confluence/confluenceToMarkdown.examples.test.ts b/plugins/scaffolder-backend-module-confluence-to-markdown/src/actions/confluence/confluenceToMarkdown.examples.test.ts index 36ae750723..5cf8969b55 100644 --- a/plugins/scaffolder-backend-module-confluence-to-markdown/src/actions/confluence/confluenceToMarkdown.examples.test.ts +++ b/plugins/scaffolder-backend-module-confluence-to-markdown/src/actions/confluence/confluenceToMarkdown.examples.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ import { createConfluenceToMarkdownAction } from './confluenceToMarkdown'; -import { UrlReader, loggerToWinstonLogger } from '@backstage/backend-common'; +import { loggerToWinstonLogger } from '@backstage/backend-common'; import { ConfigReader } from '@backstage/config'; import { ScmIntegrations } from '@backstage/integration'; import { @@ -28,6 +28,7 @@ import { examples } from './confluenceToMarkdown.examples'; import yaml from 'yaml'; import { ActionContext } from '@backstage/plugin-scaffolder-node'; import { createMockActionContext } from '@backstage/plugin-scaffolder-node-test-utils'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; describe('confluence:transform:markdown examples', () => { const baseUrl = `https://confluence.example.com`; @@ -51,7 +52,7 @@ describe('confluence:transform:markdown examples', () => { }), ); - let reader: UrlReader; + let reader: UrlReaderService; let mockContext: ActionContext<{ confluenceUrls: string[]; repoUrl: string; diff --git a/plugins/scaffolder-backend-module-confluence-to-markdown/src/actions/confluence/confluenceToMarkdown.test.ts b/plugins/scaffolder-backend-module-confluence-to-markdown/src/actions/confluence/confluenceToMarkdown.test.ts index 4c3c6b891f..a54e5dcc63 100644 --- a/plugins/scaffolder-backend-module-confluence-to-markdown/src/actions/confluence/confluenceToMarkdown.test.ts +++ b/plugins/scaffolder-backend-module-confluence-to-markdown/src/actions/confluence/confluenceToMarkdown.test.ts @@ -15,7 +15,7 @@ */ import { createConfluenceToMarkdownAction } from './confluenceToMarkdown'; -import { UrlReader, loggerToWinstonLogger } from '@backstage/backend-common'; +import { loggerToWinstonLogger } from '@backstage/backend-common'; import { ConfigReader } from '@backstage/config'; import { ScmIntegrations } from '@backstage/integration'; import { @@ -27,6 +27,7 @@ import type { ActionContext } from '@backstage/plugin-scaffolder-node'; import { rest } from 'msw'; import { setupServer } from 'msw/node'; import { createMockActionContext } from '@backstage/plugin-scaffolder-node-test-utils'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; describe('confluence:transform:markdown', () => { const baseUrl = `https://nodomain.confluence.com`; @@ -50,7 +51,7 @@ describe('confluence:transform:markdown', () => { }), ); - let reader: UrlReader; + let reader: UrlReaderService; let mockContext: ActionContext<{ confluenceUrls: string[]; repoUrl: string; diff --git a/plugins/scaffolder-backend-module-confluence-to-markdown/src/actions/confluence/confluenceToMarkdown.ts b/plugins/scaffolder-backend-module-confluence-to-markdown/src/actions/confluence/confluenceToMarkdown.ts index e88f42e39c..aa9f94988a 100644 --- a/plugins/scaffolder-backend-module-confluence-to-markdown/src/actions/confluence/confluenceToMarkdown.ts +++ b/plugins/scaffolder-backend-module-confluence-to-markdown/src/actions/confluence/confluenceToMarkdown.ts @@ -15,7 +15,6 @@ */ import { Config } from '@backstage/config'; -import { UrlReader } from '@backstage/backend-common'; import { ScmIntegrations } from '@backstage/integration'; import { createTemplateAction, @@ -34,13 +33,14 @@ import { getConfluenceConfig, } from './helpers'; import { examples } from './confluenceToMarkdown.examples'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; /** * @public */ export const createConfluenceToMarkdownAction = (options: { - reader: UrlReader; + reader: UrlReaderService; integrations: ScmIntegrations; config: Config; }) => { diff --git a/plugins/scaffolder-backend-module-cookiecutter/package.json b/plugins/scaffolder-backend-module-cookiecutter/package.json index 6029ed02b4..f412ff11b1 100644 --- a/plugins/scaffolder-backend-module-cookiecutter/package.json +++ b/plugins/scaffolder-backend-module-cookiecutter/package.json @@ -44,6 +44,7 @@ }, "dependencies": { "@backstage/backend-common": "workspace:^", + "@backstage/backend-defaults": "workspace:^", "@backstage/backend-plugin-api": "workspace:^", "@backstage/config": "workspace:^", "@backstage/errors": "workspace:^", diff --git a/plugins/scaffolder-backend-module-cookiecutter/src/actions/fetch/cookiecutter.examples.test.ts b/plugins/scaffolder-backend-module-cookiecutter/src/actions/fetch/cookiecutter.examples.test.ts index ae46ef1bd6..73c17d8ac0 100644 --- a/plugins/scaffolder-backend-module-cookiecutter/src/actions/fetch/cookiecutter.examples.test.ts +++ b/plugins/scaffolder-backend-module-cookiecutter/src/actions/fetch/cookiecutter.examples.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { UrlReader, ContainerRunner } from '@backstage/backend-common'; +import { ContainerRunner } from '@backstage/backend-common'; import { ConfigReader } from '@backstage/config'; import { JsonObject } from '@backstage/types'; import { ScmIntegrations } from '@backstage/integration'; @@ -25,6 +25,7 @@ import type { ActionContext } from '@backstage/plugin-scaffolder-node'; import { createMockActionContext } from '@backstage/plugin-scaffolder-node-test-utils'; import { examples } from './cookiecutter.examples'; import yaml from 'yaml'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; const executeShellCommand = jest.fn(); const commandExists = jest.fn(); @@ -71,7 +72,7 @@ describe('fetch:cookiecutter', () => { runContainer: jest.fn(), }; - const mockReader: UrlReader = { + const mockReader: UrlReaderService = { readUrl: jest.fn(), readTree: jest.fn(), search: jest.fn(), diff --git a/plugins/scaffolder-backend-module-cookiecutter/src/actions/fetch/cookiecutter.test.ts b/plugins/scaffolder-backend-module-cookiecutter/src/actions/fetch/cookiecutter.test.ts index fad544488a..52946ce7fd 100644 --- a/plugins/scaffolder-backend-module-cookiecutter/src/actions/fetch/cookiecutter.test.ts +++ b/plugins/scaffolder-backend-module-cookiecutter/src/actions/fetch/cookiecutter.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { UrlReader, ContainerRunner } from '@backstage/backend-common'; +import { ContainerRunner } from '@backstage/backend-common'; import { ConfigReader } from '@backstage/config'; import { JsonObject } from '@backstage/types'; import { ScmIntegrations } from '@backstage/integration'; @@ -24,6 +24,7 @@ import { join } from 'path'; import type { ActionContext } from '@backstage/plugin-scaffolder-node'; import { createMockActionContext } from '@backstage/plugin-scaffolder-node-test-utils'; import { Writable } from 'stream'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; const executeShellCommand = jest.fn(); const commandExists = jest.fn(); @@ -70,7 +71,7 @@ describe('fetch:cookiecutter', () => { runContainer: jest.fn(), }; - const mockReader: UrlReader = { + const mockReader: UrlReaderService = { readUrl: jest.fn(), readTree: jest.fn(), search: jest.fn(), diff --git a/plugins/scaffolder-backend-module-cookiecutter/src/actions/fetch/cookiecutter.ts b/plugins/scaffolder-backend-module-cookiecutter/src/actions/fetch/cookiecutter.ts index efbe0a07cf..6e540d7fca 100644 --- a/plugins/scaffolder-backend-module-cookiecutter/src/actions/fetch/cookiecutter.ts +++ b/plugins/scaffolder-backend-module-cookiecutter/src/actions/fetch/cookiecutter.ts @@ -14,8 +14,11 @@ * limitations under the License. */ -import { ContainerRunner, UrlReader } from '@backstage/backend-common'; -import { resolveSafeChildPath } from '@backstage/backend-plugin-api'; +import { ContainerRunner } from '@backstage/backend-common'; +import { + UrlReaderService, + resolveSafeChildPath, +} from '@backstage/backend-plugin-api'; import { JsonObject, JsonValue } from '@backstage/types'; import { InputError } from '@backstage/errors'; import { ScmIntegrations } from '@backstage/integration'; @@ -140,7 +143,7 @@ export class CookiecutterRunner { * @public */ export function createFetchCookiecutterAction(options: { - reader: UrlReader; + reader: UrlReaderService; integrations: ScmIntegrations; containerRunner?: ContainerRunner; }) { diff --git a/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/index.examples.test.ts b/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/index.examples.test.ts index 37e678ab6a..6bc84e04ad 100644 --- a/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/index.examples.test.ts +++ b/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/index.examples.test.ts @@ -27,7 +27,7 @@ jest.mock('./railsNewRunner', () => { }; }); -import { ContainerRunner, UrlReader } from '@backstage/backend-common'; +import { ContainerRunner } from '@backstage/backend-common'; import { ConfigReader } from '@backstage/config'; import { ScmIntegrations } from '@backstage/integration'; import { resolve as resolvePath } from 'path'; @@ -37,6 +37,7 @@ import { createMockDirectory } from '@backstage/backend-test-utils'; import { createMockActionContext } from '@backstage/plugin-scaffolder-node-test-utils'; import { examples } from './index.examples'; import yaml from 'yaml'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; describe('fetch:rails', () => { const mockDir = createMockDirectory(); @@ -66,7 +67,7 @@ describe('fetch:rails', () => { workspacePath: mockDir.path, }); - const mockReader: UrlReader = { + const mockReader: UrlReaderService = { readUrl: jest.fn(), readTree: jest.fn(), search: jest.fn(), diff --git a/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/index.test.ts b/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/index.test.ts index 40514dc7c5..616c90e0de 100644 --- a/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/index.test.ts +++ b/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/index.test.ts @@ -27,7 +27,7 @@ jest.mock('./railsNewRunner', () => { }; }); -import { ContainerRunner, UrlReader } from '@backstage/backend-common'; +import { ContainerRunner } from '@backstage/backend-common'; import { ConfigReader } from '@backstage/config'; import { ScmIntegrations } from '@backstage/integration'; import { resolve as resolvePath } from 'path'; @@ -36,6 +36,7 @@ import { fetchContents } from '@backstage/plugin-scaffolder-node'; import { createMockDirectory } from '@backstage/backend-test-utils'; import { createMockActionContext } from '@backstage/plugin-scaffolder-node-test-utils'; import { Writable } from 'stream'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; describe('fetch:rails', () => { const mockDir = createMockDirectory(); @@ -65,7 +66,7 @@ describe('fetch:rails', () => { workspacePath: mockDir.path, }); - const mockReader: UrlReader = { + const mockReader: UrlReaderService = { readUrl: jest.fn(), readTree: jest.fn(), search: jest.fn(), diff --git a/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/index.ts b/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/index.ts index 94a2a3539b..4d5db0f3ef 100644 --- a/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/index.ts +++ b/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/index.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { ContainerRunner, UrlReader } from '@backstage/backend-common'; +import { ContainerRunner } from '@backstage/backend-common'; import { JsonObject } from '@backstage/types'; import { InputError } from '@backstage/errors'; import { ScmIntegrations } from '@backstage/integration'; @@ -28,6 +28,7 @@ import { resolve as resolvePath } from 'path'; import { RailsNewRunner } from './railsNewRunner'; import { PassThrough } from 'stream'; import { examples } from './index.examples'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; /** * Creates the `fetch:rails` Scaffolder action. @@ -40,7 +41,7 @@ import { examples } from './index.examples'; * @public */ export function createFetchRailsAction(options: { - reader: UrlReader; + reader: UrlReaderService; integrations: ScmIntegrations; containerRunner?: ContainerRunner; /** A list of image names that are allowed to be passed as imageName input */ diff --git a/plugins/scaffolder-backend/package.json b/plugins/scaffolder-backend/package.json index a8413f9931..3a61e3d464 100644 --- a/plugins/scaffolder-backend/package.json +++ b/plugins/scaffolder-backend/package.json @@ -62,6 +62,7 @@ }, "dependencies": { "@backstage/backend-common": "workspace:^", + "@backstage/backend-defaults": "workspace:^", "@backstage/backend-plugin-api": "workspace:^", "@backstage/backend-tasks": "workspace:^", "@backstage/catalog-client": "workspace:^", diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts index 673776bec9..dba867c96b 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import { UrlReader } from '@backstage/backend-common'; import { CatalogApi } from '@backstage/catalog-client'; import { Config } from '@backstage/config'; import { @@ -82,7 +81,7 @@ import { } from '@backstage/plugin-scaffolder-backend-module-gitlab'; import { createPublishGiteaAction } from '@backstage/plugin-scaffolder-backend-module-gitea'; -import { AuthService } from '@backstage/backend-plugin-api'; +import { AuthService, UrlReaderService } from '@backstage/backend-plugin-api'; /** * The options passed to {@link createBuiltinActions} @@ -90,9 +89,9 @@ import { AuthService } from '@backstage/backend-plugin-api'; */ export interface CreateBuiltInActionsOptions { /** - * The {@link @backstage/backend-common#UrlReader} interface that will be used in the default actions. + * The {@link @backstage/backend-plugin-api#UrlReaderService} interface that will be used in the default actions. */ - reader: UrlReader; + reader: UrlReaderService; /** * The {@link @backstage/integrations#ScmIntegrations} that will be used in the default actions. */ diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plain.examples.test.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plain.examples.test.ts index 82a32fcbac..9dbb1f9a03 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plain.examples.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plain.examples.test.ts @@ -17,13 +17,13 @@ import yaml from 'yaml'; import { resolve as resolvePath } from 'path'; -import { UrlReader } from '@backstage/backend-common'; import { ConfigReader } from '@backstage/config'; import { ScmIntegrations } from '@backstage/integration'; import { createFetchPlainAction } from './plain'; import { fetchContents } from '@backstage/plugin-scaffolder-node'; import { createMockActionContext } from '@backstage/plugin-scaffolder-node-test-utils'; import { examples } from './plain.examples'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; jest.mock('@backstage/plugin-scaffolder-node', () => ({ ...jest.requireActual('@backstage/plugin-scaffolder-node'), @@ -38,7 +38,7 @@ describe('fetch:plain examples', () => { }, }), ); - const reader: UrlReader = { + const reader: UrlReaderService = { readUrl: jest.fn(), readTree: jest.fn(), search: jest.fn(), diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plain.test.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plain.test.ts index bc20fafe19..8a52ef7392 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plain.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plain.test.ts @@ -21,11 +21,11 @@ jest.mock('@backstage/plugin-scaffolder-node', () => { import { resolve as resolvePath } from 'path'; import { createMockActionContext } from '@backstage/plugin-scaffolder-node-test-utils'; -import { UrlReader } from '@backstage/backend-common'; import { ConfigReader } from '@backstage/config'; import { ScmIntegrations } from '@backstage/integration'; import { fetchContents } from '@backstage/plugin-scaffolder-node'; import { createFetchPlainAction } from './plain'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; describe('fetch:plain', () => { const integrations = ScmIntegrations.fromConfig( @@ -35,7 +35,7 @@ describe('fetch:plain', () => { }, }), ); - const reader: UrlReader = { + const reader: UrlReaderService = { readUrl: jest.fn(), readTree: jest.fn(), search: jest.fn(), diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plain.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plain.ts index c6beaa2d67..a4f795dd54 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plain.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plain.ts @@ -14,8 +14,10 @@ * limitations under the License. */ -import { UrlReader } from '@backstage/backend-common'; -import { resolveSafeChildPath } from '@backstage/backend-plugin-api'; +import { + resolveSafeChildPath, + UrlReaderService, +} from '@backstage/backend-plugin-api'; import { ScmIntegrations } from '@backstage/integration'; import { examples } from './plain.examples'; @@ -32,7 +34,7 @@ export const ACTION_ID = 'fetch:plain'; * @public */ export function createFetchPlainAction(options: { - reader: UrlReader; + reader: UrlReaderService; integrations: ScmIntegrations; }) { const { reader, integrations } = options; diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plainFile.examples.test.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plainFile.examples.test.ts index 9978d6d8f5..a091a6ecfe 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plainFile.examples.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plainFile.examples.test.ts @@ -23,12 +23,12 @@ jest.mock('@backstage/plugin-scaffolder-node', () => { import yaml from 'yaml'; import { resolve as resolvePath } from 'path'; -import { UrlReader } from '@backstage/backend-common'; import { ConfigReader } from '@backstage/config'; import { ScmIntegrations } from '@backstage/integration'; import { createFetchPlainFileAction } from './plainFile'; import { fetchFile } from '@backstage/plugin-scaffolder-node'; import { examples } from './plainFile.examples'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; describe('fetch:plain:file examples', () => { const integrations = ScmIntegrations.fromConfig( @@ -38,7 +38,7 @@ describe('fetch:plain:file examples', () => { }, }), ); - const reader: UrlReader = { + const reader: UrlReaderService = { readUrl: jest.fn(), readTree: jest.fn(), search: jest.fn(), diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plainFile.test.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plainFile.test.ts index bf40c7ad0e..637a209bd9 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plainFile.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plainFile.test.ts @@ -21,11 +21,11 @@ jest.mock('@backstage/plugin-scaffolder-node', () => { import { resolve as resolvePath } from 'path'; import { createMockActionContext } from '@backstage/plugin-scaffolder-node-test-utils'; -import { UrlReader } from '@backstage/backend-common'; import { ConfigReader } from '@backstage/config'; import { ScmIntegrations } from '@backstage/integration'; import { fetchFile } from '@backstage/plugin-scaffolder-node'; import { createFetchPlainFileAction } from './plainFile'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; describe('fetch:plain:file', () => { const integrations = ScmIntegrations.fromConfig( @@ -35,7 +35,7 @@ describe('fetch:plain:file', () => { }, }), ); - const reader: UrlReader = { + const reader: UrlReaderService = { readUrl: jest.fn(), readTree: jest.fn(), search: jest.fn(), diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plainFile.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plainFile.ts index 92db7aa3ed..a07c9bfc6b 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plainFile.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plainFile.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { UrlReader } from '@backstage/backend-common'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; import { resolveSafeChildPath } from '@backstage/backend-plugin-api'; import { ScmIntegrations } from '@backstage/integration'; import { examples } from './plainFile.examples'; @@ -29,7 +29,7 @@ import { * @public */ export function createFetchPlainFileAction(options: { - reader: UrlReader; + reader: UrlReaderService; integrations: ScmIntegrations; }) { const { reader, integrations } = options; diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.examples.test.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.examples.test.ts index 02fe0c30a4..41ce875317 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.examples.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.examples.test.ts @@ -16,7 +16,7 @@ import { join as joinPath, sep as pathSep } from 'path'; import fs from 'fs-extra'; -import { UrlReader } from '@backstage/backend-common'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; import { resolvePackagePath } from '@backstage/backend-plugin-api'; import { ScmIntegrations } from '@backstage/integration'; import { createMockActionContext } from '@backstage/plugin-scaffolder-node-test-utils'; @@ -71,7 +71,7 @@ describe('fetch:template examples', () => { beforeEach(() => { mockDir.clear(); action = createFetchTemplateAction({ - reader: Symbol('UrlReader') as unknown as UrlReader, + reader: Symbol('UrlReader') as unknown as UrlReaderService, integrations: Symbol('Integrations') as unknown as ScmIntegrations, }); }); diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.test.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.test.ts index 0542b6a50d..87a6c84750 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.test.ts @@ -21,8 +21,10 @@ jest.mock('@backstage/plugin-scaffolder-node', () => { import { join as joinPath, sep as pathSep } from 'path'; import fs from 'fs-extra'; -import { UrlReader } from '@backstage/backend-common'; -import { resolvePackagePath } from '@backstage/backend-plugin-api'; +import { + UrlReaderService, + resolvePackagePath, +} from '@backstage/backend-plugin-api'; import { ScmIntegrations } from '@backstage/integration'; import { createFetchTemplateAction } from './template'; import { @@ -78,7 +80,7 @@ describe('fetch:template', () => { workspace: {}, }); action = createFetchTemplateAction({ - reader: Symbol('UrlReader') as unknown as UrlReader, + reader: Symbol('UrlReaderService') as unknown as UrlReaderService, integrations: Symbol('Integrations') as unknown as ScmIntegrations, }); }); diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.ts index 0983199339..2025202c22 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.ts @@ -15,7 +15,7 @@ */ import { extname } from 'path'; -import { UrlReader } from '@backstage/backend-common'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; import { resolveSafeChildPath } from '@backstage/backend-plugin-api'; import { InputError } from '@backstage/errors'; import { ScmIntegrations } from '@backstage/integration'; @@ -40,7 +40,7 @@ import { examples } from './template.examples'; * @public */ export function createFetchTemplateAction(options: { - reader: UrlReader; + reader: UrlReaderService; integrations: ScmIntegrations; additionalTemplateFilters?: Record; additionalTemplateGlobals?: Record; diff --git a/plugins/scaffolder-backend/src/service/router.test.ts b/plugins/scaffolder-backend/src/service/router.test.ts index e53f3a5dd9..51e11d630f 100644 --- a/plugins/scaffolder-backend/src/service/router.test.ts +++ b/plugins/scaffolder-backend/src/service/router.test.ts @@ -18,7 +18,6 @@ import { DatabaseManager, loggerToWinstonLogger, PluginDatabaseManager, - UrlReaders, } from '@backstage/backend-common'; import { CatalogApi } from '@backstage/catalog-client'; import { ConfigReader } from '@backstage/config'; @@ -48,6 +47,7 @@ import { import { mockCredentials, mockServices } from '@backstage/backend-test-utils'; import { AutocompleteHandler } from '@backstage/plugin-scaffolder-node/alpha'; import { MiddlewareFactory } from '@backstage/backend-defaults/rootHttpRouter'; +import { UrlReaders } from '@backstage/backend-defaults/urlReader'; const mockAccess = jest.fn(); diff --git a/plugins/scaffolder-backend/src/service/router.ts b/plugins/scaffolder-backend/src/service/router.ts index a25731ce45..7dcf702bf7 100644 --- a/plugins/scaffolder-backend/src/service/router.ts +++ b/plugins/scaffolder-backend/src/service/router.ts @@ -18,7 +18,6 @@ import { createLegacyAuthAdapters, HostDiscovery, PluginDatabaseManager, - UrlReader, } from '@backstage/backend-common'; import { PluginTaskScheduler } from '@backstage/backend-tasks'; import { CatalogApi } from '@backstage/catalog-client'; @@ -88,6 +87,7 @@ import { HttpAuthService, LifecycleService, PermissionsService, + UrlReaderService, } from '@backstage/backend-plugin-api'; import { IdentityApi, @@ -144,7 +144,7 @@ function isActionPermissionRuleInput( export interface RouterOptions { logger: Logger; config: Config; - reader: UrlReader; + reader: UrlReaderService; lifecycle?: LifecycleService; database: PluginDatabaseManager; catalogClient: CatalogApi; diff --git a/plugins/scaffolder-node/src/actions/fetch.test.ts b/plugins/scaffolder-node/src/actions/fetch.test.ts index ea7f458fde..f831d20f35 100644 --- a/plugins/scaffolder-node/src/actions/fetch.test.ts +++ b/plugins/scaffolder-node/src/actions/fetch.test.ts @@ -18,7 +18,7 @@ jest.mock('fs-extra'); import fs from 'fs-extra'; import { resolve as resolvePath } from 'path'; -import { UrlReader } from '@backstage/backend-common'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; import { ConfigReader } from '@backstage/config'; import { ScmIntegrations } from '@backstage/integration'; import { fetchContents, fetchFile } from './fetch'; @@ -39,7 +39,7 @@ describe('fetchContents helper', () => { const readUrl = jest.fn(); const readTree = jest.fn(); - const reader: UrlReader = { + const reader: UrlReaderService = { readUrl, readTree, search: jest.fn(), diff --git a/plugins/scaffolder-node/src/actions/fetch.ts b/plugins/scaffolder-node/src/actions/fetch.ts index 63bc4b1352..a0e8dd9f85 100644 --- a/plugins/scaffolder-node/src/actions/fetch.ts +++ b/plugins/scaffolder-node/src/actions/fetch.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { UrlReader } from '@backstage/backend-common'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; import { resolveSafeChildPath } from '@backstage/backend-plugin-api'; import { InputError } from '@backstage/errors'; import { ScmIntegrations } from '@backstage/integration'; @@ -28,7 +28,7 @@ import path from 'path'; * @public */ export async function fetchContents(options: { - reader: UrlReader; + reader: UrlReaderService; integrations: ScmIntegrations; baseUrl?: string; fetchUrl?: string; @@ -67,7 +67,7 @@ export async function fetchContents(options: { * @public */ export async function fetchFile(options: { - reader: UrlReader; + reader: UrlReaderService; integrations: ScmIntegrations; baseUrl?: string; fetchUrl?: string; diff --git a/plugins/techdocs-node/src/helpers.ts b/plugins/techdocs-node/src/helpers.ts index d64c7fc289..38913e8e9b 100644 --- a/plugins/techdocs-node/src/helpers.ts +++ b/plugins/techdocs-node/src/helpers.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { UrlReader } from '@backstage/backend-common'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; import { resolveSafeChildPath } from '@backstage/backend-plugin-api'; import { Entity, @@ -143,7 +143,7 @@ export const getLocationForEntity = ( * @param opts - Options for configuring the reader, e.g. logger, etag, etc. */ export const getDocFilesFromRepository = async ( - reader: UrlReader, + reader: UrlReaderService, entity: Entity, opts?: { etag?: string; logger?: Logger }, ): Promise => { diff --git a/plugins/techdocs-node/src/stages/prepare/dir.test.ts b/plugins/techdocs-node/src/stages/prepare/dir.test.ts index a26c423aaf..df470d7da6 100644 --- a/plugins/techdocs-node/src/stages/prepare/dir.test.ts +++ b/plugins/techdocs-node/src/stages/prepare/dir.test.ts @@ -13,11 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { UrlReader, loggerToWinstonLogger } from '@backstage/backend-common'; +import { loggerToWinstonLogger } from '@backstage/backend-common'; import { TECHDOCS_ANNOTATION } from '@backstage/plugin-techdocs-common'; import { ConfigReader } from '@backstage/config'; import { DirectoryPreparer } from './dir'; import { mockServices } from '@backstage/backend-test-utils'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; function normalizePath(path: string) { return path @@ -46,7 +47,7 @@ const createMockEntity = (annotations: {}) => { }; const mockConfig = new ConfigReader({}); -const mockUrlReader: jest.Mocked = { +const mockUrlReader: jest.Mocked = { readUrl: jest.fn(), readTree: jest.fn(), search: jest.fn(), diff --git a/plugins/techdocs-node/src/stages/prepare/dir.ts b/plugins/techdocs-node/src/stages/prepare/dir.ts index 1c18b17a1e..cecd2564e6 100644 --- a/plugins/techdocs-node/src/stages/prepare/dir.ts +++ b/plugins/techdocs-node/src/stages/prepare/dir.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { UrlReader } from '@backstage/backend-common'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; import { Entity } from '@backstage/catalog-model'; import { Config } from '@backstage/config'; import { InputError } from '@backstage/errors'; @@ -38,7 +38,7 @@ import { */ export class DirectoryPreparer implements PreparerBase { private readonly scmIntegrations: ScmIntegrationRegistry; - private readonly reader: UrlReader; + private readonly reader: UrlReaderService; /** * Returns a directory preparer instance @@ -55,7 +55,7 @@ export class DirectoryPreparer implements PreparerBase { private constructor( config: Config, _logger: Logger | null, - reader: UrlReader, + reader: UrlReaderService, ) { this.reader = reader; this.scmIntegrations = ScmIntegrations.fromConfig(config); diff --git a/plugins/techdocs-node/src/stages/prepare/types.ts b/plugins/techdocs-node/src/stages/prepare/types.ts index 79cbf68a00..14ec185c97 100644 --- a/plugins/techdocs-node/src/stages/prepare/types.ts +++ b/plugins/techdocs-node/src/stages/prepare/types.ts @@ -15,7 +15,7 @@ */ import type { Entity } from '@backstage/catalog-model'; -import { UrlReader } from '@backstage/backend-common'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; import { Logger } from 'winston'; /** @@ -30,7 +30,7 @@ export type ETag = string; */ export type PreparerConfig = { logger: Logger; - reader: UrlReader; + reader: UrlReaderService; }; /** diff --git a/plugins/techdocs-node/src/stages/prepare/url.ts b/plugins/techdocs-node/src/stages/prepare/url.ts index 84ea1ccda0..24480d2703 100644 --- a/plugins/techdocs-node/src/stages/prepare/url.ts +++ b/plugins/techdocs-node/src/stages/prepare/url.ts @@ -15,7 +15,7 @@ */ import { assertError } from '@backstage/errors'; -import { UrlReader } from '@backstage/backend-common'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; import { Entity } from '@backstage/catalog-model'; import { Logger } from 'winston'; import { getDocFilesFromRepository } from '../../helpers'; @@ -32,7 +32,7 @@ import { */ export class UrlPreparer implements PreparerBase { private readonly logger: Logger; - private readonly reader: UrlReader; + private readonly reader: UrlReaderService; /** * Returns a directory preparer instance @@ -42,7 +42,7 @@ export class UrlPreparer implements PreparerBase { return new UrlPreparer(options.reader, options.logger); } - private constructor(reader: UrlReader, logger: Logger) { + private constructor(reader: UrlReaderService, logger: Logger) { this.logger = logger; this.reader = reader; } diff --git a/yarn.lock b/yarn.lock index fe8c64dd81..2d329b0c31 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5290,6 +5290,7 @@ __metadata: "@aws-sdk/types": ^3.347.0 "@aws-sdk/util-stream-node": ^3.350.0 "@backstage/backend-common": "workspace:^" + "@backstage/backend-defaults": "workspace:^" "@backstage/backend-plugin-api": "workspace:^" "@backstage/backend-tasks": "workspace:^" "@backstage/backend-test-utils": "workspace:^" @@ -6983,6 +6984,7 @@ __metadata: resolution: "@backstage/plugin-scaffolder-backend-module-cookiecutter@workspace:plugins/scaffolder-backend-module-cookiecutter" dependencies: "@backstage/backend-common": "workspace:^" + "@backstage/backend-defaults": "workspace:^" "@backstage/backend-plugin-api": "workspace:^" "@backstage/backend-test-utils": "workspace:^" "@backstage/cli": "workspace:^" @@ -27105,6 +27107,8 @@ __metadata: resolution: "example-backend-legacy@workspace:packages/backend-legacy" dependencies: "@backstage/backend-common": "workspace:^" + "@backstage/backend-defaults": "workspace:^" + "@backstage/backend-plugin-api": "workspace:^" "@backstage/backend-tasks": "workspace:^" "@backstage/catalog-client": "workspace:^" "@backstage/catalog-model": "workspace:^" From 2acc278202b8f73cca35753fb6d0f5c700ec239f Mon Sep 17 00:00:00 2001 From: Camila Belo Date: Wed, 14 Aug 2024 16:38:52 +0200 Subject: [PATCH 340/372] docs: update api reports Signed-off-by: Camila Belo --- packages/backend-common/api-report.md | 160 ------------------ .../api-report.md | 4 +- .../catalog-backend-module-aws/api-report.md | 4 +- .../api-report.md | 4 +- .../api-report.md | 6 +- plugins/catalog-backend/api-report.md | 12 +- .../api-report.md | 4 +- .../api-report.md | 4 +- .../api-report.md | 4 +- plugins/scaffolder-backend/api-report.md | 12 +- plugins/scaffolder-node/api-report.md | 6 +- plugins/techdocs-node/api-report.md | 6 +- 12 files changed, 33 insertions(+), 193 deletions(-) diff --git a/packages/backend-common/api-report.md b/packages/backend-common/api-report.md index 11a5befad4..61efc0f3a1 100644 --- a/packages/backend-common/api-report.md +++ b/packages/backend-common/api-report.md @@ -9,14 +9,7 @@ import { AppConfig } from '@backstage/config'; import { AuthCallback } from 'isomorphic-git'; import { AuthService } from '@backstage/backend-plugin-api'; -import { AwsCredentialsManager } from '@backstage/integration-aws-node'; -import { AwsS3Integration } from '@backstage/integration'; -import { AzureDevOpsCredentialsProvider } from '@backstage/integration'; -import { AzureIntegration } from '@backstage/integration'; import { BackendFeatureCompat } from '@backstage/backend-plugin-api'; -import { BitbucketCloudIntegration } from '@backstage/integration'; -import { BitbucketIntegration } from '@backstage/integration'; -import { BitbucketServerIntegration } from '@backstage/integration'; import { CacheService } from '@backstage/backend-plugin-api'; import { CacheServiceOptions } from '@backstage/backend-plugin-api'; import { CacheServiceSetOptions } from '@backstage/backend-plugin-api'; @@ -28,12 +21,6 @@ import { DiscoveryService } from '@backstage/backend-plugin-api'; import Docker from 'dockerode'; import { ErrorRequestHandler } from 'express'; import express from 'express'; -import { GerritIntegration } from '@backstage/integration'; -import { GiteaIntegration } from '@backstage/integration'; -import { GithubCredentialsProvider } from '@backstage/integration'; -import { GithubIntegration } from '@backstage/integration'; -import { GitLabIntegration } from '@backstage/integration'; -import { HarnessIntegration } from '@backstage/integration'; import { HttpAuthService } from '@backstage/backend-plugin-api'; import { IdentityService } from '@backstage/backend-plugin-api'; import { isChildPath as isChildPath_2 } from '@backstage/backend-plugin-api'; @@ -47,34 +34,18 @@ import { MergeResult } from 'isomorphic-git'; import { PermissionsService } from '@backstage/backend-plugin-api'; import { PluginMetadataService } from '@backstage/backend-plugin-api'; import { PushResult } from 'isomorphic-git'; -import { Readable } from 'stream'; import { ReadCommitResult } from 'isomorphic-git'; -import { ReadTreeOptions as ReadTreeOptions_2 } from '@backstage/backend-plugin-api'; -import { ReadTreeResponse as ReadTreeResponse_2 } from '@backstage/backend-plugin-api'; -import { ReadTreeResponseDirOptions as ReadTreeResponseDirOptions_2 } from '@backstage/backend-plugin-api'; -import { ReadTreeResponseFile as ReadTreeResponseFile_2 } from '@backstage/backend-plugin-api'; -import { ReadUrlOptions as ReadUrlOptions_2 } from '@backstage/backend-plugin-api'; -import { ReadUrlResponse as ReadUrlResponse_2 } from '@backstage/backend-plugin-api'; import { RequestHandler } from 'express'; import { resolvePackagePath as resolvePackagePath_2 } from '@backstage/backend-plugin-api'; import { resolveSafeChildPath as resolveSafeChildPath_2 } from '@backstage/backend-plugin-api'; import { RootConfigService } from '@backstage/backend-plugin-api'; import { Router } from 'express'; import { SchedulerService } from '@backstage/backend-plugin-api'; -import { SearchOptions as SearchOptions_2 } from '@backstage/backend-plugin-api'; -import { SearchResponse as SearchResponse_2 } from '@backstage/backend-plugin-api'; -import { SearchResponseFile as SearchResponseFile_2 } from '@backstage/backend-plugin-api'; import { Server } from 'http'; import { ServiceRef } from '@backstage/backend-plugin-api'; import { TokenManagerService } from '@backstage/backend-plugin-api'; import { TransportStreamOptions } from 'winston-transport'; import { UrlReaderService } from '@backstage/backend-plugin-api'; -import { UrlReaderServiceReadTreeOptions } from '@backstage/backend-plugin-api'; -import { UrlReaderServiceReadTreeResponse } from '@backstage/backend-plugin-api'; -import { UrlReaderServiceReadUrlOptions } from '@backstage/backend-plugin-api'; -import { UrlReaderServiceReadUrlResponse } from '@backstage/backend-plugin-api'; -import { UrlReaderServiceSearchOptions } from '@backstage/backend-plugin-api'; -import { UrlReaderServiceSearchResponse } from '@backstage/backend-plugin-api'; import { UserInfoService } from '@backstage/backend-plugin-api'; import { V1PodTemplateSpec } from '@kubernetes/client-node'; import * as winston from 'winston'; @@ -86,31 +57,6 @@ export type AuthCallbackOptions = { logger?: LoggerService; }; -// Warning: (ae-forgotten-export) The symbol "AwsS3UrlReader_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export class AwsS3UrlReader extends AwsS3UrlReader_2 {} - -// Warning: (ae-forgotten-export) The symbol "AzureUrlReader_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export class AzureUrlReader extends AzureUrlReader_2 {} - -// Warning: (ae-forgotten-export) The symbol "BitbucketCloudUrlReader_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export class BitbucketCloudUrlReader extends BitbucketCloudUrlReader_2 {} - -// Warning: (ae-forgotten-export) The symbol "BitbucketServerUrlReader_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export class BitbucketServerUrlReader extends BitbucketServerUrlReader_2 {} - -// Warning: (ae-forgotten-export) The symbol "BitbucketUrlReader_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export class BitbucketUrlReader extends BitbucketUrlReader_2 {} - // @public @deprecated (undocumented) export type CacheClient = CacheService; @@ -245,21 +191,6 @@ export type ErrorHandlerOptions = { logClientErrors?: boolean; }; -// Warning: (ae-forgotten-export) The symbol "FetchUrlReader_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export class FetchUrlReader extends FetchUrlReader_2 {} - -// Warning: (ae-forgotten-export) The symbol "FromReadableArrayOptions_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export type FromReadableArrayOptions = FromReadableArrayOptions_2; - -// Warning: (ae-forgotten-export) The symbol "GerritUrlReader_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export class GerritUrlReader extends GerritUrlReader_2 {} - // @public @deprecated export function getRootLogger(): winston.Logger; @@ -342,26 +273,6 @@ export class Git { resolveRef(options: { dir: string; ref: string }): Promise; } -// Warning: (ae-forgotten-export) The symbol "GiteaUrlReader_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export class GiteaUrlReader extends GiteaUrlReader_2 {} - -// Warning: (ae-forgotten-export) The symbol "GithubUrlReader_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export class GithubUrlReader extends GithubUrlReader_2 {} - -// Warning: (ae-forgotten-export) The symbol "GitlabUrlReader_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export class GitlabUrlReader extends GitlabUrlReader_2 {} - -// Warning: (ae-forgotten-export) The symbol "HarnessUrlReader_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export class HarnessUrlReader extends HarnessUrlReader_2 {} - // @public @deprecated class HostDiscovery implements DiscoveryService { static fromConfig( @@ -506,50 +417,6 @@ export interface PullOptions { }; } -// Warning: (ae-forgotten-export) The symbol "ReaderFactory_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export type ReaderFactory = ReaderFactory_2; - -// @public @deprecated (undocumented) -export type ReadTreeOptions = ReadTreeOptions_2; - -// @public @deprecated (undocumented) -export type ReadTreeResponse = ReadTreeResponse_2; - -// @public @deprecated (undocumented) -export type ReadTreeResponseDirOptions = ReadTreeResponseDirOptions_2; - -// Warning: (ae-forgotten-export) The symbol "ReadTreeResponseFactory_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export type ReadTreeResponseFactory = ReadTreeResponseFactory_2; - -// Warning: (ae-forgotten-export) The symbol "ReadTreeResponseFactoryOptions_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export type ReadTreeResponseFactoryOptions = ReadTreeResponseFactoryOptions_2; - -// @public @deprecated (undocumented) -export type ReadTreeResponseFile = ReadTreeResponseFile_2; - -// @public @deprecated (undocumented) -export type ReadUrlOptions = ReadUrlOptions_2; - -// @public @deprecated (undocumented) -export type ReadUrlResponse = ReadUrlResponse_2; - -// Warning: (ae-forgotten-export) The symbol "ReadUrlResponseFactory_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export class ReadUrlResponseFactory extends ReadUrlResponseFactory_2 {} - -// Warning: (ae-forgotten-export) The symbol "ReadUrlResponseFactoryFromStreamOptions_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export type ReadUrlResponseFactoryFromStreamOptions = - ReadUrlResponseFactoryFromStreamOptions_2; - // @public @deprecated export function redactWinstonLogLine( info: winston.Logform.TransformableInfo, @@ -583,15 +450,6 @@ export type RunContainerOptions = { pullOptions?: PullOptions; }; -// @public @deprecated (undocumented) -export type SearchOptions = SearchOptions_2; - -// @public @deprecated (undocumented) -export type SearchResponse = SearchResponse_2; - -// @public @deprecated (undocumented) -export type SearchResponseFile = SearchResponseFile_2; - // @public @deprecated export class ServerTokenManager implements TokenManager { // (undocumented) @@ -667,24 +525,6 @@ export interface StatusCheckHandlerOptions { // @public @deprecated (undocumented) export type TokenManager = TokenManagerService; -// @public @deprecated (undocumented) -export type UrlReader = UrlReaderService; - -// Warning: (ae-forgotten-export) The symbol "UrlReaderPredicateTuple_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export type UrlReaderPredicateTuple = UrlReaderPredicateTuple_2; - -// Warning: (ae-forgotten-export) The symbol "UrlReaders_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export class UrlReaders extends UrlReaders_2 {} - -// Warning: (ae-forgotten-export) The symbol "UrlReadersOptions_2" needs to be exported by the entry point index.d.ts -// -// @public @deprecated (undocumented) -export type UrlReadersOptions = UrlReadersOptions_2; - // @public @deprecated export function useHotCleanup( _module: NodeModule, diff --git a/packages/backend-dynamic-feature-service/api-report.md b/packages/backend-dynamic-feature-service/api-report.md index 97dea60170..400c55c009 100644 --- a/packages/backend-dynamic-feature-service/api-report.md +++ b/packages/backend-dynamic-feature-service/api-report.md @@ -33,7 +33,7 @@ import { ServiceRef } from '@backstage/backend-plugin-api'; import { TaskRunner } from '@backstage/backend-tasks'; import { TemplateAction } from '@backstage/plugin-scaffolder-node'; import { TokenManager } from '@backstage/backend-common'; -import { UrlReader } from '@backstage/backend-common'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; // @public (undocumented) export interface BackendDynamicPlugin extends BaseDynamicPlugin { @@ -221,7 +221,7 @@ export type LegacyPluginEnvironment = { cache: PluginCacheManager; database: PluginDatabaseManager; config: Config; - reader: UrlReader; + reader: UrlReaderService; discovery: PluginEndpointDiscovery; tokenManager: TokenManager; permissions: PermissionEvaluator; diff --git a/plugins/catalog-backend-module-aws/api-report.md b/plugins/catalog-backend-module-aws/api-report.md index 428a39d934..cf846cf25e 100644 --- a/plugins/catalog-backend-module-aws/api-report.md +++ b/plugins/catalog-backend-module-aws/api-report.md @@ -17,7 +17,7 @@ import { LocationSpec } from '@backstage/plugin-catalog-common'; import { LoggerService } from '@backstage/backend-plugin-api'; import { PluginTaskScheduler } from '@backstage/backend-tasks'; import { TaskRunner } from '@backstage/backend-tasks'; -import { UrlReader } from '@backstage/backend-common'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; // @public export const ANNOTATION_AWS_ACCOUNT_ID: string; @@ -75,7 +75,7 @@ export class AwsOrganizationCloudAccountProcessor implements CatalogProcessor { // @public @deprecated export class AwsS3DiscoveryProcessor implements CatalogProcessor { - constructor(reader: UrlReader); + constructor(reader: UrlReaderService); // (undocumented) getProcessorName(): string; // (undocumented) diff --git a/plugins/catalog-backend-module-incremental-ingestion/api-report.md b/plugins/catalog-backend-module-incremental-ingestion/api-report.md index 4088b05bb5..92666f3928 100644 --- a/plugins/catalog-backend-module-incremental-ingestion/api-report.md +++ b/plugins/catalog-backend-module-incremental-ingestion/api-report.md @@ -16,7 +16,7 @@ import type { PermissionEvaluator } from '@backstage/plugin-permission-common'; import type { PluginDatabaseManager } from '@backstage/backend-common'; import type { PluginTaskScheduler } from '@backstage/backend-tasks'; import { Router } from 'express'; -import type { UrlReader } from '@backstage/backend-common'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; // @public export type EntityIteratorResult = @@ -91,7 +91,7 @@ export type PluginEnvironment = { database: PluginDatabaseManager; scheduler: PluginTaskScheduler; config: Config; - reader: UrlReader; + reader: UrlReaderService; permissions: PermissionEvaluator; }; ``` diff --git a/plugins/catalog-backend-module-openapi/api-report.md b/plugins/catalog-backend-module-openapi/api-report.md index b1685c3584..05ab2e0561 100644 --- a/plugins/catalog-backend-module-openapi/api-report.md +++ b/plugins/catalog-backend-module-openapi/api-report.md @@ -12,7 +12,7 @@ import { LocationSpec } from '@backstage/plugin-catalog-common'; import { Logger } from 'winston'; import { PlaceholderResolverParams } from '@backstage/plugin-catalog-backend'; import { ScmIntegrations } from '@backstage/integration'; -import { UrlReader } from '@backstage/backend-common'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; // @public const catalogModuleJsonSchemaRefPlaceholderResolver: BackendFeatureCompat; @@ -31,14 +31,14 @@ export class OpenApiRefProcessor implements CatalogProcessor { constructor(options: { integrations: ScmIntegrations; logger: Logger; - reader: UrlReader; + reader: UrlReaderService; }); // (undocumented) static fromConfig( config: Config, options: { logger: Logger; - reader: UrlReader; + reader: UrlReaderService; }, ): OpenApiRefProcessor; // (undocumented) diff --git a/plugins/catalog-backend/api-report.md b/plugins/catalog-backend/api-report.md index f4c10d01a2..7efa8669e6 100644 --- a/plugins/catalog-backend/api-report.md +++ b/plugins/catalog-backend/api-report.md @@ -63,7 +63,7 @@ import { Router } from 'express'; import { ScmIntegrationRegistry } from '@backstage/integration'; import { ScmLocationAnalyzer as ScmLocationAnalyzer_2 } from '@backstage/plugin-catalog-node'; import { TokenManager } from '@backstage/backend-common'; -import { UrlReader } from '@backstage/backend-common'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; import { Validators } from '@backstage/catalog-model'; // @public @deprecated @@ -197,7 +197,7 @@ export type CatalogEnvironment = { logger: LoggerService; database: PluginDatabaseManager; config: Config; - reader: UrlReader; + reader: UrlReaderService; permissions: PermissionsService | PermissionAuthorizer; scheduler?: PluginTaskScheduler; discovery?: DiscoveryService; @@ -254,14 +254,14 @@ export class CodeOwnersProcessor implements CatalogProcessor_2 { constructor(options: { integrations: ScmIntegrationRegistry; logger: LoggerService; - reader: UrlReader; + reader: UrlReaderService; }); // (undocumented) static fromConfig( config: Config, options: { logger: LoggerService; - reader: UrlReader; + reader: UrlReaderService; }, ): CodeOwnersProcessor; // (undocumented) @@ -413,7 +413,7 @@ export class PlaceholderProcessor implements CatalogProcessor_2 { // @public (undocumented) export type PlaceholderProcessorOptions = { resolvers: Record; - reader: UrlReader; + reader: UrlReaderService; integrations: ScmIntegrationRegistry; }; @@ -465,7 +465,7 @@ export function transformLegacyPolicyToProcessor( // @public (undocumented) export class UrlReaderProcessor implements CatalogProcessor_2 { - constructor(options: { reader: UrlReader; logger: LoggerService }); + constructor(options: { reader: UrlReaderService; logger: LoggerService }); // (undocumented) getProcessorName(): string; // (undocumented) diff --git a/plugins/scaffolder-backend-module-confluence-to-markdown/api-report.md b/plugins/scaffolder-backend-module-confluence-to-markdown/api-report.md index b56ade73a2..df2e74337f 100644 --- a/plugins/scaffolder-backend-module-confluence-to-markdown/api-report.md +++ b/plugins/scaffolder-backend-module-confluence-to-markdown/api-report.md @@ -8,7 +8,7 @@ import { Config } from '@backstage/config'; import { JsonObject } from '@backstage/types'; import { ScmIntegrations } from '@backstage/integration'; import { TemplateAction } from '@backstage/plugin-scaffolder-node'; -import { UrlReader } from '@backstage/backend-common'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; // @public const confluenceToMarkdownModule: BackendFeatureCompat; @@ -16,7 +16,7 @@ export default confluenceToMarkdownModule; // @public (undocumented) export const createConfluenceToMarkdownAction: (options: { - reader: UrlReader; + reader: UrlReaderService; integrations: ScmIntegrations; config: Config; }) => TemplateAction< diff --git a/plugins/scaffolder-backend-module-cookiecutter/api-report.md b/plugins/scaffolder-backend-module-cookiecutter/api-report.md index 2dbf462063..a2332da624 100644 --- a/plugins/scaffolder-backend-module-cookiecutter/api-report.md +++ b/plugins/scaffolder-backend-module-cookiecutter/api-report.md @@ -10,7 +10,7 @@ import { ContainerRunner } from '@backstage/backend-common'; import { JsonObject } from '@backstage/types'; import { ScmIntegrations } from '@backstage/integration'; import { TemplateAction } from '@backstage/plugin-scaffolder-node'; -import { UrlReader } from '@backstage/backend-common'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; // @public const cookiecutterModule: BackendFeatureCompat; @@ -18,7 +18,7 @@ export default cookiecutterModule; // @public export function createFetchCookiecutterAction(options: { - reader: UrlReader; + reader: UrlReaderService; integrations: ScmIntegrations; containerRunner?: ContainerRunner; }): TemplateAction< diff --git a/plugins/scaffolder-backend-module-rails/api-report.md b/plugins/scaffolder-backend-module-rails/api-report.md index 9b663d33d6..31e8f6834c 100644 --- a/plugins/scaffolder-backend-module-rails/api-report.md +++ b/plugins/scaffolder-backend-module-rails/api-report.md @@ -8,11 +8,11 @@ import { ContainerRunner } from '@backstage/backend-common'; import { JsonObject } from '@backstage/types'; import { ScmIntegrations } from '@backstage/integration'; import { TemplateAction } from '@backstage/plugin-scaffolder-node'; -import { UrlReader } from '@backstage/backend-common'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; // @public export function createFetchRailsAction(options: { - reader: UrlReader; + reader: UrlReaderService; integrations: ScmIntegrations; containerRunner?: ContainerRunner; allowedImageNames?: string[]; diff --git a/plugins/scaffolder-backend/api-report.md b/plugins/scaffolder-backend/api-report.md index 1e60d5b026..207b54e63f 100644 --- a/plugins/scaffolder-backend/api-report.md +++ b/plugins/scaffolder-backend/api-report.md @@ -63,7 +63,7 @@ import { TemplateEntityStepV1beta3 } from '@backstage/plugin-scaffolder-common'; import { TemplateFilter as TemplateFilter_2 } from '@backstage/plugin-scaffolder-node'; import { TemplateGlobal as TemplateGlobal_2 } from '@backstage/plugin-scaffolder-node'; import { TemplateParametersV1beta3 } from '@backstage/plugin-scaffolder-common'; -import { UrlReader } from '@backstage/backend-common'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; import { WorkspaceProvider } from '@backstage/plugin-scaffolder-node/alpha'; import { ZodType } from 'zod'; import { ZodTypeDef } from 'zod'; @@ -95,7 +95,7 @@ export interface CreateBuiltInActionsOptions { catalogClient: CatalogApi; config: Config; integrations: ScmIntegrations; - reader: UrlReader; + reader: UrlReaderService; } // @public @@ -154,7 +154,7 @@ export function createFetchCatalogEntityAction(options: { // @public export function createFetchPlainAction(options: { - reader: UrlReader; + reader: UrlReaderService; integrations: ScmIntegrations; }): TemplateAction_2< { @@ -167,7 +167,7 @@ export function createFetchPlainAction(options: { // @public export function createFetchPlainFileAction(options: { - reader: UrlReader; + reader: UrlReaderService; integrations: ScmIntegrations; }): TemplateAction_2< { @@ -180,7 +180,7 @@ export function createFetchPlainFileAction(options: { // @public export function createFetchTemplateAction(options: { - reader: UrlReader; + reader: UrlReaderService; integrations: ScmIntegrations; additionalTemplateFilters?: Record; additionalTemplateGlobals?: Record; @@ -507,7 +507,7 @@ export interface RouterOptions { // (undocumented) permissions?: PermissionsService; // (undocumented) - reader: UrlReader; + reader: UrlReaderService; // (undocumented) scheduler?: PluginTaskScheduler; // (undocumented) diff --git a/plugins/scaffolder-node/api-report.md b/plugins/scaffolder-node/api-report.md index 515a169cb2..8b38008eee 100644 --- a/plugins/scaffolder-node/api-report.md +++ b/plugins/scaffolder-node/api-report.md @@ -16,7 +16,7 @@ import { ScmIntegrations } from '@backstage/integration'; import { SpawnOptionsWithoutStdio } from 'child_process'; import { TaskSpec } from '@backstage/plugin-scaffolder-common'; import { TemplateInfo } from '@backstage/plugin-scaffolder-common'; -import { UrlReader } from '@backstage/backend-common'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; import { UserEntity } from '@backstage/catalog-model'; import { Writable } from 'stream'; import { z } from 'zod'; @@ -196,7 +196,7 @@ export type ExecuteShellCommandOptions = { // @public export function fetchContents(options: { - reader: UrlReader; + reader: UrlReaderService; integrations: ScmIntegrations; baseUrl?: string; fetchUrl?: string; @@ -206,7 +206,7 @@ export function fetchContents(options: { // @public export function fetchFile(options: { - reader: UrlReader; + reader: UrlReaderService; integrations: ScmIntegrations; baseUrl?: string; fetchUrl?: string; diff --git a/plugins/techdocs-node/api-report.md b/plugins/techdocs-node/api-report.md index f03f9e1b0e..6c7f05e900 100644 --- a/plugins/techdocs-node/api-report.md +++ b/plugins/techdocs-node/api-report.md @@ -15,7 +15,7 @@ import { IndexableDocument } from '@backstage/plugin-search-common'; import { Logger } from 'winston'; import { PluginEndpointDiscovery } from '@backstage/backend-common'; import { ScmIntegrationRegistry } from '@backstage/integration'; -import { UrlReader } from '@backstage/backend-common'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; import * as winston from 'winston'; import { Writable } from 'stream'; @@ -82,7 +82,7 @@ export class Generators implements GeneratorBuilder { // @public export const getDocFilesFromRepository: ( - reader: UrlReader, + reader: UrlReaderService, entity: Entity, opts?: { etag?: string; @@ -157,7 +157,7 @@ export type PreparerBuilder = { // @public export type PreparerConfig = { logger: Logger; - reader: UrlReader; + reader: UrlReaderService; }; // @public From 389f5a4cfc7e09bbad10b326529fcac57ad426e6 Mon Sep 17 00:00:00 2001 From: Camila Belo Date: Wed, 14 Aug 2024 17:29:00 +0200 Subject: [PATCH 341/372] docs: add changeset files Signed-off-by: Camila Belo --- .changeset/dull-cheetahs-clap.md | 16 ++++++++++++ .changeset/fair-kangaroos-return.md | 15 +++++++++++ .changeset/healthy-carpets-reflect.md | 5 ++++ .changeset/lovely-ravens-judge.md | 36 +++++++++++++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 .changeset/dull-cheetahs-clap.md create mode 100644 .changeset/fair-kangaroos-return.md create mode 100644 .changeset/healthy-carpets-reflect.md create mode 100644 .changeset/lovely-ravens-judge.md diff --git a/.changeset/dull-cheetahs-clap.md b/.changeset/dull-cheetahs-clap.md new file mode 100644 index 0000000000..a2ea657f2e --- /dev/null +++ b/.changeset/dull-cheetahs-clap.md @@ -0,0 +1,16 @@ +--- +'@backstage/plugin-scaffolder-backend-module-confluence-to-markdown': patch +'@backstage/plugin-catalog-backend-module-incremental-ingestion': patch +'@backstage/plugin-scaffolder-backend-module-cookiecutter': patch +'@backstage/backend-dynamic-feature-service': patch +'@backstage/plugin-scaffolder-backend-module-rails': patch +'@backstage/plugin-catalog-backend-module-openapi': patch +'@backstage/plugin-catalog-backend-module-aws': patch +'@backstage/plugin-search-backend-node': patch +'@backstage/plugin-scaffolder-backend': patch +'@backstage/plugin-catalog-backend': patch +'@backstage/plugin-scaffolder-node': patch +'@backstage/plugin-techdocs-node': patch +--- + +Update deprecated url-reader-related imports. diff --git a/.changeset/fair-kangaroos-return.md b/.changeset/fair-kangaroos-return.md new file mode 100644 index 0000000000..230a6cd176 --- /dev/null +++ b/.changeset/fair-kangaroos-return.md @@ -0,0 +1,15 @@ +--- +'@backstage/backend-plugin-api': minor +--- + +Delete deprecated url reader exports: + +- ReadUrlOptions: Use `UrlReaderServiceReadUrlOptions` instead; +- ReadUrlResponse: Use `UrlReaderServiceReadUrlResponse` instead; +- ReadTreeOptions: Use `UrlReaderServiceReadTreeOptions` instead; +- ReadTreeResponse: Use `UrlReaderServiceReadTreeResponse` instead; +- ReadTreeResponseFile: Use `UrlReaderServiceReadTreeResponseFile` instead; +- ReadTreeResponseDirOptions: Use `UrlReaderServiceReadTreeResponseDirOptions` instead; +- SearchOptions: Use `UrlReaderServiceSearchOptions` instead; +- SearchResponse: Use `UrlReaderServiceSearchResponse` instead; +- SearchResponseFile: Use `UrlReaderServiceSearchResponseFile` instead. diff --git a/.changeset/healthy-carpets-reflect.md b/.changeset/healthy-carpets-reflect.md new file mode 100644 index 0000000000..ac7734a448 --- /dev/null +++ b/.changeset/healthy-carpets-reflect.md @@ -0,0 +1,5 @@ +--- +'@backstage/backend-app-api': minor +--- + +Remove deprecated `urlReaderServiceFactory`, please import from `@backstage/backend-defaults/urlReader` instead. diff --git a/.changeset/lovely-ravens-judge.md b/.changeset/lovely-ravens-judge.md new file mode 100644 index 0000000000..761d8ebd1f --- /dev/null +++ b/.changeset/lovely-ravens-judge.md @@ -0,0 +1,36 @@ +--- +'@backstage/backend-common': minor +--- + +Removed the following `Url Reader` deprecated exports: + +- UrlReader: Use `UrlReaderService` from `@backstage/backend-plugin-api` instead; +- AzureUrlReader: Import from `@backstage/backend-defaults/urlReader` instead; +- BitbucketUrlReader: Import from `@backstage/backend-defaults/urlReader` instead; +- BitbucketCloudUrlReader: Import from `@backstage/backend-defaults/urlReader` instead; +- BitbucketServerUrlReader: Import from `@backstage/backend-defaults/urlReader` instead; +- GithubUrlReader: Import from `@backstage/backend-defaults/urlReader` instead; +- GitlabUrlReader: Import from `@backstage/backend-defaults/urlReader` instead; +- GerritUrlReader: Import from `@backstage/backend-defaults/urlReader` instead; +- GiteaUrlReader: Import from `@backstage/backend-defaults/urlReader` instead; +- HarnessUrlReader: Import from `@backstage/backend-defaults/urlReader` instead; +- AwsS3UrlReader: Import from `@backstage/backend-defaults/urlReader` instead; +- FetchUrlReader: Import from `@backstage/backend-defaults/urlReader` instead; +- UrlReaders: Import from `@backstage/backend-defaults/urlReader` instead; +- UrlReadersOptions: Import from `@backstage/backend-defaults/urlReader` instead; +- UrlReaderPredicateTuple: Import from `@backstage/backend-defaults/urlReader` instead; +- FromReadableArrayOptions: Import from `@backstage/backend-defaults/urlReader` instead; +- ReaderFactory: Import from `@backstage/backend-defaults/urlReader` instead; +- ReadUrlOptions:Use `UrlReaderServiceReadUrlOptions` from `@backstage/backend-plugin-api` instead; +- ReadUrlResponse: Use `UrlReaderServiceReadUrlResponse` from `@backstage/backend-plugin-api` instead; +- ReadUrlResponseFactory: Import from `@backstage/backend-defaults/urlReader` instead; +- ReadUrlResponseFactoryFromStreamOptions: Import from `@backstage/backend-defaults/urlReader` instead; +- ReadTreeOptions: Use `UrlReaderServiceReadTreeOptions` from `@backstage/backend-plugin-api` instead; +- ReadTreeResponse: Use `UrlReaderServiceReadTreeResponse` from `@backstage/backend-plugin-api` instead; +- ReadTreeResponseFile: Use `UrlReaderServiceReadTreeResponseFile` from `@backstage/backend-plugin-api` instead; +- ReadTreeResponseDirOptions: Use `UrlReaderServiceReadTreeResponseDirOptions` from `@backstage/backend-plugin-api` instead; +- ReadTreeResponseFactory: Import from `@backstage/backend-defaults/urlReader` instead; +- ReadTreeResponseFactoryOptions: Import from `@backstage/backend-defaults/urlReader` instead; +- SearchOptions: Use `UrlReaderServiceSearchOptions` from `@backstage/backend-plugin-api` instead; +- SearchResponse: Use `UrlReaderServiceSearchResponse` from `@backstage/backend-plugin-api` instead; +- SearchResponseFile: Use `UrlReaderServiceSearchResponseFile` from `@backstage/backend-plugin-api` instead. From 3f4998eb9f48bfc6d21a8e9b714749e1f43fd08b Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Thu, 15 Aug 2024 09:12:39 +0200 Subject: [PATCH 342/372] chore: clarified that changes are breaking Signed-off-by: Johan Haals --- .changeset/fair-kangaroos-return.md | 2 +- .changeset/lovely-ravens-judge.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/fair-kangaroos-return.md b/.changeset/fair-kangaroos-return.md index 230a6cd176..6c5b2e57ae 100644 --- a/.changeset/fair-kangaroos-return.md +++ b/.changeset/fair-kangaroos-return.md @@ -2,7 +2,7 @@ '@backstage/backend-plugin-api': minor --- -Delete deprecated url reader exports: +**BREAKING** Deleted the following deprecated `UrlReader` exports - ReadUrlOptions: Use `UrlReaderServiceReadUrlOptions` instead; - ReadUrlResponse: Use `UrlReaderServiceReadUrlResponse` instead; diff --git a/.changeset/lovely-ravens-judge.md b/.changeset/lovely-ravens-judge.md index 761d8ebd1f..43611556a1 100644 --- a/.changeset/lovely-ravens-judge.md +++ b/.changeset/lovely-ravens-judge.md @@ -2,7 +2,7 @@ '@backstage/backend-common': minor --- -Removed the following `Url Reader` deprecated exports: +**BREAKING**: Removed the following `Url Reader` deprecated exports: - UrlReader: Use `UrlReaderService` from `@backstage/backend-plugin-api` instead; - AzureUrlReader: Import from `@backstage/backend-defaults/urlReader` instead; From 6bc68ceccd7e203d8007cb4c6b1f8db653e429aa Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 15 Aug 2024 13:30:49 +0200 Subject: [PATCH 343/372] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fredrik Adelöw Signed-off-by: Patrik Oldsberg --- docs/frontend-system/architecture/20-extensions.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/frontend-system/architecture/20-extensions.md b/docs/frontend-system/architecture/20-extensions.md index ac55a42827..e142044d03 100644 --- a/docs/frontend-system/architecture/20-extensions.md +++ b/docs/frontend-system/architecture/20-extensions.md @@ -20,7 +20,7 @@ Each extensions has a number of different properties that define how it behaves The ID of an extension is used to uniquely identity it, and it should ideally be unique across the entire Backstage ecosystem. For each frontend app instance there can only be a single extension for any given ID. Installing multiple extensions with the same ID will either result in an error or one of the extensions will override the others. The ID is also used to reference the extensions from other extensions, in configuration, and in other places such as developer tools and analytics. -When creating an extension do not provide the ID directly. Instead, you indirectly or directly provide the kind, namespace, and name parts that make up the ID. The kind is always provided by the [extension blueprint](./23-extension-blueprints.md), the only exception is if you use [`createExtension`](#creating-an-extensions) directly. Any extension that is provided by a plugin will by default have its namespace set to the plugin ID, so you generally only need to provide an explicit namespace if you want to override an existing extension. The name is also optional, and primarily used to distinguish between multiple extensions of the same kind and namespace. If a plugin doesn't need to distinguish between different extensions of the same kind, the name can be omitted. +When creating an extension you do not provide the ID directly. Instead, you indirectly or directly provide the kind, namespace, and name parts that make up the ID. The kind is always provided by the [extension blueprint](./23-extension-blueprints.md), the only exception is if you use [`createExtension`](#creating-an-extensions) directly. Any extension that is provided by a plugin will by default have its namespace set to the plugin ID, so you generally only need to provide an explicit namespace if you want to override an existing extension. The name is also optional, and primarily used to distinguish between multiple extensions of the same kind and namespace. If a plugin doesn't need to distinguish between different extensions of the same kind, the name can be omitted. The extension ID will be constructed using the pattern `[:][][/][]`, where the separating `/` is only present if both a namespace and name are defined. @@ -73,7 +73,7 @@ const extension = createExtension({ }); ``` -Note that while the `createExtension` is public API and used in many places, it is not typically what you use when building plugins and features. Instead there are many [extension blueprints](./23-extension-blueprints.md) exported by both the core APIs and plugins that make it easier to create extensions for more specific usages. +Note that while the `createExtension` function is public API and used in many places, it is not typically what you use when building plugins and features. Instead there are many [extension blueprints](./23-extension-blueprints.md) exported by both the core APIs and plugins that make it easier to create extensions for more specific usages. ## Extension data @@ -104,7 +104,7 @@ const extension = createExtension({ ### Extension data uniqueness -Note that you are **not** allowed to repeat the same data reference in the outputs, or return multiple values for the same reference. Multiple outputs for the same reference will conflict with each other and cause an error. If you want to output multiple values of the same TypeScript type you should create separate references for each value. That in turn means that overly generic extension data references a bad idea, for example a generic "string" type. Instead create separate references for each type of data that you want to share. +Note that you are **not** allowed to repeat the same data reference in the outputs, or return multiple values for the same reference. Multiple outputs for the same reference will conflict with each other and cause an error. If you want to output multiple values of the same TypeScript type you should create separate references for each value. That in turn means that overly generic extension data references are a bad idea, for example a generic "string" type. Instead create separate references for each type of data that you want to share. ```tsx const extension = createExtension({ @@ -282,7 +282,7 @@ app: ## Extension factory as a generator function -In all examples so far we have defined the extension factory as a regular function that returns its output in an array. However, the only requirement is that the factory function returns an iterable of extension data value. This means that you can also define the factory function as a generator function, which allows you to yield values one by one. This is particularly useful if you want to conditionally output values. +In all examples so far we have defined the extension factory as a regular function that returns its output in an array. However, the only requirement is that the factory function returns any iterable of extension data values. This means that you can also define the factory function as a generator function, which allows you to yield values one by one. This is particularly useful if you want to conditionally output values. For example, this is how we could define an extension where its output depends on the configuration: From eeb5d8cb5b0ba48d9f0ec6cf276f3093da4d1709 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 15 Aug 2024 13:33:57 +0200 Subject: [PATCH 344/372] docs/frontend-system: fix some extension examples Signed-off-by: Patrik Oldsberg --- .../architecture/20-extensions.md | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/docs/frontend-system/architecture/20-extensions.md b/docs/frontend-system/architecture/20-extensions.md index e142044d03..02f4ba9d05 100644 --- a/docs/frontend-system/architecture/20-extensions.md +++ b/docs/frontend-system/architecture/20-extensions.md @@ -139,11 +139,9 @@ const extension = createExtension({ // ... output: [coreExtensionData.reactElement.optional()], factory() { - return [ - coreExtensionData.reactElement.optional()( - Math.random() < 0.5 ? : undefined, - ), - ]; + return Math.random() > 0.5 + ? [coreExtensionData.reactElement(
    Hello World
    )] + : []; }, }); ``` @@ -327,18 +325,12 @@ The `ExtensionBoundary` can be used like the following in an extension: const routableExtension = createExtension({ // ... factory({ config, inputs, node }) { - const ExtensionComponent = lazy(() => - options - .loader({ config, inputs }) - .then(element => ({ default: () => element })), - ); - return [ coreExtensionData.path(config.path), - coreExtensionData.routeRef(options.routeRef), + coreExtensionData.routeRef(myRouteRef), coreExtensionData.reactElement( - + , ), ]; From d897ce63d619685fe1f9aec27a809f6f132abbba Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Thu, 15 Aug 2024 13:43:32 +0200 Subject: [PATCH 345/372] Remove backend-common dependency Signed-off-by: Johan Haals --- plugins/search-backend-node/api-report.md | 4 ++-- plugins/search-backend-node/package.json | 2 +- ...ewlineDelimitedJsonCollatorFactory.test.ts | 15 ++++++------ .../NewlineDelimitedJsonCollatorFactory.ts | 7 +++--- plugins/techdocs-node/src/helpers.test.ts | 24 +++++++++---------- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/plugins/search-backend-node/api-report.md b/plugins/search-backend-node/api-report.md index 5e8961a65e..03269c72e8 100644 --- a/plugins/search-backend-node/api-report.md +++ b/plugins/search-backend-node/api-report.md @@ -20,7 +20,7 @@ import { SearchQuery } from '@backstage/plugin-search-common'; import { TaskFunction } from '@backstage/backend-tasks'; import { TaskRunner } from '@backstage/backend-tasks'; import { Transform } from 'stream'; -import { UrlReader } from '@backstage/backend-common'; +import { UrlReaderService } from '@backstage/backend-plugin-api'; import { Writable } from 'stream'; // @public @@ -138,7 +138,7 @@ export class NewlineDelimitedJsonCollatorFactory export type NewlineDelimitedJsonCollatorFactoryOptions = { type: string; searchPattern: string; - reader: UrlReader; + reader: UrlReaderService; logger: LoggerService; visibilityPermission?: Permission; }; diff --git a/plugins/search-backend-node/package.json b/plugins/search-backend-node/package.json index d7a7191faa..a97a0a0a7c 100644 --- a/plugins/search-backend-node/package.json +++ b/plugins/search-backend-node/package.json @@ -53,7 +53,7 @@ "test": "backstage-cli package test" }, "dependencies": { - "@backstage/backend-common": "workspace:^", + "@backstage/backend-defaults": "workspace:^", "@backstage/backend-plugin-api": "workspace:^", "@backstage/backend-tasks": "workspace:^", "@backstage/config": "workspace:^", diff --git a/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.test.ts b/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.test.ts index 45cc98e9ba..ce640636f9 100644 --- a/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.test.ts +++ b/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.test.ts @@ -13,17 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -import { - ReadUrlResponse, - UrlReader, - UrlReaders, -} from '@backstage/backend-common'; import { ConfigReader } from '@backstage/config'; import { Readable } from 'stream'; import { NewlineDelimitedJsonCollatorFactory } from './NewlineDelimitedJsonCollatorFactory'; import { TestPipeline } from '../test-utils'; import { mockServices } from '@backstage/backend-test-utils'; +import { + UrlReaderService, + UrlReaderServiceReadUrlResponse, +} from '@backstage/backend-plugin-api'; +import { UrlReaders } from '@backstage/backend-defaults/urlReader'; describe('DefaultCatalogCollatorFactory', () => { const config = new ConfigReader({}); @@ -42,7 +41,9 @@ describe('DefaultCatalogCollatorFactory', () => { describe('getCollator', () => { let readable: Readable; let reader: jest.Mocked< - UrlReader & { readUrl: jest.Mock> } + UrlReaderService & { + readUrl: jest.Mock>; + } >; let factory: NewlineDelimitedJsonCollatorFactory; diff --git a/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.ts b/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.ts index e7d749dd41..bf78b98040 100644 --- a/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.ts +++ b/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.ts @@ -18,9 +18,8 @@ import { Config } from '@backstage/config'; import { DocumentCollatorFactory } from '@backstage/plugin-search-common'; import { Permission } from '@backstage/plugin-permission-common'; import { Readable } from 'stream'; -import { UrlReader } from '@backstage/backend-common'; import { parse as parseNdjson } from 'ndjson'; -import { LoggerService } from '@backstage/backend-plugin-api'; +import { LoggerService, UrlReaderService } from '@backstage/backend-plugin-api'; /** * Options for instantiate NewlineDelimitedJsonCollatorFactory @@ -29,7 +28,7 @@ import { LoggerService } from '@backstage/backend-plugin-api'; export type NewlineDelimitedJsonCollatorFactoryOptions = { type: string; searchPattern: string; - reader: UrlReader; + reader: UrlReaderService; logger: LoggerService; visibilityPermission?: Permission; }; @@ -73,7 +72,7 @@ export class NewlineDelimitedJsonCollatorFactory private constructor( type: string, private readonly searchPattern: string, - private readonly reader: UrlReader, + private readonly reader: UrlReaderService, private readonly logger: LoggerService, visibilityPermission: Permission | undefined, ) { diff --git a/plugins/techdocs-node/src/helpers.test.ts b/plugins/techdocs-node/src/helpers.test.ts index 4f77a5432b..33f4018f47 100644 --- a/plugins/techdocs-node/src/helpers.test.ts +++ b/plugins/techdocs-node/src/helpers.test.ts @@ -14,13 +14,6 @@ * limitations under the License. */ -import { - ReadTreeResponse, - ReadUrlOptions, - ReadUrlResponse, - SearchResponse, - UrlReader, -} from '@backstage/backend-common'; import { Entity, getEntitySourceLocation } from '@backstage/catalog-model'; import { ConfigReader } from '@backstage/config'; import { ScmIntegrations } from '@backstage/integration'; @@ -34,6 +27,13 @@ import { parseReferenceAnnotation, transformDirLocation, } from './helpers'; +import { + UrlReaderService, + UrlReaderServiceSearchResponse, + UrlReaderServiceReadUrlResponse, + UrlReaderServiceReadUrlOptions, + UrlReaderServiceReadTreeResponse, +} from '@backstage/backend-plugin-api'; jest.mock('@backstage/catalog-model', () => ({ ...jest.requireActual('@backstage/catalog-model'), @@ -290,19 +290,19 @@ describe('getLocationForEntity', () => { describe('getDocFilesFromRepository', () => { it('should read a remote directory using UrlReader.readTree', async () => { - class MockUrlReader implements UrlReader { + class MockUrlReader implements UrlReaderService { async read() { return Buffer.from('mock'); } async readUrl( _url: string, - _options?: ReadUrlOptions | undefined, - ): Promise { + _options?: UrlReaderServiceReadUrlOptions | undefined, + ): Promise { throw new Error('Method not implemented.'); } - async readTree(): Promise { + async readTree(): Promise { return { dir: async () => { return '/tmp/testfolder'; @@ -317,7 +317,7 @@ describe('getDocFilesFromRepository', () => { }; } - async search(): Promise { + async search(): Promise { return { etag: '', files: [], From 12a6126adb1383ee760fd53f4cc27e215dabe1c8 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Thu, 15 Aug 2024 13:45:51 +0200 Subject: [PATCH 346/372] chore: fix yarn lock Signed-off-by: Johan Haals --- yarn.lock | 1 + 1 file changed, 1 insertion(+) diff --git a/yarn.lock b/yarn.lock index 2d329b0c31..0c63617ae7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7559,6 +7559,7 @@ __metadata: resolution: "@backstage/plugin-search-backend-node@workspace:plugins/search-backend-node" dependencies: "@backstage/backend-common": "workspace:^" + "@backstage/backend-defaults": "workspace:^" "@backstage/backend-plugin-api": "workspace:^" "@backstage/backend-tasks": "workspace:^" "@backstage/backend-test-utils": "workspace:^" From f149bfc4f8610c07f079fc31cf681030c4a2647d Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 15 Aug 2024 13:29:46 +0200 Subject: [PATCH 347/372] chore: remove the needless thing Signed-off-by: blam --- .../src/blueprints/SignInPageBlueprint.test.tsx | 6 ++---- .../src/app/createExtensionTester.test.tsx | 7 +++++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.test.tsx b/packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.test.tsx index b45d8ead15..e6389da574 100644 --- a/packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.test.tsx @@ -62,11 +62,9 @@ describe('SignInPageBlueprint', () => { const tester = createExtensionTester(extension); - const Element = tester.get(SignInPageBlueprint.dataRefs.component); + const Component = tester.get(SignInPageBlueprint.dataRefs.component); - expect(Element).toBeDefined(); - - renderInTestApp( {}} />); + renderInTestApp( {}} />); await waitFor(() => { expect(screen.getByTestId('mock-sign-in')).toBeInTheDocument(); diff --git a/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx b/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx index 13bdca1990..73220419b7 100644 --- a/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx +++ b/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx @@ -339,6 +339,9 @@ describe('createExtensionTester', () => { const extension = createExtension({ namespace: 'test', name: 'e1', + inputs: { + ignored: createExtensionInput([stringDataRef]), + }, attachTo: { id: 'ignored', input: 'ignored' }, output: [coreExtensionData.reactElement], factory: () => [coreExtensionData.reactElement(
    bob
    )], @@ -346,8 +349,8 @@ describe('createExtensionTester', () => { const extraExtension = createExtension({ namespace: 'test', - name: 'e1', - attachTo: { id: 'ignored', input: 'ignored' }, + name: 'e2', + attachTo: { id: 'test/e1', input: 'ignored' }, output: [stringDataRef, internalRef.optional()], factory: () => [stringDataRef('test-text')], }); From f8e16b39aeee68fa449ce8d9bac3e9f5747281ea Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 15 Aug 2024 13:50:03 +0200 Subject: [PATCH 348/372] docs/frontend-system: add missing plugin doc fixes Signed-off-by: Patrik Oldsberg --- docs/frontend-system/architecture/15-plugins.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/frontend-system/architecture/15-plugins.md b/docs/frontend-system/architecture/15-plugins.md index f1a24b5b4d..a54573427d 100644 --- a/docs/frontend-system/architecture/15-plugins.md +++ b/docs/frontend-system/architecture/15-plugins.md @@ -10,19 +10,20 @@ description: Frontend plugins ## Introduction -Frontend plugins are a foundational building block in Backstage and the frontend system. They are used to encapsulate and provide functionality for a Backstage app, such as new pages, navigational elements, APIs, as well as extensions and features for other plugins, such entity page cards and content for the Software Catalog, or result list items for the search plugin. +Frontend plugins are a foundational building block in Backstage and the frontend system. They are used to encapsulate and provide functionality for a Backstage app, such as new pages, navigational elements, and APIs; as well as extensions and features for other plugins, such as entity page cards and content for the Software Catalog, or result list items for the search plugin. -Each plugin is typically shipped in a separate NPM package, whether that's a published package, or just in the local workspace. The plugins instance should always the `default` export of the package, either via the main entry-point or the `/alpha` sub-path export. Each plugin package is limited to exporting a single plugin instance. In a local workspace you could use a different structure if preferred, but this is considered a non-standard layout and should be avoided in published packages. +Each plugin is typically shipped in a separate NPM package, whether that's a published package, or just in the local workspace. The plugin instance should always the `default` export of the package, either via the main entry-point or the `/alpha` sub-path export. Each plugin package is limited to exporting a single plugin instance. In a local workspace you could use a different structure if preferred, but this is considered a non-standard layout and should be avoided in published packages. ## Creating a Plugin Frontend plugin instances are created with the `createFrontendPlugin` function, which is provided by the `@backstage/frontend-plugin-api` package. It takes a single options object that provides all of the necessary configuration for the plugin. In particular you will want to provide [extensions](./20-extensions.md) for your plugin, as that is the way that you can provide new functionality to the app. -```ts +```tsx // This creates a new extension, see "Extension Blueprints" documentation for more details const myPage = PageBlueprint.make({ params: { defaultPath: '/my-page', + loader: () => import('./MyPage').then(m => ), }, }); @@ -34,7 +35,7 @@ export default createFrontendPlugin({ ### `pluginId` option -Each plugin needs an ID, which is used to uniquely identity the plugin within an entity Backstage system. The ID does not have to be globally unique across all of the NPM ecosystem, although you generally want to strive for that. It is not possible to install multiple plugins with the same ID in a single Backstage app. +Each plugin needs an ID, which is used to uniquely identify the plugin within an entire Backstage system. The ID does not have to be globally unique across all of the NPM ecosystem, although you generally want to strive for that. It is not possible to install multiple plugins with the same ID in a single Backstage app. The plugin ID should generally be part of the of the package name and use kebab-case. See both the [frontend naming patterns section](./50-naming-patterns.md), as well as the [package metadata section](../../tooling/package-metadata.md#name) for more information. @@ -42,11 +43,11 @@ The plugin ID should generally be part of the of the package name and use kebab- These are the [extensions](./20-extensions.md) that the plugin provides to the app. Note that you should not export any of these extensions separately from the plugin package, as they can already by accessed via the `getExtension` method of the plugin instance using the extension ID. -The extensions that you provide to a plugin will have their `namespace` set to the plugin ID by default. For example, if you create an extensions using the `PageBlueprint` without any particular naming options and install that via a plugin with the ID `my-plugin`, the final extension ID will be `page:my-plugin`. You can read more about how this works in the [extension structure documentation](./20-extensions.md#extension-structure). +The extensions that you provide to a plugin will have their `namespace` set to the plugin ID by default. For example, if you create an extension using the `PageBlueprint` without any particular naming options and install that via a plugin with the ID `my-plugin`, the final extension ID will be `page:my-plugin`. You can read more about how this works in the [extension structure documentation](./20-extensions.md#extension-structure). ### `routes` and `externalRoutes` options -These are the routes that the plugin exposes to the app. The `routes` option declares all of the target routes that your plugin provides, i.e. routes that other plugins and link to. The `externalRoutes` option instead declares all the outgoing routes, i.e. routes that your plugins links to, which you can bind to the `routes` of other plugins. See the [routes documentation](./36-routes.md) for more information how to set up cross-plugin navigation. +These are the routes that the plugin exposes to the app. The `routes` option declares all of the target routes that your plugin provides, i.e. routes that other plugins link to. The `externalRoutes` option instead declares all the outgoing routes, i.e. routes that your plugins links to, which you can bind to the `routes` of other plugins. See the [routes documentation](./36-routes.md) for more information how to set up cross-plugin navigation. ### `featureFlags` option @@ -54,7 +55,7 @@ This is a list of feature flag declarations that your plugin provides to the app ## Installing a Plugin in an App -A plugin instance is considered an frontend feature and can be installed directly in any Backstage frontend app. See the [app documentation](./10-app.md) for more information about the different ways in which you can install new features in an app. +A plugin instance is considered a frontend feature and can be installed directly in any Backstage frontend app. See the [app documentation](./10-app.md) for more information about the different ways in which you can install new features in an app. ## Overriding a Plugin @@ -87,4 +88,4 @@ export default plugin.withOverrides({ }); ``` -You can keep the plugin override in your app package, but it can often be a good idea to separate it out into its own package, especially if you the overrides are complex or you want distinct ownership of the override. For example, if you are overriding the `@backstage/plugin-catalog` plugin, you might create a new package called `@internal/plugin-catalog` at `plugins/catalog` in your workspace, which exports the overridden plugin instance. +You can keep the plugin override in your app package, but it can often be a good idea to separate it out into its own package, especially if the overrides are complex or you want distinct ownership of the override. For example, if you are overriding the `@backstage/plugin-catalog` plugin, you might create a new package called `@internal/plugin-catalog` at `plugins/catalog` in your workspace, which exports the overridden plugin instance. From 805934e7342d0fb069206a7bf0eb55879f22122d Mon Sep 17 00:00:00 2001 From: Camila Belo Date: Thu, 15 Aug 2024 13:55:29 +0200 Subject: [PATCH 349/372] Update plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.test.ts Signed-off-by: Camila Belo --- .../src/scaffolder/actions/builtin/fetch/template.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.test.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.test.ts index 87a6c84750..61918e8450 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.test.ts @@ -80,7 +80,7 @@ describe('fetch:template', () => { workspace: {}, }); action = createFetchTemplateAction({ - reader: Symbol('UrlReaderService') as unknown as UrlReaderService, + reader: Symbol('UrlReader') as unknown as UrlReaderService, integrations: Symbol('Integrations') as unknown as ScmIntegrations, }); }); From cc2ee1d05fe9d450a6fa5fa960c89c972657e77d Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 15 Aug 2024 09:00:09 +0200 Subject: [PATCH 350/372] chore: fix deprecations in app-next Signed-off-by: blam --- packages/app-next/src/App.tsx | 35 +++-- .../app-next/src/examples/pagesPlugin.tsx | 142 +++++++++--------- .../app-next/src/overrides/SignInPage.tsx | 9 +- 3 files changed, 101 insertions(+), 85 deletions(-) diff --git a/packages/app-next/src/App.tsx b/packages/app-next/src/App.tsx index b57c680474..c41f33e01b 100644 --- a/packages/app-next/src/App.tsx +++ b/packages/app-next/src/App.tsx @@ -26,8 +26,8 @@ import homePlugin, { import { coreExtensionData, createExtension, - createApiExtension, createExtensionOverrides, + ApiBlueprint, } from '@backstage/frontend-plugin-api'; import techdocsPlugin from '@backstage/plugin-techdocs/alpha'; import appVisualizerPlugin from '@backstage/plugin-app-visualizer'; @@ -40,6 +40,7 @@ import { createApiFactory, configApiRef } from '@backstage/core-plugin-api'; import { ScmAuth, ScmIntegrationsApi, + scmAuthApiRef, scmIntegrationsApiRef, } from '@backstage/integration-react'; import kubernetesPlugin from '@backstage/plugin-kubernetes/alpha'; @@ -77,25 +78,31 @@ TODO: const homePageExtension = createExtension({ name: 'myhomepage', attachTo: { id: 'page:home', input: 'props' }, - output: { - children: coreExtensionData.reactElement, - title: titleExtensionDataRef, - }, + output: [coreExtensionData.reactElement, titleExtensionDataRef], factory() { - return { children: homePage, title: 'just a title' }; + return [ + coreExtensionData.reactElement(homePage), + titleExtensionDataRef('just a title'), + ]; }, }); -const scmAuthExtension = createApiExtension({ - factory: ScmAuth.createDefaultApiFactory(), +const scmAuthExtension = ApiBlueprint.make({ + namespace: scmAuthApiRef.id, + params: { + factory: ScmAuth.createDefaultApiFactory(), + }, }); -const scmIntegrationApi = createApiExtension({ - factory: createApiFactory({ - api: scmIntegrationsApiRef, - deps: { configApi: configApiRef }, - factory: ({ configApi }) => ScmIntegrationsApi.fromConfig(configApi), - }), +const scmIntegrationApi = ApiBlueprint.make({ + namespace: scmIntegrationsApiRef.id, + params: { + factory: createApiFactory({ + api: scmIntegrationsApiRef, + deps: { configApi: configApiRef }, + factory: ({ configApi }) => ScmIntegrationsApi.fromConfig(configApi), + }), + }, }); const collectedLegacyPlugins = convertLegacyApp( diff --git a/packages/app-next/src/examples/pagesPlugin.tsx b/packages/app-next/src/examples/pagesPlugin.tsx index 2b9907dd59..8eca7d1e6c 100644 --- a/packages/app-next/src/examples/pagesPlugin.tsx +++ b/packages/app-next/src/examples/pagesPlugin.tsx @@ -17,11 +17,11 @@ import React from 'react'; import { Link } from '@backstage/core-components'; import { - createPageExtension, createFrontendPlugin, createRouteRef, createExternalRouteRef, useRouteRef, + PageBlueprint, } from '@backstage/frontend-plugin-api'; import { Route, Routes } from 'react-router-dom'; @@ -37,91 +37,97 @@ export const pageXRouteRef = createRouteRef(); // path: '/page2', // }); -const IndexPage = createPageExtension({ +const IndexPage = PageBlueprint.make({ name: 'index', - defaultPath: '/', - routeRef: indexRouteRef, - loader: async () => { - const Component = () => { - const page1Link = useRouteRef(page1RouteRef); - return ( -
    - op - {page1Link && ( + params: { + defaultPath: '/', + routeRef: indexRouteRef, + loader: async () => { + const Component = () => { + const page1Link = useRouteRef(page1RouteRef); + return ( +
    + op + {page1Link && ( +
    + Page 1 +
    + )}
    - Page 1 + Home +
    +
    + GraphiQL +
    +
    + Search +
    +
    + Settings
    - )} -
    - Home
    -
    - GraphiQL -
    -
    - Search -
    -
    - Settings -
    -
    - ); - }; - return ; + ); + }; + return ; + }, }, }); -const Page1 = createPageExtension({ +const Page1 = PageBlueprint.make({ name: 'page1', - defaultPath: '/page1', - routeRef: page1RouteRef, - loader: async () => { - const Component = () => { - const indexLink = useRouteRef(indexRouteRef); - const xLink = useRouteRef(externalPageXRouteRef); - // const page2Link = useRouteRef(page2RouteRef); - - return ( -
    -

    This is page 1

    - {indexLink && Go back} - Page 2 - {/* Page 2 */} - {xLink && Page X} + params: { + defaultPath: '/page1', + routeRef: page1RouteRef, + loader: async () => { + const Component = () => { + const indexLink = useRouteRef(indexRouteRef); + const xLink = useRouteRef(externalPageXRouteRef); + // const page2Link = useRouteRef(page2RouteRef); + return (
    - Sub-page content: +

    This is page 1

    + {indexLink && Go back} + Page 2 + {/* Page 2 */} + {xLink && Page X} +
    - - This is also page 1} /> - This is page 2} /> - + Sub-page content: +
    + + This is also page 1} /> + This is page 2} /> + +
    -
    - ); - }; - return ; + ); + }; + return ; + }, }, }); -const ExternalPage = createPageExtension({ +const ExternalPage = PageBlueprint.make({ name: 'pageX', - defaultPath: '/pageX', - routeRef: pageXRouteRef, - loader: async () => { - const Component = () => { - const indexLink = useRouteRef(indexRouteRef); - // const pageXLink = useRouteRef(pageXRouteRef); + params: { + defaultPath: '/pageX', + routeRef: pageXRouteRef, + loader: async () => { + const Component = () => { + const indexLink = useRouteRef(indexRouteRef); + // const pageXLink = useRouteRef(pageXRouteRef); - return ( -
    -

    This is page X

    - {indexLink && Go back} -
    - ); - }; - return ; + return ( +
    +

    This is page X

    + {indexLink && Go back} +
    + ); + }; + return ; + }, }, }); diff --git a/packages/app-next/src/overrides/SignInPage.tsx b/packages/app-next/src/overrides/SignInPage.tsx index 364a749293..52dd01fcde 100644 --- a/packages/app-next/src/overrides/SignInPage.tsx +++ b/packages/app-next/src/overrides/SignInPage.tsx @@ -17,13 +17,16 @@ import React from 'react'; import { SignInPage } from '@backstage/core-components'; import { + SignInPageBlueprint, createExtensionOverrides, - createSignInPageExtension, } from '@backstage/frontend-plugin-api'; -const signInPage = createSignInPageExtension({ +const signInPage = SignInPageBlueprint.make({ name: 'guest', - loader: async () => props => , + params: { + loader: async () => props => + , + }, }); export const signInPageOverrides = createExtensionOverrides({ From 95f977f42cefdf8e188c33fca2364af4329a933f Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 15 Aug 2024 09:02:38 +0200 Subject: [PATCH 351/372] migrate core-compat-api Signed-off-by: blam --- .../src/collectLegacyRoutes.test.tsx | 12 +-- .../src/collectLegacyRoutes.tsx | 74 +++++++++++-------- .../src/compatWrapper/compatWrapper.test.tsx | 8 +- .../src/convertLegacyApp.test.tsx | 8 +- .../core-compat-api/src/convertLegacyApp.ts | 31 ++++---- 5 files changed, 69 insertions(+), 64 deletions(-) diff --git a/packages/core-compat-api/src/collectLegacyRoutes.test.tsx b/packages/core-compat-api/src/collectLegacyRoutes.test.tsx index b721592ffd..f8b40a561c 100644 --- a/packages/core-compat-api/src/collectLegacyRoutes.test.tsx +++ b/packages/core-compat-api/src/collectLegacyRoutes.test.tsx @@ -70,7 +70,7 @@ describe('collectLegacyRoutes', () => { id: 'page:score-card', attachTo: { id: 'app/routes', input: 'routes' }, disabled: false, - defaultConfig: { path: 'score-board' }, + defaultConfig: {}, }, { id: 'api:plugin.scoringdata.service', @@ -86,7 +86,7 @@ describe('collectLegacyRoutes', () => { id: 'page:stackstorm', attachTo: { id: 'app/routes', input: 'routes' }, disabled: false, - defaultConfig: { path: 'stackstorm' }, + defaultConfig: {}, }, { id: 'api:plugin.stackstorm.service', @@ -102,13 +102,13 @@ describe('collectLegacyRoutes', () => { id: 'page:puppetDb', attachTo: { id: 'app/routes', input: 'routes' }, disabled: false, - defaultConfig: { path: 'puppetdb' }, + defaultConfig: {}, }, { id: 'page:puppetDb/1', attachTo: { id: 'app/routes', input: 'routes' }, disabled: false, - defaultConfig: { path: 'puppetdb' }, + defaultConfig: {}, }, { id: 'api:plugin.puppetdb.service', @@ -173,12 +173,12 @@ describe('collectLegacyRoutes', () => { id: 'page:catalog', attachTo: { id: 'app/routes', input: 'routes' }, disabled: false, - defaultConfig: { path: 'catalog' }, + defaultConfig: {}, }, { id: 'page:catalog/1', attachTo: { id: 'app/routes', input: 'routes' }, - defaultConfig: { path: 'catalog/:namespace/:kind/:name' }, + defaultConfig: {}, disabled: false, }, { diff --git a/packages/core-compat-api/src/collectLegacyRoutes.tsx b/packages/core-compat-api/src/collectLegacyRoutes.tsx index 9af994d4e0..68e9aaf3a1 100644 --- a/packages/core-compat-api/src/collectLegacyRoutes.tsx +++ b/packages/core-compat-api/src/collectLegacyRoutes.tsx @@ -29,6 +29,8 @@ import { createExtensionInput, createPageExtension, createFrontendPlugin, + ApiBlueprint, + PageBlueprint, } from '@backstage/frontend-plugin-api'; import React, { Children, ReactNode, isValidElement } from 'react'; import { Route, Routes } from 'react-router-dom'; @@ -80,19 +82,24 @@ function makeRoutingShimExtension(options: { name, attachTo: { id: parentExtensionId, input: 'childRoutingShims' }, inputs: { - childRoutingShims: createExtensionInput({ - routePath: coreExtensionData.routePath.optional(), - routeRef: coreExtensionData.routeRef.optional(), - }), + childRoutingShims: createExtensionInput([ + coreExtensionData.routePath.optional(), + coreExtensionData.routeRef.optional(), + ]), }, - output: { - routePath: coreExtensionData.routePath.optional(), - routeRef: coreExtensionData.routeRef.optional(), + output: [ + coreExtensionData.routePath.optional(), + coreExtensionData.routeRef.optional(), + ], + *factory() { + if (routePath) { + yield coreExtensionData.routePath(routePath); + } + + if (routeRef) { + yield coreExtensionData.routeRef(convertLegacyRouteRef(routeRef)); + } }, - factory: () => ({ - routePath, - routeRef: routeRef ? convertLegacyRouteRef(routeRef) : undefined, - }), }); } @@ -214,28 +221,33 @@ export function collectLegacyRoutes( }`; extensions.push( - createPageExtension({ + PageBlueprint.makeWithOverrides({ name: pageExtensionName, - defaultPath: path[0] === '/' ? path.slice(1) : path, - routeRef: routeRef ? convertLegacyRouteRef(routeRef) : undefined, inputs: { - childRoutingShims: createExtensionInput({ - routePath: coreExtensionData.routePath.optional(), - routeRef: coreExtensionData.routeRef.optional(), - }), + childRoutingShims: createExtensionInput([ + coreExtensionData.routePath.optional(), + coreExtensionData.routeRef.optional(), + ]), + }, + factory(originalFactory, { inputs: _inputs }) { + // todo(blam): why do we not use the inputs here? + return originalFactory({ + defaultPath: path[0] === '/' ? path.slice(1) : path, + routeRef: routeRef ? convertLegacyRouteRef(routeRef) : undefined, + loader: async () => + compatWrapper( + route.props.children ? ( + + + + + + ) : ( + routeElement + ), + ), + }); }, - loader: async () => - compatWrapper( - route.props.children ? ( - - - - - - ) : ( - routeElement - ), - ), }), ); @@ -258,7 +270,7 @@ export function collectLegacyRoutes( extensions: [ ...extensions, ...Array.from(plugin.getApis()).map(factory => - createApiExtension({ factory }), + ApiBlueprint.make({ namespace: factory.api.id, params: { factory } }), ), ], routes: convertLegacyRouteRefs(plugin.routes ?? {}), diff --git a/packages/core-compat-api/src/compatWrapper/compatWrapper.test.tsx b/packages/core-compat-api/src/compatWrapper/compatWrapper.test.tsx index 04e2361087..6357f13906 100644 --- a/packages/core-compat-api/src/compatWrapper/compatWrapper.test.tsx +++ b/packages/core-compat-api/src/compatWrapper/compatWrapper.test.tsx @@ -45,9 +45,7 @@ describe('BackwardsCompatProvider', () => { createExtensionTester( createExtension({ attachTo: { id: 'ignored', input: 'ignored' }, - output: { - element: coreExtensionData.reactElement, - }, + output: [coreExtensionData.reactElement], factory() { function Component() { const app = useApp(); @@ -66,9 +64,7 @@ describe('BackwardsCompatProvider', () => { ); } - return { - element: compatWrapper(), - }; + return [coreExtensionData.reactElement(compatWrapper())]; }, }), ).render(); diff --git a/packages/core-compat-api/src/convertLegacyApp.test.tsx b/packages/core-compat-api/src/convertLegacyApp.test.tsx index 2e7be66915..ea84c06ba9 100644 --- a/packages/core-compat-api/src/convertLegacyApp.test.tsx +++ b/packages/core-compat-api/src/convertLegacyApp.test.tsx @@ -62,7 +62,7 @@ describe('convertLegacyApp', () => { id: 'page:score-card', attachTo: { id: 'app/routes', input: 'routes' }, disabled: false, - defaultConfig: { path: 'score-board' }, + defaultConfig: {}, }, { id: 'api:plugin.scoringdata.service', @@ -78,7 +78,7 @@ describe('convertLegacyApp', () => { id: 'page:stackstorm', attachTo: { id: 'app/routes', input: 'routes' }, disabled: false, - defaultConfig: { path: 'stackstorm' }, + defaultConfig: {}, }, { id: 'api:plugin.stackstorm.service', @@ -94,13 +94,13 @@ describe('convertLegacyApp', () => { id: 'page:puppetDb', attachTo: { id: 'app/routes', input: 'routes' }, disabled: false, - defaultConfig: { path: 'puppetdb' }, + defaultConfig: {}, }, { id: 'page:puppetDb/1', attachTo: { id: 'app/routes', input: 'routes' }, disabled: false, - defaultConfig: { path: 'puppetdb' }, + defaultConfig: {}, }, { id: 'api:plugin.puppetdb.service', diff --git a/packages/core-compat-api/src/convertLegacyApp.ts b/packages/core-compat-api/src/convertLegacyApp.ts index 72ce4b5e61..ffeab3bdc6 100644 --- a/packages/core-compat-api/src/convertLegacyApp.ts +++ b/packages/core-compat-api/src/convertLegacyApp.ts @@ -107,33 +107,30 @@ export function convertLegacyApp( name: 'layout', attachTo: { id: 'app', input: 'root' }, inputs: { - content: createExtensionInput( - { - element: coreExtensionData.reactElement, - }, - { singleton: true }, - ), - }, - output: { - element: coreExtensionData.reactElement, + content: createExtensionInput([coreExtensionData.reactElement], { + singleton: true, + }), }, + output: [coreExtensionData.reactElement], factory({ inputs }) { // Clone the root element, this replaces the FlatRoutes declared in the app with out content input - return { - element: React.cloneElement( - rootEl, - undefined, - inputs.content.output.element, + return [ + coreExtensionData.reactElement( + React.cloneElement( + rootEl, + undefined, + inputs.content.get(coreExtensionData.reactElement), + ), ), - }; + ]; }, }); const CoreNavOverride = createExtension({ namespace: 'app', name: 'nav', attachTo: { id: 'app/layout', input: 'nav' }, - output: {}, - factory: () => ({}), + output: [], + factory: () => [], disabled: true, }); From 7df9a72154944de6aaf9ecd129af565a78409ad5 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 15 Aug 2024 09:37:13 +0200 Subject: [PATCH 352/372] chore: updated frontend-app-api Signed-off-by: blam --- .../DefaultComponentsApi.test.tsx | 10 +-- .../frontend-app-api/src/extensions/App.tsx | 57 ++++++--------- .../src/extensions/AppLayout.tsx | 40 ++++------- .../src/extensions/AppNav.tsx | 48 ++++++------- .../src/extensions/AppRoot.tsx | 64 +++++++++-------- .../src/extensions/AppRoutes.tsx | 22 +++--- .../src/extensions/elements.tsx | 49 +++++++------ .../src/extensions/themes.tsx | 44 +++++++----- .../extractRouteInfoFromAppNode.test.ts | 29 ++++---- .../src/tree/createAppTree.test.ts | 8 +-- .../src/tree/resolveAppTree.test.ts | 4 +- .../src/wiring/createApp.test.tsx | 71 +++++++++++-------- .../frontend-app-api/src/wiring/createApp.tsx | 20 +++--- 13 files changed, 229 insertions(+), 237 deletions(-) diff --git a/packages/frontend-app-api/src/apis/implementations/ComponentsApi/DefaultComponentsApi.test.tsx b/packages/frontend-app-api/src/apis/implementations/ComponentsApi/DefaultComponentsApi.test.tsx index 7d62103727..e2c7581e63 100644 --- a/packages/frontend-app-api/src/apis/implementations/ComponentsApi/DefaultComponentsApi.test.tsx +++ b/packages/frontend-app-api/src/apis/implementations/ComponentsApi/DefaultComponentsApi.test.tsx @@ -40,14 +40,8 @@ const baseOverrides = createExtensionOverrides({ namespace: 'app', name: 'root', attachTo: { id: 'app', input: 'root' }, - output: { - element: coreExtensionData.reactElement, - }, - factory() { - return { - element:
    root
    , - }; - }, + output: [coreExtensionData.reactElement], + factory: () => [coreExtensionData.reactElement(
    root
    )], }), ], }); diff --git a/packages/frontend-app-api/src/extensions/App.tsx b/packages/frontend-app-api/src/extensions/App.tsx index 7794aceb79..ba6c5f65f1 100644 --- a/packages/frontend-app-api/src/extensions/App.tsx +++ b/packages/frontend-app-api/src/extensions/App.tsx @@ -18,51 +18,38 @@ import React from 'react'; import { ExtensionBoundary, coreExtensionData, - createApiExtension, createComponentExtension, createExtension, createExtensionInput, - createThemeExtension, - createTranslationExtension, IconBundleBlueprint, + ThemeBlueprint, + ApiBlueprint, + TranslationBlueprint, } from '@backstage/frontend-plugin-api'; export const App = createExtension({ namespace: 'app', attachTo: { id: 'root', input: 'default' }, // ignored inputs: { - apis: createExtensionInput({ - api: createApiExtension.factoryDataRef, + apis: createExtensionInput([ApiBlueprint.dataRefs.factory]), + themes: createExtensionInput([ThemeBlueprint.dataRefs.theme]), + components: createExtensionInput([ + createComponentExtension.componentDataRef, + ]), + translations: createExtensionInput([ + TranslationBlueprint.dataRefs.translation, + ]), + icons: createExtensionInput([IconBundleBlueprint.dataRefs.icons]), + root: createExtensionInput([coreExtensionData.reactElement], { + singleton: true, }), - themes: createExtensionInput({ - theme: createThemeExtension.themeDataRef, - }), - components: createExtensionInput({ - component: createComponentExtension.componentDataRef, - }), - translations: createExtensionInput({ - translation: createTranslationExtension.translationDataRef, - }), - icons: createExtensionInput({ - icon: IconBundleBlueprint.dataRefs.icons, - }), - root: createExtensionInput( - { - element: coreExtensionData.reactElement, - }, - { singleton: true }, + }, + output: [coreExtensionData.reactElement], + factory: ({ node, inputs }) => [ + coreExtensionData.reactElement( + + {inputs.root.get(coreExtensionData.reactElement)} + , ), - }, - output: { - root: coreExtensionData.reactElement, - }, - factory({ node, inputs }) { - return { - root: ( - - {inputs.root.output.element} - - ), - }; - }, + ], }); diff --git a/packages/frontend-app-api/src/extensions/AppLayout.tsx b/packages/frontend-app-api/src/extensions/AppLayout.tsx index 7be0029c25..9fadba8a93 100644 --- a/packages/frontend-app-api/src/extensions/AppLayout.tsx +++ b/packages/frontend-app-api/src/extensions/AppLayout.tsx @@ -27,30 +27,20 @@ export const AppLayout = createExtension({ name: 'layout', attachTo: { id: 'app/root', input: 'children' }, inputs: { - nav: createExtensionInput( - { - element: coreExtensionData.reactElement, - }, - { singleton: true }, + nav: createExtensionInput([coreExtensionData.reactElement], { + singleton: true, + }), + content: createExtensionInput([coreExtensionData.reactElement], { + singleton: true, + }), + }, + output: [coreExtensionData.reactElement], + factory: ({ inputs }) => [ + coreExtensionData.reactElement( + + {inputs.nav.get(coreExtensionData.reactElement)} + {inputs.content.get(coreExtensionData.reactElement)} + , ), - content: createExtensionInput( - { - element: coreExtensionData.reactElement, - }, - { singleton: true }, - ), - }, - output: { - element: coreExtensionData.reactElement, - }, - factory({ inputs }) { - return { - element: ( - - {inputs.nav.output.element} - {inputs.content.output.element} - - ), - }; - }, + ], }); diff --git a/packages/frontend-app-api/src/extensions/AppNav.tsx b/packages/frontend-app-api/src/extensions/AppNav.tsx index ffef1c7c61..49c95e84f2 100644 --- a/packages/frontend-app-api/src/extensions/AppNav.tsx +++ b/packages/frontend-app-api/src/extensions/AppNav.tsx @@ -86,33 +86,27 @@ export const AppNav = createExtension({ name: 'nav', attachTo: { id: 'app/layout', input: 'nav' }, inputs: { - items: createExtensionInput({ - target: createNavItemExtension.targetDataRef, + items: createExtensionInput([createNavItemExtension.targetDataRef]), + logos: createExtensionInput([createNavLogoExtension.logoElementsDataRef], { + singleton: true, + optional: true, }), - logos: createExtensionInput( - { - elements: createNavLogoExtension.logoElementsDataRef, - }, - { - singleton: true, - optional: true, - }, + }, + output: [coreExtensionData.reactElement], + factory: ({ inputs }) => [ + coreExtensionData.reactElement( + + + + {inputs.items.map((item, index) => ( + + ))} + , ), - }, - output: { - element: coreExtensionData.reactElement, - }, - factory({ inputs }) { - return { - element: ( - - - - {inputs.items.map((item, index) => ( - - ))} - - ), - }; - }, + ], }); diff --git a/packages/frontend-app-api/src/extensions/AppRoot.tsx b/packages/frontend-app-api/src/extensions/AppRoot.tsx index f3a962dd10..a158386d04 100644 --- a/packages/frontend-app-api/src/extensions/AppRoot.tsx +++ b/packages/frontend-app-api/src/extensions/AppRoot.tsx @@ -23,12 +23,12 @@ import React, { useState, } from 'react'; import { + AppRootWrapperBlueprint, + RouterBlueprint, + SignInPageBlueprint, coreExtensionData, - createAppRootWrapperExtension, createExtension, createExtensionInput, - createRouterExtension, - createSignInPageExtension, } from '@backstage/frontend-plugin-api'; import { IdentityApi, @@ -48,52 +48,54 @@ export const AppRoot = createExtension({ name: 'root', attachTo: { id: 'app', input: 'root' }, inputs: { - router: createExtensionInput( - { component: createRouterExtension.componentDataRef }, - { singleton: true, optional: true }, - ), - signInPage: createExtensionInput( - { component: createSignInPageExtension.componentDataRef }, - { singleton: true, optional: true }, - ), - children: createExtensionInput( - { element: coreExtensionData.reactElement }, - { singleton: true }, - ), - elements: createExtensionInput({ - element: coreExtensionData.reactElement, + router: createExtensionInput([RouterBlueprint.dataRefs.component], { + singleton: true, + optional: true, }), - wrappers: createExtensionInput({ - component: createAppRootWrapperExtension.componentDataRef, + signInPage: createExtensionInput([SignInPageBlueprint.dataRefs.component], { + singleton: true, + optional: true, }), + children: createExtensionInput([coreExtensionData.reactElement], { + singleton: true, + }), + elements: createExtensionInput([coreExtensionData.reactElement]), + wrappers: createExtensionInput([ + AppRootWrapperBlueprint.dataRefs.component, + ]), }, - output: { - element: coreExtensionData.reactElement, - }, + output: [coreExtensionData.reactElement], factory({ inputs }) { let content: React.ReactNode = ( <> {inputs.elements.map(el => ( - {el.output.element} + + {el.get(coreExtensionData.reactElement)} + ))} - {inputs.children.output.element} + {inputs.children.get(coreExtensionData.reactElement)} ); for (const wrapper of inputs.wrappers) { - content = {content}; + const Component = wrapper.get(AppRootWrapperBlueprint.dataRefs.component); + content = {content}; } - return { - element: ( + return [ + coreExtensionData.reactElement( {content} - + , ), - }; + ]; }, }); diff --git a/packages/frontend-app-api/src/extensions/AppRoutes.tsx b/packages/frontend-app-api/src/extensions/AppRoutes.tsx index 38a9291755..6ef7e2a271 100644 --- a/packages/frontend-app-api/src/extensions/AppRoutes.tsx +++ b/packages/frontend-app-api/src/extensions/AppRoutes.tsx @@ -29,15 +29,13 @@ export const AppRoutes = createExtension({ name: 'routes', attachTo: { id: 'app/layout', input: 'content' }, inputs: { - routes: createExtensionInput({ - path: coreExtensionData.routePath, - ref: coreExtensionData.routeRef.optional(), - element: coreExtensionData.reactElement, - }), - }, - output: { - element: coreExtensionData.reactElement, + routes: createExtensionInput([ + coreExtensionData.routePath, + coreExtensionData.routeRef.optional(), + coreExtensionData.reactElement, + ]), }, + output: [coreExtensionData.reactElement], factory({ inputs }) { const Routes = () => { const NotFoundErrorPage = useComponentRef( @@ -46,8 +44,8 @@ export const AppRoutes = createExtension({ const element = useRoutes([ ...inputs.routes.map(route => ({ - path: `${route.output.path}/*`, - element: route.output.element, + path: `${route.get(coreExtensionData.routePath)}/*`, + element: route.get(coreExtensionData.reactElement), })), { path: '*', @@ -58,8 +56,6 @@ export const AppRoutes = createExtension({ return element; }; - return { - element: , - }; + return [coreExtensionData.reactElement()]; }, }); diff --git a/packages/frontend-app-api/src/extensions/elements.tsx b/packages/frontend-app-api/src/extensions/elements.tsx index 0a764583bb..1ab7f97ba2 100644 --- a/packages/frontend-app-api/src/extensions/elements.tsx +++ b/packages/frontend-app-api/src/extensions/elements.tsx @@ -15,31 +15,36 @@ */ import { AlertDisplay, OAuthRequestDialog } from '@backstage/core-components'; -import { - createAppRootElementExtension, - createSchemaFromZod, -} from '@backstage/frontend-plugin-api'; +import { AppRootElementBlueprint } from '@backstage/frontend-plugin-api'; import React from 'react'; -export const oauthRequestDialogAppRootElement = createAppRootElementExtension({ +export const oauthRequestDialogAppRootElement = AppRootElementBlueprint.make({ namespace: 'app', name: 'oauth-request-dialog', - element: , + params: { + element: , + }, }); -export const alertDisplayAppRootElement = createAppRootElementExtension({ - namespace: 'app', - name: 'alert-display', - configSchema: createSchemaFromZod(z => - z.object({ - transientTimeoutMs: z.number().default(5000), - anchorOrigin: z - .object({ - vertical: z.enum(['top', 'bottom']).default('top'), - horizontal: z.enum(['left', 'center', 'right']).default('center'), - }) - .default({}), - }), - ), - element: ({ config }) => , -}); +export const alertDisplayAppRootElement = + AppRootElementBlueprint.makeWithOverrides({ + namespace: 'app', + name: 'alert-display', + config: { + schema: { + transientTimeoutMs: z => z.number().default(5000), + anchorOrigin: z => + z + .object({ + vertical: z.enum(['top', 'bottom']).default('top'), + horizontal: z.enum(['left', 'center', 'right']).default('center'), + }) + .default({}), + }, + }, + factory: (originalFactory, { config }) => { + return originalFactory({ + element: () => , + }); + }, + }); diff --git a/packages/frontend-app-api/src/extensions/themes.tsx b/packages/frontend-app-api/src/extensions/themes.tsx index ea11b6a638..a4fd0b253e 100644 --- a/packages/frontend-app-api/src/extensions/themes.tsx +++ b/packages/frontend-app-api/src/extensions/themes.tsx @@ -21,24 +21,34 @@ import { } from '@backstage/theme'; import DarkIcon from '@material-ui/icons/Brightness2'; import LightIcon from '@material-ui/icons/WbSunny'; -import { createThemeExtension } from '@backstage/frontend-plugin-api'; +import { ThemeBlueprint } from '@backstage/frontend-plugin-api'; -export const LightTheme = createThemeExtension({ - id: 'light', - title: 'Light Theme', - variant: 'light', - icon: , - Provider: ({ children }) => ( - - ), +export const LightTheme = ThemeBlueprint.make({ + name: 'light', + params: { + theme: { + id: 'light', + title: 'Light Theme', + variant: 'light', + icon: , + Provider: ({ children }) => ( + + ), + }, + }, }); -export const DarkTheme = createThemeExtension({ - id: 'dark', - title: 'Dark Theme', - variant: 'dark', - icon: , - Provider: ({ children }) => ( - - ), +export const DarkTheme = ThemeBlueprint.make({ + name: 'dark', + params: { + theme: { + id: 'dark', + title: 'Dark Theme', + variant: 'dark', + icon: , + Provider: ({ children }) => ( + + ), + }, + }, }); diff --git a/packages/frontend-app-api/src/routing/extractRouteInfoFromAppNode.test.ts b/packages/frontend-app-api/src/routing/extractRouteInfoFromAppNode.test.ts index c22cb6ff1d..8a54f3e73e 100644 --- a/packages/frontend-app-api/src/routing/extractRouteInfoFromAppNode.test.ts +++ b/packages/frontend-app-api/src/routing/extractRouteInfoFromAppNode.test.ts @@ -50,22 +50,23 @@ function createTestExtension(options: { attachTo: options.parent ? { id: `test/${options.parent}`, input: 'children' } : { id: 'app/routes', input: 'routes' }, - output: { - element: coreExtensionData.reactElement, - path: coreExtensionData.routePath.optional(), - routeRef: coreExtensionData.routeRef.optional(), - }, + output: [ + coreExtensionData.reactElement, + coreExtensionData.routePath.optional(), + coreExtensionData.routeRef.optional(), + ], inputs: { - children: createExtensionInput({ - element: coreExtensionData.reactElement, - }), + children: createExtensionInput([coreExtensionData.reactElement]), }, - factory() { - return { - path: options.path, - routeRef: options.routeRef, - element: React.createElement('div'), - }; + *factory() { + if (options.path) { + yield coreExtensionData.routePath(options.path); + } + if (options.routeRef) { + yield coreExtensionData.routeRef(options.routeRef); + } + + yield coreExtensionData.reactElement(React.createElement('div')); }, }); } diff --git a/packages/frontend-app-api/src/tree/createAppTree.test.ts b/packages/frontend-app-api/src/tree/createAppTree.test.ts index f24f199d5d..f5df5270cd 100644 --- a/packages/frontend-app-api/src/tree/createAppTree.test.ts +++ b/packages/frontend-app-api/src/tree/createAppTree.test.ts @@ -25,8 +25,8 @@ import { createAppTree } from './createAppTree'; const extBase = { id: 'test', attachTo: { id: 'app', input: 'root' }, - output: {}, - factory: () => ({}), + output: [], + factory: () => [], }; describe('createAppTree', () => { @@ -60,8 +60,8 @@ describe('createAppTree', () => { name: 'app', attachTo: { id: 'app/routes', input: 'route' }, inputs: {}, - output: {}, - factory: () => ({}), + output: [], + factory: () => [], }), ], }), diff --git a/packages/frontend-app-api/src/tree/resolveAppTree.test.ts b/packages/frontend-app-api/src/tree/resolveAppTree.test.ts index d9b65555fe..740f05d5f7 100644 --- a/packages/frontend-app-api/src/tree/resolveAppTree.test.ts +++ b/packages/frontend-app-api/src/tree/resolveAppTree.test.ts @@ -23,8 +23,8 @@ const extension = resolveExtensionDefinition( createExtension({ name: 'test', attachTo: { id: 'nonexistent', input: 'nonexistent' }, - output: {}, - factory: () => ({}), + output: [], + factory: () => [], }), ) as Extension; diff --git a/packages/frontend-app-api/src/wiring/createApp.test.tsx b/packages/frontend-app-api/src/wiring/createApp.test.tsx index ead9422a13..c79d8eed76 100644 --- a/packages/frontend-app-api/src/wiring/createApp.test.tsx +++ b/packages/frontend-app-api/src/wiring/createApp.test.tsx @@ -20,9 +20,9 @@ import { coreExtensionData, createExtension, createExtensionOverrides, - createPageExtension, + PageBlueprint, createFrontendPlugin, - createThemeExtension, + ThemeBlueprint, } from '@backstage/frontend-plugin-api'; import { screen, waitFor } from '@testing-library/react'; import { CreateAppFeatureLoader, createApp } from './createApp'; @@ -47,11 +47,16 @@ describe('createApp', () => { createFrontendPlugin({ id: 'test', extensions: [ - createThemeExtension({ - id: 'derp', - title: 'Derp', - variant: 'dark', - Provider: () =>
    Derp
    , + ThemeBlueprint.make({ + name: 'derp', + params: { + theme: { + id: 'derp', + title: 'Derp', + variant: 'dark', + Provider: () =>
    Derp
    , + }, + }, }), ], }), @@ -71,18 +76,22 @@ describe('createApp', () => { createFrontendPlugin({ id: duplicatedFeatureId, extensions: [ - createPageExtension({ - defaultPath: '/', - loader: async () =>
    First Page
    , + PageBlueprint.make({ + params: { + defaultPath: '/', + loader: async () =>
    First Page
    , + }, }), ], }), createFrontendPlugin({ id: duplicatedFeatureId, extensions: [ - createPageExtension({ - defaultPath: '/', - loader: async () =>
    Last Page
    , + PageBlueprint.make({ + params: { + defaultPath: '/', + loader: async () =>
    Last Page
    , + }, }), ], }), @@ -110,9 +119,11 @@ describe('createApp', () => { createFrontendPlugin({ id: 'test', extensions: [ - createPageExtension({ - defaultPath: '/', - loader: async () =>
    {config.getString('key')}
    , + PageBlueprint.make({ + params: { + defaultPath: '/', + loader: async () =>
    {config.getString('key')}
    , + }, }), ], }), @@ -170,7 +181,7 @@ describe('createApp', () => { createExtension({ name: 'first', attachTo: { id: 'app', input: 'root' }, - output: { element: coreExtensionData.reactElement }, + output: [coreExtensionData.reactElement], factory() { const Component = () => { const flagsApi = useApi(featureFlagsApiRef); @@ -184,7 +195,7 @@ describe('createApp', () => {
    ); }; - return { element: }; + return [coreExtensionData.reactElement()]; }, }), ], @@ -197,8 +208,8 @@ describe('createApp', () => { name: 'root', attachTo: { id: 'app', input: 'root' }, disabled: true, - output: {}, - factory: () => ({}), + output: [], + factory: () => [], }), ], }), @@ -221,14 +232,16 @@ describe('createApp', () => { createFrontendPlugin({ id: 'my-plugin', extensions: [ - createPageExtension({ - defaultPath: '/', - loader: async () => { - const Component = () => { - appTreeApi = useApi(appTreeApiRef); - return
    My Plugin Page
    ; - }; - return ; + PageBlueprint.make({ + params: { + defaultPath: '/', + loader: async () => { + const Component = () => { + appTreeApi = useApi(appTreeApiRef); + return
    My Plugin Page
    ; + }; + return ; + }, }, }), ], @@ -250,7 +263,7 @@ describe('createApp', () => { content [ routes [ - + ] ] diff --git a/packages/frontend-app-api/src/wiring/createApp.tsx b/packages/frontend-app-api/src/wiring/createApp.tsx index 6f23f4cf2c..ca42dce3e4 100644 --- a/packages/frontend-app-api/src/wiring/createApp.tsx +++ b/packages/frontend-app-api/src/wiring/createApp.tsx @@ -17,18 +17,18 @@ import React, { JSX, ReactNode } from 'react'; import { ConfigReader } from '@backstage/config'; import { + ApiBlueprint, AppTree, appTreeApiRef, componentsApiRef, coreExtensionData, - createApiExtension, - createThemeExtension, - createTranslationExtension, FrontendFeature, IconBundleBlueprint, iconsApiRef, RouteResolutionApi, routeResolutionApiRef, + ThemeBlueprint, + TranslationBlueprint, } from '@backstage/frontend-plugin-api'; import { App } from '../extensions/App'; import { AppRoutes } from '../extensions/AppRoutes'; @@ -110,7 +110,9 @@ import { stringifyError } from '@backstage/errors'; import { icons as defaultIcons } from '../../../app-defaults/src/defaults'; import { getBasePath } from '../routing/getBasePath'; -const DefaultApis = defaultApis.map(factory => createApiExtension({ factory })); +const DefaultApis = defaultApis.map(factory => + ApiBlueprint.make({ namespace: factory.api.id, params: { factory } }), +); export const builtinExtensions = [ App, @@ -357,23 +359,21 @@ function createApiHolder( const pluginApis = tree.root.edges.attachments .get('apis') - ?.map(e => e.instance?.getData(createApiExtension.factoryDataRef)) + ?.map(e => e.instance?.getData(ApiBlueprint.dataRefs.factory)) .filter((x): x is AnyApiFactory => !!x) ?? []; const themeExtensions = tree.root.edges.attachments .get('themes') - ?.map(e => e.instance?.getData(createThemeExtension.themeDataRef)) + ?.map(e => e.instance?.getData(ThemeBlueprint.dataRefs.theme)) .filter((x): x is AppTheme => !!x) ?? []; const translationResources = tree.root.edges.attachments .get('translations') - ?.map(e => - e.instance?.getData(createTranslationExtension.translationDataRef), - ) + ?.map(e => e.instance?.getData(TranslationBlueprint.dataRefs.translation)) .filter( - (x): x is typeof createTranslationExtension.translationDataRef.T => !!x, + (x): x is typeof TranslationBlueprint.dataRefs.translation.T => !!x, ) ?? []; const extensionIcons = tree.root.edges.attachments From 9afc8a6000f88fad84547d5843408b2d019ab837 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 15 Aug 2024 09:49:06 +0200 Subject: [PATCH 353/372] chore: updating the frontend-* packages Signed-off-by: blam --- .../src/components/ExtensionBoundary.test.tsx | 31 ++--- .../src/app/createExtensionTester.test.tsx | 110 ++++++++---------- .../src/app/renderInTestApp.tsx | 18 +-- 3 files changed, 78 insertions(+), 81 deletions(-) diff --git a/packages/frontend-plugin-api/src/components/ExtensionBoundary.test.tsx b/packages/frontend-plugin-api/src/components/ExtensionBoundary.test.tsx index 1f12f127e8..403d591db1 100644 --- a/packages/frontend-plugin-api/src/components/ExtensionBoundary.test.tsx +++ b/packages/frontend-plugin-api/src/components/ExtensionBoundary.test.tsx @@ -30,24 +30,26 @@ import { } from '@backstage/core-plugin-api'; import { createRouteRef } from '../routing'; import { createExtensionTester } from '@backstage/frontend-test-utils'; -import { createApiExtension } from '../extensions'; +import { ApiBlueprint } from '../blueprints'; const wrapInBoundaryExtension = (element?: JSX.Element) => { const routeRef = createRouteRef(); return createExtension({ name: 'test', attachTo: { id: 'app/routes', input: 'routes' }, - output: { - element: coreExtensionData.reactElement, - path: coreExtensionData.routePath, - routeRef: coreExtensionData.routeRef.optional(), - }, + output: [ + coreExtensionData.reactElement, + coreExtensionData.routePath, + coreExtensionData.routeRef.optional(), + ], factory({ node }) { - return { - routeRef, - path: '/', - element: {element}, - }; + return [ + coreExtensionData.reactElement( + {element}, + ), + coreExtensionData.routePath('/'), + coreExtensionData.routeRef(routeRef), + ]; }, }); }; @@ -134,8 +136,11 @@ describe('ExtensionBoundary', () => { await act(async () => { createExtensionTester(wrapInBoundaryExtension()) .add( - createApiExtension({ - factory: createApiFactory(analyticsApiRef, analyticsApiMock), + ApiBlueprint.make({ + namespace: analyticsApiRef.id, + params: { + factory: createApiFactory(analyticsApiRef, analyticsApiMock), + }, }), ) .render(); diff --git a/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx b/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx index 73220419b7..86953df675 100644 --- a/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx +++ b/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx @@ -41,8 +41,8 @@ describe('createExtensionTester', () => { const defaultDefinition = { namespace: 'test', attachTo: { id: 'ignored', input: 'ignored' }, - output: { element: coreExtensionData.reactElement }, - factory: () => ({ element:
    test
    }), + output: [coreExtensionData.reactElement], + factory: () => [coreExtensionData.reactElement(
    test
    )], }; it('should render a simple extension', async () => { @@ -77,23 +77,23 @@ describe('createExtensionTester', () => { it('should render multiple extensions', async () => { const indexPageExtension = createExtension({ ...defaultDefinition, - factory: () => ({ - element: ( + factory: () => [ + coreExtensionData.reactElement(
    Index page See details -
    +
    , ), - }), + ], }); const detailsPageExtension = createExtension({ ...defaultDefinition, name: 'details', attachTo: { id: 'app/routes', input: 'routes' }, - output: { - path: coreExtensionData.routePath, - element: coreExtensionData.reactElement, - }, - factory: () => ({ path: '/details', element:
    Details page
    }), + output: [coreExtensionData.routePath, coreExtensionData.reactElement], + factory: () => [ + coreExtensionData.routePath('/details'), + coreExtensionData.reactElement(
    Details page
    ), + ], }); const tester = createExtensionTester(indexPageExtension); @@ -112,9 +112,11 @@ describe('createExtensionTester', () => { it('should accepts a custom config', async () => { const indexPageExtension = createExtension({ ...defaultDefinition, - configSchema: createSchemaFromZod(z => - z.object({ title: z.string().optional() }), - ), + config: { + schema: { + title: z => z.string().optional(), + }, + }, factory: ({ config }) => { const Component = () => { const configApi = useApi(configApiRef); @@ -127,9 +129,8 @@ describe('createExtensionTester', () => {
    ); }; - return { - element: , - }; + + return [coreExtensionData.reactElement()]; }, }); @@ -137,17 +138,18 @@ describe('createExtensionTester', () => { ...defaultDefinition, name: 'details', attachTo: { id: 'app/routes', input: 'routes' }, - configSchema: createSchemaFromZod(z => - z.object({ title: z.string().optional() }), - ), - output: { - path: coreExtensionData.routePath, - element: coreExtensionData.reactElement, + config: { + schema: { + title: z => z.string().optional(), + }, }, - factory: ({ config }) => ({ - path: '/details', - element:
    {config.title ?? 'Details page'}
    , - }), + output: [coreExtensionData.routePath, coreExtensionData.reactElement], + factory: ({ config }) => [ + coreExtensionData.routePath('/details'), + coreExtensionData.reactElement( +
    {config.title ?? 'Details page'}
    , + ), + ], }); const tester = createExtensionTester(indexPageExtension, { @@ -209,9 +211,7 @@ describe('createExtensionTester', () => { ); }; - return { - element: , - }; + return [coreExtensionData.reactElement()]; }, }); @@ -254,16 +254,16 @@ describe('createExtensionTester', () => { namespace: 'test', name: 'e1', attachTo: { id: 'ignored', input: 'ignored' }, - output: { text: stringDataRef }, - factory: () => ({ text: 'test-text' }), + output: [stringDataRef], + factory: () => [stringDataRef('test-text')], }); const extension2 = createExtension({ namespace: 'test', name: 'e2', attachTo: { id: 'ignored', input: 'ignored' }, - output: { text: stringDataRef }, - factory: () => ({ text: 'test-text' }), + output: [stringDataRef], + factory: () => [stringDataRef('test-text')], }); const tester = createExtensionTester(extension); @@ -278,16 +278,16 @@ describe('createExtensionTester', () => { namespace: 'test', name: 'e1', attachTo: { id: 'ignored', input: 'ignored' }, - output: { text: stringDataRef }, - factory: () => ({ text: 'test-text' }), + output: [stringDataRef], + factory: () => [stringDataRef('test-text')], }); const extension2 = createExtension({ namespace: 'test', name: 'e2', attachTo: { id: 'ignored', input: 'ignored' }, - output: { text: stringDataRef }, - factory: () => ({ text: 'test-text' }), + output: [stringDataRef], + factory: () => [stringDataRef('test-text')], }); const tester = createExtensionTester(extension).add(extension2); @@ -377,26 +377,21 @@ describe('createExtensionTester', () => { namespace: 'test', name: 'e1', attachTo: { id: 'ignored', input: 'ignored' }, - output: { text: stringDataRef }, + output: [stringDataRef], inputs: { - input: createExtensionInput( - { - output: stringDataRef, - }, - { singleton: true }, - ), + input: createExtensionInput([stringDataRef], { singleton: true }), }, - factory: ({ inputs }) => ({ - text: `nest-${inputs.input.output.output}`, - }), + factory: ({ inputs }) => [ + stringDataRef(`nest-${inputs.input.get(stringDataRef)}`), + ], }); const extension2 = createExtension({ namespace: 'test', name: 'e2', attachTo: { id: 'test/e1', input: 'blob' }, - output: { text: stringDataRef }, - factory: () => ({ text: 'test-text' }), + output: [stringDataRef], + factory: () => [stringDataRef('test-text')], }); const tester = createExtensionTester(extension).add(extension2); @@ -418,18 +413,13 @@ describe('createExtensionTester', () => { namespace: 'test', name: 'e1', attachTo: { id: 'ignored', input: 'ignored' }, - output: { text: stringDataRef }, + output: [stringDataRef], inputs: { - input: createExtensionInput( - { - output: stringDataRef, - }, - { singleton: true }, - ), + input: createExtensionInput([stringDataRef], { singleton: true }), }, - factory: ({ inputs }) => ({ - text: `nest-${inputs.input.output.output}`, - }), + factory: ({ inputs }) => [ + stringDataRef(`nest-${inputs.input.get(stringDataRef)}`), + ], }); const tester = createExtensionTester(extension, { diff --git a/packages/frontend-test-utils/src/app/renderInTestApp.tsx b/packages/frontend-test-utils/src/app/renderInTestApp.tsx index dd03cdd2a2..b37a7c2a8d 100644 --- a/packages/frontend-test-utils/src/app/renderInTestApp.tsx +++ b/packages/frontend-test-utils/src/app/renderInTestApp.tsx @@ -152,14 +152,16 @@ export function renderInTestApp( kind: 'test-route', name: path, attachTo: { id: 'app/root', input: 'elements' }, - output: { - element: coreExtensionData.reactElement, - path: coreExtensionData.routePath, - routeRef: coreExtensionData.routeRef, - }, - factory() { - return { element: , path, routeRef }; - }, + output: [ + coreExtensionData.reactElement, + coreExtensionData.routePath, + coreExtensionData.routeRef, + ], + factory: () => [ + coreExtensionData.reactElement(), + coreExtensionData.routePath(path), + coreExtensionData.routeRef(routeRef), + ], }), ); } From 7ba66a38cbf2d705c15c2fc3b52f6a65671ad635 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 15 Aug 2024 09:57:57 +0200 Subject: [PATCH 354/372] chore: some other deprecations Signed-off-by: blam --- .../app-next-example-plugin/src/plugin.tsx | 10 +- plugins/api-docs/src/alpha.tsx | 300 ++++++++++-------- plugins/home/src/alpha.tsx | 39 +-- plugins/kubernetes/src/alpha/pages.tsx | 18 +- 4 files changed, 199 insertions(+), 168 deletions(-) diff --git a/packages/app-next-example-plugin/src/plugin.tsx b/packages/app-next-example-plugin/src/plugin.tsx index 7c41405c59..818e8abc84 100644 --- a/packages/app-next-example-plugin/src/plugin.tsx +++ b/packages/app-next-example-plugin/src/plugin.tsx @@ -16,13 +16,15 @@ import React from 'react'; import { - createPageExtension, + PageBlueprint, createFrontendPlugin, } from '@backstage/frontend-plugin-api'; -export const ExamplePage = createPageExtension({ - defaultPath: '/example', - loader: () => import('./Component').then(m => ), +export const ExamplePage = PageBlueprint.make({ + params: { + defaultPath: '/example', + loader: () => import('./Component').then(m => ), + }, }); /** @public */ diff --git a/plugins/api-docs/src/alpha.tsx b/plugins/api-docs/src/alpha.tsx index 4d803b3991..216666be8f 100644 --- a/plugins/api-docs/src/alpha.tsx +++ b/plugins/api-docs/src/alpha.tsx @@ -18,12 +18,11 @@ import React from 'react'; import Grid from '@material-ui/core/Grid'; import { - createApiExtension, + ApiBlueprint, + NavItemBlueprint, + PageBlueprint, createApiFactory, - createNavItemExtension, - createPageExtension, createFrontendPlugin, - createSchemaFromZod, } from '@backstage/frontend-plugin-api'; import { @@ -31,10 +30,6 @@ import { convertLegacyRouteRef, } from '@backstage/core-compat-api'; -import { - createEntityCardExtension, - createEntityContentExtension, -} from '@backstage/plugin-catalog-react/alpha'; import { ApiEntity, parseEntityRef, @@ -46,161 +41,190 @@ import { rootRoute, registerComponentRouteRef } from './routes'; import { apiDocsConfigRef } from './config'; import { AppIcon } from '@backstage/core-components'; -const apiDocsNavItem = createNavItemExtension({ - title: 'APIs', - routeRef: convertLegacyRouteRef(rootRoute), - icon: () => compatWrapper(), -}); +import { + EntityCardBlueprint, + EntityContentBlueprint, +} from '@backstage/plugin-catalog-react/alpha'; -const apiDocsConfigApi = createApiExtension({ - factory: createApiFactory({ - api: apiDocsConfigRef, - deps: {}, - factory: () => { - const definitionWidgets = defaultDefinitionWidgets(); - return { - getApiDefinitionWidget: (apiEntity: ApiEntity) => { - return definitionWidgets.find(d => d.type === apiEntity.spec.type); - }, - }; - }, - }), -}); - -const apiDocsExplorerPage = createPageExtension({ - defaultPath: '/api-docs', - routeRef: convertLegacyRouteRef(rootRoute), - // Mapping DefaultApiExplorerPageProps to config - configSchema: createSchemaFromZod(z => - z.object({ - path: z.string().default('/api-docs'), - initiallySelectedFilter: z.enum(['owned', 'starred', 'all']).optional(), - // Ommiting columns and actions for now as their types are too complex to map to zod - }), - ), - loader: ({ config }) => - import('./components/ApiExplorerPage').then(m => - compatWrapper( - , - ), - ), -}); - -const apiDocsHasApisEntityCard = createEntityCardExtension({ - name: 'has-apis', - // Ommiting configSchema for now - // We are skipping variants and columns are too complex to map to zod - // See: https://github.com/backstage/backstage/pull/22619#discussion_r1477333252 - filter: entity => { - return ( - entity.kind === 'Component' && - entity.relations?.some( - ({ type, targetRef }) => - type.toLocaleLowerCase('en-US') === RELATION_HAS_PART && - parseEntityRef(targetRef).kind === 'API', - )!! - ); +const apiDocsNavItem = NavItemBlueprint.make({ + params: { + title: 'APIs', + routeRef: convertLegacyRouteRef(rootRoute), + icon: () => compatWrapper(), }, - loader: () => - import('./components/ApisCards').then(m => - compatWrapper(), - ), }); -const apiDocsDefinitionEntityCard = createEntityCardExtension({ +const apiDocsConfigApi = ApiBlueprint.make({ + namespace: 'api-docs', + params: { + factory: createApiFactory({ + api: apiDocsConfigRef, + deps: {}, + factory: () => { + const definitionWidgets = defaultDefinitionWidgets(); + return { + getApiDefinitionWidget: (apiEntity: ApiEntity) => { + return definitionWidgets.find(d => d.type === apiEntity.spec.type); + }, + }; + }, + }), + }, +}); + +const apiDocsExplorerPage = PageBlueprint.makeWithOverrides({ + config: { + schema: { + // Ommiting columns and actions for now as their types are too complex to map to zod + initiallySelectedFilter: z => + z.enum(['owned', 'starred', 'all']).optional(), + }, + }, + factory(originalFactory, { config }) { + return originalFactory({ + defaultPath: '/api-docs', + routeRef: convertLegacyRouteRef(rootRoute), + loader: () => + import('./components/ApiExplorerPage').then(m => + compatWrapper( + , + ), + ), + }); + }, +}); + +const apiDocsHasApisEntityCard = EntityCardBlueprint.make({ + name: 'has-apis', + params: { + // Ommiting configSchema for now + // We are skipping variants and columns are too complex to map to zod + // See: https://github.com/backstage/backstage/pull/22619#discussion_r1477333252 + filter: entity => { + return ( + entity.kind === 'Component' && + entity.relations?.some( + ({ type, targetRef }) => + type.toLocaleLowerCase('en-US') === RELATION_HAS_PART && + parseEntityRef(targetRef).kind === 'API', + )!! + ); + }, + loader: () => + import('./components/ApisCards').then(m => + compatWrapper(), + ), + }, +}); + +const apiDocsDefinitionEntityCard = EntityCardBlueprint.make({ name: 'definition', - filter: 'kind:api', - loader: () => - import('./components/ApiDefinitionCard').then(m => - compatWrapper(), - ), + params: { + filter: 'kind:api', + loader: () => + import('./components/ApiDefinitionCard').then(m => + compatWrapper(), + ), + }, }); -const apiDocsConsumedApisEntityCard = createEntityCardExtension({ +const apiDocsConsumedApisEntityCard = EntityCardBlueprint.make({ name: 'consumed-apis', - // Ommiting configSchema for now - // We are skipping variants and columns are too complex to map to zod - // See: https://github.com/backstage/backstage/pull/22619#discussion_r1477333252 - filter: 'kind:component', - loader: () => - import('./components/ApisCards').then(m => - compatWrapper(), - ), + params: { + // Ommiting configSchema for now + // We are skipping variants and columns are too complex to map to zod + // See: https://github.com/backstage/backstage/pull/22619#discussion_r1477333252 + filter: 'kind:component', + loader: () => + import('./components/ApisCards').then(m => + compatWrapper(), + ), + }, }); -const apiDocsProvidedApisEntityCard = createEntityCardExtension({ +const apiDocsProvidedApisEntityCard = EntityCardBlueprint.make({ name: 'provided-apis', - // Ommiting configSchema for now - // We are skipping variants and columns are too complex to map to zod - // See: https://github.com/backstage/backstage/pull/22619#discussion_r1477333252 - filter: 'kind:component', - loader: () => - import('./components/ApisCards').then(m => - compatWrapper(), - ), + params: { + // Ommiting configSchema for now + // We are skipping variants and columns are too complex to map to zod + // See: https://github.com/backstage/backstage/pull/22619#discussion_r1477333252 + filter: 'kind:component', + loader: () => + import('./components/ApisCards').then(m => + compatWrapper(), + ), + }, }); -const apiDocsConsumingComponentsEntityCard = createEntityCardExtension({ +const apiDocsConsumingComponentsEntityCard = EntityCardBlueprint.make({ name: 'consuming-components', - // Ommiting configSchema for now - // We are skipping variants - // See: https://github.com/backstage/backstage/pull/22619#discussion_r1477333252 - filter: 'kind:api', - loader: () => - import('./components/ComponentsCards').then(m => - compatWrapper(), - ), + params: { + // Ommiting configSchema for now + // We are skipping variants + // See: https://github.com/backstage/backstage/pull/22619#discussion_r1477333252 + filter: 'kind:api', + loader: () => + import('./components/ComponentsCards').then(m => + compatWrapper(), + ), + }, }); -const apiDocsProvidingComponentsEntityCard = createEntityCardExtension({ +const apiDocsProvidingComponentsEntityCard = EntityCardBlueprint.make({ name: 'providing-components', - // Ommiting configSchema for now - // We are skipping variants - // See: https://github.com/backstage/backstage/pull/22619#discussion_r1477333252 - filter: 'kind:api', - loader: () => - import('./components/ComponentsCards').then(m => - compatWrapper(), - ), + params: { + // Ommiting configSchema for now + // We are skipping variants + // See: https://github.com/backstage/backstage/pull/22619#discussion_r1477333252 + filter: 'kind:api', + loader: () => + import('./components/ComponentsCards').then(m => + compatWrapper(), + ), + }, }); -const apiDocsDefinitionEntityContent = createEntityContentExtension({ +const apiDocsDefinitionEntityContent = EntityContentBlueprint.make({ name: 'definition', - defaultPath: '/defintion', - defaultTitle: 'Definition', - filter: 'kind:api', - loader: async () => - import('./components/ApiDefinitionCard').then(m => - compatWrapper( - - - - - , + params: { + defaultPath: '/defintion', + defaultTitle: 'Definition', + filter: 'kind:api', + loader: async () => + import('./components/ApiDefinitionCard').then(m => + compatWrapper( + + + + + , + ), ), - ), + }, }); -const apiDocsApisEntityContent = createEntityContentExtension({ +const apiDocsApisEntityContent = EntityContentBlueprint.make({ name: 'apis', - defaultPath: '/apis', - defaultTitle: 'APIs', - filter: 'kind:component', - loader: async () => - import('./components/ApisCards').then(m => - compatWrapper( - - - - - - - - , + params: { + defaultPath: '/apis', + defaultTitle: 'APIs', + filter: 'kind:component', + loader: async () => + import('./components/ApisCards').then(m => + compatWrapper( + + + + + + + + , + ), ), - ), + }, }); export default createFrontendPlugin({ diff --git a/plugins/home/src/alpha.tsx b/plugins/home/src/alpha.tsx index e31fe833f6..ce96b18943 100644 --- a/plugins/home/src/alpha.tsx +++ b/plugins/home/src/alpha.tsx @@ -20,7 +20,7 @@ import { coreExtensionData, createExtensionDataRef, createExtensionInput, - createPageExtension, + PageBlueprint, createFrontendPlugin, createRouteRef, } from '@backstage/frontend-plugin-api'; @@ -35,31 +35,34 @@ export const titleExtensionDataRef = createExtensionDataRef().with({ id: 'title', }); -const homePage = createPageExtension({ - defaultPath: '/home', - routeRef: rootRouteRef, +const homePage = PageBlueprint.makeWithOverrides({ inputs: { props: createExtensionInput( - { - children: coreExtensionData.reactElement.optional(), - title: titleExtensionDataRef.optional(), - }, - + [ + coreExtensionData.reactElement.optional(), + titleExtensionDataRef.optional(), + ], { singleton: true, optional: true, }, ), }, - loader: ({ inputs }) => - import('./components/').then(m => - compatWrapper( - , - ), - ), + factory: (originalFactory, { inputs }) => { + return originalFactory({ + defaultPath: '/home', + routeRef: rootRouteRef, + loader: () => + import('./components/').then(m => + compatWrapper( + , + ), + ), + }); + }, }); /** diff --git a/plugins/kubernetes/src/alpha/pages.tsx b/plugins/kubernetes/src/alpha/pages.tsx index 8b5db150bd..a58ffec94f 100644 --- a/plugins/kubernetes/src/alpha/pages.tsx +++ b/plugins/kubernetes/src/alpha/pages.tsx @@ -16,18 +16,20 @@ import React from 'react'; // Add this line to import React -import { createPageExtension } from '@backstage/frontend-plugin-api'; +import { PageBlueprint } from '@backstage/frontend-plugin-api'; import { compatWrapper, convertLegacyRouteRef, } from '@backstage/core-compat-api'; import { rootCatalogKubernetesRouteRef } from '../plugin'; -export const kubernetesPage = createPageExtension({ - defaultPath: '/kubernetes', - // you can reuse the existing routeRef - // by wrapping into the convertLegacyRouteRef. - routeRef: convertLegacyRouteRef(rootCatalogKubernetesRouteRef), - // these inputs usually match the props required by the component. - loader: () => import('../Router').then(m => compatWrapper()), +export const kubernetesPage = PageBlueprint.make({ + params: { + defaultPath: '/kubernetes', + // you can reuse the existing routeRef + // by wrapping into the convertLegacyRouteRef. + routeRef: convertLegacyRouteRef(rootCatalogKubernetesRouteRef), + // these inputs usually match the props required by the component. + loader: () => import('../Router').then(m => compatWrapper()), + }, }); From 71519b2ddc997af03a626b3ad9fc6dc400b23e9b Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 15 Aug 2024 10:17:55 +0200 Subject: [PATCH 355/372] chore: fix typescript Signed-off-by: blam --- packages/core-compat-api/src/collectLegacyRoutes.tsx | 2 -- .../frontend-test-utils/src/app/createExtensionTester.test.tsx | 1 - 2 files changed, 3 deletions(-) diff --git a/packages/core-compat-api/src/collectLegacyRoutes.tsx b/packages/core-compat-api/src/collectLegacyRoutes.tsx index 68e9aaf3a1..9cc23b8c29 100644 --- a/packages/core-compat-api/src/collectLegacyRoutes.tsx +++ b/packages/core-compat-api/src/collectLegacyRoutes.tsx @@ -24,10 +24,8 @@ import { BackstagePlugin, ExtensionDefinition, coreExtensionData, - createApiExtension, createExtension, createExtensionInput, - createPageExtension, createFrontendPlugin, ApiBlueprint, PageBlueprint, diff --git a/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx b/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx index 86953df675..5102649059 100644 --- a/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx +++ b/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx @@ -26,7 +26,6 @@ import { createExtension, createExtensionDataRef, createExtensionInput, - createSchemaFromZod, useAnalytics, useApi, } from '@backstage/frontend-plugin-api'; From 549d5502ccd30eda816986d87acf961698b023a9 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 15 Aug 2024 10:38:45 +0200 Subject: [PATCH 356/372] chore: updating api-reports Signed-off-by: blam --- .../app-next-example-plugin/api-report.md | 36 +- plugins/api-docs/api-report-alpha.md | 349 +++++++++++++++++- plugins/home/api-report-alpha.md | 62 +++- plugins/kubernetes/api-report-alpha.md | 30 +- 4 files changed, 473 insertions(+), 4 deletions(-) diff --git a/packages/app-next-example-plugin/api-report.md b/packages/app-next-example-plugin/api-report.md index 962b1473a8..3c8b740e1c 100644 --- a/packages/app-next-example-plugin/api-report.md +++ b/packages/app-next-example-plugin/api-report.md @@ -3,11 +3,45 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts +import { AnyRouteRefParams } from '@backstage/frontend-plugin-api'; import { BackstagePlugin } from '@backstage/frontend-plugin-api'; +import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api'; +import { ExtensionDefinition } from '@backstage/frontend-plugin-api'; import { default as React_2 } from 'react'; +import { RouteRef } from '@backstage/frontend-plugin-api'; // @public (undocumented) -const examplePlugin: BackstagePlugin<{}, {}, {}>; +const examplePlugin: BackstagePlugin< + {}, + {}, + { + 'page:example': ExtensionDefinition< + { + path: string | undefined; + }, + { + path?: string | undefined; + }, + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + > + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + RouteRef, + 'core.routing.ref', + { + optional: true; + } + >, + {}, + 'page', + undefined, + undefined + >; + } +>; export default examplePlugin; // @public (undocumented) diff --git a/plugins/api-docs/api-report-alpha.md b/plugins/api-docs/api-report-alpha.md index 6003056cb3..1732f06ff6 100644 --- a/plugins/api-docs/api-report-alpha.md +++ b/plugins/api-docs/api-report-alpha.md @@ -3,8 +3,17 @@ > 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 { AnyExtensionDataRef } from '@backstage/frontend-plugin-api'; +import { AnyRouteRefParams } from '@backstage/frontend-plugin-api'; import { BackstagePlugin } from '@backstage/frontend-plugin-api'; +import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api'; +import { Entity } from '@backstage/catalog-model'; +import { ExtensionDefinition } from '@backstage/frontend-plugin-api'; +import { ExtensionInput } from '@backstage/frontend-plugin-api'; import { ExternalRouteRef } from '@backstage/frontend-plugin-api'; +import { IconComponent } from '@backstage/core-plugin-api'; +import { default as React_2 } from 'react'; import { RouteRef } from '@backstage/frontend-plugin-api'; // @public (undocumented) @@ -15,7 +24,345 @@ const _default: BackstagePlugin< { registerApi: ExternalRouteRef; }, - {} + { + 'nav-item:api-docs': ExtensionDefinition< + {}, + {}, + ConfigurableExtensionDataRef< + { + title: string; + icon: IconComponent; + routeRef: RouteRef; + }, + 'core.nav-item.target', + {} + >, + {}, + 'nav-item', + undefined, + undefined + >; + 'api:api-docs': ExtensionDefinition< + {}, + {}, + ConfigurableExtensionDataRef, + {}, + 'api', + 'api-docs', + undefined + >; + 'page:api-docs': ExtensionDefinition< + { + initiallySelectedFilter: 'all' | 'owned' | 'starred' | undefined; + } & { + path: string | undefined; + }, + { + initiallySelectedFilter?: 'all' | 'owned' | 'starred' | undefined; + } & { + path?: string | undefined; + }, + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + > + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + RouteRef, + 'core.routing.ref', + { + optional: true; + } + >, + { + [x: string]: ExtensionInput< + AnyExtensionDataRef, + { + optional: boolean; + singleton: boolean; + } + >; + }, + 'page', + undefined, + undefined + >; + 'entity-card:api-docs/has-apis': ExtensionDefinition< + { + filter: string | undefined; + }, + { + filter?: string | undefined; + }, + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + > + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + { + optional: true; + } + >, + {}, + 'entity-card', + undefined, + 'has-apis' + >; + 'entity-card:api-docs/definition': ExtensionDefinition< + { + filter: string | undefined; + }, + { + filter?: string | undefined; + }, + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + > + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + { + optional: true; + } + >, + {}, + 'entity-card', + undefined, + 'definition' + >; + 'entity-card:api-docs/consumed-apis': ExtensionDefinition< + { + filter: string | undefined; + }, + { + filter?: string | undefined; + }, + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + > + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + { + optional: true; + } + >, + {}, + 'entity-card', + undefined, + 'consumed-apis' + >; + 'entity-card:api-docs/provided-apis': ExtensionDefinition< + { + filter: string | undefined; + }, + { + filter?: string | undefined; + }, + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + > + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + { + optional: true; + } + >, + {}, + 'entity-card', + undefined, + 'provided-apis' + >; + 'entity-card:api-docs/consuming-components': ExtensionDefinition< + { + filter: string | undefined; + }, + { + filter?: string | undefined; + }, + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + > + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + { + optional: true; + } + >, + {}, + 'entity-card', + undefined, + 'consuming-components' + >; + 'entity-card:api-docs/providing-components': ExtensionDefinition< + { + filter: string | undefined; + }, + { + filter?: string | undefined; + }, + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + > + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + { + optional: true; + } + >, + {}, + 'entity-card', + undefined, + 'providing-components' + >; + 'entity-content:api-docs/definition': ExtensionDefinition< + { + path: string | undefined; + title: string | undefined; + filter: string | undefined; + }, + { + filter?: string | undefined; + title?: string | undefined; + path?: string | undefined; + }, + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + > + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + RouteRef, + 'core.routing.ref', + { + optional: true; + } + > + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + { + optional: true; + } + >, + {}, + 'entity-content', + undefined, + 'definition' + >; + 'entity-content:api-docs/apis': ExtensionDefinition< + { + path: string | undefined; + title: string | undefined; + filter: string | undefined; + }, + { + filter?: string | undefined; + title?: string | undefined; + path?: string | undefined; + }, + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + > + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + RouteRef, + 'core.routing.ref', + { + optional: true; + } + > + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + { + optional: true; + } + >, + {}, + 'entity-content', + undefined, + 'apis' + >; + } >; export default _default; diff --git a/plugins/home/api-report-alpha.md b/plugins/home/api-report-alpha.md index 0f9b980a78..2efdc19b79 100644 --- a/plugins/home/api-report-alpha.md +++ b/plugins/home/api-report-alpha.md @@ -3,11 +3,71 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts +import { AnyRouteRefParams } from '@backstage/frontend-plugin-api'; import { BackstagePlugin } from '@backstage/frontend-plugin-api'; import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api'; +import { ExtensionDefinition } from '@backstage/frontend-plugin-api'; +import { ExtensionInput } from '@backstage/frontend-plugin-api'; +import { default as React_2 } from 'react'; +import { RouteRef } from '@backstage/frontend-plugin-api'; // @alpha (undocumented) -const _default: BackstagePlugin<{}, {}, {}>; +const _default: BackstagePlugin< + {}, + {}, + { + 'page:home': ExtensionDefinition< + { + [x: string]: any; + } & { + path: string | undefined; + }, + { + [x: string]: any; + } & { + path?: string | undefined; + }, + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + > + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + RouteRef, + 'core.routing.ref', + { + optional: true; + } + >, + { + props: ExtensionInput< + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'title', + { + optional: true; + } + >, + { + singleton: true; + optional: true; + } + >; + }, + 'page', + undefined, + undefined + >; + } +>; export default _default; // @alpha (undocumented) diff --git a/plugins/kubernetes/api-report-alpha.md b/plugins/kubernetes/api-report-alpha.md index befbcf379a..f3260208c3 100644 --- a/plugins/kubernetes/api-report-alpha.md +++ b/plugins/kubernetes/api-report-alpha.md @@ -3,7 +3,13 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts +/// + +import { AnyRouteRefParams } from '@backstage/frontend-plugin-api'; import { BackstagePlugin } from '@backstage/frontend-plugin-api'; +import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api'; +import { ExtensionDefinition } from '@backstage/frontend-plugin-api'; +import { JSX as JSX_2 } from 'react'; import { RouteRef } from '@backstage/frontend-plugin-api'; // @public (undocumented) @@ -12,7 +18,29 @@ const _default: BackstagePlugin< kubernetes: RouteRef; }, {}, - {} + { + 'page:kubernetes': ExtensionDefinition< + { + path: string | undefined; + }, + { + path?: string | undefined; + }, + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + RouteRef, + 'core.routing.ref', + { + optional: true; + } + >, + {}, + 'page', + undefined, + undefined + >; + } >; export default _default; From a737904cac906469ef20b0cfc8d160599aa94c21 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 15 Aug 2024 11:36:19 +0200 Subject: [PATCH 357/372] chore: fix tests Signed-off-by: blam --- .../src/routing/extractRouteInfoFromAppNode.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/frontend-app-api/src/routing/extractRouteInfoFromAppNode.test.ts b/packages/frontend-app-api/src/routing/extractRouteInfoFromAppNode.test.ts index 8a54f3e73e..1fc899a906 100644 --- a/packages/frontend-app-api/src/routing/extractRouteInfoFromAppNode.test.ts +++ b/packages/frontend-app-api/src/routing/extractRouteInfoFromAppNode.test.ts @@ -59,10 +59,11 @@ function createTestExtension(options: { children: createExtensionInput([coreExtensionData.reactElement]), }, *factory() { - if (options.path) { + if (options.path !== undefined) { yield coreExtensionData.routePath(options.path); } - if (options.routeRef) { + + if (options.routeRef !== undefined) { yield coreExtensionData.routeRef(options.routeRef); } From 89859bc83d8cf745ddbe89001222ee08e5010826 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 15 Aug 2024 14:16:18 +0200 Subject: [PATCH 358/372] chore: fixing api-docs naming Signed-off-by: blam Signed-off-by: blam --- plugins/api-docs/src/alpha.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/api-docs/src/alpha.tsx b/plugins/api-docs/src/alpha.tsx index 216666be8f..b38bfc6c91 100644 --- a/plugins/api-docs/src/alpha.tsx +++ b/plugins/api-docs/src/alpha.tsx @@ -55,7 +55,7 @@ const apiDocsNavItem = NavItemBlueprint.make({ }); const apiDocsConfigApi = ApiBlueprint.make({ - namespace: 'api-docs', + name: 'config', params: { factory: createApiFactory({ api: apiDocsConfigRef, From fe1fbb26ebbdfa780e3b1139e11f40123d4c0db8 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 15 Aug 2024 14:36:08 +0200 Subject: [PATCH 359/372] chore: add changeset Signed-off-by: blam --- .changeset/modern-brooms-grow.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .changeset/modern-brooms-grow.md diff --git a/.changeset/modern-brooms-grow.md b/.changeset/modern-brooms-grow.md new file mode 100644 index 0000000000..0aff21dcca --- /dev/null +++ b/.changeset/modern-brooms-grow.md @@ -0,0 +1,10 @@ +--- +'@backstage/core-compat-api': patch +'@backstage/frontend-app-api': patch +'@backstage/frontend-test-utils': patch +'@backstage/plugin-api-docs': patch +'@backstage/plugin-home': patch +'@backstage/plugin-kubernetes': patch +--- + +Migrating usages of the deprecated `createExtension` `v1` format to the newer `v2` format, and old `create*Extension` extension creators to blueprints. From 384b7bac2eae4bcf22e879ce2f4de6d5f6ef364a Mon Sep 17 00:00:00 2001 From: Andre Wanlin Date: Thu, 15 Aug 2024 07:52:34 -0500 Subject: [PATCH 360/372] Updated Prometheus and OpenTelemetry Guides Signed-off-by: Andre Wanlin --- contrib/docs/tutorials/prometheus-metrics.md | 3 +++ docs/tutorials/setup-opentelemetry.md | 22 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/contrib/docs/tutorials/prometheus-metrics.md b/contrib/docs/tutorials/prometheus-metrics.md index fb4366c7f7..0db97c649e 100644 --- a/contrib/docs/tutorials/prometheus-metrics.md +++ b/contrib/docs/tutorials/prometheus-metrics.md @@ -1,5 +1,8 @@ # Prometheus +> [!NOTE] +> The Prometheus metrics have been marked as deprecated and will be removed at a later point. The recommendation is to use the OpenTelemetry metrics by following the [Setup OpenTelemetry](https://backstage.io/docs/tutorials/setup-opentelemetry) documentation + ## Overview This is a small tutorial that goes over how to setup your Backstage instance to output metrics in a format that can be pulled in by Prometheus. diff --git a/docs/tutorials/setup-opentelemetry.md b/docs/tutorials/setup-opentelemetry.md index faaeab49f4..cba8ba7049 100644 --- a/docs/tutorials/setup-opentelemetry.md +++ b/docs/tutorials/setup-opentelemetry.md @@ -83,6 +83,28 @@ CMD ["node", "--require", "./instrumentation.js", "packages/backend", "--config" If you need to disable/configure some OpenTelemetry feature there are lots of [environment variables](https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/) which you can tweak. +### Available Metrics + +The following metrics are available: + +- `catalog_entities_count`: Total amount of entities in the catalog +- `catalog_registered_locations_count`: Total amount of registered locations in the catalog +- `catalog_relations_count`: Total amount of relations between entities +- `catalog.processed.entities.count`: Amount of entities processed +- `catalog.processing.duration`: Time spent executing the full processing flow +- `catalog.processors.duration`: Time spent executing catalog processors +- `catalog.processing.queue.delay`: The amount of delay between being scheduled for processing, and the start of actually being processed +- `catalog.stitched.entities.count`: Amount of entities stitched +- `catalog.stitching.duration`: Time spent executing the full stitching flow +- `catalog.stitching.queue.length`: Number of entities currently in the stitching queue +- `catalog.stitching.queue.delay`: The amount of delay between being scheduled for stitching, and the start of actually being stitched +- `scaffolder.task.count`: Count of task runs +- `scaffolder.task.duration`: Duration of a task run +- `scaffolder.step.count`: Count of step runs +- `scaffolder.step.duration`: Duration of a step runs +- `backend_tasks.task.runs.count`: Total number of times a task has been run +- `backend_tasks.task.runs.duration`: Histogram of task run durations + ## References - [Getting started with OpenTelemetry Node.js](https://opentelemetry.io/docs/instrumentation/js/getting-started/nodejs/) From 5eed3b15e3df0615e93c6d751d84f813cc9f5ff5 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 15 Aug 2024 15:19:10 +0200 Subject: [PATCH 361/372] chore: small changes Signed-off-by: blam --- packages/core-compat-api/src/collectLegacyRoutes.tsx | 2 +- .../src/routing/extractRouteInfoFromAppNode.test.ts | 2 +- .../frontend-test-utils/src/app/createExtensionTester.test.tsx | 3 --- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/core-compat-api/src/collectLegacyRoutes.tsx b/packages/core-compat-api/src/collectLegacyRoutes.tsx index 9cc23b8c29..c5cb13b6e1 100644 --- a/packages/core-compat-api/src/collectLegacyRoutes.tsx +++ b/packages/core-compat-api/src/collectLegacyRoutes.tsx @@ -90,7 +90,7 @@ function makeRoutingShimExtension(options: { coreExtensionData.routeRef.optional(), ], *factory() { - if (routePath) { + if (routePath !== undefined) { yield coreExtensionData.routePath(routePath); } diff --git a/packages/frontend-app-api/src/routing/extractRouteInfoFromAppNode.test.ts b/packages/frontend-app-api/src/routing/extractRouteInfoFromAppNode.test.ts index 1fc899a906..51d26ec51b 100644 --- a/packages/frontend-app-api/src/routing/extractRouteInfoFromAppNode.test.ts +++ b/packages/frontend-app-api/src/routing/extractRouteInfoFromAppNode.test.ts @@ -63,7 +63,7 @@ function createTestExtension(options: { yield coreExtensionData.routePath(options.path); } - if (options.routeRef !== undefined) { + if (options.routeRef) { yield coreExtensionData.routeRef(options.routeRef); } diff --git a/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx b/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx index 5102649059..14ffd05ada 100644 --- a/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx +++ b/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx @@ -395,9 +395,7 @@ describe('createExtensionTester', () => { const tester = createExtensionTester(extension).add(extension2); - // @ts-expect-error expect(tester.query(extension).get(stringDataRef)).toBe('nest-test-text'); - // @ts-expect-error expect(tester.query(extension2).get(stringDataRef)).toBe('test-text'); // @ts-expect-error expect(tester.query(extension).input('input').data(stringDataRef)).toBe( @@ -426,7 +424,6 @@ describe('createExtensionTester', () => { inputs: { input: 'test-text' }, }); - // @ts-expect-error expect(tester.query(extension).get(stringDataRef)).toBe('nest-test-text'); }); }); From 80769d9f0c97b2db25ef302fcd95ce74e44276e2 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 15 Aug 2024 15:31:24 +0200 Subject: [PATCH 362/372] chore: fix alpha api reports Signed-off-by: blam --- plugins/api-docs/api-report-alpha.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/api-docs/api-report-alpha.md b/plugins/api-docs/api-report-alpha.md index 1732f06ff6..e0831b2d98 100644 --- a/plugins/api-docs/api-report-alpha.md +++ b/plugins/api-docs/api-report-alpha.md @@ -42,14 +42,14 @@ const _default: BackstagePlugin< undefined, undefined >; - 'api:api-docs': ExtensionDefinition< + 'api:api-docs/config': ExtensionDefinition< {}, {}, ConfigurableExtensionDataRef, {}, 'api', - 'api-docs', - undefined + undefined, + 'config' >; 'page:api-docs': ExtensionDefinition< { From 8cb9a85596a5417a004811ffa429527b17ce9b72 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 15 Aug 2024 15:21:03 +0200 Subject: [PATCH 363/372] chore: migrate rest of catalogt Signed-off-by: blam --- plugins/catalog/src/alpha/apis.tsx | 60 ++++--- .../createHasMatcher.test.ts | 0 .../createHasMatcher.ts | 0 .../createIsMatcher.test.ts | 0 .../createIsMatcher.ts | 0 .../createKindMatcher.test.ts | 0 .../createKindMatcher.ts | 0 .../createTypeMatcher.test.ts | 0 .../createTypeMatcher.ts | 0 .../filter/{matrchers => matchers}/types.ts | 0 .../src/alpha/filter/parseFilterExpression.ts | 10 +- plugins/catalog/src/alpha/filters.tsx | 146 +++++++++++------- plugins/catalog/src/alpha/navItems.tsx | 12 +- plugins/catalog/src/alpha/pages.tsx | 108 +++++++------ .../catalog/src/alpha/searchResultItems.tsx | 16 +- 15 files changed, 204 insertions(+), 148 deletions(-) rename plugins/catalog/src/alpha/filter/{matrchers => matchers}/createHasMatcher.test.ts (100%) rename plugins/catalog/src/alpha/filter/{matrchers => matchers}/createHasMatcher.ts (100%) rename plugins/catalog/src/alpha/filter/{matrchers => matchers}/createIsMatcher.test.ts (100%) rename plugins/catalog/src/alpha/filter/{matrchers => matchers}/createIsMatcher.ts (100%) rename plugins/catalog/src/alpha/filter/{matrchers => matchers}/createKindMatcher.test.ts (100%) rename plugins/catalog/src/alpha/filter/{matrchers => matchers}/createKindMatcher.ts (100%) rename plugins/catalog/src/alpha/filter/{matrchers => matchers}/createTypeMatcher.test.ts (100%) rename plugins/catalog/src/alpha/filter/{matrchers => matchers}/createTypeMatcher.ts (100%) rename plugins/catalog/src/alpha/filter/{matrchers => matchers}/types.ts (100%) diff --git a/plugins/catalog/src/alpha/apis.tsx b/plugins/catalog/src/alpha/apis.tsx index 92880ba728..937ba118b3 100644 --- a/plugins/catalog/src/alpha/apis.tsx +++ b/plugins/catalog/src/alpha/apis.tsx @@ -21,7 +21,10 @@ import { storageApiRef, } from '@backstage/core-plugin-api'; import { CatalogClient } from '@backstage/catalog-client'; -import { createApiExtension } from '@backstage/frontend-plugin-api'; +import { + ApiBlueprint, + createApiExtension, +} from '@backstage/frontend-plugin-api'; import { catalogApiRef, entityPresentationApiRef, @@ -32,33 +35,42 @@ import { DefaultStarredEntitiesApi, } from '../apis'; -export const catalogApi = createApiExtension({ - factory: createApiFactory({ - api: catalogApiRef, - deps: { - discoveryApi: discoveryApiRef, - fetchApi: fetchApiRef, - }, - factory: ({ discoveryApi, fetchApi }) => - new CatalogClient({ discoveryApi, fetchApi }), - }), +export const catalogApi = ApiBlueprint.make({ + params: { + factory: createApiFactory({ + api: catalogApiRef, + deps: { + discoveryApi: discoveryApiRef, + fetchApi: fetchApiRef, + }, + factory: ({ discoveryApi, fetchApi }) => + new CatalogClient({ discoveryApi, fetchApi }), + }), + }, }); -export const catalogStarredEntitiesApi = createApiExtension({ - factory: createApiFactory({ - api: starredEntitiesApiRef, - deps: { storageApi: storageApiRef }, - factory: ({ storageApi }) => new DefaultStarredEntitiesApi({ storageApi }), - }), +export const catalogStarredEntitiesApi = ApiBlueprint.make({ + name: 'starred-entities', + params: { + factory: createApiFactory({ + api: starredEntitiesApiRef, + deps: { storageApi: storageApiRef }, + factory: ({ storageApi }) => + new DefaultStarredEntitiesApi({ storageApi }), + }), + }, }); -export const entityPresentationApi = createApiExtension({ - factory: createApiFactory({ - api: entityPresentationApiRef, - deps: { catalogApiImp: catalogApiRef }, - factory: ({ catalogApiImp }) => - DefaultEntityPresentationApi.create({ catalogApi: catalogApiImp }), - }), +export const entityPresentationApi = ApiBlueprint.make({ + name: 'entity-presentation', + params: { + factory: createApiFactory({ + api: entityPresentationApiRef, + deps: { catalogApiImp: catalogApiRef }, + factory: ({ catalogApiImp }) => + DefaultEntityPresentationApi.create({ catalogApi: catalogApiImp }), + }), + }, }); export default [catalogApi, catalogStarredEntitiesApi, entityPresentationApi]; diff --git a/plugins/catalog/src/alpha/filter/matrchers/createHasMatcher.test.ts b/plugins/catalog/src/alpha/filter/matchers/createHasMatcher.test.ts similarity index 100% rename from plugins/catalog/src/alpha/filter/matrchers/createHasMatcher.test.ts rename to plugins/catalog/src/alpha/filter/matchers/createHasMatcher.test.ts diff --git a/plugins/catalog/src/alpha/filter/matrchers/createHasMatcher.ts b/plugins/catalog/src/alpha/filter/matchers/createHasMatcher.ts similarity index 100% rename from plugins/catalog/src/alpha/filter/matrchers/createHasMatcher.ts rename to plugins/catalog/src/alpha/filter/matchers/createHasMatcher.ts diff --git a/plugins/catalog/src/alpha/filter/matrchers/createIsMatcher.test.ts b/plugins/catalog/src/alpha/filter/matchers/createIsMatcher.test.ts similarity index 100% rename from plugins/catalog/src/alpha/filter/matrchers/createIsMatcher.test.ts rename to plugins/catalog/src/alpha/filter/matchers/createIsMatcher.test.ts diff --git a/plugins/catalog/src/alpha/filter/matrchers/createIsMatcher.ts b/plugins/catalog/src/alpha/filter/matchers/createIsMatcher.ts similarity index 100% rename from plugins/catalog/src/alpha/filter/matrchers/createIsMatcher.ts rename to plugins/catalog/src/alpha/filter/matchers/createIsMatcher.ts diff --git a/plugins/catalog/src/alpha/filter/matrchers/createKindMatcher.test.ts b/plugins/catalog/src/alpha/filter/matchers/createKindMatcher.test.ts similarity index 100% rename from plugins/catalog/src/alpha/filter/matrchers/createKindMatcher.test.ts rename to plugins/catalog/src/alpha/filter/matchers/createKindMatcher.test.ts diff --git a/plugins/catalog/src/alpha/filter/matrchers/createKindMatcher.ts b/plugins/catalog/src/alpha/filter/matchers/createKindMatcher.ts similarity index 100% rename from plugins/catalog/src/alpha/filter/matrchers/createKindMatcher.ts rename to plugins/catalog/src/alpha/filter/matchers/createKindMatcher.ts diff --git a/plugins/catalog/src/alpha/filter/matrchers/createTypeMatcher.test.ts b/plugins/catalog/src/alpha/filter/matchers/createTypeMatcher.test.ts similarity index 100% rename from plugins/catalog/src/alpha/filter/matrchers/createTypeMatcher.test.ts rename to plugins/catalog/src/alpha/filter/matchers/createTypeMatcher.test.ts diff --git a/plugins/catalog/src/alpha/filter/matrchers/createTypeMatcher.ts b/plugins/catalog/src/alpha/filter/matchers/createTypeMatcher.ts similarity index 100% rename from plugins/catalog/src/alpha/filter/matrchers/createTypeMatcher.ts rename to plugins/catalog/src/alpha/filter/matchers/createTypeMatcher.ts diff --git a/plugins/catalog/src/alpha/filter/matrchers/types.ts b/plugins/catalog/src/alpha/filter/matchers/types.ts similarity index 100% rename from plugins/catalog/src/alpha/filter/matrchers/types.ts rename to plugins/catalog/src/alpha/filter/matchers/types.ts diff --git a/plugins/catalog/src/alpha/filter/parseFilterExpression.ts b/plugins/catalog/src/alpha/filter/parseFilterExpression.ts index a4c17cb8da..4f809690f7 100644 --- a/plugins/catalog/src/alpha/filter/parseFilterExpression.ts +++ b/plugins/catalog/src/alpha/filter/parseFilterExpression.ts @@ -16,11 +16,11 @@ import { Entity } from '@backstage/catalog-model'; import { InputError } from '@backstage/errors'; -import { EntityMatcherFn } from './matrchers/types'; -import { createKindMatcher } from './matrchers/createKindMatcher'; -import { createTypeMatcher } from './matrchers/createTypeMatcher'; -import { createIsMatcher } from './matrchers/createIsMatcher'; -import { createHasMatcher } from './matrchers/createHasMatcher'; +import { EntityMatcherFn } from './matchers/types'; +import { createKindMatcher } from './matchers/createKindMatcher'; +import { createTypeMatcher } from './matchers/createTypeMatcher'; +import { createIsMatcher } from './matchers/createIsMatcher'; +import { createHasMatcher } from './matchers/createHasMatcher'; const rootMatcherFactories: Record< string, diff --git a/plugins/catalog/src/alpha/filters.tsx b/plugins/catalog/src/alpha/filters.tsx index 62cf9a1353..f4d58e8273 100644 --- a/plugins/catalog/src/alpha/filters.tsx +++ b/plugins/catalog/src/alpha/filters.tsx @@ -15,97 +15,123 @@ */ import React from 'react'; -import { createCatalogFilterExtension } from './createCatalogFilterExtension'; import { createSchemaFromZod } from '@backstage/frontend-plugin-api'; +import { CatalogFilterBlueprint } from './blueprints'; -const catalogTagCatalogFilter = createCatalogFilterExtension({ +const catalogTagCatalogFilter = CatalogFilterBlueprint.make({ name: 'tag', - loader: async () => { - const { EntityTagPicker } = await import('@backstage/plugin-catalog-react'); - return ; + params: { + loader: async () => { + const { EntityTagPicker } = await import( + '@backstage/plugin-catalog-react' + ); + return ; + }, }, }); -const catalogKindCatalogFilter = createCatalogFilterExtension({ +const catalogKindCatalogFilter = CatalogFilterBlueprint.makeWithOverrides({ name: 'kind', - configSchema: createSchemaFromZod(z => - z.object({ - initialFilter: z.string().default('component'), - }), - ), - loader: async ({ config }) => { - const { EntityKindPicker } = await import( - '@backstage/plugin-catalog-react' - ); - return ; + config: { + schema: { + initialFilter: z => z.string().default('component'), + }, + }, + factory(originalFactory, { config }) { + return originalFactory({ + loader: async () => { + const { EntityKindPicker } = await import( + '@backstage/plugin-catalog-react' + ); + return ; + }, + }); }, }); -const catalogTypeCatalogFilter = createCatalogFilterExtension({ +const catalogTypeCatalogFilter = CatalogFilterBlueprint.make({ name: 'type', - loader: async () => { - const { EntityTypePicker } = await import( - '@backstage/plugin-catalog-react' - ); - return ; + params: { + loader: async () => { + const { EntityTypePicker } = await import( + '@backstage/plugin-catalog-react' + ); + return ; + }, }, }); -const catalogModeCatalogFilter = createCatalogFilterExtension({ +const catalogModeCatalogFilter = CatalogFilterBlueprint.makeWithOverrides({ name: 'mode', - configSchema: createSchemaFromZod(z => - z.object({ - mode: z.enum(['owners-only', 'all']).optional(), - }), - ), - loader: async ({ config }) => { - const { EntityOwnerPicker } = await import( - '@backstage/plugin-catalog-react' - ); - return ; + config: { + schema: { + mode: z => z.enum(['owners-only', 'all']).optional(), + }, + }, + factory(originalFactory, { config }) { + return originalFactory({ + loader: async () => { + const { EntityOwnerPicker } = await import( + '@backstage/plugin-catalog-react' + ); + return ; + }, + }); }, }); -const catalogNamespaceCatalogFilter = createCatalogFilterExtension({ +const catalogNamespaceCatalogFilter = CatalogFilterBlueprint.make({ name: 'namespace', - loader: async () => { - const { EntityNamespacePicker } = await import( - '@backstage/plugin-catalog-react' - ); - return ; + params: { + loader: async () => { + const { EntityNamespacePicker } = await import( + '@backstage/plugin-catalog-react' + ); + return ; + }, }, }); -const catalogLifecycleCatalogFilter = createCatalogFilterExtension({ +const catalogLifecycleCatalogFilter = CatalogFilterBlueprint.make({ name: 'lifecycle', - loader: async () => { - const { EntityLifecyclePicker } = await import( - '@backstage/plugin-catalog-react' - ); - return ; + params: { + loader: async () => { + const { EntityLifecyclePicker } = await import( + '@backstage/plugin-catalog-react' + ); + return ; + }, }, }); -const catalogProcessingStatusCatalogFilter = createCatalogFilterExtension({ +const catalogProcessingStatusCatalogFilter = CatalogFilterBlueprint.make({ name: 'processing-status', - loader: async () => { - const { EntityProcessingStatusPicker } = await import( - '@backstage/plugin-catalog-react' - ); - return ; + params: { + loader: async () => { + const { EntityProcessingStatusPicker } = await import( + '@backstage/plugin-catalog-react' + ); + return ; + }, }, }); -const catalogListCatalogFilter = createCatalogFilterExtension({ +const catalogListCatalogFilter = CatalogFilterBlueprint.makeWithOverrides({ name: 'list', - configSchema: createSchemaFromZod(z => - z.object({ - initialFilter: z.enum(['owned', 'starred', 'all']).default('owned'), - }), - ), - loader: async ({ config }) => { - const { UserListPicker } = await import('@backstage/plugin-catalog-react'); - return ; + config: { + schema: { + initialFilter: z => z.enum(['owned', 'starred', 'all']).default('owned'), + }, + }, + factory(originalFactory, { config }) { + return originalFactory({ + loader: async () => { + const { UserListPicker } = await import( + '@backstage/plugin-catalog-react' + ); + return ; + }, + }); }, }); diff --git a/plugins/catalog/src/alpha/navItems.tsx b/plugins/catalog/src/alpha/navItems.tsx index c1360cc29f..0eb4e6827e 100644 --- a/plugins/catalog/src/alpha/navItems.tsx +++ b/plugins/catalog/src/alpha/navItems.tsx @@ -16,13 +16,15 @@ import HomeIcon from '@material-ui/icons/Home'; import { convertLegacyRouteRef } from '@backstage/core-compat-api'; -import { createNavItemExtension } from '@backstage/frontend-plugin-api'; +import { NavItemBlueprint } from '@backstage/frontend-plugin-api'; import { rootRouteRef } from '../routes'; -export const catalogNavItem = createNavItemExtension({ - routeRef: convertLegacyRouteRef(rootRouteRef), - title: 'Catalog', - icon: HomeIcon, +export const catalogNavItem = NavItemBlueprint.make({ + params: { + routeRef: convertLegacyRouteRef(rootRouteRef), + title: 'Catalog', + icon: HomeIcon, + }, }); export default [catalogNavItem]; diff --git a/plugins/catalog/src/alpha/pages.tsx b/plugins/catalog/src/alpha/pages.tsx index 5c583e6a19..764acd1fe5 100644 --- a/plugins/catalog/src/alpha/pages.tsx +++ b/plugins/catalog/src/alpha/pages.tsx @@ -20,72 +20,86 @@ import { convertLegacyRouteRef, } from '@backstage/core-compat-api'; import { - createPageExtension, coreExtensionData, createExtensionInput, + PageBlueprint, } from '@backstage/frontend-plugin-api'; import { AsyncEntityProvider, entityRouteRef, } from '@backstage/plugin-catalog-react'; -import { catalogExtensionData } from '@backstage/plugin-catalog-react/alpha'; +import { EntityContentBlueprint } from '@backstage/plugin-catalog-react/alpha'; import { rootRouteRef } from '../routes'; import { useEntityFromUrl } from '../components/CatalogEntityPage/useEntityFromUrl'; import { buildFilterFn } from './filter/FilterWrapper'; -export const catalogPage = createPageExtension({ - defaultPath: '/catalog', - routeRef: convertLegacyRouteRef(rootRouteRef), +export const catalogPage = PageBlueprint.makeWithOverrides({ inputs: { - filters: createExtensionInput({ - element: coreExtensionData.reactElement, - }), + filters: createExtensionInput([coreExtensionData.reactElement]), }, - loader: async ({ inputs }) => { - const { BaseCatalogPage } = await import('../components/CatalogPage'); - const filters = inputs.filters.map(filter => filter.output.element); - return compatWrapper({filters}} />); + factory(originalFactory, { inputs }) { + return originalFactory({ + defaultPath: '/catalog', + routeRef: convertLegacyRouteRef(rootRouteRef), + loader: async () => { + const { BaseCatalogPage } = await import('../components/CatalogPage'); + const filters = inputs.filters.map(filter => + filter.get(coreExtensionData.reactElement), + ); + return compatWrapper({filters}} />); + }, + }); }, }); -export const catalogEntityPage = createPageExtension({ +export const catalogEntityPage = PageBlueprint.makeWithOverrides({ name: 'entity', - defaultPath: '/catalog/:namespace/:kind/:name', - routeRef: convertLegacyRouteRef(entityRouteRef), inputs: { - contents: createExtensionInput({ - element: coreExtensionData.reactElement, - path: coreExtensionData.routePath, - routeRef: coreExtensionData.routeRef.optional(), - title: catalogExtensionData.entityContentTitle, - filterFunction: catalogExtensionData.entityFilterFunction.optional(), - filterExpression: catalogExtensionData.entityFilterExpression.optional(), - }), + contents: createExtensionInput([ + coreExtensionData.reactElement, + coreExtensionData.routePath, + coreExtensionData.routeRef.optional(), + EntityContentBlueprint.dataRefs.title, + EntityContentBlueprint.dataRefs.filterFunction.optional(), + EntityContentBlueprint.dataRefs.filterExpression.optional(), + ]), }, - loader: async ({ inputs }) => { - const { EntityLayout } = await import('../components/EntityLayout'); - const Component = () => { - return ( - - - {inputs.contents.map(({ output }) => ( - - {output.element} - - ))} - - - ); - }; - return compatWrapper(); + factory(originalFactory, { inputs }) { + return originalFactory({ + defaultPath: '/catalog/:namespace/:kind/:name', + routeRef: convertLegacyRouteRef(entityRouteRef), + loader: async () => { + const { EntityLayout } = await import('../components/EntityLayout'); + const Component = () => { + return ( + + + {inputs.contents.map(output => { + return ( + + {output.get(coreExtensionData.reactElement)} + + ); + })} + + + ); + }; + return compatWrapper(); + }, + }); }, }); diff --git a/plugins/catalog/src/alpha/searchResultItems.tsx b/plugins/catalog/src/alpha/searchResultItems.tsx index 5233144173..8e140de637 100644 --- a/plugins/catalog/src/alpha/searchResultItems.tsx +++ b/plugins/catalog/src/alpha/searchResultItems.tsx @@ -14,14 +14,16 @@ * limitations under the License. */ -import { createSearchResultListItemExtension } from '@backstage/plugin-search-react/alpha'; +import { SearchResultListItemBlueprint } from '@backstage/plugin-search-react/alpha'; -export const catalogSearchResultListItem = createSearchResultListItemExtension({ - predicate: result => result.type === 'software-catalog', - component: () => - import('../components/CatalogSearchResultListItem').then( - m => m.CatalogSearchResultListItem, - ), +export const catalogSearchResultListItem = SearchResultListItemBlueprint.make({ + params: { + predicate: result => result.type === 'software-catalog', + component: () => + import('../components/CatalogSearchResultListItem').then( + m => m.CatalogSearchResultListItem, + ), + }, }); export default [catalogSearchResultListItem]; From 0f2a745ac3663a7c1991ef10049b2566385a50ad Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 15 Aug 2024 15:21:24 +0200 Subject: [PATCH 364/372] chore: migrate catalog-graph Signed-off-by: blam Signed-off-by: blam --- plugins/catalog-graph/src/alpha.tsx | 122 +++++++++++++--------------- 1 file changed, 56 insertions(+), 66 deletions(-) diff --git a/plugins/catalog-graph/src/alpha.tsx b/plugins/catalog-graph/src/alpha.tsx index d42d5587ae..11c845814f 100644 --- a/plugins/catalog-graph/src/alpha.tsx +++ b/plugins/catalog-graph/src/alpha.tsx @@ -16,84 +16,74 @@ import React from 'react'; import { - createPageExtension, createFrontendPlugin, - createSchemaFromZod, + PageBlueprint, } from '@backstage/frontend-plugin-api'; import { compatWrapper, convertLegacyRouteRef, } from '@backstage/core-compat-api'; -import { createEntityCardExtension } from '@backstage/plugin-catalog-react/alpha'; +import { EntityCardBlueprint } from '@backstage/plugin-catalog-react/alpha'; import { catalogGraphRouteRef, catalogEntityRouteRef } from './routes'; import { Direction } from './components'; -function getEntityGraphRelationsConfigSchema( - z: Parameters[0]>[0], -) { - // Mapping EntityRelationsGraphProps to config - // The classname and render functions are configurable only via extension overrides - return z.object({ - kinds: z.array(z.string()).optional(), - relations: z.array(z.string()).optional(), - maxDepth: z.number().optional(), - unidirectional: z.boolean().optional(), - mergeRelations: z.boolean().optional(), - direction: z.nativeEnum(Direction).optional(), - relationPairs: z.array(z.tuple([z.string(), z.string()])).optional(), - zoom: z.enum(['enabled', 'disabled', 'enable-on-click']).optional(), - curve: z.enum(['curveStepBefore', 'curveMonotoneX']).optional(), - }); -} - -const CatalogGraphEntityCard = createEntityCardExtension({ +const CatalogGraphEntityCard = EntityCardBlueprint.makeWithOverrides({ name: 'relations', - configSchema: createSchemaFromZod(z => - z - .object({ - // Filter is a config required to all entity cards - filter: z.string().optional(), - title: z.string().optional(), - height: z.number().optional(), - // Skipping a "variant" config for now, defaulting to "gridItem" in the component - // For more details, see this comment: https://github.com/backstage/backstage/pull/22619#discussion_r1477333252 - }) - .merge(getEntityGraphRelationsConfigSchema(z)), - ), - loader: async ({ config: { filter, ...props } }) => - import('./components/CatalogGraphCard').then(m => - compatWrapper(), - ), + config: { + schema: { + kinds: z => z.array(z.string()).optional(), + relations: z => z.array(z.string()).optional(), + maxDepth: z => z.number().optional(), + unidirectional: z => z.boolean().optional(), + mergeRelations: z => z.boolean().optional(), + direction: z => z.nativeEnum(Direction).optional(), + relationPairs: z => z.array(z.tuple([z.string(), z.string()])).optional(), + zoom: z => z.enum(['enabled', 'disabled', 'enable-on-click']).optional(), + curve: z => z.enum(['curveStepBefore', 'curveMonotoneX']).optional(), + // Skipping a "variant" config for now, defaulting to "gridItem" in the component + // For more details, see this comment: https://github.com/backstage/backstage/pull/22619#discussion_r1477333252 + title: z => z.string().optional(), + height: z => z.number().optional(), + }, + }, + factory(originalFactory, { config }) { + return originalFactory({ + loader: async () => + import('./components/CatalogGraphCard').then(m => + compatWrapper(), + ), + }); + }, }); -const CatalogGraphPage = createPageExtension({ - defaultPath: '/catalog-graph', - routeRef: convertLegacyRouteRef(catalogGraphRouteRef), - configSchema: createSchemaFromZod(z => - z.object({ - // Path is a default config required to all pages - path: z.string().default('/catalog-graph'), - // Mapping intialState prop to config, these are the initial filter values, as opposed to configuration of the available filter values - initialState: z - .object({ - selectedKinds: z.array(z.string()).optional(), - selectedRelations: z.array(z.string()).optional(), - rootEntityRefs: z.array(z.string()).optional(), - maxDepth: z.number().optional(), - unidirectional: z.boolean().optional(), - mergeRelations: z.boolean().optional(), - direction: z.nativeEnum(Direction).optional(), - showFilters: z.boolean().optional(), - curve: z.enum(['curveStepBefore', 'curveMonotoneX']).optional(), - }) - .merge(getEntityGraphRelationsConfigSchema(z)) - .optional(), - }), - ), - loader: ({ config: { path, ...props } }) => - import('./components/CatalogGraphPage').then(m => - compatWrapper(), - ), +const CatalogGraphPage = PageBlueprint.makeWithOverrides({ + config: { + schema: { + selectedKinds: z => z.array(z.string()).optional(), + selectedRelations: z => z.array(z.string()).optional(), + rootEntityRefs: z => z.array(z.string()).optional(), + maxDepth: z => z.number().optional(), + unidirectional: z => z.boolean().optional(), + mergeRelations: z => z.boolean().optional(), + direction: z => z.nativeEnum(Direction).optional(), + showFilters: z => z.boolean().optional(), + curve: z => z.enum(['curveStepBefore', 'curveMonotoneX']).optional(), + kinds: z => z.array(z.string()).optional(), + relations: z => z.array(z.string()).optional(), + relationPairs: z => z.array(z.tuple([z.string(), z.string()])).optional(), + zoom: z => z.enum(['enabled', 'disabled', 'enable-on-click']).optional(), + }, + }, + factory(originalFactory, { config }) { + return originalFactory({ + defaultPath: '/catalog-graph', + routeRef: convertLegacyRouteRef(catalogGraphRouteRef), + loader: () => + import('./components/CatalogGraphPage').then(m => + compatWrapper(), + ), + }); + }, }); export default createFrontendPlugin({ From 1a4df7277cfc0aaca6119f440812f52fc7b67a47 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 15 Aug 2024 15:21:41 +0200 Subject: [PATCH 365/372] chore: some more migrations Signed-off-by: blam --- plugins/scaffolder/src/alpha.tsx | 64 +++---- plugins/search/src/alpha.tsx | 290 ++++++++++++++++--------------- 2 files changed, 185 insertions(+), 169 deletions(-) diff --git a/plugins/scaffolder/src/alpha.tsx b/plugins/scaffolder/src/alpha.tsx index d1240e19e2..3136626f47 100644 --- a/plugins/scaffolder/src/alpha.tsx +++ b/plugins/scaffolder/src/alpha.tsx @@ -16,14 +16,14 @@ import React from 'react'; import { - createApiExtension, createApiFactory, - createNavItemExtension, - createPageExtension, createFrontendPlugin, discoveryApiRef, fetchApiRef, identityApiRef, + ApiBlueprint, + PageBlueprint, + NavItemBlueprint, } from '@backstage/frontend-plugin-api'; import CreateComponentIcon from '@material-ui/icons/AddCircleOutline'; import { @@ -51,36 +51,42 @@ export { type TemplateWizardPageProps, } from './next'; -const scaffolderApi = createApiExtension({ - factory: createApiFactory({ - api: scaffolderApiRef, - deps: { - discoveryApi: discoveryApiRef, - scmIntegrationsApi: scmIntegrationsApiRef, - fetchApi: fetchApiRef, - identityApi: identityApiRef, - }, - factory: ({ discoveryApi, scmIntegrationsApi, fetchApi, identityApi }) => - new ScaffolderClient({ - discoveryApi, - scmIntegrationsApi, - fetchApi, - identityApi, - }), - }), +const scaffolderApi = ApiBlueprint.make({ + params: { + factory: createApiFactory({ + api: scaffolderApiRef, + deps: { + discoveryApi: discoveryApiRef, + scmIntegrationsApi: scmIntegrationsApiRef, + fetchApi: fetchApiRef, + identityApi: identityApiRef, + }, + factory: ({ discoveryApi, scmIntegrationsApi, fetchApi, identityApi }) => + new ScaffolderClient({ + discoveryApi, + scmIntegrationsApi, + fetchApi, + identityApi, + }), + }), + }, }); -const scaffolderPage = createPageExtension({ - routeRef: convertLegacyRouteRef(rootRouteRef), - defaultPath: '/create', - loader: () => - import('./components/Router').then(m => compatWrapper()), +const scaffolderPage = PageBlueprint.make({ + params: { + routeRef: convertLegacyRouteRef(rootRouteRef), + defaultPath: '/create', + loader: () => + import('./components/Router').then(m => compatWrapper()), + }, }); -const scaffolderNavItem = createNavItemExtension({ - routeRef: convertLegacyRouteRef(rootRouteRef), - title: 'Create...', - icon: CreateComponentIcon, +const scaffolderNavItem = NavItemBlueprint.make({ + params: { + routeRef: convertLegacyRouteRef(rootRouteRef), + title: 'Create...', + icon: CreateComponentIcon, + }, }); /** @alpha */ diff --git a/plugins/search/src/alpha.tsx b/plugins/search/src/alpha.tsx index dbb98691c9..90fc394f9d 100644 --- a/plugins/search/src/alpha.tsx +++ b/plugins/search/src/alpha.tsx @@ -38,11 +38,10 @@ import { import { createFrontendPlugin, - createApiExtension, - createPageExtension, + ApiBlueprint, createExtensionInput, - createNavItemExtension, - createSchemaFromZod, + PageBlueprint, + NavItemBlueprint, } from '@backstage/frontend-plugin-api'; import { @@ -62,7 +61,7 @@ import { } from '@backstage/plugin-search-react'; import { SearchResult } from '@backstage/plugin-search-common'; import { searchApiRef } from '@backstage/plugin-search-react'; -import { createSearchResultListItemExtension } from '@backstage/plugin-search-react/alpha'; +import { SearchResultListItemBlueprint } from '@backstage/plugin-search-react/alpha'; import { rootRouteRef } from './plugin'; import { SearchClient } from './apis'; @@ -75,13 +74,15 @@ import { } from '@backstage/core-compat-api'; /** @alpha */ -export const searchApi = createApiExtension({ - factory: createApiFactory({ - api: searchApiRef, - deps: { discoveryApi: discoveryApiRef, fetchApi: fetchApiRef }, - factory: ({ discoveryApi, fetchApi }) => - new SearchClient({ discoveryApi, fetchApi }), - }), +export const searchApi = ApiBlueprint.make({ + params: { + factory: createApiFactory({ + api: searchApiRef, + deps: { discoveryApi: discoveryApiRef, fetchApi: fetchApiRef }, + factory: ({ discoveryApi, fetchApi }) => + new SearchClient({ discoveryApi, fetchApi }), + }), + }, }); const useSearchPageStyles = makeStyles((theme: Theme) => ({ @@ -97,143 +98,152 @@ const useSearchPageStyles = makeStyles((theme: Theme) => ({ })); /** @alpha */ -export const searchPage = createPageExtension({ - routeRef: convertLegacyRouteRef(rootRouteRef), - configSchema: createSchemaFromZod(z => - z.object({ - path: z.string().default('/search'), - noTrack: z.boolean().default(false), - }), - ), - inputs: { - items: createExtensionInput({ - item: createSearchResultListItemExtension.itemDataRef, - }), +export const searchPage = PageBlueprint.makeWithOverrides({ + config: { + schema: { + noTrack: z => z.boolean().default(false), + }, }, - loader: async ({ config, inputs }) => { - const getResultItemComponent = (result: SearchResult) => { - const value = inputs.items.find(item => - item?.output.item.predicate?.(result), - ); - return value?.output.item.component ?? DefaultResultListItem; - }; + inputs: { + items: createExtensionInput([SearchResultListItemBlueprint.dataRefs.item]), + }, + factory(originalFactory, { config, inputs }) { + return originalFactory({ + defaultPath: '/search', + routeRef: convertLegacyRouteRef(rootRouteRef), + loader: async () => { + const getResultItemComponent = (result: SearchResult) => { + const value = inputs.items.find(item => + item + ?.get(SearchResultListItemBlueprint.dataRefs.item) + .predicate?.(result), + ); + return ( + value?.get(SearchResultListItemBlueprint.dataRefs.item).component ?? + DefaultResultListItem + ); + }; - const Component = () => { - const classes = useSearchPageStyles(); - const { isMobile } = useSidebarPinState(); - const { types } = useSearch(); - const catalogApi = useApi(catalogApiRef); + const Component = () => { + const classes = useSearchPageStyles(); + const { isMobile } = useSidebarPinState(); + const { types } = useSearch(); + const catalogApi = useApi(catalogApiRef); - return ( - - {!isMobile &&
    } - - - - - - {!isMobile && ( - - , - }, - { - value: 'techdocs', - name: 'Documentation', - icon: , - }, - ]} - /> - - {types.includes('techdocs') && ( - { - // Return a list of entities which are documented. - const { items } = await catalogApi.getEntities({ - fields: ['metadata.name'], - filter: { - 'metadata.annotations.backstage.io/techdocs-ref': - CATALOG_FILTER_EXISTS, - }, - }); - - const names = items.map( - entity => entity.metadata.name, - ); - names.sort(); - return names; - }} + return ( + + {!isMobile &&
    } + + + + + + {!isMobile && ( + + , + }, + { + value: 'techdocs', + name: 'Documentation', + icon: , + }, + ]} /> - )} - - - - - )} - - - - {({ results }) => ( - <> - {results.map((result, index) => { - const { noTrack } = config; - const { document, ...rest } = result; - const SearchResultListItem = - getResultItemComponent(result); - return ( - - ); - })} - - )} - - - - - - - ); - }; + + {types.includes('techdocs') && ( + { + // Return a list of entities which are documented. + const { items } = await catalogApi.getEntities({ + fields: ['metadata.name'], + filter: { + 'metadata.annotations.backstage.io/techdocs-ref': + CATALOG_FILTER_EXISTS, + }, + }); - return compatWrapper( - - - - , - ); + const names = items.map( + entity => entity.metadata.name, + ); + names.sort(); + return names; + }} + /> + )} + + + + + )} + + + + {({ results }) => ( + <> + {results.map((result, index) => { + const { noTrack } = config; + const { document, ...rest } = result; + const SearchResultListItem = + getResultItemComponent(result); + return ( + + ); + })} + + )} + + + + + + + ); + }; + + return compatWrapper( + + + + , + ); + }, + }); }, }); /** @alpha */ -export const searchNavItem = createNavItemExtension({ - routeRef: convertLegacyRouteRef(rootRouteRef), - title: 'Search', - icon: SearchIcon, +export const searchNavItem = NavItemBlueprint.make({ + params: { + routeRef: convertLegacyRouteRef(rootRouteRef), + title: 'Search', + icon: SearchIcon, + }, }); /** @alpha */ From d2e999e4020bce0a470d872ab8f07b1a3b0ee368 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 15 Aug 2024 15:22:06 +0200 Subject: [PATCH 366/372] chore: added kuber Signed-off-by: blam --- plugins/kubernetes/src/alpha/apis.tsx | 151 ++++++++++-------- .../kubernetes/src/alpha/entityContents.tsx | 20 +-- 2 files changed, 92 insertions(+), 79 deletions(-) diff --git a/plugins/kubernetes/src/alpha/apis.tsx b/plugins/kubernetes/src/alpha/apis.tsx index 6c880d2f53..082a2da6c7 100644 --- a/plugins/kubernetes/src/alpha/apis.tsx +++ b/plugins/kubernetes/src/alpha/apis.tsx @@ -15,7 +15,7 @@ */ import { - createApiExtension, + ApiBlueprint, createApiFactory, discoveryApiRef, fetchApiRef, @@ -40,80 +40,91 @@ import { oneloginAuthApiRef, } from '@backstage/core-plugin-api'; -export const kubernetesApiExtension = createApiExtension({ - factory: createApiFactory({ - api: kubernetesApiRef, - deps: { - discoveryApi: discoveryApiRef, - fetchApi: fetchApiRef, - kubernetesAuthProvidersApi: kubernetesAuthProvidersApiRef, - }, - factory: ({ discoveryApi, fetchApi, kubernetesAuthProvidersApi }) => - new KubernetesBackendClient({ - discoveryApi, - fetchApi, - kubernetesAuthProvidersApi, - }), - }), +export const kubernetesApiExtension = ApiBlueprint.make({ + params: { + factory: createApiFactory({ + api: kubernetesApiRef, + deps: { + discoveryApi: discoveryApiRef, + fetchApi: fetchApiRef, + kubernetesAuthProvidersApi: kubernetesAuthProvidersApiRef, + }, + factory: ({ discoveryApi, fetchApi, kubernetesAuthProvidersApi }) => + new KubernetesBackendClient({ + discoveryApi, + fetchApi, + kubernetesAuthProvidersApi, + }), + }), + }, }); -export const kubernetesProxyApi = createApiExtension({ - factory: createApiFactory({ - api: kubernetesProxyApiRef, - deps: { - kubernetesApi: kubernetesApiRef, - }, - factory: ({ kubernetesApi }) => - new KubernetesProxyClient({ - kubernetesApi, - }), - }), +export const kubernetesProxyApi = ApiBlueprint.make({ + name: 'proxy', + params: { + factory: createApiFactory({ + api: kubernetesProxyApiRef, + deps: { + kubernetesApi: kubernetesApiRef, + }, + factory: ({ kubernetesApi }) => + new KubernetesProxyClient({ + kubernetesApi, + }), + }), + }, }); -export const kubernetesAuthProvidersApi = createApiExtension({ - factory: createApiFactory({ - api: kubernetesAuthProvidersApiRef, - deps: { - gitlabAuthApi: gitlabAuthApiRef, - googleAuthApi: googleAuthApiRef, - microsoftAuthApi: microsoftAuthApiRef, - oktaAuthApi: oktaAuthApiRef, - oneloginAuthApi: oneloginAuthApiRef, - }, - factory: ({ - gitlabAuthApi, - googleAuthApi, - microsoftAuthApi, - oktaAuthApi, - oneloginAuthApi, - }) => { - const oidcProviders = { - gitlab: gitlabAuthApi, - google: googleAuthApi, - microsoft: microsoftAuthApi, - okta: oktaAuthApi, - onelogin: oneloginAuthApi, - }; - - return new KubernetesAuthProviders({ - microsoftAuthApi, +export const kubernetesAuthProvidersApi = ApiBlueprint.make({ + name: 'auth-providers', + params: { + factory: createApiFactory({ + api: kubernetesAuthProvidersApiRef, + deps: { + gitlabAuthApi: gitlabAuthApiRef, + googleAuthApi: googleAuthApiRef, + microsoftAuthApi: microsoftAuthApiRef, + oktaAuthApi: oktaAuthApiRef, + oneloginAuthApi: oneloginAuthApiRef, + }, + factory: ({ + gitlabAuthApi, googleAuthApi, - oidcProviders, - }); - }, - }), + microsoftAuthApi, + oktaAuthApi, + oneloginAuthApi, + }) => { + const oidcProviders = { + gitlab: gitlabAuthApi, + google: googleAuthApi, + microsoft: microsoftAuthApi, + okta: oktaAuthApi, + onelogin: oneloginAuthApi, + }; + + return new KubernetesAuthProviders({ + microsoftAuthApi, + googleAuthApi, + oidcProviders, + }); + }, + }), + }, }); -export const kubernetesClusterLinkFormatterApi = createApiExtension({ - factory: createApiFactory({ - api: kubernetesClusterLinkFormatterApiRef, - deps: { googleAuthApi: googleAuthApiRef }, - factory: deps => { - const formatters = getDefaultFormatters(deps); - return new KubernetesClusterLinkFormatter({ - formatters, - defaultFormatterName: DEFAULT_FORMATTER_NAME, - }); - }, - }), +export const kubernetesClusterLinkFormatterApi = ApiBlueprint.make({ + name: 'cluster-link-formatter', + params: { + factory: createApiFactory({ + api: kubernetesClusterLinkFormatterApiRef, + deps: { googleAuthApi: googleAuthApiRef }, + factory: deps => { + const formatters = getDefaultFormatters(deps); + return new KubernetesClusterLinkFormatter({ + formatters, + defaultFormatterName: DEFAULT_FORMATTER_NAME, + }); + }, + }), + }, }); diff --git a/plugins/kubernetes/src/alpha/entityContents.tsx b/plugins/kubernetes/src/alpha/entityContents.tsx index 9ad0b6843f..de11310981 100644 --- a/plugins/kubernetes/src/alpha/entityContents.tsx +++ b/plugins/kubernetes/src/alpha/entityContents.tsx @@ -19,16 +19,18 @@ import { compatWrapper, convertLegacyRouteRef, } from '@backstage/core-compat-api'; -import { createEntityContentExtension } from '@backstage/plugin-catalog-react/alpha'; import { rootCatalogKubernetesRouteRef } from '../plugin'; +import { EntityContentBlueprint } from '@backstage/plugin-catalog-react/alpha'; -export const entityKubernetesContent = createEntityContentExtension({ - defaultPath: 'kubernetes', - defaultTitle: 'Kubernetes', +export const entityKubernetesContent = EntityContentBlueprint.make({ name: 'kubernetes', - routeRef: convertLegacyRouteRef(rootCatalogKubernetesRouteRef), - loader: () => - import('./KubernetesContentPage').then(m => - compatWrapper(), - ), + params: { + defaultPath: 'kubernetes', + defaultTitle: 'Kubernetes', + routeRef: convertLegacyRouteRef(rootCatalogKubernetesRouteRef), + loader: () => + import('./KubernetesContentPage').then(m => + compatWrapper(), + ), + }, }); From 75e79518eafc6e6eb55585f166667418419662de Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 15 Aug 2024 15:22:16 +0200 Subject: [PATCH 367/372] chore: some more migrations Signed-off-by: blam --- plugins/catalog-import/src/alpha.tsx | 68 ++++++----- plugins/devtools/src/alpha/plugin.tsx | 54 ++++---- plugins/org/src/alpha.tsx | 58 +++++---- plugins/techdocs/src/alpha.tsx | 170 ++++++++++++++------------ plugins/user-settings/src/alpha.tsx | 52 ++++---- 5 files changed, 221 insertions(+), 181 deletions(-) diff --git a/plugins/catalog-import/src/alpha.tsx b/plugins/catalog-import/src/alpha.tsx index 9f685cf778..cf63c92338 100644 --- a/plugins/catalog-import/src/alpha.tsx +++ b/plugins/catalog-import/src/alpha.tsx @@ -25,9 +25,9 @@ import { convertLegacyRouteRef, } from '@backstage/core-compat-api'; import { - createApiExtension, - createPageExtension, createFrontendPlugin, + PageBlueprint, + ApiBlueprint, } from '@backstage/frontend-plugin-api'; import { scmAuthApiRef, @@ -40,43 +40,47 @@ import { catalogApiRef } from '@backstage/plugin-catalog-react'; // TODO: It's currently possible to override the import page with a custom one. We need to decide // whether this type of override is typically done with an input or by overriding the entire extension. -const catalogImportPage = createPageExtension({ - defaultPath: '/catalog-import', - routeRef: convertLegacyRouteRef(rootRouteRef), - loader: () => - import('./components/ImportPage').then(m => - compatWrapper(), - ), +const catalogImportPage = PageBlueprint.make({ + params: { + defaultPath: '/catalog-import', + routeRef: convertLegacyRouteRef(rootRouteRef), + loader: () => + import('./components/ImportPage').then(m => + compatWrapper(), + ), + }, }); -const catalogImportApi = createApiExtension({ - factory: createApiFactory({ - api: catalogImportApiRef, - deps: { - discoveryApi: discoveryApiRef, - scmAuthApi: scmAuthApiRef, - fetchApi: fetchApiRef, - scmIntegrationsApi: scmIntegrationsApiRef, - catalogApi: catalogApiRef, - configApi: configApiRef, - }, - factory: ({ - discoveryApi, - scmAuthApi, - fetchApi, - scmIntegrationsApi, - catalogApi, - configApi, - }) => - new CatalogImportClient({ +const catalogImportApi = ApiBlueprint.make({ + params: { + factory: createApiFactory({ + api: catalogImportApiRef, + deps: { + discoveryApi: discoveryApiRef, + scmAuthApi: scmAuthApiRef, + fetchApi: fetchApiRef, + scmIntegrationsApi: scmIntegrationsApiRef, + catalogApi: catalogApiRef, + configApi: configApiRef, + }, + factory: ({ discoveryApi, scmAuthApi, - scmIntegrationsApi, fetchApi, + scmIntegrationsApi, catalogApi, configApi, - }), - }), + }) => + new CatalogImportClient({ + discoveryApi, + scmAuthApi, + scmIntegrationsApi, + fetchApi, + catalogApi, + configApi, + }), + }), + }, }); /** @alpha */ diff --git a/plugins/devtools/src/alpha/plugin.tsx b/plugins/devtools/src/alpha/plugin.tsx index 73b94f52f8..4c62dd3155 100644 --- a/plugins/devtools/src/alpha/plugin.tsx +++ b/plugins/devtools/src/alpha/plugin.tsx @@ -16,13 +16,13 @@ import React from 'react'; import { - createApiExtension, createApiFactory, - createNavItemExtension, - createPageExtension, createFrontendPlugin, discoveryApiRef, fetchApiRef, + ApiBlueprint, + PageBlueprint, + NavItemBlueprint, } from '@backstage/frontend-plugin-api'; import { devToolsApiRef, DevToolsClient } from '../api'; @@ -34,33 +34,39 @@ import BuildIcon from '@material-ui/icons/Build'; import { rootRouteRef } from '../routes'; /** @alpha */ -export const devToolsApi = createApiExtension({ - factory: createApiFactory({ - api: devToolsApiRef, - deps: { - discoveryApi: discoveryApiRef, - fetchApi: fetchApiRef, - }, - factory: ({ discoveryApi, fetchApi }) => - new DevToolsClient({ discoveryApi, fetchApi }), - }), +export const devToolsApi = ApiBlueprint.make({ + params: { + factory: createApiFactory({ + api: devToolsApiRef, + deps: { + discoveryApi: discoveryApiRef, + fetchApi: fetchApiRef, + }, + factory: ({ discoveryApi, fetchApi }) => + new DevToolsClient({ discoveryApi, fetchApi }), + }), + }, }); /** @alpha */ -export const devToolsPage = createPageExtension({ - defaultPath: '/devtools', - routeRef: convertLegacyRouteRef(rootRouteRef), - loader: () => - import('../components/DevToolsPage').then(m => - compatWrapper(), - ), +export const devToolsPage = PageBlueprint.make({ + params: { + defaultPath: '/devtools', + routeRef: convertLegacyRouteRef(rootRouteRef), + loader: () => + import('../components/DevToolsPage').then(m => + compatWrapper(), + ), + }, }); /** @alpha */ -export const devToolsNavItem = createNavItemExtension({ - title: 'DevTools', - routeRef: convertLegacyRouteRef(rootRouteRef), - icon: BuildIcon, +export const devToolsNavItem = NavItemBlueprint.make({ + params: { + title: 'DevTools', + routeRef: convertLegacyRouteRef(rootRouteRef), + icon: BuildIcon, + }, }); /** @alpha */ diff --git a/plugins/org/src/alpha.tsx b/plugins/org/src/alpha.tsx index 481d9f2b63..61054a2d8a 100644 --- a/plugins/org/src/alpha.tsx +++ b/plugins/org/src/alpha.tsx @@ -21,46 +21,54 @@ import { import { createFrontendPlugin } from '@backstage/frontend-plugin-api'; import React from 'react'; import { catalogIndexRouteRef } from './routes'; -import { createEntityCardExtension } from '@backstage/plugin-catalog-react/alpha'; +import { EntityCardBlueprint } from '@backstage/plugin-catalog-react/alpha'; /** @alpha */ -const EntityGroupProfileCard = createEntityCardExtension({ +const EntityGroupProfileCard = EntityCardBlueprint.make({ name: 'group-profile', - filter: 'kind:group', - loader: async () => - import('./components/Cards/Group/GroupProfile/GroupProfileCard').then(m => - compatWrapper(), - ), + params: { + filter: 'kind:group', + loader: async () => + import('./components/Cards/Group/GroupProfile/GroupProfileCard').then(m => + compatWrapper(), + ), + }, }); /** @alpha */ -const EntityMembersListCard = createEntityCardExtension({ +const EntityMembersListCard = EntityCardBlueprint.make({ name: 'members-list', - filter: 'kind:group', - loader: async () => - import('./components/Cards/Group/MembersList/MembersListCard').then(m => - compatWrapper(), - ), + params: { + filter: 'kind:group', + loader: async () => + import('./components/Cards/Group/MembersList/MembersListCard').then(m => + compatWrapper(), + ), + }, }); /** @alpha */ -const EntityOwnershipCard = createEntityCardExtension({ +const EntityOwnershipCard = EntityCardBlueprint.make({ name: 'ownership', - filter: 'kind:group,user', - loader: async () => - import('./components/Cards/OwnershipCard/OwnershipCard').then(m => - compatWrapper(), - ), + params: { + filter: 'kind:group,user', + loader: async () => + import('./components/Cards/OwnershipCard/OwnershipCard').then(m => + compatWrapper(), + ), + }, }); /** @alpha */ -const EntityUserProfileCard = createEntityCardExtension({ +const EntityUserProfileCard = EntityCardBlueprint.make({ name: 'user-profile', - filter: 'kind:user', - loader: async () => - import('./components/Cards/User/UserProfileCard/UserProfileCard').then(m => - compatWrapper(), - ), + params: { + filter: 'kind:user', + loader: async () => + import('./components/Cards/User/UserProfileCard/UserProfileCard').then( + m => compatWrapper(), + ), + }, }); /** @alpha */ diff --git a/plugins/techdocs/src/alpha.tsx b/plugins/techdocs/src/alpha.tsx index d1a186f227..b0d0d3d467 100644 --- a/plugins/techdocs/src/alpha.tsx +++ b/plugins/techdocs/src/alpha.tsx @@ -18,12 +18,11 @@ import React from 'react'; import LibraryBooks from '@material-ui/icons/LibraryBooks'; import { createFrontendPlugin, - createSchemaFromZod, - createApiExtension, - createPageExtension, - createNavItemExtension, + ApiBlueprint, + PageBlueprint, + NavItemBlueprint, } from '@backstage/frontend-plugin-api'; -import { createSearchResultListItemExtension } from '@backstage/plugin-search-react/alpha'; +import { SearchResultListItemBlueprint } from '@backstage/plugin-search-react/alpha'; import { configApiRef, createApiFactory, @@ -45,64 +44,73 @@ import { rootDocsRouteRef, rootRouteRef, } from './routes'; -import { createEntityContentExtension } from '@backstage/plugin-catalog-react/alpha'; +import { EntityContentBlueprint } from '@backstage/plugin-catalog-react/alpha'; /** @alpha */ -const techDocsStorageApi = createApiExtension({ - factory: createApiFactory({ - api: techdocsStorageApiRef, - deps: { - configApi: configApiRef, - discoveryApi: discoveryApiRef, - fetchApi: fetchApiRef, - }, - factory: ({ configApi, discoveryApi, fetchApi }) => - new TechDocsStorageClient({ - configApi, - discoveryApi, - fetchApi, - }), - }), +const techDocsStorageApi = ApiBlueprint.make({ + name: 'storage', + params: { + factory: createApiFactory({ + api: techdocsStorageApiRef, + deps: { + configApi: configApiRef, + discoveryApi: discoveryApiRef, + fetchApi: fetchApiRef, + }, + factory: ({ configApi, discoveryApi, fetchApi }) => + new TechDocsStorageClient({ + configApi, + discoveryApi, + fetchApi, + }), + }), + }, }); /** @alpha */ -const techDocsClientApi = createApiExtension({ - factory: createApiFactory({ - api: techdocsApiRef, - deps: { - configApi: configApiRef, - discoveryApi: discoveryApiRef, - fetchApi: fetchApiRef, - }, - factory: ({ configApi, discoveryApi, fetchApi }) => - new TechDocsClient({ - configApi, - discoveryApi, - fetchApi, - }), - }), +const techDocsClientApi = ApiBlueprint.make({ + params: { + factory: createApiFactory({ + api: techdocsApiRef, + deps: { + configApi: configApiRef, + discoveryApi: discoveryApiRef, + fetchApi: fetchApiRef, + }, + factory: ({ configApi, discoveryApi, fetchApi }) => + new TechDocsClient({ + configApi, + discoveryApi, + fetchApi, + }), + }), + }, }); /** @alpha */ export const techDocsSearchResultListItemExtension = - createSearchResultListItemExtension({ - configSchema: createSchemaFromZod(z => - z.object({ - // TODO: Define how the icon can be configurable - title: z.string().optional(), - lineClamp: z.number().default(5), - asLink: z.boolean().default(true), - asListItem: z.boolean().default(true), - noTrack: z.boolean().default(false), - }), - ), - predicate: result => result.type === 'techdocs', - component: async ({ config }) => { - const { TechDocsSearchResultListItem } = await import( - './search/components/TechDocsSearchResultListItem' - ); - return props => - compatWrapper(); + SearchResultListItemBlueprint.makeWithOverrides({ + config: { + schema: { + title: z => z.string().optional(), + lineClamp: z => z.number().default(5), + asLink: z => z.boolean().default(true), + asListItem: z => z.boolean().default(true), + }, + }, + factory(originalFactory, { config }) { + return originalFactory({ + predicate: result => result.type === 'techdocs', + component: async () => { + const { TechDocsSearchResultListItem } = await import( + './search/components/TechDocsSearchResultListItem' + ); + return props => + compatWrapper( + , + ); + }, + }); }, }); @@ -111,13 +119,15 @@ export const techDocsSearchResultListItemExtension = * * @alpha */ -const techDocsPage = createPageExtension({ - defaultPath: '/docs', - routeRef: convertLegacyRouteRef(rootRouteRef), - loader: () => - import('./home/components/TechDocsIndexPage').then(m => - compatWrapper(), - ), +const techDocsPage = PageBlueprint.make({ + params: { + defaultPath: '/docs', + routeRef: convertLegacyRouteRef(rootRouteRef), + loader: () => + import('./home/components/TechDocsIndexPage').then(m => + compatWrapper(), + ), + }, }); /** @@ -125,14 +135,16 @@ const techDocsPage = createPageExtension({ * * @alpha */ -const techDocsReaderPage = createPageExtension({ +const techDocsReaderPage = PageBlueprint.make({ name: 'reader', - defaultPath: '/docs/:namespace/:kind/:name', - routeRef: convertLegacyRouteRef(rootDocsRouteRef), - loader: () => - import('./reader/components/TechDocsReaderPage').then(m => - compatWrapper(), - ), + params: { + defaultPath: '/docs/:namespace/:kind/:name', + routeRef: convertLegacyRouteRef(rootDocsRouteRef), + loader: () => + import('./reader/components/TechDocsReaderPage').then(m => + compatWrapper(), + ), + }, }); /** @@ -140,18 +152,22 @@ const techDocsReaderPage = createPageExtension({ * * @alpha */ -const techDocsEntityContent = createEntityContentExtension({ - defaultPath: 'docs', - defaultTitle: 'TechDocs', - loader: () => - import('./Router').then(m => compatWrapper()), +const techDocsEntityContent = EntityContentBlueprint.make({ + params: { + defaultPath: 'docs', + defaultTitle: 'TechDocs', + loader: () => + import('./Router').then(m => compatWrapper()), + }, }); /** @alpha */ -const techDocsNavItem = createNavItemExtension({ - icon: LibraryBooks, - title: 'Docs', - routeRef: convertLegacyRouteRef(rootRouteRef), +const techDocsNavItem = NavItemBlueprint.make({ + params: { + icon: LibraryBooks, + title: 'Docs', + routeRef: convertLegacyRouteRef(rootRouteRef), + }, }); /** @alpha */ diff --git a/plugins/user-settings/src/alpha.tsx b/plugins/user-settings/src/alpha.tsx index cfc3369487..bdd16acf0f 100644 --- a/plugins/user-settings/src/alpha.tsx +++ b/plugins/user-settings/src/alpha.tsx @@ -16,9 +16,9 @@ import { coreExtensionData, createExtensionInput, - createNavItemExtension, - createPageExtension, createFrontendPlugin, + PageBlueprint, + NavItemBlueprint, } from '@backstage/frontend-plugin-api'; import { convertLegacyRouteRef, @@ -32,32 +32,38 @@ import React from 'react'; export * from './translation'; -const userSettingsPage = createPageExtension({ - defaultPath: '/settings', - routeRef: convertLegacyRouteRef(settingsRouteRef), +const userSettingsPage = PageBlueprint.makeWithOverrides({ inputs: { - providerSettings: createExtensionInput( - { - element: coreExtensionData.reactElement, - }, - { singleton: true, optional: true }, - ), + providerSettings: createExtensionInput([coreExtensionData.reactElement], { + singleton: true, + optional: true, + }), + }, + factory(originalFactory, { inputs }) { + return originalFactory({ + defaultPath: '/settings', + routeRef: convertLegacyRouteRef(settingsRouteRef), + loader: () => + import('./components/SettingsPage').then(m => + compatWrapper( + , + ), + ), + }); }, - loader: ({ inputs }) => - import('./components/SettingsPage').then(m => - compatWrapper( - , - ), - ), }); /** @alpha */ -export const settingsNavItem = createNavItemExtension({ - routeRef: convertLegacyRouteRef(settingsRouteRef), - title: 'Settings', - icon: SettingsIcon, +export const settingsNavItem = NavItemBlueprint.make({ + params: { + routeRef: convertLegacyRouteRef(settingsRouteRef), + title: 'Settings', + icon: SettingsIcon, + }, }); /** From 4a8b94ee93a8a83726c28a7bdce1fe69ab758fa3 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 15 Aug 2024 15:28:34 +0200 Subject: [PATCH 368/372] chore: last one Signed-off-by: blam Signed-off-by: blam --- .../AppVisualizerPage/DetailedVisualizer.tsx | 18 ++++++------ plugins/app-visualizer/src/plugin.tsx | 28 +++++++++++-------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/plugins/app-visualizer/src/components/AppVisualizerPage/DetailedVisualizer.tsx b/plugins/app-visualizer/src/components/AppVisualizerPage/DetailedVisualizer.tsx index b2c9685bab..d22c2d94db 100644 --- a/plugins/app-visualizer/src/components/AppVisualizerPage/DetailedVisualizer.tsx +++ b/plugins/app-visualizer/src/components/AppVisualizerPage/DetailedVisualizer.tsx @@ -20,9 +20,9 @@ import { ExtensionDataRef, RouteRef, coreExtensionData, - createApiExtension, - createNavItemExtension, - createThemeExtension, + ApiBlueprint, + NavItemBlueprint, + ThemeBlueprint, useRouteRef, } from '@backstage/frontend-plugin-api'; import Box from '@material-ui/core/Box'; @@ -66,9 +66,9 @@ const getOutputColor = createOutputColorGenerator( [coreExtensionData.reactElement.id]: colors.green[500], [coreExtensionData.routePath.id]: colors.yellow[500], [coreExtensionData.routeRef.id]: colors.purple[500], - [createApiExtension.factoryDataRef.id]: colors.blue[500], - [createThemeExtension.themeDataRef.id]: colors.lime[500], - [createNavItemExtension.targetDataRef.id]: colors.orange[500], + [ApiBlueprint.dataRefs.factory.id]: colors.blue[500], + [ThemeBlueprint.dataRefs.theme.id]: colors.lime[500], + [NavItemBlueprint.dataRefs.target.id]: colors.orange[500], }, [ @@ -323,11 +323,11 @@ function Extension(props: { node: AppNode; depth: number }) { const legendMap = { 'React Element': coreExtensionData.reactElement, - 'Utility API': createApiExtension.factoryDataRef, + 'Utility API': ApiBlueprint.dataRefs.factory, 'Route Path': coreExtensionData.routePath, 'Route Ref': coreExtensionData.routeRef, - 'Nav Target': createNavItemExtension.targetDataRef, - Theme: createThemeExtension.themeDataRef, + 'Nav Target': NavItemBlueprint.dataRefs.target, + Theme: ThemeBlueprint.dataRefs.theme, }; function Legend() { diff --git a/plugins/app-visualizer/src/plugin.tsx b/plugins/app-visualizer/src/plugin.tsx index b41f1c69e8..0e18b692e8 100644 --- a/plugins/app-visualizer/src/plugin.tsx +++ b/plugins/app-visualizer/src/plugin.tsx @@ -15,27 +15,33 @@ */ import { - createNavItemExtension, - createPageExtension, createFrontendPlugin, createRouteRef, + NavItemBlueprint, + PageBlueprint, } from '@backstage/frontend-plugin-api'; import VisualizerIcon from '@material-ui/icons/Visibility'; import React from 'react'; const rootRouteRef = createRouteRef(); -const appVisualizerPage = createPageExtension({ - defaultPath: '/visualizer', - routeRef: rootRouteRef, - loader: () => - import('./components/AppVisualizerPage').then(m => ), +const appVisualizerPage = PageBlueprint.make({ + params: { + defaultPath: '/visualizer', + routeRef: rootRouteRef, + loader: () => + import('./components/AppVisualizerPage').then(m => ( + + )), + }, }); -export const appVisualizerNavItem = createNavItemExtension({ - title: 'Visualizer', - icon: VisualizerIcon, - routeRef: rootRouteRef, +export const appVisualizerNavItem = NavItemBlueprint.make({ + params: { + title: 'Visualizer', + icon: VisualizerIcon, + routeRef: rootRouteRef, + }, }); /** @public */ From af7be32e90e6a3d159bf58a4b70190c57d72b604 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 15 Aug 2024 16:32:09 +0200 Subject: [PATCH 369/372] chore: api-reports Signed-off-by: blam --- plugins/app-visualizer/api-report.md | 55 ++++- plugins/catalog-graph/api-report-alpha.md | 135 ++++++++++- plugins/catalog-graph/src/alpha.tsx | 2 +- plugins/catalog-import/api-report-alpha.md | 42 +++- plugins/catalog/api-report-alpha.md | 261 +++++++++++++++++++++ plugins/catalog/src/alpha/apis.tsx | 5 +- plugins/catalog/src/alpha/filters.tsx | 1 - plugins/devtools/api-report-alpha.md | 60 ++++- plugins/kubernetes/api-report-alpha.md | 69 ++++++ plugins/org/api-report-alpha.md | 131 ++++++++++- plugins/scaffolder/api-report-alpha.md | 59 ++++- plugins/search/api-report-alpha.md | 159 +++++++++++-- plugins/techdocs/api-report-alpha.md | 187 ++++++++++++++- plugins/user-settings/api-report-alpha.md | 92 +++++++- 14 files changed, 1195 insertions(+), 63 deletions(-) diff --git a/plugins/app-visualizer/api-report.md b/plugins/app-visualizer/api-report.md index fd3749b159..cab8b113b6 100644 --- a/plugins/app-visualizer/api-report.md +++ b/plugins/app-visualizer/api-report.md @@ -3,10 +3,63 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts +import { AnyRouteRefParams } from '@backstage/frontend-plugin-api'; import { BackstagePlugin } from '@backstage/frontend-plugin-api'; +import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api'; +import { ExtensionDefinition } from '@backstage/frontend-plugin-api'; +import { IconComponent } from '@backstage/core-plugin-api'; +import { default as React_2 } from 'react'; +import { RouteRef } from '@backstage/frontend-plugin-api'; // @public (undocumented) -const visualizerPlugin: BackstagePlugin<{}, {}, {}>; +const visualizerPlugin: BackstagePlugin< + {}, + {}, + { + 'page:app-visualizer': ExtensionDefinition< + { + path: string | undefined; + }, + { + path?: string | undefined; + }, + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + > + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + RouteRef, + 'core.routing.ref', + { + optional: true; + } + >, + {}, + 'page', + undefined, + undefined + >; + 'nav-item:app-visualizer': ExtensionDefinition< + {}, + {}, + ConfigurableExtensionDataRef< + { + title: string; + icon: IconComponent; + routeRef: RouteRef; + }, + 'core.nav-item.target', + {} + >, + {}, + 'nav-item', + undefined, + undefined + >; + } +>; export default visualizerPlugin; // (No @packageDocumentation comment for this package) diff --git a/plugins/catalog-graph/api-report-alpha.md b/plugins/catalog-graph/api-report-alpha.md index e651946463..03ee352227 100644 --- a/plugins/catalog-graph/api-report-alpha.md +++ b/plugins/catalog-graph/api-report-alpha.md @@ -3,8 +3,16 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts +import { AnyExtensionDataRef } from '@backstage/frontend-plugin-api'; +import { AnyRouteRefParams } from '@backstage/frontend-plugin-api'; import { BackstagePlugin } from '@backstage/frontend-plugin-api'; +import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api'; +import { Direction } from '@backstage/plugin-catalog-graph'; +import { Entity } from '@backstage/catalog-model'; +import { ExtensionDefinition } from '@backstage/frontend-plugin-api'; +import { ExtensionInput } from '@backstage/frontend-plugin-api'; import { ExternalRouteRef } from '@backstage/frontend-plugin-api'; +import { default as React_2 } from 'react'; import { RouteRef } from '@backstage/frontend-plugin-api'; // @public (undocumented) @@ -19,7 +27,132 @@ const _default: BackstagePlugin< namespace: string; }>; }, - {} + { + 'entity-card:catalog-graph/relations': ExtensionDefinition< + { + kinds: string[] | undefined; + relations: string[] | undefined; + maxDepth: number | undefined; + unidirectional: boolean | undefined; + mergeRelations: boolean | undefined; + direction: Direction | undefined; + relationPairs: [string, string][] | undefined; + zoom: 'disabled' | 'enabled' | 'enable-on-click' | undefined; + curve: 'curveStepBefore' | 'curveMonotoneX' | undefined; + title: string | undefined; + height: number | undefined; + } & { + filter: string | undefined; + }, + { + height?: number | undefined; + curve?: 'curveStepBefore' | 'curveMonotoneX' | undefined; + direction?: Direction | undefined; + title?: string | undefined; + zoom?: 'disabled' | 'enabled' | 'enable-on-click' | undefined; + relations?: string[] | undefined; + maxDepth?: number | undefined; + kinds?: string[] | undefined; + unidirectional?: boolean | undefined; + mergeRelations?: boolean | undefined; + relationPairs?: [string, string][] | undefined; + } & { + filter?: string | undefined; + }, + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + > + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + { + optional: true; + } + >, + { + [x: string]: ExtensionInput< + AnyExtensionDataRef, + { + optional: boolean; + singleton: boolean; + } + >; + }, + 'entity-card', + undefined, + 'relations' + >; + 'page:catalog-graph': ExtensionDefinition< + { + selectedKinds: string[] | undefined; + selectedRelations: string[] | undefined; + rootEntityRefs: string[] | undefined; + maxDepth: number | undefined; + unidirectional: boolean | undefined; + mergeRelations: boolean | undefined; + direction: Direction | undefined; + showFilters: boolean | undefined; + curve: 'curveStepBefore' | 'curveMonotoneX' | undefined; + kinds: string[] | undefined; + relations: string[] | undefined; + relationPairs: [string, string][] | undefined; + zoom: 'disabled' | 'enabled' | 'enable-on-click' | undefined; + } & { + path: string | undefined; + }, + { + curve?: 'curveStepBefore' | 'curveMonotoneX' | undefined; + direction?: Direction | undefined; + zoom?: 'disabled' | 'enabled' | 'enable-on-click' | undefined; + relations?: string[] | undefined; + rootEntityRefs?: string[] | undefined; + maxDepth?: number | undefined; + kinds?: string[] | undefined; + unidirectional?: boolean | undefined; + mergeRelations?: boolean | undefined; + relationPairs?: [string, string][] | undefined; + selectedRelations?: string[] | undefined; + selectedKinds?: string[] | undefined; + showFilters?: boolean | undefined; + } & { + path?: string | undefined; + }, + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + > + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + RouteRef, + 'core.routing.ref', + { + optional: true; + } + >, + { + [x: string]: ExtensionInput< + AnyExtensionDataRef, + { + optional: boolean; + singleton: boolean; + } + >; + }, + 'page', + undefined, + undefined + >; + } >; export default _default; diff --git a/plugins/catalog-graph/src/alpha.tsx b/plugins/catalog-graph/src/alpha.tsx index 11c845814f..8186fd3b96 100644 --- a/plugins/catalog-graph/src/alpha.tsx +++ b/plugins/catalog-graph/src/alpha.tsx @@ -25,7 +25,7 @@ import { } from '@backstage/core-compat-api'; import { EntityCardBlueprint } from '@backstage/plugin-catalog-react/alpha'; import { catalogGraphRouteRef, catalogEntityRouteRef } from './routes'; -import { Direction } from './components'; +import { Direction } from '@backstage/plugin-catalog-graph'; const CatalogGraphEntityCard = EntityCardBlueprint.makeWithOverrides({ name: 'relations', diff --git a/plugins/catalog-import/api-report-alpha.md b/plugins/catalog-import/api-report-alpha.md index 51e3d99fd7..3129d13e07 100644 --- a/plugins/catalog-import/api-report-alpha.md +++ b/plugins/catalog-import/api-report-alpha.md @@ -3,7 +3,12 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts +import { AnyApiFactory } from '@backstage/core-plugin-api'; +import { AnyRouteRefParams } from '@backstage/frontend-plugin-api'; import { BackstagePlugin } from '@backstage/frontend-plugin-api'; +import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api'; +import { ExtensionDefinition } from '@backstage/frontend-plugin-api'; +import { default as React_2 } from 'react'; import { RouteRef } from '@backstage/frontend-plugin-api'; // @alpha (undocumented) @@ -12,7 +17,42 @@ const _default: BackstagePlugin< importPage: RouteRef; }, {}, - {} + { + 'api:catalog-import': ExtensionDefinition< + {}, + {}, + ConfigurableExtensionDataRef, + {}, + 'api', + undefined, + undefined + >; + 'page:catalog-import': ExtensionDefinition< + { + path: string | undefined; + }, + { + path?: string | undefined; + }, + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + > + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + RouteRef, + 'core.routing.ref', + { + optional: true; + } + >, + {}, + 'page', + undefined, + undefined + >; + } >; export default _default; diff --git a/plugins/catalog/api-report-alpha.md b/plugins/catalog/api-report-alpha.md index 399580d6a2..386024e0c0 100644 --- a/plugins/catalog/api-report-alpha.md +++ b/plugins/catalog/api-report-alpha.md @@ -5,6 +5,8 @@ ```ts /// +import { AnyApiFactory } from '@backstage/frontend-plugin-api'; +import { AnyExtensionDataRef } from '@backstage/frontend-plugin-api'; import { AnyExtensionInputMap } from '@backstage/frontend-plugin-api'; import { AnyRouteRefParams } from '@backstage/frontend-plugin-api'; import { BackstagePlugin } from '@backstage/frontend-plugin-api'; @@ -14,10 +16,13 @@ import { ExtensionBlueprint } from '@backstage/frontend-plugin-api'; import { ExtensionDefinition } from '@backstage/frontend-plugin-api'; import { ExtensionInput } from '@backstage/frontend-plugin-api'; import { ExternalRouteRef } from '@backstage/frontend-plugin-api'; +import { IconComponent } from '@backstage/core-plugin-api'; import { JSX as JSX_2 } from 'react'; import { PortableSchema } from '@backstage/frontend-plugin-api'; import { default as React_2 } from 'react'; import { RouteRef } from '@backstage/frontend-plugin-api'; +import { SearchResultItemExtensionComponent } from '@backstage/plugin-search-react/alpha'; +import { SearchResultItemExtensionPredicate } from '@backstage/plugin-search-react/alpha'; import { TranslationRef } from '@backstage/core-plugin-api/alpha'; // @alpha @@ -164,6 +169,41 @@ const _default: BackstagePlugin< unregisterRedirect: ExternalRouteRef; }, { + 'nav-item:catalog': ExtensionDefinition< + {}, + {}, + ConfigurableExtensionDataRef< + { + title: string; + icon: IconComponent; + routeRef: RouteRef; + }, + 'core.nav-item.target', + {} + >, + {}, + 'nav-item', + undefined, + undefined + >; + 'api:catalog/starred-entities': ExtensionDefinition< + {}, + {}, + ConfigurableExtensionDataRef, + {}, + 'api', + undefined, + 'starred-entities' + >; + 'api:catalog/entity-presentation': ExtensionDefinition< + {}, + {}, + ConfigurableExtensionDataRef, + {}, + 'api', + undefined, + 'entity-presentation' + >; 'entity-card:catalog/about': ExtensionDefinition< { filter: string | undefined; @@ -500,6 +540,227 @@ const _default: BackstagePlugin< undefined, 'overview' >; + 'catalog-filter:catalog/tag': ExtensionDefinition< + {}, + {}, + ConfigurableExtensionDataRef, + {}, + 'catalog-filter', + undefined, + 'tag' + >; + 'catalog-filter:catalog/kind': ExtensionDefinition< + { + initialFilter: string; + }, + { + initialFilter?: string | undefined; + }, + ConfigurableExtensionDataRef, + { + [x: string]: ExtensionInput< + AnyExtensionDataRef, + { + optional: boolean; + singleton: boolean; + } + >; + }, + 'catalog-filter', + undefined, + 'kind' + >; + 'catalog-filter:catalog/type': ExtensionDefinition< + {}, + {}, + ConfigurableExtensionDataRef, + {}, + 'catalog-filter', + undefined, + 'type' + >; + 'catalog-filter:catalog/mode': ExtensionDefinition< + { + mode: 'all' | 'owners-only' | undefined; + }, + { + mode?: 'all' | 'owners-only' | undefined; + }, + ConfigurableExtensionDataRef, + { + [x: string]: ExtensionInput< + AnyExtensionDataRef, + { + optional: boolean; + singleton: boolean; + } + >; + }, + 'catalog-filter', + undefined, + 'mode' + >; + 'catalog-filter:catalog/namespace': ExtensionDefinition< + {}, + {}, + ConfigurableExtensionDataRef, + {}, + 'catalog-filter', + undefined, + 'namespace' + >; + 'catalog-filter:catalog/lifecycle': ExtensionDefinition< + {}, + {}, + ConfigurableExtensionDataRef, + {}, + 'catalog-filter', + undefined, + 'lifecycle' + >; + 'catalog-filter:catalog/processing-status': ExtensionDefinition< + {}, + {}, + ConfigurableExtensionDataRef, + {}, + 'catalog-filter', + undefined, + 'processing-status' + >; + 'catalog-filter:catalog/list': ExtensionDefinition< + { + initialFilter: 'all' | 'owned' | 'starred'; + }, + { + initialFilter?: 'all' | 'owned' | 'starred' | undefined; + }, + ConfigurableExtensionDataRef, + { + [x: string]: ExtensionInput< + AnyExtensionDataRef, + { + optional: boolean; + singleton: boolean; + } + >; + }, + 'catalog-filter', + undefined, + 'list' + >; + 'page:catalog': ExtensionDefinition< + { + [x: string]: any; + } & { + path: string | undefined; + }, + { + [x: string]: any; + } & { + path?: string | undefined; + }, + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + RouteRef, + 'core.routing.ref', + { + optional: true; + } + >, + { + filters: ExtensionInput< + ConfigurableExtensionDataRef, + { + singleton: false; + optional: false; + } + >; + }, + 'page', + undefined, + undefined + >; + 'page:catalog/entity': ExtensionDefinition< + { + [x: string]: any; + } & { + path: string | undefined; + }, + { + [x: string]: any; + } & { + path?: string | undefined; + }, + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + RouteRef, + 'core.routing.ref', + { + optional: true; + } + >, + { + contents: ExtensionInput< + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + RouteRef, + 'core.routing.ref', + { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-content-title', + {} + > + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + { + optional: true; + } + >, + { + singleton: false; + optional: false; + } + >; + }, + 'page', + undefined, + 'entity' + >; + 'search-result-list-item:catalog': ExtensionDefinition< + { + noTrack: boolean; + }, + { + noTrack?: boolean | undefined; + }, + ConfigurableExtensionDataRef< + { + predicate?: SearchResultItemExtensionPredicate | undefined; + component: SearchResultItemExtensionComponent; + }, + 'search.search-result-list-item.item', + {} + >, + {}, + 'search-result-list-item', + undefined, + undefined + >; } >; export default _default; diff --git a/plugins/catalog/src/alpha/apis.tsx b/plugins/catalog/src/alpha/apis.tsx index 937ba118b3..d0f80c3aec 100644 --- a/plugins/catalog/src/alpha/apis.tsx +++ b/plugins/catalog/src/alpha/apis.tsx @@ -21,10 +21,7 @@ import { storageApiRef, } from '@backstage/core-plugin-api'; import { CatalogClient } from '@backstage/catalog-client'; -import { - ApiBlueprint, - createApiExtension, -} from '@backstage/frontend-plugin-api'; +import { ApiBlueprint } from '@backstage/frontend-plugin-api'; import { catalogApiRef, entityPresentationApiRef, diff --git a/plugins/catalog/src/alpha/filters.tsx b/plugins/catalog/src/alpha/filters.tsx index f4d58e8273..3507658731 100644 --- a/plugins/catalog/src/alpha/filters.tsx +++ b/plugins/catalog/src/alpha/filters.tsx @@ -15,7 +15,6 @@ */ import React from 'react'; -import { createSchemaFromZod } from '@backstage/frontend-plugin-api'; import { CatalogFilterBlueprint } from './blueprints'; const catalogTagCatalogFilter = CatalogFilterBlueprint.make({ diff --git a/plugins/devtools/api-report-alpha.md b/plugins/devtools/api-report-alpha.md index 23ede8144c..f5ca1f98c1 100644 --- a/plugins/devtools/api-report-alpha.md +++ b/plugins/devtools/api-report-alpha.md @@ -3,7 +3,13 @@ > 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 { BackstagePlugin } from '@backstage/frontend-plugin-api'; +import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api'; +import { ExtensionDefinition } from '@backstage/frontend-plugin-api'; +import { IconComponent } from '@backstage/core-plugin-api'; +import { default as React_2 } from 'react'; import { RouteRef } from '@backstage/frontend-plugin-api'; // @alpha (undocumented) @@ -12,7 +18,59 @@ const _default: BackstagePlugin< root: RouteRef; }, {}, - {} + { + 'api:devtools': ExtensionDefinition< + {}, + {}, + ConfigurableExtensionDataRef, + {}, + 'api', + undefined, + undefined + >; + 'page:devtools': ExtensionDefinition< + { + path: string | undefined; + }, + { + path?: string | undefined; + }, + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + > + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + RouteRef, + 'core.routing.ref', + { + optional: true; + } + >, + {}, + 'page', + undefined, + undefined + >; + 'nav-item:devtools': ExtensionDefinition< + {}, + {}, + ConfigurableExtensionDataRef< + { + title: string; + icon: IconComponent; + routeRef: RouteRef; + }, + 'core.nav-item.target', + {} + >, + {}, + 'nav-item', + undefined, + undefined + >; + } >; export default _default; diff --git a/plugins/kubernetes/api-report-alpha.md b/plugins/kubernetes/api-report-alpha.md index f3260208c3..6b53443e2a 100644 --- a/plugins/kubernetes/api-report-alpha.md +++ b/plugins/kubernetes/api-report-alpha.md @@ -5,9 +5,11 @@ ```ts /// +import { AnyApiFactory } from '@backstage/frontend-plugin-api'; import { AnyRouteRefParams } from '@backstage/frontend-plugin-api'; import { BackstagePlugin } from '@backstage/frontend-plugin-api'; import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api'; +import { Entity } from '@backstage/catalog-model'; import { ExtensionDefinition } from '@backstage/frontend-plugin-api'; import { JSX as JSX_2 } from 'react'; import { RouteRef } from '@backstage/frontend-plugin-api'; @@ -40,6 +42,73 @@ const _default: BackstagePlugin< undefined, undefined >; + 'entity-content:kubernetes/kubernetes': ExtensionDefinition< + { + path: string | undefined; + title: string | undefined; + filter: string | undefined; + }, + { + filter?: string | undefined; + title?: string | undefined; + path?: string | undefined; + }, + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + RouteRef, + 'core.routing.ref', + { + optional: true; + } + > + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + { + optional: true; + } + >, + {}, + 'entity-content', + undefined, + 'kubernetes' + >; + 'api:kubernetes/proxy': ExtensionDefinition< + {}, + {}, + ConfigurableExtensionDataRef, + {}, + 'api', + undefined, + 'proxy' + >; + 'api:kubernetes/auth-providers': ExtensionDefinition< + {}, + {}, + ConfigurableExtensionDataRef, + {}, + 'api', + undefined, + 'auth-providers' + >; + 'api:kubernetes/cluster-link-formatter': ExtensionDefinition< + {}, + {}, + ConfigurableExtensionDataRef, + {}, + 'api', + undefined, + 'cluster-link-formatter' + >; } >; export default _default; diff --git a/plugins/org/api-report-alpha.md b/plugins/org/api-report-alpha.md index be74cde141..d96825c601 100644 --- a/plugins/org/api-report-alpha.md +++ b/plugins/org/api-report-alpha.md @@ -4,7 +4,11 @@ ```ts import { BackstagePlugin } from '@backstage/frontend-plugin-api'; +import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api'; +import { Entity } from '@backstage/catalog-model'; +import { ExtensionDefinition } from '@backstage/frontend-plugin-api'; import { ExternalRouteRef } from '@backstage/frontend-plugin-api'; +import { default as React_2 } from 'react'; // @alpha (undocumented) const _default: BackstagePlugin< @@ -12,7 +16,132 @@ const _default: BackstagePlugin< { catalogIndex: ExternalRouteRef; }, - {} + { + 'entity-card:org/group-profile': ExtensionDefinition< + { + filter: string | undefined; + }, + { + filter?: string | undefined; + }, + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + > + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + { + optional: true; + } + >, + {}, + 'entity-card', + undefined, + 'group-profile' + >; + 'entity-card:org/members-list': ExtensionDefinition< + { + filter: string | undefined; + }, + { + filter?: string | undefined; + }, + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + > + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + { + optional: true; + } + >, + {}, + 'entity-card', + undefined, + 'members-list' + >; + 'entity-card:org/ownership': ExtensionDefinition< + { + filter: string | undefined; + }, + { + filter?: string | undefined; + }, + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + > + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + { + optional: true; + } + >, + {}, + 'entity-card', + undefined, + 'ownership' + >; + 'entity-card:org/user-profile': ExtensionDefinition< + { + filter: string | undefined; + }, + { + filter?: string | undefined; + }, + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + > + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + { + optional: true; + } + >, + {}, + 'entity-card', + undefined, + 'user-profile' + >; + } >; export default _default; diff --git a/plugins/scaffolder/api-report-alpha.md b/plugins/scaffolder/api-report-alpha.md index de0fc463a9..4025174c55 100644 --- a/plugins/scaffolder/api-report-alpha.md +++ b/plugins/scaffolder/api-report-alpha.md @@ -3,11 +3,16 @@ > 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 { BackstagePlugin } from '@backstage/frontend-plugin-api'; +import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api'; +import { ExtensionDefinition } from '@backstage/frontend-plugin-api'; import { ExternalRouteRef } from '@backstage/frontend-plugin-api'; import { FieldExtensionOptions } from '@backstage/plugin-scaffolder-react'; import type { FormProps as FormProps_2 } from '@rjsf/core'; import { FormProps as FormProps_3 } from '@backstage/plugin-scaffolder-react'; +import { IconComponent } from '@backstage/core-plugin-api'; import { LayoutOptions } from '@backstage/plugin-scaffolder-react'; import { PathParams } from '@backstage/core-plugin-api'; import { default as React_2 } from 'react'; @@ -37,7 +42,59 @@ const _default: BackstagePlugin< namespace: string; }>; }, - {} + { + 'api:scaffolder': ExtensionDefinition< + {}, + {}, + ConfigurableExtensionDataRef, + {}, + 'api', + undefined, + undefined + >; + 'page:scaffolder': ExtensionDefinition< + { + path: string | undefined; + }, + { + path?: string | undefined; + }, + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + > + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + RouteRef, + 'core.routing.ref', + { + optional: true; + } + >, + {}, + 'page', + undefined, + undefined + >; + 'nav-item:scaffolder': ExtensionDefinition< + {}, + {}, + ConfigurableExtensionDataRef< + { + title: string; + icon: IconComponent; + routeRef: RouteRef; + }, + 'core.nav-item.target', + {} + >, + {}, + 'nav-item', + undefined, + undefined + >; + } >; export default _default; diff --git a/plugins/search/api-report-alpha.md b/plugins/search/api-report-alpha.md index e6f91d6d19..8a47cb41fc 100644 --- a/plugins/search/api-report-alpha.md +++ b/plugins/search/api-report-alpha.md @@ -3,10 +3,17 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -import { AnyExtensionDataRef } from '@backstage/frontend-plugin-api'; +import { AnyApiFactory } from '@backstage/core-plugin-api'; +import { AnyRouteRefParams } from '@backstage/frontend-plugin-api'; import { BackstagePlugin } from '@backstage/frontend-plugin-api'; +import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api'; import { ExtensionDefinition } from '@backstage/frontend-plugin-api'; +import { ExtensionInput } from '@backstage/frontend-plugin-api'; +import { IconComponent } from '@backstage/core-plugin-api'; +import { default as React_2 } from 'react'; import { RouteRef } from '@backstage/frontend-plugin-api'; +import { SearchResultItemExtensionComponent } from '@backstage/plugin-search-react/alpha'; +import { SearchResultItemExtensionPredicate } from '@backstage/plugin-search-react/alpha'; // @alpha (undocumented) const _default: BackstagePlugin< @@ -14,7 +21,78 @@ const _default: BackstagePlugin< root: RouteRef; }, {}, - {} + { + 'api:search': ExtensionDefinition< + {}, + {}, + ConfigurableExtensionDataRef, + {}, + 'api', + undefined, + undefined + >; + 'nav-item:search': ExtensionDefinition< + {}, + {}, + ConfigurableExtensionDataRef< + { + title: string; + icon: IconComponent; + routeRef: RouteRef; + }, + 'core.nav-item.target', + {} + >, + {}, + 'nav-item', + undefined, + undefined + >; + 'page:search': ExtensionDefinition< + { + noTrack: boolean; + } & { + path: string | undefined; + }, + { + noTrack?: boolean | undefined; + } & { + path?: string | undefined; + }, + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + > + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + RouteRef, + 'core.routing.ref', + { + optional: true; + } + >, + { + items: ExtensionInput< + ConfigurableExtensionDataRef< + { + predicate?: SearchResultItemExtensionPredicate | undefined; + component: SearchResultItemExtensionComponent; + }, + 'search.search-result-list-item.item', + {} + >, + { + singleton: false; + optional: false; + } + >; + }, + 'page', + undefined, + undefined + >; + } >; export default _default; @@ -22,43 +100,72 @@ export default _default; export const searchApi: ExtensionDefinition< {}, {}, - never, - never, - string | undefined, - string | undefined, - string | undefined + ConfigurableExtensionDataRef, + {}, + 'api', + undefined, + undefined >; // @alpha (undocumented) export const searchNavItem: ExtensionDefinition< - { - title: string; - }, - { - title?: string | undefined; - }, - never, - never, - string | undefined, - string | undefined, - string | undefined + {}, + {}, + ConfigurableExtensionDataRef< + { + title: string; + icon: IconComponent; + routeRef: RouteRef; + }, + 'core.nav-item.target', + {} + >, + {}, + 'nav-item', + undefined, + undefined >; // @alpha (undocumented) export const searchPage: ExtensionDefinition< { - path: string; noTrack: boolean; + } & { + path: string | undefined; }, { - path: string; - noTrack: boolean; + noTrack?: boolean | undefined; + } & { + path?: string | undefined; }, - AnyExtensionDataRef, - {}, - string | undefined, - string | undefined, - string | undefined + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + RouteRef, + 'core.routing.ref', + { + optional: true; + } + >, + { + items: ExtensionInput< + ConfigurableExtensionDataRef< + { + predicate?: SearchResultItemExtensionPredicate | undefined; + component: SearchResultItemExtensionComponent; + }, + 'search.search-result-list-item.item', + {} + >, + { + singleton: false; + optional: false; + } + >; + }, + 'page', + undefined, + undefined >; // (No @packageDocumentation comment for this package) diff --git a/plugins/techdocs/api-report-alpha.md b/plugins/techdocs/api-report-alpha.md index f7c6679139..14a2400534 100644 --- a/plugins/techdocs/api-report-alpha.md +++ b/plugins/techdocs/api-report-alpha.md @@ -3,9 +3,19 @@ > 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 { AnyExtensionDataRef } from '@backstage/frontend-plugin-api'; +import { AnyRouteRefParams } from '@backstage/frontend-plugin-api'; import { BackstagePlugin } from '@backstage/frontend-plugin-api'; +import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api'; +import { Entity } from '@backstage/catalog-model'; import { ExtensionDefinition } from '@backstage/frontend-plugin-api'; +import { ExtensionInput } from '@backstage/frontend-plugin-api'; +import { IconComponent } from '@backstage/core-plugin-api'; +import { default as React_2 } from 'react'; import { RouteRef } from '@backstage/frontend-plugin-api'; +import { SearchResultItemExtensionComponent } from '@backstage/plugin-search-react/alpha'; +import { SearchResultItemExtensionPredicate } from '@backstage/plugin-search-react/alpha'; // @alpha (undocumented) const _default: BackstagePlugin< @@ -19,31 +29,182 @@ const _default: BackstagePlugin< entityContent: RouteRef; }, {}, - {} + { + 'nav-item:techdocs': ExtensionDefinition< + {}, + {}, + ConfigurableExtensionDataRef< + { + title: string; + icon: IconComponent; + routeRef: RouteRef; + }, + 'core.nav-item.target', + {} + >, + {}, + 'nav-item', + undefined, + undefined + >; + 'api:techdocs/storage': ExtensionDefinition< + {}, + {}, + ConfigurableExtensionDataRef, + {}, + 'api', + undefined, + 'storage' + >; + 'search-result-list-item:techdocs': ExtensionDefinition< + { + title: string | undefined; + lineClamp: number; + asLink: boolean; + asListItem: boolean; + } & { + noTrack: boolean; + }, + { + title?: string | undefined; + lineClamp?: number | undefined; + asListItem?: boolean | undefined; + asLink?: boolean | undefined; + } & { + noTrack?: boolean | undefined; + }, + ConfigurableExtensionDataRef< + { + predicate?: SearchResultItemExtensionPredicate | undefined; + component: SearchResultItemExtensionComponent; + }, + 'search.search-result-list-item.item', + {} + >, + { + [x: string]: ExtensionInput< + AnyExtensionDataRef, + { + optional: boolean; + singleton: boolean; + } + >; + }, + 'search-result-list-item', + undefined, + undefined + >; + 'page:techdocs/reader': ExtensionDefinition< + { + path: string | undefined; + }, + { + path?: string | undefined; + }, + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + > + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + RouteRef, + 'core.routing.ref', + { + optional: true; + } + >, + {}, + 'page', + undefined, + 'reader' + >; + 'entity-content:techdocs': ExtensionDefinition< + { + path: string | undefined; + title: string | undefined; + filter: string | undefined; + }, + { + filter?: string | undefined; + title?: string | undefined; + path?: string | undefined; + }, + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + > + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + RouteRef, + 'core.routing.ref', + { + optional: true; + } + > + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + (entity: Entity) => boolean, + 'catalog.entity-filter-function', + { + optional: true; + } + > + | ConfigurableExtensionDataRef< + string, + 'catalog.entity-filter-expression', + { + optional: true; + } + >, + {}, + 'entity-content', + undefined, + undefined + >; + } >; export default _default; // @alpha (undocumented) export const techDocsSearchResultListItemExtension: ExtensionDefinition< { + title: string | undefined; lineClamp: number; - noTrack: boolean; - asListItem: boolean; asLink: boolean; - title?: string | undefined; + asListItem: boolean; + } & { + noTrack: boolean; }, { - lineClamp: number; - noTrack: boolean; - asListItem: boolean; - asLink: boolean; title?: string | undefined; + lineClamp?: number | undefined; + asListItem?: boolean | undefined; + asLink?: boolean | undefined; + } & { + noTrack?: boolean | undefined; }, - never, - never, - string | undefined, - string | undefined, - string | undefined + ConfigurableExtensionDataRef< + { + predicate?: SearchResultItemExtensionPredicate | undefined; + component: SearchResultItemExtensionComponent; + }, + 'search.search-result-list-item.item', + {} + >, + { + [x: string]: ExtensionInput< + AnyExtensionDataRef, + { + optional: boolean; + singleton: boolean; + } + >; + }, + 'search-result-list-item', + undefined, + undefined >; // (No @packageDocumentation comment for this package) diff --git a/plugins/user-settings/api-report-alpha.md b/plugins/user-settings/api-report-alpha.md index 700e06a7ad..b79657cabc 100644 --- a/plugins/user-settings/api-report-alpha.md +++ b/plugins/user-settings/api-report-alpha.md @@ -3,8 +3,13 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts +import { AnyRouteRefParams } from '@backstage/frontend-plugin-api'; import { BackstagePlugin } from '@backstage/frontend-plugin-api'; +import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api'; import { ExtensionDefinition } from '@backstage/frontend-plugin-api'; +import { ExtensionInput } from '@backstage/frontend-plugin-api'; +import { IconComponent } from '@backstage/core-plugin-api'; +import { default as React_2 } from 'react'; import { RouteRef } from '@backstage/frontend-plugin-api'; import { TranslationRef } from '@backstage/core-plugin-api/alpha'; @@ -14,23 +19,86 @@ const _default: BackstagePlugin< root: RouteRef; }, {}, - {} + { + 'nav-item:user-settings': ExtensionDefinition< + {}, + {}, + ConfigurableExtensionDataRef< + { + title: string; + icon: IconComponent; + routeRef: RouteRef; + }, + 'core.nav-item.target', + {} + >, + {}, + 'nav-item', + undefined, + undefined + >; + 'page:user-settings': ExtensionDefinition< + { + [x: string]: any; + } & { + path: string | undefined; + }, + { + [x: string]: any; + } & { + path?: string | undefined; + }, + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + > + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + RouteRef, + 'core.routing.ref', + { + optional: true; + } + >, + { + providerSettings: ExtensionInput< + ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + >, + { + singleton: true; + optional: true; + } + >; + }, + 'page', + undefined, + undefined + >; + } >; export default _default; // @alpha (undocumented) export const settingsNavItem: ExtensionDefinition< - { - title: string; - }, - { - title?: string | undefined; - }, - never, - never, - string | undefined, - string | undefined, - string | undefined + {}, + {}, + ConfigurableExtensionDataRef< + { + title: string; + icon: IconComponent; + routeRef: RouteRef; + }, + 'core.nav-item.target', + {} + >, + {}, + 'nav-item', + undefined, + undefined >; // @alpha (undocumented) From c7603e839d28c14ca6bf62778ad76bcba0955fdf Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 15 Aug 2024 16:38:27 +0200 Subject: [PATCH 370/372] chore: added changeset Signed-off-by: blam --- .changeset/giant-buttons-guess.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .changeset/giant-buttons-guess.md diff --git a/.changeset/giant-buttons-guess.md b/.changeset/giant-buttons-guess.md new file mode 100644 index 0000000000..7a7842259e --- /dev/null +++ b/.changeset/giant-buttons-guess.md @@ -0,0 +1,14 @@ +--- +'@backstage/plugin-app-visualizer': patch +'@backstage/plugin-catalog-graph': patch +'@backstage/plugin-catalog-import': patch +'@backstage/plugin-catalog': patch +'@backstage/plugin-devtools': patch +'@backstage/plugin-org': patch +'@backstage/plugin-scaffolder': patch +'@backstage/plugin-search': patch +'@backstage/plugin-techdocs': patch +'@backstage/plugin-user-settings': patch +--- + +Deprecate the old pattern of `create*Extension`, and replace it with the equivalent Blueprint implementation instead From c894d8d2720c4a67d9319aa6aaa4c73e058bfe30 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 15 Aug 2024 17:00:57 +0200 Subject: [PATCH 371/372] chore: expose react types Signed-off-by: blam --- plugins/app-visualizer/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/app-visualizer/package.json b/plugins/app-visualizer/package.json index 6634f3cc1b..4efcf0faf0 100644 --- a/plugins/app-visualizer/package.json +++ b/plugins/app-visualizer/package.json @@ -38,11 +38,11 @@ "@backstage/core-plugin-api": "workspace:^", "@backstage/frontend-plugin-api": "workspace:^", "@material-ui/core": "^4.12.2", - "@material-ui/icons": "^4.9.1" + "@material-ui/icons": "^4.9.1", + "@types/react": "^16.13.1 || ^17.0.0" }, "devDependencies": { - "@backstage/cli": "workspace:^", - "@types/react": "^16.13.1 || ^17.0.0" + "@backstage/cli": "workspace:^" }, "peerDependencies": { "react": "^16.13.1 || ^17.0.0 || ^18.0.0", From 4490d733b503497ee91a1cae76f1419960237991 Mon Sep 17 00:00:00 2001 From: Sydney Achinger <78113809+squid-ney@users.noreply.github.com> Date: Thu, 15 Aug 2024 14:34:15 -0400 Subject: [PATCH 372/372] Redirect: Add documentation. Cleanup (#26041) * Add documentation. Cleanup. Add guardrail not to redirect to current url. --------- Signed-off-by: Sydney Achinger --- .changeset/pink-bobcats-explain.md | 5 ++ docs/features/techdocs/how-to-guides.md | 5 ++ .../TechDocsReaderPageContent/dom.tsx | 2 +- .../TechDocsRedirectNotification.tsx | 67 ++++++++++++++++++ .../TechDocsRedirectNotification/index.ts | 17 +++++ .../transformers/handleMetaRedirects.test.ts | 4 +- .../transformers/handleMetaRedirects.tsx | 70 +++++-------------- .../techdocs/src/reader/transformers/index.ts | 1 + 8 files changed, 115 insertions(+), 56 deletions(-) create mode 100644 .changeset/pink-bobcats-explain.md create mode 100644 plugins/techdocs/src/reader/components/TechDocsRedirectNotification/TechDocsRedirectNotification.tsx create mode 100644 plugins/techdocs/src/reader/components/TechDocsRedirectNotification/index.ts diff --git a/.changeset/pink-bobcats-explain.md b/.changeset/pink-bobcats-explain.md new file mode 100644 index 0000000000..0274e55369 --- /dev/null +++ b/.changeset/pink-bobcats-explain.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs': patch +--- + +Refactor TechDocs' mkdocs-redirects support. diff --git a/docs/features/techdocs/how-to-guides.md b/docs/features/techdocs/how-to-guides.md index 3a7cfd97bb..59198e919b 100644 --- a/docs/features/techdocs/how-to-guides.md +++ b/docs/features/techdocs/how-to-guides.md @@ -841,3 +841,8 @@ metadata: annotations: backstage.io/techdocs-entity: system:default/example ``` + +## How to resolve broken links from moved or renamed pages in your documentation site + +TechDocs supports using the [mkdocs-redirects](https://github.com/mkdocs/mkdocs-redirects/tree/master) plugin to create a redirect map for any TechDocs site. This allows broken links from renamed or moved pages in your site to be redirected to their specified replacement. +TechDocs will notify the user that the page they are trying to access is no longer maintained. Then, they will be redirected. External site redirects are not supported. If an external redirect is provided, the user will instead be redirected to the index page of the documentation site. diff --git a/plugins/techdocs/src/reader/components/TechDocsReaderPageContent/dom.tsx b/plugins/techdocs/src/reader/components/TechDocsReaderPageContent/dom.tsx index c686827255..28090cb62c 100644 --- a/plugins/techdocs/src/reader/components/TechDocsReaderPageContent/dom.tsx +++ b/plugins/techdocs/src/reader/components/TechDocsReaderPageContent/dom.tsx @@ -44,9 +44,9 @@ import { copyToClipboard, useSanitizerTransformer, useStylesTransformer, + handleMetaRedirects, } from '../../transformers'; import { useNavigateUrl } from './useNavigateUrl'; -import { handleMetaRedirects } from '../../transformers/handleMetaRedirects'; const MOBILE_MEDIA_QUERY = 'screen and (max-width: 76.1875em)'; diff --git a/plugins/techdocs/src/reader/components/TechDocsRedirectNotification/TechDocsRedirectNotification.tsx b/plugins/techdocs/src/reader/components/TechDocsRedirectNotification/TechDocsRedirectNotification.tsx new file mode 100644 index 0000000000..b233549b9e --- /dev/null +++ b/plugins/techdocs/src/reader/components/TechDocsRedirectNotification/TechDocsRedirectNotification.tsx @@ -0,0 +1,67 @@ +/* + * Copyright 2024 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 { makeStyles } from '@material-ui/core/styles'; +import React, { useState } from 'react'; +import Snackbar from '@material-ui/core/Snackbar'; +import Button from '@material-ui/core/Button'; + +type TechDocsRedirectNotificationProps = { + handleButtonClick: () => void; + message: string; + autoHideDuration: number; +}; + +const useStyles = makeStyles(theme => ({ + button: { + color: theme.palette.primary.light, + textDecoration: 'underline', + }, +})); + +export const TechDocsRedirectNotification = ({ + message, + handleButtonClick, + autoHideDuration, +}: TechDocsRedirectNotificationProps) => { + const classes = useStyles(); + const [open, setOpen] = useState(true); + + const handleClose = () => setOpen(false); + + return ( + { + handleClose(); + handleButtonClick(); + }} + > + Redirect now + + } + /> + ); +}; diff --git a/plugins/techdocs/src/reader/components/TechDocsRedirectNotification/index.ts b/plugins/techdocs/src/reader/components/TechDocsRedirectNotification/index.ts new file mode 100644 index 0000000000..fe94a25bd6 --- /dev/null +++ b/plugins/techdocs/src/reader/components/TechDocsRedirectNotification/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2024 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 { TechDocsRedirectNotification } from './TechDocsRedirectNotification'; diff --git a/plugins/techdocs/src/reader/transformers/handleMetaRedirects.test.ts b/plugins/techdocs/src/reader/transformers/handleMetaRedirects.test.ts index 12a552577a..0be1773846 100644 --- a/plugins/techdocs/src/reader/transformers/handleMetaRedirects.test.ts +++ b/plugins/techdocs/src/reader/transformers/handleMetaRedirects.test.ts @@ -82,7 +82,9 @@ describe('handleMetaRedirects', () => { ), ).toBeInTheDocument(); jest.runAllTimers(); - expect(navigate).toHaveBeenCalledWith('/docs/default/component/testEntity'); + expect(navigate).toHaveBeenCalledWith( + 'http://localhost/docs/default/component/testEntity', + ); }); it('should navigate to absolute URL if meta redirect tag is present and not external', async () => { diff --git a/plugins/techdocs/src/reader/transformers/handleMetaRedirects.tsx b/plugins/techdocs/src/reader/transformers/handleMetaRedirects.tsx index 2d74f4cbf5..04b7b27ba2 100644 --- a/plugins/techdocs/src/reader/transformers/handleMetaRedirects.tsx +++ b/plugins/techdocs/src/reader/transformers/handleMetaRedirects.tsx @@ -16,64 +16,19 @@ import { Transformer } from './transformer'; import { normalizeUrl } from './rewriteDocLinks'; -import Snackbar from '@material-ui/core/Snackbar'; -import React, { useState } from 'react'; +import React from 'react'; import { renderReactElement } from './renderReactElement'; -import Button from '@material-ui/core/Button'; -import { makeStyles } from '@material-ui/core/styles'; - -type RedirectNotificationProps = { - handleButtonClick: () => void; - message: string; - autoHideDuration: number; -}; - -const useStyles = makeStyles(theme => ({ - button: { - color: theme.palette.primary.light, - textDecoration: 'underline', - }, -})); -const RedirectNotification = ({ - message, - handleButtonClick, - autoHideDuration, -}: RedirectNotificationProps) => { - const classes = useStyles(); - const [open, setOpen] = useState(true); - const handleClose = () => { - setOpen(prev => !prev); - }; - - return ( - - Redirect now - - } - /> - ); -}; +import { TechDocsRedirectNotification } from '../components/TechDocsRedirectNotification'; export const handleMetaRedirects = ( navigate: (to: string) => void, entityName: string, ): Transformer => { - const redirectAfterMs = 4000; + const redirectAfterMs = 3000; + const determineRedirectURL = (metaUrl: string) => { const normalizedCurrentUrl = normalizeUrl(window.location.href); - // If metaUrl is relative, it will be resolved with base href. If it is absolute, it will replace the base href when creating URL object. + // When creating URL object, if the metaUrl is relative, it will be resolved with base href. If it is absolute, it will replace the base href. const absoluteRedirectObj = new URL(metaUrl, normalizedCurrentUrl); const isExternalRedirect = absoluteRedirectObj.hostname !== window.location.hostname; @@ -85,9 +40,8 @@ export const handleMetaRedirects = ( 0, indexOfSiteHome + entityName.length, ); - return siteHomePath; + return new URL(siteHomePath, normalizedCurrentUrl).href; } - // The navigate function from dom.tsx is a wrapper around react-router navigate function that helps absolute url redirects. return absoluteRedirectObj.href; }; @@ -97,15 +51,23 @@ export const handleMetaRedirects = ( const metaContentParameters = elem .getAttribute('content') ?.split('url='); + if (!metaContentParameters || metaContentParameters.length < 2) { - continue; + return dom; } + const metaUrl = metaContentParameters[1]; const redirectURL = determineRedirectURL(metaUrl); + + // If the current URL is the same as the redirect URL, do not proceed with the redirect. + if (window.location.href === redirectURL) { + return dom; + } + const container = document.createElement('div'); renderReactElement( - navigate(redirectURL)} autoHideDuration={redirectAfterMs} diff --git a/plugins/techdocs/src/reader/transformers/index.ts b/plugins/techdocs/src/reader/transformers/index.ts index 7df98f1f26..7fdf47b009 100644 --- a/plugins/techdocs/src/reader/transformers/index.ts +++ b/plugins/techdocs/src/reader/transformers/index.ts @@ -27,3 +27,4 @@ export * from './simplifyMkdocsFooter'; export * from './onCssReady'; export * from './scrollIntoNavigation'; export * from './transformer'; +export * from './handleMetaRedirects';