@backstage/backend-app-api 0.7.9 → 0.8.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 +33 -22
- package/alpha/package.json +1 -1
- package/dist/alpha.d.ts +1 -1
- package/dist/index.cjs.js +106 -102
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +34 -38
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,51 +1,62 @@
|
|
|
1
1
|
# @backstage/backend-app-api
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1cb84d7: **BREAKING**: Removed the depreacted `getPath` option from `httpRouterServiceFactory`, as well as the `HttpRouterFactoryOptions` type.
|
|
8
|
+
- 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.
|
|
4
9
|
|
|
5
10
|
### Patch Changes
|
|
6
11
|
|
|
12
|
+
- 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.
|
|
13
|
+
- b05e1e1: Service factories exported by this package have been updated to use the new service factory format that doesn't use a callback.
|
|
14
|
+
- 617a7d2: Internal refactor that avoids the use of service factory options.
|
|
15
|
+
- b60db08: Fixing exporting of classes properly from new packages
|
|
16
|
+
- 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.
|
|
17
|
+
- a63c4b6: Fixing issue with `MiddlewareFactory` deprecation wrapping
|
|
7
18
|
- Updated dependencies
|
|
8
|
-
- @backstage/backend-plugin-api@0.
|
|
9
|
-
- @backstage/backend-
|
|
10
|
-
- @backstage/
|
|
11
|
-
- @backstage/
|
|
12
|
-
- @backstage/plugin-permission-node@0.
|
|
19
|
+
- @backstage/backend-plugin-api@0.7.0
|
|
20
|
+
- @backstage/backend-common@0.23.3
|
|
21
|
+
- @backstage/cli-node@0.2.7
|
|
22
|
+
- @backstage/backend-tasks@0.5.27
|
|
23
|
+
- @backstage/plugin-permission-node@0.8.0
|
|
24
|
+
- @backstage/plugin-auth-node@0.4.17
|
|
25
|
+
- @backstage/config-loader@1.8.1
|
|
13
26
|
- @backstage/cli-common@0.1.14
|
|
14
|
-
- @backstage/cli-node@0.2.6
|
|
15
27
|
- @backstage/config@1.2.0
|
|
16
|
-
- @backstage/config-loader@1.8.1
|
|
17
28
|
- @backstage/errors@1.2.4
|
|
18
29
|
- @backstage/types@1.1.1
|
|
19
30
|
|
|
20
|
-
## 0.7.
|
|
31
|
+
## 0.7.10-next.1
|
|
21
32
|
|
|
22
33
|
### Patch Changes
|
|
23
34
|
|
|
24
|
-
- c5957b0: Fixing issue with `MiddlewareFactory` deprecation wrapping
|
|
25
35
|
- Updated dependencies
|
|
26
|
-
- @backstage/backend-common@0.23.1
|
|
27
|
-
- @backstage/backend-plugin-api@0.6.
|
|
28
|
-
- @backstage/backend-tasks@0.5.
|
|
36
|
+
- @backstage/backend-common@0.23.3-next.1
|
|
37
|
+
- @backstage/backend-plugin-api@0.6.22-next.1
|
|
38
|
+
- @backstage/backend-tasks@0.5.27-next.1
|
|
29
39
|
- @backstage/cli-common@0.1.14
|
|
30
40
|
- @backstage/cli-node@0.2.6
|
|
31
41
|
- @backstage/config@1.2.0
|
|
32
42
|
- @backstage/config-loader@1.8.1
|
|
33
43
|
- @backstage/errors@1.2.4
|
|
34
44
|
- @backstage/types@1.1.1
|
|
35
|
-
- @backstage/plugin-auth-node@0.4.
|
|
36
|
-
- @backstage/plugin-permission-node@0.7.
|
|
45
|
+
- @backstage/plugin-auth-node@0.4.17-next.1
|
|
46
|
+
- @backstage/plugin-permission-node@0.7.33-next.1
|
|
37
47
|
|
|
38
|
-
## 0.7.
|
|
48
|
+
## 0.7.9-next.0
|
|
39
49
|
|
|
40
50
|
### Patch Changes
|
|
41
51
|
|
|
42
|
-
-
|
|
52
|
+
- b60db08: Fixing exporting of classes properly from new packages
|
|
53
|
+
- a63c4b6: Fixing issue with `MiddlewareFactory` deprecation wrapping
|
|
43
54
|
- Updated dependencies
|
|
44
|
-
- @backstage/backend-
|
|
45
|
-
- @backstage/backend-
|
|
46
|
-
- @backstage/
|
|
47
|
-
- @backstage/plugin-
|
|
48
|
-
- @backstage/
|
|
55
|
+
- @backstage/backend-plugin-api@0.6.21-next.0
|
|
56
|
+
- @backstage/backend-common@0.23.2-next.0
|
|
57
|
+
- @backstage/backend-tasks@0.5.26-next.0
|
|
58
|
+
- @backstage/plugin-auth-node@0.4.16-next.0
|
|
59
|
+
- @backstage/plugin-permission-node@0.7.32-next.0
|
|
49
60
|
- @backstage/cli-common@0.1.14
|
|
50
61
|
- @backstage/cli-node@0.2.6
|
|
51
62
|
- @backstage/config@1.2.0
|
package/alpha/package.json
CHANGED
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:
|
|
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
|
-
|
|
1238
|
-
|
|
1237
|
+
function createPluginMetadataServiceFactory(pluginId) {
|
|
1238
|
+
return backendPluginApi.createServiceFactory({
|
|
1239
1239
|
service: backendPluginApi.coreServices.pluginMetadata,
|
|
1240
1240
|
deps: {},
|
|
1241
|
-
factory: async () => ({ getId: () =>
|
|
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(
|
|
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
|
|
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(
|
|
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
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
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
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
})
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
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
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
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
|
|
|
@@ -3690,52 +3669,77 @@ let DefaultRootHttpRouter$1 = class DefaultRootHttpRouter {
|
|
|
3690
3669
|
}
|
|
3691
3670
|
};
|
|
3692
3671
|
|
|
3672
|
+
function createHealthRouter(options) {
|
|
3673
|
+
const router = Router__default.default();
|
|
3674
|
+
router.get(
|
|
3675
|
+
".backstage/health/v1/readiness",
|
|
3676
|
+
async (_request, response) => {
|
|
3677
|
+
const { status, payload } = await options.health.getReadiness();
|
|
3678
|
+
response.status(status).json(payload);
|
|
3679
|
+
}
|
|
3680
|
+
);
|
|
3681
|
+
router.get(
|
|
3682
|
+
".backstage/health/v1/liveness",
|
|
3683
|
+
async (_request, response) => {
|
|
3684
|
+
const { status, payload } = await options.health.getLiveness();
|
|
3685
|
+
response.status(status).json(payload);
|
|
3686
|
+
}
|
|
3687
|
+
);
|
|
3688
|
+
return router;
|
|
3689
|
+
}
|
|
3690
|
+
|
|
3693
3691
|
function defaultConfigure({ applyDefaults }) {
|
|
3694
3692
|
applyDefaults();
|
|
3695
3693
|
}
|
|
3696
|
-
const
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
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()
|
|
3739
3743
|
);
|
|
3740
3744
|
|
|
3741
3745
|
const rootHttpRouterServiceFactory = rootHttpRouterServiceFactory$1;
|