@backstage/backend-plugin-api 0.0.0-nightly-20230112022659 → 0.0.0-nightly-20230114022133

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,10 +1,11 @@
1
1
  # @backstage/backend-plugin-api
2
2
 
3
- ## 0.0.0-nightly-20230112022659
3
+ ## 0.0.0-nightly-20230114022133
4
4
 
5
5
  ### Minor Changes
6
6
 
7
7
  - 8e06f3cf00: Moved `loggerToWinstonLogger` to `@backstage/backend-common`.
8
+ - ecbec4ec4c: Updated all factory function creators to accept options as a top-level callback rather than extra parameter to the main factory function.
8
9
 
9
10
  ### Patch Changes
10
11
 
@@ -18,11 +19,11 @@
18
19
  - 16054afdec: Documented `coreServices` an all of its members.
19
20
  - 62b04bb865: Updates all `create*` methods to simplify their type definitions and ensure they all have configuration interfaces.
20
21
  - Updated dependencies
21
- - @backstage/backend-tasks@0.0.0-nightly-20230112022659
22
- - @backstage/config@0.0.0-nightly-20230112022659
22
+ - @backstage/backend-tasks@0.0.0-nightly-20230114022133
23
+ - @backstage/config@0.0.0-nightly-20230114022133
23
24
  - @backstage/types@1.0.2
24
- - @backstage/plugin-auth-node@0.0.0-nightly-20230112022659
25
- - @backstage/plugin-permission-common@0.0.0-nightly-20230112022659
25
+ - @backstage/plugin-auth-node@0.0.0-nightly-20230114022133
26
+ - @backstage/plugin-permission-common@0.0.0-nightly-20230114022133
26
27
 
27
28
  ## 0.3.0-next.1
28
29
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/backend-plugin-api",
3
- "version": "0.0.0-nightly-20230112022659",
3
+ "version": "0.0.0-nightly-20230114022133",
4
4
  "main": "../dist/index.cjs.js",
5
5
  "types": "../dist/index.alpha.d.ts"
6
6
  }
@@ -22,16 +22,16 @@ export declare interface BackendFeature {
22
22
  }
23
23
 
24
24
  /** @public */
