@backstage/backend-app-api 0.7.10-next.1 → 0.8.1-next.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,50 @@
1
1
  # @backstage/backend-app-api
2
2
 
3
+ ## 0.8.1-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/backend-common@0.23.4-next.0
9
+ - @backstage/config-loader@1.8.2-next.0
10
+ - @backstage/backend-plugin-api@0.7.1-next.0
11
+ - @backstage/backend-tasks@0.5.28-next.0
12
+ - @backstage/cli-common@0.1.14
13
+ - @backstage/cli-node@0.2.7
14
+ - @backstage/config@1.2.0
15
+ - @backstage/errors@1.2.4
16
+ - @backstage/types@1.1.1
17
+ - @backstage/plugin-auth-node@0.4.18-next.0
18
+ - @backstage/plugin-permission-node@0.8.1-next.0
19
+
20
+ ## 0.8.0
21
+
22
+ ### Minor Changes
23
+
24
+ - 1cb84d7: **BREAKING**: Removed the depreacted `getPath` option from `httpRouterServiceFactory`, as well as the `HttpRouterFactoryOptions` type.
25
+ - f691c9b: **BREAKING**: Removed the ability to pass callback-form service factories through the `defaultServiceFactories` option of `createSpecializedBackend`. This is an immediate breaking change as usage of this function is expected to be very rare.
26
+
27
+ ### Patch Changes
28
+
29
+ - 2f99178: The `ServiceFactoryTest.get` method was deprecated and the `ServiceFactoryTest.getSubject` should be used instead. The `getSubject` method has the same behavior, but has a better method name to indicate that the service instance returned is the subject currently being tested.
30
+ - b05e1e1: Service factories exported by this package have been updated to use the new service factory format that doesn't use a callback.
31
+ - 617a7d2: Internal refactor that avoids the use of service factory options.
32
+ - b60db08: Fixing exporting of classes properly from new packages
33
+ - 18b96b1: The ability to install backend features in callback form (`() => BackendFeature`) has been deprecated. This typically means that you need to update the installed features to use the latest version of `@backstage/backend-plugin-api`. If the feature is from a third-party package, please reach out to the package maintainer to update it.
34
+ - a63c4b6: Fixing issue with `MiddlewareFactory` deprecation wrapping
35
+ - Updated dependencies
36
+ - @backstage/backend-plugin-api@0.7.0
37
+ - @backstage/backend-common@0.23.3
38
+ - @backstage/cli-node@0.2.7
39
+ - @backstage/backend-tasks@0.5.27
40
+ - @backstage/plugin-permission-node@0.8.0
41
+ - @backstage/plugin-auth-node@0.4.17
42
+ - @backstage/config-loader@1.8.1
43
+ - @backstage/cli-common@0.1.14
44
+ - @backstage/config@1.2.0
45
+ - @backstage/errors@1.2.4
46
+ - @backstage/types@1.1.1
47
+
3
48
  ## 0.7.10-next.1
4
49
 
5
50
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/backend-app-api__alpha",
3
- "version": "0.7.10-next.1",
3
+ "version": "0.8.1-next.0",
4
4
  "main": "../dist/alpha.cjs.js",
5
5
  "types": "../dist/alpha.d.ts"
6
6
  }
package/dist/alpha.d.ts CHANGED
@@ -2,6 +2,6 @@ import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
2
2
  import { FeatureDiscoveryService } from '@backstage/backend-plugin-api/alpha';
3
3
 
4
4
  /** @alpha */
5
- declare const featureDiscoveryServiceFactory: () => _backstage_backend_plugin_api.ServiceFactory<FeatureDiscoveryService, "root">;
5
+ declare const featureDiscoveryServiceFactory: _backstage_backend_plugin_api.ServiceFactoryCompat<FeatureDiscoveryService, "root", undefined>;
6
6
 
7
7
  export { featureDiscoveryServiceFactory };
package/dist/index.cjs.js CHANGED
@@ -1234,13 +1234,13 @@ function toInternalServiceFactory(factory) {
1234
1234
  }
