@backstage/backend-plugin-api 0.8.0-next.2 → 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 CHANGED
@@ -1,5 +1,132 @@
1
1
  # @backstage/backend-plugin-api
2
2
 
3
+ ## 0.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 389f5a4: **BREAKING** Deleted the following deprecated `UrlReader` exports
8
+
9
+ - ReadUrlOptions: Use `UrlReaderServiceReadUrlOptions` instead;
10
+ - ReadUrlResponse: Use `UrlReaderServiceReadUrlResponse` instead;
11
+ - ReadTreeOptions: Use `UrlReaderServiceReadTreeOptions` instead;
12
+ - ReadTreeResponse: Use `UrlReaderServiceReadTreeResponse` instead;
13
+ - ReadTreeResponseFile: Use `UrlReaderServiceReadTreeResponseFile` instead;
14
+ - ReadTreeResponseDirOptions: Use `UrlReaderServiceReadTreeResponseDirOptions` instead;
15
+ - SearchOptions: Use `UrlReaderServiceSearchOptions` instead;
16
+ - SearchResponse: Use `UrlReaderServiceSearchResponse` instead;
17
+ - SearchResponseFile: Use `UrlReaderServiceSearchResponseFile` instead.
18
+
19
+ - 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.
20
+
21
+ We're looking for ways to make it possible to augment services without the need to replace the entire service.
22
+
23
+ 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:
24
+
25
+ ```diff
26
+ // @backstage/backend-defaults
27
+
28
+ + export const urlReaderFactoriesServiceRef = createServiceRef<ReaderFactory>({
29
+ + id: 'core.urlReader.factories',
30
+ + scope: 'plugin',
31
+ + multiton: true,
32
+ + });
33
+
34
+ ...
35
+
36
+ export const urlReaderServiceFactory = createServiceFactory({
37
+ service: coreServices.urlReader,
38
+ deps: {
39
+ config: coreServices.rootConfig,
40
+ logger: coreServices.logger,
41
+ + factories: urlReaderFactoriesServiceRef,
42
+ },
43
+ - async factory({ config, logger }) {
44
+ + async factory({ config, logger, factories }) {
45
+ return UrlReaders.default({
46
+ config,
47
+ logger,
48
+ + factories,
49
+ });
50
+ },
51
+ });
52
+ ```
53
+
54
+ With that, you can then add more custom `UrlReader` factories by installing more implementations of the `urlReaderFactoriesServiceRef` in your backend instance. Something like:
55
+
56
+ ```ts
57
+ // packages/backend/index.ts
58
+ import { createServiceFactory } from '@backstage/backend-plugin-api';
59
+ import { urlReaderFactoriesServiceRef } from '@backstage/backend-defaults';
60
+ ...
61
+
62
+ backend.add(createServiceFactory({
63
+ service: urlReaderFactoriesServiceRef,
64
+ deps: {},
65
+ async factory() {
66
+ return CustomUrlReader.factory;
67
+ },
68
+ }));
69
+
70
+ ...
71
+
72
+ ```
73
+
74
+ - c99c620: **BREAKING** Removed the following deprecated types:
75
+
76
+ - `ServiceRefConfig` use `ServiceRefOptions`
77
+ - `RootServiceFactoryConfig` use `RootServiceFactoryOptions`
78
+ - `PluginServiceFactoryConfig` use `PluginServiceFactoryOptions`
79
+
80
+ ### Patch Changes
81
+
82
+ - 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.
83
+ - 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`.
84
+ - 8b13183: Added `createBackendFeatureLoader`, which can be used to programmatically select and install backend features.
85
+
86
+ 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.
87
+
88
+ 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.
89
+
90
+ ```ts
91
+ const searchLoader = createBackendFeatureLoader({
92
+ deps: {
93
+ config: coreServices.rootConfig,
94
+ },
95
+ *loader({ config }) {
96
+ // Example of a custom config flag to enable search
97
+ if (config.getOptionalString('customFeatureToggle.search')) {
98
+ yield import('@backstage/plugin-search-backend/alpha');
99
+ yield import('@backstage/plugin-search-backend-module-catalog/alpha');
100
+ yield import('@backstage/plugin-search-backend-module-explore/alpha');
101
+ yield import('@backstage/plugin-search-backend-module-techdocs/alpha');
102
+ }
103
+ },
104
+ });
105
+ ```
106
+
107
+ - ddde5fe: Fixed a type issue where plugin and modules depending on multiton services would not receive the correct type.
108
+ - f011d1b: fix typo in `getPluginRequestToken` comments
109
+ - Updated dependencies
110
+ - @backstage/plugin-permission-common@0.8.1
111
+ - @backstage/plugin-auth-node@0.5.0
112
+ - @backstage/cli-common@0.1.14
113
+ - @backstage/config@1.2.0
114
+ - @backstage/errors@1.2.4
115
+ - @backstage/types@1.1.1
116
+
117
+ ## 0.8.0-next.3
118
+
119
+ ### Patch Changes
120
+
121
+ - ddde5fe: Fixed a type issue where plugin and modules depending on multiton services would not receive the correct type.
122
+ - Updated dependencies
123
+ - @backstage/cli-common@0.1.14
124
+ - @backstage/config@1.2.0
125
+ - @backstage/errors@1.2.4
126
+ - @backstage/types@1.1.1
127
+ - @backstage/plugin-auth-node@0.5.0-next.3
128
+ - @backstage/plugin-permission-common@0.8.1-next.1
129
+
3
130
  ## 0.8.0-next.2
4
131
 
5
132
  ### Minor Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/backend-plugin-api__alpha",
3
- "version": "0.8.0-next.2",
3
+ "version": "0.8.0",
4
4
  "main": "../dist/alpha.cjs.js",
5
5
  "types": "../dist/alpha.d.ts"
6
6
  }
package/dist/index.d.ts CHANGED
@@ -335,51 +335,6 @@ type UrlReaderServiceSearchResponseFile = {
335
335
  */
336
336
  lastModifiedAt?: Date;
337
337
  };
338
- /**
339
- * @public
340
- * @deprecated Use `UrlReaderServiceReadTreeOptions` instead
341
- */
342
- type ReadTreeOptions = UrlReaderServiceReadTreeOptions;
343
- /**
344
- * @public
345
- * @deprecated Use `UrlReaderServiceReadTreeResponse` instead
346
- */
347
- type ReadTreeResponse = UrlReaderServiceReadTreeResponse;
348
- /**
349
- * @public
350
- * @deprecated Use `UrlReaderServiceReadTreeResponseDirOptions` instead
351
- */
352
- type ReadTreeResponseDirOptions = UrlReaderServiceReadTreeResponseDirOptions;
353
- /**
354
- * @public
355
- * @deprecated Use `UrlReaderServiceReadTreeResponseFile` instead
356
- */
357
- type ReadTreeResponseFile = UrlReaderServiceReadTreeResponseFile;
358
- /**
359
- * @public
360
- * @deprecated Use `UrlReaderServiceReadUrlResponse` instead
361
- */
362
- type ReadUrlResponse = UrlReaderServiceReadUrlResponse;
363
- /**
364
- * @public
365
- * @deprecated Use `UrlReaderServiceReadUrlOptions` instead
366
- */
367
- type ReadUrlOptions = UrlReaderServiceReadUrlOptions;
368
- /**
369
- * @public
370
- * @deprecated Use `UrlReaderServiceSearchOptions` instead
371
- */
372
- type SearchOptions = UrlReaderServiceSearchOptions;
373
- /**
374
- * @public
375
- * @deprecated Use `UrlReaderServiceSearchResponse` instead
376
- */
377
- type SearchResponse = UrlReaderServiceSearchResponse;
378
- /**
379
- * @public
380
- * @deprecated Use `UrlReaderServiceSearchResponseFile` instead
381
- */
382
- type SearchResponseFile = UrlReaderServiceSearchResponseFile;
383
338
 
384
339
  /**
385
340
  * This is the legacy service for creating and validating tokens. Please migrate to the new `coreServices.auth`, `coreServices.httpAuth`, and `coreServices.userInfo` services as needed instead.
@@ -1864,6 +1819,12 @@ type ExtensionPoint<T> = {
1864
1819
  toString(): string;
1865
1820
  $$type: '@backstage/ExtensionPoint';
1866
1821
  };
1822
+ /** @ignore */
1823
+ type DepsToInstances<TDeps extends {
1824
+ [key in string]: ServiceRef<unknown> | ExtensionPoint<unknown>;
1825
+ }> = {
1826
+ [key in keyof TDeps]: TDeps[key] extends ServiceRef<unknown, any, 'multiton'> ? Array<TDeps[key]['T']> : TDeps[key]['T'];
1827
+ };
1867
1828
  /**
1868
1829
  * The callbacks passed to the `register` method of a backend plugin.
1869
1830
  *
@@ -1871,13 +1832,11 @@ type ExtensionPoint<T> = {
1871
1832
  */
1872
1833
  interface BackendPluginRegistrationPoints {
1873
1834
  registerExtensionPoint<TExtensionPoint>(ref: ExtensionPoint<TExtensionPoint>, impl: TExtensionPoint): void;
1874
- registerInit<Deps extends {
1875
- [name in string]: unknown;
1835
+ registerInit<TDeps extends {
1836
+ [name in string]: ServiceRef<unknown>;
1876
1837
  }>(options: {
1877
- deps: {
1878
- [name in keyof Deps]: ServiceRef<Deps[name]>;
1879
- };
1880
- init(deps: Deps): Promise<void>;
1838
+ deps: TDeps;
1839
+ init(deps: DepsToInstances<TDeps>): Promise<void>;
1881
1840
  }): void;
1882
1841
  }
1883
1842
  /**
@@ -1887,13 +1846,11 @@ interface BackendPluginRegistrationPoints {
1887
1846
  */
1888
1847
  interface BackendModuleRegistrationPoints {
1889
1848
  registerExtensionPoint<TExtensionPoint>(ref: ExtensionPoint<TExtensionPoint>, impl: TExtensionPoint): void;
1890
- registerInit<Deps extends {
1891
- [name in string]: unknown;
1849
+ registerInit<TDeps extends {
1850
+ [name in string]: ServiceRef<unknown> | ExtensionPoint<unknown>;
1892
1851
  }>(options: {
1893
- deps: {
1894
- [name in keyof Deps]: ServiceRef<Deps[name]> | ExtensionPoint<Deps[name]>;
1895
- };
1896
- init(deps: Deps): Promise<void>;
1852
+ deps: TDeps;
1853
+ init(deps: DepsToInstances<TDeps>): Promise<void>;
1897
1854
  }): void;
1898
1855
  }
1899
1856
 
@@ -2016,24 +1973,4 @@ type BackendModuleConfig = CreateBackendModuleOptions;
2016
1973
  */
2017
1974
  type ExtensionPointConfig = CreateExtensionPointOptions;
2018
1975
 
2019
- /**
2020
- * @public
2021
- * @deprecated Use {@link ServiceRefOptions} instead
2022
- */
2023
- type ServiceRefConfig<TService, TScope extends 'root' | 'plugin', TInstances extends 'singleton' | 'multiton'> = ServiceRefOptions<TService, TScope, TInstances>;
2024
- /**
2025
- * @public
2026
- * @deprecated Use {@link RootServiceFactoryOptions} instead
2027
- */
2028
- type RootServiceFactoryConfig<TService, TInstances extends 'singleton' | 'multiton', TImpl extends TService, TDeps extends {
2029
- [name in string]: ServiceRef<unknown>;
2030
- }> = RootServiceFactoryOptions<TService, TInstances, TImpl, TDeps>;
2031
- /**
2032
- * @public
2033
- * @deprecated Use {@link PluginServiceFactoryOptions} instead
2034
- */
2035
- type PluginServiceFactoryConfig<TService, TInstances extends 'singleton' | 'multiton', TContext, TImpl extends TService, TDeps extends {
2036
- [name in string]: ServiceRef<unknown>;
2037
- }> = PluginServiceFactoryOptions<TService, TInstances, TContext, TImpl, TDeps>;
2038
-
2039
- export { type AuthService, type BackendFeature, type BackendFeatureCompat, type BackendModuleConfig, type BackendModuleRegistrationPoints, type BackendPluginConfig, type BackendPluginRegistrationPoints, type BackstageCredentials, type BackstageNonePrincipal, type BackstagePrincipalAccessRestrictions, type BackstagePrincipalTypes, type BackstageServicePrincipal, type BackstageUserInfo, type BackstageUserPrincipal, type CacheService, type CacheServiceOptions, type CacheServiceSetOptions, type CreateBackendFeatureLoaderOptions, type CreateBackendModuleOptions, type CreateBackendPluginOptions, type CreateExtensionPointOptions, type DatabaseService, type DiscoveryService, type ExtensionPoint, type ExtensionPointConfig, type HttpAuthService, type HttpRouterService, type HttpRouterServiceAuthPolicy, type IdentityService, type LifecycleService, type LifecycleServiceShutdownHook, type LifecycleServiceShutdownOptions, type LifecycleServiceStartupHook, type LifecycleServiceStartupOptions, type LoggerService, type PermissionsService, type PermissionsServiceRequestOptions, type PluginMetadataService, type PluginServiceFactoryConfig, type PluginServiceFactoryOptions, type ReadTreeOptions, type ReadTreeResponse, type ReadTreeResponseDirOptions, type ReadTreeResponseFile, type ReadUrlOptions, type ReadUrlResponse, type RootConfigService, type RootHealthService, type RootHttpRouterService, type RootLifecycleService, type RootLoggerService, type RootServiceFactoryConfig, type RootServiceFactoryOptions, type SchedulerService, type SchedulerServiceTaskDescriptor, type SchedulerServiceTaskFunction, type SchedulerServiceTaskInvocationDefinition, type SchedulerServiceTaskRunner, type SchedulerServiceTaskScheduleDefinition, type SchedulerServiceTaskScheduleDefinitionConfig, type SearchOptions, type SearchResponse, type SearchResponseFile, type ServiceFactory, type ServiceFactoryCompat, type ServiceFactoryOrFunction, type ServiceRef, type ServiceRefConfig, type ServiceRefOptions, type TokenManagerService, type UrlReaderService, type UrlReaderServiceReadTreeOptions, type UrlReaderServiceReadTreeResponse, type UrlReaderServiceReadTreeResponseDirOptions, type UrlReaderServiceReadTreeResponseFile, type UrlReaderServiceReadUrlOptions, type UrlReaderServiceReadUrlResponse, type UrlReaderServiceSearchOptions, type UrlReaderServiceSearchResponse, type UrlReaderServiceSearchResponseFile, type UserInfoService, coreServices, createBackendFeatureLoader, createBackendModule, createBackendPlugin, createExtensionPoint, createServiceFactory, createServiceRef, isDatabaseConflictError, readSchedulerServiceTaskScheduleDefinitionFromConfig, resolvePackagePath, resolveSafeChildPath };
1976
+ export { type AuthService, type BackendFeature, type BackendFeatureCompat, type BackendModuleConfig, type BackendModuleRegistrationPoints, type BackendPluginConfig, type BackendPluginRegistrationPoints, type BackstageCredentials, type BackstageNonePrincipal, type BackstagePrincipalAccessRestrictions, type BackstagePrincipalTypes, type BackstageServicePrincipal, type BackstageUserInfo, type BackstageUserPrincipal, type CacheService, type CacheServiceOptions, type CacheServiceSetOptions, type CreateBackendFeatureLoaderOptions, type CreateBackendModuleOptions, type CreateBackendPluginOptions, type CreateExtensionPointOptions, type DatabaseService, type DiscoveryService, type ExtensionPoint, type ExtensionPointConfig, type HttpAuthService, type HttpRouterService, type HttpRouterServiceAuthPolicy, type IdentityService, type LifecycleService, type LifecycleServiceShutdownHook, type LifecycleServiceShutdownOptions, type LifecycleServiceStartupHook, type LifecycleServiceStartupOptions, type LoggerService, type PermissionsService, type PermissionsServiceRequestOptions, type PluginMetadataService, type PluginServiceFactoryOptions, type RootConfigService, type RootHealthService, type RootHttpRouterService, type RootLifecycleService, type RootLoggerService, type RootServiceFactoryOptions, type SchedulerService, type SchedulerServiceTaskDescriptor, type SchedulerServiceTaskFunction, type SchedulerServiceTaskInvocationDefinition, type SchedulerServiceTaskRunner, type SchedulerServiceTaskScheduleDefinition, type SchedulerServiceTaskScheduleDefinitionConfig, type ServiceFactory, type ServiceFactoryCompat, type ServiceFactoryOrFunction, type ServiceRef, type ServiceRefOptions, type TokenManagerService, type UrlReaderService, type UrlReaderServiceReadTreeOptions, type UrlReaderServiceReadTreeResponse, type UrlReaderServiceReadTreeResponseDirOptions, type UrlReaderServiceReadTreeResponseFile, type UrlReaderServiceReadUrlOptions, type UrlReaderServiceReadUrlResponse, type UrlReaderServiceSearchOptions, type UrlReaderServiceSearchResponse, type UrlReaderServiceSearchResponseFile, type UserInfoService, coreServices, createBackendFeatureLoader, createBackendModule, createBackendPlugin, createExtensionPoint, createServiceFactory, createServiceRef, isDatabaseConflictError, readSchedulerServiceTaskScheduleDefinitionFromConfig, resolvePackagePath, resolveSafeChildPath };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/backend-plugin-api",
3
- "version": "0.8.0-next.2",
3
+ "version": "0.8.0",
4
4
  "description": "Core API used by Backstage backend plugins",
5
5
  "backstage": {
6
6
  "role": "node-library"
@@ -56,8 +56,8 @@
56
56
  "@backstage/cli-common": "^0.1.14",
57
57
  "@backstage/config": "^1.2.0",
58
58
  "@backstage/errors": "^1.2.4",
59
- "@backstage/plugin-auth-node": "^0.5.0-next.2",
60
- "@backstage/plugin-permission-common": "^0.8.1-next.1",
59
+ "@backstage/plugin-auth-node": "^0.5.0",
60
+ "@backstage/plugin-permission-common": "^0.8.1",
61
61
  "@backstage/types": "^1.1.1",
62
62
  "@types/express": "^4.17.6",
63
63
  "@types/luxon": "^3.0.0",
@@ -66,7 +66,7 @@
66
66
  "luxon": "^3.0.0"
67
67
  },
68
68
  "devDependencies": {
69
- "@backstage/backend-test-utils": "^0.4.5-next.2",
70
- "@backstage/cli": "^0.27.0-next.3"
69
+ "@backstage/backend-test-utils": "^0.5.0",
70
+ "@backstage/cli": "^0.27.0"
71
71
  }
72
72
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/backend-plugin-api__testutils",
3
- "version": "0.8.0-next.2",
3
+ "version": "0.8.0",
4
4
  "main": "../dist/testUtils.cjs.js",
5
5
  "types": "../dist/testUtils.d.ts"
6
6
  }