Merge branch 'master' into add-sans-institute-to-adopters

This commit is contained in:
Christopher Klewin
2022-06-13 09:17:15 -04:00
committed by GitHub
87 changed files with 2130 additions and 528 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-cost-insights': patch
---
In the README, a old path of the `sidebar` was updated to the current path.
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-user-settings': patch
---
Added new `<UserSettingsIdentityCard />` to show the result of the `identityApi.getBackstageIdentity()` call to help debug ownership issues. The new card has been added to the user settings page.
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-react': patch
---
Table component no longer has drag and drop columns by default
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-dynatrace': minor
---
Adds Dynatrace plugin
+50
View File
@@ -0,0 +1,50 @@
---
'@backstage/create-app': patch
---
It's now possible to pass result item components a `rank`, which is captured by the analytics API when a user clicks on a search result. To apply this change, update your `/packages/app/src/components/search/SearchPage.tsx` in the following way:
```diff
// ...
<SearchResult>
{({ results }) => (
<List>
- {results.map(({ type, document, highlight }) => {
+ {results.map(({ type, document, highlight, rank }) => {
switch (type) {
case 'software-catalog':
return (
<CatalogSearchResultListItem
key={document.location}
result={document}
highlight={highlight}
+ rank={rank}
/>
);
case 'techdocs':
return (
<TechDocsSearchResultListItem
key={document.location}
result={document}
highlight={highlight}
+ rank={rank}
/>
);
default:
return (
<DefaultResultListItem
key={document.location}
result={document}
highlight={highlight}
+ rank={rank}
/>
);
}
})}
</List>
)}
</SearchResult>
// ...
```
If you have implemented a custom Search Modal or other custom search experience, you will want to make similar changes in those components.
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-search-common': patch
---
Added an optional `rank` attribute to the `Result` type. This represents the result rank (starting at 1) for a given result in a result set for a given search.
+8
View File
@@ -0,0 +1,8 @@
---
'@backstage/plugin-search-backend': patch
'@backstage/plugin-search-backend-module-elasticsearch': patch
'@backstage/plugin-search-backend-module-pg': patch
'@backstage/plugin-search-backend-node': patch
---
The provided search engine now adds a pagination-aware `rank` value to all results.
+7
View File
@@ -0,0 +1,7 @@
---
'@backstage/plugin-catalog': patch
'@backstage/plugin-search': patch
'@backstage/plugin-techdocs': patch
---
In order to simplify analytics on top of the search experience in Backstage, the provided `<*ResultListItem />` component now captures a `discover` analytics event instead of a `click` event. This event includes the result rank as its `value` and, like a click, the URL/path clicked to as its `to` attribute.
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/create-app': patch
---
Updated the auth backend setup in the template to include a guest sign-in resolver in order to make it quicker to get up and running with a basic sign-in setup. There is no need to update existing apps to match this change, but in case you want to use the guest sign-in resolver you can find it at https://backstage.io/docs/auth/identity-resolver#guest-sign-in-resolver
+8
View File
@@ -0,0 +1,8 @@
---
'@backstage/plugin-tech-insights-backend': patch
'@backstage/plugin-tech-insights-node': patch
---
Introduce additional JsonValue types to be storable as facts. This enables the possibility to store more complex objects for fact checking purposes. The rules engine supports walking keyed object values directly to create rules and checks
Modify facts database table to have a more restricted timestamp precision for cases where the postgres server isn't configured to contain such value. This fixes the issue where in some cases `maxItems` lifecycle condition didn't work as expected.
+3
View File
@@ -85,6 +85,8 @@ dockerfiles
Dockerize
dockerode
Docusaurus
dynatrace
Dynatrace
ecco
env
Env
@@ -302,6 +304,7 @@ superfences
Superfences
superset
supertype
storable
talkdesk
Talkdesk
tasklist
+1
View File
@@ -159,4 +159,5 @@ _If you're using Backstage in your organization, please try to add your company
| [Doctolib](https://doctolib.engineering/) | [@djiit](https://github.com/djiit) | Rails modularization effort awareness, tech organization discoverability. Improving the daily workflows and collaboration processes of our engineers. |
| [Twilio](https://www.twilio.com) | [Kyle Smith](https://github.com/knksmith57) | Developer portal, universal software catalog, and centralized taxonomy platform. |
| [OVHcloud](https://www.ovhcloud.com/fr/) | [Jean-Philippe Blary](https://github.com/blaryjp), [Arnaud Bauer](mailto:arnaud.bauer@ovhcloud.com), [Flavien Chantelot](https://github.com/Dorn-) | We're providing Backstage to our collaborators to ease their daily jobs, and let them extends it using plugins. |
| [Procter & Gamble](https://us.pg.com/) | [Binita Nayak](https://github.com/binitan), [Josh Rose](https://github.com/joshuarose), [RJ Winkler](https://github.com/rjwink) | P&G leverages Backstage to build internal developer portal to ensure developers' happiness. This developer portal shall act as single source of information needed by development teams to seamlessly create, find and maintain their software components/resources/documentation. |
| [SANS Institute](https://www.sans.org) | [Christopher Klewin](mailto:cklewin@sans.org) | Developer portal for centralized visibility, reporting, and tooling across multiple organizations. |
+8
View File
@@ -115,6 +115,11 @@ proxy:
headers:
Authorization: Basic ${GOCD_AUTH_CREDENTIALS}
'/dynatrace':
target: https://your.dynatrace.instance.com/api/v2
headers:
Authorization: 'Api-Token ${DYNATRACE_ACCESS_TOKEN}'
organization:
name: My Company
@@ -131,6 +136,9 @@ techdocs:
publisher:
type: 'local' # Alternatives - 'googleGcs' or 'awsS3' or 'azureBlobStorage' or 'openStackSwift'. Read documentation for using alternatives.
dynatrace:
baseUrl: https://your.dynatrace.instance.com
sentry:
organization: my-company
+179 -98
View File
@@ -1,9 +1,113 @@
---
id: add-auth-provider
title: Adding authentication providers
description: Documentation on Adding authentication providers
title: Contributing New Providers
description: Documentation on adding new authentication providers
---
> NOTE: The primary audience for this documentation are contributors to the main
> Backstage project that want to add support for new authentication providers.
> While you can follow it to implement your own custom providers it is much
> more advanced than using our built-in providers.
## How Does Authentication Work?
The Backstage application can use various external authentication providers for
authentication. An external provider is wrapped using an
`AuthProviderRouteHandlers` interface for handling authentication. This
interface consists of four methods. Each of these methods is hosted at an
endpoint (by default) `/api/auth/[provider]/method`, where `method` performs a
certain operation as follows:
```
/auth/[provider]/start -> Initiate a login from the web page
/auth/[provider]/handler/frame -> Handle a finished authentication operation
/auth/[provider]/refresh -> Refresh the validity of a login
/auth/[provider]/logout -> Log out a logged-in user
```
The flow is as follows:
1. A user attempts to sign in.
2. A popup window is opened, pointing to the `auth` endpoint. That endpoint does
initial preparations and then re-directs the user to an external
authenticator, still inside the popup.
3. The authenticator validates the user and returns the result of the validation
(success OR failure), to the wrapper's endpoint (`handler/frame`).
4. The `handler/frame` rendered webpage will issue the appropriate response to
the webpage that opened the popup window, and the popup is closed.
5. The user signs out by clicking on a UI interface and the webpage makes a
request to logout the user.
## Implementing Your Own Auth Wrapper
The core interface of any auth wrapper is the `AuthProviderRouteHandlers`
interface. This interface has four methods corresponding to the API described in
the initial section. Any auth wrapper will have to implement this interface.
When initiating a login, a pop-up window is created by the frontend, to allow
the user to initiate a login. This login request is done to the `/start`
endpoint which is handled by the `start` method.
The `start` method re-directs to the external auth provider who authenticates
the request and re-directs the request to the `/frame/handler` endpoint, which
is handled by the `frameHandler` method.
The `frameHandler` returns an HTML response, containing a script that does a
`postMessage` to the frontend window, containing the result of the request.
The `WebMessageResponse` type is the message sent by the `postMessage` to the
frontend.
A `postMessageResponse` utility function wraps the logic of generating a
`postMessage` response that ensures that CORS is successfully handled. This
function takes an `express.Response`, a `WebMessageResponse` and the URL of the
frontend (`appOrigin`) as parameters and return an HTML page with the script and
the message.
There is a helper class for [OAuth2](https://oauth.net/2/) based authentication providers, [OAuthAdapter](../reference/plugin-auth-backend.oauthadapter.md). This class implements the `AuthProviderRouteHandlers` interface
for you, and instead requires you to implement [OAuthHandlers](../reference/plugin-auth-backend.oauthhandlers.md), which
is significantly easier.
### Auth Environment Separation
The concept of an `env` is core to the way the auth backend works. It uses an
`env` query parameter to identify the environment in which the application is
running (`development`, `staging`, `production`, etc). Each runtime can
simultaneously support multiple environments at the same time and the right
handler for each request is identified and dispatched to, based on the `env`
parameter.
`OAuthEnvironmentHandler` is a utility wrapper for an `OAuthHandlers` that
implements the `AuthProviderRouteHandlers` interface while supporting multiple
`env`s.
To instantiate OAuth providers (the same but for different environments), use
`OAuthEnvironmentHandler.mapConfig`. It's a helper to iterate over a
configuration object that is a map of environments to configurations. See one of
the existing OAuth providers for an example of how it is used.
Given the following configuration:
```yaml
development:
clientId: abc
clientSecret: secret
production:
clientId: xyz
clientSecret: supersecret
```
The `OAuthEnvironmentHandler.mapConfig(config, envConfig => ...)` call will
split the config by the top level `development` and `production` keys, and pass
on each block as `envConfig`.
For convenience, the `AuthProviderFactory` is a factory function that has to be
implemented which can then generate a `AuthProviderRouteHandlers` for a given
provider.
All of the supported providers provide an `AuthProviderFactory` that returns an
`OAuthEnvironmentHandler`, capable of handling authentication for multiple
environments.
## Passport
We chose [Passport](http://www.passportjs.org/) as our authentication platform
@@ -46,13 +150,13 @@ plugins/auth-backend/src/providers/providerA
**`plugins/auth-backend/src/providers/providerA/provider.ts`** defines the
provider class which implements a handler for the chosen framework.
#### Adding an OAuth based provider
### Adding an OAuth based provider
If we're adding an `OAuth` based provider we would implement the
[OAuthProviderHandlers](#OAuthProviderHandlers) interface. By implementing this
`OAuthHandlers` interface. By implementing this
interface we can use the `OAuthProvider` class provided by `lib/oauth`, meaning
we don't need to implement the full
[AuthProviderRouteHandlers](#AuthProviderRouteHandlers) interface that providers
`AuthProviderRouteHandlers` interface that providers
otherwise need to implement.
The provider class takes the provider's options as a class parameter. It also
@@ -65,7 +169,7 @@ export type ProviderAProviderOptions = OAuthProviderOptions & {
// extra options here
}
export class ProviderAAuthProvider implements OAuthProviderHandlers {
export class ProviderAAuthProvider implements OAuthHandlers {
private readonly _strategy: ProviderAStrategy;
constructor(options: ProviderAProviderOptions) {
@@ -87,13 +191,10 @@ export class ProviderAAuthProvider implements OAuthProviderHandlers {
}
```
#### Adding an non-OAuth based provider
_**Note**: We have prioritized OAuth-based providers and non-OAuth providers
should be considered experimental._
### Adding an non-OAuth based provider
An non-`OAuth` based provider could implement
[AuthProviderRouteHandlers](#AuthProviderRouteHandlers) instead.
`AuthProviderRouteHandlers` instead.
```ts
type ProviderAOptions = {
@@ -119,13 +220,19 @@ export class ProviderAAuthProvider implements AuthProviderRouteHandlers {
}
```
#### Factory function
#### Integration Wrapper
Each provider exports a factory function that instantiates the provider. The
factory should implement [AuthProviderFactory](#AuthProviderFactory), which
Each provider exports an object that provides a way to create new instances
of the provider, along with related utilities like predefined sign-in resolvers.
The object is created using `createAuthProviderIntegration`, with the most
important part being the `create` method that acts as the factory function
for our provider.
The factory should return an implementation of `AuthProviderFactory`, which
passes in a object with utilities for configuration, logging, token issuing,
etc. The factory should return an implementation of
[AuthProviderRouteHandlers](#AuthProviderRouteHandlers).
`AuthProviderRouteHandlers`.
The factory is what decides the mapping from
[static configuration](../conf/index.md) to the creation of auth providers. For
@@ -133,48 +240,70 @@ example, OAuth providers use `OAuthEnvironmentHandler` to allow for multiple
different configurations, one for each environment, which looks like this;
```ts
export const createOktaProvider: AuthProviderFactory = ({
globalConfig,
config,
tokenIssuer,
}) =>
OAuthEnvironmentHandler.mapConfig(config, envConfig => {
// read options from config
const clientId = envConfig.getString('clientId');
const clientSecret = envConfig.getString('clientSecret');
export const okta = createAuthProviderIntegration({
create(options?: {
/**
* The profile transformation function used to verify and convert the auth response
* into the profile that will be presented to the user.
*/
authHandler?: AuthHandler<OAuthResult>;
// instantiate our OAuthProviderHandlers implementation
const provider = new OktaAuthProvider({
audience,
clientId,
clientSecret,
callbackUrl,
});
/**
* Configure sign-in for this provider, without it the provider can not be used to sign users in.
*/
signIn?: {
/**
* Maps an auth result to a Backstage identity for the user.
*/
resolver: SignInResolver<OAuthResult>;
};
}) {
return ({ providerId, globalConfig, config, resolverContext }) =>
OAuthEnvironmentHandler.mapConfig(config, envConfig => {
// read options from config
const clientId = envConfig.getString('clientId');
const clientSecret = envConfig.getString('clientSecret');
// Wrap the OAuthProviderHandlers with OAuthProvider, which implements AuthProviderRouteHandlers
return OAuthProvider.fromConfig(globalConfig, provider, {
providerId,
tokenIssuer,
});
});
// Use provided auth handler, or create a default one
const authHandler: AuthHandler<OAuthResult> = options?.authHandler
? options.authHandler
: async ({ fullProfile, params }) => ({
profile: makeProfileInfo(fullProfile, params.id_token),
});
// instantiate our OAuthHandlers implementation
const provider = new OktaAuthProvider({
audience,
clientId,
clientSecret,
callbackUrl,
authHandler,
signInResolver: options?.signIn?.resolver,
resolverContext,
});
// Wrap the OAuthHandlers with OAuthProvider, which implements AuthProviderRouteHandlers
return OAuthProvider.fromConfig(globalConfig, provider, {
providerId,
tokenIssuer,
});
});
},
resolvers: {
/**
* Looks up the user by matching their email local part to the entity name.
*/
emailLocalPartMatchingUserEntityName: () => commonByEmailLocalPartResolver,
// ... additional predefined resolvers
},
});
```
The purpose of the different environments is to allow for a single auth-backend
to serve as the authentication service for multiple different frontend
environments, such as local development, staging, and production.
The factory function for other providers can be a lot simpler, as they might not
have configuration for each environment. Looking something like this:
```ts
export const createProviderAProvider: AuthProviderFactory = ({ config }) => {
const a = config.getString('a');
const b = config.getString('b');
return new ProviderAAuthProvider({ a, b });
};
```
#### Verify Callback
> Strategies require what is known as a verify callback. The purpose of a verify
@@ -202,7 +331,7 @@ export { createProviderAProvider } from './provider';
**`plugins/auth-backend/src/providers/factories.ts`** When the `auth-backend`
starts it sets up routing for all the available providers by calling
`createAuthProviderRouter` on each provider. You need to import the factory
the factory function of each provider. You need to import the factory
function from the provider and add it to the factory:
```ts
@@ -232,51 +361,3 @@ You can `curl -i localhost:7007/api/auth/providerA/start` and which should
provide a `302` redirect with a `Location` header. Paste the URL from that
header into a web browser and you should be able to trigger the authorization
flow.
---
##### OAuthProviderHandlers
```ts
export interface OAuthProviderHandlers {
start(
req: express.Request,
options: Record<string, string>,
): Promise<RedirectInfo>;
handler(req: express.Request): Promise<{
response: AuthResponse<OAuthProviderInfo>;
refreshToken?: string;
}>;
refresh?(
refreshToken: string,
scope: string,
): Promise<AuthResponse<OAuthProviderInfo>>;
logout?(): Promise<void>;
}
```
##### AuthProviderRouteHandlers
```ts
export interface AuthProviderRouteHandlers {
start(req: express.Request, res: express.Response): Promise<any>;
frameHandler(req: express.Request, res: express.Response): Promise<any>;
refresh?(req: express.Request, res: express.Response): Promise<any>;
logout(req: express.Request, res: express.Response): Promise<any>;
}
```
##### AuthProviderFactory
```ts
export type AuthProviderFactoryOptions = {
globalConfig: AuthProviderConfig;
config: Config;
logger: Logger;
tokenIssuer: TokenIssuer;
};
export type AuthProviderFactory = (
options: AuthProviderFactoryOptions,
) => AuthProviderRouteHandlers;
```
-206
View File
@@ -1,206 +0,0 @@
---
id: auth-backend-classes
title: Auth backend classes
description: Documentation on Auth backend classes
---
## How Does Authentication Work?
The Backstage application can use various external authentication providers for
authentication. An external provider is wrapped using an
`AuthProviderRouteHandlers` interface for handling authentication. This
interface consists of four methods. Each of these methods is hosted at an
endpoint (by default) `/api/auth/[provider]/method`, where `method` performs a
certain operation as follows:
```
/auth/[provider]/start -> Initiate a login from the web page
/auth/[provider]/handler/frame -> Handle a finished authentication operation
/auth/[provider]/refresh -> Refresh the validity of a login
/auth/[provider]/logout -> Log out a logged-in user
```
The flow is as follows:
1. A user attempts to sign in.
2. A popup window is opened, pointing to the `auth` endpoint. That endpoint does
initial preparations and then re-directs the user to an external
authenticator, still inside the popup.
3. The authenticator validates the user and returns the result of the validation
(success OR failure), to the wrapper's endpoint (`handler/frame`).
4. The `handler/frame` rendered b´webpage will issue the appropriate response to
the webpage that opened the popup window, and the popup is closed.
5. The user signs out by clicking on a UI interface and the webpage makes a
request to logout the user.
There are currently two different classes for two authentication mechanisms that
implement this interface: an `OAuthAdapter` for [OAuth](https://oauth.net/2/)
based mechanisms and a `SAMLAuthProvider` for
[SAML](http://docs.oasis-open.org/security/saml/Post2.0/sstc-saml-tech-overview-2.0.html).
If you do not have an `OAuth2` or `SAML` based authentication provider, look in
the section [below](#implementing-your-own-auth-wrapper).
### OAuth Mechanisms
For more information on how these methods are used and for which purpose, refer
to the [OAuth documentation](oauth.md).
Currently OAuth is assumed to be the de facto authentication mechanism for
Backstage based applications.
Backstage comes with a "batteries-included" set of supported commonly used OAuth
providers: Okta, GitHub, Google, GitLab, and a generic OAuth2 provider. For a
list of available providers, look at the available wrappers in
`backstage/plugins/auth-backend/src/providers/`.
All of these use the **authorization flow** of OAuth2 to implement
authentication.
If your authentication provider is any of the above mentioned providers, you can
configure them by setting the right variables in `app-config.yaml` under the
`auth` section.
### SAML
The SAML Provider is currently under development. Additional validation and
profile handling is still required before use in production.
To configure the SAML Auth provider, look at the configuration parameters
supported by
[Passport-SAML](https://github.com/node-saml/passport-saml#config-parameter-details)
under the `auth.providers.saml` key
For security reasons, validate that the response from the IdP is indeed signed
by also providing the `cert` configuration.
### Configuration
Each authentication provider (except SAML) needs six parameters: an OAuth client
ID, a client secret, an authorization endpoint, a token endpoint, an optional
list of scopes (as a string separated by spaces) that may be required by the
OAuth2 Server to enable end-user sign-on, and an app origin. The app origin is
the URL at which the frontend of the application is hosted, and it is read from
the `app.baseUrl` config. This is required because the application opens a popup
window to perform the authentication, and once the flow is completed, the popup
window sends a `postMessage` to the frontend application to indicate the result
of the operation. Also this URL is used to verify that authentication requests
are coming from only this endpoint.
These values are configured via the `app-config.yaml` present in the root of
your app folder.
```
auth:
providers:
google:
development:
clientId: ${AUTH_GOOGLE_CLIENT_ID}
clientSecret: ${AUTH_GOOGLE_CLIENT_SECRET}
github:
development:
clientId: ${AUTH_GITHUB_CLIENT_ID}
clientSecret: ${AUTH_GITHUB_CLIENT_SECRET}
enterpriseInstanceUrl: ${AUTH_GITHUB_ENTERPRISE_INSTANCE_URL}
gitlab:
development:
clientId: ${AUTH_GITLAB_CLIENT_ID}
oauth2:
development:
clientId: ${AUTH_OAUTH2_CLIENT_ID}
clientSecret: ${AUTH_OAUTH2_CLIENT_SECRET}
authorizationUrl: ${AUTH_OAUTH2_AUTH_URL}
tokenUrl: ${AUTH_OAUTH2_TOKEN_URL}
scope: ${AUTH_OAUTH2_SCOPE}
saml:
entryPoint: ${AUTH_SAML_ENTRY_POINT}
issuer: ${AUTH_SAML_ISSUER}
...
```
## Implementing Your Own Auth Wrapper
The core interface of any auth wrapper is the `AuthProviderRouteHandlers`
interface. This interface has four methods corresponding to the API described in
the initial section. Any auth wrapper will have to implement this interface.
When initiating a login, a pop-up window is created by the frontend, to allow
the user to initiate a login. This login request is done to the `/start`
endpoint which is handled by the `start` method.
The `start` method re-directs to the external auth provider who authenticates
the request and re-directs the request to the `/frame/handler` endpoint, which
is handled by the `frameHandler` method.
The `frameHandler` returns an HTML response, containing a script that does a
`postMessage` to the frontend's window, containing the result of the request.
The `WebMessageResponse` type is the message sent by the `postMessage` to the
frontend.
A `postMessageResponse` utility function wraps the logic of generating a
`postMessage` response that ensures that CORS is successfully handled. This
function takes an `express.Response`, a `WebMessageResponse` and the URL of the
frontend (`appOrigin`) as parameters and return an HTML page with the script and
the message.
### OAuth Wrapping Interfaces.
Each OAuth external provider is supported by a corresponding
[Passport](https://github.com/jaredhanson/passport) strategy. For a generic
OAuth2 provider, passport has a `passport-oauth2` strategy. The strategy class
handles the implementation details of working with each provider.
Each strategy is wrapped by an `OAuthHandlers` interface.
This interface cannot be directly used as an Express HTTP request handler. To do
so, `OAuthHandlers` are wrapped in an `OAuthAdapter`, which implements the
`AuthProviderRouterHandlers` interface.
#### Env
The concept of an `env` is core to the way the auth backend works. It uses an
`env` query parameter to identify the environment in which the application is
running (`development`, `staging`, `production`, etc). Each runtime can
simultaneously support multiple environments at the same time and the right
handler for each request is identified and dispatched to, based on the `env`
parameter.
`OAuthEnvironmentHandler` is a utility wrapper for an `OAuthHandlers` that
implements the `AuthProviderRouteHandlers` interface while supporting multiple
`env`s.
To instantiate OAuth providers (the same but for different environments), use
`OAuthEnvironmentHandler.mapConfig`. It's a helper to iterate over a
configuration object that is a map of environments to configurations. See one of
the existing OAuth providers for an example of how it is used.
Given the following configuration:
```yaml
development:
clientId: abc
clientSecret: secret
production:
clientId: xyz
clientSecret: supersecret
```
The `OAuthEnvironmentHandler.mapConfig(config, envConfig => ...)` call will
split the config by the top level `development` and `production` keys, and pass
on each block as `envConfig`.
For convenience, the `AuthProviderFactory` is a factory function that has to be
implemented which can then generate a `AuthProviderRouteHandlers` for a given
provider.
All of the supported providers provide an `AuthProviderFactory` that returns an
`OAuthEnvironmentHandler`, capable of handling authentication for multiple
environments.
### OAuth2 Provider
The `oauth2` provider abstracts a generic **OAuth2 + OIDC** based authentication
provider. What this means is that after the application has been given
permission by the user, the `authorization code` will be exchanged for an
`access_token`, a `refresh_token` and an `id_token`. This `id_token` is used to
obtain an email id of the user, which is then used for creating the session.
+28
View File
@@ -12,6 +12,34 @@ If you want to use an auth provider to sign in users, you need to explicitly con
it have sign-in enabled and also tell it how the external identities should
be mapped to user identities within Backstage.
## Guest Sign-In Resolver
Backstage projects created with `npx @backstage/create-app` come configured with a
sign-in resolver for GitHub guest access. This resolver makes all users share
a single "guest" identity and is only intended as a minimum requirement to quickly
get up and running. You can replace `github` for any of the other providers if you need.
This resolver should not be used in production, as it uses a single shared identity,
and has no restrictions on who is able to sign-in. Be sure to read through the rest
of this page to understand the Backstage identity system once you need to install
a resolver for your production environment.
The guest resolver can be useful for testing purposes too, and it looks like this:
```ts
signIn: {
resolver(_, ctx) {
const userRef = 'user:default/guest'
return ctx.issueToken({
claims: {
sub: userRef,
ent: [userRef],
},
}),
},
},
```
## Backstage User Identity
A user identity within Backstage is built up from two pieces of information, a
+20 -17
View File
@@ -6,7 +6,7 @@ description: Adding OAuth2Proxy as an authentication provider in Backstage
---
The Backstage `@backstage/plugin-auth-backend` package comes with an
`oauth2proxy` authentication provider that can authenticate users by using a
`oauth2Proxy` authentication provider that can authenticate users by using a
[oauth2-proxy](https://github.com/oauth2-proxy/oauth2-proxy) in front of an
actual Backstage instance. This enables to reuse existing authentications within
a cluster. In general the `oauth2-proxy` supports all OpenID Connect providers,
@@ -21,17 +21,17 @@ The provider configuration can be added to your `app-config.yaml` under the root
```yaml
auth:
providers:
oauth2proxy: {}
oauth2Proxy: {}
```
Right now no configuration options are supported, but the empty object is needed
to enable the provider in the auth backend.
To use the `oauth2proxy` provider you must also configure it with a sign-in resolver.
To use the `oauth2Proxy` provider you must also configure it with a sign-in resolver.
For more information about the sign-in process in general, see the
[Sign-in Identities and Resolvers](../identity-resolver.md) documentation.
For the `oauth2proxy` provider, the sign-in result is quite different than other providers.
For the `oauth2Proxy` provider, the sign-in result is quite different than other providers.
Because it's a proxy provider that can be configured to forward information through
arbitrary headers, the auth result simply just gives you access to the HTTP headers
of the incoming request. Using these you can either extract the information directly,
@@ -40,19 +40,22 @@ or grab ID or access tokens to look up additional information and/or validate th
A simple sign-in resolver might for example look like this:
```ts
providers.oauth2Proxy.create({
signIn: {
async resolver({ result }, ctx) {
const name = result.getHeader('x-forwarded-user');
if (!name) {
throw new Error('Request did not contain a user')
}
return ctx.signInWithCatalogUser({
entityRef: { name },
});
providerFactories: {
...defaultAuthProviderFactories,
oauth2Proxy: providers.oauth2Proxy.create({
signIn: {
async resolver({ result }, ctx) {
const name = result.getHeader('x-forwarded-user');
if (!name) {
throw new Error('Request did not contain a user')
}
return ctx.signInWithCatalogUser({
entityRef: { name },
});
},
},
},
}),
}),
},
```
## Adding the provider to the Backstage frontend
@@ -65,7 +68,7 @@ installed in `packages/app/src/App.tsx` like this:
const app = createApp({
components: {
+ SignInPage: props => <ProxiedSignInPage {...props} provider="oauth2proxy" />,
+ SignInPage: props => <ProxiedSignInPage {...props} provider="oauth2Proxy" />,
```
See the [Sign-In with Proxy Providers](../index.md#sign-in-with-proxy-providers) section for more information.
@@ -397,6 +397,26 @@ There's also the ability to pass additional scopes when requesting the `oauth`
token from the user, which you can do on a per-provider basis, in case your
template can be published to multiple providers.
### 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.
If you have enabled a sign in provider and have a [sign in resolver](../../auth/identity-resolver.md) that points to a user in the Catalog, then you can use the `${{ user.entity }}` templating expression to access the raw entity from the Catalog.
This can be particularly useful if you have processors setup in the Catalog to write `spec.profile.email` of the `User Entities` to reference them and pass them into actions like below:
```yaml
steps:
action: publish:github
...
input:
...
gitAuthorName: ${{ user.entity.metadata.name }}
gitAuthorEmail: ${{ user.entity.spec.profile.email }}
```
You also have access to `user.entity.metadata.annotations` too, so if you have some other additional information stored in there, you reference those too.
### The Owner Picker
When the scaffolder needs to add new components to the catalog, it needs to have
+6 -5
View File
@@ -52,11 +52,12 @@ learn how to contribute the integration yourself!
The following table summarizes events that, depending on the plugins you have
installed, may be captured.
| Action | Provided By | Subject |
| ---------- | -------------- | --------------------------------------------------- |
| `navigate` | Backstage Core | The URL of the page that was navigated to |
| `click` | Backstage Core | The text of the link that was clicked on |
| `search` | Backstage Core | The search term entered in any search bar component |
| Action | Subject | Other Notes |
| ---------- | --------------------------------------------------- | ----------------------------------------------------------------- |
| `navigate` | The URL of the page that was navigated to | |
| `click` | The text of the link that was clicked on | The `to` attribute represents the URL clicked to |
| `search` | The search term entered in any search bar component | The `searchTypes` attribute holds `types` constraining the search |
| `discover` | The title of the search result that was clicked on | The `value` is the result rank. A `to` attribute is also provided |
If there is an event you'd like to see captured, please [open an
issue][add-event] describing the event you want to see and the questions it
+12
View File
@@ -0,0 +1,12 @@
---
title: Dynatrace
author: TELUS
authorUrl: https://github.com/telus
category: Monitoring
description: View monitoring info from dynatrace for services in your software catalog.
documentation: https://github.com/backstage/backstage/tree/master/plugins/dynatrace
iconUrl: img/dynatrace.svg
npmPackageName: '@backstage/plugin-dynatrace'
tags:
- dynatrace
- monitoring
+1 -2
View File
@@ -259,11 +259,10 @@
"auth/oauth2-proxy/provider"
]
},
"auth/add-auth-provider",
"auth/identity-resolver",
"auth/auth-backend",
"auth/oauth",
"auth/auth-backend-classes",
"auth/add-auth-provider",
"auth/troubleshooting",
"auth/glossary"
],
+68
View File
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="370px"
height="344px" viewBox="0 0 370 344" enable-background="new 0 0 370 344" xml:space="preserve">
<g id="Background">
</g>
<g id="Vertical">
</g>
<g id="Horizontal">
</g>
<g id="Dynatrace_Color">
</g>
<g id="Variants">
<g>
<g>
<g>
<path fill="#FFFFFF" d="M241.9,282.2h-10.6c-3,0-5.1,0.6-6.3,1.8c-1.3,1.2-1.9,3.3-1.9,6.2l0,36.6h-6.4l0-37.1
c0-2.8,0.5-5.9,2-8.2c2.7-4.3,7.9-5.1,11.7-5.1h11.5V282.2z"/>
</g>
<g>
<path fill="#FFFFFF" d="M201.1,321.2c-3,0-5.1-0.6-6.3-1.8c-1.3-1.2-1.9-3.2-1.9-6.1v-31h13.3v-5.7h-13.3v-15.1h-6.4v52.2
c0,2.8,0.5,5.9,2,8.2c2.7,4.3,7.9,5.1,11.7,5.1h11.5v-5.7H201.1z"/>
</g>
<path fill="#FFFFFF" d="M35.1,261.4v15.1l-13.3,0c-8.1,0-13,2.4-16,5.3c-4.7,4.5-4.7,11-4.7,11.7c0,0.8,0,15.4,0,16.2
c0,0.7,0,7.2,4.7,11.7c3,2.9,7.9,5.3,16,5.3h5.9c3.8,0,9-0.8,11.7-5.1c1.5-2.3,2-5.4,2-8.2v-52.2H35.1z M33.2,319.3
c-1.3,1.2-3.3,1.8-6.3,1.8h-5.7c-5.2,0-8.5-1.5-10.5-3.5c-2.4-2.3-3.2-5.3-3.2-7.7v-16.6c0-2.4,0.8-5.4,3.2-7.7
c2-2,5.3-3.5,10.5-3.5l13.9,0l0,31C35.1,316.1,34.4,318.1,33.2,319.3z"/>
<path fill="#FFFFFF" d="M299.3,285.7c2-2,5.3-3.5,10.5-3.5h15.3v-5.7h-14.6c-8.1,0-13,2.4-16,5.3c-4.7,4.5-4.7,11-4.7,11.7
c0,0.4,0,15.8,0,16.2c0,0.7,0,7.2,4.7,11.7c3,2.9,7.9,5.3,16,5.3h14.6v-5.7h-15.3c-5.2,0-8.5-1.5-10.5-3.5
c-2.4-2.3-3.2-5.3-3.2-7.7v-16.6C296.2,291,297,288,299.3,285.7z"/>
<path fill="#FFFFFF" d="M180,293.6c0-0.7,0-7.2-4.7-11.7c-3-2.9-7.9-5.3-16-5.3h-14.1v5.7H160c5.2,0,8.5,1.5,10.5,3.5
c2.4,2.3,3.2,5.3,3.2,7.7v4.8h-20.2c-3.8,0-9,0.8-11.7,5.1c-1.5,2.3-2,5.4-2,8.2v2c0,2.8,0.5,5.9,2,8.2c2.7,4.3,7.9,5.1,11.7,5.1
h12.8c3.8,0,9-0.8,11.7-5.1c1.5-2.3,2-5.4,2-8.2C180,313.6,180,296.9,180,293.6z M171.7,319.3c-1.3,1.2-3.3,1.8-6.3,1.8h-11.1
c-3,0-5.1-0.6-6.3-1.8c-1.3-1.2-1.9-3.2-1.9-6.1v-1.4c0-2.9,0.6-4.9,1.9-6.1c1.3-1.2,3.3-1.8,6.3-1.8h19.4l0,9.3
C173.6,316.1,173,318.1,171.7,319.3z"/>
<path fill="#FFFFFF" d="M284.8,293.6c0-0.7,0-7.2-4.7-11.7c-3-2.9-7.9-5.3-16-5.3H250v5.7h14.7c5.2,0,8.5,1.5,10.5,3.5
c2.4,2.3,3.2,5.3,3.2,7.7v4.8h-20.2c-3.8,0-9,0.8-11.7,5.1c-1.5,2.3-2,5.4-2,8.2v2c0,2.8,0.5,5.9,2,8.2c2.7,4.3,7.9,5.1,11.7,5.1
H271c3.8,0,9-0.8,11.7-5.1c1.5-2.3,2-5.4,2-8.2C284.8,313.6,284.8,296.9,284.8,293.6z M276.5,319.3c-1.3,1.2-3.3,1.8-6.3,1.8H259
c-3,0-5.1-0.6-6.3-1.8c-1.3-1.2-1.9-3.2-1.9-6.1v-1.4c0-2.9,0.6-4.9,1.9-6.1c1.3-1.2,3.3-1.8,6.3-1.8h19.4l0,9.3
C278.4,316.1,277.8,318.1,276.5,319.3z"/>
<polygon fill="#FFFFFF" points="91.8,276.5 85.2,276.5 69.1,318.3 53.1,276.5 46.5,276.5 65.8,326.9 60,342 66.6,342 "/>
<path fill="#FFFFFF" d="M134.6,293.6c0-0.7,0-7.2-4.6-11.7c-2.9-2.9-7.6-5.2-15.2-5.3h-0.7c-7.6,0.1-12.3,2.5-15.2,5.3
c-4.6,4.5-4.6,11-4.6,11.7c0,0.8,0,30.7,0,33.3h6.3l0-33.5c0-2.4,0.8-5.4,3.1-7.7c2-1.9,5.7-3.4,10.7-3.4c5,0.1,8.8,1.5,10.7,3.4
c2.3,2.3,3.1,5.3,3.1,7.7l0,33.5h6.3C134.6,324.3,134.6,294.4,134.6,293.6z"/>
<path fill="#FFFFFF" d="M364.3,281.9c-2.9-2.9-7.6-5.2-15.2-5.3h-0.7c-7.6,0.1-12.3,2.5-15.2,5.3c-4.6,4.5-4.6,11-4.6,11.7v16.2
c0,0.7,0,7.2,4.6,11.7c2.9,2.9,7.6,5.2,15.2,5.3h14.9v-5.7l-14.6,0c-5-0.1-8.8-1.5-10.7-3.4c-2.3-2.3-3.1-5.3-3.1-7.7v-6h34
v-10.5C368.9,292.9,368.9,286.4,364.3,281.9z M334.9,298.3v-5c0-2.4,0.8-5.4,3.1-7.7c2-1.9,5.7-3.4,10.7-3.4
c5,0.1,8.8,1.5,10.7,3.4c2.3,2.3,3.1,5.3,3.1,7.7l0,5H334.9z"/>
</g>
<g>
<path fill="#1496FF" d="M151,19.8c-2.7,14.5-6.2,35.9-8,57.6c-3.2,38.4-1.2,64-1.2,64l-53.9,51.3c0,0-4.2-28.8-6.3-61.2
c-1.3-20-1.7-37.7-1.8-48.4c0-0.6,0.3-1.2,0.3-1.8c0-0.7,0.9-7.9,7.9-14.5C95.7,59.5,151.8,15.5,151,19.8z"/>
<path fill="#1284EA" d="M151,19.8c-2.7,14.5-6.2,35.9-8,57.6c0,0-59.7-7.1-63.2,7.3c0-0.7,1-9.5,8-16.2
C95.5,61.1,151.8,15.5,151,19.8z"/>
<path fill="#B4DC00" d="M79.8,81.3c0,1,0,2.1,0,3.3c0.6-2.6,1.6-4.5,3.8-7.2c4.4-5.6,11.6-7.1,14.5-7.5
c14.6-1.9,36.2-4.3,57.9-4.9c38.5-1.2,63.9,2,63.9,2l53.9-51.3c0,0-28.3-5.4-60.6-9.2c-21.1-2.5-39.7-3.8-50.1-4.4
c-0.7,0-8.2-1-15.2,5.7c-7.7,7.3-46.3,43.9-61.8,58.7C79.3,73.1,79.8,80.6,79.8,81.3z"/>
<path fill="#6F2DA8" d="M271.9,146.8c-14.6,2-36.1,4.4-57.9,5.1c-38.5,1.3-64-1.9-64-1.9L96,201.3c0,0,28.6,5.6,60.8,9.3
c19.7,2.3,37.3,3.5,47.9,4.1c0.7,0,2-0.6,2.7-0.6c0.7,0,8.2-1.3,15.2-8C230.4,198.8,276.2,146.3,271.9,146.8z"/>
<path fill="#591F91" d="M271.9,146.8c-14.6,2-36.1,4.4-57.9,5.1c0,0,4.2,60-10.4,62.7c0.7,0,10.6-0.5,17.6-7.1
C228.9,200.2,276.2,146.3,271.9,146.8z"/>
<path fill="#73BE28" d="M206.9,214.9c-1-0.1-2.1-0.1-3.3-0.2c2.7-0.5,4.5-1.4,7.4-3.4c5.8-4.2,7.7-11.2,8.2-14.1
c2.6-14.5,6-35.9,7.8-57.6c3.1-38.4,1.1-63.9,1.1-63.9l53.9-51.3c0,0,4,28.5,6.2,60.9c1.4,21.2,1.8,39.8,1.9,50.2
c0,0.7,0.6,8.2-6.4,14.9c-7.7,7.3-46.2,44.1-61.7,58.9C215.1,215.8,207.6,214.9,206.9,214.9z"/>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.9 KiB

+1 -2
View File
@@ -156,11 +156,10 @@ nav:
- OneLogin: 'auth/onelogin/provider.md'
- OAuth2Proxy: 'auth/oauth2-proxy/provider.md'
- Bitbucket: 'auth/bitbucket/provider.md'
- Adding authentication providers: 'auth/add-auth-provider.md'
- Sign in resolvers: 'auth/identity-resolver.md'
- Auth backend: 'auth/auth-backend.md'
- OAuth and OpenID Connect: 'auth/oauth.md'
- Auth backend classes: 'auth/auth-backend-classes.md'
- Contributing New Providers: 'auth/add-auth-provider.md'
- Troubleshooting Auth: 'auth/troubleshooting.md'
- Glossary: 'auth/glossary.md'
- Deployment:
+1
View File
@@ -29,6 +29,7 @@
"@backstage/plugin-cloudbuild": "^0.3.6-next.1",
"@backstage/plugin-code-coverage": "^0.1.33-next.1",
"@backstage/plugin-cost-insights": "^0.11.28-next.2",
"@backstage/plugin-dynatrace": "^0.0.0",
"@backstage/plugin-explore": "^0.3.37-next.1",
"@backstage/plugin-gcalendar": "^0.3.2-next.1",
"@backstage/plugin-gcp-projects": "^0.3.25-next.1",
@@ -73,6 +73,10 @@ import {
isCloudbuildAvailable,
} from '@backstage/plugin-cloudbuild';
import { EntityCodeCoverageContent } from '@backstage/plugin-code-coverage';
import {
DynatraceTab,
isDynatraceAvailable,
} from '@backstage/plugin-dynatrace';
import {
EntityGithubActionsContent,
EntityRecentGithubActionsRunsCard,
@@ -447,6 +451,14 @@ const serviceEntityPage = (
<EntityLayout.Route path="/todos" title="TODOs">
<EntityTodoContent />
</EntityLayout.Route>
<EntityLayout.Route
path="/dynatrace"
title="Dynatrace"
if={isDynatraceAvailable}
>
<DynatraceTab />
</EntityLayout.Route>
</EntityLayoutWrapper>
);
@@ -495,6 +507,14 @@ const websiteEntityPage = (
<EntityKubernetesContent />
</EntityLayout.Route>
<EntityLayout.Route
path="/dynatrace"
title="Dynatrace"
if={isDynatraceAvailable}
>
<DynatraceTab />
</EntityLayout.Route>
<EntityLayout.Route
if={isAzureDevOpsAvailable}
path="/git-tags"
@@ -184,7 +184,7 @@ export const SearchModal = ({ toggleModal }: { toggleModal: () => void }) => {
<SearchResult>
{({ results }) => (
<List>
{results.map(({ type, document, highlight }) => {
{results.map(({ type, document, highlight, rank }) => {
let resultItem;
switch (type) {
case 'software-catalog':
@@ -194,6 +194,7 @@ export const SearchModal = ({ toggleModal }: { toggleModal: () => void }) => {
key={document.location}
result={document}
highlight={highlight}
rank={rank}
/>
);
break;
@@ -204,6 +205,7 @@ export const SearchModal = ({ toggleModal }: { toggleModal: () => void }) => {
key={document.location}
result={document}
highlight={highlight}
rank={rank}
/>
);
break;
@@ -213,6 +215,7 @@ export const SearchModal = ({ toggleModal }: { toggleModal: () => void }) => {
key={document.location}
result={document}
highlight={highlight}
rank={rank}
/>
);
}
@@ -132,7 +132,7 @@ const SearchPage = () => {
<SearchResult>
{({ results }) => (
<List>
{results.map(({ type, document, highlight }) => {
{results.map(({ type, document, highlight, rank }) => {
switch (type) {
case 'software-catalog':
return (
@@ -141,6 +141,7 @@ const SearchPage = () => {
key={document.location}
result={document}
highlight={highlight}
rank={rank}
/>
);
case 'techdocs':
@@ -150,6 +151,7 @@ const SearchPage = () => {
key={document.location}
result={document}
highlight={highlight}
rank={rank}
/>
);
default:
@@ -158,6 +160,7 @@ const SearchPage = () => {
key={document.location}
result={document}
highlight={highlight}
rank={rank}
/>
);
}
@@ -112,7 +112,7 @@ const SearchPage = () => {
<SearchResult>
{({ results }) => (
<List>
{results.map(({ type, document, highlight }) => {
{results.map(({ type, document, highlight, rank }) => {
switch (type) {
case 'software-catalog':
return (
@@ -120,6 +120,7 @@ const SearchPage = () => {
key={document.location}
result={document}
highlight={highlight}
rank={rank}
/>
);
case 'techdocs':
@@ -128,6 +129,7 @@ const SearchPage = () => {
key={document.location}
result={document}
highlight={highlight}
rank={rank}
/>
);
default:
@@ -136,6 +138,7 @@ const SearchPage = () => {
key={document.location}
result={document}
highlight={highlight}
rank={rank}
/>
);
}
@@ -18,18 +18,36 @@ export default async function createPlugin(
providerFactories: {
...defaultAuthProviderFactories,
// This overrides the default GitHub auth provider with a custom one.
// Since the options are empty it will behave just like the default
// provider, but if you uncomment the `signIn` section you will enable
// sign-in via GitHub. This particular configuration uses a resolver
// that matches the username to the user entity name. See the auth
// documentation for more details on how to enable and customize sign-in:
// This replaces the default GitHub auth provider with a customized one.
// The `signIn` option enables sign-in for this provider, using the
// identity resolution logic that's provided in the `resolver` callback.
//
// This particular resolver makes all users share a single "guest" identity.
// It should only be used for testing and trying out Backstage.
//
// If you want to use a production ready resolver you can switch to the
// the one that is commented out below, it looks up a user entity in the
// catalog using the GitHub username of the authenticated user.
// That resolver requires you to have user entities populated in the catalog,
// for example using https://backstage.io/docs/integrations/github/org
//
// There are other resolvers to choose from, and you can also create
// your own, see the auth documentation for more details:
//
// https://backstage.io/docs/auth/identity-resolver
github: providers.github.create({
// signIn: {
// resolver: providers.github.resolvers.usernameMatchingUserEntityName(),
// },
signIn: {
resolver(_, ctx) {
const userRef = 'user:default/guest'; // Must be a full entity reference
return ctx.issueToken({
claims: {
sub: userRef, // The user's own identity
ent: [userRef], // A list of identities that the user claims ownership through
},
});
},
// resolver: providers.github.resolvers.usernameMatchingUserEntityName(),
},
}),
},
});
@@ -85,6 +85,7 @@ export const EntityTable = <T extends Entity>(props: EntityTableProps<T>) => {
paging: false,
actionsColumnIndex: -1,
padding: 'dense',
draggable: false,
}}
data={entities}
/>
+2
View File
@@ -114,6 +114,8 @@ export interface CatalogSearchResultListItemProps {
// (undocumented)
icon?: ReactNode;
// (undocumented)
rank?: number;
// (undocumented)
result: IndexableDocument;
}
@@ -25,6 +25,7 @@ import {
makeStyles,
} from '@material-ui/core';
import { Link } from '@backstage/core-components';
import { useAnalytics } from '@backstage/core-plugin-api';
import {
IndexableDocument,
ResultHighlight,
@@ -51,6 +52,7 @@ export interface CatalogSearchResultListItemProps {
icon?: ReactNode;
result: IndexableDocument;
highlight?: ResultHighlight;
rank?: number;
}
/** @public */
@@ -60,8 +62,16 @@ export function CatalogSearchResultListItem(
const result = props.result as any;
const classes = useStyles();
const analytics = useAnalytics();
const handleClick = () => {
analytics.captureEvent('discover', result.title, {
attributes: { to: result.location },
value: props.rank,
});
};
return (
<Link to={result.location}>
<Link noTrack to={result.location} onClick={handleClick}>
<ListItem alignItems="flex-start">
{props.icon && <ListItemIcon>{props.icon}</ListItemIcon>}
<div className={classes.flexContainer}>
+41 -28
View File
@@ -72,37 +72,50 @@ import { CostInsightsPage } from '@backstage/plugin-cost-insights';
To expose the plugin to your users, you can integrate the `cost-insights` route anyway that suits your application, but most commonly it is added to the Sidebar.
```diff
// packages/app/src/sidebar.tsx
// packages/app/src/components/Root/Root.tsx
+ import MoneyIcon from '@material-ui/icons/MonetizationOn';
...
export const AppSidebar = () => (
<Sidebar>
<SidebarLogo />
<SidebarGroup icon={<SearchIcon />} to="/search">
<SidebarSearch />
</SidebarGroup>
<SidebarDivider />
{/* Global nav, not org-specific */}
<SidebarGroup label="Menu" icon={<MenuIcon />}>
<SidebarItem icon={HomeIcon} to="./" text="Home" />
<SidebarItem icon={ExtensionIcon} to="api-docs" text="APIs" />
<SidebarItem icon={LibraryBooks} to="/docs" text="Docs" />
<SidebarItem icon={CreateComponentIcon} to="create" text="Create..." />
<SidebarDivider />
<SidebarItem icon={MapIcon} to="tech-radar" text="Tech Radar" />
+ <SidebarItem icon={MoneyIcon} to="cost-insights" text="Cost Insights" />
</SidebarGroup>
{/* End global nav */}
<SidebarDivider />
<SidebarSpace />
<SidebarDivider />
<SidebarGroup icon={<UserSettingsSignInAvatar />} to="/settings">
<SidebarSettings />
</SidebarGroup>
</Sidebar>
);
export const Root = ({ children }: PropsWithChildren<{}>) => (
<SidebarPage>
<Sidebar>
<SidebarLogo />
<SidebarGroup label="Search" icon={<SearchIcon />} to="/search">
<SidebarSearchModal>
{({ toggleModal }) => <SearchModal toggleModal={toggleModal} />}
</SidebarSearchModal>
</SidebarGroup>
<SidebarDivider />
<SidebarItem icon={ExtensionIcon} to="api-docs" text="APIs" />
<SidebarItem icon={LibraryBooks} to="docs" text="Docs" />
<SidebarItem icon={LayersIcon} to="explore" text="Explore" />
<SidebarItem icon={CreateComponentIcon} to="create" text="Create..." />
{/* End global nav */}
<SidebarDivider />
<SidebarScrollWrapper>
+ <SidebarItem
+ icon={MoneyIcon}
+ to="cost-insights"
+ text="Cost Insights"
+ />
</SidebarScrollWrapper>
<SidebarDivider />
<Shortcuts />
</SidebarGroup>
<SidebarSpace />
<SidebarDivider />
<SidebarGroup
label="Settings"
icon={<UserSettingsSignInAvatar />}
to="/settings"
>
<SidebarSettings />
</SidebarGroup>
</Sidebar>
{children}
</SidebarPage>
);
```
## Configuration
@@ -157,7 +170,7 @@ costInsights:
### Currencies (Optional)
In the `Cost Overview` panel, users can choose from a dropdown of currencies to see costs in, such as Engineers or USD. Currencies must be defined as keys on the `currencies` field. A user-friendly label and unit are **required**. If not set, the `defaultCurrencies` in `currenc.ts` will be used.
In the `Cost Overview` panel, users can choose from a dropdown of currencies to see costs in, such as Engineers or USD. Currencies must be defined as keys on the `currencies` field. A user-friendly label and unit are **required**. If not set, the `defaultCurrencies` in `currency.ts` will be used.
A currency without `kind` is reserved to calculate cost for `engineers`. There should only be one currency without `kind`.
+1
View File
@@ -0,0 +1 @@
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname);
+56
View File
@@ -0,0 +1,56 @@
# Dynatrace
Welcome to the Dynatrace plugin!
## Getting started
This plugin uses the Backstage proxy to communicate with Dynatrace's REST APIs.
### Setup
#### Dynatrace API Key
The Dynatrace plugin will require the following information, to be used in the configuration options detailed below:
- Dynatrace API URL, e.g. `https://my-dynatrace-instance.dynatrace.com/api/v2`
- Dynatrace API access token (see [documentation](https://www.dynatrace.com/support/help/dynatrace-api/basics/dynatrace-api-authentication)), with the following permissions:
- `entities.read`
- `problems.read`
#### Plugin Configuration
This plugin requires a proxy endpoint for Dynatrace configured in `app-config.yaml` like so:
```yaml
proxy:
'/dynatrace':
target: 'https://example.dynatrace.com/api/v2'
headers:
Authorization: 'Api-Token ${DYNATRACE_ACCESS_TOKEN}'
```
It also requires a baseUrl for rendering links to problems in the table like so:
```yaml
dynatrace:
baseUrl: 'https://example.dynatrace.com'
```
#### Catalog Configuration
To show information from Dynatrace for a catalog entity, add the following annotation to `catalog-info.yaml`:
```yaml
# catalog-info.yaml
# [...]
metadata:
annotations:
dynatrace.com/dynatrace-entity-id: DYNATRACE_ENTITY_ID
# [...]
```
The `DYNATRACE_ENTITY_ID` can be found in Dynatrace by browsing to the entity (a service, synthetic, frontend, workload, etc.). It will be located in the browser address bar in the `id` parameter and has the format `ENTITY_TYPE-ENTITY_ID`, where `ENTITY_TYPE` will be one of `SERVICE`, `SYNTHETIC_TEST`, or other, and `ENTITY_ID` will be a string of characters containing uppercase letters and numbers.
## Disclaimer
This plugin is not officially supported by Dynatrace.
+23
View File
@@ -0,0 +1,23 @@
## API Report File for "@backstage/plugin-dynatrace"
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts
/// <reference types="react" />
import { BackstagePlugin } from '@backstage/core-plugin-api';
import { Entity } from '@backstage/catalog-model';
// @public
export const dynatracePlugin: BackstagePlugin<{}, {}>;
// @public
export const DynatraceTab: () => JSX.Element;
// Warning: (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
//
// @public
export const isDynatraceAvailable: (entity: Entity) => boolean;
// (No @packageDocumentation comment for this package)
```
+28
View File
@@ -0,0 +1,28 @@
/*
* 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.
*/
export interface Config {
/**
* dynatrace config
* @visibility frontend
*/
dynatrace?: {
/**
* base url for links
* @visibility frontend
*/
baseUrl: string;
};
}
+27
View File
@@ -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 React from 'react';
import { createDevApp } from '@backstage/dev-utils';
import { dynatracePlugin, DynatraceTab } from '../src/plugin';
createDevApp()
.registerPlugin(dynatracePlugin)
.addPage({
element: <DynatraceTab />,
title: 'Root Page',
path: '/dynatrace',
})
.render();
+58
View File
@@ -0,0 +1,58 @@
{
"name": "@backstage/plugin-dynatrace",
"version": "0.0.0",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "Apache-2.0",
"publishConfig": {
"access": "public",
"main": "dist/index.esm.js",
"types": "dist/index.d.ts"
},
"backstage": {
"role": "frontend-plugin"
},
"scripts": {
"start": "backstage-cli package start",
"build": "backstage-cli package build",
"lint": "backstage-cli package lint",
"test": "backstage-cli package test",
"clean": "backstage-cli package clean",
"prepack": "backstage-cli package prepack",
"postpack": "backstage-cli package postpack"
},
"dependencies": {
"@backstage/catalog-model": "^1.0.3-next.0",
"@backstage/core-components": "^0.9.5-next.1",
"@backstage/core-plugin-api": "^1.0.3-next.0",
"@backstage/theme": "^0.2.15",
"@material-ui/core": "^4.9.13",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "4.0.0-alpha.57",
"cross-fetch": "^3.1.5",
"react-use": "^17.2.4"
},
"peerDependencies": {
"@backstage/plugin-catalog-react": "^1.1.1-next.1",
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
"@backstage/cli": "^0.17.2-next.1",
"@backstage/core-app-api": "^1.0.3-next.0",
"@backstage/dev-utils": "^1.0.3-next.1",
"@backstage/test-utils": "^1.1.1-next.0",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "*",
"@types/node": "*",
"cross-fetch": "^3.1.5",
"express": "^4.18.1",
"msw": "^0.42.0"
},
"files": [
"dist",
"config.d.ts"
],
"configSchema": "config.d.ts"
}
+50
View File
@@ -0,0 +1,50 @@
/*
* 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 { createApiRef } from '@backstage/core-plugin-api';
export type DynatraceEntity = {
entityId: {
id: string;
type: string;
};
name: string;
};
export type DynatraceProblem = {
problemId: string;
impactLevel: string;
status: string;
startTime: number;
endTime: number;
title: string;
severityLevel: string;
rootCauseEntity: DynatraceEntity;
affectedEntities: Array<DynatraceEntity>;
};
export interface DynatraceProblems {
problems: Array<DynatraceProblem>;
}
export const dynatraceApiRef = createApiRef<DynatraceApi>({
id: 'plugin.dynatrace.service',
});
export type DynatraceApi = {
getDynatraceProblems(
dynatraceEntityId: string,
): Promise<DynatraceProblems | undefined>;
};
@@ -0,0 +1,66 @@
/*
* 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 { DynatraceProblems, DynatraceApi } from './DynatraceApi';
import { DiscoveryApi, FetchApi } from '@backstage/core-plugin-api';
export class DynatraceClient implements DynatraceApi {
discoveryApi: DiscoveryApi;
fetchApi: FetchApi;
constructor({
discoveryApi,
fetchApi,
}: {
discoveryApi: DiscoveryApi;
fetchApi: FetchApi;
}) {
this.discoveryApi = discoveryApi;
this.fetchApi = fetchApi;
}
private async callApi<T>(
path: string,
query: { [key in string]: any },
): Promise<T | undefined> {
const apiUrl = `${await this.discoveryApi.getBaseUrl('proxy')}/dynatrace`;
const response = await this.fetchApi.fetch(
`${apiUrl}/${path}?${new URLSearchParams(query).toString()}`,
{
headers: {
'Content-Type': 'application/json',
},
},
);
if (response.status === 200) {
return (await response.json()) as T;
}
throw new Error(
`Dynatrace API call failed: ${response.status}:${response.statusText}`,
);
}
async getDynatraceProblems(
dynatraceEntityId: string,
): Promise<DynatraceProblems | undefined> {
if (!dynatraceEntityId) {
throw new Error('Dynatrace entity ID is required');
}
return this.callApi('problems', {
entitySelector: `entityId(${dynatraceEntityId})`,
});
}
}
+22
View File
@@ -0,0 +1,22 @@
/*
* 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.
*/
export type {
DynatraceProblems,
DynatraceProblem,
DynatraceEntity,
} from './DynatraceApi';
export { dynatraceApiRef } from './DynatraceApi';
export { DynatraceClient } from './DynatraceClient';
@@ -0,0 +1,56 @@
/*
* 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 React from 'react';
import { Grid } from '@material-ui/core';
import {
Page,
Content,
ContentHeader,
SupportButton,
MissingAnnotationEmptyState,
} from '@backstage/core-components';
import { useEntity } from '@backstage/plugin-catalog-react';
import { ProblemsList } from '../Problems/ProblemsList';
import { isDynatraceAvailable } from '../../plugin';
import { DYNATRACE_ID_ANNOTATION } from '../../constants';
export const DynatraceTab = () => {
const { entity } = useEntity();
if (!isDynatraceAvailable(entity)) {
return <MissingAnnotationEmptyState annotation={DYNATRACE_ID_ANNOTATION} />;
}
const dynatraceEntityId: string =
entity?.metadata.annotations?.[DYNATRACE_ID_ANNOTATION]!;
return (
<Page themeId="tool">
<Content>
<ContentHeader title="Dynatrace">
<SupportButton>
Plugin to show information from Dynatrace
</SupportButton>
</ContentHeader>
<Grid container spacing={2}>
<Grid item xs={12} lg={12}>
<ProblemsList dynatraceEntityId={dynatraceEntityId} />
</Grid>
</Grid>
</Content>
</Page>
);
};
@@ -0,0 +1,16 @@
/*
* 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.
*/
export { DynatraceTab } from './DynatraceTab';
@@ -0,0 +1,29 @@
/*
* 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 React from 'react';
import { ProblemStatus } from './ProblemStatus';
import { renderInTestApp } from '@backstage/test-utils';
describe('ProblemStatus', () => {
it('renders StatusOK for a closed issue', async () => {
const rendered = await renderInTestApp(<ProblemStatus status="closed" />);
expect(await rendered.findByText('Closed')).toBeInTheDocument();
});
it('renders StatusError for an open issue', async () => {
const rendered = await renderInTestApp(<ProblemStatus status="open" />);
expect(await rendered.findByText('Open')).toBeInTheDocument();
});
});
@@ -0,0 +1,39 @@
/*
* 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 React from 'react';
import { DynatraceProblem } from '../../../api/DynatraceApi';
import { StatusError, StatusOK } from '@backstage/core-components';
export const ProblemStatus = ({ status }: Partial<DynatraceProblem>) => {
switch (status?.toLocaleLowerCase()) {
case 'open':
return (
<>
<StatusError />
Open
</>
);
case 'closed':
return (
<>
<StatusOK />
Closed
</>
);
default:
return <></>;
}
};
@@ -0,0 +1,16 @@
/*
* 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.
*/
export { ProblemStatus } from './ProblemStatus';
@@ -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 React from 'react';
import { ProblemsList } from './ProblemsList';
import { renderInTestApp, TestApiRegistry } from '@backstage/test-utils';
import { dynatraceApiRef } from '../../../api';
import { problems } from '../../../mocks/problems.json';
import { ApiProvider, ConfigReader } from '@backstage/core-app-api';
import { configApiRef } from '@backstage/core-plugin-api';
const mockDynatraceApi = {
getDynatraceProblems: jest.fn(),
};
const apis = TestApiRegistry.from(
[dynatraceApiRef, mockDynatraceApi],
[configApiRef, new ConfigReader({ dynatrace: { baseUrl: '__dynatrace__' } })],
);
describe('ProblemStatus', () => {
it('renders a table with problem data', async () => {
mockDynatraceApi.getDynatraceProblems = jest
.fn()
.mockResolvedValue({ problems });
const rendered = await renderInTestApp(
<ApiProvider apis={apis}>
<ProblemsList dynatraceEntityId="example-service-3" />
</ApiProvider>,
);
expect(await rendered.findByText('example-service')).toBeInTheDocument();
});
it('renders "nothing to report :)" if no problems are found', async () => {
mockDynatraceApi.getDynatraceProblems = jest.fn().mockResolvedValue({});
const rendered = await renderInTestApp(
<ApiProvider apis={apis}>
<ProblemsList dynatraceEntityId="example-service-3" />
</ApiProvider>,
);
expect(
await rendered.findByText('Nothing to report :)'),
).toBeInTheDocument();
});
});
@@ -0,0 +1,43 @@
/*
* 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 React from 'react';
import useAsync from 'react-use/lib/useAsync';
import { Progress } from '@backstage/core-components';
import Alert from '@material-ui/lab/Alert';
import { useApi } from '@backstage/core-plugin-api';
import { ProblemsTable } from '../ProblemsTable';
import { dynatraceApiRef } from '../../../api';
type ProblemsListProps = {
dynatraceEntityId: string;
};
export const ProblemsList = (props: ProblemsListProps) => {
const { dynatraceEntityId } = props;
const dynatraceApi = useApi(dynatraceApiRef);
const { value, loading, error } = useAsync(async () => {
return dynatraceApi.getDynatraceProblems(dynatraceEntityId);
}, [dynatraceApi, dynatraceEntityId]);
const problems = value?.problems;
if (loading) {
return <Progress />;
} else if (error) {
return <Alert severity="error">{error.message}</Alert>;
}
if (!problems) return <div>Nothing to report :)</div>;
return <ProblemsTable problems={problems} />;
};
@@ -0,0 +1,16 @@
/*
* 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.
*/
export { ProblemsList } from './ProblemsList';
@@ -0,0 +1,44 @@
/*
* 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 React from 'react';
import { ProblemsTable } from './ProblemsTable';
import { renderInTestApp, TestApiRegistry } from '@backstage/test-utils';
import { problems } from '../../../mocks/problems.json';
import { ApiProvider, ConfigReader } from '@backstage/core-app-api';
import { configApiRef } from '@backstage/core-plugin-api';
describe('ProblemsTable', () => {
const apis = TestApiRegistry.from([
configApiRef,
new ConfigReader({ dynatrace: { baseUrl: '__dynatrace__' } }),
]);
it('renders the table with some problem data', async () => {
const rendered = await renderInTestApp(
<ApiProvider apis={apis}>
<ProblemsTable problems={problems} />,
</ApiProvider>,
);
expect(await rendered.findByText('example-service')).toBeInTheDocument();
});
it('renders an empty table when no data is provided', async () => {
const rendered = await renderInTestApp(
<ApiProvider apis={apis}>
<ProblemsTable problems={[]} />
</ApiProvider>,
);
expect(await rendered.findByText('Problems')).toBeInTheDocument();
});
});
@@ -0,0 +1,86 @@
/*
* 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 React from 'react';
import { Table, TableColumn } from '@backstage/core-components';
import { DynatraceProblem } from '../../../api/DynatraceApi';
import { ProblemStatus } from '../ProblemStatus';
import { configApiRef } from '@backstage/core-plugin-api';
import { useApi } from '@backstage/core-plugin-api';
import { Link } from '@material-ui/core';
type ProblemsTableProps = {
problems: DynatraceProblem[];
};
export const ProblemsTable = ({ problems }: ProblemsTableProps) => {
const configApi = useApi(configApiRef);
const dynatraceBaseUrl = configApi.getString('dynatrace.baseUrl');
const columns: TableColumn[] = [
{
title: 'Title',
field: 'title',
render: (row: Partial<DynatraceProblem>) => (
<Link
href={`${dynatraceBaseUrl}/#problems/problemdetails;pid=${row.problemId}`}
>
{row.title}
</Link>
),
},
{
title: 'Status',
field: 'status',
render: (row: Partial<DynatraceProblem>) => (
<ProblemStatus status={row.status} />
),
},
{ title: 'Severity', field: 'severityLevel' },
{
title: 'Root Cause',
field: 'rootCauseEntity',
render: (row: Partial<DynatraceProblem>) => row.rootCauseEntity?.name,
},
{
title: 'Affected',
field: 'affectedEntities',
render: (row: Partial<DynatraceProblem>) =>
row.affectedEntities?.map(e => e.name),
},
{
title: 'Start Time',
field: 'startTime',
render: (row: Partial<DynatraceProblem>) =>
new Date(row.startTime || 0).toString(),
},
{
title: 'End Time',
field: 'endTime',
render: (row: Partial<DynatraceProblem>) =>
row.endTime === -1 ? 'ongoing' : new Date(row.endTime || 0).toString(),
},
];
return (
<Table
title="Problems"
options={{ search: true, paging: true }}
columns={columns}
data={problems.map(p => {
return { ...p, id: p.problemId };
})}
/>
);
};
@@ -0,0 +1,16 @@
/*
* 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.
*/
export { ProblemsTable } from './ProblemsTable';
+16
View File
@@ -0,0 +1,16 @@
/*
* 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.
*/
export const DYNATRACE_ID_ANNOTATION = 'dynatrace.com/dynatrace-entity-id';
+16
View File
@@ -0,0 +1,16 @@
/*
* 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.
*/
export { dynatracePlugin, DynatraceTab, isDynatraceAvailable } from './plugin';
+135
View File
@@ -0,0 +1,135 @@
{
"totalCount": 0,
"pageSize": 0,
"nextPageKey": "AQAAABQBAAAABQ==",
"problems": [
{
"managementZones": [
{
"name": "string",
"id": "string"
}
],
"severityLevel": "AVAILABILITY",
"entityTags": [
{
"stringRepresentation": "string",
"value": "string",
"key": "string",
"context": "string"
}
],
"problemId": "string",
"displayId": "string",
"affectedEntities": [
{
"entityId": {
"id": "string",
"type": "string"
},
"name": "my-service"
},
{
"entityId": {
"id": "string",
"type": "string"
},
"name": "example-service-3"
}
],
"rootCauseEntity": {
"entityId": {
"id": "string",
"type": "string"
},
"name": "example-service"
},
"impactedEntities": [
{
"entityId": {
"id": "string",
"type": "string"
},
"name": "HELP ME"
},
{
"entityId": {
"id": "string",
"type": "string"
},
"name": "HELP ME 2"
}
],
"linkedProblemInfo": {
"problemId": "string",
"displayId": "string"
},
"problemFilters": [
{
"name": "string",
"id": "string"
}
],
"evidenceDetails": {
"totalCount": 0,
"details": [
{
"evidenceType": "AVAILABILITY_EVIDENCE",
"displayName": "string",
"entity": {
"entityId": {
"id": "string",
"type": "string"
},
"name": "string"
},
"groupingEntity": {
"entityId": {
"id": "string",
"type": "string"
},
"name": "string"
},
"rootCauseRelevant": true,
"startTime": 0
}
]
},
"recentComments": {
"comments": [
{
"createdAtTimestamp": 0,
"authorName": "string",
"context": "string",
"id": "string",
"content": "string"
}
],
"totalCount": 0,
"pageSize": 0,
"nextPageKey": "AQAAABQBAAAABQ=="
},
"impactAnalysis": {
"impacts": [
{
"impactType": "APPLICATION",
"impactedEntity": {
"entityId": {
"id": "string",
"type": "string"
},
"name": "string"
},
"estimatedAffectedUsers": 0
}
]
},
"impactLevel": "APPLICATION",
"status": "OPEN",
"startTime": 0,
"endTime": 0,
"title": "this IS a big problem"
}
],
"warnings": ["string"]
}
+22
View File
@@ -0,0 +1,22 @@
/*
* 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 { dynatracePlugin } from './plugin';
describe('dynatrace', () => {
it('should export plugin', () => {
expect(dynatracePlugin).toBeDefined();
});
});
+71
View File
@@ -0,0 +1,71 @@
/*
* 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 { dynatraceApiRef, DynatraceClient } from './api';
import {
createApiFactory,
createPlugin,
discoveryApiRef,
fetchApiRef,
createRoutableExtension,
} from '@backstage/core-plugin-api';
import { Entity } from '@backstage/catalog-model';
import { DYNATRACE_ID_ANNOTATION } from './constants';
import { rootRouteRef } from './routes';
/**
* Create the Dynatrace plugin.
* @public
*/
export const dynatracePlugin = createPlugin({
id: 'dynatrace',
apis: [
createApiFactory({
api: dynatraceApiRef,
deps: {
discoveryApi: discoveryApiRef,
fetchApi: fetchApiRef,
},
factory: ({ discoveryApi, fetchApi }) =>
new DynatraceClient({
discoveryApi,
fetchApi,
}),
}),
],
});
/**
* Checks if the entity has a dynatrace id annotation.
* @public
* @param entity {Entity} - The entity to check for the dynatrace id annotation.
*/
export const isDynatraceAvailable = (entity: Entity) =>
Boolean(entity.metadata.annotations?.[DYNATRACE_ID_ANNOTATION]);
/**
* Creates a routable extension for the dynatrace plugin tab.
* @public
*/
export const DynatraceTab = dynatracePlugin.provide(
createRoutableExtension({
name: 'DynatraceTab',
component: () =>
import('./components/DynatraceTab').then(m => m.DynatraceTab),
mountPoint: rootRouteRef,
}),
);
+20
View File
@@ -0,0 +1,20 @@
/*
* 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 { createRouteRef } from '@backstage/core-plugin-api';
export const rootRouteRef = createRouteRef({
id: 'dynatrace',
});
+17
View File
@@ -0,0 +1,17 @@
/*
* 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 '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
@@ -523,6 +523,7 @@ describe('ElasticSearchSearchEngine', () => {
.map((_, i) => ({
type: 'mytype',
document: { value: `${i}` },
rank: i + 1,
})),
),
});
@@ -567,6 +568,7 @@ describe('ElasticSearchSearchEngine', () => {
.map((_, i) => ({
type: 'mytype',
document: { value: `${i}` },
rank: i + 1,
})),
),
nextPageCursor: 'MQ==',
@@ -614,6 +616,7 @@ describe('ElasticSearchSearchEngine', () => {
.map((_, i) => ({
type: 'mytype',
document: { value: `${i}` },
rank: i + 1,
}))
.slice(25),
),
@@ -667,6 +670,7 @@ describe('ElasticSearchSearchEngine', () => {
.map((_, i) => ({
type: 'mytype',
document: { value: `${i}` },
rank: i + 1,
highlight: {
preTag: '<tag>',
postTag: '</tag>',
@@ -334,27 +334,30 @@ export class ElasticSearchSearchEngine implements SearchEngine {
: undefined;
return {
results: result.body.hits.hits.map((d: ElasticSearchResult) => {
const resultItem: IndexableResult = {
type: this.getTypeFromIndex(d._index),
document: d._source,
};
if (d.highlight) {
resultItem.highlight = {
preTag: this.highlightOptions.preTag as string,
postTag: this.highlightOptions.postTag as string,
fields: Object.fromEntries(
Object.entries(d.highlight).map(([field, fragments]) => [
field,
fragments.join(this.highlightOptions.fragmentDelimiter),
]),
),
results: result.body.hits.hits.map(
(d: ElasticSearchResult, index: number) => {
const resultItem: IndexableResult = {
type: this.getTypeFromIndex(d._index),
document: d._source,
rank: pageSize * page + index + 1,
};
}
return resultItem;
}),
if (d.highlight) {
resultItem.highlight = {
preTag: this.highlightOptions.preTag as string,
postTag: this.highlightOptions.postTag as string,
fields: Object.fromEntries(
Object.entries(d.highlight).map(([field, fragments]) => [
field,
fragments.join(this.highlightOptions.fragmentDelimiter),
]),
),
};
}
return resultItem;
},
),
nextPageCursor,
previousPageCursor,
};
@@ -174,6 +174,7 @@ describe('PgSearchEngine', () => {
location: 'location-1',
},
type: 'my-type',
rank: 1,
},
],
nextPageCursor: undefined,
@@ -215,6 +216,7 @@ describe('PgSearchEngine', () => {
location: `location-${i}`,
},
type: 'my-type',
rank: i + 1,
})),
nextPageCursor: 'MQ==',
});
@@ -257,6 +259,7 @@ describe('PgSearchEngine', () => {
location: `location-${i}`,
},
type: 'my-type',
rank: i + 1,
}))
.slice(25),
previousPageCursor: 'MA==',
@@ -18,6 +18,7 @@ import { SearchEngine } from '@backstage/plugin-search-backend-node';
import {
SearchQuery,
IndexableResultSet,
IndexableResult,
} from '@backstage/plugin-search-common';
import { PgSearchEngineIndexer } from './PgSearchEngineIndexer';
import {
@@ -104,10 +105,13 @@ export class PgSearchEngine implements SearchEngine {
? encodePageCursor({ page: page - 1 })
: undefined;
const results = pageRows.map(({ type, document }) => ({
type,
document,
}));
const results = pageRows.map(
({ type, document }, index): IndexableResult => ({
type,
document,
rank: page * pageSize + index + 1,
}),
);
return { results, nextPageCursor, previousPageCursor };
}
@@ -431,6 +431,7 @@ describe('LunrSearchEngine', () => {
location: 'test/location',
},
type: 'test-index',
rank: 1,
},
],
nextPageCursor: undefined,
@@ -469,6 +470,7 @@ describe('LunrSearchEngine', () => {
text: 'testText',
location: 'test/location',
},
rank: 1,
},
],
nextPageCursor: undefined,
@@ -521,6 +523,7 @@ describe('LunrSearchEngine', () => {
location: `${highlightTags.pre}test/location${highlightTags.post}`,
},
},
rank: 1,
},
],
nextPageCursor: undefined,
@@ -559,6 +562,7 @@ describe('LunrSearchEngine', () => {
text: 'testText',
location: 'test/location',
},
rank: 1,
},
],
nextPageCursor: undefined,
@@ -598,6 +602,7 @@ describe('LunrSearchEngine', () => {
text: 'testText',
location: 'test/location',
},
rank: 1,
},
],
nextPageCursor: undefined,
@@ -637,6 +642,7 @@ describe('LunrSearchEngine', () => {
text: 'Hello World.',
location: 'test/location',
},
rank: 1,
},
],
nextPageCursor: undefined,
@@ -676,6 +682,7 @@ describe('LunrSearchEngine', () => {
text: 'Searching',
location: 'test/location',
},
rank: 1,
},
],
nextPageCursor: undefined,
@@ -722,6 +729,7 @@ describe('LunrSearchEngine', () => {
text: 'testText',
location: 'test/location2',
},
rank: 1,
},
],
nextPageCursor: undefined,
@@ -777,6 +785,7 @@ describe('LunrSearchEngine', () => {
location: 'test/location2',
extraField: 'testExtraField',
},
rank: 1,
},
],
nextPageCursor: undefined,
@@ -823,6 +832,7 @@ describe('LunrSearchEngine', () => {
text: 'testText',
location: 'test:location2',
},
rank: 1,
},
],
nextPageCursor: undefined,
@@ -886,6 +896,7 @@ describe('LunrSearchEngine', () => {
text: 'testText',
title: 'testTitle',
},
rank: 1,
},
{
document: {
@@ -893,6 +904,7 @@ describe('LunrSearchEngine', () => {
text: 'testText',
title: 'testTitle',
},
rank: 2,
},
],
nextPageCursor: undefined,
@@ -931,6 +943,7 @@ describe('LunrSearchEngine', () => {
location: `test/location/${i}`,
},
type: 'test-index',
rank: i + 1,
})),
nextPageCursor: 'MQ==',
previousPageCursor: undefined,
@@ -968,6 +981,7 @@ describe('LunrSearchEngine', () => {
location: `test/location/${i}`,
},
type: 'test-index',
rank: i + 1,
}))
.slice(25),
nextPageCursor: undefined,
@@ -207,9 +207,10 @@ export class LunrSearchEngine implements SearchEngine {
// Translate results into IndexableResultSet
const realResultSet: IndexableResultSet = {
results: results.slice(offset, offset + pageSize).map(d => ({
results: results.slice(offset, offset + pageSize).map((d, index) => ({
type: d.type,
document: this.docStore[d.result.ref],
rank: page * pageSize + index + 1,
highlight: {
preTag: this.highlightPreTag,
postTag: this.highlightPostTag,
@@ -44,6 +44,7 @@ describe('AuthorizedSearchEngine', () => {
.fill(0)
.map((_, index) => ({
type,
rank: index + 1,
document: {
title: `${type}_doc_${index}`,
authorization: withAuthorization
@@ -261,9 +262,11 @@ describe('AuthorizedSearchEngine', () => {
}),
);
const expectedResult = { ...usersWithAuth[8], rank: 1 };
await expect(
authorizedSearchEngine.query({ term: '' }, options),
).resolves.toEqual({ results: [usersWithAuth[8]] });
).resolves.toEqual({ results: [expectedResult] });
expect(mockedQuery).toHaveBeenCalledWith(
{ term: '', types: ['users'] },
@@ -275,6 +278,7 @@ describe('AuthorizedSearchEngine', () => {
const searchResults = [
{
type: 'templates',
rank: 1,
document: {
title: `doc_0_a`,
authorization: { resourceRef: `template_doc_0` },
@@ -282,6 +286,7 @@ describe('AuthorizedSearchEngine', () => {
},
{
type: 'templates',
rank: 2,
document: {
title: `doc_0_b`,
authorization: { resourceRef: `template_doc_0` },
@@ -419,7 +424,9 @@ describe('AuthorizedSearchEngine', () => {
{ token: 'token' },
);
const expectedResult = allDocuments.slice(0, 25);
const expectedResult = allDocuments
.slice(0, 25)
.map((r, i) => ({ ...r, rank: i + 1 }));
const expectedFirstRequestCursor = 'MQ==';
expect(result).toEqual({
@@ -510,7 +517,8 @@ describe('AuthorizedSearchEngine', () => {
const expectedResult = allDocuments
.filter(d => d.type !== typeServices)
.slice(0, 25);
.slice(0, 25)
.map((d, i) => ({ ...d, rank: i + 1 }));
const expectedFirstRequestCursor = 'MQ==';
expect(result).toEqual({
@@ -587,8 +595,12 @@ describe('AuthorizedSearchEngine', () => {
{ token: 'token' },
);
const expectedResults = servicesWithAuth
.slice(5)
.map((r, i) => ({ ...r, rank: 25 + i + 1 }));
expect(result).toEqual({
results: servicesWithAuth.slice(5),
results: expectedResults,
previousPageCursor: encodePageCursor({ page: 0 }),
});
});
@@ -189,10 +189,15 @@ export class AuthorizedSearchEngine implements SearchEngine {
);
return {
results: filteredResults.slice(
page * this.pageSize,
(page + 1) * this.pageSize,
),
results: filteredResults
.slice(page * this.pageSize, (page + 1) * this.pageSize)
.map((result, index) => {
// Overwrite any/all rank entries to avoid leaking knowledge of filtered results.
return {
...result,
rank: page * this.pageSize + index + 1,
};
}),
previousPageCursor:
page === 0 ? undefined : encodePageCursor({ page: page - 1 }),
nextPageCursor:
+1 -3
View File
@@ -52,11 +52,9 @@ export type QueryTranslator = (query: SearchQuery) => unknown;
// @public (undocumented)
export interface Result<TDocument extends SearchDocument> {
// (undocumented)
document: TDocument;
// (undocumented)
highlight?: ResultHighlight;
// (undocumented)
rank?: number;
type: string;
}
+18
View File
@@ -56,9 +56,27 @@ export interface ResultHighlight {
* @public
*/
export interface Result<TDocument extends SearchDocument> {
/**
* The "type" of the given document. See: {@link DocumentCollatorFactory."type"}
*/
type: string;
/**
* The raw value of the document, as indexed.
*/
document: TDocument;
/**
* Optional result highlight. Useful for improving the search result
* display/experience.
*/
highlight?: ResultHighlight;
/**
* Optional result rank, where 1 is the first/top result returned. Useful for
* understanding search effectiveness in analytics.
*/
rank?: number;
}
/**
+1
View File
@@ -38,6 +38,7 @@ export type DefaultResultListItemProps = {
secondaryAction?: ReactNode;
result: SearchDocument;
highlight?: ResultHighlight;
rank?: number;
lineClamp?: number;
};
@@ -15,7 +15,7 @@
*/
import React, { ReactNode } from 'react';
import { AnalyticsContext } from '@backstage/core-plugin-api';
import { AnalyticsContext, useAnalytics } from '@backstage/core-plugin-api';
import {
ResultHighlight,
SearchDocument,
@@ -40,6 +40,7 @@ export type DefaultResultListItemProps = {
secondaryAction?: ReactNode;
result: SearchDocument;
highlight?: ResultHighlight;
rank?: number;
lineClamp?: number;
};
@@ -51,12 +52,21 @@ export type DefaultResultListItemProps = {
export const DefaultResultListItemComponent = ({
result,
highlight,
rank,
icon,
secondaryAction,
lineClamp = 5,
}: DefaultResultListItemProps) => {
const analytics = useAnalytics();
const handleClick = () => {
analytics.captureEvent('discover', result.title, {
attributes: { to: result.location },
value: rank,
});
};
return (
<Link to={result.location}>
<Link noTrack to={result.location} onClick={handleClick}>
<ListItem alignItems="center">
{icon && <ListItemIcon>{icon}</ListItemIcon>}
<ListItemText
@@ -0,0 +1,36 @@
/*
* Copyright 2021 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-check
/**
* @param {import('knex').Knex} knex
*/
exports.up = async function up(knex) {
await knex.schema.alterTable('facts', table => {
table
.dateTime('timestamp', { precision: 0 })
.defaultTo(knex.fn.now())
.notNullable()
.comment('The timestamp when this entry was created')
.alter();
});
};
/**
* @param {import('knex').Knex} _knex
*/
exports.down = async function down(_knex) {};
+10 -1
View File
@@ -8,6 +8,7 @@ import { Config } from '@backstage/config';
import { DateTime } from 'luxon';
import { Duration } from 'luxon';
import { DurationLike } from 'luxon';
import { JsonValue } from '@backstage/types';
import { Logger } from 'winston';
import { PluginEndpointDiscovery } from '@backstage/backend-common';
import { TokenManager } from '@backstage/backend-common';
@@ -76,7 +77,14 @@ export type FactRetrieverRegistration = {
// @public
export type FactSchema = {
[name: string]: {
type: 'integer' | 'float' | 'string' | 'boolean' | 'datetime' | 'set';
type:
| 'integer'
| 'float'
| 'string'
| 'boolean'
| 'datetime'
| 'set'
| 'object';
description: string;
since?: string;
metadata?: Record<string, any>;
@@ -136,6 +144,7 @@ export type TechInsightFact = {
| string[]
| boolean[]
| DateTime[]
| JsonValue
>;
timestamp?: DateTime;
};
+1
View File
@@ -36,6 +36,7 @@
"@backstage/backend-common": "^0.14.0-next.2",
"@backstage/config": "^1.0.1",
"@backstage/plugin-tech-insights-common": "^0.2.4",
"@backstage/types": "^1.0.0",
"@types/luxon": "^2.0.5",
"luxon": "^2.0.2",
"winston": "^3.2.1"
+11 -2
View File
@@ -15,6 +15,7 @@
*/
import { DateTime, Duration, DurationLike } from 'luxon';
import { Config } from '@backstage/config';
import { JsonValue } from '@backstage/types';
import {
PluginEndpointDiscovery,
TokenManager,
@@ -55,6 +56,7 @@ export type TechInsightFact = {
| string[]
| boolean[]
| DateTime[]
| JsonValue
>;
/**
@@ -94,9 +96,16 @@ export type FactSchema = {
* Type of the individual fact value
*
* Numbers are split into integers and floating point values.
* `set` indicates a collection of values
* `set` indicates a collection of values, `object` indicates JSON serializable value
*/
type: 'integer' | 'float' | 'string' | 'boolean' | 'datetime' | 'set';
type:
| 'integer'
| 'float'
| 'string'
| 'boolean'
| 'datetime'
| 'set'
| 'object';
/**
* A description of this individual fact value
@@ -54,62 +54,107 @@ const resolvedDir = resolvePackagePath(
);
describe('local publisher', () => {
it('should publish generated documentation dir', async () => {
mockFs({
[tmpDir]: {
'index.html': '',
},
describe('publish', () => {
beforeEach(() => {
mockFs({
[tmpDir]: {
'index.html': '',
},
});
});
const mockConfig = new ConfigReader({});
const publisher = LocalPublish.fromConfig(
mockConfig,
logger,
testDiscovery,
);
const mockEntity = createMockEntity();
const lowerMockEntity = createMockEntity(undefined, true);
await publisher.publish({ entity: mockEntity, directory: tmpDir });
expect(await publisher.hasDocsBeenGenerated(mockEntity)).toBe(true);
// Lower/upper should be treated the same.
expect(await publisher.hasDocsBeenGenerated(lowerMockEntity)).toBe(true);
mockFs.restore();
});
it('should respect legacy casing', async () => {
mockFs({
[tmpDir]: {
'index.html': '',
},
afterEach(() => {
mockFs.restore();
});
const mockConfig = new ConfigReader({
techdocs: {
legacyUseCaseSensitiveTripletPaths: true,
},
it('should publish generated documentation dir', async () => {
const mockConfig = new ConfigReader({});
const publisher = LocalPublish.fromConfig(
mockConfig,
logger,
testDiscovery,
);
const mockEntity = createMockEntity();
const lowerMockEntity = createMockEntity(undefined, true);
await publisher.publish({ entity: mockEntity, directory: tmpDir });
expect(await publisher.hasDocsBeenGenerated(mockEntity)).toBe(true);
// Lower/upper should be treated the same.
expect(await publisher.hasDocsBeenGenerated(lowerMockEntity)).toBe(true);
mockFs.restore();
});
const publisher = LocalPublish.fromConfig(
mockConfig,
logger,
testDiscovery,
);
const mockEntity = createMockEntity();
const lowerMockEntity = createMockEntity(undefined, true);
it('should respect legacy casing', async () => {
const mockConfig = new ConfigReader({
techdocs: {
legacyUseCaseSensitiveTripletPaths: true,
},
});
await publisher.publish({ entity: mockEntity, directory: tmpDir });
const publisher = LocalPublish.fromConfig(
mockConfig,
logger,
testDiscovery,
);
const mockEntity = createMockEntity();
const lowerMockEntity = createMockEntity(undefined, true);
expect(await publisher.hasDocsBeenGenerated(mockEntity)).toBe(true);
await publisher.publish({ entity: mockEntity, directory: tmpDir });
// Lower/upper should be treated differently.
expect(await publisher.hasDocsBeenGenerated(lowerMockEntity)).toBe(false);
expect(await publisher.hasDocsBeenGenerated(mockEntity)).toBe(true);
mockFs.restore();
// Lower/upper should be treated differently.
expect(await publisher.hasDocsBeenGenerated(lowerMockEntity)).toBe(false);
mockFs.restore();
});
it('should throw with unsafe triplet', async () => {
const mockConfig = new ConfigReader({});
const publisher = LocalPublish.fromConfig(
mockConfig,
logger,
testDiscovery,
);
const mockEntity = {
...createMockEntity(),
...{
kind: '..',
metadata: { name: '..', namespace: '..' },
},
};
await expect(() =>
publisher.publish({ entity: mockEntity, directory: tmpDir }),
).rejects.toThrowError('Unable to publish TechDocs site');
});
it('should throw with unsafe name', async () => {
const mockConfig = new ConfigReader({});
const publisher = LocalPublish.fromConfig(
mockConfig,
logger,
testDiscovery,
);
const mockEntity = {
...createMockEntity(),
...{
kind: 'component',
metadata: {
name: '../component/other-component',
namespace: 'default',
},
},
};
await expect(() =>
publisher.publish({ entity: mockEntity, directory: tmpDir }),
).rejects.toThrowError('Unable to publish TechDocs site');
});
});
describe('docsRouter', () => {
@@ -16,8 +16,13 @@
import {
PluginEndpointDiscovery,
resolvePackagePath,
resolveSafeChildPath,
} from '@backstage/backend-common';
import { Entity, CompoundEntityRef } from '@backstage/catalog-model';
import {
Entity,
CompoundEntityRef,
stringifyEntityRef,
} from '@backstage/catalog-model';
import { Config } from '@backstage/config';
import express from 'express';
import fs from 'fs-extra';
@@ -37,7 +42,7 @@ import {
getHeadersForFileExtension,
lowerCaseEntityTripletInStoragePath,
} from './helpers';
import { assertError } from '@backstage/errors';
import { ForwardedError } from '@backstage/errors';
// TODO: Use a more persistent storage than node_modules or /tmp directory.
// Make it configurable with techdocs.publisher.local.publishDirectory
@@ -103,12 +108,22 @@ export class LocalPublish implements PublisherBase {
directory,
}: PublishRequest): Promise<PublishResponse> {
const entityNamespace = entity.metadata.namespace ?? 'default';
let publishDir: string;
const publishDir = this.staticEntityPathJoin(
entityNamespace,
entity.kind,
entity.metadata.name,
);
try {
publishDir = this.staticEntityPathJoin(
entityNamespace,
entity.kind,
entity.metadata.name,
);
} catch (error) {
throw new ForwardedError(
`Unable to publish TechDocs site for entity: ${stringifyEntityRef(
entity,
)}`,
error,
);
}
if (!fs.existsSync(publishDir)) {
this.logger.info(`Could not find ${publishDir}, creating the directory.`);
@@ -144,21 +159,31 @@ export class LocalPublish implements PublisherBase {
async fetchTechDocsMetadata(
entityName: CompoundEntityRef,
): Promise<TechDocsMetadata> {
const metadataPath = this.staticEntityPathJoin(
entityName.namespace,
entityName.kind,
entityName.name,
'techdocs_metadata.json',
);
let metadataPath: string;
try {
metadataPath = this.staticEntityPathJoin(
entityName.namespace,
entityName.kind,
entityName.name,
'techdocs_metadata.json',
);
} catch (err) {
throw new ForwardedError(
`Unexpected entity when fetching metadata: ${stringifyEntityRef(
entityName,
)}`,
err,
);
}
try {
return await fs.readJson(metadataPath);
} catch (err) {
assertError(err);
this.logger.error(
throw new ForwardedError(
`Unable to read techdocs_metadata.json at ${metadataPath}. Error: ${err}`,
err,
);
throw new Error(err.message);
}
}
@@ -217,18 +242,26 @@ export class LocalPublish implements PublisherBase {
async hasDocsBeenGenerated(entity: Entity): Promise<boolean> {
const namespace = entity.metadata.namespace ?? 'default';
const indexHtmlPath = this.staticEntityPathJoin(
namespace,
entity.kind,
entity.metadata.name,
'index.html',
);
// Check if the file exists
try {
const indexHtmlPath = this.staticEntityPathJoin(
namespace,
entity.kind,
entity.metadata.name,
'index.html',
);
await fs.access(indexHtmlPath, fs.constants.F_OK);
return true;
} catch (err) {
if (err.name === 'NotAllowedError') {
this.logger.error(
`Unexpected entity when checking if generated: ${stringifyEntityRef(
entity,
)}`,
);
}
return false;
}
}
@@ -278,17 +311,25 @@ export class LocalPublish implements PublisherBase {
* Utility wrapper around path.join(), used to control legacy case logic.
*/
protected staticEntityPathJoin(...allParts: string[]): string {
if (this.legacyPathCasing) {
const [namespace, kind, name, ...parts] = allParts;
return path.join(staticDocsDir, namespace, kind, name, ...parts);
}
const [namespace, kind, name, ...parts] = allParts;
return path.join(
staticDocsDir,
namespace.toLowerCase(),
kind.toLowerCase(),
name.toLowerCase(),
...parts,
);
let staticEntityPath = staticDocsDir;
allParts
.map(part => part.split(path.sep))
.flat()
.forEach((part, index) => {
// Respect legacy path casing when operating on namespace, kind, or name.
if (index < 3) {
staticEntityPath = resolveSafeChildPath(
staticEntityPath,
this.legacyPathCasing ? part : part.toLowerCase(),
);
return;
}
// Otherwise, respect the provided case.
staticEntityPath = resolveSafeChildPath(staticEntityPath, part);
});
return staticEntityPath;
}
}
+1
View File
@@ -393,6 +393,7 @@ export type TechDocsSearchResultListItemProps = {
icon?: ReactNode;
result: any;
highlight?: ResultHighlight;
rank?: number;
lineClamp?: number;
asListItem?: boolean;
asLink?: boolean;
@@ -23,6 +23,7 @@ import {
makeStyles,
} from '@material-ui/core';
import { Link } from '@backstage/core-components';
import { useAnalytics } from '@backstage/core-plugin-api';
import { ResultHighlight } from '@backstage/plugin-search-common';
import { HighlightedSearchResultText } from '@backstage/plugin-search-react';
@@ -45,6 +46,7 @@ export type TechDocsSearchResultListItemProps = {
icon?: ReactNode;
result: any;
highlight?: ResultHighlight;
rank?: number;
lineClamp?: number;
asListItem?: boolean;
asLink?: boolean;
@@ -62,6 +64,7 @@ export const TechDocsSearchResultListItem = (
const {
result,
highlight,
rank,
lineClamp = 5,
asListItem = true,
asLink = true,
@@ -69,6 +72,15 @@ export const TechDocsSearchResultListItem = (
icon,
} = props;
const classes = useStyles();
const analytics = useAnalytics();
const handleClick = () => {
analytics.captureEvent('discover', result.title, {
attributes: { to: result.location },
value: rank,
});
};
const TextItem = () => {
const resultTitle = highlight?.fields.title ? (
<HighlightedSearchResultText
@@ -138,7 +150,13 @@ export const TechDocsSearchResultListItem = (
};
const LinkWrapper = ({ children }: PropsWithChildren<{}>) =>
asLink ? <Link to={result.location}>{children}</Link> : <>{children}</>;
asLink ? (
<Link noTrack to={result.location} onClick={handleClick}>
{children}
</Link>
) : (
<>{children}</>
);
const ListItemWrapper = ({ children }: PropsWithChildren<{}>) =>
asListItem ? (
+19 -5
View File
@@ -7,6 +7,7 @@
import { ApiRef } from '@backstage/core-plugin-api';
import { BackstagePlugin } from '@backstage/core-plugin-api';
import { BackstageUserIdentity } from '@backstage/core-plugin-api';
import { IconComponent } from '@backstage/core-plugin-api';
import { ProfileInfo } from '@backstage/core-plugin-api';
import { PropsWithChildren } from 'react';
@@ -70,6 +71,11 @@ export const UserSettingsFeatureFlags: () => JSX.Element;
// @public (undocumented)
export const UserSettingsGeneral: () => JSX.Element;
// Warning: (ae-missing-release-tag) "UserSettingsIdentityCard" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const UserSettingsIdentityCard: () => JSX.Element;
// Warning: (ae-missing-release-tag) "UserSettingsMenu" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
@@ -129,9 +135,17 @@ export const UserSettingsThemeToggle: () => JSX.Element;
// Warning: (ae-missing-release-tag) "useUserProfile" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const useUserProfile: () => {
profile: ProfileInfo;
displayName: string;
loading: boolean;
};
export const useUserProfile: () =>
| {
profile: ProfileInfo;
displayName: string;
loading: boolean;
backstageIdentity?: undefined;
}
| {
profile: ProfileInfo;
backstageIdentity: BackstageUserIdentity;
displayName: string;
loading: false;
};
```
@@ -17,6 +17,7 @@ import { Grid } from '@material-ui/core';
import React from 'react';
import { UserSettingsProfileCard } from './UserSettingsProfileCard';
import { UserSettingsAppearanceCard } from './UserSettingsAppearanceCard';
import { UserSettingsIdentityCard } from './UserSettingsIdentityCard';
export const UserSettingsGeneral = () => {
return (
@@ -27,6 +28,9 @@ export const UserSettingsGeneral = () => {
<Grid item xs={12} md={6}>
<UserSettingsAppearanceCard />
</Grid>
<Grid item xs={12} md={6}>
<UserSettingsIdentityCard />
</Grid>
</Grid>
);
};
@@ -0,0 +1,53 @@
/*
* 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 {
renderWithEffects,
wrapInTestApp,
TestApiRegistry,
} from '@backstage/test-utils';
import { screen } from '@testing-library/react';
import React from 'react';
import { UserSettingsIdentityCard } from './UserSettingsIdentityCard';
import { ApiProvider } from '@backstage/core-app-api';
import { identityApiRef } from '@backstage/core-plugin-api';
const apiRegistry = TestApiRegistry.from([
identityApiRef,
{
getProfileInfo: jest.fn(async () => ({})),
getBackstageIdentity: jest.fn(async () => ({
type: 'user' as const,
userEntityRef: 'foo:bar/foobar',
ownershipEntityRefs: ['test-ownership'],
})),
},
]);
describe('<UserSettingsIdentityCard />', () => {
it('displays an identity card', async () => {
await renderWithEffects(
wrapInTestApp(
<ApiProvider apis={apiRegistry}>
<UserSettingsIdentityCard />
</ApiProvider>,
),
);
expect(screen.getByText('test-ownership')).toBeInTheDocument();
expect(screen.getByText('foo:bar/foobar')).toBeInTheDocument();
});
});
@@ -0,0 +1,52 @@
/*
* 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 { InfoCard } from '@backstage/core-components';
import React from 'react';
import { useUserProfile } from '../useUserProfileInfo';
import Chip from '@material-ui/core/Chip';
import Grid from '@material-ui/core/Grid';
import Typography from '@material-ui/core/Typography';
export const UserSettingsIdentityCard = () => {
const { backstageIdentity } = useUserProfile();
return (
<InfoCard title="Backstage Identity">
<Grid container spacing={6}>
<Grid item xs={12} sm container>
<Grid item xs container direction="column" spacing={2}>
<Grid item xs>
<Typography variant="subtitle1" gutterBottom>
User Entity:{' '}
<Chip
label={backstageIdentity?.userEntityRef}
variant="outlined"
size="small"
/>
</Typography>
<Typography variant="subtitle1">
Ownership Entities:{' '}
{backstageIdentity?.ownershipEntityRefs.map(it => (
<Chip label={it} variant="outlined" size="small" />
))}
</Typography>
</Grid>
</Grid>
</Grid>
</Grid>
</InfoCard>
);
};
@@ -21,3 +21,4 @@ export { UserSettingsSignInAvatar } from './UserSettingsSignInAvatar';
export { UserSettingsAppearanceCard } from './UserSettingsAppearanceCard';
export { UserSettingsThemeToggle } from './UserSettingsThemeToggle';
export { UserSettingsPinToggle } from './UserSettingsPinToggle';
export { UserSettingsIdentityCard } from './UserSettingsIdentityCard';
@@ -53,6 +53,7 @@ export const useUserProfile = () => {
return {
profile: value!.profile,
backstageIdentity: value!.identity,
displayName: value!.profile.displayName ?? value!.identity.userEntityRef,
loading,
};
+36 -30
View File
@@ -2271,17 +2271,17 @@
teeny-request "^8.0.0"
uuid "^8.0.0"
"@graphiql/react@^0.4.0":
version "0.4.0"
resolved "https://registry.npmjs.org/@graphiql/react/-/react-0.4.0.tgz#55099632c29be0c49f1251904b74cbfd2d31993b"
integrity sha512-9OtwzJ3EaDgD5Qi+WtnHA8Wv0XL9l+W4n3jtNR+wFDjC2vvbEd/grPm0eSikryVcq/0q6aR4HyR3SuKj6tKPYg==
"@graphiql/react@^0.4.1":
version "0.4.1"
resolved "https://registry.npmjs.org/@graphiql/react/-/react-0.4.1.tgz#c424951f4e1b2ffa22aa514b18663d7a848ff31f"
integrity sha512-YeB26Sc223zfv6wSzygKRfeJ7JeXZW40c6vY4Om/POXuytRyrxuKynuP1Z3ueGYY4Rji8YMg6dPAjtTOUDLjZw==
dependencies:
"@graphiql/toolkit" "^0.6.0"
codemirror "^5.65.3"
codemirror-graphql "^1.3.0"
codemirror-graphql "^1.3.1"
copy-to-clipboard "^3.2.0"
escape-html "^1.0.3"
graphql-language-service "^5.0.4"
graphql-language-service "^5.0.5"
markdown-it "^12.2.0"
set-value "^4.1.0"
@@ -5016,19 +5016,19 @@
resolved "https://registry.npmjs.org/@octokit/webhooks-methods/-/webhooks-methods-2.0.0.tgz#1108b9ea661ca6c81e4a8bfa63a09eb27d5bc2db"
integrity sha512-35cfQ4YWlnZnmZKmIxlGPUPLtbkF8lr/A/1Sk1eC0ddLMwQN06dOuLc+dI3YLQS+T+MoNt3DIQ0NynwgKPilig==
"@octokit/webhooks-types@5.6.0":
version "5.6.0"
resolved "https://registry.npmjs.org/@octokit/webhooks-types/-/webhooks-types-5.6.0.tgz#cbc908ef0df997de7f65da4e4003ecb8430410d3"
integrity sha512-y3MqE6N6Ksg1+YV0sXVpW2WP7Y24h7rUp2hDJuzoqWdKGr7owmRDyHC72INwfCYNzura/vsNPXvc6Xbfp4wGGw==
"@octokit/webhooks-types@5.7.1":
version "5.7.1"
resolved "https://registry.npmjs.org/@octokit/webhooks-types/-/webhooks-types-5.7.1.tgz#26452dcd72fa77ac85bb188fda2a5980eb292932"
integrity sha512-zabCzfWvvquxDzj1lU7GhJQteACGfGXnHfROJD4A7LKhRjlkaggoSkE5cWQJJ6nW2t/UI51dSFrEA+A4mhqfPw==
"@octokit/webhooks@^9.0.1", "@octokit/webhooks@^9.14.1":
version "9.24.0"
resolved "https://registry.npmjs.org/@octokit/webhooks/-/webhooks-9.24.0.tgz#3e3b194ee67151f674e8d0d565c8179828a12b3d"
integrity sha512-s1nqplA+j4sP7Cz40jn/Q2ipkKRKJ7Gi+NzZiSnwNfisYNduLHEwMUJVBEKc5I0r6GMcZZRJOe6PJ2rJXYW66g==
version "9.25.0"
resolved "https://registry.npmjs.org/@octokit/webhooks/-/webhooks-9.25.0.tgz#f1bd7815af59fb37892b87c86d2cb8625a570e9a"
integrity sha512-pyCraAmxHSnfTMe4K+QnNH/nSCJolCc++J2SAfYBwPFm6gg2WTGxWuegzuHul+Xm71+V9qL2NhIXX48U7MvTIA==
dependencies:
"@octokit/request-error" "^2.0.2"
"@octokit/webhooks-methods" "^2.0.0"
"@octokit/webhooks-types" "5.6.0"
"@octokit/webhooks-types" "5.7.1"
aggregate-error "^3.1.0"
"@open-draft/until@^1.0.3":
@@ -9589,12 +9589,12 @@ code-point-at@^1.0.0:
resolved "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"
integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=
codemirror-graphql@^1.3.0:
version "1.3.0"
resolved "https://registry.npmjs.org/codemirror-graphql/-/codemirror-graphql-1.3.0.tgz#6ca19eb2735dbfd5ac9db59b8fc4c8fc1e34fe43"
integrity sha512-Inqecp/PpUsNFz6+V6jpgQD1m7jjGg3yby60baw2t5yb2stBH8Z/6cHm/IYp9eN0Aq2EWqomd0GkGmiISPi4jQ==
codemirror-graphql@^1.3.1:
version "1.3.1"
resolved "https://registry.npmjs.org/codemirror-graphql/-/codemirror-graphql-1.3.1.tgz#c852b12b6909783681a5e37d61d1627a78f9c7a6"
integrity sha512-jlLwTARoMeuYLR5sQYbh5uYewIoYUYAn+0lOIKXpaHudk9X1rOrP/WtOqfDza1ETnyfnlpLidBnpieIMKktriQ==
dependencies:
graphql-language-service "^5.0.4"
graphql-language-service "^5.0.5"
codemirror@^5.65.3:
version "5.65.3"
@@ -12407,6 +12407,7 @@ evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3:
"@backstage/plugin-cloudbuild" "^0.3.6-next.1"
"@backstage/plugin-code-coverage" "^0.1.33-next.1"
"@backstage/plugin-cost-insights" "^0.11.28-next.2"
"@backstage/plugin-dynatrace" "^0.0.0"
"@backstage/plugin-explore" "^0.3.37-next.1"
"@backstage/plugin-gcalendar" "^0.3.2-next.1"
"@backstage/plugin-gcp-projects" "^0.3.25-next.1"
@@ -12618,7 +12619,7 @@ express-xml-bodyparser@^0.3.0:
dependencies:
xml2js "^0.4.11"
express@^4.17.1, express@^4.17.3:
express@^4.17.1, express@^4.17.3, express@^4.18.1:
version "4.18.1"
resolved "https://registry.npmjs.org/express/-/express-4.18.1.tgz#7797de8b9c72c857b9cd0e14a5eea80666267caf"
integrity sha512-zZBcOX9TfehHQhtupq57OF8lFZ3UZi08Y97dwFCkD8p9d/d2Y3M+ykKcwaMDEL+4qyUolgBDX6AblpR3fL212Q==
@@ -13905,14 +13906,14 @@ grapheme-splitter@^1.0.4:
integrity sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==
graphiql@^1.5.12, graphiql@^1.8.8:
version "1.9.6"
resolved "https://registry.npmjs.org/graphiql/-/graphiql-1.9.6.tgz#ab1714a0200bdcf358761d7e9625de41fe06a98c"
integrity sha512-HxKM2cu6SQUi8x1QqZc/GkLBnyjZerPOKmiBfsZmIWYLtZTJTd4dezeraD2klB80FkYKgPVPbojGLofuLq8w3w==
version "1.9.7"
resolved "https://registry.npmjs.org/graphiql/-/graphiql-1.9.7.tgz#2edadea4fbbd723f9ba27a1f464f4ff5b20866bd"
integrity sha512-rn0njwDkCpFn5GwDbSuzt7GwjiFLhYCdgiscYm4n8Oq9EeOyGrIxQK/PjUz1YaR/+T7lg1raIBuRAX/Nei9KcQ==
dependencies:
"@graphiql/react" "^0.4.0"
"@graphiql/react" "^0.4.1"
"@graphiql/toolkit" "^0.6.0"
entities "^2.0.0"
graphql-language-service "^5.0.4"
graphql-language-service "^5.0.5"
markdown-it "^12.2.0"
graphlib@^2.1.8:
@@ -13944,10 +13945,10 @@ graphql-executor@0.0.23:
resolved "https://registry.npmjs.org/graphql-executor/-/graphql-executor-0.0.23.tgz#205c1764b39ee0fcf611553865770f37b45851a2"
integrity sha512-3Ivlyfjaw3BWmGtUSnMpP/a4dcXCp0mJtj0PiPG14OKUizaMKlSEX+LX2Qed0LrxwniIwvU6B4w/koVjEPyWJg==
graphql-language-service@^5.0.4:
version "5.0.4"
resolved "https://registry.npmjs.org/graphql-language-service/-/graphql-language-service-5.0.4.tgz#068dd4ff5dc6fcc6c8560ccc8f05311d5fd63fcd"
integrity sha512-lX+ahYBwvTHJe1N7JqA08moNwbr0RWaFILxVnbciaaeb469TTIhQi87ZgVJ/y9Szre4d0r3vjIt2EstwafzcDA==
graphql-language-service@^5.0.5:
version "5.0.5"
resolved "https://registry.npmjs.org/graphql-language-service/-/graphql-language-service-5.0.5.tgz#894c08bee50070c97cc53ae514847aeef41bc0ac"
integrity sha512-hekBLI73r6ghShWrIMJ7Pe4Z+yJrda/U+kLenNJLNswuCrR0XfFOv5pNtnSXLcjFZkQfY1bwGV0D8IVKZEOW5Q==
dependencies:
nullthrows "^1.0.0"
vscode-languageserver-types "^3.15.1"
@@ -26099,7 +26100,7 @@ write-pkg@^4.0.0:
type-fest "^0.4.1"
write-json-file "^3.2.0"
ws@8.7.0, ws@^8.0.0, ws@^8.3.0:
ws@8.7.0:
version "8.7.0"
resolved "https://registry.npmjs.org/ws/-/ws-8.7.0.tgz#eaf9d874b433aa00c0e0d8752532444875db3957"
integrity sha512-c2gsP0PRwcLFzUiA8Mkr37/MI7ilIlHQxaEAtd0uNMbVMoy8puJyafRlm0bV9MbGSabUPeLrRRaqIBcFcA2Pqg==
@@ -26109,6 +26110,11 @@ ws@^7.3.1, ws@^7.4.6:
resolved "https://registry.npmjs.org/ws/-/ws-7.5.7.tgz#9e0ac77ee50af70d58326ecff7e85eb3fa375e67"
integrity sha512-KMvVuFzpKBuiIXW3E4u3mySRO2/mCHSyZDJQM5NQ9Q9KHWHWh0NHgfbRMLLrceUK5qAL4ytALJbpRMjixFZh8A==
ws@^8.0.0, ws@^8.3.0:
version "8.8.0"
resolved "https://registry.npmjs.org/ws/-/ws-8.8.0.tgz#8e71c75e2f6348dbf8d78005107297056cb77769"
integrity sha512-JDAgSYQ1ksuwqfChJusw1LSJ8BizJ2e/vVu5Lxjq3YvNJNlROv1ui4i+c/kUUrPheBvQl4c5UbERhTwKa6QBJQ==
ws@^8.4.2:
version "8.5.0"
resolved "https://registry.npmjs.org/ws/-/ws-8.5.0.tgz#bfb4be96600757fe5382de12c670dab984a1ed4f"