@backstage/backend-app-api 0.2.4 → 0.2.5-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of @backstage/backend-app-api might be problematic. Click here for more details.

package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @backstage/backend-app-api
2
2
 
3
+ ## 0.2.5-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 6cfd4d7073: Updated implementations for the new `RootLifecycleService`.
8
+ - Updated dependencies
9
+ - @backstage/backend-plugin-api@0.2.1-next.0
10
+ - @backstage/backend-common@0.18.0-next.0
11
+ - @backstage/backend-tasks@0.4.1-next.0
12
+ - @backstage/errors@1.1.4
13
+ - @backstage/plugin-permission-node@0.7.3-next.0
14
+
3
15
  ## 0.2.4
4
16
 
5
17
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/backend-app-api",
3
- "version": "0.2.4",
3
+ "version": "0.2.5-next.0",
4
4
  "main": "../dist/index.cjs.js",
5
5
  "types": "../dist/index.alpha.d.ts"
6
6
  }
@@ -77,6 +77,11 @@ export declare const loggerFactory: (options?: undefined) => ServiceFactory<Logg
77
77
  /** @public */
78
78
  export declare const permissionsFactory: (options?: undefined) => ServiceFactory<PermissionsService>;
79
79
 
80
+ /**
81
+ * Allows plugins to register shutdown hooks that are run when the process is about to exit.
82
+ * @public */
83
+ export declare const rootLifecycleFactory: (options?: undefined) => ServiceFactory<LifecycleService>;
84
+
80
85
  /** @public */
81
86
  export declare const rootLoggerFactory: (options?: undefined) => ServiceFactory<LoggerService>;
82
87
 
@@ -77,6 +77,11 @@ export declare const loggerFactory: (options?: undefined) => ServiceFactory<Logg
77
77
  /** @public */
78
78
  export declare const permissionsFactory: (options?: undefined) => ServiceFactory<PermissionsService>;
79
79
 
80
+ /**
81
+ * Allows plugins to register shutdown hooks that are run when the process is about to exit.
82
+ * @public */
83
+ export declare const rootLifecycleFactory: (options?: undefined) => ServiceFactory<LifecycleService>;
84
+
80
85
  /** @public */
81
86
  export declare const rootLoggerFactory: (options?: undefined) => ServiceFactory<LoggerService>;
82
87
 
package/dist/index.cjs.js CHANGED
@@ -50,44 +50,26 @@ class BackendLifecycleImpl {
50
50
  __privateSet$3(this, _isCalled, true);
51
51
  this.logger.info(`Running ${__privateGet$3(this, _shutdownTasks).length} shutdown tasks...`);
52
52
  await Promise.all(
53
- __privateGet$3(this, _shutdownTasks).map(
54
- (hook) => Promise.resolve().then(() => hook.fn()).catch((e) => {
55
- this.logger.error(
56
- `Shutdown hook registered by plugin '${hook.pluginId}' failed with: ${e}`
57
- );
58
- }).then(
59
- () => this.logger.info(
60
- `Successfully ran shutdown hook registered by plugin ${hook.pluginId}`
61
- )
62
- )
63
- )
53
+ __privateGet$3(this, _shutdownTasks).map(async (hook) => {
54
+ try {
55
+ await hook.fn();
56
+ this.logger.info(`Shutdown hook succeeded`, hook.labels);
57
+ } catch (error) {
58
+ this.logger.error(`Shutdown hook failed, ${error}`, hook.labels);
59
+ }
60
+ })
64
61
  );
65
62
  }
66
63
  }
67
64
  _isCalled = new WeakMap();
68
65
  _shutdownTasks = new WeakMap();
