@backstage/backend-plugin-api 0.0.0-nightly-20230207022622 → 0.0.0-nightly-20230209023017

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,14 +1,18 @@
1
1
  # @backstage/backend-plugin-api
2
2
 
3
- ## 0.0.0-nightly-20230207022622
3
+ ## 0.0.0-nightly-20230209023017
4
4
 
5
5
  ### Minor Changes
6
6
 
7
7
  - e716946103: **BREAKING**: Split out the hook for both lifecycle services so that the first parameter of `addShutdownHook` is the hook function, and the second is the options.
8
8
  - 0ff03319be: **BREAKING**: The plugin ID option passed to `createBackendPlugin` is now `pluginId`, rather than just `id`. This is to make it match `createBackendModule` more closely.
9
+ - 71a5ec0f06: **BREAKING**: Switched out `LogMeta` type for `JsonObject`.
10
+ - b86efa2d04: Switch `ServiceFactory` to be an opaque type, keeping only the `service` field as public API, but also adding a type parameter for the service scope.
11
+ - 610d65e143: Switched `BackendFeature` to be an opaque type.
9
12
 
10
13
  ### Patch Changes
11
14
 
15
+ - 9c9456fd33: Removed the unused `TypesToServiceRef` type
12
16
  - 181c03edb5: Aligned opaque type markers to all use a `$type` property with namespacing.
13
17
  - ae88f61e00: The `register` methods passed to `createBackendPlugin` and `createBackendModule`
14
18
  now have dedicated `BackendPluginRegistrationPoints` and
@@ -17,10 +21,30 @@
17
21
  dependencies to plugins (should only ever be done for modules). This has no
18
22
  practical effect on code that was already well behaved.
19
23
  - Updated dependencies
20
- - @backstage/backend-tasks@0.0.0-nightly-20230207022622
24
+ - @backstage/backend-tasks@0.0.0-nightly-20230209023017
25
+ - @backstage/config@1.0.6
26
+ - @backstage/types@1.0.2
27
+ - @backstage/plugin-auth-node@0.0.0-nightly-20230209023017
28
+ - @backstage/plugin-permission-common@0.7.3
29
+
30
+ ## 0.4.0-next.2
31
+
32
+ ### Minor Changes
33
+
34
+ - e716946103: **BREAKING**: Split out the hook for both lifecycle services so that the first parameter of `addShutdownHook` is the hook function, and the second is the options.
35
+ - 0ff03319be: **BREAKING**: The plugin ID option passed to `createBackendPlugin` is now `pluginId`, rather than just `id`. This is to make it match `createBackendModule` more closely.
36
+ - 71a5ec0f06: **BREAKING**: Switched out `LogMeta` type for `JsonObject`.
37
+ - 610d65e143: Switched `BackendFeature` to be an opaque type.
38
+
39
+ ### Patch Changes
40
+
41
+ - 9c9456fd33: Removed the unused `TypesToServiceRef` type
42
+ - 181c03edb5: Aligned opaque type markers to all use a `$type` property with namespacing.
43
+ - Updated dependencies
44
+ - @backstage/backend-tasks@0.4.3-next.2
45
+ - @backstage/plugin-auth-node@0.2.11-next.2
21
46
  - @backstage/config@1.0.6
22
47
  - @backstage/types@1.0.2
23
- - @backstage/plugin-auth-node@0.0.0-nightly-20230207022622
24
48
  - @backstage/plugin-permission-common@0.7.3
25
49
 
26
50
  ## 0.3.2-next.1
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/backend-plugin-api",
3
- "version": "0.0.0-nightly-20230207022622",
3
+ "version": "0.0.0-nightly-20230209023017",
4
4
  "main": "../dist/index.cjs.js",
5
5
  "types": "../dist/index.alpha.d.ts"
6
6
  }
@@ -9,6 +9,7 @@
9
9
  import { Config } from '@backstage/config';
10
10
  import { Handler } from 'express';
11
11
  import { IdentityApi } from '@backstage/plugin-auth-node';
12
+ import { JsonObject } from '@backstage/types';
12
13
  import { JsonValue } from '@backstage/types';
13
14
  import { Knex } from 'knex';
14
15
  import { PermissionEvaluator } from '@backstage/plugin-permission-common';
@@ -17,8 +18,7 @@ import { Readable } from 'stream';
17
18
 
18
19
  /** @public */
19
20
  export declare interface BackendFeature {
20
- id: string;
21
- register(reg: BackendRegistrationPoints): void;
21
+ $$type: '@backstage/BackendFeature';
22
22
  }
23
23
 
24
24
  /**
@@ -92,25 +92,6 @@ export declare interface BackendPluginRegistrationPoints {
92
92
  }): void;
93
93
  }
94
94
 
95
- /**
96
- * The callbacks passed to the `register` method of a backend feature; this is
97
- * essentially a superset of {@link BackendPluginRegistrationPoints} and
98
- * {@link BackendModuleRegistrationPoints}.
99
- *
100
- * @public
101
- */
102
- export declare interface BackendRegistrationPoints {
103
- registerExtensionPoint<TExtensionPoint>(ref: ExtensionPoint<TExtensionPoint>, impl: TExtensionPoint): void;
104
- registerInit<Deps extends {
105
- [name in string]: unknown;
106
- }>(options: {
107
- deps: {
108
- [name in keyof Deps]: ServiceRef<Deps[name]> | ExtensionPoint<Deps[name]>;
109
- };
110
- init(deps: Deps): Promise<void>;
111
- }): void;
112
- }
113
-
114
95
  /**
115
96
  * A pre-configured, storage agnostic cache client suitable for use by
116
97
  * Backstage plugins.
@@ -324,7 +305,7 @@ export declare function createExtensionPoint<T>(config: ExtensionPointConfig): E
324
305
  */
325
306
  export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
326
307
  [name in string]: ServiceRef<unknown>;
327
- }, TOpts extends object | undefined = undefined>(config: RootServiceFactoryConfig<TService, TImpl, TDeps>): () => ServiceFactory<TService>;
308
+ }, TOpts extends object | undefined = undefined>(config: RootServiceFactoryConfig<TService, TImpl, TDeps>): () => ServiceFactory<TService, 'root'>;
328
309
 
329
310
  /**
330
311
  * Creates a root scoped service factory with optional options.
@@ -334,7 +315,7 @@ export declare function createServiceFactory<TService, TImpl extends TService, T
334
315
  */
335
316
  export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
336
317
  [name in string]: ServiceRef<unknown>;
337
- }, TOpts extends object | undefined = undefined>(config: (options?: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>): (options?: TOpts) => ServiceFactory<TService>;
318
+ }, TOpts extends object | undefined = undefined>(config: (options?: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>): (options?: TOpts) => ServiceFactory<TService, 'root'>;
338
319
 
339
320
  /**
340
321
  * Creates a root scoped service factory with required options.
@@ -344,7 +325,7 @@ export declare function createServiceFactory<TService, TImpl extends TService, T
344
325
  */
345
326
  export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
346
327
  [name in string]: ServiceRef<unknown>;
347
- }, TOpts extends object | undefined = undefined>(config: (options: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>): (options: TOpts) => ServiceFactory<TService>;
328
+ }, TOpts extends object | undefined = undefined>(config: (options: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>): (options: TOpts) => ServiceFactory<TService, 'root'>;
348
329
 
349
330
  /**
350
331
  * Creates a plugin scoped service factory without options.
@@ -354,7 +335,7 @@ export declare function createServiceFactory<TService, TImpl extends TService, T
354
335
  */
355
336
  export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
356
337
  [name in string]: ServiceRef<unknown>;
357
- }, TContext = undefined, TOpts extends object | undefined = undefined>(config: PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>): () => ServiceFactory<TService>;
338
+ }, TContext = undefined, TOpts extends object | undefined = undefined>(config: PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>): () => ServiceFactory<TService, 'plugin'>;
358
339
 
359
340
  /**
360
341
  * Creates a plugin scoped service factory with optional options.
@@ -364,7 +345,7 @@ export declare function createServiceFactory<TService, TImpl extends TService, T
364
345
  */
365
346
  export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
366
347
  [name in string]: ServiceRef<unknown>;
367
- }, TContext = undefined, TOpts extends object | undefined = undefined>(config: (options?: TOpts) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>): (options?: TOpts) => ServiceFactory<TService>;
348
+ }, TContext = undefined, TOpts extends object | undefined = undefined>(config: (options?: TOpts) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>): (options?: TOpts) => ServiceFactory<TService, 'plugin'>;
368
349
 
369
350
  /**
370
351
  * Creates a plugin scoped service factory with required options.
@@ -374,7 +355,7 @@ export declare function createServiceFactory<TService, TImpl extends TService, T
374
355
  */
375
356
  export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
376
357
  [name in string]: ServiceRef<unknown>;
377
- }, TContext = undefined, TOpts extends object | undefined = undefined>(config: PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps> | ((options: TOpts) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>)): (options: TOpts) => ServiceFactory<TService>;
358
+ }, TContext = undefined, TOpts extends object | undefined = undefined>(config: PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps> | ((options: TOpts) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>)): (options: TOpts) => ServiceFactory<TService, 'plugin'>;
378
359
 
379
360
  /**
380
361
  * Creates a new service definition. This overload is used to create plugin scoped services.
@@ -545,20 +526,13 @@ export declare interface LifecycleServiceShutdownOptions {
545
526
  * @public
546
527
  */
