@backstage/core-app-api 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @backstage/core-app-api
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - e2eb92c109: Removed previously deprecated `ApiRegistry` export.
8
+
9
+ ### Patch Changes
10
+
11
+ - 34442cd5cf: Fixed an issue where valid SAML and GitHub sessions would be considered invalid and not be stored.
12
+
13
+ Deprecated the `SamlSession` and `GithubSession` types.
14
+
15
+ - 784d8078ab: Removed direct and transitive MUI dependencies.
16
+ - Updated dependencies
17
+ - @backstage/config@0.1.12
18
+ - @backstage/core-plugin-api@0.5.0
19
+
3
20
  ## 0.3.1
4
21
 
5
22
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ReactNode, PropsWithChildren, ComponentType } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { ApiHolder, ApiRef, ApiFactory, AnyApiRef, ProfileInfo, BackstageIdentity, OAuthRequestApi, DiscoveryApi, AuthProviderInfo, OAuthApi, SessionApi, SessionState, AuthRequestOptions, gitlabAuthApiRef, googleAuthApiRef, OpenIdConnectApi, ProfileInfoApi, BackstageIdentityApi, oktaAuthApiRef, auth0AuthApiRef, microsoftAuthApiRef, oneloginAuthApiRef, bitbucketAuthApiRef, atlassianAuthApiRef, AlertApi, AlertMessage, AnalyticsApi, AnalyticsEvent, AppThemeApi, AppTheme, ErrorApi, ErrorApiError, ErrorApiErrorContext, FeatureFlagsApi, FeatureFlag, FeatureFlagsSaveOptions, FetchApi, IdentityApi, OAuthRequesterOptions, OAuthRequester, PendingOAuthRequest, StorageApi, StorageValueSnapshot, BackstagePlugin, IconComponent, ExternalRouteRef, AnyApiFactory, PluginOutput, RouteRef, SubRouteRef } from '@backstage/core-plugin-api';
3
+ import { ApiHolder, ApiRef, ApiFactory, AnyApiRef, ProfileInfo, BackstageIdentity, OAuthRequestApi, DiscoveryApi, AuthProviderInfo, OAuthApi, SessionApi, SessionState, AuthRequestOptions, gitlabAuthApiRef, googleAuthApiRef, OpenIdConnectApi, ProfileInfoApi, BackstageIdentityApi, oktaAuthApiRef, auth0AuthApiRef, microsoftAuthApiRef, oneloginAuthApiRef, bitbucketAuthApiRef, atlassianAuthApiRef, AlertApi, AlertMessage, AnalyticsApi, AnalyticsEvent, AppThemeApi, AppTheme, ErrorApi, ErrorApiError, ErrorApiErrorContext, FeatureFlagsApi, FeatureFlag, FeatureFlagsSaveOptions, FetchApi, IdentityApi, OAuthRequesterOptions, OAuthRequester, PendingOAuthRequest, StorageApi, StorageValueSnapshot, BackstagePlugin, IconComponent, ExternalRouteRef, AnyApiFactory, RouteRef, SubRouteRef } from '@backstage/core-plugin-api';
4
4
  import * as _backstage_types from '@backstage/types';
5
5
  import { Observable, JsonValue } from '@backstage/types';
6
6
  import { Config, AppConfig } from '@backstage/config';
@@ -30,45 +30,6 @@ declare const ApiProvider: {
30
30
  };
31
31
  };
32
32
 
33
- declare type ApiImpl<T = unknown> = readonly [ApiRef<T>, T];
34
- declare class ApiRegistryBuilder {
35
- private apis;
36
- add<T, I extends T>(api: ApiRef<T>, impl: I): I;
37
- build(): ApiRegistry;
38
- }
39
- /**
40
- * A registry for utility APIs.
41
- *
42
- * @public
43
- * @deprecated Will be removed, use {@link @backstage/test-utils#TestApiProvider} or {@link @backstage/test-utils#TestApiRegistry} instead.
44
- */
45
- declare class ApiRegistry implements ApiHolder {
46
- private readonly apis;
47
- static builder(): ApiRegistryBuilder;
48
- /**
49
- * Creates a new ApiRegistry with a list of API implementations.
50
- *
51
- * @param apis - A list of pairs mapping an ApiRef to its respective implementation
52
- */
53
- static from(apis: ApiImpl[]): ApiRegistry;
54
- /**
55
- * Creates a new ApiRegistry with a single API implementation.
56
- *
57
- * @param api - ApiRef for the API to add
58
- * @param impl - Implementation of the API to add
59
- */
60
- static with<T>(api: ApiRef<T>, impl: T): ApiRegistry;
61
- constructor(apis: Map<string, unknown>);
62
- /**
63
- * Returns a new ApiRegistry with the provided API added to the existing ones.
64
- *
65
- * @param api - ApiRef for the API to add
66
- * @param impl - Implementation of the API to add
67
- */
68
- with<T>(api: ApiRef<T>, impl: T): ApiRegistry;
69
- get<T>(api: ApiRef<T>): T | undefined;
70
- }
71
-
72
33
  /**
73
34
  * @public
74
35
  */