69
- class PluginScopedLifecycleImpl {
70
- constructor(lifecycle, pluginId) {
71
- this.lifecycle = lifecycle;
72
- this.pluginId = pluginId;
73
- }
74
- addShutdownHook(options) {
75
- this.lifecycle.addShutdownHook({ ...options, pluginId: this.pluginId });
76
- }
77
- }
78
- const lifecycleFactory = backendPluginApi.createServiceFactory({
79
- service: backendPluginApi.coreServices.lifecycle,
66
+ const rootLifecycleFactory = backendPluginApi.createServiceFactory({
67
+ service: backendPluginApi.coreServices.rootLifecycle,
80
68
  deps: {
81
- logger: backendPluginApi.coreServices.rootLogger,
82
- plugin: backendPluginApi.coreServices.pluginMetadata
69
+ logger: backendPluginApi.coreServices.rootLogger
83
70
  },
84
71
  async factory({ logger }) {
85
- const rootLifecycle = new BackendLifecycleImpl(
86
- backendPluginApi.loggerToWinstonLogger(logger)
87
- );
88
- return async ({ plugin }) => {
89
- return new PluginScopedLifecycleImpl(rootLifecycle, plugin.getId());
90
- };
72
+ return new BackendLifecycleImpl(backendPluginApi.loggerToWinstonLogger(logger));
91
73
  }
92
74
  });
93
75
 
@@ -186,12 +168,11 @@ class BackendInitializer {
186
168
  return;
187
169
  }
188
170
  const lifecycleService = await __privateGet$2(this, _serviceHolder).get(
189
- backendPluginApi.coreServices.lifecycle,
171
+ backendPluginApi.coreServices.rootLifecycle,
190
172
  "root"
191
173
  );
192
- const lifecycle = lifecycleService == null ? void 0 : lifecycleService.lifecycle;
193
- if (lifecycle instanceof BackendLifecycleImpl) {
194
- await lifecycle.shutdown();
174
+ if (lifecycleService instanceof BackendLifecycleImpl) {
175
+ await lifecycleService.shutdown();
195
176
  } else {
196
177
  throw new Error("Unexpected lifecycle service implementation");
197
178
  }
@@ -665,6 +646,27 @@ const httpRouterFactory = backendPluginApi.createServiceFactory({
665
646
  }
666
647
  });
667
648
 
649
+ const lifecycleFactory = backendPluginApi.createServiceFactory({
650
+ service: backendPluginApi.coreServices.lifecycle,
651
+ deps: {
652
+ rootLifecycle: backendPluginApi.coreServices.rootLifecycle,
653
+ pluginMetadata: backendPluginApi.coreServices.pluginMetadata
654
+ },
655
+ async factory({ rootLifecycle }) {
656
+ return async ({ pluginMetadata }) => {
657
+ const plugin = pluginMetadata.getId();
658
+ return {
659
+ addShutdownHook(options) {
660
+ rootLifecycle.addShutdownHook({
661
+ ...options,
662
+ labels: { ...options == null ? void 0 : options.labels, plugin }
663
+ });
664
+ }
665
+ };
666
+ };
667
+ }
668
+ });
669
+
668
670
  exports.cacheFactory = cacheFactory;
669
671
  exports.configFactory = configFactory;
670
672
  exports.createSpecializedBackend = createSpecializedBackend;
@@ -674,6 +676,7 @@ exports.httpRouterFactory = httpRouterFactory;
674
676
  exports.lifecycleFactory = lifecycleFactory;
675
677
  exports.loggerFactory = loggerFactory;
676
678
  exports.permissionsFactory = permissionsFactory;
679
+ exports.rootLifecycleFactory = rootLifecycleFactory;
677
680
  exports.rootLoggerFactory = rootLoggerFactory;
678
681
  exports.schedulerFactory = schedulerFactory;
679
682
  exports.tokenManagerFactory = tokenManagerFactory;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/services/implementations/lifecycleService.ts","../src/wiring/BackendInitializer.ts","../src/wiring/ServiceRegistry.ts","../src/wiring/BackstageBackend.ts","../src/wiring/types.ts","../src/services/implementations/cacheService.ts","../src/services/implementations/configService.ts","../src/services/implementations/databaseService.ts","../src/services/implementations/discoveryService.ts","../src/services/implementations/loggerService.ts","../src/services/implementations/rootLoggerService.ts","../src/services/implementations/permissionsService.ts","../src/services/implementations/schedulerService.ts","../src/services/implementations/tokenManagerService.ts","../src/services/implementations/urlReaderService.ts","../src/services/implementations/httpRouterService.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 */\nimport {\n LifecycleService,\n createServiceFactory,\n coreServices,\n loggerToWinstonLogger,\n LifecycleServiceShutdownHook,\n} from '@backstage/backend-plugin-api';\nimport { Logger } from 'winston';\n\nconst CALLBACKS = ['SIGTERM', 'SIGINT', 'beforeExit'];\nexport class BackendLifecycleImpl {\n constructor(private readonly logger: Logger) {\n CALLBACKS.map(signal => process.on(signal, () => this.shutdown()));\n }\n\n #isCalled = false;\n #shutdownTasks: Array<LifecycleServiceShutdownHook & { pluginId: string }> =\n [];\n\n addShutdownHook(\n options: LifecycleServiceShutdownHook & { pluginId: string },\n ): void {\n this.#shutdownTasks.push(options);\n }\n\n async shutdown(): Promise<void> {\n if (this.#isCalled) {\n return;\n }\n this.#isCalled = true;\n\n this.logger.info(`Running ${this.#shutdownTasks.length} shutdown tasks...`);\n await Promise.all(\n this.#shutdownTasks.map(hook =>\n Promise.resolve()\n .then(() => hook.fn())\n .catch(e => {\n this.logger.error(\n `Shutdown hook registered by plugin '${hook.pluginId}' failed with: ${e}`,\n );\n })\n .then(() =>\n this.logger.info(\n `Successfully ran shutdown hook registered by plugin ${hook.pluginId}`,\n ),\n ),\n ),\n );\n }\n}\n\nclass PluginScopedLifecycleImpl implements LifecycleService {\n constructor(\n private readonly lifecycle: BackendLifecycleImpl,\n private readonly pluginId: string,\n ) {}\n addShutdownHook(options: LifecycleServiceShutdownHook): void {\n this.lifecycle.addShutdownHook({ ...options, pluginId: this.pluginId });\n }\n}\n\n/**\n * Allows plugins to register shutdown hooks that are run when the process is about to exit.\n * @public */\nexport const lifecycleFactory = createServiceFactory({\n service: coreServices.lifecycle,\n deps: {\n logger: coreServices.rootLogger,\n plugin: coreServices.pluginMetadata,\n },\n async factory({ logger }) {\n const rootLifecycle = new BackendLifecycleImpl(\n loggerToWinstonLogger(logger),\n );\n return async ({ plugin }) => {\n return new PluginScopedLifecycleImpl(rootLifecycle, plugin.getId());\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 {\n BackendFeature,\n ExtensionPoint,\n coreServices,\n ServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { BackendLifecycleImpl } from '../services/implementations/lifecycleService';\nimport {\n BackendRegisterInit,\n EnumerableServiceHolder,\n ServiceOrExtensionPoint,\n} from './types';\n\nexport class BackendInitializer {\n #started = false;\n #features = new Map<BackendFeature, unknown>();\n #registerInits = new Array<BackendRegisterInit>();\n #extensionPoints = new Map<ExtensionPoint<unknown>, unknown>();\n #serviceHolder: EnumerableServiceHolder;\n\n constructor(serviceHolder: EnumerableServiceHolder) {\n this.#serviceHolder = serviceHolder;\n }\n\n async #getInitDeps(\n deps: { [name: string]: ServiceOrExtensionPoint },\n pluginId: string,\n ) {\n const result = new Map<string, unknown>();\n const missingRefs = new Set<ServiceOrExtensionPoint>();\n\n for (const [name, ref] of Object.entries(deps)) {\n const extensionPoint = this.#extensionPoints.get(\n ref as ExtensionPoint<unknown>,\n );\n if (extensionPoint) {\n result.set(name, extensionPoint);\n } else {\n const impl = await this.#serviceHolder.get(\n ref as ServiceRef<unknown>,\n pluginId,\n );\n if (impl) {\n result.set(name, impl);\n } else {\n missingRefs.add(ref);\n }\n }\n }\n\n if (missingRefs.size > 0) {\n const missing = Array.from(missingRefs).join(', ');\n throw new Error(\n `No extension point or service available for the following ref(s): ${missing}`,\n );\n }\n\n return Object.fromEntries(result);\n }\n\n add<TOptions>(feature: BackendFeature, options?: TOptions) {\n if (this.#started) {\n throw new Error('feature can not be added after the backend has started');\n }\n this.#features.set(feature, options);\n }\n\n async start(): Promise<void> {\n if (this.#started) {\n throw new Error('Backend has already started');\n }\n this.#started = true;\n\n // Initialize all root scoped services\n for (const ref of this.#serviceHolder.getServiceRefs()) {\n if (ref.scope === 'root') {\n await this.#serviceHolder.get(ref, 'root');\n }\n }\n\n // Initialize all features\n for (const [feature] of this.#features) {\n const provides = new Set<ExtensionPoint<unknown>>();\n\n let registerInit: BackendRegisterInit | undefined = undefined;\n\n feature.register({\n registerExtensionPoint: (extensionPointRef, impl) => {\n if (registerInit) {\n throw new Error('registerExtensionPoint called after registerInit');\n }\n if (this.#extensionPoints.has(extensionPointRef)) {\n throw new Error(`API ${extensionPointRef.id} already registered`);\n }\n this.#extensionPoints.set(extensionPointRef, impl);\n provides.add(extensionPointRef);\n },\n registerInit: registerOptions => {\n if (registerInit) {\n throw new Error('registerInit must only be called once');\n }\n registerInit = {\n id: feature.id,\n provides,\n consumes: new Set(Object.values(registerOptions.deps)),\n deps: registerOptions.deps,\n init: registerOptions.init as BackendRegisterInit['init'],\n };\n },\n });\n\n if (!registerInit) {\n throw new Error(\n `registerInit was not called by register in ${feature.id}`,\n );\n }\n\n this.#registerInits.push(registerInit);\n }\n\n const orderedRegisterResults = this.#resolveInitOrder(this.#registerInits);\n\n for (const registerInit of orderedRegisterResults) {\n const deps = await this.#getInitDeps(registerInit.deps, registerInit.id);\n await registerInit.init(deps);\n }\n }\n\n #resolveInitOrder(registerInits: Array<BackendRegisterInit>) {\n let registerInitsToOrder = registerInits.slice();\n const orderedRegisterInits = new Array<BackendRegisterInit>();\n\n // TODO: Validate duplicates\n\n while (registerInitsToOrder.length > 0) {\n const toRemove = new Set<unknown>();\n\n for (const registerInit of registerInitsToOrder) {\n const unInitializedDependents = [];\n\n for (const provided of registerInit.provides) {\n if (\n registerInitsToOrder.some(\n init => init !== registerInit && init.consumes.has(provided),\n )\n ) {\n unInitializedDependents.push(provided);\n }\n }\n\n if (unInitializedDependents.length === 0) {\n orderedRegisterInits.push(registerInit);\n toRemove.add(registerInit);\n }\n }\n\n registerInitsToOrder = registerInitsToOrder.filter(r => !toRemove.has(r));\n }\n\n return orderedRegisterInits;\n }\n\n async stop(): Promise<void> {\n if (!this.#started) {\n return;\n }\n\n const lifecycleService = await this.#serviceHolder.get(\n coreServices.lifecycle,\n 'root',\n );\n\n // TODO(Rugvip): Find a better way to do this\n const lifecycle = (lifecycleService as any)?.lifecycle;\n if (lifecycle instanceof BackendLifecycleImpl) {\n await lifecycle.shutdown();\n } else {\n throw new Error('Unexpected lifecycle service implementation');\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 {\n ServiceFactory,\n ServiceRef,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { stringifyError } from '@backstage/errors';\nimport { EnumerableServiceHolder } from './types';\n/**\n * Keep in sync with `@backstage/backend-plugin-api/src/services/system/types.ts`\n * @internal\n */\nexport type InternalServiceRef<T> = ServiceRef<T> & {\n __defaultFactory?: (\n service: ServiceRef<T>,\n ) => Promise<ServiceFactory<T> | (() => ServiceFactory<T>)>;\n};\n\nexport class ServiceRegistry implements EnumerableServiceHolder {\n readonly #providedFactories: Map<string, ServiceFactory>;\n readonly #loadedDefaultFactories: Map<Function, Promise<ServiceFactory>>;\n readonly #implementations: Map<\n ServiceFactory,\n {\n factoryFunc: Promise<\n (deps: { [name in string]: unknown }) => Promise<unknown>\n >;\n byPlugin: Map<string, Promise<unknown>>;\n }\n >;\n\n constructor(\n factories: Array<ServiceFactory<unknown> | (() => ServiceFactory<unknown>)>,\n ) {\n this.#providedFactories = new Map(\n factories.map(f => {\n if (typeof f === 'function') {\n const cf = f();\n return [cf.service.id, cf];\n }\n return [f.service.id, f];\n }),\n );\n this.#loadedDefaultFactories = new Map();\n this.#implementations = new Map();\n }\n\n #resolveFactory(\n ref: ServiceRef<unknown>,\n pluginId: string,\n ): Promise<ServiceFactory> | undefined {\n // Special case handling of the plugin metadata service, generating a custom factory for it each time\n if (ref.id === coreServices.pluginMetadata.id) {\n return Promise.resolve({\n scope: 'plugin',\n service: coreServices.pluginMetadata,\n deps: {},\n factory: async () => async () => ({\n getId() {\n return pluginId;\n },\n }),\n });\n }\n\n let resolvedFactory: Promise<ServiceFactory> | ServiceFactory | undefined =\n this.#providedFactories.get(ref.id);\n const { __defaultFactory: defaultFactory } =\n ref as InternalServiceRef<unknown>;\n if (!resolvedFactory && !defaultFactory) {\n return undefined;\n }\n\n if (!resolvedFactory) {\n let loadedFactory = this.#loadedDefaultFactories.get(defaultFactory!);\n if (!loadedFactory) {\n loadedFactory = Promise.resolve()\n .then(() => defaultFactory!(ref))\n .then(f =>\n typeof f === 'function' ? f() : f,\n ) as Promise<ServiceFactory>;\n this.#loadedDefaultFactories.set(defaultFactory!, loadedFactory);\n }\n resolvedFactory = loadedFactory.catch(error => {\n throw new Error(\n `Failed to instantiate service '${\n ref.id\n }' because the default factory loader threw an error, ${stringifyError(\n error,\n )}`,\n );\n });\n }\n\n return Promise.resolve(resolvedFactory);\n }\n\n #separateMapForTheRootService = new Map<ServiceFactory, Promise<unknown>>();\n\n #checkForMissingDeps(factory: ServiceFactory, pluginId: string) {\n const missingDeps = Object.values(factory.deps).filter(ref => {\n if (ref.id === coreServices.pluginMetadata.id) {\n return false;\n }\n if (this.#providedFactories.get(ref.id)) {\n return false;\n }\n\n return !(ref as InternalServiceRef<unknown>).__defaultFactory;\n });\n\n if (missingDeps.length) {\n const missing = missingDeps.map(r => `'${r.id}'`).join(', ');\n throw new Error(\n `Failed to instantiate service '${factory.service.id}' for '${pluginId}' because the following dependent services are missing: ${missing}`,\n );\n }\n }\n\n getServiceRefs(): ServiceRef<unknown>[] {\n return Array.from(this.#providedFactories.values()).map(f => f.service);\n }\n\n get<T>(ref: ServiceRef<T>, pluginId: string): Promise<T> | undefined {\n return this.#resolveFactory(ref, pluginId)?.then(factory => {\n if (factory.scope === 'root') {\n let existing = this.#separateMapForTheRootService.get(factory);\n if (!existing) {\n this.#checkForMissingDeps(factory, pluginId);\n const rootDeps = new Array<Promise<[name: string, impl: unknown]>>();\n\n for (const [name, serviceRef] of Object.entries(factory.deps)) {\n if (serviceRef.scope !== 'root') {\n throw new Error(\n `Failed to instantiate 'root' scoped service '${ref.id}' because it depends on '${serviceRef.scope}' scoped service '${serviceRef.id}'.`,\n );\n }\n const target = this.get(serviceRef, pluginId)!;\n rootDeps.push(target.then(impl => [name, impl]));\n }\n\n existing = Promise.all(rootDeps).then(entries =>\n factory.factory(Object.fromEntries(entries)),\n );\n this.#separateMapForTheRootService.set(factory, existing);\n }\n return existing as Promise<T>;\n }\n\n let implementation = this.#implementations.get(factory);\n if (!implementation) {\n this.#checkForMissingDeps(factory, pluginId);\n const rootDeps = new Array<Promise<[name: string, impl: unknown]>>();\n\n for (const [name, serviceRef] of Object.entries(factory.deps)) {\n if (serviceRef.scope === 'root') {\n const target = this.get(serviceRef, pluginId)!;\n rootDeps.push(target.then(impl => [name, impl]));\n }\n }\n\n implementation = {\n factoryFunc: Promise.all(rootDeps)\n .then(entries => factory.factory(Object.fromEntries(entries)))\n .catch(error => {\n const cause = stringifyError(error);\n throw new Error(\n `Failed to instantiate service '${ref.id}' because the top-level factory function threw an error, ${cause}`,\n );\n }),\n byPlugin: new Map(),\n };\n\n this.#implementations.set(factory, implementation);\n }\n\n let result = implementation.byPlugin.get(pluginId) as Promise<any>;\n if (!result) {\n const allDeps = new Array<Promise<[name: string, impl: unknown]>>();\n\n for (const [name, serviceRef] of Object.entries(factory.deps)) {\n const target = this.get(serviceRef, pluginId)!;\n allDeps.push(target.then(impl => [name, impl]));\n }\n\n result = implementation.factoryFunc\n .then(func =>\n Promise.all(allDeps).then(entries =>\n func(Object.fromEntries(entries)),\n ),\n )\n .catch(error => {\n const cause = stringifyError(error);\n throw new Error(\n `Failed to instantiate service '${ref.id}' for '${pluginId}' because the factory function threw an error, ${cause}`,\n );\n });\n implementation.byPlugin.set(pluginId, result);\n }\n\n return result;\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 { ServiceFactory, BackendFeature } from '@backstage/backend-plugin-api';\nimport { BackendInitializer } from './BackendInitializer';\nimport { ServiceRegistry } from './ServiceRegistry';\nimport { Backend } from './types';\n\nexport class BackstageBackend implements Backend {\n #services: ServiceRegistry;\n #initializer: BackendInitializer;\n\n constructor(apiFactories: ServiceFactory[]) {\n this.#services = new ServiceRegistry(apiFactories);\n this.#initializer = new BackendInitializer(this.#services);\n }\n\n add(feature: BackendFeature): void {\n this.#initializer.add(feature);\n }\n\n async start(): Promise<void> {\n await this.#initializer.start();\n }\n\n async stop(): Promise<void> {\n await this.#initializer.stop();\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 ServiceFactory,\n BackendFeature,\n ExtensionPoint,\n ServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { BackstageBackend } from './BackstageBackend';\n\n/**\n * @public\n */\nexport interface Backend {\n add(feature: BackendFeature): void;\n start(): Promise<void>;\n stop(): Promise<void>;\n}\n\nexport interface BackendRegisterInit {\n id: string;\n consumes: Set<ServiceOrExtensionPoint>;\n provides: Set<ServiceOrExtensionPoint>;\n deps: { [name: string]: ServiceOrExtensionPoint };\n init: (deps: { [name: string]: unknown }) => Promise<void>;\n}\n\n/**\n * @public\n */\nexport interface CreateSpecializedBackendOptions {\n services: (ServiceFactory | (() => ServiceFactory))[];\n}\n\nexport interface ServiceHolder {\n get<T>(api: ServiceRef<T>, pluginId: string): Promise<T> | undefined;\n}\n\n/**\n * @internal\n */\nexport interface EnumerableServiceHolder extends ServiceHolder {\n getServiceRefs(): ServiceRef<unknown>[];\n}\n\n/**\n * @public\n */\nexport function createSpecializedBackend(\n options: CreateSpecializedBackendOptions,\n): Backend {\n return new BackstageBackend(\n options.services.map(s => (typeof s === 'function' ? s() : s)),\n );\n}\n\n/**\n * @public\n */\nexport type ServiceOrExtensionPoint<T = unknown> =\n | ExtensionPoint<T>\n | ServiceRef<T>;\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 { CacheManager } from '@backstage/backend-common';\nimport {\n coreServices,\n createServiceFactory,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const cacheFactory = createServiceFactory({\n service: coreServices.cache,\n deps: {\n config: coreServices.config,\n plugin: coreServices.pluginMetadata,\n },\n async factory({ config }) {\n const cacheManager = CacheManager.fromConfig(config);\n return async ({ plugin }) => {\n return cacheManager.forPlugin(plugin.getId());\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 { loadBackendConfig } from '@backstage/backend-common';\nimport {\n coreServices,\n createServiceFactory,\n loggerToWinstonLogger,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const configFactory = createServiceFactory({\n service: coreServices.config,\n deps: {\n logger: coreServices.rootLogger,\n },\n async factory({ logger }) {\n const config = await loadBackendConfig({\n argv: process.argv,\n logger: loggerToWinstonLogger(logger),\n });\n return config;\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 { DatabaseManager } from '@backstage/backend-common';\nimport {\n coreServices,\n createServiceFactory,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const databaseFactory = createServiceFactory({\n service: coreServices.database,\n deps: {\n config: coreServices.config,\n plugin: coreServices.pluginMetadata,\n },\n async factory({ config }) {\n const databaseManager = DatabaseManager.fromConfig(config);\n return async ({ plugin }) => {\n return databaseManager.forPlugin(plugin.getId());\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 { SingleHostDiscovery } from '@backstage/backend-common';\nimport {\n coreServices,\n createServiceFactory,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const discoveryFactory = createServiceFactory({\n service: coreServices.discovery,\n deps: {\n config: coreServices.config,\n },\n async factory({ config }) {\n const discovery = SingleHostDiscovery.fromConfig(config);\n return async () => {\n return discovery;\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 {\n createServiceFactory,\n coreServices,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const loggerFactory = createServiceFactory({\n service: coreServices.logger,\n deps: {\n rootLogger: coreServices.rootLogger,\n plugin: coreServices.pluginMetadata,\n },\n async factory({ rootLogger }) {\n return async ({ plugin }) => {\n return rootLogger.child({ pluginId: plugin.getId() });\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 { createRootLogger } from '@backstage/backend-common';\nimport {\n createServiceFactory,\n LoggerService,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { LogMeta } from '@backstage/backend-plugin-api';\nimport { Logger as WinstonLogger } from 'winston';\n\nclass BackstageLogger implements LoggerService {\n static fromWinston(logger: WinstonLogger): BackstageLogger {\n return new BackstageLogger(logger);\n }\n\n private constructor(private readonly winston: WinstonLogger) {}\n\n error(message: string, meta?: LogMeta): void {\n this.winston.error(message, meta);\n }\n\n warn(message: string, meta?: LogMeta): void {\n this.winston.warn(message, meta);\n }\n\n info(message: string, meta?: LogMeta): void {\n this.winston.info(message, meta);\n }\n\n debug(message: string, meta?: LogMeta): void {\n this.winston.debug(message, meta);\n }\n\n child(meta: LogMeta): LoggerService {\n return new BackstageLogger(this.winston.child(meta));\n }\n}\n\n/** @public */\nexport const rootLoggerFactory = createServiceFactory({\n service: coreServices.rootLogger,\n deps: {},\n async factory() {\n return BackstageLogger.fromWinston(createRootLogger());\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 coreServices,\n createServiceFactory,\n} from '@backstage/backend-plugin-api';\nimport { ServerPermissionClient } from '@backstage/plugin-permission-node';\n\n/** @public */\nexport const permissionsFactory = createServiceFactory({\n service: coreServices.permissions,\n deps: {\n config: coreServices.config,\n discovery: coreServices.discovery,\n tokenManager: coreServices.tokenManager,\n },\n async factory({ config }) {\n return async ({ discovery, tokenManager }) => {\n return ServerPermissionClient.fromConfig(config, {\n discovery,\n tokenManager,\n });\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 {\n coreServices,\n createServiceFactory,\n} from '@backstage/backend-plugin-api';\nimport { TaskScheduler } from '@backstage/backend-tasks';\n\n/** @public */\nexport const schedulerFactory = createServiceFactory({\n service: coreServices.scheduler,\n deps: {\n config: coreServices.config,\n plugin: coreServices.pluginMetadata,\n },\n async factory({ config }) {\n const taskScheduler = TaskScheduler.fromConfig(config);\n return async ({ plugin }) => {\n return taskScheduler.forPlugin(plugin.getId());\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 {\n coreServices,\n createServiceFactory,\n loggerToWinstonLogger,\n} from '@backstage/backend-plugin-api';\nimport { ServerTokenManager } from '@backstage/backend-common';\n\n/** @public */\nexport const tokenManagerFactory = createServiceFactory({\n service: coreServices.tokenManager,\n deps: {\n config: coreServices.config,\n logger: coreServices.logger,\n },\n async factory() {\n return async ({ config, logger }) => {\n return ServerTokenManager.fromConfig(config, {\n logger: loggerToWinstonLogger(logger),\n });\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 { UrlReaders } from '@backstage/backend-common';\nimport {\n coreServices,\n createServiceFactory,\n loggerToWinstonLogger,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const urlReaderFactory = createServiceFactory({\n service: coreServices.urlReader,\n deps: {\n config: coreServices.config,\n logger: coreServices.logger,\n },\n async factory() {\n return async ({ config, logger }) => {\n return UrlReaders.default({\n config,\n logger: loggerToWinstonLogger(logger),\n });\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 {\n createServiceFactory,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport Router from 'express-promise-router';\nimport { Handler } from 'express';\nimport { createServiceBuilder } from '@backstage/backend-common';\n\n/**\n * @public\n */\nexport type HttpRouterFactoryOptions = {\n /**\n * The plugin ID used for the index route. Defaults to 'app'\n */\n indexPlugin?: string;\n};\n\n/** @public */\nexport const httpRouterFactory = createServiceFactory({\n service: coreServices.httpRouter,\n deps: {\n config: coreServices.config,\n plugin: coreServices.pluginMetadata,\n },\n async factory({ config }, options?: HttpRouterFactoryOptions) {\n const defaultPluginId = options?.indexPlugin ?? 'app';\n\n const apiRouter = Router();\n const rootRouter = Router();\n\n const service = createServiceBuilder(module)\n .loadConfig(config)\n .addRouter('/api', apiRouter)\n .addRouter('', rootRouter);\n\n await service.start();\n\n return async ({ plugin }) => {\n const pluginId = plugin.getId();\n return {\n use(handler: Handler) {\n if (pluginId === defaultPluginId) {\n rootRouter.use(handler);\n } else {\n apiRouter.use(`/${pluginId}`, handler);\n }\n },\n };\n };\n },\n});\n"],"names":["__privateAdd","__privateGet","__privateSet","createServiceFactory","coreServices","loggerToWinstonLogger","__privateMethod","stringifyError","CacheManager","loadBackendConfig","DatabaseManager","SingleHostDiscovery","createRootLogger","ServerPermissionClient","TaskScheduler","ServerTokenManager","UrlReaders","Router","createServiceBuilder"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,SAAA,EAAA,cAAA,CAAA;AAwBA,MAAM,SAAY,GA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AACzB,IAAA,MAAM,aAAaA,0BAAO,EAAA,CAAA;AAE1B,IAAA,MAAM,OAAU,GAAAC,kCAAA,CAAqB,MAAM,CAAA,CACxC,UAAW,CAAA,MAAM,CACjB,CAAA,SAAA,CAAU,MAAQ,EAAA,SAAS,CAC3B,CAAA,SAAA,CAAU,IAAI,UAAU,CAAA,CAAA;AAE3B,IAAA,MAAM,QAAQ,KAAM,EAAA,CAAA;AAEpB,IAAO,OAAA,OAAO,EAAE,MAAA,EAAa,KAAA;AAC3B,MAAM,MAAA,QAAA,GAAW,OAAO,KAAM,EAAA,CAAA;AAC9B,MAAO,OAAA;AAAA,QACL,IAAI,OAAkB,EAAA;AACpB,UAAA,IAAI,aAAa,eAAiB,EAAA;AAChC,YAAA,UAAA,CAAW,IAAI,OAAO,CAAA,CAAA;AAAA,WACjB,MAAA;AACL,YAAU,SAAA,CAAA,GAAA,CAAI,CAAI,CAAA,EAAA,QAAA,CAAA,CAAA,EAAY,OAAO,CAAA,CAAA;AAAA,WACvC;AAAA,SACF;AAAA,OACF,CAAA;AAAA,KACF,CAAA;AAAA,GACF;AACF,CAAC;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/services/implementations/rootLifecycleService.ts","../src/wiring/BackendInitializer.ts","../src/wiring/ServiceRegistry.ts","../src/wiring/BackstageBackend.ts","../src/wiring/types.ts","../src/services/implementations/cacheService.ts","../src/services/implementations/configService.ts","../src/services/implementations/databaseService.ts","../src/services/implementations/discoveryService.ts","../src/services/implementations/loggerService.ts","../src/services/implementations/rootLoggerService.ts","../src/services/implementations/permissionsService.ts","../src/services/implementations/schedulerService.ts","../src/services/implementations/tokenManagerService.ts","../src/services/implementations/urlReaderService.ts","../src/services/implementations/httpRouterService.ts","../src/services/implementations/lifecycleService.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 */\nimport {\n createServiceFactory,\n coreServices,\n loggerToWinstonLogger,\n LifecycleServiceShutdownHook,\n RootLifecycleService,\n} from '@backstage/backend-plugin-api';\nimport { Logger } from 'winston';\n\nconst CALLBACKS = ['SIGTERM', 'SIGINT', 'beforeExit'];\nexport class BackendLifecycleImpl implements RootLifecycleService {\n constructor(private readonly logger: Logger) {\n CALLBACKS.map(signal => process.on(signal, () => this.shutdown()));\n }\n\n #isCalled = false;\n #shutdownTasks: Array<LifecycleServiceShutdownHook> = [];\n\n addShutdownHook(options: LifecycleServiceShutdownHook): void {\n this.#shutdownTasks.push(options);\n }\n\n async shutdown(): Promise<void> {\n if (this.#isCalled) {\n return;\n }\n this.#isCalled = true;\n\n this.logger.info(`Running ${this.#shutdownTasks.length} shutdown tasks...`);\n await Promise.all(\n this.#shutdownTasks.map(async hook => {\n try {\n await hook.fn();\n this.logger.info(`Shutdown hook succeeded`, hook.labels);\n } catch (error) {\n this.logger.error(`Shutdown hook failed, ${error}`, hook.labels);\n }\n }),\n );\n }\n}\n\n/**\n * Allows plugins to register shutdown hooks that are run when the process is about to exit.\n * @public */\nexport const rootLifecycleFactory = createServiceFactory({\n service: coreServices.rootLifecycle,\n deps: {\n logger: coreServices.rootLogger,\n },\n async factory({ logger }) {\n return new BackendLifecycleImpl(loggerToWinstonLogger(logger));\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 BackendFeature,\n ExtensionPoint,\n coreServices,\n ServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { BackendLifecycleImpl } from '../services/implementations/rootLifecycleService';\nimport {\n BackendRegisterInit,\n EnumerableServiceHolder,\n ServiceOrExtensionPoint,\n} from './types';\n\nexport class BackendInitializer {\n #started = false;\n #features = new Map<BackendFeature, unknown>();\n #registerInits = new Array<BackendRegisterInit>();\n #extensionPoints = new Map<ExtensionPoint<unknown>, unknown>();\n #serviceHolder: EnumerableServiceHolder;\n\n constructor(serviceHolder: EnumerableServiceHolder) {\n this.#serviceHolder = serviceHolder;\n }\n\n async #getInitDeps(\n deps: { [name: string]: ServiceOrExtensionPoint },\n pluginId: string,\n ) {\n const result = new Map<string, unknown>();\n const missingRefs = new Set<ServiceOrExtensionPoint>();\n\n for (const [name, ref] of Object.entries(deps)) {\n const extensionPoint = this.#extensionPoints.get(\n ref as ExtensionPoint<unknown>,\n );\n if (extensionPoint) {\n result.set(name, extensionPoint);\n } else {\n const impl = await this.#serviceHolder.get(\n ref as ServiceRef<unknown>,\n pluginId,\n );\n if (impl) {\n result.set(name, impl);\n } else {\n missingRefs.add(ref);\n }\n }\n }\n\n if (missingRefs.size > 0) {\n const missing = Array.from(missingRefs).join(', ');\n throw new Error(\n `No extension point or service available for the following ref(s): ${missing}`,\n );\n }\n\n return Object.fromEntries(result);\n }\n\n add<TOptions>(feature: BackendFeature, options?: TOptions) {\n if (this.#started) {\n throw new Error('feature can not be added after the backend has started');\n }\n this.#features.set(feature, options);\n }\n\n async start(): Promise<void> {\n if (this.#started) {\n throw new Error('Backend has already started');\n }\n this.#started = true;\n\n // Initialize all root scoped services\n for (const ref of this.#serviceHolder.getServiceRefs()) {\n if (ref.scope === 'root') {\n await this.#serviceHolder.get(ref, 'root');\n }\n }\n\n // Initialize all features\n for (const [feature] of this.#features) {\n const provides = new Set<ExtensionPoint<unknown>>();\n\n let registerInit: BackendRegisterInit | undefined = undefined;\n\n feature.register({\n registerExtensionPoint: (extensionPointRef, impl) => {\n if (registerInit) {\n throw new Error('registerExtensionPoint called after registerInit');\n }\n if (this.#extensionPoints.has(extensionPointRef)) {\n throw new Error(`API ${extensionPointRef.id} already registered`);\n }\n this.#extensionPoints.set(extensionPointRef, impl);\n provides.add(extensionPointRef);\n },\n registerInit: registerOptions => {\n if (registerInit) {\n throw new Error('registerInit must only be called once');\n }\n registerInit = {\n id: feature.id,\n provides,\n consumes: new Set(Object.values(registerOptions.deps)),\n deps: registerOptions.deps,\n init: registerOptions.init as BackendRegisterInit['init'],\n };\n },\n });\n\n if (!registerInit) {\n throw new Error(\n `registerInit was not called by register in ${feature.id}`,\n );\n }\n\n this.#registerInits.push(registerInit);\n }\n\n const orderedRegisterResults = this.#resolveInitOrder(this.#registerInits);\n\n for (const registerInit of orderedRegisterResults) {\n const deps = await this.#getInitDeps(registerInit.deps, registerInit.id);\n await registerInit.init(deps);\n }\n }\n\n #resolveInitOrder(registerInits: Array<BackendRegisterInit>) {\n let registerInitsToOrder = registerInits.slice();\n const orderedRegisterInits = new Array<BackendRegisterInit>();\n\n // TODO: Validate duplicates\n\n while (registerInitsToOrder.length > 0) {\n const toRemove = new Set<unknown>();\n\n for (const registerInit of registerInitsToOrder) {\n const unInitializedDependents = [];\n\n for (const provided of registerInit.provides) {\n if (\n registerInitsToOrder.some(\n init => init !== registerInit && init.consumes.has(provided),\n )\n ) {\n unInitializedDependents.push(provided);\n }\n }\n\n if (unInitializedDependents.length === 0) {\n orderedRegisterInits.push(registerInit);\n toRemove.add(registerInit);\n }\n }\n\n registerInitsToOrder = registerInitsToOrder.filter(r => !toRemove.has(r));\n }\n\n return orderedRegisterInits;\n }\n\n async stop(): Promise<void> {\n if (!this.#started) {\n return;\n }\n\n const lifecycleService = await this.#serviceHolder.get(\n coreServices.rootLifecycle,\n 'root',\n );\n\n // TODO(Rugvip): Find a better way to do this\n if (lifecycleService instanceof BackendLifecycleImpl) {\n await lifecycleService.shutdown();\n } else {\n throw new Error('Unexpected lifecycle service implementation');\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 {\n ServiceFactory,\n ServiceRef,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { stringifyError } from '@backstage/errors';\nimport { EnumerableServiceHolder } from './types';\n/**\n * Keep in sync with `@backstage/backend-plugin-api/src/services/system/types.ts`\n * @internal\n */\nexport type InternalServiceRef<T> = ServiceRef<T> & {\n __defaultFactory?: (\n service: ServiceRef<T>,\n ) => Promise<ServiceFactory<T> | (() => ServiceFactory<T>)>;\n};\n\nexport class ServiceRegistry implements EnumerableServiceHolder {\n readonly #providedFactories: Map<string, ServiceFactory>;\n readonly #loadedDefaultFactories: Map<Function, Promise<ServiceFactory>>;\n readonly #implementations: Map<\n ServiceFactory,\n {\n factoryFunc: Promise<\n (deps: { [name in string]: unknown }) => Promise<unknown>\n >;\n byPlugin: Map<string, Promise<unknown>>;\n }\n >;\n\n constructor(\n factories: Array<ServiceFactory<unknown> | (() => ServiceFactory<unknown>)>,\n ) {\n this.#providedFactories = new Map(\n factories.map(f => {\n if (typeof f === 'function') {\n const cf = f();\n return [cf.service.id, cf];\n }\n return [f.service.id, f];\n }),\n );\n this.#loadedDefaultFactories = new Map();\n this.#implementations = new Map();\n }\n\n #resolveFactory(\n ref: ServiceRef<unknown>,\n pluginId: string,\n ): Promise<ServiceFactory> | undefined {\n // Special case handling of the plugin metadata service, generating a custom factory for it each time\n if (ref.id === coreServices.pluginMetadata.id) {\n return Promise.resolve({\n scope: 'plugin',\n service: coreServices.pluginMetadata,\n deps: {},\n factory: async () => async () => ({\n getId() {\n return pluginId;\n },\n }),\n });\n }\n\n let resolvedFactory: Promise<ServiceFactory> | ServiceFactory | undefined =\n this.#providedFactories.get(ref.id);\n const { __defaultFactory: defaultFactory } =\n ref as InternalServiceRef<unknown>;\n if (!resolvedFactory && !defaultFactory) {\n return undefined;\n }\n\n if (!resolvedFactory) {\n let loadedFactory = this.#loadedDefaultFactories.get(defaultFactory!);\n if (!loadedFactory) {\n loadedFactory = Promise.resolve()\n .then(() => defaultFactory!(ref))\n .then(f =>\n typeof f === 'function' ? f() : f,\n ) as Promise<ServiceFactory>;\n this.#loadedDefaultFactories.set(defaultFactory!, loadedFactory);\n }\n resolvedFactory = loadedFactory.catch(error => {\n throw new Error(\n `Failed to instantiate service '${\n ref.id\n }' because the default factory loader threw an error, ${stringifyError(\n error,\n )}`,\n );\n });\n }\n\n return Promise.resolve(resolvedFactory);\n }\n\n #separateMapForTheRootService = new Map<ServiceFactory, Promise<unknown>>();\n\n #checkForMissingDeps(factory: ServiceFactory, pluginId: string) {\n const missingDeps = Object.values(factory.deps).filter(ref => {\n if (ref.id === coreServices.pluginMetadata.id) {\n return false;\n }\n if (this.#providedFactories.get(ref.id)) {\n return false;\n }\n\n return !(ref as InternalServiceRef<unknown>).__defaultFactory;\n });\n\n if (missingDeps.length) {\n const missing = missingDeps.map(r => `'${r.id}'`).join(', ');\n throw new Error(\n `Failed to instantiate service '${factory.service.id}' for '${pluginId}' because the following dependent services are missing: ${missing}`,\n );\n }\n }\n\n getServiceRefs(): ServiceRef<unknown>[] {\n return Array.from(this.#providedFactories.values()).map(f => f.service);\n }\n\n get<T>(ref: ServiceRef<T>, pluginId: string): Promise<T> | undefined {\n return this.#resolveFactory(ref, pluginId)?.then(factory => {\n if (factory.scope === 'root') {\n let existing = this.#separateMapForTheRootService.get(factory);\n if (!existing) {\n this.#checkForMissingDeps(factory, pluginId);\n const rootDeps = new Array<Promise<[name: string, impl: unknown]>>();\n\n for (const [name, serviceRef] of Object.entries(factory.deps)) {\n if (serviceRef.scope !== 'root') {\n throw new Error(\n `Failed to instantiate 'root' scoped service '${ref.id}' because it depends on '${serviceRef.scope}' scoped service '${serviceRef.id}'.`,\n );\n }\n const target = this.get(serviceRef, pluginId)!;\n rootDeps.push(target.then(impl => [name, impl]));\n }\n\n existing = Promise.all(rootDeps).then(entries =>\n factory.factory(Object.fromEntries(entries)),\n );\n this.#separateMapForTheRootService.set(factory, existing);\n }\n return existing as Promise<T>;\n }\n\n let implementation = this.#implementations.get(factory);\n if (!implementation) {\n this.#checkForMissingDeps(factory, pluginId);\n const rootDeps = new Array<Promise<[name: string, impl: unknown]>>();\n\n for (const [name, serviceRef] of Object.entries(factory.deps)) {\n if (serviceRef.scope === 'root') {\n const target = this.get(serviceRef, pluginId)!;\n rootDeps.push(target.then(impl => [name, impl]));\n }\n }\n\n implementation = {\n factoryFunc: Promise.all(rootDeps)\n .then(entries => factory.factory(Object.fromEntries(entries)))\n .catch(error => {\n const cause = stringifyError(error);\n throw new Error(\n `Failed to instantiate service '${ref.id}' because the top-level factory function threw an error, ${cause}`,\n );\n }),\n byPlugin: new Map(),\n };\n\n this.#implementations.set(factory, implementation);\n }\n\n let result = implementation.byPlugin.get(pluginId) as Promise<any>;\n if (!result) {\n const allDeps = new Array<Promise<[name: string, impl: unknown]>>();\n\n for (const [name, serviceRef] of Object.entries(factory.deps)) {\n const target = this.get(serviceRef, pluginId)!;\n allDeps.push(target.then(impl => [name, impl]));\n }\n\n result = implementation.factoryFunc\n .then(func =>\n Promise.all(allDeps).then(entries =>\n func(Object.fromEntries(entries)),\n ),\n )\n .catch(error => {\n const cause = stringifyError(error);\n throw new Error(\n `Failed to instantiate service '${ref.id}' for '${pluginId}' because the factory function threw an error, ${cause}`,\n );\n });\n implementation.byPlugin.set(pluginId, result);\n }\n\n return result;\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 { ServiceFactory, BackendFeature } from '@backstage/backend-plugin-api';\nimport { BackendInitializer } from './BackendInitializer';\nimport { ServiceRegistry } from './ServiceRegistry';\nimport { Backend } from './types';\n\nexport class BackstageBackend implements Backend {\n #services: ServiceRegistry;\n #initializer: BackendInitializer;\n\n constructor(apiFactories: ServiceFactory[]) {\n this.#services = new ServiceRegistry(apiFactories);\n this.#initializer = new BackendInitializer(this.#services);\n }\n\n add(feature: BackendFeature): void {\n this.#initializer.add(feature);\n }\n\n async start(): Promise<void> {\n await this.#initializer.start();\n }\n\n async stop(): Promise<void> {\n await this.#initializer.stop();\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 ServiceFactory,\n BackendFeature,\n ExtensionPoint,\n ServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { BackstageBackend } from './BackstageBackend';\n\n/**\n * @public\n */\nexport interface Backend {\n add(feature: BackendFeature): void;\n start(): Promise<void>;\n stop(): Promise<void>;\n}\n\nexport interface BackendRegisterInit {\n id: string;\n consumes: Set<ServiceOrExtensionPoint>;\n provides: Set<ServiceOrExtensionPoint>;\n deps: { [name: string]: ServiceOrExtensionPoint };\n init: (deps: { [name: string]: unknown }) => Promise<void>;\n}\n\n/**\n * @public\n */\nexport interface CreateSpecializedBackendOptions {\n services: (ServiceFactory | (() => ServiceFactory))[];\n}\n\nexport interface ServiceHolder {\n get<T>(api: ServiceRef<T>, pluginId: string): Promise<T> | undefined;\n}\n\n/**\n * @internal\n */\nexport interface EnumerableServiceHolder extends ServiceHolder {\n getServiceRefs(): ServiceRef<unknown>[];\n}\n\n/**\n * @public\n */\nexport function createSpecializedBackend(\n options: CreateSpecializedBackendOptions,\n): Backend {\n return new BackstageBackend(\n options.services.map(s => (typeof s === 'function' ? s() : s)),\n );\n}\n\n/**\n * @public\n */\nexport type ServiceOrExtensionPoint<T = unknown> =\n | ExtensionPoint<T>\n | ServiceRef<T>;\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 { CacheManager } from '@backstage/backend-common';\nimport {\n coreServices,\n createServiceFactory,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const cacheFactory = createServiceFactory({\n service: coreServices.cache,\n deps: {\n config: coreServices.config,\n plugin: coreServices.pluginMetadata,\n },\n async factory({ config }) {\n const cacheManager = CacheManager.fromConfig(config);\n return async ({ plugin }) => {\n return cacheManager.forPlugin(plugin.getId());\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 { loadBackendConfig } from '@backstage/backend-common';\nimport {\n coreServices,\n createServiceFactory,\n loggerToWinstonLogger,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const configFactory = createServiceFactory({\n service: coreServices.config,\n deps: {\n logger: coreServices.rootLogger,\n },\n async factory({ logger }) {\n const config = await loadBackendConfig({\n argv: process.argv,\n logger: loggerToWinstonLogger(logger),\n });\n return config;\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 { DatabaseManager } from '@backstage/backend-common';\nimport {\n coreServices,\n createServiceFactory,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const databaseFactory = createServiceFactory({\n service: coreServices.database,\n deps: {\n config: coreServices.config,\n plugin: coreServices.pluginMetadata,\n },\n async factory({ config }) {\n const databaseManager = DatabaseManager.fromConfig(config);\n return async ({ plugin }) => {\n return databaseManager.forPlugin(plugin.getId());\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 { SingleHostDiscovery } from '@backstage/backend-common';\nimport {\n coreServices,\n createServiceFactory,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const discoveryFactory = createServiceFactory({\n service: coreServices.discovery,\n deps: {\n config: coreServices.config,\n },\n async factory({ config }) {\n const discovery = SingleHostDiscovery.fromConfig(config);\n return async () => {\n return discovery;\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 {\n createServiceFactory,\n coreServices,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const loggerFactory = createServiceFactory({\n service: coreServices.logger,\n deps: {\n rootLogger: coreServices.rootLogger,\n plugin: coreServices.pluginMetadata,\n },\n async factory({ rootLogger }) {\n return async ({ plugin }) => {\n return rootLogger.child({ pluginId: plugin.getId() });\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 { createRootLogger } from '@backstage/backend-common';\nimport {\n createServiceFactory,\n LoggerService,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { LogMeta } from '@backstage/backend-plugin-api';\nimport { Logger as WinstonLogger } from 'winston';\n\nclass BackstageLogger implements LoggerService {\n static fromWinston(logger: WinstonLogger): BackstageLogger {\n return new BackstageLogger(logger);\n }\n\n private constructor(private readonly winston: WinstonLogger) {}\n\n error(message: string, meta?: LogMeta): void {\n this.winston.error(message, meta);\n }\n\n warn(message: string, meta?: LogMeta): void {\n this.winston.warn(message, meta);\n }\n\n info(message: string, meta?: LogMeta): void {\n this.winston.info(message, meta);\n }\n\n debug(message: string, meta?: LogMeta): void {\n this.winston.debug(message, meta);\n }\n\n child(meta: LogMeta): LoggerService {\n return new BackstageLogger(this.winston.child(meta));\n }\n}\n\n/** @public */\nexport const rootLoggerFactory = createServiceFactory({\n service: coreServices.rootLogger,\n deps: {},\n async factory() {\n return BackstageLogger.fromWinston(createRootLogger());\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 coreServices,\n createServiceFactory,\n} from '@backstage/backend-plugin-api';\nimport { ServerPermissionClient } from '@backstage/plugin-permission-node';\n\n/** @public */\nexport const permissionsFactory = createServiceFactory({\n service: coreServices.permissions,\n deps: {\n config: coreServices.config,\n discovery: coreServices.discovery,\n tokenManager: coreServices.tokenManager,\n },\n async factory({ config }) {\n return async ({ discovery, tokenManager }) => {\n return ServerPermissionClient.fromConfig(config, {\n discovery,\n tokenManager,\n });\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 {\n coreServices,\n createServiceFactory,\n} from '@backstage/backend-plugin-api';\nimport { TaskScheduler } from '@backstage/backend-tasks';\n\n/** @public */\nexport const schedulerFactory = createServiceFactory({\n service: coreServices.scheduler,\n deps: {\n config: coreServices.config,\n plugin: coreServices.pluginMetadata,\n },\n async factory({ config }) {\n const taskScheduler = TaskScheduler.fromConfig(config);\n return async ({ plugin }) => {\n return taskScheduler.forPlugin(plugin.getId());\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 {\n coreServices,\n createServiceFactory,\n loggerToWinstonLogger,\n} from '@backstage/backend-plugin-api';\nimport { ServerTokenManager } from '@backstage/backend-common';\n\n/** @public */\nexport const tokenManagerFactory = createServiceFactory({\n service: coreServices.tokenManager,\n deps: {\n config: coreServices.config,\n logger: coreServices.logger,\n },\n async factory() {\n return async ({ config, logger }) => {\n return ServerTokenManager.fromConfig(config, {\n logger: loggerToWinstonLogger(logger),\n });\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 { UrlReaders } from '@backstage/backend-common';\nimport {\n coreServices,\n createServiceFactory,\n loggerToWinstonLogger,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const urlReaderFactory = createServiceFactory({\n service: coreServices.urlReader,\n deps: {\n config: coreServices.config,\n logger: coreServices.logger,\n },\n async factory() {\n return async ({ config, logger }) => {\n return UrlReaders.default({\n config,\n logger: loggerToWinstonLogger(logger),\n });\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 {\n createServiceFactory,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport Router from 'express-promise-router';\nimport { Handler } from 'express';\nimport { createServiceBuilder } from '@backstage/backend-common';\n\n/**\n * @public\n */\nexport type HttpRouterFactoryOptions = {\n /**\n * The plugin ID used for the index route. Defaults to 'app'\n */\n indexPlugin?: string;\n};\n\n/** @public */\nexport const httpRouterFactory = createServiceFactory({\n service: coreServices.httpRouter,\n deps: {\n config: coreServices.config,\n plugin: coreServices.pluginMetadata,\n },\n async factory({ config }, options?: HttpRouterFactoryOptions) {\n const defaultPluginId = options?.indexPlugin ?? 'app';\n\n const apiRouter = Router();\n const rootRouter = Router();\n\n const service = createServiceBuilder(module)\n .loadConfig(config)\n .addRouter('/api', apiRouter)\n .addRouter('', rootRouter);\n\n await service.start();\n\n return async ({ plugin }) => {\n const pluginId = plugin.getId();\n return {\n use(handler: Handler) {\n if (pluginId === defaultPluginId) {\n rootRouter.use(handler);\n } else {\n apiRouter.use(`/${pluginId}`, handler);\n }\n },\n };\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 */\nimport {\n createServiceFactory,\n coreServices,\n LifecycleServiceShutdownHook,\n} from '@backstage/backend-plugin-api';\n\n/**\n * Allows plugins to register shutdown hooks that are run when the process is about to exit.\n * @public */\nexport const lifecycleFactory = createServiceFactory({\n service: coreServices.lifecycle,\n deps: {\n rootLifecycle: coreServices.rootLifecycle,\n pluginMetadata: coreServices.pluginMetadata,\n },\n async factory({ rootLifecycle }) {\n return async ({ pluginMetadata }) => {\n const plugin = pluginMetadata.getId();\n return {\n addShutdownHook(options: LifecycleServiceShutdownHook): void {\n rootLifecycle.addShutdownHook({\n ...options,\n labels: { ...options?.labels, plugin },\n });\n },\n };\n };\n },\n});\n"],"names":["__privateAdd","__privateGet","__privateSet","createServiceFactory","coreServices","loggerToWinstonLogger","__privateMethod","stringifyError","CacheManager","loadBackendConfig","DatabaseManager","SingleHostDiscovery","createRootLogger","ServerPermissionClient","TaskScheduler","ServerTokenManager","UrlReaders","Router","createServiceBuilder"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,SAAA,EAAA,cAAA,CAAA;AAwBA,MAAM,SAAY,GAAA,CAAC,SAAW,EAAA,QAAA,EAAU,YAAY,CAAA,CAAA;AAC7C,MAAM,oBAAqD,CAAA;AAAA,EAChE,YAA6B,MAAgB,EAAA;AAAhB,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA,CAAA;AAI7B,IAAYA,cAAA,CAAA,IAAA,EAAA,SAAA,EAAA,KAAA,CAAA,CAAA;AACZ,IAAAA,cAAA,CAAA,IAAA,EAAA,cAAA,EAAsD,EAAC,CAAA,CAAA;AAJrD,IAAU,SAAA,CAAA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,MAAA,MAAA,GAAS,eAAe,KAAM,EAAA,CAAA;AACpC,MAAO,OAAA;AAAA,QACL,gBAAgB,OAA6C,EAAA;AAC3D,UAAA,aAAA,CAAc,eAAgB,CAAA;AAAA,YAC5B,GAAG,OAAA;AAAA,YACH,MAAQ,EAAA,EAAE,GAAG,OAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,OAAA,CAAS,QAAQ,MAAO,EAAA;AAAA,WACtC,CAAA,CAAA;AAAA,SACH;AAAA,OACF,CAAA;AAAA,KACF,CAAA;AAAA,GACF;AACF,CAAC;;;;;;;;;;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -77,6 +77,11 @@ export declare const loggerFactory: (options?: undefined) => ServiceFactory<Logg
77
77
  /** @public */
78
78
  export declare const permissionsFactory: (options?: undefined) => ServiceFactory<PermissionsService>;
79
79
 
80
+ /**
81
+ * Allows plugins to register shutdown hooks that are run when the process is about to exit.
82
+ * @public */
83
+ export declare const rootLifecycleFactory: (options?: undefined) => ServiceFactory<LifecycleService>;
84
+
80
85
  /** @public */
81
86
  export declare const rootLoggerFactory: (options?: undefined) => ServiceFactory<LoggerService>;
82
87
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@backstage/backend-app-api",
3
3
  "description": "Core API used by Backstage backend apps",
4
- "version": "0.2.4",
4
+ "version": "0.2.5-next.0",
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-common": "^0.17.0",
37
- "@backstage/backend-plugin-api": "^0.2.0",
38
- "@backstage/backend-tasks": "^0.4.0",
36
+ "@backstage/backend-common": "^0.18.0-next.0",
37
+ "@backstage/backend-plugin-api": "^0.2.1-next.0",
38
+ "@backstage/backend-tasks": "^0.4.1-next.0",
39
39
  "@backstage/errors": "^1.1.4",
40
- "@backstage/plugin-permission-node": "^0.7.2",
40
+ "@backstage/plugin-permission-node": "^0.7.3-next.0",
41
41
  "express": "^4.17.1",
42
42
  "express-promise-router": "^4.1.0",
43
43
  "winston": "^3.2.1"
44
44
  },
45
45
  "devDependencies": {
46
- "@backstage/cli": "^0.22.0"
46
+ "@backstage/cli": "^0.22.1-next.1"
47
47
  },
48
48
  "files": [
49
49
  "dist",