547
528
  export declare interface LoggerService {
548
- error(message: string, meta?: Error | LogMeta): void;
549
- warn(message: string, meta?: Error | LogMeta): void;
550
- info(message: string, meta?: Error | LogMeta): void;
551
- debug(message: string, meta?: Error | LogMeta): void;
552
- child(meta: LogMeta): LoggerService;
529
+ error(message: string, meta?: Error | JsonObject): void;
530
+ warn(message: string, meta?: Error | JsonObject): void;
531
+ info(message: string, meta?: Error | JsonObject): void;
532
+ debug(message: string, meta?: Error | JsonObject): void;
533
+ child(meta: JsonObject): LoggerService;
553
534
  }
554
535
 
555
- /**
556
- * @public
557
- */
558
- export declare type LogMeta = {
559
- [name: string]: unknown;
560
- };
561
-
562
536
  /** @public */
563
537
  export declare interface PermissionsService extends PermissionEvaluator {
564
538
  }
@@ -846,35 +820,17 @@ export declare type SearchResponseFile = {
846
820
  };
847
821
 
848
822
  /** @public */
849
- export declare type ServiceFactory<TService = unknown> = {
850
- scope: 'root';
851
- service: ServiceRef<TService, 'root'>;
852
- deps: {
853
- [key in string]: ServiceRef<unknown>;
854
- };
855
- factory(deps: {
856
- [key in string]: unknown;
857
- }): Promise<TService>;
858
- } | {
859
- scope: 'plugin';
860
- service: ServiceRef<TService, 'plugin'>;
861
- deps: {
862
- [key in string]: ServiceRef<unknown>;
863
- };
864
- createRootContext?(deps: {
865
- [key in string]: unknown;
866
- }): Promise<unknown>;
867
- factory(deps: {
868
- [key in string]: unknown;
869
- }, context: unknown): Promise<TService>;
870
- };
823
+ export declare interface ServiceFactory<TService = unknown, TScope extends 'plugin' | 'root' = 'plugin' | 'root'> {
824
+ $$type: '@backstage/ServiceFactory';
825
+ service: ServiceRef<TService, TScope>;
826
+ }
871
827
 
872
828
  /**
873
829
  * Represents either a {@link ServiceFactory} or a function that returns one.
874
830
  *
875
831
  * @public
876
832
  */
877
- export declare type ServiceFactoryOrFunction<TService = unknown> = ServiceFactory<TService> | (() => ServiceFactory<TService>);
833
+ export declare type ServiceFactoryOrFunction = ServiceFactory | (() => ServiceFactory);
878
834
 
879
835
  /**
880
836
  * TODO
@@ -906,7 +862,7 @@ export declare type ServiceRef<TService, TScope extends 'root' | 'plugin' = 'roo
906
862
  export declare interface ServiceRefConfig<TService, TScope extends 'root' | 'plugin'> {
907
863
  id: string;
908
864
  scope?: TScope;
909
- defaultFactory?: (service: ServiceRef<TService, TScope>) => Promise<ServiceFactoryOrFunction<TService>>;
865
+ defaultFactory?: (service: ServiceRef<TService, TScope>) => Promise<ServiceFactoryOrFunction>;
910
866
  }
911
867
 
912
868
  /** @ignore */
@@ -959,11 +915,6 @@ export declare interface TokenManagerService {
959
915
  authenticate(token: string): Promise<void>;
960
916
  }
961
917
 
962
- /** @public */
963
- export declare type TypesToServiceRef<T> = {
964
- [key in keyof T]: ServiceRef<T[key]>;
965
- };
966
-
967
918
  /**
968
919
  * A generic interface for fetching plain data from URLs.
969
920
  *
@@ -9,6 +9,7 @@
9
9
  import { Config } from '@backstage/config';
10
10
  import { Handler } from 'express';
11
11
  import { IdentityApi } from '@backstage/plugin-auth-node';
12
+ import { JsonObject } from '@backstage/types';
12
13
  import { JsonValue } from '@backstage/types';
13
14
  import { Knex } from 'knex';
14
15
  import { PermissionEvaluator } from '@backstage/plugin-permission-common';
@@ -17,8 +18,7 @@ import { Readable } from 'stream';
17
18
 
18
19
  /** @public */
19
20
  export declare interface BackendFeature {
20
- id: string;
21
- register(reg: BackendRegistrationPoints): void;
21
+ $$type: '@backstage/BackendFeature';
22
22
  }
23
23
 
24
24
  /**
@@ -92,25 +92,6 @@ export declare interface BackendPluginRegistrationPoints {
92
92
  }): void;
93
93
  }
94
94
 
95
- /**
96
- * The callbacks passed to the `register` method of a backend feature; this is
97
- * essentially a superset of {@link BackendPluginRegistrationPoints} and
98
- * {@link BackendModuleRegistrationPoints}.
99
- *
100
- * @public
101
- */
102
- export declare interface BackendRegistrationPoints {
103
- registerExtensionPoint<TExtensionPoint>(ref: ExtensionPoint<TExtensionPoint>, impl: TExtensionPoint): void;
104
- registerInit<Deps extends {
105
- [name in string]: unknown;
106
- }>(options: {
107
- deps: {
108
- [name in keyof Deps]: ServiceRef<Deps[name]> | ExtensionPoint<Deps[name]>;
109
- };
110
- init(deps: Deps): Promise<void>;
111
- }): void;
112
- }
113
-
114
95
  /**
115
96
  * A pre-configured, storage agnostic cache client suitable for use by
116
97
  * Backstage plugins.
@@ -324,7 +305,7 @@ export declare function createExtensionPoint<T>(config: ExtensionPointConfig): E
324
305
  */
325
306
  export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
326
307
  [name in string]: ServiceRef<unknown>;
327
- }, TOpts extends object | undefined = undefined>(config: RootServiceFactoryConfig<TService, TImpl, TDeps>): () => ServiceFactory<TService>;
308
+ }, TOpts extends object | undefined = undefined>(config: RootServiceFactoryConfig<TService, TImpl, TDeps>): () => ServiceFactory<TService, 'root'>;
328
309
 
329
310
  /**
330
311
  * Creates a root scoped service factory with optional options.
@@ -334,7 +315,7 @@ export declare function createServiceFactory<TService, TImpl extends TService, T
334
315
  */
335
316
  export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
336
317
  [name in string]: ServiceRef<unknown>;
337
- }, TOpts extends object | undefined = undefined>(config: (options?: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>): (options?: TOpts) => ServiceFactory<TService>;
318
+ }, TOpts extends object | undefined = undefined>(config: (options?: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>): (options?: TOpts) => ServiceFactory<TService, 'root'>;
338
319
 
339
320
  /**
340
321
  * Creates a root scoped service factory with required options.
@@ -344,7 +325,7 @@ export declare function createServiceFactory<TService, TImpl extends TService, T
344
325
  */
345
326
  export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
346
327
  [name in string]: ServiceRef<unknown>;
347
- }, TOpts extends object | undefined = undefined>(config: (options: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>): (options: TOpts) => ServiceFactory<TService>;
328
+ }, TOpts extends object | undefined = undefined>(config: (options: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>): (options: TOpts) => ServiceFactory<TService, 'root'>;
348
329
 
349
330
  /**
350
331
  * Creates a plugin scoped service factory without options.
@@ -354,7 +335,7 @@ export declare function createServiceFactory<TService, TImpl extends TService, T
354
335
  */
355
336
  export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
356
337
  [name in string]: ServiceRef<unknown>;
357
- }, TContext = undefined, TOpts extends object | undefined = undefined>(config: PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>): () => ServiceFactory<TService>;
338
+ }, TContext = undefined, TOpts extends object | undefined = undefined>(config: PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>): () => ServiceFactory<TService, 'plugin'>;
358
339
 
359
340
  /**
360
341
  * Creates a plugin scoped service factory with optional options.
@@ -364,7 +345,7 @@ export declare function createServiceFactory<TService, TImpl extends TService, T
364
345
  */
365
346
  export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
366
347
  [name in string]: ServiceRef<unknown>;
367
- }, TContext = undefined, TOpts extends object | undefined = undefined>(config: (options?: TOpts) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>): (options?: TOpts) => ServiceFactory<TService>;
348
+ }, TContext = undefined, TOpts extends object | undefined = undefined>(config: (options?: TOpts) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>): (options?: TOpts) => ServiceFactory<TService, 'plugin'>;
368
349
 
369
350
  /**
370
351
  * Creates a plugin scoped service factory with required options.
@@ -374,7 +355,7 @@ export declare function createServiceFactory<TService, TImpl extends TService, T
374
355
  */
375
356
  export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
376
357
  [name in string]: ServiceRef<unknown>;
377
- }, TContext = undefined, TOpts extends object | undefined = undefined>(config: PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps> | ((options: TOpts) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>)): (options: TOpts) => ServiceFactory<TService>;
358
+ }, TContext = undefined, TOpts extends object | undefined = undefined>(config: PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps> | ((options: TOpts) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>)): (options: TOpts) => ServiceFactory<TService, 'plugin'>;
378
359
 
379
360
  /**
380
361
  * Creates a new service definition. This overload is used to create plugin scoped services.
@@ -545,20 +526,13 @@ export declare interface LifecycleServiceShutdownOptions {
545
526
  * @public
546
527
  */
