Version Packages (next)
This commit is contained in:
@@ -1,5 +1,99 @@
|
||||
# @backstage/backend-plugin-api
|
||||
|
||||
## 0.8.0-next.2
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 7c5f3b0: The `createServiceRef` function now accepts a new boolean `multiple` option. The `multiple` option defaults to `false` and when set to `true`, it enables that multiple implementation are installed for the created service ref.
|
||||
|
||||
We're looking for ways to make it possible to augment services without the need to replace the entire service.
|
||||
|
||||
Typical example of that being the ability to install support for additional targets for the `UrlReader` service without replacing the service itself. This achieves that by allowing us to define services that can have multiple simultaneous implementation, allowing the `UrlReader` implementation to depend on such a service to collect all possible implementation of support for external targets:
|
||||
|
||||
```diff
|
||||
// @backstage/backend-defaults
|
||||
|
||||
+ export const urlReaderFactoriesServiceRef = createServiceRef<ReaderFactory>({
|
||||
+ id: 'core.urlReader.factories',
|
||||
+ scope: 'plugin',
|
||||
+ multiton: true,
|
||||
+ });
|
||||
|
||||
...
|
||||
|
||||
export const urlReaderServiceFactory = createServiceFactory({
|
||||
service: coreServices.urlReader,
|
||||
deps: {
|
||||
config: coreServices.rootConfig,
|
||||
logger: coreServices.logger,
|
||||
+ factories: urlReaderFactoriesServiceRef,
|
||||
},
|
||||
- async factory({ config, logger }) {
|
||||
+ async factory({ config, logger, factories }) {
|
||||
return UrlReaders.default({
|
||||
config,
|
||||
logger,
|
||||
+ factories,
|
||||
});
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
With that, you can then add more custom `UrlReader` factories by installing more implementations of the `urlReaderFactoriesServiceRef` in your backend instance. Something like:
|
||||
|
||||
```ts
|
||||
// packages/backend/index.ts
|
||||
import { createServiceFactory } from '@backstage/backend-plugin-api';
|
||||
import { urlReaderFactoriesServiceRef } from '@backstage/backend-defaults';
|
||||
...
|
||||
|
||||
backend.add(createServiceFactory({
|
||||
service: urlReaderFactoriesServiceRef,
|
||||
deps: {},
|
||||
async factory() {
|
||||
return CustomUrlReader.factory;
|
||||
},
|
||||
}));
|
||||
|
||||
...
|
||||
|
||||
```
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 6061061: Added `createBackendFeatureLoader`, which can be used to create an installable backend feature that can in turn load in additional backend features in a dynamic way.
|
||||
- ba9abf4: The `SchedulerService` now allows tasks with `frequency: { trigger: 'manual' }`. This means that the task will not be scheduled, but rather run only when manually triggered with `SchedulerService.triggerTask`.
|
||||
- 8b13183: Added `createBackendFeatureLoader`, which can be used to programmatically select and install backend features.
|
||||
|
||||
A feature loader can return an list of features to be installed, for example in the form on an `Array` or other for of iterable, which allows for the loader to be defined as a generator function. Both synchronous and asynchronous loaders are supported.
|
||||
|
||||
Additionally, a loader can depend on services in its implementation, with the restriction that it can only depend on root-scoped services, and it may not override services that have already been instantiated.
|
||||
|
||||
```ts
|
||||
const searchLoader = createBackendFeatureLoader({
|
||||
deps: {
|
||||
config: coreServices.rootConfig,
|
||||
},
|
||||
*loader({ config }) {
|
||||
// Example of a custom config flag to enable search
|
||||
if (config.getOptionalString('customFeatureToggle.search')) {
|
||||
yield import('@backstage/plugin-search-backend/alpha');
|
||||
yield import('@backstage/plugin-search-backend-module-catalog/alpha');
|
||||
yield import('@backstage/plugin-search-backend-module-explore/alpha');
|
||||
yield import('@backstage/plugin-search-backend-module-techdocs/alpha');
|
||||
}
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
- Updated dependencies
|
||||
- @backstage/plugin-permission-common@0.8.1-next.1
|
||||
- @backstage/plugin-auth-node@0.5.0-next.2
|
||||
- @backstage/cli-common@0.1.14
|
||||
- @backstage/config@1.2.0
|
||||
- @backstage/errors@1.2.4
|
||||
- @backstage/types@1.1.1
|
||||
|
||||
## 0.7.1-next.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@backstage/backend-plugin-api",
|
||||
"version": "0.7.1-next.1",
|
||||
"version": "0.8.0-next.2",
|
||||
"description": "Core API used by Backstage backend plugins",
|
||||
"backstage": {
|
||||
"role": "node-library"
|
||||
|
||||
Reference in New Issue
Block a user