@backstage/core-app-api 0.1.20 → 0.1.21

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,24 @@
1
1
  # @backstage/core-app-api
2
2
 
3
+ ## 0.1.21
4
+
5
+ ### Patch Changes
6
+
7
+ - 0b1de52732: Migrated to using new `ErrorApiError` and `ErrorApiErrorContext` names.
8
+ - ecd1fcb80a: Deprecated the `BackstagePluginWithAnyOutput` type.
9
+ - 32bfbafb0f: Start exporting and marking several types as public to address errors in the API report.
10
+ - 014cbf8cb9: The `createApp` function from `@backstage/core-app-api` has been deprecated, with two new options being provided as a replacement.
11
+
12
+ The first and most commonly used one is `createApp` from the new `@backstage/app-defaults` package, which behaves just like the existing `createApp`. In the future this method is likely to be expanded to add more APIs and other pieces into the default setup, for example the Utility APIs from `@backstage/integration-react`.
13
+
14
+ The other option that we now provide is to use `createSpecializedApp` from `@backstage/core-app-api`. This is a more low-level API where you need to provide a full set of options, including your own `components`, `icons`, `defaultApis`, and `themes`. The `createSpecializedApp` way of creating an app is particularly useful if you are not using `@backstage/core-components` or MUI, as it allows you to avoid those dependencies completely.
15
+
16
+ - 475edb5bc5: move the BehaviorSubject init into the constructor
17
+ - Updated dependencies
18
+ - @backstage/core-components@0.7.4
19
+ - @backstage/core-plugin-api@0.2.0
20
+ - @backstage/app-defaults@0.1.1
21
+
3
22
  ## 0.1.20
4
23
 
5
24
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,12 +1,16 @@
1
- import { PropsWithChildren, ReactNode, ComponentType } from 'react';
1
+ import { ReactNode, PropsWithChildren, ComponentType } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
4
- import { ApiHolder, ApiRef, ApiFactory, AnyApiRef, ProfileInfo, BackstageIdentity, SessionState, OAuthRequestApi, DiscoveryApi, AuthProvider, OAuthApi, SessionApi, AuthRequestOptions, gitlabAuthApiRef, googleAuthApiRef, OpenIdConnectApi, ProfileInfoApi, BackstageIdentityApi, oktaAuthApiRef, auth0AuthApiRef, microsoftAuthApiRef, oneloginAuthApiRef, bitbucketAuthApiRef, atlassianAuthApiRef, AlertApi, AlertMessage, AnalyticsApi, AnalyticsEvent, AppThemeApi, AppTheme, ErrorApi, ErrorContext, FeatureFlagsApi, FeatureFlag, FeatureFlagsSaveOptions, AuthRequesterOptions, AuthRequester, PendingAuthRequest, StorageApi, StorageValueChange, IconComponent, BackstagePlugin, ExternalRouteRef, PluginOutput, AnyApiFactory, RouteRef, SubRouteRef } from '@backstage/core-plugin-api';
3
+ import { ApiHolder, ApiRef, ApiFactory, AnyApiRef, ProfileInfo, BackstageIdentity, SessionState, OAuthRequestApi, DiscoveryApi, AuthProvider, OAuthApi, SessionApi, AuthRequestOptions, gitlabAuthApiRef, googleAuthApiRef, OpenIdConnectApi, ProfileInfoApi, BackstageIdentityApi, oktaAuthApiRef, auth0AuthApiRef, microsoftAuthApiRef, oneloginAuthApiRef, bitbucketAuthApiRef, atlassianAuthApiRef, AlertApi, AlertMessage, AnalyticsApi, AnalyticsEvent, AppThemeApi, AppTheme, ErrorApi, ErrorApiError, ErrorApiErrorContext, FeatureFlagsApi, FeatureFlag, FeatureFlagsSaveOptions, AuthRequesterOptions, AuthRequester, PendingAuthRequest, StorageApi, StorageValueChange, BackstagePlugin, IconComponent, ExternalRouteRef, PluginOutput, AnyApiFactory, RouteRef, SubRouteRef } from '@backstage/core-plugin-api';
5
4
  import * as _backstage_types from '@backstage/types';