547
528
  export declare interface LoggerService {
548
- error(message: string, meta?: Error | LogMeta): void;
549
- warn(message: string, meta?: Error | LogMeta): void;
550
- info(message: string, meta?: Error | LogMeta): void;
551
- debug(message: string, meta?: Error | LogMeta): void;
552
- child(meta: LogMeta): LoggerService;
529
+ error(message: string, meta?: Error | JsonObject): void;
530
+ warn(message: string, meta?: Error | JsonObject): void;
531
+ info(message: string, meta?: Error | JsonObject): void;
532
+ debug(message: string, meta?: Error | JsonObject): void;
533
+ child(meta: JsonObject): LoggerService;
553
534
  }
554
535
 
555
- /**
556
- * @public
557
- */
558
- export declare type LogMeta = {
559
- [name: string]: unknown;
560
- };
561
-
562
536
  /** @public */
563
537
  export declare interface PermissionsService extends PermissionEvaluator {
564
538
  }
@@ -846,35 +820,17 @@ export declare type SearchResponseFile = {
846
820
  };
847
821
 
848
822
  /** @public */
849
- export declare type ServiceFactory<TService = unknown> = {
850
- scope: 'root';
851
- service: ServiceRef<TService, 'root'>;
852
- deps: {
853
- [key in string]: ServiceRef<unknown>;
854
- };
855
- factory(deps: {
856
- [key in string]: unknown;
857
- }): Promise<TService>;
858
- } | {
859
- scope: 'plugin';
860
- service: ServiceRef<TService, 'plugin'>;
861
- deps: {
862
- [key in string]: ServiceRef<unknown>;
863
- };
864
- createRootContext?(deps: {
865
- [key in string]: unknown;
866
- }): Promise<unknown>;
867
- factory(deps: {
868
- [key in string]: unknown;
869
- }, context: unknown): Promise<TService>;
870
- };
823
+ export declare interface ServiceFactory<TService = unknown, TScope extends 'plugin' | 'root' = 'plugin' | 'root'> {
824
+ $$type: '@backstage/ServiceFactory';
825
+ service: ServiceRef<TService, TScope>;
826
+ }
871
827
 
872
828
  /**
873
829
  * Represents either a {@link ServiceFactory} or a function that returns one.
874
830
  *
875
831
  * @public
876
832
  */
877
- export declare type ServiceFactoryOrFunction<TService = unknown> = ServiceFactory<TService> | (() => ServiceFactory<TService>);
833
+ export declare type ServiceFactoryOrFunction = ServiceFactory | (() => ServiceFactory);
878
834
 
879
835
  /**
880
836
  * TODO
@@ -906,7 +862,7 @@ export declare type ServiceRef<TService, TScope extends 'root' | 'plugin' = 'roo
906
862
  export declare interface ServiceRefConfig<TService, TScope extends 'root' | 'plugin'> {
907
863
  id: string;
908
864
  scope?: TScope;
909
- defaultFactory?: (service: ServiceRef<TService, TScope>) => Promise<ServiceFactoryOrFunction<TService>>;
865
+ defaultFactory?: (service: ServiceRef<TService, TScope>) => Promise<ServiceFactoryOrFunction>;
910
866
  }
911
867
 
912
868
  /** @ignore */
@@ -959,11 +915,6 @@ export declare interface TokenManagerService {
959
915
  authenticate(token: string): Promise<void>;
960
916
  }
961
917
 