@@ -134,6 +95,7 @@ declare class ApiFactoryRegistry implements ApiFactoryHolder {
134
95
  * Session information for GitHub auth.
135
96
  *
136
97
  * @public
98
+ * @deprecated This type is internal and will be removed
137
99
  */
138
100
  declare type GithubSession = {
139
101
  providerInfo: {
@@ -271,8 +233,9 @@ declare class SamlAuth implements ProfileInfoApi, BackstageIdentityApi, SessionA
271
233
  * Session information for SAML auth.
272
234
  *
273
235
  * @public
236
+ * @deprecated This type is internal and will be removed
274
237
  */
275
- declare type SamlSession = {
238
+ declare type ExportedSamlSession = {
276
239
  userId: string;
277
240
  profile: ProfileInfo;
278
241
  backstageIdentity: BackstageIdentity;
@@ -782,11 +745,14 @@ declare type AppOptions = {
782
745
  /**
783
746
  * A list of all plugins to include in the app.
784
747
  */
785
- plugins?: (Omit<BackstagePlugin<any, any>, 'output'> & {
786
- output(): (PluginOutput | {
748
+ plugins?: Array<BackstagePlugin<any, any> & {
749
+ output?(): Array<{
750
+ type: 'feature-flag';
751
+ name: string;
752
+ } | {
787
753
  type: string;
788
- })[];
789
- })[];
754
+ }>;
755
+ }>;
790
756
  /**
791
757
  * Supply components to the app to override the default ones.
792
758
  */
@@ -971,4 +937,4 @@ declare type FeatureFlaggedProps = {
971
937
  */
972
938
  declare const FeatureFlagged: (props: FeatureFlaggedProps) => JSX.Element;
973
939
 
974
- export { AlertApiForwarder, ApiFactoryHolder, ApiFactoryRegistry, ApiFactoryScope, ApiProvider, ApiProviderProps, ApiRegistry, ApiResolver, AppComponents, AppConfigLoader, AppContext, AppIcons, AppOptions, AppRouteBinder, AppThemeSelector, AtlassianAuth, Auth0Auth, AuthApiCreateOptions, BackstageApp, BitbucketAuth, BitbucketSession, BootErrorPageProps, ErrorAlerter, ErrorApiForwarder, ErrorBoundaryFallbackProps, FeatureFlagged, FeatureFlaggedProps, FetchMiddleware, FetchMiddlewares, FlatRoutes, FlatRoutesProps, GithubAuth, GithubSession, GitlabAuth, GoogleAuth, LocalStorageFeatureFlags, MicrosoftAuth, NoOpAnalyticsApi, OAuth2, OAuth2CreateOptions, OAuth2Session, OAuthApiCreateOptions, OAuthRequestManager, OktaAuth, OneLoginAuth, OneLoginAuthCreateOptions, SamlAuth, SamlSession, SignInPageProps, SignInResult, UnhandledErrorForwarder, UrlPatternDiscovery, WebStorage, createFetchApi, createSpecializedApp, defaultConfigLoader };
940
+ export { AlertApiForwarder, ApiFactoryHolder, ApiFactoryRegistry, ApiFactoryScope, ApiProvider, ApiProviderProps, ApiResolver, AppComponents, AppConfigLoader, AppContext, AppIcons, AppOptions, AppRouteBinder, AppThemeSelector, AtlassianAuth, Auth0Auth, AuthApiCreateOptions, BackstageApp, BitbucketAuth, BitbucketSession, BootErrorPageProps, ErrorAlerter, ErrorApiForwarder, ErrorBoundaryFallbackProps, FeatureFlagged, FeatureFlaggedProps, FetchMiddleware, FetchMiddlewares, FlatRoutes, FlatRoutesProps, GithubAuth, GithubSession, GitlabAuth, GoogleAuth, LocalStorageFeatureFlags, MicrosoftAuth, NoOpAnalyticsApi, OAuth2, OAuth2CreateOptions, OAuth2Session, OAuthApiCreateOptions, OAuthRequestManager, OktaAuth, OneLoginAuth, OneLoginAuthCreateOptions, SamlAuth, ExportedSamlSession as SamlSession, SignInPageProps, SignInResult, UnhandledErrorForwarder, UrlPatternDiscovery, WebStorage, createFetchApi, createSpecializedApp, defaultConfigLoader };
package/dist/index.esm.js CHANGED
@@ -8,7 +8,6 @@ import { ConfigReader } from '@backstage/config';
8
8
  export { ConfigReader } from '@backstage/config';
9
9
  import { matchRoutes, generatePath, useLocation, Routes, Route, useRoutes } from 'react-router-dom';
10
10
  import useAsync from 'react-use/lib/useAsync';
11
- import { UserIdentity } from '@backstage/core-components';
12
11
  import useObservable from 'react-use/lib/useObservable';
13
12
 
14
13
  class ApiAggregator {
@@ -42,39 +41,6 @@ ApiProvider.propTypes = {
42
41
  children: PropTypes.node
43
42
  };
44
43
 
45
- class ApiRegistryBuilder {
46
- constructor() {
47
- this.apis = [];
48
- }
49
- add(api, impl) {
50
- this.apis.push([api.id, impl]);
51
- return impl;
52
- }
53
- build() {
54
- return new ApiRegistry(new Map(this.apis));
55
- }
56
- }
57
- class ApiRegistry {
58
- constructor(apis) {
59
- this.apis = apis;
60
- }
61
- static builder() {
62
- return new ApiRegistryBuilder();
63
- }
64
- static from(apis) {
65
- return new ApiRegistry(new Map(apis.map(([api, impl]) => [api.id, impl])));
66
- }
67
- static with(api, impl) {
68
- return new ApiRegistry(/* @__PURE__ */ new Map([[api.id, impl]]));
69
- }
70
- with(api, impl) {
71
- return new ApiRegistry(new Map([...this.apis, [api.id, impl]]));
72
- }
73
- get(api) {
74
- return this.apis.get(api.id);
75
- }
76
- }
77
-
78
44
  class ApiResolver {
79
45
  constructor(factories) {
80
46
  this.factories = factories;
@@ -1119,7 +1085,6 @@ class OktaAuth {
1119
1085
  }
1120
1086
 
1121
1087
  const samlSessionSchema = z.object({
1122
- userId: z.string(),
1123
1088
  profile: z.object({
1124
1089
  email: z.string().optional(),
1125
1090
  displayName: z.string().optional(),
@@ -2344,6 +2309,39 @@ const defaultConfigLoader = async (runtimeConfigJson = "__APP_INJECTED_RUNTIME_C
2344
2309
  return configs;
2345
2310
  };
2346
2311
 
2312
+ class ApiRegistryBuilder {
2313
+ constructor() {
2314
+ this.apis = [];
2315
+ }
2316
+ add(api, impl) {
2317
+ this.apis.push([api.id, impl]);
2318
+ return impl;
2319
+ }
2320
+ build() {
2321
+ return new ApiRegistry(new Map(this.apis));
2322
+ }
2323
+ }
2324
+ class ApiRegistry {
2325
+ constructor(apis) {
2326
+ this.apis = apis;
2327
+ }
2328
+ static builder() {
2329
+ return new ApiRegistryBuilder();
2330
+ }
2331
+ static from(apis) {
2332
+ return new ApiRegistry(new Map(apis.map(([api, impl]) => [api.id, impl])));
2333
+ }
2334
+ static with(api, impl) {
2335
+ return new ApiRegistry(/* @__PURE__ */ new Map([[api.id, impl]]));
2336
+ }
2337
+ with(api, impl) {
2338
+ return new ApiRegistry(new Map([...this.apis, [api.id, impl]]));
2339
+ }
2340
+ get(api) {
2341
+ return this.apis.get(api.id);
2342
+ }
2343
+ }
2344
+
2347
2345
  function generateBoundRoutes(bindRoutes) {
2348
2346
  const result = /* @__PURE__ */ new Map();
2349
2347
  if (bindRoutes) {
@@ -2390,7 +2388,7 @@ function useConfigLoader(configLoader, components, appThemeApi) {
2390
2388
  if (noConfigNode) {
2391
2389
  return {
2392
2390
  node: /* @__PURE__ */ React.createElement(ApiProvider, {
2393
- apis: ApiRegistry.from([[appThemeApiRef, appThemeApi]])
2391
+ apis: ApiRegistry.with(appThemeApiRef, appThemeApi)
2394
2392
  }, /* @__PURE__ */ React.createElement(ThemeProvider, null, noConfigNode))
2395
2393
  };
2396
2394
  }
@@ -2475,14 +2473,11 @@ class AppManager {
2475
2473
  }
2476
2474
  } else {
2477
2475
  for (const output of plugin.output()) {
2478
- switch (output.type) {
2479
- case "feature-flag": {
2480
- featureFlagsApi.registerFlag({
2481
- name: output.name,
2482
- pluginId: plugin.getId()
2483
- });
2484
- break;
2485
- }
2476
+ if (output.type === "feature-flag") {
2477
+ featureFlagsApi.registerFlag({
2478
+ name: output.name,
2479
+ pluginId: plugin.getId()
2480
+ });
2486
2481
  }
2487
2482
  }
2488
2483
  }
@@ -2529,7 +2524,26 @@ class AppManager {
2529
2524
  const configApi = useApi(configApiRef);
2530
2525
  const mountPath = `${getBasePath(configApi)}/*`;
2531
2526
  if (!SignInPageComponent) {
2532
- this.appIdentityProxy.setTarget(UserIdentity.createGuest());
2527
+ this.appIdentityProxy.setTarget({
2528
+ getUserId: () => "guest",
2529
+ getIdToken: async () => void 0,
2530
+ getProfile: () => ({
2531
+ email: "guest@example.com",
2532
+ displayName: "Guest"
2533
+ }),
2534
+ getProfileInfo: async () => ({
2535
+ email: "guest@example.com",
2536
+ displayName: "Guest"
2537
+ }),
2538
+ getBackstageIdentity: async () => ({
2539
+ type: "user",
2540
+ userEntityRef: "user:default/guest",
2541
+ ownershipEntityRefs: ["user:default/guest"]
2542
+ }),
2543
+ getCredentials: async () => ({}),
2544
+ signOut: async () => {
2545
+ }
2546
+ });
2533
2547
  return /* @__PURE__ */ React.createElement(RouterComponent, null, /* @__PURE__ */ React.createElement(RouteTracker, {
2534
2548
  tree: children
2535
2549
  }), /* @__PURE__ */ React.createElement(Routes, null, /* @__PURE__ */ React.createElement(Route, {
@@ -2653,5 +2667,5 @@ const FlatRoutes = (props) => {
2653
2667
  return useRoutes(routes);
2654
2668
  };
2655
2669
 
2656
- export { AlertApiForwarder, ApiFactoryRegistry, ApiProvider, ApiRegistry, ApiResolver, AppThemeSelector, AtlassianAuth, Auth0Auth, BitbucketAuth, ErrorAlerter, ErrorApiForwarder, FeatureFlagged, FetchMiddlewares, FlatRoutes, GithubAuth, GitlabAuth, GoogleAuth, LocalStorageFeatureFlags, MicrosoftAuth, NoOpAnalyticsApi, OAuth2, OAuthRequestManager, OktaAuth, OneLoginAuth, SamlAuth, UnhandledErrorForwarder, UrlPatternDiscovery, WebStorage, createFetchApi, createSpecializedApp, defaultConfigLoader };
2670
+ export { AlertApiForwarder, ApiFactoryRegistry, ApiProvider, ApiResolver, AppThemeSelector, AtlassianAuth, Auth0Auth, BitbucketAuth, ErrorAlerter, ErrorApiForwarder, FeatureFlagged, FetchMiddlewares, FlatRoutes, GithubAuth, GitlabAuth, GoogleAuth, LocalStorageFeatureFlags, MicrosoftAuth, NoOpAnalyticsApi, OAuth2, OAuthRequestManager, OktaAuth, OneLoginAuth, SamlAuth, UnhandledErrorForwarder, UrlPatternDiscovery, WebStorage, createFetchApi, createSpecializedApp, defaultConfigLoader };
2657
2671
  //# sourceMappingURL=index.esm.js.map