1235
1235
  return f;
1236
1236
  }
1237
- const pluginMetadataServiceFactory = backendPluginApi.createServiceFactory(
1238
- (options) => ({
1237
+ function createPluginMetadataServiceFactory(pluginId) {
1238
+ return backendPluginApi.createServiceFactory({
1239
1239
  service: backendPluginApi.coreServices.pluginMetadata,
1240
1240
  deps: {},
1241
- factory: async () => ({ getId: () => options?.pluginId })
1242
- })
1243
- );
1241
+ factory: async () => ({ getId: () => pluginId })
1242
+ });
1243
+ }
1244
1244
  class ServiceRegistry {
1245
1245
  static create(factories) {
1246
1246
  const registry = new ServiceRegistry(factories);
@@ -1263,7 +1263,7 @@ class ServiceRegistry {
1263
1263
  #resolveFactory(ref, pluginId) {
1264
1264
  if (ref.id === backendPluginApi.coreServices.pluginMetadata.id) {
1265
1265
  return Promise.resolve(
1266
- toInternalServiceFactory(pluginMetadataServiceFactory({ pluginId }))
1266
+ toInternalServiceFactory(createPluginMetadataServiceFactory(pluginId))
1267
1267
  );
1268
1268
  }
1269
1269
  let resolvedFactory = this.#providedFactories.get(ref.id);
@@ -1783,12 +1783,9 @@ function unwrapFeature(feature) {
1783
1783
  }
1784
1784
 
1785
1785
  function createSpecializedBackend(options) {
1786
- const services = options.defaultServiceFactories.map(
1787
- (sf) => typeof sf === "function" ? sf() : sf
1788
- );
1789
1786
  const exists = /* @__PURE__ */ new Set();
1790
1787
  const duplicates = /* @__PURE__ */ new Set();
1791
- for (const { service } of services) {
1788
+ for (const { service } of options.defaultServiceFactories) {
1792
1789
  if (exists.has(service.id)) {
1793
1790
  duplicates.add(service.id);
1794
1791
  } else {
@@ -1804,7 +1801,7 @@ function createSpecializedBackend(options) {
1804
1801
  `The ${backendPluginApi.coreServices.pluginMetadata.id} service cannot be overridden`
1805
1802
  );
1806
1803
  }
1807
- return new BackstageBackend(services);
1804
+ return new BackstageBackend(options.defaultServiceFactories);
1808
1805
  }
1809
1806
 
1810
1807
  const cacheServiceFactory = backendPluginApi.createServiceFactory({
@@ -3556,56 +3553,38 @@ function createCookieAuthRefreshMiddleware(options) {
3556
3553
  return router;
3557
3554
  }
3558
3555
 
3559
- const httpRouterServiceFactory$1 = backendPluginApi.createServiceFactory(
3560
- (options) => ({
3561
- service: backendPluginApi.coreServices.httpRouter,
3562
- initialization: "always",
3563
- deps: {
3564
- plugin: backendPluginApi.coreServices.pluginMetadata,
3565
- config: backendPluginApi.coreServices.rootConfig,
3566
- logger: backendPluginApi.coreServices.logger,
3567
- lifecycle: backendPluginApi.coreServices.lifecycle,
3568
- rootHttpRouter: backendPluginApi.coreServices.rootHttpRouter,
3569
- auth: backendPluginApi.coreServices.auth,
3570
- httpAuth: backendPluginApi.coreServices.httpAuth
3571
- },
3572
- async factory({
3573
- auth,
3556
+ const httpRouterServiceFactory$1 = backendPluginApi.createServiceFactory({
3557
+ service: backendPluginApi.coreServices.httpRouter,
3558
+ initialization: "always",
3559
+ deps: {
3560
+ plugin: backendPluginApi.coreServices.pluginMetadata,
3561
+ config: backendPluginApi.coreServices.rootConfig,
3562
+ lifecycle: backendPluginApi.coreServices.lifecycle,
3563
+ rootHttpRouter: backendPluginApi.coreServices.rootHttpRouter,
3564
+ auth: backendPluginApi.coreServices.auth,
3565
+ httpAuth: backendPluginApi.coreServices.httpAuth
3566
+ },
3567
+ async factory({ auth, httpAuth, config, plugin, rootHttpRouter, lifecycle }) {
3568
+ const router = Router__default.default();
3569
+ rootHttpRouter.use(`/api/${plugin.getId()}`, router);
3570
+ const credentialsBarrier = createCredentialsBarrier({
3574
3571
  httpAuth,
3575
- config,
3576
- logger,
3577
- plugin,
3578
- rootHttpRouter,
3579
- lifecycle
3580
- }) {
3581
- if (options?.getPath) {
3582
- logger.warn(
3583
- `DEPRECATION WARNING: The 'getPath' option for HttpRouterService is deprecated. The ability to reconfigure the '/api/' path prefix for plugins will be removed in the future.`
3584
- );
3572
+ config
3573
+ });
3574
+ router.use(createAuthIntegrationRouter({ auth }));
3575
+ router.use(createLifecycleMiddleware$1({ lifecycle }));
3576
+ router.use(credentialsBarrier.middleware);
3577
+ router.use(createCookieAuthRefreshMiddleware({ auth, httpAuth }));
3578
+ return {
3579
+ use(handler) {
3580
+ router.use(handler);
3581
+ },
3582
+ addAuthPolicy(policy) {
3583
+ credentialsBarrier.addAuthPolicy(policy);
3585
3584
  }
3586
- const getPath = options?.getPath ?? ((id) => `/api/${id}`);
3587
- const path = getPath(plugin.getId());
3588
- const router = Router__default.default();
3589
- rootHttpRouter.use(path, router);
3590
- const credentialsBarrier = createCredentialsBarrier({
3591
- httpAuth,
3592
- config
3593
- });
3594
- router.use(createAuthIntegrationRouter({ auth }));
3595
- router.use(createLifecycleMiddleware$1({ lifecycle }));
3596
- router.use(credentialsBarrier.middleware);
3597
- router.use(createCookieAuthRefreshMiddleware({ auth, httpAuth }));
3598
- return {
3599
- use(handler) {
3600
- router.use(handler);
3601
- },
3602
- addAuthPolicy(policy) {
3603
- credentialsBarrier.addAuthPolicy(policy);
3604
- }
3605
- };
3606
- }
3607
- })
3608
- );
3585
+ };
3586
+ }
3587
+ });
3609
3588
 
3610
3589
  const httpRouterServiceFactory = httpRouterServiceFactory$1;
3611
3590
 
@@ -3693,14 +3672,14 @@ let DefaultRootHttpRouter$1 = class DefaultRootHttpRouter {
3693
3672
  function createHealthRouter(options) {
3694
3673
  const router = Router__default.default();
3695
3674
  router.get(
3696
- ".backstage/health/v1/readiness",
3675
+ "/.backstage/health/v1/readiness",
3697
3676
  async (_request, response) => {
3698
3677
  const { status, payload } = await options.health.getReadiness();
3699
3678
  response.status(status).json(payload);
3700
3679
  }
3701
3680
  );
3702
3681
  router.get(
3703
- ".backstage/health/v1/liveness",
3682
+ "/.backstage/health/v1/liveness",
3704
3683
  async (_request, response) => {
3705
3684
  const { status, payload } = await options.health.getLiveness();
3706
3685
  response.status(status).json(payload);
@@ -3712,53 +3691,55 @@ function createHealthRouter(options) {
3712
3691
  function defaultConfigure({ applyDefaults }) {
3713
3692
  applyDefaults();
3714
3693
  }
3715
- const rootHttpRouterServiceFactory$1 = backendPluginApi.createServiceFactory(
3716
- (options) => ({
3717
- service: backendPluginApi.coreServices.rootHttpRouter,
3718
- deps: {
3719
- config: backendPluginApi.coreServices.rootConfig,
3720
- rootLogger: backendPluginApi.coreServices.rootLogger,
3721
- lifecycle: backendPluginApi.coreServices.rootLifecycle,
3722
- health: backendPluginApi.coreServices.rootHealth
3723
- },
3724
- async factory({ config, rootLogger, lifecycle, health }) {
3725
- const { indexPath, configure = defaultConfigure } = options ?? {};
3726
- const logger = rootLogger.child({ service: "rootHttpRouter" });
3727
- const app = express__default.default();
3728
- const router = DefaultRootHttpRouter$1.create({ indexPath });
3729
- const middleware = MiddlewareFactory$1.create({ config, logger });
3730
- const routes = router.handler();
3731
- const healthRouter = createHealthRouter({ health });
3732
- const server = await createHttpServer$1(
3733
- app,
3734
- readHttpServerOptions$1(config.getOptionalConfig("backend")),
3735
- { logger }
3736
- );
3737
- configure({
3738
- app,
3739
- server,
3740
- routes,
3741
- middleware,
3742
- config,
3743
- logger,
3744
- lifecycle,
3745
- healthRouter,
3746
- applyDefaults() {
3747
- app.use(middleware.helmet());
3748
- app.use(middleware.cors());
3749
- app.use(middleware.compression());
3750
- app.use(middleware.logging());
3751
- app.use(healthRouter);
3752
- app.use(routes);
3753
- app.use(middleware.notFound());
3754
- app.use(middleware.error());
3755
- }
3756
- });
3757
- lifecycle.addShutdownHook(() => server.stop());
3758
- await server.start();
3759
- return router;
3760
- }
3761
- })
3694
+ const rootHttpRouterServiceFactoryWithOptions = (options) => backendPluginApi.createServiceFactory({
3695
+ service: backendPluginApi.coreServices.rootHttpRouter,
3696
+ deps: {
3697
+ config: backendPluginApi.coreServices.rootConfig,
3698
+ rootLogger: backendPluginApi.coreServices.rootLogger,
3699
+ lifecycle: backendPluginApi.coreServices.rootLifecycle,
3700
+ health: backendPluginApi.coreServices.rootHealth
3701
+ },
3702
+ async factory({ config, rootLogger, lifecycle, health }) {
3703
+ const { indexPath, configure = defaultConfigure } = options ?? {};
3704
+ const logger = rootLogger.child({ service: "rootHttpRouter" });
3705
+ const app = express__default.default();
3706
+ const router = DefaultRootHttpRouter$1.create({ indexPath });
3707
+ const middleware = MiddlewareFactory$1.create({ config, logger });
3708
+ const routes = router.handler();
3709
+ const healthRouter = createHealthRouter({ health });
3710
+ const server = await createHttpServer$1(
3711
+ app,
3712
+ readHttpServerOptions$1(config.getOptionalConfig("backend")),
3713
+ { logger }
3714
+ );
3715
+ configure({
3716
+ app,
3717
+ server,
3718
+ routes,
3719
+ middleware,
3720
+ config,
3721
+ logger,
3722
+ lifecycle,
3723
+ healthRouter,
3724
+ applyDefaults() {
3725
+ app.use(middleware.helmet());
3726
+ app.use(middleware.cors());
3727
+ app.use(middleware.compression());
3728
+ app.use(middleware.logging());
3729
+ app.use(healthRouter);
3730
+ app.use(routes);
3731
+ app.use(middleware.notFound());
3732
+ app.use(middleware.error());
3733
+ }
3734
+ });
3735
+ lifecycle.addShutdownHook(() => server.stop());
3736
+ await server.start();
3737
+ return router;
3738
+ }
3739
+ })();
3740
+ const rootHttpRouterServiceFactory$1 = Object.assign(
3741
+ rootHttpRouterServiceFactoryWithOptions,
3742
+ rootHttpRouterServiceFactoryWithOptions()
3762
3743
  );
3763
3744
 
3764
3745
  const rootHttpRouterServiceFactory = rootHttpRouterServiceFactory$1;