962
- /** @public */
963
- export declare type TypesToServiceRef<T> = {
964
- [key in keyof T]: ServiceRef<T[key]>;
965
- };
966
-
967
918
  /**
968
919
  * A generic interface for fetching plain data from URLs.
969
920
  *
package/dist/index.cjs.js CHANGED
@@ -20,17 +20,30 @@ function createServiceRef(config) {
20
20
  function createServiceFactory(config) {
21
21
  const configCallback = typeof config === "function" ? config : () => config;
22
22
  return (options) => {
23
- const c = configCallback(options);
23
+ const anyConf = configCallback(options);
24
+ if (anyConf.service.scope === "root") {
25
+ const c2 = anyConf;
26
+ return {
27
+ $$type: "@backstage/ServiceFactory",
28
+ version: "v1",
29
+ service: c2.service,
30
+ deps: c2.deps,
31
+ factory: async (deps) => c2.factory(deps)
32
+ };
33
+ }
34
+ const c = anyConf;
24
35
  return {
25
- ...c,
36
+ $$type: "@backstage/ServiceFactory",
37
+ version: "v1",
38
+ service: c.service,
26
39
  ..."createRootContext" in c ? {
27
40
  createRootContext: async (deps) => {
28
41
  var _a;
29
42
  return (_a = c == null ? void 0 : c.createRootContext) == null ? void 0 : _a.call(c, deps);
30
43
  }
31
44
  } : {},
32
- factory: async (deps, ctx) => c.factory(deps, ctx),
33
- scope: c.service.scope
45
+ deps: c.deps,
46
+ factory: async (deps, ctx) => c.factory(deps, ctx)
34
47
  };
35
48
  };
36
49
  }
@@ -102,38 +115,97 @@ function createExtensionPoint(config) {
102
115
  };
103
116
  }
104
117
  function createBackendPlugin(config) {
105
- if (typeof config === "function") {
106
- return (...options) => {
107
- const c = config(...options);
108
- return {
109
- ...c,
110
- id: c.pluginId
111
- };
118
+ const configCallback = typeof config === "function" ? config : () => config;
119
+ return (...options) => {
120
+ const c = configCallback(...options);
121
+ let registrations;
122
+ return {
123
+ $$type: "@backstage/BackendFeature",
124
+ version: "v1",
125
+ getRegistrations() {
126
+ if (registrations) {
127
+ return registrations;
128
+ }
129
+ const extensionPoints = [];
130
+ let init = void 0;
131
+ c.register({
132
+ registerExtensionPoint(ext, impl) {
133
+ if (init) {
134
+ throw new Error(
135
+ "registerExtensionPoint called after registerInit"
136
+ );
137
+ }
138
+ extensionPoints.push([ext, impl]);
139
+ },
140
+ registerInit(regInit) {
141
+ if (init) {
142
+ throw new Error("registerInit must only be called once");
143
+ }
144
+ init = {
145
+ deps: regInit.deps,
146
+ func: regInit.init
147
+ };
148
+ }
149
+ });
150
+ if (!init) {
151
+ throw new Error(
152
+ `registerInit was not called by register in ${c.pluginId}`
153
+ );
154
+ }
155
+ registrations = [
156
+ {
157
+ type: "plugin",
158
+ pluginId: c.pluginId,
159
+ extensionPoints,
160
+ init
161
+ }
162
+ ];
163
+ return registrations;
164
+ }
112
165
  };
113
- }
114
- return () => ({
115
- ...config,
116
- id: config.pluginId
117
- });
166
+ };
118
167
  }
119
168
  function createBackendModule(config) {
120
- if (typeof config === "function") {
121
- return (...options) => {
122
- const c = config(...options);
123
- return {
124
- id: `${c.pluginId}.${c.moduleId}`,
125
- register: c.register
126
- };
169
+ const configCallback = typeof config === "function" ? config : () => config;
170
+ return (...options) => {
171
+ const c = configCallback(...options);
172
+ let registrations;
173
+ return {
174
+ $$type: "@backstage/BackendFeature",
175
+ version: "v1",
176
+ getRegistrations() {
177
+ if (registrations) {
178
+ return registrations;
179
+ }
180
+ let init = void 0;
181
+ c.register({
182
+ registerInit(regInit) {
183
+ if (init) {
184
+ throw new Error("registerInit must only be called once");
185
+ }
186
+ init = {
187
+ deps: regInit.deps,
188
+ func: regInit.init
189
+ };
190
+ }
191
+ });
192
+ if (!init) {
193
+ throw new Error(
194
+ `registerInit was not called by register in ${c.moduleId} module for ${c.pluginId}`
195
+ );
196
+ }
197
+ registrations = [
198
+ {
199
+ type: "module",
200
+ pluginId: c.pluginId,
201
+ moduleId: c.moduleId,
202
+ init
203
+ }
204
+ ];
205
+ return registrations;
206
+ }
127
207
  };
128
- }
129
- return () => ({
130
- id: `${config.pluginId}.${config.moduleId}`,
131
- register(register) {
132
- return config.register({
133
- registerInit: register.registerInit.bind(register)
134
- });
135
- }
136
- });
208
+ };
137
209
  }
138
210
 
139
211
  exports.createBackendModule = createBackendModule;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/services/system/types.ts","../src/services/definitions/coreServices.ts","../src/wiring/createSharedEnvironment.ts","../src/wiring/factories.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * TODO\n *\n * @public\n */\nexport type ServiceRef<\n TService,\n TScope extends 'root' | 'plugin' = 'root' | 'plugin',\n> = {\n id: string;\n\n /**\n * This determines the scope at which this service is available.\n *\n * Root scoped services are available to all other services but\n * may only depend on other root scoped services.\n *\n * Plugin scoped services are only available to other plugin scoped\n * services but may depend on all other services.\n */\n scope: TScope;\n\n /**\n * Utility for getting the type of the service, using `typeof serviceRef.T`.\n * Attempting to actually read this value will result in an exception.\n */\n T: TService;\n\n toString(): string;\n\n $$type: '@backstage/ServiceRef';\n};\n\n/** @public */\nexport type TypesToServiceRef<T> = { [key in keyof T]: ServiceRef<T[key]> };\n\n/** @public */\nexport type ServiceFactory<TService = unknown> =\n | {\n // This scope prop is needed in addition to the service ref, as TypeScript\n // can't properly discriminate the two factory types otherwise.\n scope: 'root';\n service: ServiceRef<TService, 'root'>;\n deps: { [key in string]: ServiceRef<unknown> };\n factory(deps: { [key in string]: unknown }): Promise<TService>;\n }\n | {\n scope: 'plugin';\n service: ServiceRef<TService, 'plugin'>;\n deps: { [key in string]: ServiceRef<unknown> };\n createRootContext?(deps: { [key in string]: unknown }): Promise<unknown>;\n factory(\n deps: { [key in string]: unknown },\n context: unknown,\n ): Promise<TService>;\n };\n\n/**\n * Represents either a {@link ServiceFactory} or a function that returns one.\n *\n * @public\n */\nexport type ServiceFactoryOrFunction<TService = unknown> =\n | ServiceFactory<TService>\n | (() => ServiceFactory<TService>);\n\n/** @public */\nexport interface ServiceRefConfig<TService, TScope extends 'root' | 'plugin'> {\n id: string;\n scope?: TScope;\n defaultFactory?: (\n service: ServiceRef<TService, TScope>,\n ) => Promise<ServiceFactoryOrFunction<TService>>;\n}\n\n/**\n * Creates a new service definition. This overload is used to create plugin scoped services.\n *\n * @public\n */\nexport function createServiceRef<TService>(\n config: ServiceRefConfig<TService, 'plugin'>,\n): ServiceRef<TService, 'plugin'>;\n\n/**\n * Creates a new service definition. This overload is used to create root scoped services.\n *\n * @public\n */\nexport function createServiceRef<TService>(\n config: ServiceRefConfig<TService, 'root'>,\n): ServiceRef<TService, 'root'>;\nexport function createServiceRef<TService>(\n config: ServiceRefConfig<TService, any>,\n): ServiceRef<TService, any> {\n const { id, scope = 'plugin', defaultFactory } = config;\n return {\n id,\n scope,\n get T(): TService {\n throw new Error(`tried to read ServiceRef.T of ${this}`);\n },\n toString() {\n return `serviceRef{${config.id}}`;\n },\n $$type: '@backstage/ServiceRef',\n __defaultFactory: defaultFactory,\n } as ServiceRef<TService, typeof scope> & {\n __defaultFactory?: (\n service: ServiceRef<TService>,\n ) => Promise<ServiceFactory<TService> | (() => ServiceFactory<TService>)>;\n };\n}\n\n/** @ignore */\ntype ServiceRefsToInstances<\n T extends { [key in string]: ServiceRef<unknown> },\n TScope extends 'root' | 'plugin' = 'root' | 'plugin',\n> = {\n [key in keyof T as T[key]['scope'] extends TScope ? key : never]: T[key]['T'];\n};\n\n/** @public */\nexport interface RootServiceFactoryConfig<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n> {\n service: ServiceRef<TService, 'root'>;\n deps: TDeps;\n factory(deps: ServiceRefsToInstances<TDeps, 'root'>): TImpl | Promise<TImpl>;\n}\n\n/** @public */\nexport interface PluginServiceFactoryConfig<\n TService,\n TContext,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n> {\n service: ServiceRef<TService, 'plugin'>;\n deps: TDeps;\n createRootContext?(\n deps: ServiceRefsToInstances<TDeps, 'root'>,\n ): TContext | Promise<TContext>;\n factory(\n deps: ServiceRefsToInstances<TDeps>,\n context: TContext,\n ): TImpl | Promise<TImpl>;\n}\n\n/**\n * Creates a root scoped service factory without options.\n *\n * @public\n * @param config - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TOpts extends object | undefined = undefined,\n>(\n config: RootServiceFactoryConfig<TService, TImpl, TDeps>,\n): () => ServiceFactory<TService>;\n/**\n * Creates a root scoped service factory with optional options.\n *\n * @public\n * @param config - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TOpts extends object | undefined = undefined,\n>(\n config: (options?: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>,\n): (options?: TOpts) => ServiceFactory<TService>;\n/**\n * Creates a root scoped service factory with required options.\n *\n * @public\n * @param config - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TOpts extends object | undefined = undefined,\n>(\n config: (options: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>,\n): (options: TOpts) => ServiceFactory<TService>;\n/**\n * Creates a plugin scoped service factory without options.\n *\n * @public\n * @param config - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TContext = undefined,\n TOpts extends object | undefined = undefined,\n>(\n config: PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>,\n): () => ServiceFactory<TService>;\n/**\n * Creates a plugin scoped service factory with optional options.\n *\n * @public\n * @param config - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TContext = undefined,\n TOpts extends object | undefined = undefined,\n>(\n config: (\n options?: TOpts,\n ) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>,\n): (options?: TOpts) => ServiceFactory<TService>;\n/**\n * Creates a plugin scoped service factory with required options.\n *\n * @public\n * @param config - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TContext = undefined,\n TOpts extends object | undefined = undefined,\n>(\n config:\n | PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>\n | ((\n options: TOpts,\n ) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>),\n): (options: TOpts) => ServiceFactory<TService>;\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TContext,\n TOpts extends object | undefined = undefined,\n>(\n config:\n | RootServiceFactoryConfig<TService, TImpl, TDeps>\n | PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>\n | ((options: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>)\n | ((\n options: TOpts,\n ) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>)\n | (() => RootServiceFactoryConfig<TService, TImpl, TDeps>)\n | (() => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>),\n): (options: TOpts) => ServiceFactory<TService> {\n const configCallback = typeof config === 'function' ? config : () => config;\n return (options: TOpts) => {\n const c = configCallback(options);\n return {\n ...c,\n ...('createRootContext' in c\n ? {\n createRootContext: async (deps: TDeps) =>\n c?.createRootContext?.(deps),\n }\n : {}),\n factory: async (deps: TDeps, ctx: TContext) => c.factory(deps, ctx),\n scope: c.service.scope,\n } as ServiceFactory<TService>;\n };\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system';\n\n/**\n * All core services references\n *\n * @public\n */\nexport namespace coreServices {\n /**\n * The service reference for the plugin scoped {@link CacheService}.\n *\n * @public\n */\n export const cache = createServiceRef<import('./CacheService').CacheService>({\n id: 'core.cache',\n });\n\n /**\n * The service reference for the root scoped {@link ConfigService}.\n *\n * @public\n */\n export const config = createServiceRef<\n import('./ConfigService').ConfigService\n >({ id: 'core.config', scope: 'root' });\n\n /**\n * The service reference for the plugin scoped {@link DatabaseService}.\n *\n * @public\n */\n export const database = createServiceRef<\n import('./DatabaseService').DatabaseService\n >({ id: 'core.database' });\n\n /**\n * The service reference for the plugin scoped {@link DiscoveryService}.\n *\n * @public\n */\n export const discovery = createServiceRef<\n import('./DiscoveryService').DiscoveryService\n >({ id: 'core.discovery' });\n\n /**\n * The service reference for the plugin scoped {@link HttpRouterService}.\n *\n * @public\n */\n export const httpRouter = createServiceRef<\n import('./HttpRouterService').HttpRouterService\n >({ id: 'core.httpRouter' });\n\n /**\n * The service reference for the plugin scoped {@link LifecycleService}.\n *\n * @public\n */\n export const lifecycle = createServiceRef<\n import('./LifecycleService').LifecycleService\n >({ id: 'core.lifecycle' });\n\n /**\n * The service reference for the plugin scoped {@link LoggerService}.\n *\n * @public\n */\n export const logger = createServiceRef<\n import('./LoggerService').LoggerService\n >({ id: 'core.logger' });\n\n /**\n * The service reference for the plugin scoped {@link PermissionsService}.\n *\n * @public\n */\n export const permissions = createServiceRef<\n import('./PermissionsService').PermissionsService\n >({ id: 'core.permissions' });\n\n /**\n * The service reference for the plugin scoped {@link PluginMetadataService}.\n *\n * @public\n */\n export const pluginMetadata = createServiceRef<\n import('./PluginMetadataService').PluginMetadataService\n >({ id: 'core.pluginMetadata' });\n\n /**\n * The service reference for the root scoped {@link RootHttpRouterService}.\n *\n * @public\n */\n export const rootHttpRouter = createServiceRef<\n import('./RootHttpRouterService').RootHttpRouterService\n >({ id: 'core.rootHttpRouter', scope: 'root' });\n\n /**\n * The service reference for the root scoped {@link RootLifecycleService}.\n *\n * @public\n */\n export const rootLifecycle = createServiceRef<\n import('./RootLifecycleService').RootLifecycleService\n >({ id: 'core.rootLifecycle', scope: 'root' });\n\n /**\n * The service reference for the root scoped {@link RootLoggerService}.\n *\n * @public\n */\n export const rootLogger = createServiceRef<\n import('./RootLoggerService').RootLoggerService\n >({ id: 'core.rootLogger', scope: 'root' });\n\n /**\n * The service reference for the plugin scoped {@link SchedulerService}.\n *\n * @public\n */\n export const scheduler = createServiceRef<\n import('./SchedulerService').SchedulerService\n >({ id: 'core.scheduler' });\n\n /**\n * The service reference for the plugin scoped {@link TokenManagerService}.\n *\n * @public\n */\n export const tokenManager = createServiceRef<\n import('./TokenManagerService').TokenManagerService\n >({ id: 'core.tokenManager' });\n\n /**\n * The service reference for the plugin scoped {@link UrlReaderService}.\n *\n * @public\n */\n export const urlReader = createServiceRef<\n import('./UrlReaderService').UrlReaderService\n >({ id: 'core.urlReader' });\n\n /**\n * The service reference for the plugin scoped {@link IdentityService}.\n *\n * @public\n */\n export const identity = createServiceRef<\n import('./IdentityService').IdentityService\n >({ id: 'core.identity' });\n}\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ServiceFactory, ServiceFactoryOrFunction } from '../services';\n\n/**\n * The configuration options passed to {@link createSharedEnvironment}.\n *\n * @public\n */\nexport interface SharedBackendEnvironmentConfig {\n services?: ServiceFactoryOrFunction[];\n}\n\n/**\n * An opaque type that represents the contents of a shared backend environment.\n *\n * @public\n */\nexport interface SharedBackendEnvironment {\n $$type: '@backstage/SharedBackendEnvironment';\n\n // NOTE: This type is opaque in order to allow for future API evolution without\n // cluttering the external API. For example we might want to add support\n // for more powerful callback based backend modifications.\n //\n // By making this opaque we also ensure that the type doesn't become an input\n // type that we need to care about, as it would otherwise be possible to pass\n // a custom environment definition to `createBackend`, which we don't want.\n}\n\n/**\n * This type is NOT supposed to be used by anyone except internally by the\n * backend-app-api package.\n *\n * @internal\n */\nexport interface InternalSharedBackendEnvironment {\n version: 'v1';\n services?: ServiceFactory[];\n}\n\n/**\n * Creates a shared backend environment which can be used to create multiple\n * backends.\n *\n * @public\n */\nexport function createSharedEnvironment<\n TOptions extends [options?: object] = [],\n>(\n config:\n | SharedBackendEnvironmentConfig\n | ((...params: TOptions) => SharedBackendEnvironmentConfig),\n): (...options: TOptions) => SharedBackendEnvironment {\n const configCallback = typeof config === 'function' ? config : () => config;\n\n return (...options) => {\n const actualConfig = configCallback(...options);\n const services = actualConfig?.services?.map(sf =>\n typeof sf === 'function' ? sf() : sf,\n );\n\n const exists = new Set<string>();\n const duplicates = new Set<string>();\n for (const { service } of services ?? []) {\n if (exists.has(service.id)) {\n duplicates.add(service.id);\n } else {\n exists.add(service.id);\n }\n }\n\n if (duplicates.size > 0) {\n const dupStr = [...duplicates].map(id => `'${id}'`).join(', ');\n throw new Error(\n `Duplicate service implementations provided in shared environment for ${dupStr}`,\n );\n }\n\n // Here to ensure type safety in this internal implementation.\n const env: SharedBackendEnvironment & InternalSharedBackendEnvironment = {\n $$type: '@backstage/SharedBackendEnvironment',\n version: 'v1',\n services,\n };\n return env;\n };\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n BackendModuleRegistrationPoints,\n BackendPluginRegistrationPoints,\n BackendRegistrationPoints,\n BackendFeature,\n ExtensionPoint,\n} from './types';\n\n/**\n * The configuration options passed to {@link createExtensionPoint}.\n *\n * @public\n * @see {@link https://backstage.io/docs/backend-system/architecture/extension-points | The architecture of extension points}\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\nexport interface ExtensionPointConfig {\n /**\n * The ID of this extension point.\n *\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\n id: string;\n}\n\n/**\n * Creates a new backend extension point.\n *\n * @public\n * @see {@link https://backstage.io/docs/backend-system/architecture/extension-points | The architecture of extension points}\n */\nexport function createExtensionPoint<T>(\n config: ExtensionPointConfig,\n): ExtensionPoint<T> {\n return {\n id: config.id,\n get T(): T {\n throw new Error(`tried to read ExtensionPoint.T of ${this}`);\n },\n toString() {\n return `extensionPoint{${config.id}}`;\n },\n $$type: '@backstage/ExtensionPoint',\n };\n}\n\n/**\n * The configuration options passed to {@link createBackendPlugin}.\n *\n * @public\n * @see {@link https://backstage.io/docs/backend-system/architecture/plugins | The architecture of plugins}\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\nexport interface BackendPluginConfig {\n /**\n * The ID of this plugin.\n *\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\n pluginId: string;\n register(reg: BackendPluginRegistrationPoints): void;\n}\n\n/**\n * Creates a new backend plugin.\n *\n * @public\n * @see {@link https://backstage.io/docs/backend-system/architecture/plugins | The architecture of plugins}\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\nexport function createBackendPlugin<TOptions extends [options?: object] = []>(\n config: BackendPluginConfig | ((...params: TOptions) => BackendPluginConfig),\n): (...params: TOptions) => BackendFeature {\n if (typeof config === 'function') {\n return (...options: TOptions) => {\n const c = config(...options);\n return {\n ...c,\n id: c.pluginId,\n };\n };\n }\n return () => ({\n ...config,\n id: config.pluginId,\n });\n}\n\n/**\n * The configuration options passed to {@link createBackendModule}.\n *\n * @public\n * @see {@link https://backstage.io/docs/backend-system/architecture/modules | The architecture of modules}\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\nexport interface BackendModuleConfig {\n /**\n * The ID of this plugin.\n *\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\n pluginId: string;\n /**\n * Should exactly match the `id` of the plugin that the module extends.\n */\n moduleId: string;\n register(reg: BackendModuleRegistrationPoints): void;\n}\n\n/**\n * Creates a new backend module for a given plugin.\n *\n * @public\n * @see {@link https://backstage.io/docs/backend-system/architecture/modules | The architecture of modules}\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\nexport function createBackendModule<TOptions extends [options?: object] = []>(\n config: BackendModuleConfig | ((...params: TOptions) => BackendModuleConfig),\n): (...params: TOptions) => BackendFeature {\n if (typeof config === 'function') {\n return (...options: TOptions) => {\n const c = config(...options);\n return {\n id: `${c.pluginId}.${c.moduleId}`,\n register: c.register,\n };\n };\n }\n return () => ({\n id: `${config.pluginId}.${config.moduleId}`,\n register(register: BackendRegistrationPoints) {\n return config.register({\n registerInit: register.registerInit.bind(register),\n });\n },\n });\n}\n"],"names":["coreServices"],"mappings":";;;;AA4GO,SAAS,iBACd,MAC2B,EAAA;AAC3B,EAAA,MAAM,EAAE,EAAA,EAAI,KAAQ,GAAA,QAAA,EAAU,gBAAmB,GAAA,MAAA,CAAA;AACjD,EAAO,OAAA;AAAA,IACL,EAAA;AAAA,IACA,KAAA;AAAA,IACA,IAAI,CAAc,GAAA;AAChB,MAAM,MAAA,IAAI,KAAM,CAAA,CAAA,8BAAA,EAAiC,IAAM,CAAA,CAAA,CAAA,CAAA;AAAA,KACzD;AAAA,IACA,QAAW,GAAA;AACT,MAAA,OAAO,cAAc,MAAO,CAAA,EAAA,CAAA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AAA,CAAA,EAAG,CAAE,CAAA,QAAA,CAAA,CAAA,EAAY,CAAE,CAAA,QAAA,CAAA,CAAA;AAAA,QACvB,UAAU,CAAE,CAAA,QAAA;AAAA,OACd,CAAA;AAAA,KACF,CAAA;AAAA,GACF;AACA,EAAA,OAAO,OAAO;AAAA,IACZ,EAAI,EAAA,CAAA,EAAG,MAAO,CAAA,QAAA,CAAA,CAAA,EAAY,MAAO,CAAA,QAAA,CAAA,CAAA;AAAA,IACjC,SAAS,QAAqC,EAAA;AAC5C,MAAA,OAAO,OAAO,QAAS,CAAA;AAAA,QACrB,YAAc,EAAA,QAAA,CAAS,YAAa,CAAA,IAAA,CAAK,QAAQ,CAAA;AAAA,OAClD,CAAA,CAAA;AAAA,KACH;AAAA,GACF,CAAA,CAAA;AACF;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/services/system/types.ts","../src/services/definitions/coreServices.ts","../src/wiring/createSharedEnvironment.ts","../src/wiring/factories.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * TODO\n *\n * @public\n */\nexport type ServiceRef<\n TService,\n TScope extends 'root' | 'plugin' = 'root' | 'plugin',\n> = {\n id: string;\n\n /**\n * This determines the scope at which this service is available.\n *\n * Root scoped services are available to all other services but\n * may only depend on other root scoped services.\n *\n * Plugin scoped services are only available to other plugin scoped\n * services but may depend on all other services.\n */\n scope: TScope;\n\n /**\n * Utility for getting the type of the service, using `typeof serviceRef.T`.\n * Attempting to actually read this value will result in an exception.\n */\n T: TService;\n\n toString(): string;\n\n $$type: '@backstage/ServiceRef';\n};\n\n/** @public */\nexport interface ServiceFactory<\n TService = unknown,\n TScope extends 'plugin' | 'root' = 'plugin' | 'root',\n> {\n $$type: '@backstage/ServiceFactory';\n\n service: ServiceRef<TService, TScope>;\n}\n\n/** @internal */\nexport interface InternalServiceFactory<\n TService = unknown,\n TScope extends 'plugin' | 'root' = 'plugin' | 'root',\n> extends ServiceFactory<TService, TScope> {\n version: 'v1';\n deps: { [key in string]: ServiceRef<unknown> };\n createRootContext?(deps: { [key in string]: unknown }): Promise<unknown>;\n factory(\n deps: { [key in string]: unknown },\n context: unknown,\n ): Promise<TService>;\n}\n\n/**\n * Represents either a {@link ServiceFactory} or a function that returns one.\n *\n * @public\n */\nexport type ServiceFactoryOrFunction = ServiceFactory | (() => ServiceFactory);\n\n/** @public */\nexport interface ServiceRefConfig<TService, TScope extends 'root' | 'plugin'> {\n id: string;\n scope?: TScope;\n defaultFactory?: (\n service: ServiceRef<TService, TScope>,\n ) => Promise<ServiceFactoryOrFunction>;\n}\n\n/**\n * Creates a new service definition. This overload is used to create plugin scoped services.\n *\n * @public\n */\nexport function createServiceRef<TService>(\n config: ServiceRefConfig<TService, 'plugin'>,\n): ServiceRef<TService, 'plugin'>;\n\n/**\n * Creates a new service definition. This overload is used to create root scoped services.\n *\n * @public\n */\nexport function createServiceRef<TService>(\n config: ServiceRefConfig<TService, 'root'>,\n): ServiceRef<TService, 'root'>;\nexport function createServiceRef<TService>(\n config: ServiceRefConfig<TService, any>,\n): ServiceRef<TService, any> {\n const { id, scope = 'plugin', defaultFactory } = config;\n return {\n id,\n scope,\n get T(): TService {\n throw new Error(`tried to read ServiceRef.T of ${this}`);\n },\n toString() {\n return `serviceRef{${config.id}}`;\n },\n $$type: '@backstage/ServiceRef',\n __defaultFactory: defaultFactory,\n } as ServiceRef<TService, typeof scope> & {\n __defaultFactory?: (\n service: ServiceRef<TService>,\n ) => Promise<ServiceFactory<TService> | (() => ServiceFactory<TService>)>;\n };\n}\n\n/** @ignore */\ntype ServiceRefsToInstances<\n T extends { [key in string]: ServiceRef<unknown> },\n TScope extends 'root' | 'plugin' = 'root' | 'plugin',\n> = {\n [key in keyof T as T[key]['scope'] extends TScope ? key : never]: T[key]['T'];\n};\n\n/** @public */\nexport interface RootServiceFactoryConfig<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n> {\n service: ServiceRef<TService, 'root'>;\n deps: TDeps;\n factory(deps: ServiceRefsToInstances<TDeps, 'root'>): TImpl | Promise<TImpl>;\n}\n\n/** @public */\nexport interface PluginServiceFactoryConfig<\n TService,\n TContext,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n> {\n service: ServiceRef<TService, 'plugin'>;\n deps: TDeps;\n createRootContext?(\n deps: ServiceRefsToInstances<TDeps, 'root'>,\n ): TContext | Promise<TContext>;\n factory(\n deps: ServiceRefsToInstances<TDeps>,\n context: TContext,\n ): TImpl | Promise<TImpl>;\n}\n\n/**\n * Creates a root scoped service factory without options.\n *\n * @public\n * @param config - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TOpts extends object | undefined = undefined,\n>(\n config: RootServiceFactoryConfig<TService, TImpl, TDeps>,\n): () => ServiceFactory<TService, 'root'>;\n/**\n * Creates a root scoped service factory with optional options.\n *\n * @public\n * @param config - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TOpts extends object | undefined = undefined,\n>(\n config: (options?: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>,\n): (options?: TOpts) => ServiceFactory<TService, 'root'>;\n/**\n * Creates a root scoped service factory with required options.\n *\n * @public\n * @param config - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TOpts extends object | undefined = undefined,\n>(\n config: (options: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>,\n): (options: TOpts) => ServiceFactory<TService, 'root'>;\n/**\n * Creates a plugin scoped service factory without options.\n *\n * @public\n * @param config - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TContext = undefined,\n TOpts extends object | undefined = undefined,\n>(\n config: PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>,\n): () => ServiceFactory<TService, 'plugin'>;\n/**\n * Creates a plugin scoped service factory with optional options.\n *\n * @public\n * @param config - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TContext = undefined,\n TOpts extends object | undefined = undefined,\n>(\n config: (\n options?: TOpts,\n ) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>,\n): (options?: TOpts) => ServiceFactory<TService, 'plugin'>;\n/**\n * Creates a plugin scoped service factory with required options.\n *\n * @public\n * @param config - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TContext = undefined,\n TOpts extends object | undefined = undefined,\n>(\n config:\n | PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>\n | ((\n options: TOpts,\n ) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>),\n): (options: TOpts) => ServiceFactory<TService, 'plugin'>;\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TContext,\n TOpts extends object | undefined = undefined,\n>(\n config:\n | RootServiceFactoryConfig<TService, TImpl, TDeps>\n | PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>\n | ((options: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>)\n | ((\n options: TOpts,\n ) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>)\n | (() => RootServiceFactoryConfig<TService, TImpl, TDeps>)\n | (() => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>),\n): (options: TOpts) => ServiceFactory {\n const configCallback = typeof config === 'function' ? config : () => config;\n return (\n options: TOpts,\n ): InternalServiceFactory<TService, 'plugin' | 'root'> => {\n const anyConf = configCallback(options);\n if (anyConf.service.scope === 'root') {\n const c = anyConf as RootServiceFactoryConfig<TService, TImpl, TDeps>;\n return {\n $$type: '@backstage/ServiceFactory',\n version: 'v1',\n service: c.service,\n deps: c.deps,\n factory: async (deps: TDeps) => c.factory(deps),\n };\n }\n const c = anyConf as PluginServiceFactoryConfig<\n TService,\n TContext,\n TImpl,\n TDeps\n >;\n return {\n $$type: '@backstage/ServiceFactory',\n version: 'v1',\n service: c.service,\n ...('createRootContext' in c\n ? {\n createRootContext: async (deps: TDeps) =>\n c?.createRootContext?.(deps),\n }\n : {}),\n deps: c.deps,\n factory: async (deps: TDeps, ctx: TContext) => c.factory(deps, ctx),\n };\n };\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system';\n\n/**\n * All core services references\n *\n * @public\n */\nexport namespace coreServices {\n /**\n * The service reference for the plugin scoped {@link CacheService}.\n *\n * @public\n */\n export const cache = createServiceRef<import('./CacheService').CacheService>({\n id: 'core.cache',\n });\n\n /**\n * The service reference for the root scoped {@link ConfigService}.\n *\n * @public\n */\n export const config = createServiceRef<\n import('./ConfigService').ConfigService\n >({ id: 'core.config', scope: 'root' });\n\n /**\n * The service reference for the plugin scoped {@link DatabaseService}.\n *\n * @public\n */\n export const database = createServiceRef<\n import('./DatabaseService').DatabaseService\n >({ id: 'core.database' });\n\n /**\n * The service reference for the plugin scoped {@link DiscoveryService}.\n *\n * @public\n */\n export const discovery = createServiceRef<\n import('./DiscoveryService').DiscoveryService\n >({ id: 'core.discovery' });\n\n /**\n * The service reference for the plugin scoped {@link HttpRouterService}.\n *\n * @public\n */\n export const httpRouter = createServiceRef<\n import('./HttpRouterService').HttpRouterService\n >({ id: 'core.httpRouter' });\n\n /**\n * The service reference for the plugin scoped {@link LifecycleService}.\n *\n * @public\n */\n export const lifecycle = createServiceRef<\n import('./LifecycleService').LifecycleService\n >({ id: 'core.lifecycle' });\n\n /**\n * The service reference for the plugin scoped {@link LoggerService}.\n *\n * @public\n */\n export const logger = createServiceRef<\n import('./LoggerService').LoggerService\n >({ id: 'core.logger' });\n\n /**\n * The service reference for the plugin scoped {@link PermissionsService}.\n *\n * @public\n */\n export const permissions = createServiceRef<\n import('./PermissionsService').PermissionsService\n >({ id: 'core.permissions' });\n\n /**\n * The service reference for the plugin scoped {@link PluginMetadataService}.\n *\n * @public\n */\n export const pluginMetadata = createServiceRef<\n import('./PluginMetadataService').PluginMetadataService\n >({ id: 'core.pluginMetadata' });\n\n /**\n * The service reference for the root scoped {@link RootHttpRouterService}.\n *\n * @public\n */\n export const rootHttpRouter = createServiceRef<\n import('./RootHttpRouterService').RootHttpRouterService\n >({ id: 'core.rootHttpRouter', scope: 'root' });\n\n /**\n * The service reference for the root scoped {@link RootLifecycleService}.\n *\n * @public\n */\n export const rootLifecycle = createServiceRef<\n import('./RootLifecycleService').RootLifecycleService\n >({ id: 'core.rootLifecycle', scope: 'root' });\n\n /**\n * The service reference for the root scoped {@link RootLoggerService}.\n *\n * @public\n */\n export const rootLogger = createServiceRef<\n import('./RootLoggerService').RootLoggerService\n >({ id: 'core.rootLogger', scope: 'root' });\n\n /**\n * The service reference for the plugin scoped {@link SchedulerService}.\n *\n * @public\n */\n export const scheduler = createServiceRef<\n import('./SchedulerService').SchedulerService\n >({ id: 'core.scheduler' });\n\n /**\n * The service reference for the plugin scoped {@link TokenManagerService}.\n *\n * @public\n */\n export const tokenManager = createServiceRef<\n import('./TokenManagerService').TokenManagerService\n >({ id: 'core.tokenManager' });\n\n /**\n * The service reference for the plugin scoped {@link UrlReaderService}.\n *\n * @public\n */\n export const urlReader = createServiceRef<\n import('./UrlReaderService').UrlReaderService\n >({ id: 'core.urlReader' });\n\n /**\n * The service reference for the plugin scoped {@link IdentityService}.\n *\n * @public\n */\n export const identity = createServiceRef<\n import('./IdentityService').IdentityService\n >({ id: 'core.identity' });\n}\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ServiceFactory, ServiceFactoryOrFunction } from '../services';\n\n/**\n * The configuration options passed to {@link createSharedEnvironment}.\n *\n * @public\n */\nexport interface SharedBackendEnvironmentConfig {\n services?: ServiceFactoryOrFunction[];\n}\n\n/**\n * An opaque type that represents the contents of a shared backend environment.\n *\n * @public\n */\nexport interface SharedBackendEnvironment {\n $$type: '@backstage/SharedBackendEnvironment';\n\n // NOTE: This type is opaque in order to allow for future API evolution without\n // cluttering the external API. For example we might want to add support\n // for more powerful callback based backend modifications.\n //\n // By making this opaque we also ensure that the type doesn't become an input\n // type that we need to care about, as it would otherwise be possible to pass\n // a custom environment definition to `createBackend`, which we don't want.\n}\n\n/**\n * This type is NOT supposed to be used by anyone except internally by the\n * backend-app-api package.\n *\n * @internal\n */\nexport interface InternalSharedBackendEnvironment {\n version: 'v1';\n services?: ServiceFactory[];\n}\n\n/**\n * Creates a shared backend environment which can be used to create multiple\n * backends.\n *\n * @public\n */\nexport function createSharedEnvironment<\n TOptions extends [options?: object] = [],\n>(\n config:\n | SharedBackendEnvironmentConfig\n | ((...params: TOptions) => SharedBackendEnvironmentConfig),\n): (...options: TOptions) => SharedBackendEnvironment {\n const configCallback = typeof config === 'function' ? config : () => config;\n\n return (...options) => {\n const actualConfig = configCallback(...options);\n const services = actualConfig?.services?.map(sf =>\n typeof sf === 'function' ? sf() : sf,\n );\n\n const exists = new Set<string>();\n const duplicates = new Set<string>();\n for (const { service } of services ?? []) {\n if (exists.has(service.id)) {\n duplicates.add(service.id);\n } else {\n exists.add(service.id);\n }\n }\n\n if (duplicates.size > 0) {\n const dupStr = [...duplicates].map(id => `'${id}'`).join(', ');\n throw new Error(\n `Duplicate service implementations provided in shared environment for ${dupStr}`,\n );\n }\n\n // Here to ensure type safety in this internal implementation.\n const env: SharedBackendEnvironment & InternalSharedBackendEnvironment = {\n $$type: '@backstage/SharedBackendEnvironment',\n version: 'v1',\n services,\n };\n return env;\n };\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n BackendModuleRegistrationPoints,\n BackendPluginRegistrationPoints,\n BackendFeature,\n ExtensionPoint,\n InternalBackendFeature,\n InternalBackendModuleRegistration,\n InternalBackendPluginRegistration,\n} from './types';\n\n/**\n * The configuration options passed to {@link createExtensionPoint}.\n *\n * @public\n * @see {@link https://backstage.io/docs/backend-system/architecture/extension-points | The architecture of extension points}\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\nexport interface ExtensionPointConfig {\n /**\n * The ID of this extension point.\n *\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\n id: string;\n}\n\n/**\n * Creates a new backend extension point.\n *\n * @public\n * @see {@link https://backstage.io/docs/backend-system/architecture/extension-points | The architecture of extension points}\n */\nexport function createExtensionPoint<T>(\n config: ExtensionPointConfig,\n): ExtensionPoint<T> {\n return {\n id: config.id,\n get T(): T {\n throw new Error(`tried to read ExtensionPoint.T of ${this}`);\n },\n toString() {\n return `extensionPoint{${config.id}}`;\n },\n $$type: '@backstage/ExtensionPoint',\n };\n}\n\n/**\n * The configuration options passed to {@link createBackendPlugin}.\n *\n * @public\n * @see {@link https://backstage.io/docs/backend-system/architecture/plugins | The architecture of plugins}\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\nexport interface BackendPluginConfig {\n /**\n * The ID of this plugin.\n *\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\n pluginId: string;\n register(reg: BackendPluginRegistrationPoints): void;\n}\n\n/**\n * Creates a new backend plugin.\n *\n * @public\n * @see {@link https://backstage.io/docs/backend-system/architecture/plugins | The architecture of plugins}\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\nexport function createBackendPlugin<TOptions extends [options?: object] = []>(\n config: BackendPluginConfig | ((...params: TOptions) => BackendPluginConfig),\n): (...params: TOptions) => BackendFeature {\n const configCallback = typeof config === 'function' ? config : () => config;\n return (...options: TOptions): InternalBackendFeature => {\n const c = configCallback(...options);\n\n let registrations: InternalBackendPluginRegistration[];\n\n return {\n $$type: '@backstage/BackendFeature',\n version: 'v1',\n getRegistrations() {\n if (registrations) {\n return registrations;\n }\n const extensionPoints: InternalBackendPluginRegistration['extensionPoints'] =\n [];\n let init: InternalBackendPluginRegistration['init'] | undefined =\n undefined;\n\n c.register({\n registerExtensionPoint(ext, impl) {\n if (init) {\n throw new Error(\n 'registerExtensionPoint called after registerInit',\n );\n }\n extensionPoints.push([ext, impl]);\n },\n registerInit(regInit) {\n if (init) {\n throw new Error('registerInit must only be called once');\n }\n init = {\n deps: regInit.deps,\n func: regInit.init,\n };\n },\n });\n\n if (!init) {\n throw new Error(\n `registerInit was not called by register in ${c.pluginId}`,\n );\n }\n\n registrations = [\n {\n type: 'plugin',\n pluginId: c.pluginId,\n extensionPoints,\n init,\n },\n ];\n return registrations;\n },\n };\n };\n}\n\n/**\n * The configuration options passed to {@link createBackendModule}.\n *\n * @public\n * @see {@link https://backstage.io/docs/backend-system/architecture/modules | The architecture of modules}\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\nexport interface BackendModuleConfig {\n /**\n * The ID of this plugin.\n *\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\n pluginId: string;\n /**\n * Should exactly match the `id` of the plugin that the module extends.\n */\n moduleId: string;\n register(reg: BackendModuleRegistrationPoints): void;\n}\n\n/**\n * Creates a new backend module for a given plugin.\n *\n * @public\n * @see {@link https://backstage.io/docs/backend-system/architecture/modules | The architecture of modules}\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\nexport function createBackendModule<TOptions extends [options?: object] = []>(\n config: BackendModuleConfig | ((...params: TOptions) => BackendModuleConfig),\n): (...params: TOptions) => BackendFeature {\n const configCallback = typeof config === 'function' ? config : () => config;\n return (...options: TOptions): InternalBackendFeature => {\n const c = configCallback(...options);\n\n let registrations: InternalBackendModuleRegistration[];\n\n return {\n $$type: '@backstage/BackendFeature',\n version: 'v1',\n getRegistrations() {\n if (registrations) {\n return registrations;\n }\n let init: InternalBackendModuleRegistration['init'] | undefined =\n undefined;\n\n c.register({\n registerInit(regInit) {\n if (init) {\n throw new Error('registerInit must only be called once');\n }\n init = {\n deps: regInit.deps,\n func: regInit.init,\n };\n },\n });\n\n if (!init) {\n throw new Error(\n `registerInit was not called by register in ${c.moduleId} module for ${c.pluginId}`,\n );\n }\n\n registrations = [\n {\n type: 'module',\n pluginId: c.pluginId,\n moduleId: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ACF;AAAA,SACD,CAAA,CAAA;AAED,QAAA,IAAI,CAAC,IAAM,EAAA;AACT,UAAA,MAAM,IAAI,KAAA;AAAA,YACR,CAAA,2CAAA,EAA8C,CAAE,CAAA,QAAA,CAAA,YAAA,EAAuB,CAAE,CAAA,QAAA,CAAA,CAAA;AAAA,WAC3E,CAAA;AAAA,SACF;AAEA,QAAgB,aAAA,GAAA;AAAA,UACd;AAAA,YACE,IAAM,EAAA,QAAA;AAAA,YACN,UAAU,CAAE,CAAA,QAAA;AAAA,YACZ,UAAU,CAAE,CAAA,QAAA;AAAA,YACZ,IAAA;AAAA,WACF;AAAA,SACF,CAAA;AACA,QAAO,OAAA,aAAA,CAAA;AAAA,OACT;AAAA,KACF,CAAA;AAAA,GACF,CAAA;AACF;;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@
9
9
  import { Config } from '@backstage/config';
10
10
  import { Handler } from 'express';
11
11
  import { IdentityApi } from '@backstage/plugin-auth-node';
12
+ import { JsonObject } from '@backstage/types';
12
13
  import { JsonValue } from '@backstage/types';
13
14
  import { Knex } from 'knex';
14
15
  import { PermissionEvaluator } from '@backstage/plugin-permission-common';
@@ -17,8 +18,7 @@ import { Readable } from 'stream';
17
18
 
18
19
  /** @public */
19
20
  export declare interface BackendFeature {
20
- id: string;
21
- register(reg: BackendRegistrationPoints): void;
21
+ $$type: '@backstage/BackendFeature';
22
22
  }
23
23
 
24
24
  /**
@@ -92,25 +92,6 @@ export declare interface BackendPluginRegistrationPoints {
92
92
  }): void;
93
93
  }
94
94
 
95
- /**
96
- * The callbacks passed to the `register` method of a backend feature; this is
97
- * essentially a superset of {@link BackendPluginRegistrationPoints} and
98
- * {@link BackendModuleRegistrationPoints}.
99
- *
100
- * @public
101
- */
102
- export declare interface BackendRegistrationPoints {
103
- registerExtensionPoint<TExtensionPoint>(ref: ExtensionPoint<TExtensionPoint>, impl: TExtensionPoint): void;
104
- registerInit<Deps extends {
105
- [name in string]: unknown;
106
- }>(options: {
107
- deps: {
108
- [name in keyof Deps]: ServiceRef<Deps[name]> | ExtensionPoint<Deps[name]>;
109
- };
110
- init(deps: Deps): Promise<void>;
111
- }): void;
112
- }
113
-
114
95
  /**
115
96
  * A pre-configured, storage agnostic cache client suitable for use by
116
97
  * Backstage plugins.
@@ -324,7 +305,7 @@ export declare function createExtensionPoint<T>(config: ExtensionPointConfig): E
324
305
  */
325
306
  export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
326
307
  [name in string]: ServiceRef<unknown>;
327
- }, TOpts extends object | undefined = undefined>(config: RootServiceFactoryConfig<TService, TImpl, TDeps>): () => ServiceFactory<TService>;
308
+ }, TOpts extends object | undefined = undefined>(config: RootServiceFactoryConfig<TService, TImpl, TDeps>): () => ServiceFactory<TService, 'root'>;
328
309
 