25
- export declare interface BackendModuleConfig<TOptions> {
25
+ export declare interface BackendModuleConfig {
26
26
  pluginId: string;
27
27
  moduleId: string;
28
- register(reg: Omit<BackendRegistrationPoints, 'registerExtensionPoint'>, options: TOptions): void;
28
+ register(reg: Omit<BackendRegistrationPoints, 'registerExtensionPoint'>): void;
29
29
  }
30
30
 
31
31
  /** @public */
32
- export declare interface BackendPluginConfig<TOptions> {
32
+ export declare interface BackendPluginConfig {
33
33
  id: string;
34
- register(reg: BackendRegistrationPoints, options: TOptions): void;
34
+ register(reg: BackendRegistrationPoints): void;
35
35
  }
36
36
 
37
37
  /** @public */
@@ -240,10 +240,10 @@ export declare namespace coreServices {
240
240
  *
241
241
  * The `pluginId` should exactly match the `id` of the plugin that the module extends.
242
242
  */
243
- export declare function createBackendModule<TOptions extends MaybeOptions = undefined>(config: BackendModuleConfig<TOptions>): FactoryFunctionWithOptions<BackendFeature, TOptions>;
243
+ export declare function createBackendModule<TOptions extends [options?: object] = []>(config: BackendModuleConfig | ((...params: TOptions) => BackendModuleConfig)): (...params: TOptions) => BackendFeature;
244
244
 
245
245
  /** @public */
246
- export declare function createBackendPlugin<TOptions extends MaybeOptions = undefined>(config: BackendPluginConfig<TOptions>): FactoryFunctionWithOptions<BackendFeature, TOptions>;
246
+ export declare function createBackendPlugin<TOptions extends [options?: object] = []>(config: BackendPluginConfig | ((...params: TOptions) => BackendPluginConfig)): (...params: TOptions) => BackendFeature;
247
247
 
248
248
  /** @public */
249
249
  export declare function createExtensionPoint<T>(config: ExtensionPointConfig): ExtensionPoint<T>;
@@ -253,7 +253,7 @@ export declare function createExtensionPoint<T>(config: ExtensionPointConfig): E
253
253
  */
254
254
  export declare function createServiceFactory<TService, TScope extends 'root' | 'plugin', TImpl extends TService, TDeps extends {
255
255
  [name in string]: ServiceRef<unknown>;
256
- }, TOpts extends MaybeOptions = undefined>(config: ServiceFactoryConfig<TService, TScope, TImpl, TDeps, TOpts>): FactoryFunctionWithOptions<ServiceFactory<TService>, TOpts>;
256
+ }, TOpts extends [options?: object] = []>(config: ServiceFactoryConfig<TService, TScope, TImpl, TDeps> | ((...options: TOpts) => ServiceFactoryConfig<TService, TScope, TImpl, TDeps>)): (...params: TOpts) => ServiceFactory<TService>;
257
257
 
258
258
  /**
259
259
  * Creates a new service definition. This overload is used to create plugin scoped services.
@@ -363,13 +363,6 @@ export declare interface ExtensionPointConfig {
363
363
  id: string;
364
364
  }
365
365
 
366
- /**
367
- * Helper type that makes the options argument optional if options are not required.
368
- *
369
- * @ignore
370
- */
371
- declare type FactoryFunctionWithOptions<TResult, TOptions> = undefined extends TOptions ? (options?: TOptions) => TResult : (options: TOptions) => TResult;
372
-
373
366
  /**
374
367
  * @public
375
368
  */
@@ -422,13 +415,6 @@ export declare type LogMeta = {
422
415
  [name: string]: unknown;
423
416
  };
424
417
 
425
- /**
426
- * Base type for options objects that aren't required.
427
- *
428
- * @ignore
429
- */
430
- declare type MaybeOptions = object | undefined;
431
-
432
418
  /** @public */
433
419
  export declare interface PermissionsService extends PermissionEvaluator {
434
420
  }
@@ -722,10 +708,10 @@ export declare type ServiceFactory<TService = unknown> = {
722
708
  /** @public */
723
709
  export declare interface ServiceFactoryConfig<TService, TScope extends 'root' | 'plugin', TImpl extends TService, TDeps extends {
724
710
  [name in string]: ServiceRef<unknown>;
725
- }, TOpts extends MaybeOptions = undefined> {
711
+ }> {
726
712
  service: ServiceRef<TService, TScope>;
727
713
  deps: TDeps;
728
- factory(deps: ServiceRefsToInstances<TDeps, 'root'>, options: TOpts): TScope extends 'root' ? Promise<TImpl> : Promise<(deps: ServiceRefsToInstances<TDeps>) => Promise<TImpl>>;
714
+ factory(deps: ServiceRefsToInstances<TDeps, 'root'>): TScope extends 'root' ? Promise<TImpl> : Promise<(deps: ServiceRefsToInstances<TDeps>) => Promise<TImpl>>;
729
715
  }
730
716
 
731
717
  /**
@@ -772,9 +758,7 @@ export declare interface ServiceRefConfig<TService, TScope extends 'root' | 'plu
772
758
  declare type ServiceRefsToInstances<T extends {
773
759
  [key in string]: ServiceRef<unknown>;
774
760
  }, TScope extends 'root' | 'plugin' = 'root' | 'plugin'> = {
775
- [name in {
776
- [key in keyof T]: T[key] extends ServiceRef<unknown, TScope> ? key : never;
777
- }[keyof T]]: T[name] extends ServiceRef<infer TImpl> ? TImpl : never;
761
+ [key in keyof T as T[key]['scope'] extends TScope ? key : never]: T[key]['T'];
778
762
  };
779
763
 
780
764
  /**
@@ -22,16 +22,16 @@ export declare interface BackendFeature {
22
22
  }
23
23
 
24
24
  /** @public */
25
- export declare interface BackendModuleConfig<TOptions> {
25
+ export declare interface BackendModuleConfig {
26
26
  pluginId: string;
27
27
  moduleId: string;
28
- register(reg: Omit<BackendRegistrationPoints, 'registerExtensionPoint'>, options: TOptions): void;
28
+ register(reg: Omit<BackendRegistrationPoints, 'registerExtensionPoint'>): void;
29
29
  }
30
30
 
31
31
  /** @public */
32
- export declare interface BackendPluginConfig<TOptions> {
32
+ export declare interface BackendPluginConfig {
33
33
  id: string;
34
- register(reg: BackendRegistrationPoints, options: TOptions): void;
34
+ register(reg: BackendRegistrationPoints): void;
35
35
  }
36
36
 
37
37
  /** @public */
@@ -240,10 +240,10 @@ export declare namespace coreServices {
240
240
  *
241
241
  * The `pluginId` should exactly match the `id` of the plugin that the module extends.
242
242
  */
243
- export declare function createBackendModule<TOptions extends MaybeOptions = undefined>(config: BackendModuleConfig<TOptions>): FactoryFunctionWithOptions<BackendFeature, TOptions>;
243
+ export declare function createBackendModule<TOptions extends [options?: object] = []>(config: BackendModuleConfig | ((...params: TOptions) => BackendModuleConfig)): (...params: TOptions) => BackendFeature;
244
244
 
245
245
  /** @public */
246
- export declare function createBackendPlugin<TOptions extends MaybeOptions = undefined>(config: BackendPluginConfig<TOptions>): FactoryFunctionWithOptions<BackendFeature, TOptions>;
246
+ export declare function createBackendPlugin<TOptions extends [options?: object] = []>(config: BackendPluginConfig | ((...params: TOptions) => BackendPluginConfig)): (...params: TOptions) => BackendFeature;
247
247
 
248
248
  /** @public */
249
249
  export declare function createExtensionPoint<T>(config: ExtensionPointConfig): ExtensionPoint<T>;
@@ -253,7 +253,7 @@ export declare function createExtensionPoint<T>(config: ExtensionPointConfig): E
253
253
  */
254
254
  export declare function createServiceFactory<TService, TScope extends 'root' | 'plugin', TImpl extends TService, TDeps extends {
255
255
  [name in string]: ServiceRef<unknown>;
256
- }, TOpts extends MaybeOptions = undefined>(config: ServiceFactoryConfig<TService, TScope, TImpl, TDeps, TOpts>): FactoryFunctionWithOptions<ServiceFactory<TService>, TOpts>;
256
+ }, TOpts extends [options?: object] = []>(config: ServiceFactoryConfig<TService, TScope, TImpl, TDeps> | ((...options: TOpts) => ServiceFactoryConfig<TService, TScope, TImpl, TDeps>)): (...params: TOpts) => ServiceFactory<TService>;
257
257
 
258
258
  /**
259
259
  * Creates a new service definition. This overload is used to create plugin scoped services.
@@ -363,13 +363,6 @@ export declare interface ExtensionPointConfig {
363
363
  id: string;
364
364
  }
365
365
 
366
- /**
367
- * Helper type that makes the options argument optional if options are not required.
368
- *
369
- * @ignore
370
- */
371
- declare type FactoryFunctionWithOptions<TResult, TOptions> = undefined extends TOptions ? (options?: TOptions) => TResult : (options: TOptions) => TResult;
372
-
373
366
  /**
374
367
  * @public
375
368
  */
@@ -422,13 +415,6 @@ export declare type LogMeta = {
422
415
  [name: string]: unknown;
423
416
  };
424
417
 
425
- /**
426
- * Base type for options objects that aren't required.
427
- *
428
- * @ignore
429
- */
430
- declare type MaybeOptions = object | undefined;
431
-
432
418
  /** @public */
433
419
  export declare interface PermissionsService extends PermissionEvaluator {
434
420
  }
@@ -722,10 +708,10 @@ export declare type ServiceFactory<TService = unknown> = {
722
708
  /** @public */
723
709
  export declare interface ServiceFactoryConfig<TService, TScope extends 'root' | 'plugin', TImpl extends TService, TDeps extends {
724
710
  [name in string]: ServiceRef<unknown>;
725
- }, TOpts extends MaybeOptions = undefined> {
711
+ }> {
726
712
  service: ServiceRef<TService, TScope>;
727
713
  deps: TDeps;
728
- factory(deps: ServiceRefsToInstances<TDeps, 'root'>, options: TOpts): TScope extends 'root' ? Promise<TImpl> : Promise<(deps: ServiceRefsToInstances<TDeps>) => Promise<TImpl>>;
714
+ factory(deps: ServiceRefsToInstances<TDeps, 'root'>): TScope extends 'root' ? Promise<TImpl> : Promise<(deps: ServiceRefsToInstances<TDeps>) => Promise<TImpl>>;
729
715
  }
730
716
 
731
717
  /**
@@ -772,9 +758,7 @@ export declare interface ServiceRefConfig<TService, TScope extends 'root' | 'plu
772
758
  declare type ServiceRefsToInstances<T extends {
773
759
  [key in string]: ServiceRef<unknown>;
774
760
  }, TScope extends 'root' | 'plugin' = 'root' | 'plugin'> = {
775
- [name in {
776
- [key in keyof T]: T[key] extends ServiceRef<unknown, TScope> ? key : never;
777
- }[keyof T]]: T[name] extends ServiceRef<infer TImpl> ? TImpl : never;
761
+ [key in keyof T as T[key]['scope'] extends TScope ? key : never]: T[key]['T'];
778
762
  };
779
763
 
780
764
  /**
package/dist/index.cjs.js CHANGED
@@ -19,13 +19,15 @@ function createServiceRef(config) {
19
19
  };
20
20
  }
21
21
  function createServiceFactory(config) {
22
- return (options) => ({
23
- scope: config.service.scope,
24
- service: config.service,
25
- deps: config.deps,
26
- factory(deps) {
27
- return config.factory(deps, options);
28
- }
22
+ if (typeof config === "function") {
23
+ return (...opts) => {
24
+ const c = config(...opts);
25
+ return { ...c, scope: c.service.scope };
26
+ };
27
+ }
28
+ return () => ({
29
+ ...config,
30
+ scope: config.service.scope
29
31
  });
30
32
  }
31
33
 
@@ -65,18 +67,25 @@ function createExtensionPoint(config) {
65
67
  };
66
68
  }
67
69
  function createBackendPlugin(config) {
68
- return (options) => ({
69
- id: config.id,
70
- register(register) {
71
- return config.register(register, options);
72
- }
73
- });
70
+ if (typeof config === "function") {
71
+ return config;
72
+ }
73
+ return () => config;
74
74
  }
75
75
  function createBackendModule(config) {
76
- return (options) => ({
76
+ if (typeof config === "function") {
77
+ return (...options) => {
78
+ const c = config(...options);
79
+ return {
80
+ id: `${c.pluginId}.${c.moduleId}`,
81
+ register: c.register
82
+ };
83
+ };
84
+ }
85
+ return () => ({
77
86
  id: `${config.pluginId}.${config.moduleId}`,
78
87
  register(register) {
79
- return config.register(register, options);
88
+ return config.register(register);
80
89
  }
81
90
  });
82
91
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/services/system/types.ts","../src/services/definitions/coreServices.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\nimport { FactoryFunctionWithOptions, MaybeOptions } from '../../types';\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 $$ref: 'service';\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 factory(deps: { [key in string]: unknown }): Promise<\n (deps: { [key in string]: unknown }) => Promise<TService>\n >;\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 $$ref: 'service', // TODO: declare\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 [name in {\n [key in keyof T]: T[key] extends ServiceRef<unknown, TScope> ? key : never;\n }[keyof T]]: T[name] extends ServiceRef<infer TImpl> ? TImpl : never;\n};\n\n/** @public */\nexport interface ServiceFactoryConfig<\n TService,\n TScope extends 'root' | 'plugin',\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TOpts extends MaybeOptions = undefined,\n> {\n service: ServiceRef<TService, TScope>;\n deps: TDeps;\n factory(\n deps: ServiceRefsToInstances<TDeps, 'root'>,\n options: TOpts,\n ): TScope extends 'root'\n ? Promise<TImpl>\n : Promise<(deps: ServiceRefsToInstances<TDeps>) => Promise<TImpl>>;\n}\n\n/**\n * @public\n */\nexport function createServiceFactory<\n TService,\n TScope extends 'root' | 'plugin',\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TOpts extends MaybeOptions = undefined,\n>(\n config: ServiceFactoryConfig<TService, TScope, TImpl, TDeps, TOpts>,\n): FactoryFunctionWithOptions<ServiceFactory<TService>, TOpts> {\n return (options?: TOpts) =>\n ({\n scope: config.service.scope,\n service: config.service,\n deps: config.deps,\n factory(deps: ServiceRefsToInstances<TDeps, 'root'>) {\n return config.factory(deps, options!);\n },\n } as ServiceFactory<TService>);\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 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 { FactoryFunctionWithOptions, MaybeOptions } from '../types';\nimport {\n BackendRegistrationPoints,\n BackendFeature,\n ExtensionPoint,\n} from './types';\n\n/** @public */\nexport interface ExtensionPointConfig {\n id: string;\n}\n\n/** @public */\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 $$ref: 'extension-point', // TODO: declare\n };\n}\n\n/** @public */\nexport interface BackendPluginConfig<TOptions> {\n id: string;\n register(reg: BackendRegistrationPoints, options: TOptions): void;\n}\n\n/** @public */\nexport function createBackendPlugin<TOptions extends MaybeOptions = undefined>(\n config: BackendPluginConfig<TOptions>,\n): FactoryFunctionWithOptions<BackendFeature, TOptions> {\n return (options?: TOptions) => ({\n id: config.id,\n register(register: BackendRegistrationPoints) {\n return config.register(register, options!);\n },\n });\n}\n\n/** @public */\nexport interface BackendModuleConfig<TOptions> {\n pluginId: string;\n moduleId: string;\n register(\n reg: Omit<BackendRegistrationPoints, 'registerExtensionPoint'>,\n options: TOptions,\n ): void;\n}\n\n/**\n * Creates a new backend module for a given plugin.\n *\n * @public\n *\n * @remarks\n *\n * The `moduleId` should be equal to the module-specific prefix of the exported name, such\n * that the full name is `moduleId + PluginId + \"Module\"`. For example, a GitHub entity\n * provider module for the `catalog` plugin might have the module ID `'githubEntityProvider'`,\n * and the full exported name would be `githubEntityProviderCatalogModule`.\n *\n * The `pluginId` should exactly match the `id` of the plugin that the module extends.\n */\nexport function createBackendModule<TOptions extends MaybeOptions = undefined>(\n config: BackendModuleConfig<TOptions>,\n): FactoryFunctionWithOptions<BackendFeature, TOptions> {\n return (options?: TOptions) => ({\n id: `${config.pluginId}.${config.moduleId}`,\n register(register: BackendRegistrationPoints) {\n // TODO: Hide registerExtensionPoint\n return config.register(register, options!);\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,CAAA,CAAA,CAAA;AAAA,KAC9B;AAAA,IACA,KAAO,EAAA,SAAA;AAAA;AAAA,IACP,gBAAkB,EAAA,cAAA;AAAA,GACpB,CAAA;AAKF,CAAA;AAiCO,SAAS,qBAOd,MAC6D,EAAA;AAC7D,EAAA,OAAO,CAAC,OACL,MAAA;AAAA,IACC,KAAA,EAAO,OAAO,OAAQ,CAAA,KAAA;AAAA,I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,OAAO,CAAC,OAAwB,MAAA;AAAA,IAC9B,EAAI,EAAA,CAAA,EAAG,MAAO,CAAA,QAAA,CAAA,CAAA,EAAY,MAAO,CAAA,QAAA,CAAA,CAAA;AAAA,IACjC,SAAS,QAAqC,EAAA;AAE5C,MAAO,OAAA,MAAA,CAAO,QAAS,CAAA,QAAA,EAAU,OAAQ,CAAA,CAAA;AAAA,KAC3C;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/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 $$ref: 'service';\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 factory(deps: { [key in string]: unknown }): Promise<\n (deps: { [key in string]: unknown }) => Promise<TService>\n >;\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 $$ref: 'service', // TODO: declare\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 ServiceFactoryConfig<\n TService,\n TScope extends 'root' | 'plugin',\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n> {\n service: ServiceRef<TService, TScope>;\n deps: TDeps;\n factory(\n deps: ServiceRefsToInstances<TDeps, 'root'>,\n ): TScope extends 'root'\n ? Promise<TImpl>\n : Promise<(deps: ServiceRefsToInstances<TDeps>) => Promise<TImpl>>;\n}\n\n/**\n * @public\n */\nexport function createServiceFactory<\n TService,\n TScope extends 'root' | 'plugin',\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TOpts extends [options?: object] = [],\n>(\n config:\n | ServiceFactoryConfig<TService, TScope, TImpl, TDeps>\n | ((\n ...options: TOpts\n ) => ServiceFactoryConfig<TService, TScope, TImpl, TDeps>),\n): (...params: TOpts) => ServiceFactory<TService> {\n if (typeof config === 'function') {\n return (...opts: TOpts) => {\n const c = config(...opts);\n return { ...c, scope: c.service.scope } as ServiceFactory<TService>;\n };\n }\n return () =>\n ({\n ...config,\n scope: config.service.scope,\n } as ServiceFactory<TService>);\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 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 BackendRegistrationPoints,\n BackendFeature,\n ExtensionPoint,\n} from './types';\n\n/** @public */\nexport interface ExtensionPointConfig {\n id: string;\n}\n\n/** @public */\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 $$ref: 'extension-point', // TODO: declare\n };\n}\n\n/** @public */\nexport interface BackendPluginConfig {\n id: string;\n register(reg: BackendRegistrationPoints): void;\n}\n\n/** @public */\nexport function createBackendPlugin<TOptions extends [options?: object] = []>(\n config: BackendPluginConfig | ((...params: TOptions) => BackendPluginConfig),\n): (...params: TOptions) => BackendFeature {\n if (typeof config === 'function') {\n return config;\n }\n\n return () => config;\n}\n\n/** @public */\nexport interface BackendModuleConfig {\n pluginId: string;\n moduleId: string;\n register(\n reg: Omit<BackendRegistrationPoints, 'registerExtensionPoint'>,\n ): void;\n}\n\n/**\n * Creates a new backend module for a given plugin.\n *\n * @public\n *\n * @remarks\n *\n * The `moduleId` should be equal to the module-specific prefix of the exported name, such\n * that the full name is `moduleId + PluginId + \"Module\"`. For example, a GitHub entity\n * provider module for the `catalog` plugin might have the module ID `'githubEntityProvider'`,\n * and the full exported name would be `githubEntityProviderCatalogModule`.\n *\n * The `pluginId` should exactly match the `id` of the plugin that the module extends.\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 // TODO: Hide registerExtensionPoint\n return config.register(register);\n },\n });\n}\n"],"names":["coreServices"],"mappings":";;;;AA0GO,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,CAAA,CAAA,CAAA;AAAA,KAC9B;AAAA,IACA,KAAO,EAAA,SAAA;AAAA;AAAA,IACP,gBAAkB,EAAA,cAAA;AAAA,GACpB,CAAA;AAKF,CAAA;AA6BO,SAAS,qBAOd,MAKgD,EAAA;AAChD,EAAI,IAAA,OAAO,WAAW,UAAY,EAAA;AACh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,SAAS,oBACd,MACyC,EAAA;AACzC,EAAI,IAAA,OAAO,WAAW,UAAY,EAAA;AAChC,IAAA,OAAO,IAAI,OAAsB,KAAA;AAC/B,MAAM,MAAA,CAAA,GAAI,MAAO,CAAA,GAAG,OAAO,CAAA,CAAA;AAC3B,MAAO,OAAA;AAAA,QACL,EAAI,EAAA,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;AAE5C,MAAO,OAAA,MAAA,CAAO,SAAS,QAAQ,CAAA,CAAA;AAAA,KACjC;AAAA,GACF,CAAA,CAAA;AACF;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -22,16 +22,16 @@ export declare interface BackendFeature {
22
22
  }
23
23
 
24
24
  /** @public */
25
- export declare interface BackendModuleConfig<TOptions> {
25
+ export declare interface BackendModuleConfig {
26
26
  pluginId: string;
27
27
  moduleId: string;
28
- register(reg: Omit<BackendRegistrationPoints, 'registerExtensionPoint'>, options: TOptions): void;
28
+ register(reg: Omit<BackendRegistrationPoints, 'registerExtensionPoint'>): void;
29
29
  }
30
30
 
31
31
  /** @public */
32
- export declare interface BackendPluginConfig<TOptions> {
32
+ export declare interface BackendPluginConfig {
33
33
  id: string;
34
- register(reg: BackendRegistrationPoints, options: TOptions): void;
34
+ register(reg: BackendRegistrationPoints): void;
35
35
  }
36
36
 
37
37
  /** @public */
@@ -240,10 +240,10 @@ export declare namespace coreServices {
240
240
  *
241
241
  * The `pluginId` should exactly match the `id` of the plugin that the module extends.
242
242
  */
243
- export declare function createBackendModule<TOptions extends MaybeOptions = undefined>(config: BackendModuleConfig<TOptions>): FactoryFunctionWithOptions<BackendFeature, TOptions>;
243
+ export declare function createBackendModule<TOptions extends [options?: object] = []>(config: BackendModuleConfig | ((...params: TOptions) => BackendModuleConfig)): (...params: TOptions) => BackendFeature;
244
244
 
245
245
  /** @public */
246
- export declare function createBackendPlugin<TOptions extends MaybeOptions = undefined>(config: BackendPluginConfig<TOptions>): FactoryFunctionWithOptions<BackendFeature, TOptions>;
246
+ export declare function createBackendPlugin<TOptions extends [options?: object] = []>(config: BackendPluginConfig | ((...params: TOptions) => BackendPluginConfig)): (...params: TOptions) => BackendFeature;
247
247
 
248
248
  /** @public */
249
249
  export declare function createExtensionPoint<T>(config: ExtensionPointConfig): ExtensionPoint<T>;
@@ -253,7 +253,7 @@ export declare function createExtensionPoint<T>(config: ExtensionPointConfig): E
253
253
  */
254
254
  export declare function createServiceFactory<TService, TScope extends 'root' | 'plugin', TImpl extends TService, TDeps extends {
255
255
  [name in string]: ServiceRef<unknown>;
256
- }, TOpts extends MaybeOptions = undefined>(config: ServiceFactoryConfig<TService, TScope, TImpl, TDeps, TOpts>): FactoryFunctionWithOptions<ServiceFactory<TService>, TOpts>;
256
+ }, TOpts extends [options?: object] = []>(config: ServiceFactoryConfig<TService, TScope, TImpl, TDeps> | ((...options: TOpts) => ServiceFactoryConfig<TService, TScope, TImpl, TDeps>)): (...params: TOpts) => ServiceFactory<TService>;
257
257
 
258
258
  /**
259
259
  * Creates a new service definition. This overload is used to create plugin scoped services.
@@ -363,13 +363,6 @@ export declare interface ExtensionPointConfig {
363
363
  id: string;
364
364
  }
365
365
 
366
- /**
367
- * Helper type that makes the options argument optional if options are not required.
368
- *
369
- * @ignore
370
- */
371
- declare type FactoryFunctionWithOptions<TResult, TOptions> = undefined extends TOptions ? (options?: TOptions) => TResult : (options: TOptions) => TResult;
372
-
373
366
  /**
374
367
  * @public
375
368
  */
@@ -422,13 +415,6 @@ export declare type LogMeta = {
422
415
  [name: string]: unknown;
423
416
  };
424
417
 
425
- /**
426
- * Base type for options objects that aren't required.
427
- *
428
- * @ignore
429
- */
430
- declare type MaybeOptions = object | undefined;
431
-
432
418
  /** @public */
433
419
  export declare interface PermissionsService extends PermissionEvaluator {
434
420
  }
@@ -722,10 +708,10 @@ export declare type ServiceFactory<TService = unknown> = {
722
708
  /** @public */
723
709
  export declare interface ServiceFactoryConfig<TService, TScope extends 'root' | 'plugin', TImpl extends TService, TDeps extends {
724
710
  [name in string]: ServiceRef<unknown>;
725
- }, TOpts extends MaybeOptions = undefined> {
711
+ }> {
726
712
  service: ServiceRef<TService, TScope>;
727
713
  deps: TDeps;
728
- factory(deps: ServiceRefsToInstances<TDeps, 'root'>, options: TOpts): TScope extends 'root' ? Promise<TImpl> : Promise<(deps: ServiceRefsToInstances<TDeps>) => Promise<TImpl>>;
714
+ factory(deps: ServiceRefsToInstances<TDeps, 'root'>): TScope extends 'root' ? Promise<TImpl> : Promise<(deps: ServiceRefsToInstances<TDeps>) => Promise<TImpl>>;
729
715
  }
730
716
 
731
717
  /**
@@ -772,9 +758,7 @@ export declare interface ServiceRefConfig<TService, TScope extends 'root' | 'plu
772
758
  declare type ServiceRefsToInstances<T extends {
773
759
  [key in string]: ServiceRef<unknown>;
774
760
  }, TScope extends 'root' | 'plugin' = 'root' | 'plugin'> = {
775
- [name in {
776
- [key in keyof T]: T[key] extends ServiceRef<unknown, TScope> ? key : never;
777
- }[keyof T]]: T[name] extends ServiceRef<infer TImpl> ? TImpl : never;
761
+ [key in keyof T as T[key]['scope'] extends TScope ? key : never]: T[key]['T'];
778
762
  };
779
763
 
780
764
  /**
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-20230112022659",
4
+ "version": "0.0.0-nightly-20230114022133",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "publishConfig": {
@@ -33,17 +33,17 @@
33
33
  "start": "backstage-cli package start"
34
34
  },
35
35
  "dependencies": {
36
- "@backstage/backend-tasks": "^0.0.0-nightly-20230112022659",
37
- "@backstage/config": "^0.0.0-nightly-20230112022659",
38
- "@backstage/plugin-auth-node": "^0.0.0-nightly-20230112022659",
39
- "@backstage/plugin-permission-common": "^0.0.0-nightly-20230112022659",
36
+ "@backstage/backend-tasks": "^0.0.0-nightly-20230114022133",
37
+ "@backstage/config": "^0.0.0-nightly-20230114022133",
38
+ "@backstage/plugin-auth-node": "^0.0.0-nightly-20230114022133",
39
+ "@backstage/plugin-permission-common": "^0.0.0-nightly-20230114022133",
40
40
  "@backstage/types": "^1.0.2",
41
41
  "@types/express": "^4.17.6",
42
42
  "express": "^4.17.1",
43
43
  "knex": "^2.0.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@backstage/cli": "^0.0.0-nightly-20230112022659"
46
+ "@backstage/cli": "^0.0.0-nightly-20230114022133"
47
47
  },
48
48
  "files": [
49
49
  "dist",