6
5
  import { Observable } from '@backstage/types';
7
6
  import { AppConfig } from '@backstage/config';
8
7
  export { ConfigReader } from '@backstage/config';
8
+ import { OptionalAppOptions } from '@backstage/app-defaults';
9
9
 
10
+ /**
11
+ * Prop types for the ApiProvider component.
12
+ * @public
13
+ */
10
14
  declare type ApiProviderProps = {
11
15
  apis: ApiHolder;
12
16
  children: ReactNode;
@@ -94,6 +98,10 @@ declare class ApiResolver implements ApiHolder {
94
98
  private loadDeps;
95
99
  }
96
100
 
101
+ /**
102
+ * Scope type when registering API factories.
103
+ * @public
104
+ */
97
105
  declare type ApiFactoryScope = 'default' | 'app' | 'static';
98
106
  /**
99
107
  * ApiFactoryRegistry is an ApiFactoryHolder implementation that enables
@@ -153,10 +161,18 @@ declare type SessionManager<T> = {
153
161
  sessionState$(): Observable<SessionState>;
154
162
  };
155
163
 
164
+ /**
165
+ * Create options for OAuth APIs.
166
+ * @public
167
+ */
156
168
  declare type OAuthApiCreateOptions = AuthApiCreateOptions & {
157
169
  oauthRequestApi: OAuthRequestApi;
158
170
  defaultScopes?: string[];
159
171
  };
172
+ /**
173
+ * Generic create options for auth APIs.
174
+ * @public
175
+ */
160
176
  declare type AuthApiCreateOptions = {
161
177
  discoveryApi: DiscoveryApi;
162
178
  environment?: string;
@@ -173,6 +189,9 @@ declare type AuthApiCreateOptions = {
173
189
  declare class GithubAuth implements OAuthApi, SessionApi {
174
190
  private readonly sessionManager;
175
191
  static create({ discoveryApi, environment, provider, oauthRequestApi, defaultScopes, }: OAuthApiCreateOptions): GithubAuth;
192
+ /**
193
+ * @deprecated will be made private in the future. Use create method instead.
194
+ */
176
195
  constructor(sessionManager: SessionManager<GithubSession>);
177
196
  signIn(): Promise<void>;
178
197
  signOut(): Promise<void>;
@@ -217,7 +236,11 @@ declare type OAuth2Session = {
217
236
  backstageIdentity: BackstageIdentity;
218
237
  };
219
238
 
220
- declare type CreateOptions$1 = OAuthApiCreateOptions & {
239
+ /**
240
+ * OAuth2 create options.
241
+ * @public
242
+ */
243
+ declare type OAuth2CreateOptions = OAuthApiCreateOptions & {
221
244
  scopeTransform?: (scopes: string[]) => string[];
222
245
  };
223
246
  /**
@@ -226,9 +249,12 @@ declare type CreateOptions$1 = OAuthApiCreateOptions & {
226
249
  * @public
227
250
  */
228
251
  declare class OAuth2 implements OAuthApi, OpenIdConnectApi, ProfileInfoApi, BackstageIdentityApi, SessionApi {
229
- static create({ discoveryApi, environment, provider, oauthRequestApi, defaultScopes, scopeTransform, }: CreateOptions$1): OAuth2;
252
+ static create({ discoveryApi, environment, provider, oauthRequestApi, defaultScopes, scopeTransform, }: OAuth2CreateOptions): OAuth2;
230
253
  private readonly sessionManager;
231
254
  private readonly scopeTransform;
255
+ /**
256
+ * @deprecated will be made private in the future. Use create method instead.
257
+ */
232
258
  constructor(options: {
233
259
  sessionManager: SessionManager<OAuth2Session>;
234
260
  scopeTransform: (scopes: string[]) => string[];
@@ -272,6 +298,9 @@ declare class SamlAuth implements ProfileInfoApi, BackstageIdentityApi, SessionA
272
298
  private readonly sessionManager;
273
299
  static create({ discoveryApi, environment, provider, }: AuthApiCreateOptions): SamlAuth;
274
300
  sessionState$(): Observable<SessionState>;
301
+ /**
302
+ * @deprecated will be made private in the future. Use create method instead.
303
+ */
275
304
  constructor(sessionManager: SessionManager<SamlSession>);
276
305
  signIn(): Promise<void>;
277
306
  signOut(): Promise<void>;
@@ -297,7 +326,11 @@ declare class MicrosoftAuth {
297
326
  static create({ environment, provider, oauthRequestApi, discoveryApi, defaultScopes, }: OAuthApiCreateOptions): typeof microsoftAuthApiRef.T;
298
327
  }
299
328
 
300
- declare type CreateOptions = {
329
+ /**
330
+ * OneLogin auth provider create options.
331
+ * @public
332
+ */
333
+ declare type OneLoginAuthCreateOptions = {
301
334
  discoveryApi: DiscoveryApi;
302
335
  oauthRequestApi: OAuthRequestApi;
303
336
  environment?: string;
@@ -311,7 +344,7 @@ declare type CreateOptions = {
311
344
  * @public
312
345
  */
313
346
  declare class OneLoginAuth {
314
- static create({ discoveryApi, environment, provider, oauthRequestApi, }: CreateOptions): typeof oneloginAuthApiRef.T;
347
+ static create({ discoveryApi, environment, provider, oauthRequestApi, }: OneLoginAuthCreateOptions): typeof oneloginAuthApiRef.T;
315
348
  }
316
349
 
317
350
  /**
@@ -415,10 +448,10 @@ declare class ErrorAlerter implements ErrorApi {
415
448
  private readonly alertApi;
416
449
  private readonly errorApi;
417
450
  constructor(alertApi: AlertApi, errorApi: ErrorApi);
418
- post(error: Error, context?: ErrorContext): void;
451
+ post(error: ErrorApiError, context?: ErrorApiErrorContext): void;
419
452
  error$(): _backstage_types.Observable<{
420
- error: _backstage_core_plugin_api.Error;
421
- context?: ErrorContext | undefined;
453
+ error: ErrorApiError;
454
+ context?: ErrorApiErrorContext | undefined;
422
455
  }>;
423
456
  }
424
457
 
@@ -429,10 +462,10 @@ declare class ErrorAlerter implements ErrorApi {
429
462
  */
430
463
  declare class ErrorApiForwarder implements ErrorApi {
431
464
  private readonly subject;
432
- post(error: Error, context?: ErrorContext): void;
465
+ post(error: ErrorApiError, context?: ErrorApiErrorContext): void;
433
466
  error$(): Observable<{
434
467
  error: Error;
435
- context?: ErrorContext;
468
+ context?: ErrorApiErrorContext;
436
469
  }>;
437
470
  }
438
471
 
@@ -445,7 +478,7 @@ declare class UnhandledErrorForwarder {
445
478
  /**
446
479
  * Add event listener, such that unhandled errors can be forwarded using an given `ErrorApi` instance
447
480
  */
448
- static forward(errorApi: ErrorApi, errorContext: ErrorContext): void;
481
+ static forward(errorApi: ErrorApi, errorContext: ErrorApiErrorContext): void;
449
482
  }
450
483
 
451
484
  /**
@@ -506,11 +539,6 @@ declare class WebStorage implements StorageApi {
506
539
  private readonly observable;
507
540
  }
508
541
 
509
- declare type AppIconsKey = 'brokenImage' | 'catalog' | 'scaffolder' | 'techdocs' | 'search' | 'chat' | 'dashboard' | 'docs' | 'email' | 'github' | 'group' | 'help' | 'kind:api' | 'kind:component' | 'kind:domain' | 'kind:group' | 'kind:location' | 'kind:system' | 'kind:user' | 'user' | 'warning';
510
- declare type AppIcons = {
511
- [key in AppIconsKey]: IconComponent;
512
- };
513
-
514
542
  /**
515
543
  * Props for the `BootErrorPage` component of {@link AppComponents}.
516
544
  *
@@ -572,7 +600,7 @@ declare type AppComponents = {
572
600
  Progress: ComponentType<{}>;
573
601
  Router: ComponentType<{}>;
574
602
  ErrorBoundaryFallback: ComponentType<ErrorBoundaryFallbackProps>;
575
- ThemeProvider: ComponentType<{}>;
603
+ ThemeProvider?: ComponentType<{}>;
576
604
  /**
577
605
  * An optional sign-in page that will be rendered instead of the AppRouter at startup.
578
606
  *
@@ -584,6 +612,34 @@ declare type AppComponents = {
584
612
  */
585
613
  SignInPage?: ComponentType<SignInPageProps>;
586
614
  };
615
+ /**
616
+ * A set of well-known icons that should be available within an app.
617
+ *
618
+ * @public
619
+ */
620
+ declare type AppIcons = {
621
+ 'kind:api': IconComponent;
622
+ 'kind:component': IconComponent;
623
+ 'kind:domain': IconComponent;
624
+ 'kind:group': IconComponent;
625
+ 'kind:location': IconComponent;
626
+ 'kind:system': IconComponent;
627
+ 'kind:user': IconComponent;
628
+ brokenImage: IconComponent;
629
+ catalog: IconComponent;
630
+ chat: IconComponent;
631
+ dashboard: IconComponent;
632
+ docs: IconComponent;
633
+ email: IconComponent;
634
+ github: IconComponent;
635
+ group: IconComponent;
636
+ help: IconComponent;
637
+ scaffolder: IconComponent;
638
+ search: IconComponent;
639
+ techdocs: IconComponent;
640
+ user: IconComponent;
641
+ warning: IconComponent;
642
+ };
587
643
  /**
588
644
  * A function that loads in the App config that will be accessible via the ConfigApi.
589
645
  *
@@ -595,6 +651,8 @@ declare type AppComponents = {
595
651
  declare type AppConfigLoader = () => Promise<AppConfig[]>;
596
652
  /**
597
653
  * Extracts a union of the keys in a map whose value extends the given type
654
+ *
655
+ * @ignore
598
656
  */
599
657
  declare type KeysWithType<Obj extends {
600
658
  [key in string]: any;
@@ -603,12 +661,16 @@ declare type KeysWithType<Obj extends {
603
661
  }[keyof Obj];
604
662
  /**
605
663
  * Takes a map Map required values and makes all keys matching Keys optional
664
+ *
665
+ * @ignore
606
666
  */
607
667
  declare type PartialKeys<Map extends {
608
668
  [name in string]: any;
609
669
  }, Keys extends keyof Map> = Partial<Pick<Map, Keys>> & Required<Omit<Map, Keys>>;
610
670
  /**
611
671
  * Creates a map of target routes with matching parameters based on a map of external routes.
672
+ *
673
+ * @ignore
612
674
  */
613
675
  declare type TargetRouteMap<ExternalRoutes extends {
614
676
  [name: string]: ExternalRouteRef;
@@ -629,6 +691,7 @@ declare type AppRouteBinder = <ExternalRoutes extends {
629
691
  *
630
692
  * @public
631
693
  * @remarks
694
+ * @deprecated Will be removed
632
695
  *
633
696
  * The `type: string` type is there to handle output from newer or older plugin
634
697
  * API versions that might not be supported by this version of the app API, but
@@ -652,23 +715,35 @@ declare type BackstagePluginWithAnyOutput = Omit<BackstagePlugin<any, any>, 'out
652
715
  declare type AppOptions = {
653
716
  /**
654
717
  * A collection of ApiFactories to register in the application to either
655
- * add add new ones, or override factories provided by default or by plugins.
718
+ * add new ones, or override factories provided by default or by plugins.
656
719
  */
657
720
  apis?: Iterable<AnyApiFactory>;
721
+ /**
722
+ * A collection of ApiFactories to register in the application as default APIs.
723
+ * Theses APIs can not be overridden by plugin factories, but can be overridden
724
+ * by plugin APIs provided through the
725
+ * A collection of ApiFactories to register in the application to either
726
+ * add new ones, or override factories provided by default or by plugins.
727
+ */
728
+ defaultApis?: Iterable<AnyApiFactory>;
658
729
  /**
659
730
  * Supply icons to override the default ones.
660
731
  */
661
- icons?: Partial<AppIcons> & {
732
+ icons: AppIcons & {
662
733
  [key in string]: IconComponent;
663
734
  };
664
735
  /**
665
736
  * A list of all plugins to include in the app.
666
737
  */
667
- plugins?: BackstagePluginWithAnyOutput[];
738
+ plugins?: (Omit<BackstagePlugin<any, any>, 'output'> & {
739
+ output(): (PluginOutput | {
740
+ type: string;
741
+ })[];
742
+ })[];
668
743
  /**
669
744
  * Supply components to the app to override the default ones.
670
745
  */
671
- components?: Partial<AppComponents>;
746
+ components: AppComponents;
672
747
  /**
673
748
  * Themes provided as a part of the app. By default two themes are included, one
674
749
  * light variant of the default backstage theme, and one dark.
@@ -680,18 +755,26 @@ declare type AppOptions = {
680
755
  * id: 'light',
681
756
  * title: 'Light Theme',
682
757
  * variant: 'light',
683
- * theme: lightTheme,
684
758
  * icon: <LightIcon />,
759
+ * Provider: ({ children }) => (
760
+ * <ThemeProvider theme={lightTheme}>
761
+ * <CssBaseline>{children}</CssBaseline>
762
+ * </ThemeProvider>
763
+ * ),
685
764
  * }, {
686
765
  * id: 'dark',
687
766
  * title: 'Dark Theme',
688
767
  * variant: 'dark',
689
- * theme: darkTheme,
690
768
  * icon: <DarkIcon />,
769
+ * Provider: ({ children }) => (
770
+ * <ThemeProvider theme={darkTheme}>
771
+ * <CssBaseline>{children}</CssBaseline>
772
+ * </ThemeProvider>
773
+ * ),
691
774
  * }]
692
775
  * ```
693
776
  */
694
- themes?: AppTheme[];
777
+ themes: (Partial<AppTheme> & Omit<AppTheme, 'theme'>)[];
695
778
  /**
696
779
  * A function that loads in App configuration that will be accessible via
697
780
  * the ConfigApi.
@@ -770,38 +853,23 @@ declare type AppContext = {
770
853
  getComponents(): AppComponents;
771
854
  };
772
855
 
773
- declare type FullAppOptions = {
774
- apis: Iterable<AnyApiFactory>;
775
- icons: NonNullable<AppOptions['icons']>;
776
- plugins: BackstagePlugin<any, any>[];
777
- components: AppComponents;
778
- themes: AppTheme[];
779
- configLoader?: AppConfigLoader;
780
- defaultApis: Iterable<AnyApiFactory>;
781
- bindRoutes?: AppOptions['bindRoutes'];
782
- };
783
- declare class PrivateAppImpl implements BackstageApp {
784
- private apiHolder?;
785
- private configApi?;
786
- private readonly apis;
787
- private readonly icons;
788
- private readonly plugins;
789
- private readonly components;
790
- private readonly themes;
791
- private readonly configLoader?;
792
- private readonly defaultApis;
793
- private readonly bindRoutes;
794
- private readonly identityApi;
795
- private readonly apiFactoryRegistry;
796
- constructor(options: FullAppOptions);
797
- getPlugins(): BackstagePlugin<any, any>[];
798
- getSystemIcon(key: string): IconComponent | undefined;
799
- getComponents(): AppComponents;
800
- getProvider(): ComponentType<{}>;
801
- getRouter(): ComponentType<{}>;
802
- private getApiHolder;
803
- private verifyPlugins;
804
- }
856
+ /**
857
+ * Creates a new Backstage App.
858
+ *
859
+ * @deprecated Use {@link @backstage/app-defaults#createApp} from `@backstage/app-defaults` instead
860
+ * @param options - A set of options for creating the app
861
+ * @public
862
+ */
863
+ declare function createApp(options?: OptionalAppOptions): BackstageApp;
864
+
865
+ /**
866
+ * Creates a new Backstage App where the full set of options are required.
867
+ *
868
+ * @public
869
+ * @param options - A set of options for creating the app
870
+ * @returns
871
+ */
872
+ declare function createSpecializedApp(options: AppOptions): BackstageApp;
805
873
 
806
874
  /**
807
875
  * The default config loader, which expects that config is available at compile-time
@@ -816,12 +884,6 @@ declare class PrivateAppImpl implements BackstageApp {
816
884
  * @public
817
885
  */
818
886
  declare const defaultConfigLoader: AppConfigLoader;
819
- /**
820
- * Creates a new Backstage App.
821
- *
822
- * @public
823
- */
824
- declare function createApp(options?: AppOptions): PrivateAppImpl;
825
887
 
826
888
  /**
827
889
  * Props for the {@link FlatRoutes} component.
@@ -864,4 +926,4 @@ declare type FeatureFlaggedProps = {
864
926
  */
865
927
  declare const FeatureFlagged: (props: FeatureFlaggedProps) => JSX.Element;
866
928
 
867
- export { AlertApiForwarder, ApiFactoryHolder, ApiFactoryRegistry, ApiProvider, ApiRegistry, ApiResolver, AppComponents, AppConfigLoader, AppContext, AppOptions, AppRouteBinder, AppThemeSelector, AtlassianAuth, Auth0Auth, BackstageApp, BackstagePluginWithAnyOutput, BitbucketAuth, BitbucketSession, BootErrorPageProps, ErrorAlerter, ErrorApiForwarder, ErrorBoundaryFallbackProps, FeatureFlagged, FeatureFlaggedProps, FlatRoutes, FlatRoutesProps, GithubAuth, GithubSession, GitlabAuth, GoogleAuth, LocalStorageFeatureFlags, MicrosoftAuth, NoOpAnalyticsApi, OAuth2, OAuth2Session, OAuthRequestManager, OktaAuth, OneLoginAuth, SamlAuth, SignInPageProps, SignInResult, UnhandledErrorForwarder, UrlPatternDiscovery, WebStorage, createApp, defaultConfigLoader };
929
+ export { AlertApiForwarder, ApiFactoryHolder, ApiFactoryRegistry, ApiFactoryScope, ApiProvider, ApiProviderProps, ApiRegistry, ApiResolver, AppComponents, AppConfigLoader, AppContext, AppIcons, AppOptions, AppRouteBinder, AppThemeSelector, AtlassianAuth, Auth0Auth, AuthApiCreateOptions, BackstageApp, BackstagePluginWithAnyOutput, BitbucketAuth, BitbucketSession, BootErrorPageProps, ErrorAlerter, ErrorApiForwarder, ErrorBoundaryFallbackProps, FeatureFlagged, FeatureFlaggedProps, FlatRoutes, FlatRoutesProps, GithubAuth, GithubSession, GitlabAuth, GoogleAuth, LocalStorageFeatureFlags, MicrosoftAuth, NoOpAnalyticsApi, OAuth2, OAuth2CreateOptions, OAuth2Session, OAuthApiCreateOptions, OAuthRequestManager, OktaAuth, OneLoginAuth, OneLoginAuthCreateOptions, SamlAuth, SamlSession, SignInPageProps, SignInResult, UnhandledErrorForwarder, UrlPatternDiscovery, WebStorage, createApp, createSpecializedApp, defaultConfigLoader };