329
310
  /**
330
311
  * Creates a root scoped service factory with optional options.
@@ -334,7 +315,7 @@ export declare function createServiceFactory<TService, TImpl extends TService, T
334
315
  */
335
316
  export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
336
317
  [name in string]: ServiceRef<unknown>;
337
- }, TOpts extends object | undefined = undefined>(config: (options?: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>): (options?: TOpts) => ServiceFactory<TService>;
318
+ }, TOpts extends object | undefined = undefined>(config: (options?: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>): (options?: TOpts) => ServiceFactory<TService, 'root'>;
338
319
 
339
320
  /**
340
321
  * Creates a root scoped service factory with required options.
@@ -344,7 +325,7 @@ export declare function createServiceFactory<TService, TImpl extends TService, T
344
325
  */
345
326
  export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
346
327
  [name in string]: ServiceRef<unknown>;
347
- }, TOpts extends object | undefined = undefined>(config: (options: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>): (options: TOpts) => ServiceFactory<TService>;
328
+ }, TOpts extends object | undefined = undefined>(config: (options: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>): (options: TOpts) => ServiceFactory<TService, 'root'>;
348
329
 
349
330
  /**
350
331
  * Creates a plugin scoped service factory without options.
@@ -354,7 +335,7 @@ export declare function createServiceFactory<TService, TImpl extends TService, T
354
335
  */
355
336
  export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
356
337
  [name in string]: ServiceRef<unknown>;
357
- }, TContext = undefined, TOpts extends object | undefined = undefined>(config: PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>): () => ServiceFactory<TService>;
338
+ }, TContext = undefined, TOpts extends object | undefined = undefined>(config: PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>): () => ServiceFactory<TService, 'plugin'>;
358
339
 
