@backstage/backend-plugin-api 0.2.1-next.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -2,15 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var winston = require('winston');
6
- var Transport = require('winston-transport');
7
-
8
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
-
10
- var Transport__default = /*#__PURE__*/_interopDefaultLegacy(Transport);
11
-
12
- function createServiceRef(options) {
13
- const { id, scope = "plugin", defaultFactory } = options;
5
+ function createServiceRef(config) {
6
+ const { id, scope = "plugin", defaultFactory } = config;
14
7
  return {
15
8
  id,
16
9
  scope,
@@ -18,173 +11,126 @@ function createServiceRef(options) {
18
11
  throw new Error(`tried to read ServiceRef.T of ${this}`);
19
12
  },
20
13
  toString() {
21
- return `serviceRef{${options.id}}`;
14
+ return `serviceRef{${config.id}}`;
22
15
  },
23
16
  $$ref: "service",
17
+ // TODO: declare
24
18
  __defaultFactory: defaultFactory
25
19
  };
26
20
  }
27
21
  function createServiceFactory(config) {
28
- return (options) => ({
29
- scope: config.service.scope,
30
- service: config.service,
31
- deps: config.deps,
32
- factory(deps) {
33
- return config.factory(deps, options);
34
- }
35
- });
22
+ const configCallback = typeof config === "function" ? config : () => config;
23
+ return (options) => {
24
+ const c = configCallback(options);
25
+ return {
26
+ ...c,
27
+ ..."createRootContext" in c ? {
28
+ createRootContext: async (deps) => {
29
+ var _a;
30
+ return (_a = c == null ? void 0 : c.createRootContext) == null ? void 0 : _a.call(c, deps);
31
+ }
32
+ } : {},
33
+ factory: async (deps, ctx) => c.factory(deps, ctx),
34
+ scope: c.service.scope
35
+ };
36
+ };
36
37
  }
37
38
 
38
- const configServiceRef = createServiceRef({
39
- id: "core.root.config",
40
- scope: "root"
41
- });
42
-
43
- const httpRouterServiceRef = createServiceRef({
44
- id: "core.httpRouter"
45
- });
46
-
47
- const loggerServiceRef = createServiceRef({
48
- id: "core.logger"
49
- });
50
-
51
- const urlReaderServiceRef = createServiceRef({
52
- id: "core.urlReader"
53
- });
54
-
55
- const cacheServiceRef = createServiceRef({
56
- id: "core.cache"
57
- });
58
-
59
- const databaseServiceRef = createServiceRef({
60
- id: "core.database"
61
- });
62
-
63
- const discoveryServiceRef = createServiceRef({
64
- id: "core.discovery"
65
- });
66
-
67
- const tokenManagerServiceRef = createServiceRef({
68
- id: "core.tokenManager"
69
- });
70
-
71
- const permissionsServiceRef = createServiceRef({
72
- id: "core.permissions"
73
- });
74
-
75
- const schedulerServiceRef = createServiceRef({
76
- id: "core.scheduler"
77
- });
78
-
79
- const rootLifecycleServiceRef = createServiceRef({
80
- id: "core.rootLifecycle",
81
- scope: "root"
82
- });
83
-
84
- const rootLoggerServiceRef = createServiceRef({
85
- id: "core.root.logger",
86
- scope: "root"
87
- });
88
-
89
- const pluginMetadataServiceRef = createServiceRef(
90
- {
91
- id: "core.plugin-metadata"
92
- }
93
- );
94
-
95
- const lifecycleServiceRef = createServiceRef({
96
- id: "core.lifecycle",
97
- scope: "plugin"
98
- });
99
-
100
- var coreServices = /*#__PURE__*/Object.freeze({
101
- __proto__: null,
102
- config: configServiceRef,
103
- httpRouter: httpRouterServiceRef,
104
- logger: loggerServiceRef,
105
- urlReader: urlReaderServiceRef,
106
- cache: cacheServiceRef,
107
- database: databaseServiceRef,
108
- discovery: discoveryServiceRef,
109
- tokenManager: tokenManagerServiceRef,
110
- permissions: permissionsServiceRef,
111
- scheduler: schedulerServiceRef,
112
- rootLifecycle: rootLifecycleServiceRef,
113
- rootLogger: rootLoggerServiceRef,
114
- pluginMetadata: pluginMetadataServiceRef,
115
- lifecycle: lifecycleServiceRef
116
- });
117
-
118
- class BackstageLoggerTransport extends Transport__default["default"] {
119
- constructor(backstageLogger, opts) {
120
- super(opts);
121
- this.backstageLogger = backstageLogger;
122
- }
123
- log(info, callback) {
124
- if (typeof info !== "object" || info === null) {
125
- callback();
126
- return;
39
+ exports.coreServices = void 0;
40
+ ((coreServices2) => {
41
+ coreServices2.cache = createServiceRef({
42
+ id: "core.cache"
43
+ });
44
+ coreServices2.config = createServiceRef({ id: "core.config", scope: "root" });
45
+ coreServices2.database = createServiceRef({ id: "core.database" });
46
+ coreServices2.discovery = createServiceRef({ id: "core.discovery" });
47
+ coreServices2.httpRouter = createServiceRef({ id: "core.httpRouter" });
48
+ coreServices2.lifecycle = createServiceRef({ id: "core.lifecycle" });
49
+ coreServices2.logger = createServiceRef({ id: "core.logger" });
50
+ coreServices2.permissions = createServiceRef({ id: "core.permissions" });
51
+ coreServices2.pluginMetadata = createServiceRef({ id: "core.pluginMetadata" });
52
+ coreServices2.rootHttpRouter = createServiceRef({ id: "core.rootHttpRouter", scope: "root" });
53
+ coreServices2.rootLifecycle = createServiceRef({ id: "core.rootLifecycle", scope: "root" });
54
+ coreServices2.rootLogger = createServiceRef({ id: "core.rootLogger", scope: "root" });
55
+ coreServices2.scheduler = createServiceRef({ id: "core.scheduler" });
56
+ coreServices2.tokenManager = createServiceRef({ id: "core.tokenManager" });
57
+ coreServices2.urlReader = createServiceRef({ id: "core.urlReader" });
58
+ coreServices2.identity = createServiceRef({ id: "core.identity" });
59
+ })(exports.coreServices || (exports.coreServices = {}));
60
+
61
+ function createSharedEnvironment(config) {
62
+ const configCallback = typeof config === "function" ? config : () => config;
63
+ return (...options) => {
64
+ var _a;
65
+ const actualConfig = configCallback(...options);
66
+ const services = (_a = actualConfig == null ? void 0 : actualConfig.services) == null ? void 0 : _a.map(
67
+ (sf) => typeof sf === "function" ? sf() : sf
68
+ );
69
+ const exists = /* @__PURE__ */ new Set();
70
+ const duplicates = /* @__PURE__ */ new Set();
71
+ for (const { service } of services != null ? services : []) {
72
+ if (exists.has(service.id)) {
73
+ duplicates.add(service.id);
74
+ } else {
75
+ exists.add(service.id);
76
+ }
127
77
  }
128
- const { level, message, ...meta } = info;
129
- switch (level) {
130
- case "error":
131
- this.backstageLogger.error(String(message), meta);
132
- break;
133
- case "warn":
134
- this.backstageLogger.warn(String(message), meta);
135
- break;
136
- case "info":
137
- this.backstageLogger.info(String(message), meta);
138
- break;
139
- case "debug":
140
- this.backstageLogger.debug(String(message), meta);
141
- break;
142
- default:
143
- this.backstageLogger.info(String(message), meta);
78
+ if (duplicates.size > 0) {
79
+ const dupStr = [...duplicates].map((id) => `'${id}'`).join(", ");
80
+ throw new Error(
81
+ `Duplicate service implementations provided in shared environment for ${dupStr}`
82
+ );
144
83
  }
145
- callback();
146
- }
147
- }
148
- function loggerToWinstonLogger(logger, opts) {
149
- return winston.createLogger({
150
- transports: [new BackstageLoggerTransport(logger, opts)]
151
- });
84
+ const env = {
85
+ $$type: "SharedBackendEnvironment",
86
+ version: "v1",
87
+ services
88
+ };
89
+ return env;
90
+ };
152
91
  }
153
92
 
154
- function createExtensionPoint(options) {
93
+ function createExtensionPoint(config) {
155
94
  return {
156
- id: options.id,
95
+ id: config.id,
157
96
  get T() {
158
97
  throw new Error(`tried to read ExtensionPoint.T of ${this}`);
159
98
  },
160
99
  toString() {
161
- return `extensionPoint{${options.id}}`;
100
+ return `extensionPoint{${config.id}}`;
162
101
  },
163
102
  $$ref: "extension-point"
103
+ // TODO: declare
164
104
  };
165
105
  }
166
106
  function createBackendPlugin(config) {
167
- return (options) => ({
168
- id: config.id,
169
- register(register) {
170
- return config.register(register, options);
171
- }
172
- });
107
+ if (typeof config === "function") {
108
+ return config;
109
+ }
110
+ return () => config;
173
111
  }
174
112
  function createBackendModule(config) {
175
- return (options) => ({
113
+ if (typeof config === "function") {
114
+ return (...options) => {
115
+ const c = config(...options);
116
+ return {
117
+ id: `${c.pluginId}.${c.moduleId}`,
118
+ register: c.register
119
+ };
120
+ };
121
+ }
122
+ return () => ({
176
123
  id: `${config.pluginId}.${config.moduleId}`,
177
124
  register(register) {
178
- return config.register(register, options);
125
+ return config.register(register);
179
126
  }
180
127
  });
181
128
  }
182
129
 
183
- exports.coreServices = coreServices;
184
130
  exports.createBackendModule = createBackendModule;
185
131
  exports.createBackendPlugin = createBackendPlugin;
186
132
  exports.createExtensionPoint = createExtensionPoint;
187
133
  exports.createServiceFactory = createServiceFactory;
188
134
  exports.createServiceRef = createServiceRef;
189
- exports.loggerToWinstonLogger = loggerToWinstonLogger;
135
+ exports.createSharedEnvironment = createSharedEnvironment;
190
136
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/services/system/types.ts","../src/services/definitions/configServiceRef.ts","../src/services/definitions/httpRouterServiceRef.ts","../src/services/definitions/loggerServiceRef.ts","../src/services/definitions/urlReaderServiceRef.ts","../src/services/definitions/cacheServiceRef.ts","../src/services/definitions/databaseServiceRef.ts","../src/services/definitions/discoveryServiceRef.ts","../src/services/definitions/tokenManagerServiceRef.ts","../src/services/definitions/permissionsServiceRef.ts","../src/services/definitions/schedulerServiceRef.ts","../src/services/definitions/rootLifecycleServiceRef.ts","../src/services/definitions/rootLoggerServiceRef.ts","../src/services/definitions/pluginMetadataServiceRef.ts","../src/services/definitions/lifecycleServiceRef.ts","../src/services/helpers/loggerToWinstonLogger.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/** @public */\nexport function createServiceRef<T>(options: {\n id: string;\n scope?: 'plugin';\n defaultFactory?: (\n service: ServiceRef<T, 'plugin'>,\n ) => Promise<ServiceFactory<T> | (() => ServiceFactory<T>)>;\n}): ServiceRef<T, 'plugin'>;\n/** @public */\nexport function createServiceRef<T>(options: {\n id: string;\n scope: 'root';\n defaultFactory?: (\n service: ServiceRef<T, 'root'>,\n ) => Promise<ServiceFactory<T> | (() => ServiceFactory<T>)>;\n}): ServiceRef<T, 'root'>;\nexport function createServiceRef<T>(options: {\n id: string;\n scope?: 'plugin' | 'root';\n defaultFactory?:\n | ((\n service: ServiceRef<T, 'plugin'>,\n ) => Promise<ServiceFactory<T> | (() => ServiceFactory<T>)>)\n | ((\n service: ServiceRef<T, 'root'>,\n ) => Promise<ServiceFactory<T> | (() => ServiceFactory<T>)>);\n}): ServiceRef<T> {\n const { id, scope = 'plugin', defaultFactory } = options;\n return {\n id,\n scope,\n get T(): T {\n throw new Error(`tried to read ServiceRef.T of ${this}`);\n },\n toString() {\n return `serviceRef{${options.id}}`;\n },\n $$ref: 'service', // TODO: declare\n __defaultFactory: defaultFactory,\n } as ServiceRef<T, typeof scope> & {\n __defaultFactory?: (\n service: ServiceRef<T>,\n ) => Promise<ServiceFactory<T> | (() => ServiceFactory<T>)>;\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/**\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 object | undefined = undefined,\n>(config: {\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}): undefined extends TOpts\n ? (options?: TOpts) => ServiceFactory<TService>\n : (options: TOpts) => ServiceFactory<TService> {\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 { Config } from '@backstage/config';\nimport { createServiceRef } from '../system/types';\n\n/**\n * @public\n */\nexport type ConfigService = Config;\n\n/**\n * @public\n */\nexport const configServiceRef = createServiceRef<ConfigService>({\n id: 'core.root.config',\n scope: 'root',\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/types';\nimport { Handler } from 'express';\n\n/**\n * @public\n */\nexport interface HttpRouterService {\n use(handler: Handler): void;\n}\n\n/**\n * @public\n */\nexport const httpRouterServiceRef = createServiceRef<HttpRouterService>({\n id: 'core.httpRouter',\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/types';\n\n/**\n * @public\n */\nexport type LogMeta = { [name: string]: unknown };\n\n/**\n * @public\n */\nexport interface LoggerService {\n error(message: string, meta?: Error | LogMeta): void;\n warn(message: string, meta?: Error | LogMeta): void;\n info(message: string, meta?: Error | LogMeta): void;\n debug(message: string, meta?: Error | LogMeta): void;\n\n child(meta: LogMeta): LoggerService;\n}\n\n/**\n * @public\n */\nexport const loggerServiceRef = createServiceRef<LoggerService>({\n id: 'core.logger',\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/types';\nimport { Readable } from 'stream';\n\n/**\n * A generic interface for fetching plain data from URLs.\n *\n * @public\n */\nexport type UrlReaderService = {\n /**\n * Reads a single file and return its content.\n */\n readUrl(url: string, options?: ReadUrlOptions): Promise<ReadUrlResponse>;\n\n /**\n * Reads a full or partial file tree.\n */\n readTree(url: string, options?: ReadTreeOptions): Promise<ReadTreeResponse>;\n\n /**\n * Searches for a file in a tree using a glob pattern.\n */\n search(url: string, options?: SearchOptions): Promise<SearchResponse>;\n};\n\n/**\n * An options object for readUrl operations.\n *\n * @public\n */\nexport type ReadUrlOptions = {\n /**\n * An ETag which can be provided to check whether a\n * {@link UrlReaderService.readUrl} response has changed from a previous execution.\n *\n * @remarks\n *\n * In the {@link UrlReaderService.readUrl} response, an ETag is returned along with\n * the data. The ETag is a unique identifier of the data, usually the commit\n * SHA or ETag from the target.\n *\n * When an ETag is given in ReadUrlOptions, {@link UrlReaderService.readUrl} will\n * first compare the ETag against the ETag of the target. If they match,\n * {@link UrlReaderService.readUrl} will throw a\n * {@link @backstage/errors#NotModifiedError} indicating that the response\n * will not differ from the previous response which included this particular\n * ETag. If they do not match, {@link UrlReaderService.readUrl} will return the rest\n * of the response along with a new ETag.\n */\n etag?: string;\n\n /**\n * An abort signal to pass down to the underlying request.\n *\n * @remarks\n *\n * Not all reader implementations may take this field into account.\n */\n signal?: AbortSignal;\n};\n\n/**\n * A response object for {@link UrlReaderService.readUrl} operations.\n *\n * @public\n */\nexport type ReadUrlResponse = {\n /**\n * Returns the data that was read from the remote URL.\n */\n buffer(): Promise<Buffer>;\n\n /**\n * Returns the data that was read from the remote URL as a Readable stream.\n *\n * @remarks\n *\n * This method will be required in a future release.\n */\n stream?(): Readable;\n\n /**\n * Etag returned by content provider.\n *\n * @remarks\n *\n * Can be used to compare and cache responses when doing subsequent calls.\n */\n etag?: string;\n};\n\n/**\n * An options object for {@link UrlReaderService.readTree} operations.\n *\n * @public\n */\nexport type ReadTreeOptions = {\n /**\n * A filter that can be used to select which files should be included.\n *\n * @remarks\n *\n * The path passed to the filter function is the relative path from the URL\n * that the file tree is fetched from, without any leading '/'.\n *\n * For example, given the URL https://github.com/my/repo/tree/master/my-dir, a file\n * at https://github.com/my/repo/blob/master/my-dir/my-subdir/my-file.txt will\n * be represented as my-subdir/my-file.txt\n *\n * If no filter is provided, all files are extracted.\n */\n filter?(path: string, info?: { size: number }): boolean;\n\n /**\n * An ETag which can be provided to check whether a\n * {@link UrlReaderService.readTree} response has changed from a previous execution.\n *\n * @remarks\n *\n * In the {@link UrlReaderService.readTree} response, an ETag is returned along with\n * the tree blob. The ETag is a unique identifier of the tree blob, usually\n * the commit SHA or ETag from the target.\n *\n * When an ETag is given as a request option, {@link UrlReaderService.readTree} will\n * first compare the ETag against the ETag on the target branch. If they\n * match, {@link UrlReaderService.readTree} will throw a\n * {@link @backstage/errors#NotModifiedError} indicating that the response\n * will not differ from the previous response which included this particular\n * ETag. If they do not match, {@link UrlReaderService.readTree} will return the\n * rest of the response along with a new ETag.\n */\n etag?: string;\n\n /**\n * An abort signal to pass down to the underlying request.\n *\n * @remarks\n *\n * Not all reader implementations may take this field into account.\n */\n signal?: AbortSignal;\n};\n\n/**\n * Options that control {@link ReadTreeResponse.dir} execution.\n *\n * @public\n */\nexport type ReadTreeResponseDirOptions = {\n /**\n * The directory to write files to.\n *\n * @remarks\n *\n * Defaults to the OS tmpdir, or `backend.workingDirectory` if set in config.\n */\n targetDir?: string;\n};\n\n/**\n * A response object for {@link UrlReaderService.readTree} operations.\n *\n * @public\n */\nexport type ReadTreeResponse = {\n /**\n * Returns an array of all the files inside the tree, and corresponding\n * functions to read their content.\n */\n files(): Promise<ReadTreeResponseFile[]>;\n\n /**\n * Returns the tree contents as a binary archive, using a stream.\n */\n archive(): Promise<NodeJS.ReadableStream>;\n\n /**\n * Extracts the tree response into a directory and returns the path of the\n * directory.\n *\n * **NOTE**: It is the responsibility of the caller to remove the directory after use.\n */\n dir(options?: ReadTreeResponseDirOptions): Promise<string>;\n\n /**\n * Etag returned by content provider.\n *\n * @remarks\n *\n * Can be used to compare and cache responses when doing subsequent calls.\n */\n etag: string;\n};\n\n/**\n * Represents a single file in a {@link UrlReaderService.readTree} response.\n *\n * @public\n */\nexport type ReadTreeResponseFile = {\n path: string;\n content(): Promise<Buffer>;\n};\n\n/**\n * An options object for search operations.\n *\n * @public\n */\nexport type SearchOptions = {\n /**\n * An etag can be provided to check whether the search response has changed from a previous execution.\n *\n * In the search() response, an etag is returned along with the files. The etag is a unique identifier\n * of the current tree, usually the commit SHA or etag from the target.\n *\n * When an etag is given in SearchOptions, search will first compare the etag against the etag\n * on the target branch. If they match, search will throw a NotModifiedError indicating that the search\n * response will not differ from the previous response which included this particular etag. If they mismatch,\n * search will return the rest of SearchResponse along with a new etag.\n */\n etag?: string;\n\n /**\n * An abort signal to pass down to the underlying request.\n *\n * @remarks\n *\n * Not all reader implementations may take this field into account.\n */\n signal?: AbortSignal;\n};\n\n/**\n * The output of a search operation.\n *\n * @public\n */\nexport type SearchResponse = {\n /**\n * The files that matched the search query.\n */\n files: SearchResponseFile[];\n\n /**\n * A unique identifier of the current remote tree, usually the commit SHA or etag from the target.\n */\n etag: string;\n};\n\n/**\n * Represents a single file in a search response.\n *\n * @public\n */\nexport type SearchResponseFile = {\n /**\n * The full URL to the file.\n */\n url: string;\n\n /**\n * The binary contents of the file.\n */\n content(): Promise<Buffer>;\n};\n\n/**\n * @public\n */\nexport const urlReaderServiceRef = createServiceRef<UrlReaderService>({\n id: 'core.urlReader',\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/types';\nimport { PluginCacheManager } from '@backstage/backend-common';\n\n/** @public */\nexport type CacheService = PluginCacheManager;\n\n/**\n * @public\n */\nexport const cacheServiceRef = createServiceRef<CacheService>({\n id: 'core.cache',\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 { PluginDatabaseManager } from '@backstage/backend-common';\nimport { createServiceRef } from '../system/types';\n\n/** @public */\nexport type DatabaseService = PluginDatabaseManager;\n\n/**\n * @public\n */\nexport const databaseServiceRef = createServiceRef<DatabaseService>({\n id: 'core.database',\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/types';\n\n/**\n * The DiscoveryService is used to provide a mechanism for backend\n * plugins to discover the endpoints for itself or other backend plugins.\n *\n * The purpose of the discovery API is to allow for many different deployment\n * setups and routing methods through a central configuration, instead\n * of letting each individual plugin manage that configuration.\n *\n * Implementations of the discovery API can be as simple as a URL pattern\n * using the pluginId, but could also have overrides for individual plugins,\n * or query a separate discovery service.\n *\n * @public\n */\nexport type DiscoveryService = {\n /**\n * Returns the internal HTTP base URL for a given plugin, without a trailing slash.\n *\n * The returned URL should point to an internal endpoint for the plugin, with\n * the shortest route possible. The URL should be used for service-to-service\n * communication within a Backstage backend deployment.\n *\n * This method must always be called just before making a request, as opposed to\n * fetching the URL when constructing an API client. That is to ensure that more\n * flexible routing patterns can be supported.\n *\n * For example, asking for the URL for `catalog` may return something\n * like `http://10.1.2.3/api/catalog`\n */\n getBaseUrl(pluginId: string): Promise<string>;\n\n /**\n * Returns the external HTTP base backend URL for a given plugin, without a trailing slash.\n *\n * The returned URL should point to an external endpoint for the plugin, such that\n * it is reachable from the Backstage frontend and other external services. The returned\n * URL should be usable for example as a callback / webhook URL.\n *\n * The returned URL should be stable and in general not change unless other static\n * or external configuration is changed. Changes should not come as a surprise\n * to an operator of the Backstage backend.\n *\n * For example, asking for the URL for `catalog` may return something\n * like `https://backstage.example.com/api/catalog`\n */\n getExternalBaseUrl(pluginId: string): Promise<string>;\n};\n\n/**\n * @public\n */\nexport const discoveryServiceRef = createServiceRef<DiscoveryService>({\n id: 'core.discovery',\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/types';\nimport { TokenManager } from '@backstage/backend-common';\n\n/** @public */\nexport type TokenManagerService = TokenManager;\n\n/**\n * @public\n */\nexport const tokenManagerServiceRef = createServiceRef<TokenManagerService>({\n id: 'core.tokenManager',\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/types';\nimport {\n PermissionAuthorizer,\n PermissionEvaluator,\n} from '@backstage/plugin-permission-common';\n\n/** @public */\nexport type PermissionsService = PermissionEvaluator | PermissionAuthorizer;\n\n/**\n * @public\n */\nexport const permissionsServiceRef = createServiceRef<PermissionsService>({\n id: 'core.permissions',\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/types';\nimport { PluginTaskScheduler } from '@backstage/backend-tasks';\n\n/** @public */\nexport type SchedulerService = PluginTaskScheduler;\n\n/**\n * @public\n */\nexport const schedulerServiceRef = createServiceRef<SchedulerService>({\n id: 'core.scheduler',\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/types';\nimport { LifecycleService } from './lifecycleServiceRef';\n\n/** @public */\nexport type RootLifecycleService = LifecycleService;\n\n/**\n * @public\n */\nexport const rootLifecycleServiceRef = createServiceRef<RootLifecycleService>({\n id: 'core.rootLifecycle',\n scope: 'root',\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/types';\nimport { LoggerService } from './loggerServiceRef';\n\n/** @public */\nexport type RootLoggerService = LoggerService;\n\n/**\n * @public\n */\nexport const rootLoggerServiceRef = createServiceRef<RootLoggerService>({\n id: 'core.root.logger',\n scope: 'root',\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/types';\n\n/**\n * @public\n */\nexport interface PluginMetadataService {\n getId(): string;\n}\n\n/**\n * @public\n */\nexport const pluginMetadataServiceRef = createServiceRef<PluginMetadataService>(\n {\n id: 'core.plugin-metadata',\n },\n);\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system/types';\n\n/**\n * @public\n **/\nexport type LifecycleServiceShutdownHook = {\n fn: () => void | Promise<void>;\n\n /** Labels to help identify the shutdown hook */\n labels?: Record<string, string>;\n};\n\n/**\n * @public\n **/\nexport interface LifecycleService {\n /**\n * Register a function to be called when the backend is shutting down.\n */\n addShutdownHook(options: LifecycleServiceShutdownHook): void;\n}\n\n/**\n * @public\n */\nexport const lifecycleServiceRef = createServiceRef<LifecycleService>({\n id: 'core.lifecycle',\n scope: 'plugin',\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 { LoggerService } from '../definitions';\nimport { Logger as WinstonLogger, createLogger } from 'winston';\nimport Transport, { TransportStreamOptions } from 'winston-transport';\n\nclass BackstageLoggerTransport extends Transport {\n constructor(\n private readonly backstageLogger: LoggerService,\n opts?: TransportStreamOptions,\n ) {\n super(opts);\n }\n\n log(info: unknown, callback: VoidFunction) {\n if (typeof info !== 'object' || info === null) {\n callback();\n return;\n }\n const { level, message, ...meta } = info as { [name: string]: unknown };\n switch (level) {\n case 'error':\n this.backstageLogger.error(String(message), meta);\n break;\n case 'warn':\n this.backstageLogger.warn(String(message), meta);\n break;\n case 'info':\n this.backstageLogger.info(String(message), meta);\n break;\n case 'debug':\n this.backstageLogger.debug(String(message), meta);\n break;\n default:\n this.backstageLogger.info(String(message), meta);\n }\n callback();\n }\n}\n\n/** @public */\nexport function loggerToWinstonLogger(\n logger: LoggerService,\n opts?: TransportStreamOptions,\n): WinstonLogger {\n return createLogger({\n transports: [new BackstageLoggerTransport(logger, opts)],\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 BackendRegistrationPoints,\n BackendFeature,\n ExtensionPoint,\n} from './types';\n\n/** @public */\nexport function createExtensionPoint<T>(options: {\n id: string;\n}): ExtensionPoint<T> {\n return {\n id: options.id,\n get T(): T {\n throw new Error(`tried to read ExtensionPoint.T of ${this}`);\n },\n toString() {\n return `extensionPoint{${options.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<\n TOptions extends object | undefined = undefined,\n>(config: {\n id: string;\n register(reg: BackendRegistrationPoints, options: TOptions): void;\n}): undefined extends TOptions\n ? (options?: TOptions) => BackendFeature\n : (options: TOptions) => BackendFeature {\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 * @public\n *\n * Creates a new backend module for a given plugin.\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<\n TOptions extends object | undefined = undefined,\n>(\n config: BackendModuleConfig<TOptions>,\n): undefined extends TOptions\n ? (options?: TOptions) => BackendFeature\n : (options: TOptions) => BackendFeature {\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":["Transport","createLogger"],"mappings":";;;;;;;;;;;AAuFO,SAAS,iBAAoB,OAUlB,EAAA;AAChB,EAAA,MAAM,EAAE,EAAA,EAAI,KAAQ,GAAA,QAAA,EAAU,gBAAmB,GAAA,OAAA,CAAA;AACjD,EAAO,OAAA;AAAA,IACL,EAAA;AAAA,IACA,KAAA;AAAA,IACA,IAAI,CAAO,GAAA;AACT,MAAM,MAAA,IAAI,KAAM,CAAA,CAAA,8BAAA,EAAiC,IAAM,CAAA,CAAA,CAAA,CAAA;AAAA,KACzD;AAAA,IACA,QAAW,GAAA;AACT,MAAA,OAAO,cAAc,OAAQ,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA;AAAA,KAC/B;AAAA,IACA,KAAO,EAAA,SAAA;AAAA,IACP,gBAAkB,EAAA,cAAA;AAAA,GACpB,CAAA;AAKF,CAAA;AAeO,SAAS,qBAMd,MAW+C,EAAA;AAC/C,EAAA,OAAO,CAAC,OACL,MAAA;AAAA,IACC,KAAA,EAAO,OAAO,OAAQ,CAAA,KAAA;AAAA,IACtB,SAAS,MAAO,CAAA,OAAA;AAAA,IAChB,MAAM,MAAO,CAAA,IAAA;AAAA,IACb,QAAQ,IAA6C,EAAA;AACnD,MAAO,OAAA,MAAA,CAAO,OAAQ,CAAA,IAAA,EAAM,OAAQ,CA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
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/services/system/types.ts","../src/services/definitions/coreServices.ts","../src/wiring/createSharedEnvironment.ts","../src/wiring/factories.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * TODO\n *\n * @public\n */\nexport type ServiceRef<\n TService,\n TScope extends 'root' | 'plugin' = 'root' | 'plugin',\n> = {\n id: string;\n\n /**\n * This determines the scope at which this service is available.\n *\n * Root scoped services are available to all other services but\n * may only depend on other root scoped services.\n *\n * Plugin scoped services are only available to other plugin scoped\n * services but may depend on all other services.\n */\n scope: TScope;\n\n /**\n * Utility for getting the type of the service, using `typeof serviceRef.T`.\n * Attempting to actually read this value will result in an exception.\n */\n T: TService;\n\n toString(): string;\n\n $$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 createRootContext?(deps: { [key in string]: unknown }): Promise<unknown>;\n factory(\n deps: { [key in string]: unknown },\n context: unknown,\n ): Promise<TService>;\n };\n\n/**\n * Represents either a {@link ServiceFactory} or a function that returns one.\n *\n * @public\n */\nexport type ServiceFactoryOrFunction<TService = unknown> =\n | ServiceFactory<TService>\n | (() => ServiceFactory<TService>);\n\n/** @public */\nexport interface ServiceRefConfig<TService, TScope extends 'root' | 'plugin'> {\n id: string;\n scope?: TScope;\n defaultFactory?: (\n service: ServiceRef<TService, TScope>,\n ) => Promise<ServiceFactoryOrFunction<TService>>;\n}\n\n/**\n * Creates a new service definition. This overload is used to create plugin scoped services.\n *\n * @public\n */\nexport function createServiceRef<TService>(\n config: ServiceRefConfig<TService, 'plugin'>,\n): ServiceRef<TService, 'plugin'>;\n\n/**\n * Creates a new service definition. This overload is used to create root scoped services.\n *\n * @public\n */\nexport function createServiceRef<TService>(\n config: ServiceRefConfig<TService, 'root'>,\n): ServiceRef<TService, 'root'>;\nexport function createServiceRef<TService>(\n config: ServiceRefConfig<TService, any>,\n): ServiceRef<TService, any> {\n const { id, scope = 'plugin', defaultFactory } = config;\n return {\n id,\n scope,\n get T(): TService {\n throw new Error(`tried to read ServiceRef.T of ${this}`);\n },\n toString() {\n return `serviceRef{${config.id}}`;\n },\n $$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 RootServiceFactoryConfig<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n> {\n service: ServiceRef<TService, 'root'>;\n deps: TDeps;\n factory(deps: ServiceRefsToInstances<TDeps, 'root'>): TImpl | Promise<TImpl>;\n}\n\n/** @public */\nexport interface PluginServiceFactoryConfig<\n TService,\n TContext,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n> {\n service: ServiceRef<TService, 'plugin'>;\n deps: TDeps;\n createRootContext?(\n deps: ServiceRefsToInstances<TDeps, 'root'>,\n ): TContext | Promise<TContext>;\n factory(\n deps: ServiceRefsToInstances<TDeps>,\n context: TContext,\n ): TImpl | Promise<TImpl>;\n}\n\n/**\n * Creates a root scoped service factory without options.\n *\n * @public\n * @param config - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TOpts extends object | undefined = undefined,\n>(\n config: RootServiceFactoryConfig<TService, TImpl, TDeps>,\n): () => ServiceFactory<TService>;\n/**\n * Creates a root scoped service factory with optional options.\n *\n * @public\n * @param config - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TOpts extends object | undefined = undefined,\n>(\n config: (options?: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>,\n): (options?: TOpts) => ServiceFactory<TService>;\n/**\n * Creates a root scoped service factory with required options.\n *\n * @public\n * @param config - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TOpts extends object | undefined = undefined,\n>(\n config: (options: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>,\n): (options: TOpts) => ServiceFactory<TService>;\n/**\n * Creates a plugin scoped service factory without options.\n *\n * @public\n * @param config - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TContext = undefined,\n TOpts extends object | undefined = undefined,\n>(\n config: PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>,\n): () => ServiceFactory<TService>;\n/**\n * Creates a plugin scoped service factory with optional options.\n *\n * @public\n * @param config - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TContext = undefined,\n TOpts extends object | undefined = undefined,\n>(\n config: (\n options?: TOpts,\n ) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>,\n): (options?: TOpts) => ServiceFactory<TService>;\n/**\n * Creates a plugin scoped service factory with required options.\n *\n * @public\n * @param config - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TContext = undefined,\n TOpts extends object | undefined = undefined,\n>(\n config:\n | PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>\n | ((\n options: TOpts,\n ) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>),\n): (options: TOpts) => ServiceFactory<TService>;\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TContext,\n TOpts extends object | undefined = undefined,\n>(\n config:\n | RootServiceFactoryConfig<TService, TImpl, TDeps>\n | PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>\n | ((options: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>)\n | ((\n options: TOpts,\n ) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>)\n | (() => RootServiceFactoryConfig<TService, TImpl, TDeps>)\n | (() => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>),\n): (options: TOpts) => ServiceFactory<TService> {\n const configCallback = typeof config === 'function' ? config : () => config;\n return (options: TOpts) => {\n const c = configCallback(options);\n return {\n ...c,\n ...('createRootContext' in c\n ? {\n createRootContext: async (deps: TDeps) =>\n c?.createRootContext?.(deps),\n }\n : {}),\n factory: async (deps: TDeps, ctx: TContext) => c.factory(deps, ctx),\n scope: c.service.scope,\n } as ServiceFactory<TService>;\n };\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system';\n\n/**\n * All core services references\n *\n * @public\n */\nexport namespace coreServices {\n /**\n * The service reference for the plugin scoped {@link CacheService}.\n *\n * @public\n */\n export const cache = createServiceRef<import('./CacheService').CacheService>({\n id: 'core.cache',\n });\n\n /**\n * The service reference for the root scoped {@link ConfigService}.\n *\n * @public\n */\n export const config = createServiceRef<\n import('./ConfigService').ConfigService\n >({ id: 'core.config', scope: 'root' });\n\n /**\n * The service reference for the plugin scoped {@link DatabaseService}.\n *\n * @public\n */\n export const database = createServiceRef<\n import('./DatabaseService').DatabaseService\n >({ id: 'core.database' });\n\n /**\n * The service reference for the plugin scoped {@link DiscoveryService}.\n *\n * @public\n */\n export const discovery = createServiceRef<\n import('./DiscoveryService').DiscoveryService\n >({ id: 'core.discovery' });\n\n /**\n * The service reference for the plugin scoped {@link HttpRouterService}.\n *\n * @public\n */\n export const httpRouter = createServiceRef<\n import('./HttpRouterService').HttpRouterService\n >({ id: 'core.httpRouter' });\n\n /**\n * The service reference for the plugin scoped {@link LifecycleService}.\n *\n * @public\n */\n export const lifecycle = createServiceRef<\n import('./LifecycleService').LifecycleService\n >({ id: 'core.lifecycle' });\n\n /**\n * The service reference for the plugin scoped {@link LoggerService}.\n *\n * @public\n */\n export const logger = createServiceRef<\n import('./LoggerService').LoggerService\n >({ id: 'core.logger' });\n\n /**\n * The service reference for the plugin scoped {@link PermissionsService}.\n *\n * @public\n */\n export const permissions = createServiceRef<\n import('./PermissionsService').PermissionsService\n >({ id: 'core.permissions' });\n\n /**\n * The service reference for the plugin scoped {@link PluginMetadataService}.\n *\n * @public\n */\n export const pluginMetadata = createServiceRef<\n import('./PluginMetadataService').PluginMetadataService\n >({ id: 'core.pluginMetadata' });\n\n /**\n * The service reference for the root scoped {@link RootHttpRouterService}.\n *\n * @public\n */\n export const rootHttpRouter = createServiceRef<\n import('./RootHttpRouterService').RootHttpRouterService\n >({ id: 'core.rootHttpRouter', scope: 'root' });\n\n /**\n * The service reference for the root scoped {@link RootLifecycleService}.\n *\n * @public\n */\n export const rootLifecycle = createServiceRef<\n import('./RootLifecycleService').RootLifecycleService\n >({ id: 'core.rootLifecycle', scope: 'root' });\n\n /**\n * The service reference for the root scoped {@link RootLoggerService}.\n *\n * @public\n */\n export const rootLogger = createServiceRef<\n import('./RootLoggerService').RootLoggerService\n >({ id: 'core.rootLogger', scope: 'root' });\n\n /**\n * The service reference for the plugin scoped {@link SchedulerService}.\n *\n * @public\n */\n export const scheduler = createServiceRef<\n import('./SchedulerService').SchedulerService\n >({ id: 'core.scheduler' });\n\n /**\n * The service reference for the plugin scoped {@link TokenManagerService}.\n *\n * @public\n */\n export const tokenManager = createServiceRef<\n import('./TokenManagerService').TokenManagerService\n >({ id: 'core.tokenManager' });\n\n /**\n * The service reference for the plugin scoped {@link UrlReaderService}.\n *\n * @public\n */\n export const urlReader = createServiceRef<\n import('./UrlReaderService').UrlReaderService\n >({ id: 'core.urlReader' });\n\n /**\n * The service reference for the plugin scoped {@link IdentityService}.\n *\n * @public\n */\n export const identity = createServiceRef<\n import('./IdentityService').IdentityService\n >({ id: 'core.identity' });\n}\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ServiceFactory, ServiceFactoryOrFunction } from '../services';\n\n/** @public */\nexport interface SharedBackendEnvironmentConfig {\n services?: ServiceFactoryOrFunction[];\n}\n\n// This type is opaque in order to allow for future API evolution without\n// cluttering the external API. For example we might want to add support\n// for more powerful callback based backend modifications.\n//\n// By making this opaque we also ensure that the type doesn't become an input\n// type that we need to care about, as it would otherwise be possible to pass\n// a custom environment definition to `createBackend`, which we don't want.\n/**\n * @public\n */\nexport interface SharedBackendEnvironment {\n $$type: 'SharedBackendEnvironment';\n}\n\n/**\n * This type is NOT supposed to be used by anyone except internally by the backend-app-api package.\n * @internal */\nexport interface InternalSharedBackendEnvironment {\n version: 'v1';\n services?: ServiceFactory[];\n}\n\n/**\n * Creates a shared backend environment which can be used to create multiple backends\n * @public\n */\nexport function createSharedEnvironment<\n TOptions extends [options?: object] = [],\n>(\n config:\n | SharedBackendEnvironmentConfig\n | ((...params: TOptions) => SharedBackendEnvironmentConfig),\n): (...options: TOptions) => SharedBackendEnvironment {\n const configCallback = typeof config === 'function' ? config : () => config;\n\n return (...options) => {\n const actualConfig = configCallback(...options);\n const services = actualConfig?.services?.map(sf =>\n typeof sf === 'function' ? sf() : sf,\n );\n\n const exists = new Set<string>();\n const duplicates = new Set<string>();\n for (const { service } of services ?? []) {\n if (exists.has(service.id)) {\n duplicates.add(service.id);\n } else {\n exists.add(service.id);\n }\n }\n\n if (duplicates.size > 0) {\n const dupStr = [...duplicates].map(id => `'${id}'`).join(', ');\n throw new Error(\n `Duplicate service implementations provided in shared environment for ${dupStr}`,\n );\n }\n\n // Here to ensure type safety in this internal implementation.\n const env: SharedBackendEnvironment & InternalSharedBackendEnvironment = {\n $$type: 'SharedBackendEnvironment',\n version: 'v1',\n services,\n };\n return env;\n };\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n 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":";;;;AA4GO,SAAS,iBACd,MAC2B,EAA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