359
340
  /**
360
341
  * Creates a plugin scoped service factory with optional options.
@@ -364,7 +345,7 @@ export declare function createServiceFactory<TService, TImpl extends TService, T
364
345
  */
365
346
  export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
366
347
  [name in string]: ServiceRef<unknown>;
367
- }, TContext = undefined, TOpts extends object | undefined = undefined>(config: (options?: TOpts) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>): (options?: TOpts) => ServiceFactory<TService>;
348
+ }, TContext = undefined, TOpts extends object | undefined = undefined>(config: (options?: TOpts) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>): (options?: TOpts) => ServiceFactory<TService, 'plugin'>;
368
349
 
369
350
  /**
370
351
  * Creates a plugin scoped service factory with required options.
@@ -374,7 +355,7 @@ export declare function createServiceFactory<TService, TImpl extends TService, T
374
355
  */
375
356
  export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
376
357
  [name in string]: ServiceRef<unknown>;
377
- }, TContext = undefined, TOpts extends object | undefined = undefined>(config: PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps> | ((options: TOpts) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>)): (options: TOpts) => ServiceFactory<TService>;
358
+ }, TContext = undefined, TOpts extends object | undefined = undefined>(config: PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps> | ((options: TOpts) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>)): (options: TOpts) => ServiceFactory<TService, 'plugin'>;
378
359
 
379
360
  /**
380
361
  * Creates a new service definition. This overload is used to create plugin scoped services.
@@ -545,20 +526,13 @@ export declare interface LifecycleServiceShutdownOptions {
545
526
  * @public
546
527
  */
547
528
  export declare interface LoggerService {
548
- error(message: string, meta?: Error | LogMeta): void;
549
- warn(message: string, meta?: Error | LogMeta): void;
550
- info(message: string, meta?: Error | LogMeta): void;
551
- debug(message: string, meta?: Error | LogMeta): void;
552
- child(meta: LogMeta): LoggerService;
529
+ error(message: string, meta?: Error | JsonObject): void;
530
+ warn(message: string, meta?: Error | JsonObject): void;
531
+ info(message: string, meta?: Error | JsonObject): void;
532
+ debug(message: string, meta?: Error | JsonObject): void;
533
+ child(meta: JsonObject): LoggerService;
553
534
  }
554
535
 
555
- /**
556
- * @public
557
- */
558
- export declare type LogMeta = {
559
- [name: string]: unknown;
560
- };
561
-
562
536
  /** @public */
563
537
  export declare interface PermissionsService extends PermissionEvaluator {
564
538
  }
@@ -846,35 +820,17 @@ export declare type SearchResponseFile = {
846
820
  };
847
821
 
848
822
  /** @public */
849
- export declare type ServiceFactory<TService = unknown> = {
850
- scope: 'root';
851
- service: ServiceRef<TService, 'root'>;
852
- deps: {
853
- [key in string]: ServiceRef<unknown>;
854
- };
855
- factory(deps: {
856
- [key in string]: unknown;
857
- }): Promise<TService>;
858
- } | {
859
- scope: 'plugin';
860
- service: ServiceRef<TService, 'plugin'>;
861
- deps: {
862
- [key in string]: ServiceRef<unknown>;
863
- };
864
- createRootContext?(deps: {
865
- [key in string]: unknown;
866
- }): Promise<unknown>;
867
- factory(deps: {
868
- [key in string]: unknown;
869
- }, context: unknown): Promise<TService>;
870
- };
823
+ export declare interface ServiceFactory<TService = unknown, TScope extends 'plugin' | 'root' = 'plugin' | 'root'> {
824
+ $$type: '@backstage/ServiceFactory';
825
+ service: ServiceRef<TService, TScope>;
826
+ }
871
827
 
872
828
  /**
873
829
  * Represents either a {@link ServiceFactory} or a function that returns one.
874
830
  *
875
831
  * @public
876
832
  */
877
- export declare type ServiceFactoryOrFunction<TService = unknown> = ServiceFactory<TService> | (() => ServiceFactory<TService>);
833
+ export declare type ServiceFactoryOrFunction = ServiceFactory | (() => ServiceFactory);
878
834
 
879
835
  /**
880
836
  * TODO
@@ -906,7 +862,7 @@ export declare type ServiceRef<TService, TScope extends 'root' | 'plugin' = 'roo
906
862
  export declare interface ServiceRefConfig<TService, TScope extends 'root' | 'plugin'> {
907
863
  id: string;
908
864
  scope?: TScope;
909
- defaultFactory?: (service: ServiceRef<TService, TScope>) => Promise<ServiceFactoryOrFunction<TService>>;
865
+ defaultFactory?: (service: ServiceRef<TService, TScope>) => Promise<ServiceFactoryOrFunction>;
910
866
  }
911
867
 
912
868
  /** @ignore */
@@ -959,11 +915,6 @@ export declare interface TokenManagerService {
959
915
  authenticate(token: string): Promise<void>;
960
916
  }
961
917
 
962
- /** @public */
963
- export declare type TypesToServiceRef<T> = {
964
- [key in keyof T]: ServiceRef<T[key]>;
965
- };
966
-
967
918
  /**
968
919
  * A generic interface for fetching plain data from URLs.
969
920
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@backstage/backend-plugin-api",
3
3
  "description": "Core API used by Backstage backend plugins",
4
- "version": "0.0.0-nightly-20230207022622",
4
+ "version": "0.0.0-nightly-20230209023017",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "publishConfig": {
@@ -33,9 +33,9 @@
33
33
  "start": "backstage-cli package start"
34
34
  },
35
35
  "dependencies": {
36
- "@backstage/backend-tasks": "^0.0.0-nightly-20230207022622",
36
+ "@backstage/backend-tasks": "^0.0.0-nightly-20230209023017",
37
37
  "@backstage/config": "^1.0.6",
38
- "@backstage/plugin-auth-node": "^0.0.0-nightly-20230207022622",
38
+ "@backstage/plugin-auth-node": "^0.0.0-nightly-20230209023017",
39
39
  "@backstage/plugin-permission-common": "^0.7.3",
40
40
  "@backstage/types": "^1.0.2",
41
41
  "@types/express": "^4.17.6",
@@ -43,7 +43,7 @@
43
43
  "knex": "^2.0.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@backstage/cli": "^0.0.0-nightly-20230207022622"
46
+ "@backstage/cli": "^0.0.0-nightly-20230209023017"
47
47
  },
48
48
  "files": [
49
49
  "dist",