@backstage/backend-app-api 1.7.2 → 1.7.3-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.
- package/CHANGELOG.md +9 -0
- package/dist/connections-node/src/DefaultConnectionsService.cjs.js +239 -0
- package/dist/connections-node/src/DefaultConnectionsService.cjs.js.map +1 -0
- package/dist/connections-node/src/combineConnectionSources.cjs.js +26 -0
- package/dist/connections-node/src/combineConnectionSources.cjs.js.map +1 -0
- package/dist/connections-node/src/getLegacyIntegrations.cjs.js +339 -0
- package/dist/connections-node/src/getLegacyIntegrations.cjs.js.map +1 -0
- package/dist/connections-node/src/lookup.cjs.js +16 -0
- package/dist/connections-node/src/lookup.cjs.js.map +1 -0
- package/dist/connections-node/src/service.cjs.js +34 -0
- package/dist/connections-node/src/service.cjs.js.map +1 -0
- package/dist/wiring/BackendInitializer.cjs.js +4 -2
- package/dist/wiring/BackendInitializer.cjs.js.map +1 -1
- package/package.json +10 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @backstage/backend-app-api
|
|
2
2
|
|
|
3
|
+
## 1.7.3-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 64cea29: Updated the backend runtime to use the internal connection service implementation after the shared connection contract moved into `@backstage/connections`.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/connections@0.3.0-next.0
|
|
10
|
+
- @backstage/backend-plugin-api@1.10.0-next.0
|
|
11
|
+
|
|
3
12
|
## 1.7.2
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var lookup = require('./lookup.cjs.js');
|
|
4
|
+
var errors = require('@backstage/errors');
|
|
5
|
+
var v4 = require('zod/v4');
|
|
6
|
+
var getLegacyIntegrations = require('./getLegacyIntegrations.cjs.js');
|
|
7
|
+
var combineConnectionSources = require('./combineConnectionSources.cjs.js');
|
|
8
|
+
|
|
9
|
+
function describeError(error) {
|
|
10
|
+
const e = errors.toError(error);
|
|
11
|
+
if (e.name === "ZodError") {
|
|
12
|
+
return v4.z.prettifyError(e);
|
|
13
|
+
}
|
|
14
|
+
if (e.cause !== void 0) {
|
|
15
|
+
const cause = errors.toError(e.cause);
|
|
16
|
+
if (cause.name === "ZodError") {
|
|
17
|
+
return v4.z.prettifyError(cause);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return e.message;
|
|
21
|
+
}
|
|
22
|
+
class PluginConnectionsService {
|
|
23
|
+
logger;
|
|
24
|
+
connections;
|
|
25
|
+
constructor(logger, connections) {
|
|
26
|
+
this.logger = logger;
|
|
27
|
+
this.connections = connections;
|
|
28
|
+
}
|
|
29
|
+
async find(options) {
|
|
30
|
+
const result = await this.findOptional(options);
|
|
31
|
+
if (!result) {
|
|
32
|
+
throw new errors.NotFoundError(
|
|
33
|
+
`Connection not found for type "${options.type}" matching url "${options.url}"`
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
async findOptional({
|
|
39
|
+
type,
|
|
40
|
+
url,
|
|
41
|
+
authMethods
|
|
42
|
+
}) {
|
|
43
|
+
this.logger.debug(
|
|
44
|
+
`Finding connection of type "${type}" matching url "${url}"`
|
|
45
|
+
);
|
|
46
|
+
let host;
|
|
47
|
+
try {
|
|
48
|
+
host = new URL(url).host;
|
|
49
|
+
} catch {
|
|
50
|
+
throw new errors.InputError(
|
|
51
|
+
`Invalid url "${url}" passed to ConnectionsService.find`
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
const connection = this.connections.find(
|
|
55
|
+
(c) => c.type === type && c.host === host
|
|
56
|
+
);
|
|
57
|
+
if (!connection) {
|
|
58
|
+
return void 0;
|
|
59
|
+
}
|
|
60
|
+
if (connection.auth.length === 0) {
|
|
61
|
+
throw new errors.NotAllowedError(
|
|
62
|
+
`Connection of type "${type}" for host "${host}" has no auth method available to this plugin`
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
const matchAuth = lookup.getConnectionType(type).matchAuth;
|
|
66
|
+
const selected = matchAuth ? matchAuth(connection.auth, url) : connection.auth[0];
|
|
67
|
+
if (!selected) {
|
|
68
|
+
return void 0;
|
|
69
|
+
}
|
|
70
|
+
if (!authMethods.includes(selected.method)) {
|
|
71
|
+
throw new errors.NotAllowedError(
|
|
72
|
+
`Connection not found for type "${type}" with auth method "${selected.method}"`
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
...connection,
|
|
77
|
+
auth: selected
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
class DefaultConnectionsService {
|
|
82
|
+
logger;
|
|
83
|
+
connections;
|
|
84
|
+
config;
|
|
85
|
+
constructor(logger, config) {
|
|
86
|
+
this.logger = logger;
|
|
87
|
+
this.config = config;
|
|
88
|
+
this.connections = [];
|
|
89
|
+
this.#registerConnectionsFromConfig();
|
|
90
|
+
}
|
|
91
|
+
static create(options) {
|
|
92
|
+
return new DefaultConnectionsService(options.logger, options.config);
|
|
93
|
+
}
|
|
94
|
+
#registerConnectionsFromConfig() {
|
|
95
|
+
const legacy = this.#validateLegacy(getLegacyIntegrations.getLegacyIntegrations(this.config));
|
|
96
|
+
const rawConnections = this.config.getOptional("connections");
|
|
97
|
+
if (rawConnections !== void 0 && !Array.isArray(rawConnections)) {
|
|
98
|
+
throw new errors.InputError(
|
|
99
|
+
'Expected "connections" config to be an array of connection objects'
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
const fromConfig = this.#validateConfig(
|
|
103
|
+
rawConnections ?? []
|
|
104
|
+
);
|
|
105
|
+
if (legacy.length === 0 && fromConfig.length === 0) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
this.connections.push(
|
|
109
|
+
...combineConnectionSources.combineConnectionSources(legacy, fromConfig, this.logger)
|
|
110
|
+
);
|
|
111
|
+
const seen = /* @__PURE__ */ new Set();
|
|
112
|
+
for (const c of this.connections) {
|
|
113
|
+
const host = c.host;
|
|
114
|
+
const key = `${c.type} ${host}`;
|
|
115
|
+
if (seen.has(key)) {
|
|
116
|
+
throw new errors.InputError(
|
|
117
|
+
`Duplicate connection of type "${c.type}" for host "${host}"`
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
seen.add(key);
|
|
121
|
+
}
|
|
122
|
+
this.#assignDefaultTitles();
|
|
123
|
+
this.#assignDefaultAuthTitles();
|
|
124
|
+
this.logger.info(
|
|
125
|
+
`Loaded ${this.connections.length} connection${this.connections.length === 1 ? "" : "s"} from configuration`
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
#validateConfig(raw) {
|
|
129
|
+
return raw.map((v) => {
|
|
130
|
+
try {
|
|
131
|
+
return this.#validateConnection(v);
|
|
132
|
+
} catch (e) {
|
|
133
|
+
const type = typeof v.type === "string" ? v.type : "unknown";
|
|
134
|
+
throw new errors.InputError(
|
|
135
|
+
`Invalid connection of type "${type}" in connections config:
|
|
136
|
+
${describeError(
|
|
137
|
+
e
|
|
138
|
+
)}`
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
#validateLegacy(raw) {
|
|
144
|
+
const result = [];
|
|
145
|
+
for (const v of raw) {
|
|
146
|
+
try {
|
|
147
|
+
result.push(this.#validateConnection(v));
|
|
148
|
+
} catch (e) {
|
|
149
|
+
const type = typeof v.type === "string" ? v.type : "unknown";
|
|
150
|
+
this.logger.error(
|
|
151
|
+
`Failed to validate connection of type "${type}":
|
|
152
|
+
${describeError(
|
|
153
|
+
e
|
|
154
|
+
)}`
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return result;
|
|
159
|
+
}
|
|
160
|
+
#validateConnection(connection) {
|
|
161
|
+
if (typeof connection.type !== "string") {
|
|
162
|
+
throw new errors.InputError(`Unrecognised connection type ${connection.type}`);
|
|
163
|
+
}
|
|
164
|
+
if (!lookup.isConnectionTypeKey(connection.type)) {
|
|
165
|
+
throw new errors.InputError(`Unrecognised connection type ${connection.type}`);
|
|
166
|
+
}
|
|
167
|
+
const parsed = lookup.getConnectionType(connection.type).configSchema.parse(
|
|
168
|
+
connection
|
|
169
|
+
);
|
|
170
|
+
if (parsed.auth.length === 0) {
|
|
171
|
+
throw new errors.InputError(
|
|
172
|
+
`Connection of type "${connection.type}" must configure at least one auth method`
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
return parsed;
|
|
176
|
+
}
|
|
177
|
+
#assignDefaultTitles() {
|
|
178
|
+
const typeCounts = /* @__PURE__ */ new Map();
|
|
179
|
+
for (const c of this.connections) {
|
|
180
|
+
const type = c.type;
|
|
181
|
+
typeCounts.set(type, (typeCounts.get(type) ?? 0) + 1);
|
|
182
|
+
}
|
|
183
|
+
for (const c of this.connections) {
|
|
184
|
+
if (!c.title) {
|
|
185
|
+
const type = c.type;
|
|
186
|
+
const displayName = lookup.getConnectionType(type).title;
|
|
187
|
+
const host = c.host;
|
|
188
|
+
c.title = typeCounts.get(type) > 1 ? `${displayName} (${host})` : displayName;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
#assignDefaultAuthTitles() {
|
|
193
|
+
for (const c of this.connections) {
|
|
194
|
+
const type = c.type;
|
|
195
|
+
const connectionType = lookup.getConnectionType(type);
|
|
196
|
+
for (const auth of c.auth) {
|
|
197
|
+
const authMethod = connectionType.authMethods.find(
|
|
198
|
+
(am) => am.method === auth.method
|
|
199
|
+
);
|
|
200
|
+
if (!authMethod) {
|
|
201
|
+
throw new Error(
|
|
202
|
+
`Unknown auth method "${auth.method}" for connection type "${type}"`
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
auth.title ??= authMethod.title;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
#getConnectionsForPlugin(pluginId) {
|
|
210
|
+
return this.connections.flatMap(({ match, auth, ...rest }) => {
|
|
211
|
+
if (match && !match.plugins.includes(pluginId)) {
|
|
212
|
+
return [];
|
|
213
|
+
}
|
|
214
|
+
const pluginMatched = [];
|
|
215
|
+
const unmatched = [];
|
|
216
|
+
for (const { match: authMatch, ...authRest } of auth) {
|
|
217
|
+
if (authMatch) {
|
|
218
|
+
if (!authMatch.plugins.includes(pluginId)) continue;
|
|
219
|
+
pluginMatched.push(authRest);
|
|
220
|
+
} else {
|
|
221
|
+
unmatched.push(authRest);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return [
|
|
225
|
+
{ ...rest, auth: [...pluginMatched, ...unmatched] }
|
|
226
|
+
];
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
forPlugin(pluginId, options) {
|
|
230
|
+
const logger = options?.logger ?? this.logger;
|
|
231
|
+
return new PluginConnectionsService(
|
|
232
|
+
logger,
|
|
233
|
+
this.#getConnectionsForPlugin(pluginId)
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
exports.DefaultConnectionsService = DefaultConnectionsService;
|
|
239
|
+
//# sourceMappingURL=DefaultConnectionsService.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultConnectionsService.cjs.js","sources":["../../../../connections-node/src/DefaultConnectionsService.ts"],"sourcesContent":["/*\n * Copyright 2026 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 LoggerService,\n RootConfigService,\n} from '@backstage/backend-plugin-api';\nimport type {\n Connection,\n ConnectionAuthMethodKey,\n ConnectionsService,\n ConnectionTypeKey,\n} from '@backstage/connections';\nimport { getConnectionType, isConnectionTypeKey } from './lookup';\nimport type { RootConnection } from './types';\nimport { JsonObject } from '@backstage/types';\nimport {\n InputError,\n NotAllowedError,\n NotFoundError,\n toError,\n} from '@backstage/errors';\nimport { z } from 'zod/v4';\nimport { getLegacyIntegrations } from './getLegacyIntegrations';\nimport { combineConnectionSources } from './combineConnectionSources';\n\nfunction describeError(error: unknown): string {\n const e = toError(error);\n if (e.name === 'ZodError') {\n return z.prettifyError(e as unknown as z.ZodError);\n }\n if (e.cause !== undefined) {\n const cause = toError(e.cause);\n if (cause.name === 'ZodError') {\n return z.prettifyError(cause as unknown as z.ZodError);\n }\n }\n return e.message;\n}\n\nclass PluginConnectionsService implements ConnectionsService {\n private readonly logger: LoggerService;\n private readonly connections: Connection[];\n\n constructor(logger: LoggerService, connections: Connection[]) {\n this.logger = logger;\n this.connections = connections;\n }\n\n async find<\n TType extends ConnectionTypeKey,\n TAuthMethod extends ConnectionAuthMethodKey<TType>,\n >(options: {\n type: TType;\n url: string;\n authMethods: readonly [TAuthMethod, ...TAuthMethod[]];\n }): Promise<Connection<TType, TAuthMethod>> {\n const result = await this.findOptional(options);\n if (!result) {\n throw new NotFoundError(\n `Connection not found for type \"${options.type}\" matching url \"${options.url}\"`,\n );\n }\n return result;\n }\n\n async findOptional<\n TType extends ConnectionTypeKey,\n TAuthMethod extends ConnectionAuthMethodKey<TType>,\n >({\n type,\n url,\n authMethods,\n }: {\n type: TType;\n url: string;\n authMethods: readonly [TAuthMethod, ...TAuthMethod[]];\n }): Promise<Connection<TType, TAuthMethod> | undefined> {\n this.logger.debug(\n `Finding connection of type \"${type}\" matching url \"${url}\"`,\n );\n let host: string;\n try {\n host = new URL(url).host;\n } catch {\n throw new InputError(\n `Invalid url \"${url}\" passed to ConnectionsService.find`,\n );\n }\n\n const connection = this.connections.find(\n c => c.type === type && (c as { host?: unknown }).host === host,\n ) as Connection<TType> | undefined;\n\n if (!connection) {\n return undefined;\n }\n\n if (connection.auth.length === 0) {\n throw new NotAllowedError(\n `Connection of type \"${type}\" for host \"${host}\" has no auth method available to this plugin`,\n );\n }\n\n const matchAuth = getConnectionType(type).matchAuth as\n | ((authMethods: any[], query: string) => any | undefined)\n | undefined;\n\n // We take the host-matched connection and check to see if there's an auth method better suited to the current url\n // e.g. org selection\n const selected = matchAuth\n ? matchAuth(connection.auth, url)\n : connection.auth[0];\n\n if (!selected) {\n return undefined;\n }\n\n // Now we compare user requested auth methods with what the connection can provide\n if (!(authMethods as readonly string[]).includes(selected.method)) {\n throw new NotAllowedError(\n `Connection not found for type \"${type}\" with auth method \"${selected.method}\"`,\n );\n }\n\n return {\n ...connection,\n auth: selected,\n } as Connection<TType, TAuthMethod>;\n }\n}\n\n/** @public */\nexport class DefaultConnectionsService {\n private readonly logger: LoggerService;\n private readonly connections: RootConnection[];\n private readonly config: RootConfigService;\n\n private constructor(logger: LoggerService, config: RootConfigService) {\n this.logger = logger;\n this.config = config;\n this.connections = [];\n this.#registerConnectionsFromConfig();\n }\n\n static create(options: {\n logger: LoggerService;\n config: RootConfigService;\n }): DefaultConnectionsService {\n return new DefaultConnectionsService(options.logger, options.config);\n }\n\n #registerConnectionsFromConfig(): void {\n const legacy = this.#validateLegacy(getLegacyIntegrations(this.config));\n\n const rawConnections = this.config.getOptional('connections');\n if (rawConnections !== undefined && !Array.isArray(rawConnections)) {\n throw new InputError(\n 'Expected \"connections\" config to be an array of connection objects',\n );\n }\n\n const fromConfig = this.#validateConfig(\n (rawConnections as JsonObject[] | undefined) ?? [],\n );\n\n if (legacy.length === 0 && fromConfig.length === 0) {\n return;\n }\n\n this.connections.push(\n ...combineConnectionSources(legacy, fromConfig, this.logger),\n );\n\n const seen = new Set<string>();\n for (const c of this.connections) {\n const host = (c as unknown as { host: string }).host;\n const key = `${c.type} ${host}`;\n if (seen.has(key)) {\n throw new InputError(\n `Duplicate connection of type \"${c.type}\" for host \"${host}\"`,\n );\n }\n seen.add(key);\n }\n\n this.#assignDefaultTitles();\n this.#assignDefaultAuthTitles();\n\n this.logger.info(\n `Loaded ${this.connections.length} connection${\n this.connections.length === 1 ? '' : 's'\n } from configuration`,\n );\n }\n\n #validateConfig(raw: JsonObject[]): RootConnection[] {\n return raw.map(v => {\n try {\n return this.#validateConnection(v);\n } catch (e) {\n const type = typeof v.type === 'string' ? v.type : 'unknown';\n throw new InputError(\n `Invalid connection of type \"${type}\" in connections config:\\n${describeError(\n e,\n )}`,\n );\n }\n });\n }\n\n #validateLegacy(raw: JsonObject[]): RootConnection[] {\n const result: RootConnection[] = [];\n for (const v of raw) {\n try {\n result.push(this.#validateConnection(v));\n } catch (e) {\n const type = typeof v.type === 'string' ? v.type : 'unknown';\n this.logger.error(\n `Failed to validate connection of type \"${type}\":\\n${describeError(\n e,\n )}`,\n );\n }\n }\n return result;\n }\n\n #validateConnection(connection: JsonObject): RootConnection {\n if (typeof connection.type !== 'string') {\n throw new InputError(`Unrecognised connection type ${connection.type}`);\n }\n\n if (!isConnectionTypeKey(connection.type)) {\n throw new InputError(`Unrecognised connection type ${connection.type}`);\n }\n\n const parsed = getConnectionType(connection.type).configSchema.parse(\n connection,\n );\n if (parsed.auth.length === 0) {\n throw new InputError(\n `Connection of type \"${connection.type}\" must configure at least one auth method`,\n );\n }\n return parsed;\n }\n\n #assignDefaultTitles(): void {\n const typeCounts = new Map<string, number>();\n for (const c of this.connections) {\n const type = c.type as ConnectionTypeKey;\n typeCounts.set(type, (typeCounts.get(type) ?? 0) + 1);\n }\n for (const c of this.connections) {\n if (!c.title) {\n const type = c.type as ConnectionTypeKey;\n const displayName = getConnectionType(type).title;\n const host = (c as unknown as { host: string }).host;\n (c as { title?: string }).title =\n typeCounts.get(type)! > 1 ? `${displayName} (${host})` : displayName;\n }\n }\n }\n\n #assignDefaultAuthTitles(): void {\n for (const c of this.connections) {\n const type = c.type as ConnectionTypeKey;\n const connectionType = getConnectionType(type);\n for (const auth of c.auth) {\n const authMethod = connectionType.authMethods.find(\n am => am.method === auth.method,\n );\n // The config schema only allows methods declared by the connection\n // type, so failing to find one means that invariant has been broken.\n if (!authMethod) {\n throw new Error(\n `Unknown auth method \"${auth.method}\" for connection type \"${type}\"`,\n );\n }\n auth.title ??= authMethod.title;\n }\n }\n }\n\n #getConnectionsForPlugin(pluginId: string): Connection[] {\n // Filter connections and hide auth methods based on these conditions:\n // 1. Include Connections with no plugin matcher condition\n // 2. Include Connections with a plugin matcher condition for this plugin\n // 3. Include auth methods with no plugin matcher condition\n // 4. Remove auth methods with a plugin matcher condition for other plugins\n return this.connections.flatMap(({ match, auth, ...rest }) => {\n if (match && !match.plugins.includes(pluginId)) {\n return [];\n }\n\n const pluginMatched: Connection['auth'] = [];\n const unmatched: Connection['auth'] = [];\n for (const { match: authMatch, ...authRest } of auth) {\n if (authMatch) {\n if (!authMatch.plugins.includes(pluginId)) continue;\n pluginMatched.push(authRest as Connection['auth'][number]);\n } else {\n unmatched.push(authRest as Connection['auth'][number]);\n }\n }\n\n return [\n { ...rest, auth: [...pluginMatched, ...unmatched] } as Connection,\n ];\n });\n }\n\n forPlugin(\n pluginId: string,\n options?: {\n logger: LoggerService;\n },\n ): ConnectionsService {\n const logger = options?.logger ?? this.logger;\n return new PluginConnectionsService(\n logger,\n this.#getConnectionsForPlugin(pluginId),\n );\n }\n}\n"],"names":["toError","z","NotFoundError","InputError","NotAllowedError","getConnectionType","getLegacyIntegrations","combineConnectionSources","isConnectionTypeKey"],"mappings":";;;;;;;;AAsCA,SAAS,cAAc,KAAA,EAAwB;AAC7C,EAAA,MAAM,CAAA,GAAIA,eAAQ,KAAK,CAAA;AACvB,EAAA,IAAI,CAAA,CAAE,SAAS,UAAA,EAAY;AACzB,IAAA,OAAOC,IAAA,CAAE,cAAc,CAA0B,CAAA;AAAA,EACnD;AACA,EAAA,IAAI,CAAA,CAAE,UAAU,MAAA,EAAW;AACzB,IAAA,MAAM,KAAA,GAAQD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C,EAAC;AACvC,MAAA,KAAA,MAAW,EAAE,KAAA,EAAO,SAAA,EAAW,GAAG,QAAA,MAAc,IAAA,EAAM;AACpD,QAAA,IAAI,SAAA,EAAW;AACb,UAAA,IAAI,CAAC,SAAA,CAAU,OAAA,CAAQ,QAAA,CAAS,QAAQ,CAAA,EAAG;AAC3C,UAAA,aAAA,CAAc,KAAK,QAAsC,CAAA;AAAA,QAC3D,CAAA,MAAO;AACL,UAAA,SAAA,CAAU,KAAK,QAAsC,CAAA;AAAA,QACvD;AAAA,MACF;AAEA,MAAA,OAAO;AAAA,QACL,EAAE,GAAG,IAAA,EAAM,IAAA,EAAM,CAAC,GAAG,aAAA,EAAe,GAAG,SAAS,CAAA;AAAE,OACpD;AAAA,IACF,CAAC,CAAA;AAAA,EACH;AAAA,EAEA,SAAA,CACE,UACA,OAAA,EAGoB;AACpB,IAAA,MAAM,MAAA,GAAS,OAAA,EAAS,MAAA,IAAU,IAAA,CAAK,MAAA;AACvC,IAAA,OAAO,IAAI,wBAAA;AAAA,MACT,MAAA;AAAA,MACA,IAAA,CAAK,yBAAyB,QAAQ;AAAA,KACxC;AAAA,EACF;AACF;;;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function combineConnectionSources(legacy, fromConfig, logger) {
|
|
4
|
+
const typeOf = (c) => c.type;
|
|
5
|
+
const typesInConfig = new Set(fromConfig.map(typeOf));
|
|
6
|
+
const warned = /* @__PURE__ */ new Set();
|
|
7
|
+
const result = [];
|
|
8
|
+
for (const legacyConn of legacy) {
|
|
9
|
+
const type = typeOf(legacyConn);
|
|
10
|
+
if (typesInConfig.has(type)) {
|
|
11
|
+
if (!warned.has(type)) {
|
|
12
|
+
warned.add(type);
|
|
13
|
+
logger.warn(
|
|
14
|
+
`Connection type "${type}" is defined in both legacy integrations and connections config; legacy integrations of this type are ignored.`
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
result.push(legacyConn);
|
|
20
|
+
}
|
|
21
|
+
result.push(...fromConfig);
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
exports.combineConnectionSources = combineConnectionSources;
|
|
26
|
+
//# sourceMappingURL=combineConnectionSources.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combineConnectionSources.cjs.js","sources":["../../../../connections-node/src/combineConnectionSources.ts"],"sourcesContent":["/*\n * Copyright 2026 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 { LoggerService } from '@backstage/backend-plugin-api';\nimport type { RootConnection } from './types';\n\n/**\n * Merges connections derived from legacy `integrations.*` config with\n * connections defined explicitly in `connections:` config.\n *\n * If any entry in `fromConfig` declares a given connection type, all legacy\n * entries of that type are discarded — the connections config fully takes\n * over for that type. A single warning is logged per discarded type.\n */\nexport function combineConnectionSources(\n legacy: RootConnection[],\n fromConfig: RootConnection[],\n logger: LoggerService,\n): RootConnection[] {\n const typeOf = (c: RootConnection) => c.type as string;\n const typesInConfig = new Set(fromConfig.map(typeOf));\n\n const warned = new Set<string>();\n const result: RootConnection[] = [];\n\n for (const legacyConn of legacy) {\n const type = typeOf(legacyConn);\n if (typesInConfig.has(type)) {\n if (!warned.has(type)) {\n warned.add(type);\n logger.warn(\n `Connection type \"${type}\" is defined in both legacy integrations and connections config; legacy integrations of this type are ignored.`,\n );\n }\n continue;\n }\n result.push(legacyConn);\n }\n\n result.push(...fromConfig);\n\n return result;\n}\n"],"names":[],"mappings":";;AA0BO,SAAS,wBAAA,CACd,MAAA,EACA,UAAA,EACA,MAAA,EACkB;AAClB,EAAA,MAAM,MAAA,GAAS,CAAC,CAAA,KAAsB,CAAA,CAAE,IAAA;AACxC,EAAA,MAAM,gBAAgB,IAAI,GAAA,CAAI,UAAA,CAAW,GAAA,CAAI,MAAM,CAAC,CAAA;AAEpD,EAAA,MAAM,MAAA,uBAAa,GAAA,EAAY;AAC/B,EAAA,MAAM,SAA2B,EAAC;AAElC,EAAA,KAAA,MAAW,cAAc,MAAA,EAAQ;AAC/B,IAAA,MAAM,IAAA,GAAO,OAAO,UAAU,CAAA;AAC9B,IAAA,IAAI,aAAA,CAAc,GAAA,CAAI,IAAI,CAAA,EAAG;AAC3B,MAAA,IAAI,CAAC,MAAA,CAAO,GAAA,CAAI,IAAI,CAAA,EAAG;AACrB,QAAA,MAAA,CAAO,IAAI,IAAI,CAAA;AACf,QAAA,MAAA,CAAO,IAAA;AAAA,UACL,oBAAoB,IAAI,CAAA,8GAAA;AAAA,SAC1B;AAAA,MACF;AACA,MAAA;AAAA,IACF;AACA,IAAA,MAAA,CAAO,KAAK,UAAU,CAAA;AAAA,EACxB;AAEA,EAAA,MAAA,CAAO,IAAA,CAAK,GAAG,UAAU,CAAA;AAEzB,EAAA,OAAO,MAAA;AACT;;;;"}
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function getLegacyIntegrations(config) {
|
|
4
|
+
const integrations = config.getOptionalConfig("integrations");
|
|
5
|
+
if (!integrations) {
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
8
|
+
return [
|
|
9
|
+
...convertAwsCodeCommit(
|
|
10
|
+
integrations.getOptionalConfigArray("awsCodeCommit") ?? []
|
|
11
|
+
),
|
|
12
|
+
...convertAwsS3(integrations.getOptionalConfigArray("awsS3") ?? []),
|
|
13
|
+
...convertAzure(integrations.getOptionalConfigArray("azure") ?? []),
|
|
14
|
+
...convertAzureBlobStorage(
|
|
15
|
+
integrations.getOptionalConfigArray("azureBlobStorage") ?? []
|
|
16
|
+
),
|
|
17
|
+
...convertBitbucketCloud(
|
|
18
|
+
integrations.getOptionalConfigArray("bitbucketCloud") ?? []
|
|
19
|
+
),
|
|
20
|
+
...convertBitbucketServer(
|
|
21
|
+
integrations.getOptionalConfigArray("bitbucketServer") ?? []
|
|
22
|
+
),
|
|
23
|
+
...convertGerrit(integrations.getOptionalConfigArray("gerrit") ?? []),
|
|
24
|
+
...convertGitea(integrations.getOptionalConfigArray("gitea") ?? []),
|
|
25
|
+
...convertGithub(integrations.getOptionalConfigArray("github") ?? []),
|
|
26
|
+
...convertGitlab(integrations.getOptionalConfigArray("gitlab") ?? []),
|
|
27
|
+
...convertGoogleGcs(integrations.getOptionalConfigArray("googleGcs") ?? []),
|
|
28
|
+
...convertHarness(integrations.getOptionalConfigArray("harness") ?? [])
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
function convertGithub(entries) {
|
|
32
|
+
return entries.map((entry) => {
|
|
33
|
+
const auth = [];
|
|
34
|
+
const token = entry.getOptionalString("token");
|
|
35
|
+
if (token !== void 0) {
|
|
36
|
+
auth.push({ method: "token", token });
|
|
37
|
+
}
|
|
38
|
+
for (const app of entry.getOptionalConfigArray("apps") ?? []) {
|
|
39
|
+
auth.push(convertGithubApp(app));
|
|
40
|
+
}
|
|
41
|
+
return omitUndefined({
|
|
42
|
+
type: "github",
|
|
43
|
+
host: entry.getOptionalString("host"),
|
|
44
|
+
apiBaseUrl: entry.getOptionalString("apiBaseUrl"),
|
|
45
|
+
rawBaseUrl: entry.getOptionalString("rawBaseUrl"),
|
|
46
|
+
auth: withNoneAuthFallback(auth)
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function convertGitlab(entries) {
|
|
51
|
+
return entries.map((entry) => {
|
|
52
|
+
const auth = [];
|
|
53
|
+
const token = entry.getOptionalString("token");
|
|
54
|
+
if (token !== void 0) {
|
|
55
|
+
auth.push({ method: "token", token });
|
|
56
|
+
}
|
|
57
|
+
return omitUndefined({
|
|
58
|
+
type: "gitlab",
|
|
59
|
+
host: entry.getOptionalString("host"),
|
|
60
|
+
apiBaseUrl: entry.getOptionalString("apiBaseUrl"),
|
|
61
|
+
baseUrl: entry.getOptionalString("baseUrl"),
|
|
62
|
+
auth: withNoneAuthFallback(auth)
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function convertGithubApp(app) {
|
|
67
|
+
return omitUndefined({
|
|
68
|
+
method: "app",
|
|
69
|
+
appId: app.getOptional("appId"),
|
|
70
|
+
privateKey: app.getOptionalString("privateKey"),
|
|
71
|
+
clientId: app.getOptionalString("clientId"),
|
|
72
|
+
clientSecret: app.getOptionalString("clientSecret"),
|
|
73
|
+
webhookSecret: app.getOptionalString("webhookSecret"),
|
|
74
|
+
orgs: app.getOptionalStringArray("allowedInstallationOwners"),
|
|
75
|
+
publicAccess: app.getOptionalBoolean("publicAccess")
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function convertAzure(entries) {
|
|
79
|
+
return entries.map((entry) => {
|
|
80
|
+
const auth = [];
|
|
81
|
+
for (const credential of entry.getOptionalConfigArray("credentials") ?? []) {
|
|
82
|
+
const converted = convertAzureCredential(credential);
|
|
83
|
+
if (converted) {
|
|
84
|
+
auth.push(converted);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return omitUndefined({
|
|
88
|
+
type: "azure",
|
|
89
|
+
host: entry.getOptionalString("host"),
|
|
90
|
+
auth: withNoneAuthFallback(auth)
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function convertAzureCredential(credential) {
|
|
95
|
+
const orgs = credential.getOptionalStringArray("organizations");
|
|
96
|
+
const personalAccessToken = credential.getOptionalString(
|
|
97
|
+
"personalAccessToken"
|
|
98
|
+
);
|
|
99
|
+
if (personalAccessToken !== void 0) {
|
|
100
|
+
return omitUndefined({
|
|
101
|
+
method: "pat",
|
|
102
|
+
personalAccessToken,
|
|
103
|
+
orgs
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
const clientSecret = credential.getOptionalString("clientSecret");
|
|
107
|
+
if (clientSecret !== void 0) {
|
|
108
|
+
return omitUndefined({
|
|
109
|
+
method: "clientCredentials",
|
|
110
|
+
clientId: credential.getOptionalString("clientId"),
|
|
111
|
+
clientSecret,
|
|
112
|
+
tenantId: credential.getOptionalString("tenantId"),
|
|
113
|
+
orgs
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
const clientId = credential.getOptionalString("clientId");
|
|
117
|
+
if (clientId !== void 0) {
|
|
118
|
+
return omitUndefined({
|
|
119
|
+
method: "managedIdentity",
|
|
120
|
+
clientId,
|
|
121
|
+
tenantId: credential.getOptionalString("tenantId"),
|
|
122
|
+
managedIdentityClientId: credential.getOptionalString(
|
|
123
|
+
"managedIdentityClientId"
|
|
124
|
+
),
|
|
125
|
+
orgs
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return void 0;
|
|
129
|
+
}
|
|
130
|
+
function convertBitbucketCloud(entries) {
|
|
131
|
+
return entries.map((entry) => {
|
|
132
|
+
const username = entry.getOptionalString("username");
|
|
133
|
+
const auth = [];
|
|
134
|
+
const token = entry.getOptionalString("token");
|
|
135
|
+
if (username !== void 0 && token !== void 0) {
|
|
136
|
+
auth.push({ method: "token", username, token });
|
|
137
|
+
}
|
|
138
|
+
const appPassword = entry.getOptionalString("appPassword");
|
|
139
|
+
if (username !== void 0 && appPassword !== void 0) {
|
|
140
|
+
auth.push({ method: "appPassword", username, appPassword });
|
|
141
|
+
}
|
|
142
|
+
const clientId = entry.getOptionalString("clientId");
|
|
143
|
+
const clientSecret = entry.getOptionalString("clientSecret");
|
|
144
|
+
if (clientId !== void 0 && clientSecret !== void 0) {
|
|
145
|
+
auth.push({ method: "oauth", clientId, clientSecret });
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
type: "bitbucket-cloud",
|
|
149
|
+
host: "bitbucket.org",
|
|
150
|
+
auth: withNoneAuthFallback(auth)
|
|
151
|
+
};
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
function convertBitbucketServer(entries) {
|
|
155
|
+
return entries.map((entry) => {
|
|
156
|
+
const auth = [];
|
|
157
|
+
const token = entry.getOptionalString("token");
|
|
158
|
+
if (token !== void 0) {
|
|
159
|
+
auth.push({ method: "token", token });
|
|
160
|
+
}
|
|
161
|
+
const username = entry.getOptionalString("username");
|
|
162
|
+
const password = entry.getOptionalString("password");
|
|
163
|
+
if (username !== void 0 && password !== void 0) {
|
|
164
|
+
auth.push({ method: "basic", username, password });
|
|
165
|
+
}
|
|
166
|
+
return omitUndefined({
|
|
167
|
+
type: "bitbucket-server",
|
|
168
|
+
host: entry.getOptionalString("host"),
|
|
169
|
+
apiBaseUrl: entry.getOptionalString("apiBaseUrl"),
|
|
170
|
+
auth: withNoneAuthFallback(auth)
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
function convertGerrit(entries) {
|
|
175
|
+
return entries.map((entry) => {
|
|
176
|
+
const auth = [];
|
|
177
|
+
const username = entry.getOptionalString("username");
|
|
178
|
+
const password = entry.getOptionalString("password");
|
|
179
|
+
if (username !== void 0 && password !== void 0) {
|
|
180
|
+
auth.push({ method: "basic", username, password });
|
|
181
|
+
}
|
|
182
|
+
return omitUndefined({
|
|
183
|
+
type: "gerrit",
|
|
184
|
+
host: entry.getOptionalString("host"),
|
|
185
|
+
baseUrl: entry.getOptionalString("baseUrl"),
|
|
186
|
+
gitilesBaseUrl: entry.getOptionalString("gitilesBaseUrl"),
|
|
187
|
+
cloneUrl: entry.getOptionalString("cloneUrl"),
|
|
188
|
+
auth: withNoneAuthFallback(auth)
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
function convertGitea(entries) {
|
|
193
|
+
return entries.map((entry) => {
|
|
194
|
+
const auth = [];
|
|
195
|
+
const username = entry.getOptionalString("username");
|
|
196
|
+
const password = entry.getOptionalString("password");
|
|
197
|
+
if (username !== void 0 && password !== void 0) {
|
|
198
|
+
auth.push({ method: "basic", username, password });
|
|
199
|
+
}
|
|
200
|
+
return omitUndefined({
|
|
201
|
+
type: "gitea",
|
|
202
|
+
host: entry.getOptionalString("host"),
|
|
203
|
+
baseUrl: entry.getOptionalString("baseUrl"),
|
|
204
|
+
auth: withNoneAuthFallback(auth)
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
function convertHarness(entries) {
|
|
209
|
+
return entries.map((entry) => {
|
|
210
|
+
const auth = [];
|
|
211
|
+
const token = entry.getOptionalString("token");
|
|
212
|
+
if (token !== void 0) {
|
|
213
|
+
const apiKey = entry.getOptionalString("apiKey");
|
|
214
|
+
auth.push(omitUndefined({ method: "token", token, apiKey }));
|
|
215
|
+
}
|
|
216
|
+
return omitUndefined({
|
|
217
|
+
type: "harness",
|
|
218
|
+
host: entry.getOptionalString("host"),
|
|
219
|
+
auth
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
function convertAwsCodeCommit(entries) {
|
|
224
|
+
return entries.map((entry) => {
|
|
225
|
+
const auth = [];
|
|
226
|
+
const accessKeyId = entry.getOptionalString("accessKeyId");
|
|
227
|
+
const secretAccessKey = entry.getOptionalString("secretAccessKey");
|
|
228
|
+
if (accessKeyId !== void 0 && secretAccessKey !== void 0) {
|
|
229
|
+
auth.push({ method: "accessKey", accessKeyId, secretAccessKey });
|
|
230
|
+
}
|
|
231
|
+
const roleArn = entry.getOptionalString("roleArn");
|
|
232
|
+
if (roleArn !== void 0) {
|
|
233
|
+
auth.push(
|
|
234
|
+
omitUndefined({
|
|
235
|
+
method: "assumeRole",
|
|
236
|
+
roleArn,
|
|
237
|
+
externalId: entry.getOptionalString("externalId")
|
|
238
|
+
})
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
const region = entry.getString("region");
|
|
242
|
+
const host = entry.getOptionalString("host") ?? `${region}.console.aws.amazon.com`;
|
|
243
|
+
return { type: "aws-codecommit", host, region, auth };
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
function convertAwsS3(entries) {
|
|
247
|
+
return entries.map((entry) => {
|
|
248
|
+
const auth = [];
|
|
249
|
+
const accessKeyId = entry.getOptionalString("accessKeyId");
|
|
250
|
+
const secretAccessKey = entry.getOptionalString("secretAccessKey");
|
|
251
|
+
if (accessKeyId !== void 0 && secretAccessKey !== void 0) {
|
|
252
|
+
auth.push({ method: "accessKey", accessKeyId, secretAccessKey });
|
|
253
|
+
}
|
|
254
|
+
const roleArn = entry.getOptionalString("roleArn");
|
|
255
|
+
if (roleArn !== void 0) {
|
|
256
|
+
auth.push(
|
|
257
|
+
omitUndefined({
|
|
258
|
+
method: "assumeRole",
|
|
259
|
+
roleArn,
|
|
260
|
+
externalId: entry.getOptionalString("externalId")
|
|
261
|
+
})
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
const endpoint = entry.getOptionalString("endpoint");
|
|
265
|
+
const host = endpoint ? new URL(endpoint).host : "amazonaws.com";
|
|
266
|
+
return omitUndefined({
|
|
267
|
+
type: "aws-s3",
|
|
268
|
+
host,
|
|
269
|
+
endpoint,
|
|
270
|
+
s3ForcePathStyle: entry.getOptionalBoolean("s3ForcePathStyle"),
|
|
271
|
+
auth: withNoneAuthFallback(auth)
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
function convertAzureBlobStorage(entries) {
|
|
276
|
+
return entries.map((entry) => {
|
|
277
|
+
const auth = [];
|
|
278
|
+
const accountKey = entry.getOptionalString("accountKey");
|
|
279
|
+
if (accountKey !== void 0) {
|
|
280
|
+
auth.push({ method: "accountKey", accountKey });
|
|
281
|
+
}
|
|
282
|
+
const sasToken = entry.getOptionalString("sasToken");
|
|
283
|
+
if (sasToken !== void 0) {
|
|
284
|
+
auth.push({ method: "sasToken", sasToken });
|
|
285
|
+
}
|
|
286
|
+
const connectionString = entry.getOptionalString("connectionString");
|
|
287
|
+
if (connectionString !== void 0) {
|
|
288
|
+
auth.push({ method: "connectionString", connectionString });
|
|
289
|
+
}
|
|
290
|
+
if (entry.has("aadCredential")) {
|
|
291
|
+
auth.push({
|
|
292
|
+
method: "aadCredential",
|
|
293
|
+
clientId: entry.getString("aadCredential.clientId"),
|
|
294
|
+
tenantId: entry.getString("aadCredential.tenantId"),
|
|
295
|
+
clientSecret: entry.getString("aadCredential.clientSecret")
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
const endpoint = entry.getOptionalString("endpoint");
|
|
299
|
+
const host = endpoint ? new URL(endpoint).host : entry.getOptionalString("host") ?? "blob.core.windows.net";
|
|
300
|
+
return omitUndefined({
|
|
301
|
+
type: "azure-blob-storage",
|
|
302
|
+
host,
|
|
303
|
+
accountName: entry.getOptionalString("accountName"),
|
|
304
|
+
endpoint,
|
|
305
|
+
endpointSuffix: entry.getOptionalString("endpointSuffix"),
|
|
306
|
+
auth: withNoneAuthFallback(auth)
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
function convertGoogleGcs(entries) {
|
|
311
|
+
return entries.map((entry) => {
|
|
312
|
+
const auth = [];
|
|
313
|
+
const clientEmail = entry.getOptionalString("clientEmail");
|
|
314
|
+
const privateKey = entry.getOptionalString("privateKey");
|
|
315
|
+
if (clientEmail !== void 0 && privateKey !== void 0) {
|
|
316
|
+
auth.push({ method: "serviceAccount", clientEmail, privateKey });
|
|
317
|
+
}
|
|
318
|
+
return {
|
|
319
|
+
type: "google-gcs",
|
|
320
|
+
host: "storage.cloud.google.com",
|
|
321
|
+
auth: withNoneAuthFallback(auth)
|
|
322
|
+
};
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
function withNoneAuthFallback(auth) {
|
|
326
|
+
return auth.length > 0 ? auth : [{ method: "none" }];
|
|
327
|
+
}
|
|
328
|
+
function omitUndefined(input) {
|
|
329
|
+
const out = {};
|
|
330
|
+
for (const [key, value] of Object.entries(input)) {
|
|
331
|
+
if (value !== void 0) {
|
|
332
|
+
out[key] = value;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return out;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
exports.getLegacyIntegrations = getLegacyIntegrations;
|
|
339
|
+
//# sourceMappingURL=getLegacyIntegrations.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLegacyIntegrations.cjs.js","sources":["../../../../connections-node/src/getLegacyIntegrations.ts"],"sourcesContent":["/*\n * Copyright 2026 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 { RootConfigService } from '@backstage/backend-plugin-api';\nimport { Config } from '@backstage/config';\nimport { JsonObject, JsonValue } from '@backstage/types';\n\n/**\n * Reads legacy `integrations.*` config and converts each entry to a connection\n * object in the same shape as `connections:` config. The result is a list of\n * unvalidated JsonObjects; the caller is expected to run them through the\n * normal connection-schema validation alongside the rest of the connections\n * config.\n */\nexport function getLegacyIntegrations(config: RootConfigService): JsonObject[] {\n const integrations = config.getOptionalConfig('integrations');\n if (!integrations) {\n return [];\n }\n\n return [\n ...convertAwsCodeCommit(\n integrations.getOptionalConfigArray('awsCodeCommit') ?? [],\n ),\n ...convertAwsS3(integrations.getOptionalConfigArray('awsS3') ?? []),\n ...convertAzure(integrations.getOptionalConfigArray('azure') ?? []),\n ...convertAzureBlobStorage(\n integrations.getOptionalConfigArray('azureBlobStorage') ?? [],\n ),\n ...convertBitbucketCloud(\n integrations.getOptionalConfigArray('bitbucketCloud') ?? [],\n ),\n ...convertBitbucketServer(\n integrations.getOptionalConfigArray('bitbucketServer') ?? [],\n ),\n ...convertGerrit(integrations.getOptionalConfigArray('gerrit') ?? []),\n ...convertGitea(integrations.getOptionalConfigArray('gitea') ?? []),\n ...convertGithub(integrations.getOptionalConfigArray('github') ?? []),\n ...convertGitlab(integrations.getOptionalConfigArray('gitlab') ?? []),\n ...convertGoogleGcs(integrations.getOptionalConfigArray('googleGcs') ?? []),\n ...convertHarness(integrations.getOptionalConfigArray('harness') ?? []),\n ];\n}\n\nfunction convertGithub(entries: Config[]): JsonObject[] {\n return entries.map(entry => {\n const auth: JsonObject[] = [];\n\n const token = entry.getOptionalString('token');\n if (token !== undefined) {\n auth.push({ method: 'token', token });\n }\n\n for (const app of entry.getOptionalConfigArray('apps') ?? []) {\n auth.push(convertGithubApp(app));\n }\n\n return omitUndefined({\n type: 'github',\n host: entry.getOptionalString('host'),\n apiBaseUrl: entry.getOptionalString('apiBaseUrl'),\n rawBaseUrl: entry.getOptionalString('rawBaseUrl'),\n auth: withNoneAuthFallback(auth),\n });\n });\n}\n\nfunction convertGitlab(entries: Config[]): JsonObject[] {\n return entries.map(entry => {\n const auth: JsonObject[] = [];\n\n const token = entry.getOptionalString('token');\n if (token !== undefined) {\n auth.push({ method: 'token', token });\n }\n\n return omitUndefined({\n type: 'gitlab',\n host: entry.getOptionalString('host'),\n apiBaseUrl: entry.getOptionalString('apiBaseUrl'),\n baseUrl: entry.getOptionalString('baseUrl'),\n auth: withNoneAuthFallback(auth),\n });\n });\n}\n\nfunction convertGithubApp(app: Config): JsonObject {\n return omitUndefined({\n method: 'app',\n appId: app.getOptional<JsonValue>('appId'),\n privateKey: app.getOptionalString('privateKey'),\n clientId: app.getOptionalString('clientId'),\n clientSecret: app.getOptionalString('clientSecret'),\n webhookSecret: app.getOptionalString('webhookSecret'),\n orgs: app.getOptionalStringArray('allowedInstallationOwners'),\n publicAccess: app.getOptionalBoolean('publicAccess'),\n });\n}\n\nfunction convertAzure(entries: Config[]): JsonObject[] {\n return entries.map(entry => {\n const auth: JsonObject[] = [];\n for (const credential of entry.getOptionalConfigArray('credentials') ??\n []) {\n const converted = convertAzureCredential(credential);\n if (converted) {\n auth.push(converted);\n }\n }\n\n return omitUndefined({\n type: 'azure',\n host: entry.getOptionalString('host'),\n auth: withNoneAuthFallback(auth),\n });\n });\n}\n\nfunction convertAzureCredential(credential: Config): JsonObject | undefined {\n const orgs = credential.getOptionalStringArray('organizations');\n const personalAccessToken = credential.getOptionalString(\n 'personalAccessToken',\n );\n if (personalAccessToken !== undefined) {\n return omitUndefined({\n method: 'pat',\n personalAccessToken,\n orgs,\n });\n }\n\n const clientSecret = credential.getOptionalString('clientSecret');\n if (clientSecret !== undefined) {\n return omitUndefined({\n method: 'clientCredentials',\n clientId: credential.getOptionalString('clientId'),\n clientSecret,\n tenantId: credential.getOptionalString('tenantId'),\n orgs,\n });\n }\n\n const clientId = credential.getOptionalString('clientId');\n if (clientId !== undefined) {\n return omitUndefined({\n method: 'managedIdentity',\n clientId,\n tenantId: credential.getOptionalString('tenantId'),\n managedIdentityClientId: credential.getOptionalString(\n 'managedIdentityClientId',\n ),\n orgs,\n });\n }\n\n return undefined;\n}\n\nfunction convertBitbucketCloud(entries: Config[]): JsonObject[] {\n return entries.map(entry => {\n const username = entry.getOptionalString('username');\n const auth: JsonObject[] = [];\n\n const token = entry.getOptionalString('token');\n if (username !== undefined && token !== undefined) {\n auth.push({ method: 'token', username, token });\n }\n\n const appPassword = entry.getOptionalString('appPassword');\n if (username !== undefined && appPassword !== undefined) {\n auth.push({ method: 'appPassword', username, appPassword });\n }\n\n const clientId = entry.getOptionalString('clientId');\n const clientSecret = entry.getOptionalString('clientSecret');\n if (clientId !== undefined && clientSecret !== undefined) {\n auth.push({ method: 'oauth', clientId, clientSecret });\n }\n\n return {\n type: 'bitbucket-cloud',\n host: 'bitbucket.org',\n auth: withNoneAuthFallback(auth),\n };\n });\n}\n\nfunction convertBitbucketServer(entries: Config[]): JsonObject[] {\n return entries.map(entry => {\n const auth: JsonObject[] = [];\n\n const token = entry.getOptionalString('token');\n if (token !== undefined) {\n auth.push({ method: 'token', token });\n }\n\n const username = entry.getOptionalString('username');\n const password = entry.getOptionalString('password');\n if (username !== undefined && password !== undefined) {\n auth.push({ method: 'basic', username, password });\n }\n\n return omitUndefined({\n type: 'bitbucket-server',\n host: entry.getOptionalString('host'),\n apiBaseUrl: entry.getOptionalString('apiBaseUrl'),\n auth: withNoneAuthFallback(auth),\n });\n });\n}\n\nfunction convertGerrit(entries: Config[]): JsonObject[] {\n return entries.map(entry => {\n const auth: JsonObject[] = [];\n\n const username = entry.getOptionalString('username');\n const password = entry.getOptionalString('password');\n if (username !== undefined && password !== undefined) {\n auth.push({ method: 'basic', username, password });\n }\n\n return omitUndefined({\n type: 'gerrit',\n host: entry.getOptionalString('host'),\n baseUrl: entry.getOptionalString('baseUrl'),\n gitilesBaseUrl: entry.getOptionalString('gitilesBaseUrl'),\n cloneUrl: entry.getOptionalString('cloneUrl'),\n auth: withNoneAuthFallback(auth),\n });\n });\n}\n\nfunction convertGitea(entries: Config[]): JsonObject[] {\n return entries.map(entry => {\n const auth: JsonObject[] = [];\n\n const username = entry.getOptionalString('username');\n const password = entry.getOptionalString('password');\n if (username !== undefined && password !== undefined) {\n auth.push({ method: 'basic', username, password });\n }\n\n return omitUndefined({\n type: 'gitea',\n host: entry.getOptionalString('host'),\n baseUrl: entry.getOptionalString('baseUrl'),\n auth: withNoneAuthFallback(auth),\n });\n });\n}\n\nfunction convertHarness(entries: Config[]): JsonObject[] {\n return entries.map(entry => {\n const auth: JsonObject[] = [];\n\n const token = entry.getOptionalString('token');\n if (token !== undefined) {\n const apiKey = entry.getOptionalString('apiKey');\n auth.push(omitUndefined({ method: 'token', token, apiKey }));\n }\n\n return omitUndefined({\n type: 'harness',\n host: entry.getOptionalString('host'),\n auth,\n });\n });\n}\n\nfunction convertAwsCodeCommit(entries: Config[]): JsonObject[] {\n return entries.map(entry => {\n const auth: JsonObject[] = [];\n\n const accessKeyId = entry.getOptionalString('accessKeyId');\n const secretAccessKey = entry.getOptionalString('secretAccessKey');\n if (accessKeyId !== undefined && secretAccessKey !== undefined) {\n auth.push({ method: 'accessKey', accessKeyId, secretAccessKey });\n }\n\n const roleArn = entry.getOptionalString('roleArn');\n if (roleArn !== undefined) {\n auth.push(\n omitUndefined({\n method: 'assumeRole',\n roleArn,\n externalId: entry.getOptionalString('externalId'),\n }),\n );\n }\n\n const region = entry.getString('region');\n const host =\n entry.getOptionalString('host') ?? `${region}.console.aws.amazon.com`;\n\n return { type: 'aws-codecommit', host, region, auth };\n });\n}\n\nfunction convertAwsS3(entries: Config[]): JsonObject[] {\n return entries.map(entry => {\n const auth: JsonObject[] = [];\n\n const accessKeyId = entry.getOptionalString('accessKeyId');\n const secretAccessKey = entry.getOptionalString('secretAccessKey');\n if (accessKeyId !== undefined && secretAccessKey !== undefined) {\n auth.push({ method: 'accessKey', accessKeyId, secretAccessKey });\n }\n\n const roleArn = entry.getOptionalString('roleArn');\n if (roleArn !== undefined) {\n auth.push(\n omitUndefined({\n method: 'assumeRole',\n roleArn,\n externalId: entry.getOptionalString('externalId'),\n }),\n );\n }\n\n const endpoint = entry.getOptionalString('endpoint');\n const host = endpoint ? new URL(endpoint).host : 'amazonaws.com';\n\n return omitUndefined({\n type: 'aws-s3',\n host,\n endpoint,\n s3ForcePathStyle: entry.getOptionalBoolean('s3ForcePathStyle'),\n auth: withNoneAuthFallback(auth),\n });\n });\n}\n\nfunction convertAzureBlobStorage(entries: Config[]): JsonObject[] {\n return entries.map(entry => {\n const auth: JsonObject[] = [];\n\n const accountKey = entry.getOptionalString('accountKey');\n if (accountKey !== undefined) {\n auth.push({ method: 'accountKey', accountKey });\n }\n\n const sasToken = entry.getOptionalString('sasToken');\n if (sasToken !== undefined) {\n auth.push({ method: 'sasToken', sasToken });\n }\n\n const connectionString = entry.getOptionalString('connectionString');\n if (connectionString !== undefined) {\n auth.push({ method: 'connectionString', connectionString });\n }\n\n if (entry.has('aadCredential')) {\n auth.push({\n method: 'aadCredential',\n clientId: entry.getString('aadCredential.clientId'),\n tenantId: entry.getString('aadCredential.tenantId'),\n clientSecret: entry.getString('aadCredential.clientSecret'),\n });\n }\n\n const endpoint = entry.getOptionalString('endpoint');\n const host = endpoint\n ? new URL(endpoint).host\n : entry.getOptionalString('host') ?? 'blob.core.windows.net';\n\n return omitUndefined({\n type: 'azure-blob-storage',\n host,\n accountName: entry.getOptionalString('accountName'),\n endpoint,\n endpointSuffix: entry.getOptionalString('endpointSuffix'),\n auth: withNoneAuthFallback(auth),\n });\n });\n}\n\nfunction convertGoogleGcs(entries: Config[]): JsonObject[] {\n return entries.map(entry => {\n const auth: JsonObject[] = [];\n\n const clientEmail = entry.getOptionalString('clientEmail');\n const privateKey = entry.getOptionalString('privateKey');\n if (clientEmail !== undefined && privateKey !== undefined) {\n auth.push({ method: 'serviceAccount', clientEmail, privateKey });\n }\n\n return {\n type: 'google-gcs',\n host: 'storage.cloud.google.com',\n auth: withNoneAuthFallback(auth),\n };\n });\n}\n\nfunction withNoneAuthFallback(auth: JsonObject[]): JsonObject[] {\n return auth.length > 0 ? auth : [{ method: 'none' }];\n}\n\nfunction omitUndefined(\n input: Record<string, JsonValue | undefined>,\n): JsonObject {\n const out: JsonObject = {};\n for (const [key, value] of Object.entries(input)) {\n if (value !== undefined) {\n out[key] = value;\n }\n }\n return out;\n}\n"],"names":[],"mappings":";;AA0BO,SAAS,sBAAsB,MAAA,EAAyC;AAC7E,EAAA,MAAM,YAAA,GAAe,MAAA,CAAO,iBAAA,CAAkB,cAAc,CAAA;AAC5D,EAAA,IAAI,CAAC,YAAA,EAAc;AACjB,IAAA,OAAO,EAAC;AAAA,EACV;AAEA,EAAA,OAAO;AAAA,IACL,GAAG,oBAAA;AAAA,MACD,YAAA,CAAa,sBAAA,CAAuB,eAAe,CAAA,IAAK;AAAC,KAC3D;AAAA,IACA,GAAG,YAAA,CAAa,YAAA,CAAa,uBAAuB,OAAO,CAAA,IAAK,EA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,EACH,CAAC,CAAA;AACH;AAEA,SAAS,iBAAiB,OAAA,EAAiC;AACzD,EAAA,OAAO,OAAA,CAAQ,IAAI,CAAA,KAAA,KAAS;AAC1B,IAAA,MAAM,OAAqB,EAAC;AAE5B,IAAA,MAAM,WAAA,GAAc,KAAA,CAAM,iBAAA,CAAkB,aAAa,CAAA;AACzD,IAAA,MAAM,UAAA,GAAa,KAAA,CAAM,iBAAA,CAAkB,YAAY,CAAA;AACvD,IAAA,IAAI,WAAA,KAAgB,MAAA,IAAa,UAAA,KAAe,MAAA,EAAW;AACzD,MAAA,IAAA,CAAK,KAAK,EAAE,MAAA,EAAQ,gBAAA,EAAkB,WAAA,EAAa,YAAY,CAAA;AAAA,IACjE;AAEA,IAAA,OAAO;AAAA,MACL,IAAA,EAAM,YAAA;AAAA,MACN,IAAA,EAAM,0BAAA;AAAA,MACN,IAAA,EAAM,qBAAqB,IAAI;AAAA,KACjC;AAAA,EACF,CAAC,CAAA;AACH;AAEA,SAAS,qBAAqB,IAAA,EAAkC;AAC9D,EAAA,OAAO,IAAA,CAAK,SAAS,CAAA,GAAI,IAAA,GAAO,CAAC,EAAE,MAAA,EAAQ,QAAQ,CAAA;AACrD;AAEA,SAAS,cACP,KAAA,EACY;AACZ,EAAA,MAAM,MAAkB,EAAC;AACzB,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA,EAAG;AAChD,IAAA,IAAI,UAAU,MAAA,EAAW;AACvB,MAAA,GAAA,CAAI,GAAG,CAAA,GAAI,KAAA;AAAA,IACb;AAAA,EACF;AACA,EAAA,OAAO,GAAA;AACT;;;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var connections = require('@backstage/connections');
|
|
4
|
+
|
|
5
|
+
const connectionTypesMap = new Map(Object.entries(connections.connectionTypes));
|
|
6
|
+
function getConnectionType(key) {
|
|
7
|
+
return connectionTypesMap.get(key);
|
|
8
|
+
}
|
|
9
|
+
function isConnectionTypeKey(value) {
|
|
10
|
+
if (!value) return false;
|
|
11
|
+
return connectionTypesMap.has(value);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.getConnectionType = getConnectionType;
|
|
15
|
+
exports.isConnectionTypeKey = isConnectionTypeKey;
|
|
16
|
+
//# sourceMappingURL=lookup.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lookup.cjs.js","sources":["../../../../connections-node/src/lookup.ts"],"sourcesContent":["/*\n * Copyright 2026 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 LookupConnectionType,\n ConnectionTypeKey,\n connectionTypes,\n} from '@backstage/connections';\n\nconst connectionTypesMap = new Map(Object.entries(connectionTypes));\n\nexport function getConnectionType<T extends ConnectionTypeKey>(\n key: T,\n): LookupConnectionType<T> {\n return connectionTypesMap.get(key) as LookupConnectionType<T>;\n}\n\nexport function isConnectionTypeKey(\n value: string | undefined,\n): value is ConnectionTypeKey {\n if (!value) return false;\n\n return connectionTypesMap.has(value);\n}\n"],"names":["connectionTypes"],"mappings":";;;;AAqBA,MAAM,qBAAqB,IAAI,GAAA,CAAI,MAAA,CAAO,OAAA,CAAQA,2BAAe,CAAC,CAAA;AAE3D,SAAS,kBACd,GAAA,EACyB;AACzB,EAAA,OAAO,kBAAA,CAAmB,IAAI,GAAG,CAAA;AACnC;AAEO,SAAS,oBACd,KAAA,EAC4B;AAC5B,EAAA,IAAI,CAAC,OAAO,OAAO,KAAA;AAEnB,EAAA,OAAO,kBAAA,CAAmB,IAAI,KAAK,CAAA;AACrC;;;;;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
4
|
+
var DefaultConnectionsService = require('./DefaultConnectionsService.cjs.js');
|
|
5
|
+
|
|
6
|
+
function createConnectionsServiceFactory(service) {
|
|
7
|
+
return backendPluginApi.createServiceFactory({
|
|
8
|
+
service,
|
|
9
|
+
deps: {
|
|
10
|
+
pluginMetadata: backendPluginApi.coreServices.pluginMetadata,
|
|
11
|
+
rootLogger: backendPluginApi.coreServices.rootLogger,
|
|
12
|
+
logger: backendPluginApi.coreServices.logger,
|
|
13
|
+
config: backendPluginApi.coreServices.rootConfig
|
|
14
|
+
},
|
|
15
|
+
async createRootContext({ rootLogger, config }) {
|
|
16
|
+
return DefaultConnectionsService.DefaultConnectionsService.create({ logger: rootLogger, config });
|
|
17
|
+
},
|
|
18
|
+
async factory({ logger, pluginMetadata }, connectionsService) {
|
|
19
|
+
const pluginId = pluginMetadata.getId();
|
|
20
|
+
return connectionsService.forPlugin(pluginId, { logger });
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
const connectionsServiceRef = backendPluginApi.createServiceRef({
|
|
25
|
+
id: "core.connections",
|
|
26
|
+
scope: "plugin",
|
|
27
|
+
defaultFactory: async (service) => createConnectionsServiceFactory(service)
|
|
28
|
+
});
|
|
29
|
+
createConnectionsServiceFactory(
|
|
30
|
+
connectionsServiceRef
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
exports.connectionsServiceRef = connectionsServiceRef;
|
|
34
|
+
//# sourceMappingURL=service.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.cjs.js","sources":["../../../../connections-node/src/service.ts"],"sourcesContent":["/*\n * Copyright 2026 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 createServiceRef,\n type ServiceRef,\n} from '@backstage/backend-plugin-api';\nimport type { ConnectionsService } from '@backstage/connections';\nimport { DefaultConnectionsService } from './DefaultConnectionsService';\n\nfunction createConnectionsServiceFactory<\n TInstances extends 'singleton' | 'multiton',\n>(service: ServiceRef<ConnectionsService, 'plugin', TInstances>) {\n return createServiceFactory({\n service,\n deps: {\n pluginMetadata: coreServices.pluginMetadata,\n rootLogger: coreServices.rootLogger,\n logger: coreServices.logger,\n config: coreServices.rootConfig,\n },\n async createRootContext({ rootLogger, config }) {\n return DefaultConnectionsService.create({ logger: rootLogger, config });\n },\n\n async factory({ logger, pluginMetadata }, connectionsService) {\n const pluginId = pluginMetadata.getId();\n return connectionsService.forPlugin(pluginId, { logger });\n },\n });\n}\n\n/** @public */\nexport const connectionsServiceRef = createServiceRef<ConnectionsService>({\n id: 'core.connections',\n scope: 'plugin',\n defaultFactory: async service => createConnectionsServiceFactory(service),\n});\n\n/** @public */\nexport const connectionsServiceFactory = createConnectionsServiceFactory(\n connectionsServiceRef,\n);\n"],"names":["createServiceFactory","coreServices","DefaultConnectionsService","createServiceRef"],"mappings":";;;;;AAyBA,SAAS,gCAEP,OAAA,EAA+D;AAC/D,EAAA,OAAOA,qCAAA,CAAqB;AAAA,IAC1B,OAAA;AAAA,IACA,IAAA,EAAM;AAAA,MACJ,gBAAgBC,6BAAA,CAAa,cAAA;AAAA,MAC7B,YAAYA,6BAAA,CAAa,UAAA;AAAA,MACzB,QAAQA,6BAAA,CAAa,MAAA;AAAA,MACrB,QAAQA,6BAAA,CAAa;AAAA,KACvB;AAAA,IACA,MAAM,iBAAA,CAAkB,EAAE,UAAA,EAAY,QAAO,EAAG;AAC9C,MAAA,OAAOC,oDAA0B,MAAA,CAAO,EAAE,MAAA,EAAQ,UAAA,EAAY,QAAQ,CAAA;AAAA,IACxE,CAAA;AAAA,IAEA,MAAM,OAAA,CAAQ,EAAE,MAAA,EAAQ,cAAA,IAAkB,kBAAA,EAAoB;AAC5D,MAAA,MAAM,QAAA,GAAW,eAAe,KAAA,EAAM;AACtC,MAAA,OAAO,kBAAA,CAAmB,SAAA,CAAU,QAAA,EAAU,EAAE,QAAQ,CAAA;AAAA,IAC1D;AAAA,GACD,CAAA;AACH;AAGO,MAAM,wBAAwBC,iCAAA,CAAqC;AAAA,EACxE,EAAA,EAAI,kBAAA;AAAA,EACJ,KAAA,EAAO,QAAA;AAAA,EACP,cAAA,EAAgB,OAAM,OAAA,KAAW,+BAAA,CAAgC,OAAO;AAC1E,CAAC;AAGwC,+BAAA;AAAA,EACvC;AACF;;;;"}
|
|
@@ -8,7 +8,9 @@ var createInitializationResultCollector = require('./createInitializationResultC
|
|
|
8
8
|
var helpers$1 = require('./helpers.cjs.js');
|
|
9
9
|
var BackendStartupError = require('./BackendStartupError.cjs.js');
|
|
10
10
|
var createAllowBootFailurePredicate = require('./createAllowBootFailurePredicate.cjs.js');
|
|
11
|
-
var
|
|
11
|
+
var service = require('../connections-node/src/service.cjs.js');
|
|
12
|
+
require('../connections-node/src/lookup.cjs.js');
|
|
13
|
+
require('zod/v4');
|
|
12
14
|
var withDeclaredConnections = require('./withDeclaredConnections.cjs.js');
|
|
13
15
|
var OpaqueExtensionPointFactoryMiddleware = require('../backend-internal/src/wiring/OpaqueExtensionPointFactoryMiddleware.cjs.js');
|
|
14
16
|
var helpers = require('../backend-internal/src/wiring/helpers.cjs.js');
|
|
@@ -177,7 +179,7 @@ class BackendInitializer {
|
|
|
177
179
|
pluginId
|
|
178
180
|
);
|
|
179
181
|
if (impl) {
|
|
180
|
-
if (ref.id ===
|
|
182
|
+
if (ref.id === service.connectionsServiceRef.id) {
|
|
181
183
|
const registrations = this.#getConnectionRegistrations(
|
|
182
184
|
pluginId,
|
|
183
185
|
moduleId
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackendInitializer.cjs.js","sources":["../../src/wiring/BackendInitializer.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n BackendFeature,\n ExtensionPoint,\n coreServices,\n ServiceRef,\n ServiceFactory,\n LifecycleService,\n RootLifecycleService,\n createServiceFactory,\n ExtensionPointFactoryContext,\n} from '@backstage/backend-plugin-api';\nimport type { ConnectionRegistration } from '@backstage/backend-plugin-api/alpha';\nimport {\n ExtensionPointFactoryMiddleware,\n ServiceOrExtensionPoint,\n} from './types';\nimport {\n OpaqueExtensionPointFactoryMiddleware,\n unwrapFeature,\n} from '@internal/backend';\n// Direct internal import to avoid duplication\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport type {\n InternalBackendFeature,\n InternalBackendFeatureLoader,\n InternalBackendRegistrations,\n} from '../../../backend-plugin-api/src/wiring/types';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport type { InternalServiceFactory } from '../../../backend-plugin-api/src/services/system/types';\nimport { ConflictError, ForwardedError, toError } from '@backstage/errors';\nimport { DependencyGraph } from '../lib/DependencyGraph';\nimport { ServiceRegistry } from './ServiceRegistry';\nimport { createInitializationResultCollector } from './createInitializationResultCollector';\nimport { deepFreeze } from './helpers';\nimport type { RootInstanceMetadataServicePluginInfo } from '@backstage/backend-plugin-api';\nimport { BackendStartupResult } from './types';\nimport { BackendStartupError } from './BackendStartupError';\nimport { createAllowBootFailurePredicate } from './createAllowBootFailurePredicate';\nimport {\n connectionsServiceRef,\n type ConnectionsService,\n} from '@backstage/connections';\nimport { withDeclaredConnections } from './withDeclaredConnections';\n\nexport interface BackendRegisterInit {\n consumes: Set<ServiceOrExtensionPoint>;\n provides: Set<ServiceOrExtensionPoint>;\n init: {\n deps: { [name: string]: ServiceOrExtensionPoint };\n func: (deps: { [name: string]: unknown }) => Promise<void>;\n };\n}\n\n/**\n * A registry of backend instances, used to manage process shutdown hooks across all instances.\n */\nconst instanceRegistry = new (class InstanceRegistry {\n #registered = false;\n #instances = new Set<BackendInitializer>();\n\n register(instance: BackendInitializer) {\n if (!this.#registered) {\n this.#registered = true;\n\n process.addListener('SIGTERM', this.#exitHandler);\n process.addListener('SIGINT', this.#exitHandler);\n process.addListener('beforeExit', this.#exitHandler);\n }\n\n this.#instances.add(instance);\n }\n\n unregister(instance: BackendInitializer) {\n this.#instances.delete(instance);\n }\n\n #exitHandler = async () => {\n try {\n const results = await Promise.allSettled(\n Array.from(this.#instances).map(b => b.stop()),\n );\n const errors = results.flatMap(r =>\n r.status === 'rejected' ? [r.reason] : [],\n );\n\n if (errors.length > 0) {\n for (const error of errors) {\n console.error(error);\n }\n process.exit(1);\n } else {\n process.exit(0);\n }\n } catch (error) {\n console.error(error);\n process.exit(1);\n }\n };\n})();\n\nfunction callerKey(pluginId: string, moduleId?: string): string {\n return moduleId ? `${pluginId}\\0${moduleId}` : pluginId;\n}\n\nfunction collectCallerConnectionRegistrations(\n registrations: ReturnType<InternalBackendRegistrations['getRegistrations']>,\n): Map<string, ConnectionRegistration[]> {\n const byCaller = new Map<string, ConnectionRegistration[]>();\n\n for (const registration of registrations) {\n const declared =\n 'connections' in registration && Array.isArray(registration.connections)\n ? registration.connections\n : [];\n if (declared.length === 0) continue;\n\n const key =\n 'moduleId' in registration\n ? callerKey(registration.pluginId, registration.moduleId)\n : callerKey(registration.pluginId);\n\n const target =\n byCaller.get(key) ??\n (() => {\n const list: ConnectionRegistration[] = [];\n byCaller.set(key, list);\n return list;\n })();\n\n for (const decl of declared) {\n if (!target.some(c => c.type === decl.type)) {\n target.push({ ...decl });\n }\n }\n }\n\n return byCaller;\n}\n\nfunction createRootInstanceMetadataServiceFactory(\n rawRegistrations: InternalBackendRegistrations[],\n) {\n const installedPlugins: Map<string, RootInstanceMetadataServicePluginInfo> =\n new Map();\n const registrations = rawRegistrations\n .filter(registration => registration.featureType === 'registrations')\n .flatMap(registration => registration.getRegistrations());\n const plugins = registrations.filter(\n registration =>\n registration.type === 'plugin' || registration.type === 'plugin-v1.1',\n );\n const modules = registrations.filter(\n registration =>\n registration.type === 'module' || registration.type === 'module-v1.1',\n );\n for (const plugin of plugins) {\n const { pluginId } = plugin;\n if (!installedPlugins.get(pluginId)) {\n installedPlugins.set(pluginId, {\n pluginId,\n modules: [],\n });\n }\n }\n for (const module of modules) {\n const { pluginId, moduleId } = module;\n const installedPlugin = installedPlugins.get(pluginId);\n if (installedPlugin) {\n (installedPlugin.modules as Array<{ moduleId: string }>).push({\n moduleId,\n });\n }\n }\n\n return createServiceFactory({\n service: coreServices.rootInstanceMetadata,\n deps: {},\n factory: async () => {\n const readonlyInstalledPlugins = deepFreeze([\n ...installedPlugins.values(),\n ]);\n const instanceMetadata = {\n getInstalledPlugins: () => Promise.resolve(readonlyInstalledPlugins),\n };\n\n return instanceMetadata;\n },\n });\n}\n\nexport class BackendInitializer {\n #startPromise?: Promise<{ result: BackendStartupResult }>;\n #stopPromise?: Promise<void>;\n #registrations = new Array<InternalBackendRegistrations>();\n #extensionPoints = new Map<\n string,\n {\n pluginId: string;\n factory: (context: ExtensionPointFactoryContext) => unknown;\n }\n >();\n #serviceRegistry: ServiceRegistry;\n #registeredFeatures = new Array<Promise<BackendFeature>>();\n #registeredFeatureLoaders = new Array<InternalBackendFeatureLoader>();\n #extensionPointFactoryMiddleware: ExtensionPointFactoryMiddleware[];\n #callerConnectionRegistrations = new Map<string, ConnectionRegistration[]>();\n\n #getConnectionRegistrations(\n pluginId: string,\n moduleId?: string,\n ): ConnectionRegistration[] {\n if (moduleId) {\n return (\n this.#callerConnectionRegistrations.get(\n callerKey(pluginId, moduleId),\n ) ?? []\n );\n }\n // Aggregate registrations from the plugin\n const result: ConnectionRegistration[] = [];\n for (const [key, registrations] of this.#callerConnectionRegistrations) {\n if (key === pluginId) {\n result.push(...registrations);\n }\n }\n return result;\n }\n\n #unhandledRejectionHandler?: (reason: Error) => void;\n #uncaughtExceptionHandler?: (error: Error) => void;\n\n constructor(\n defaultApiFactories: ServiceFactory[],\n extensionPointFactoryMiddleware?: ExtensionPointFactoryMiddleware[],\n ) {\n this.#serviceRegistry = ServiceRegistry.create([...defaultApiFactories]);\n this.#extensionPointFactoryMiddleware =\n extensionPointFactoryMiddleware ?? [];\n }\n\n async #getInitDeps(\n deps: { [name: string]: ServiceOrExtensionPoint },\n resultCollector: ReturnType<typeof createInitializationResultCollector>,\n pluginId: string,\n moduleId?: 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 ep = this.#extensionPoints.get(ref.id);\n if (ep) {\n if (ep.pluginId !== pluginId) {\n throw new Error(\n `Illegal dependency: Module '${moduleId}' for plugin '${pluginId}' attempted to depend on extension point '${ref.id}' for plugin '${ep.pluginId}'. Extension points can only be used within their plugin's scope.`,\n );\n }\n if (!moduleId) {\n throw new Error(\n `Rejected dependency on extension point ${ref.id} from outside of a module`,\n );\n }\n let epImpl = ep.factory({\n reportModuleStartupFailure: ({ error }) => {\n resultCollector.amendPluginModuleResult(pluginId, moduleId, error);\n },\n });\n for (const mw of this.#extensionPointFactoryMiddleware) {\n const internal = OpaqueExtensionPointFactoryMiddleware.toInternal(mw);\n if (internal.extensionPointId === ref.id) {\n epImpl = await internal.middleware(epImpl);\n }\n }\n result.set(name, epImpl);\n } else {\n const impl = await this.#serviceRegistry.get(\n ref as ServiceRef<unknown>,\n pluginId,\n );\n if (impl) {\n if (ref.id === connectionsServiceRef.id) {\n const registrations = this.#getConnectionRegistrations(\n pluginId,\n moduleId,\n );\n result.set(\n name,\n withDeclaredConnections(\n impl as ConnectionsService,\n registrations,\n ),\n );\n } else {\n result.set(name, impl);\n }\n } else {\n missingRefs.add(ref);\n }\n }\n }\n\n if (missingRefs.size > 0) {\n const missing = Array.from(missingRefs).join(', ');\n const target = moduleId\n ? `module '${moduleId}' for plugin '${pluginId}'`\n : `plugin '${pluginId}'`;\n throw new Error(\n `Service or extension point dependencies of ${target} are missing for the following ref(s): ${missing}`,\n );\n }\n\n return Object.fromEntries(result);\n }\n\n add(feature: BackendFeature | Promise<BackendFeature>) {\n if (this.#startPromise) {\n throw new Error('feature can not be added after the backend has started');\n }\n this.#registeredFeatures.push(Promise.resolve(feature));\n }\n\n #addFeature(feature: BackendFeature) {\n if (isServiceFactory(feature)) {\n this.#serviceRegistry.add(feature);\n } else if (isBackendFeatureLoader(feature)) {\n this.#registeredFeatureLoaders.push(feature);\n } else if (isBackendRegistrations(feature)) {\n this.#registrations.push(feature);\n } else {\n throw new Error(\n `Failed to add feature, invalid feature ${JSON.stringify(feature)}`,\n );\n }\n }\n\n async start(): Promise<{ result: BackendStartupResult }> {\n if (this.#startPromise) {\n throw new Error('Backend has already started');\n }\n if (this.#stopPromise) {\n throw new Error('Backend has already stopped');\n }\n\n instanceRegistry.register(this);\n\n this.#startPromise = this.#doStart();\n return await this.#startPromise;\n }\n\n async #doStart(): Promise<{ result: BackendStartupResult }> {\n this.#serviceRegistry.checkForCircularDeps();\n\n for (const feature of this.#registeredFeatures) {\n this.#addFeature(await feature);\n }\n\n await this.#applyBackendFeatureLoaders(this.#registeredFeatureLoaders);\n\n this.#serviceRegistry.add(\n createRootInstanceMetadataServiceFactory(this.#registrations),\n );\n\n // This makes sure that any uncaught errors or unhandled rejections are\n // caught and logged, rather than terminating the process. We register these\n // as early as possible while still using the root logger service, the\n // tradeoff that if there are any unhandled errors as part of the that\n // instationation, it will cause the process to crash. If there are multiple\n // backend instances, each instance will log the error, because we can't\n // determine which instance the error came from.\n if (process.env.NODE_ENV !== 'test') {\n const rootLogger = await this.#serviceRegistry.get(\n coreServices.rootLogger,\n 'root',\n );\n this.#unhandledRejectionHandler = (reason: Error) => {\n rootLogger\n ?.child({ type: 'unhandledRejection' })\n ?.error('Unhandled rejection', reason);\n };\n this.#uncaughtExceptionHandler = (error: Error) => {\n rootLogger\n ?.child({ type: 'uncaughtException' })\n ?.error('Uncaught exception', error);\n };\n process.on('unhandledRejection', this.#unhandledRejectionHandler);\n process.on('uncaughtException', this.#uncaughtExceptionHandler);\n }\n\n // Initialize all root scoped services\n await this.#serviceRegistry.initializeEagerServicesWithScope('root');\n\n const rootConfig = await this.#serviceRegistry.get(\n coreServices.rootConfig,\n 'root',\n );\n const rootLogger = await this.#serviceRegistry.get(\n coreServices.rootLogger,\n 'root',\n );\n\n const allRegistrations = this.#registrations.flatMap(f =>\n f.getRegistrations(),\n );\n\n this.#callerConnectionRegistrations =\n collectCallerConnectionRegistrations(allRegistrations);\n\n const allPluginIds = [\n ...new Set(\n allRegistrations.flatMap(r =>\n 'pluginId' in r && typeof r.pluginId === 'string' ? [r.pluginId] : [],\n ),\n ),\n ];\n\n const resultCollector = createInitializationResultCollector({\n pluginIds: allPluginIds,\n logger: rootLogger,\n allowBootFailurePredicate: createAllowBootFailurePredicate(rootConfig),\n });\n\n const { pluginInits, moduleInits } = this.#enumerateRegistrations(\n allRegistrations,\n resultCollector,\n );\n\n // All plugins are initialized in parallel\n await Promise.all(\n [...pluginInits.keys()].map(async pluginId => {\n try {\n // Initialize all eager services\n await this.#serviceRegistry.initializeEagerServicesWithScope(\n 'plugin',\n pluginId,\n );\n\n // Modules are initialized before plugins, so that they can provide extension to the plugin\n const modules = moduleInits.get(pluginId);\n if (modules) {\n const tree = DependencyGraph.fromIterable(\n Array.from(modules).map(([moduleId, moduleInit]) => ({\n value: { moduleId, moduleInit },\n // Relationships are reversed at this point since we're only interested in the extension points.\n // If a modules provides extension point A we want it to be initialized AFTER all modules\n // that depend on extension point A, so that they can provide their extensions.\n consumes: Array.from(moduleInit.provides).map(p => p.id),\n provides: Array.from(moduleInit.consumes).map(c => c.id),\n })),\n );\n const circular = tree.detectCircularDependency();\n if (circular) {\n throw new ConflictError(\n `Circular dependency detected for modules of plugin '${pluginId}', ${circular\n .map(({ moduleId }) => `'${moduleId}'`)\n .join(' -> ')}`,\n );\n }\n await tree.parallelTopologicalTraversal(\n async ({ moduleId, moduleInit }) => {\n try {\n const moduleDeps = await this.#getInitDeps(\n moduleInit.init.deps,\n resultCollector,\n pluginId,\n moduleId,\n );\n await moduleInit.init.func(moduleDeps);\n resultCollector.onPluginModuleResult(pluginId, moduleId);\n } catch (error: unknown) {\n const err = toError(error);\n resultCollector.onPluginModuleResult(pluginId, moduleId, err);\n }\n },\n );\n }\n\n // Once all modules have been initialized, we can initialize the plugin itself\n const pluginInit = pluginInits.get(pluginId);\n // We allow modules to be installed without the accompanying plugin, so the plugin may not exist\n if (pluginInit) {\n const pluginDeps = await this.#getInitDeps(\n pluginInit.init.deps,\n resultCollector,\n pluginId,\n );\n await pluginInit.init.func(pluginDeps);\n }\n\n resultCollector.onPluginResult(pluginId);\n\n // Once the plugin and all modules have been initialized, we can signal that the plugin has stared up successfully\n const lifecycleService = await this.#getPluginLifecycleImpl(pluginId);\n await lifecycleService.startup();\n } catch (error: unknown) {\n const err = toError(error);\n resultCollector.onPluginResult(pluginId, err);\n }\n }),\n ).catch(error => {\n throw new ForwardedError(\n 'Unexpected uncaught backend startup error',\n error,\n );\n });\n\n const result = resultCollector.finalize();\n if (result.outcome === 'failure') {\n throw new BackendStartupError(result);\n }\n\n // Once all plugins and modules have been initialized, we can signal that the backend has started up successfully\n const lifecycleService = await this.#getRootLifecycleImpl();\n await lifecycleService.startup();\n\n return { result };\n }\n\n #enumerateRegistrations(\n allRegistrations: ReturnType<\n InternalBackendRegistrations['getRegistrations']\n >,\n resultCollector: ReturnType<typeof createInitializationResultCollector>,\n ): {\n pluginInits: Map<string, BackendRegisterInit>;\n moduleInits: Map<string, Map<string, BackendRegisterInit>>;\n } {\n const pluginInits = new Map<string, BackendRegisterInit>();\n const moduleInits = new Map<string, Map<string, BackendRegisterInit>>();\n\n for (const r of allRegistrations) {\n const addedExtensionPointIds: string[] = [];\n try {\n const provides = new Set<ExtensionPoint<unknown>>();\n\n if (r.type === 'plugin' || r.type === 'module') {\n // Handle v1 format: Array<readonly [ExtensionPoint<unknown>, unknown]>\n for (const [extRef, extImpl] of r.extensionPoints) {\n if (this.#extensionPoints.has(extRef.id)) {\n throw new Error(\n `ExtensionPoint with ID '${extRef.id}' is already registered`,\n );\n }\n this.#extensionPoints.set(extRef.id, {\n pluginId: r.pluginId,\n factory: () => extImpl,\n });\n addedExtensionPointIds.push(extRef.id);\n provides.add(extRef);\n }\n } else if (r.type === 'plugin-v1.1' || r.type === 'module-v1.1') {\n // Handle v1.1 format: Array<ExtensionPointRegistration>\n for (const extReg of r.extensionPoints) {\n if (this.#extensionPoints.has(extReg.extensionPoint.id)) {\n throw new Error(\n `ExtensionPoint with ID '${extReg.extensionPoint.id}' is already registered`,\n );\n }\n this.#extensionPoints.set(extReg.extensionPoint.id, {\n pluginId: r.pluginId,\n factory: extReg.factory,\n });\n addedExtensionPointIds.push(extReg.extensionPoint.id);\n provides.add(extReg.extensionPoint);\n }\n }\n\n if (r.type === 'plugin' || r.type === 'plugin-v1.1') {\n if (pluginInits.has(r.pluginId)) {\n throw new Error(`Plugin '${r.pluginId}' is already registered`);\n }\n pluginInits.set(r.pluginId, {\n provides,\n consumes: new Set(Object.values(r.init.deps)),\n init: r.init,\n });\n } else if (r.type === 'module' || r.type === 'module-v1.1') {\n let modules = moduleInits.get(r.pluginId);\n if (!modules) {\n modules = new Map();\n moduleInits.set(r.pluginId, modules);\n }\n if (modules.has(r.moduleId)) {\n throw new Error(\n `Module '${r.moduleId}' for plugin '${r.pluginId}' is already registered`,\n );\n }\n modules.set(r.moduleId, {\n provides,\n consumes: new Set(Object.values(r.init.deps)),\n init: r.init,\n });\n } else {\n throw new Error(`Invalid registration type '${(r as any).type}'`);\n }\n } catch (error: unknown) {\n const err = toError(error);\n // Clean up partially registered extension points\n for (const id of addedExtensionPointIds) {\n this.#extensionPoints.delete(id);\n }\n if ('pluginId' in r && 'moduleId' in r) {\n resultCollector.onPluginModuleResult(r.pluginId, r.moduleId, err);\n } else if ('pluginId' in r) {\n pluginInits.delete(r.pluginId);\n moduleInits.delete(r.pluginId);\n resultCollector.onPluginResult(r.pluginId, err);\n } else {\n throw err;\n }\n }\n }\n\n return { pluginInits, moduleInits };\n }\n\n // It's fine to call .stop() multiple times, which for example can happen with manual stop + process exit\n async stop(): Promise<void> {\n instanceRegistry.unregister(this);\n\n if (!this.#stopPromise) {\n this.#stopPromise = this.#doStop();\n }\n await this.#stopPromise;\n }\n\n async #doStop(): Promise<void> {\n if (!this.#startPromise) {\n return;\n }\n\n try {\n await this.#startPromise;\n } catch (error) {\n // The startup failed, but we may still want to do cleanup so we continue silently\n }\n\n const rootLifecycleService = await this.#getRootLifecycleImpl();\n\n // Root services like the health one need to immediately be notified of the shutdown\n await rootLifecycleService.beforeShutdown();\n\n // Get all plugins.\n const allPlugins = new Set<string>();\n for (const feature of this.#registrations) {\n for (const r of feature.getRegistrations()) {\n if (r.type === 'plugin' || r.type === 'plugin-v1.1') {\n allPlugins.add(r.pluginId);\n }\n }\n }\n\n // Iterate through all plugins and run their shutdown hooks.\n await Promise.allSettled(\n [...allPlugins].map(async pluginId => {\n const lifecycleService = await this.#getPluginLifecycleImpl(pluginId);\n await lifecycleService.shutdown();\n }),\n );\n\n // Once all plugin shutdown hooks are done, run root shutdown hooks.\n await rootLifecycleService.shutdown();\n\n // Clean up process event listeners to prevent memory leaks and duplicate logging\n if (this.#unhandledRejectionHandler) {\n process.off('unhandledRejection', this.#unhandledRejectionHandler);\n this.#unhandledRejectionHandler = undefined;\n }\n if (this.#uncaughtExceptionHandler) {\n process.off('uncaughtException', this.#uncaughtExceptionHandler);\n this.#uncaughtExceptionHandler = undefined;\n }\n }\n\n // Bit of a hacky way to grab the lifecycle services, potentially find a nicer way to do this\n async #getRootLifecycleImpl(): Promise<\n RootLifecycleService & {\n startup(): Promise<void>;\n beforeShutdown(): Promise<void>;\n shutdown(): Promise<void>;\n }\n > {\n const lifecycleService = await this.#serviceRegistry.get(\n coreServices.rootLifecycle,\n 'root',\n );\n\n const service = lifecycleService as any;\n if (\n service &&\n typeof service.startup === 'function' &&\n typeof service.shutdown === 'function'\n ) {\n return service;\n }\n\n throw new Error('Unexpected root lifecycle service implementation');\n }\n\n async #getPluginLifecycleImpl(\n pluginId: string,\n ): Promise<\n LifecycleService & { startup(): Promise<void>; shutdown(): Promise<void> }\n > {\n const lifecycleService = await this.#serviceRegistry.get(\n coreServices.lifecycle,\n pluginId,\n );\n\n const service = lifecycleService as any;\n if (\n service &&\n typeof service.startup === 'function' &&\n typeof service.shutdown === 'function'\n ) {\n return service;\n }\n\n throw new Error('Unexpected plugin lifecycle service implementation');\n }\n\n async #applyBackendFeatureLoaders(loaders: InternalBackendFeatureLoader[]) {\n const servicesAddedByLoaders = new Map<\n string,\n InternalBackendFeatureLoader\n >();\n\n for (const loader of loaders) {\n const deps = new Map<string, unknown>();\n const missingRefs = new Set<ServiceOrExtensionPoint>();\n\n for (const [name, ref] of Object.entries(loader.deps ?? {})) {\n if (ref.scope !== 'root') {\n throw new Error(\n `Feature loaders can only depend on root scoped services, but '${name}' is scoped to '${ref.scope}'. Offending loader is ${loader.description}`,\n );\n }\n const impl = await this.#serviceRegistry.get(\n ref as ServiceRef<unknown>,\n 'root',\n );\n if (impl) {\n deps.set(name, impl);\n } else {\n missingRefs.add(ref);\n }\n }\n\n if (missingRefs.size > 0) {\n const missing = Array.from(missingRefs).join(', ');\n throw new Error(\n `No service available for the following ref(s): ${missing}, depended on by feature loader ${loader.description}`,\n );\n }\n\n const result = await loader\n .loader(Object.fromEntries(deps))\n .then(features => features.map(unwrapFeature))\n .catch(error => {\n throw new ForwardedError(\n `Feature loader ${loader.description} failed`,\n error,\n );\n });\n\n let didAddServiceFactory = false;\n const newLoaders = new Array<InternalBackendFeatureLoader>();\n\n for await (const feature of result) {\n if (isBackendFeatureLoader(feature)) {\n newLoaders.push(feature);\n } else {\n // This block makes sure that feature loaders do not provide duplicate\n // implementations for the same service, but at the same time allows\n // service factories provided by feature loaders to be overridden by\n // ones that are explicitly installed with backend.add(serviceFactory).\n //\n // If a factory has already been explicitly installed, the service\n // factory provided by the loader will simply be ignored.\n if (isServiceFactory(feature) && !feature.service.multiton) {\n const conflictingLoader = servicesAddedByLoaders.get(\n feature.service.id,\n );\n if (conflictingLoader) {\n throw new Error(\n `Duplicate service implementations provided for ${feature.service.id} by both feature loader ${loader.description} and feature loader ${conflictingLoader.description}`,\n );\n }\n\n // Check that this service wasn't already explicitly added by backend.add(serviceFactory)\n if (!this.#serviceRegistry.hasBeenAdded(feature.service)) {\n didAddServiceFactory = true;\n servicesAddedByLoaders.set(feature.service.id, loader);\n this.#addFeature(feature);\n }\n } else {\n this.#addFeature(feature);\n }\n }\n }\n\n // Every time we add a new service factory we need to make sure that we don't have circular dependencies\n if (didAddServiceFactory) {\n this.#serviceRegistry.checkForCircularDeps();\n }\n\n // Apply loaders recursively, depth-first\n if (newLoaders.length > 0) {\n await this.#applyBackendFeatureLoaders(newLoaders);\n }\n }\n }\n}\n\nfunction toInternalBackendFeature(\n feature: BackendFeature,\n): InternalBackendFeature {\n if (feature.$$type !== '@backstage/BackendFeature') {\n throw new Error(`Invalid BackendFeature, bad type '${feature.$$type}'`);\n }\n const internal = feature as InternalBackendFeature;\n if (internal.version !== 'v1') {\n throw new Error(\n `Invalid BackendFeature, bad version '${internal.version}'`,\n );\n }\n return internal;\n}\n\nfunction isServiceFactory(\n feature: BackendFeature,\n): feature is InternalServiceFactory {\n const internal = toInternalBackendFeature(feature);\n if (internal.featureType === 'service') {\n return true;\n }\n // Backwards compatibility for v1 registrations that use duck typing\n return 'service' in internal;\n}\n\nfunction isBackendRegistrations(\n feature: BackendFeature,\n): feature is InternalBackendRegistrations {\n const internal = toInternalBackendFeature(feature);\n if (internal.featureType === 'registrations') {\n return true;\n }\n // Backwards compatibility for v1 registrations that use duck typing\n return 'getRegistrations' in internal;\n}\n\nfunction isBackendFeatureLoader(\n feature: BackendFeature,\n): feature is InternalBackendFeatureLoader {\n return toInternalBackendFeature(feature).featureType === 'loader';\n}\n"],"names":["createServiceFactory","coreServices","deepFreeze","ServiceRegistry","OpaqueExtensionPointFactoryMiddleware","connectionsServiceRef","withDeclaredConnections","rootLogger","createInitializationResultCollector","createAllowBootFailurePredicate","DependencyGraph","ConflictError","toError","lifecycleService","ForwardedError","BackendStartupError","unwrapFeature"],"mappings":";;;;;;;;;;;;;;;AAwEA,MAAM,gBAAA,GAAmB,IAAK,MAAM,gBAAA,CAAiB;AAAA,EACnD,WAAA,GAAc,KAAA;AAAA,EACd,UAAA,uBAAiB,GAAA,EAAwB;AAAA,EAEzC,SAAS,QAAA,EAA8B;AACrC,IAAA,IAAI,CAAC,KAAK,WAAA,EAAa;AACrB,MAAA,IAAA,CAAK,WAAA,GAAc,IAAA;AAEnB,MAAA,OAAA,CAAQ,WAAA,CAAY,SAAA,EAAW,IAAA,CAAK,YAAY,CAAA;AAChD,MAAA,OAAA,CAAQ,WAAA,CAAY,QAAA,EAAU,IAAA,CAAK,YAAY,CAAA;AAC/C,MAAA,OAAA,CAAQ,WAAA,CAAY,YAAA,EAAc,IAAA,CAAK,YAAY,CAAA;AAAA,IACrD;AAEA,IAAA,IAAA,CAAK,UAAA,CAAW,IAAI,QAAQ,CAAA;AAAA,EAC9B;AAAA,EAEA,WAAW,QAAA,EAA8B;AACvC,IAAA,IAAA,CAAK,UAAA,CAAW,OAAO,QAAQ,CAAA;AAAA,EACjC;AAAA,EAEA,eAAe,YAAY;AACzB,IAAA,IAAI;AACF,MAAA,MAAM,OAAA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AgB,eAAA,EAAiB;AAC5C,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,OAAO,kBAAA,IAAsB,QAAA;AAC/B;AAEA,SAAS,uBACP,OAAA,EACyC;AACzC,EAAA,OAAO,wBAAA,CAAyB,OAAO,CAAA,CAAE,WAAA,KAAgB,QAAA;AAC3D;;;;"}
|
|
1
|
+
{"version":3,"file":"BackendInitializer.cjs.js","sources":["../../src/wiring/BackendInitializer.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n BackendFeature,\n ExtensionPoint,\n coreServices,\n ServiceRef,\n ServiceFactory,\n LifecycleService,\n RootLifecycleService,\n createServiceFactory,\n ExtensionPointFactoryContext,\n} from '@backstage/backend-plugin-api';\nimport type { ConnectionRegistration } from '@backstage/backend-plugin-api/alpha';\nimport {\n ExtensionPointFactoryMiddleware,\n ServiceOrExtensionPoint,\n} from './types';\nimport {\n OpaqueExtensionPointFactoryMiddleware,\n unwrapFeature,\n} from '@internal/backend';\n// Direct internal import to avoid duplication\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport type {\n InternalBackendFeature,\n InternalBackendFeatureLoader,\n InternalBackendRegistrations,\n} from '../../../backend-plugin-api/src/wiring/types';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport type { InternalServiceFactory } from '../../../backend-plugin-api/src/services/system/types';\nimport { ConflictError, ForwardedError, toError } from '@backstage/errors';\nimport { DependencyGraph } from '../lib/DependencyGraph';\nimport { ServiceRegistry } from './ServiceRegistry';\nimport { createInitializationResultCollector } from './createInitializationResultCollector';\nimport { deepFreeze } from './helpers';\nimport type { RootInstanceMetadataServicePluginInfo } from '@backstage/backend-plugin-api';\nimport { BackendStartupResult } from './types';\nimport { BackendStartupError } from './BackendStartupError';\nimport { createAllowBootFailurePredicate } from './createAllowBootFailurePredicate';\nimport type { ConnectionsService } from '@backstage/connections';\nimport { connectionsServiceRef } from '@backstage/connections-node';\nimport { withDeclaredConnections } from './withDeclaredConnections';\n\nexport interface BackendRegisterInit {\n consumes: Set<ServiceOrExtensionPoint>;\n provides: Set<ServiceOrExtensionPoint>;\n init: {\n deps: { [name: string]: ServiceOrExtensionPoint };\n func: (deps: { [name: string]: unknown }) => Promise<void>;\n };\n}\n\n/**\n * A registry of backend instances, used to manage process shutdown hooks across all instances.\n */\nconst instanceRegistry = new (class InstanceRegistry {\n #registered = false;\n #instances = new Set<BackendInitializer>();\n\n register(instance: BackendInitializer) {\n if (!this.#registered) {\n this.#registered = true;\n\n process.addListener('SIGTERM', this.#exitHandler);\n process.addListener('SIGINT', this.#exitHandler);\n process.addListener('beforeExit', this.#exitHandler);\n }\n\n this.#instances.add(instance);\n }\n\n unregister(instance: BackendInitializer) {\n this.#instances.delete(instance);\n }\n\n #exitHandler = async () => {\n try {\n const results = await Promise.allSettled(\n Array.from(this.#instances).map(b => b.stop()),\n );\n const errors = results.flatMap(r =>\n r.status === 'rejected' ? [r.reason] : [],\n );\n\n if (errors.length > 0) {\n for (const error of errors) {\n console.error(error);\n }\n process.exit(1);\n } else {\n process.exit(0);\n }\n } catch (error) {\n console.error(error);\n process.exit(1);\n }\n };\n})();\n\nfunction callerKey(pluginId: string, moduleId?: string): string {\n return moduleId ? `${pluginId}\\0${moduleId}` : pluginId;\n}\n\nfunction collectCallerConnectionRegistrations(\n registrations: ReturnType<InternalBackendRegistrations['getRegistrations']>,\n): Map<string, ConnectionRegistration[]> {\n const byCaller = new Map<string, ConnectionRegistration[]>();\n\n for (const registration of registrations) {\n const declared =\n 'connections' in registration && Array.isArray(registration.connections)\n ? registration.connections\n : [];\n if (declared.length === 0) continue;\n\n const key =\n 'moduleId' in registration\n ? callerKey(registration.pluginId, registration.moduleId)\n : callerKey(registration.pluginId);\n\n const target =\n byCaller.get(key) ??\n (() => {\n const list: ConnectionRegistration[] = [];\n byCaller.set(key, list);\n return list;\n })();\n\n for (const decl of declared) {\n if (!target.some(c => c.type === decl.type)) {\n target.push({ ...decl });\n }\n }\n }\n\n return byCaller;\n}\n\nfunction createRootInstanceMetadataServiceFactory(\n rawRegistrations: InternalBackendRegistrations[],\n) {\n const installedPlugins: Map<string, RootInstanceMetadataServicePluginInfo> =\n new Map();\n const registrations = rawRegistrations\n .filter(registration => registration.featureType === 'registrations')\n .flatMap(registration => registration.getRegistrations());\n const plugins = registrations.filter(\n registration =>\n registration.type === 'plugin' || registration.type === 'plugin-v1.1',\n );\n const modules = registrations.filter(\n registration =>\n registration.type === 'module' || registration.type === 'module-v1.1',\n );\n for (const plugin of plugins) {\n const { pluginId } = plugin;\n if (!installedPlugins.get(pluginId)) {\n installedPlugins.set(pluginId, {\n pluginId,\n modules: [],\n });\n }\n }\n for (const module of modules) {\n const { pluginId, moduleId } = module;\n const installedPlugin = installedPlugins.get(pluginId);\n if (installedPlugin) {\n (installedPlugin.modules as Array<{ moduleId: string }>).push({\n moduleId,\n });\n }\n }\n\n return createServiceFactory({\n service: coreServices.rootInstanceMetadata,\n deps: {},\n factory: async () => {\n const readonlyInstalledPlugins = deepFreeze([\n ...installedPlugins.values(),\n ]);\n const instanceMetadata = {\n getInstalledPlugins: () => Promise.resolve(readonlyInstalledPlugins),\n };\n\n return instanceMetadata;\n },\n });\n}\n\nexport class BackendInitializer {\n #startPromise?: Promise<{ result: BackendStartupResult }>;\n #stopPromise?: Promise<void>;\n #registrations = new Array<InternalBackendRegistrations>();\n #extensionPoints = new Map<\n string,\n {\n pluginId: string;\n factory: (context: ExtensionPointFactoryContext) => unknown;\n }\n >();\n #serviceRegistry: ServiceRegistry;\n #registeredFeatures = new Array<Promise<BackendFeature>>();\n #registeredFeatureLoaders = new Array<InternalBackendFeatureLoader>();\n #extensionPointFactoryMiddleware: ExtensionPointFactoryMiddleware[];\n #callerConnectionRegistrations = new Map<string, ConnectionRegistration[]>();\n\n #getConnectionRegistrations(\n pluginId: string,\n moduleId?: string,\n ): ConnectionRegistration[] {\n if (moduleId) {\n return (\n this.#callerConnectionRegistrations.get(\n callerKey(pluginId, moduleId),\n ) ?? []\n );\n }\n // Aggregate registrations from the plugin\n const result: ConnectionRegistration[] = [];\n for (const [key, registrations] of this.#callerConnectionRegistrations) {\n if (key === pluginId) {\n result.push(...registrations);\n }\n }\n return result;\n }\n\n #unhandledRejectionHandler?: (reason: Error) => void;\n #uncaughtExceptionHandler?: (error: Error) => void;\n\n constructor(\n defaultApiFactories: ServiceFactory[],\n extensionPointFactoryMiddleware?: ExtensionPointFactoryMiddleware[],\n ) {\n this.#serviceRegistry = ServiceRegistry.create([...defaultApiFactories]);\n this.#extensionPointFactoryMiddleware =\n extensionPointFactoryMiddleware ?? [];\n }\n\n async #getInitDeps(\n deps: { [name: string]: ServiceOrExtensionPoint },\n resultCollector: ReturnType<typeof createInitializationResultCollector>,\n pluginId: string,\n moduleId?: 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 ep = this.#extensionPoints.get(ref.id);\n if (ep) {\n if (ep.pluginId !== pluginId) {\n throw new Error(\n `Illegal dependency: Module '${moduleId}' for plugin '${pluginId}' attempted to depend on extension point '${ref.id}' for plugin '${ep.pluginId}'. Extension points can only be used within their plugin's scope.`,\n );\n }\n if (!moduleId) {\n throw new Error(\n `Rejected dependency on extension point ${ref.id} from outside of a module`,\n );\n }\n let epImpl = ep.factory({\n reportModuleStartupFailure: ({ error }) => {\n resultCollector.amendPluginModuleResult(pluginId, moduleId, error);\n },\n });\n for (const mw of this.#extensionPointFactoryMiddleware) {\n const internal = OpaqueExtensionPointFactoryMiddleware.toInternal(mw);\n if (internal.extensionPointId === ref.id) {\n epImpl = await internal.middleware(epImpl);\n }\n }\n result.set(name, epImpl);\n } else {\n const impl = await this.#serviceRegistry.get(\n ref as ServiceRef<unknown>,\n pluginId,\n );\n if (impl) {\n if (ref.id === connectionsServiceRef.id) {\n const registrations = this.#getConnectionRegistrations(\n pluginId,\n moduleId,\n );\n result.set(\n name,\n withDeclaredConnections(\n impl as ConnectionsService,\n registrations,\n ),\n );\n } else {\n result.set(name, impl);\n }\n } else {\n missingRefs.add(ref);\n }\n }\n }\n\n if (missingRefs.size > 0) {\n const missing = Array.from(missingRefs).join(', ');\n const target = moduleId\n ? `module '${moduleId}' for plugin '${pluginId}'`\n : `plugin '${pluginId}'`;\n throw new Error(\n `Service or extension point dependencies of ${target} are missing for the following ref(s): ${missing}`,\n );\n }\n\n return Object.fromEntries(result);\n }\n\n add(feature: BackendFeature | Promise<BackendFeature>) {\n if (this.#startPromise) {\n throw new Error('feature can not be added after the backend has started');\n }\n this.#registeredFeatures.push(Promise.resolve(feature));\n }\n\n #addFeature(feature: BackendFeature) {\n if (isServiceFactory(feature)) {\n this.#serviceRegistry.add(feature);\n } else if (isBackendFeatureLoader(feature)) {\n this.#registeredFeatureLoaders.push(feature);\n } else if (isBackendRegistrations(feature)) {\n this.#registrations.push(feature);\n } else {\n throw new Error(\n `Failed to add feature, invalid feature ${JSON.stringify(feature)}`,\n );\n }\n }\n\n async start(): Promise<{ result: BackendStartupResult }> {\n if (this.#startPromise) {\n throw new Error('Backend has already started');\n }\n if (this.#stopPromise) {\n throw new Error('Backend has already stopped');\n }\n\n instanceRegistry.register(this);\n\n this.#startPromise = this.#doStart();\n return await this.#startPromise;\n }\n\n async #doStart(): Promise<{ result: BackendStartupResult }> {\n this.#serviceRegistry.checkForCircularDeps();\n\n for (const feature of this.#registeredFeatures) {\n this.#addFeature(await feature);\n }\n\n await this.#applyBackendFeatureLoaders(this.#registeredFeatureLoaders);\n\n this.#serviceRegistry.add(\n createRootInstanceMetadataServiceFactory(this.#registrations),\n );\n\n // This makes sure that any uncaught errors or unhandled rejections are\n // caught and logged, rather than terminating the process. We register these\n // as early as possible while still using the root logger service, the\n // tradeoff that if there are any unhandled errors as part of the that\n // instationation, it will cause the process to crash. If there are multiple\n // backend instances, each instance will log the error, because we can't\n // determine which instance the error came from.\n if (process.env.NODE_ENV !== 'test') {\n const rootLogger = await this.#serviceRegistry.get(\n coreServices.rootLogger,\n 'root',\n );\n this.#unhandledRejectionHandler = (reason: Error) => {\n rootLogger\n ?.child({ type: 'unhandledRejection' })\n ?.error('Unhandled rejection', reason);\n };\n this.#uncaughtExceptionHandler = (error: Error) => {\n rootLogger\n ?.child({ type: 'uncaughtException' })\n ?.error('Uncaught exception', error);\n };\n process.on('unhandledRejection', this.#unhandledRejectionHandler);\n process.on('uncaughtException', this.#uncaughtExceptionHandler);\n }\n\n // Initialize all root scoped services\n await this.#serviceRegistry.initializeEagerServicesWithScope('root');\n\n const rootConfig = await this.#serviceRegistry.get(\n coreServices.rootConfig,\n 'root',\n );\n const rootLogger = await this.#serviceRegistry.get(\n coreServices.rootLogger,\n 'root',\n );\n\n const allRegistrations = this.#registrations.flatMap(f =>\n f.getRegistrations(),\n );\n\n this.#callerConnectionRegistrations =\n collectCallerConnectionRegistrations(allRegistrations);\n\n const allPluginIds = [\n ...new Set(\n allRegistrations.flatMap(r =>\n 'pluginId' in r && typeof r.pluginId === 'string' ? [r.pluginId] : [],\n ),\n ),\n ];\n\n const resultCollector = createInitializationResultCollector({\n pluginIds: allPluginIds,\n logger: rootLogger,\n allowBootFailurePredicate: createAllowBootFailurePredicate(rootConfig),\n });\n\n const { pluginInits, moduleInits } = this.#enumerateRegistrations(\n allRegistrations,\n resultCollector,\n );\n\n // All plugins are initialized in parallel\n await Promise.all(\n [...pluginInits.keys()].map(async pluginId => {\n try {\n // Initialize all eager services\n await this.#serviceRegistry.initializeEagerServicesWithScope(\n 'plugin',\n pluginId,\n );\n\n // Modules are initialized before plugins, so that they can provide extension to the plugin\n const modules = moduleInits.get(pluginId);\n if (modules) {\n const tree = DependencyGraph.fromIterable(\n Array.from(modules).map(([moduleId, moduleInit]) => ({\n value: { moduleId, moduleInit },\n // Relationships are reversed at this point since we're only interested in the extension points.\n // If a modules provides extension point A we want it to be initialized AFTER all modules\n // that depend on extension point A, so that they can provide their extensions.\n consumes: Array.from(moduleInit.provides).map(p => p.id),\n provides: Array.from(moduleInit.consumes).map(c => c.id),\n })),\n );\n const circular = tree.detectCircularDependency();\n if (circular) {\n throw new ConflictError(\n `Circular dependency detected for modules of plugin '${pluginId}', ${circular\n .map(({ moduleId }) => `'${moduleId}'`)\n .join(' -> ')}`,\n );\n }\n await tree.parallelTopologicalTraversal(\n async ({ moduleId, moduleInit }) => {\n try {\n const moduleDeps = await this.#getInitDeps(\n moduleInit.init.deps,\n resultCollector,\n pluginId,\n moduleId,\n );\n await moduleInit.init.func(moduleDeps);\n resultCollector.onPluginModuleResult(pluginId, moduleId);\n } catch (error: unknown) {\n const err = toError(error);\n resultCollector.onPluginModuleResult(pluginId, moduleId, err);\n }\n },\n );\n }\n\n // Once all modules have been initialized, we can initialize the plugin itself\n const pluginInit = pluginInits.get(pluginId);\n // We allow modules to be installed without the accompanying plugin, so the plugin may not exist\n if (pluginInit) {\n const pluginDeps = await this.#getInitDeps(\n pluginInit.init.deps,\n resultCollector,\n pluginId,\n );\n await pluginInit.init.func(pluginDeps);\n }\n\n resultCollector.onPluginResult(pluginId);\n\n // Once the plugin and all modules have been initialized, we can signal that the plugin has stared up successfully\n const lifecycleService = await this.#getPluginLifecycleImpl(pluginId);\n await lifecycleService.startup();\n } catch (error: unknown) {\n const err = toError(error);\n resultCollector.onPluginResult(pluginId, err);\n }\n }),\n ).catch(error => {\n throw new ForwardedError(\n 'Unexpected uncaught backend startup error',\n error,\n );\n });\n\n const result = resultCollector.finalize();\n if (result.outcome === 'failure') {\n throw new BackendStartupError(result);\n }\n\n // Once all plugins and modules have been initialized, we can signal that the backend has started up successfully\n const lifecycleService = await this.#getRootLifecycleImpl();\n await lifecycleService.startup();\n\n return { result };\n }\n\n #enumerateRegistrations(\n allRegistrations: ReturnType<\n InternalBackendRegistrations['getRegistrations']\n >,\n resultCollector: ReturnType<typeof createInitializationResultCollector>,\n ): {\n pluginInits: Map<string, BackendRegisterInit>;\n moduleInits: Map<string, Map<string, BackendRegisterInit>>;\n } {\n const pluginInits = new Map<string, BackendRegisterInit>();\n const moduleInits = new Map<string, Map<string, BackendRegisterInit>>();\n\n for (const r of allRegistrations) {\n const addedExtensionPointIds: string[] = [];\n try {\n const provides = new Set<ExtensionPoint<unknown>>();\n\n if (r.type === 'plugin' || r.type === 'module') {\n // Handle v1 format: Array<readonly [ExtensionPoint<unknown>, unknown]>\n for (const [extRef, extImpl] of r.extensionPoints) {\n if (this.#extensionPoints.has(extRef.id)) {\n throw new Error(\n `ExtensionPoint with ID '${extRef.id}' is already registered`,\n );\n }\n this.#extensionPoints.set(extRef.id, {\n pluginId: r.pluginId,\n factory: () => extImpl,\n });\n addedExtensionPointIds.push(extRef.id);\n provides.add(extRef);\n }\n } else if (r.type === 'plugin-v1.1' || r.type === 'module-v1.1') {\n // Handle v1.1 format: Array<ExtensionPointRegistration>\n for (const extReg of r.extensionPoints) {\n if (this.#extensionPoints.has(extReg.extensionPoint.id)) {\n throw new Error(\n `ExtensionPoint with ID '${extReg.extensionPoint.id}' is already registered`,\n );\n }\n this.#extensionPoints.set(extReg.extensionPoint.id, {\n pluginId: r.pluginId,\n factory: extReg.factory,\n });\n addedExtensionPointIds.push(extReg.extensionPoint.id);\n provides.add(extReg.extensionPoint);\n }\n }\n\n if (r.type === 'plugin' || r.type === 'plugin-v1.1') {\n if (pluginInits.has(r.pluginId)) {\n throw new Error(`Plugin '${r.pluginId}' is already registered`);\n }\n pluginInits.set(r.pluginId, {\n provides,\n consumes: new Set(Object.values(r.init.deps)),\n init: r.init,\n });\n } else if (r.type === 'module' || r.type === 'module-v1.1') {\n let modules = moduleInits.get(r.pluginId);\n if (!modules) {\n modules = new Map();\n moduleInits.set(r.pluginId, modules);\n }\n if (modules.has(r.moduleId)) {\n throw new Error(\n `Module '${r.moduleId}' for plugin '${r.pluginId}' is already registered`,\n );\n }\n modules.set(r.moduleId, {\n provides,\n consumes: new Set(Object.values(r.init.deps)),\n init: r.init,\n });\n } else {\n throw new Error(`Invalid registration type '${(r as any).type}'`);\n }\n } catch (error: unknown) {\n const err = toError(error);\n // Clean up partially registered extension points\n for (const id of addedExtensionPointIds) {\n this.#extensionPoints.delete(id);\n }\n if ('pluginId' in r && 'moduleId' in r) {\n resultCollector.onPluginModuleResult(r.pluginId, r.moduleId, err);\n } else if ('pluginId' in r) {\n pluginInits.delete(r.pluginId);\n moduleInits.delete(r.pluginId);\n resultCollector.onPluginResult(r.pluginId, err);\n } else {\n throw err;\n }\n }\n }\n\n return { pluginInits, moduleInits };\n }\n\n // It's fine to call .stop() multiple times, which for example can happen with manual stop + process exit\n async stop(): Promise<void> {\n instanceRegistry.unregister(this);\n\n if (!this.#stopPromise) {\n this.#stopPromise = this.#doStop();\n }\n await this.#stopPromise;\n }\n\n async #doStop(): Promise<void> {\n if (!this.#startPromise) {\n return;\n }\n\n try {\n await this.#startPromise;\n } catch (error) {\n // The startup failed, but we may still want to do cleanup so we continue silently\n }\n\n const rootLifecycleService = await this.#getRootLifecycleImpl();\n\n // Root services like the health one need to immediately be notified of the shutdown\n await rootLifecycleService.beforeShutdown();\n\n // Get all plugins.\n const allPlugins = new Set<string>();\n for (const feature of this.#registrations) {\n for (const r of feature.getRegistrations()) {\n if (r.type === 'plugin' || r.type === 'plugin-v1.1') {\n allPlugins.add(r.pluginId);\n }\n }\n }\n\n // Iterate through all plugins and run their shutdown hooks.\n await Promise.allSettled(\n [...allPlugins].map(async pluginId => {\n const lifecycleService = await this.#getPluginLifecycleImpl(pluginId);\n await lifecycleService.shutdown();\n }),\n );\n\n // Once all plugin shutdown hooks are done, run root shutdown hooks.\n await rootLifecycleService.shutdown();\n\n // Clean up process event listeners to prevent memory leaks and duplicate logging\n if (this.#unhandledRejectionHandler) {\n process.off('unhandledRejection', this.#unhandledRejectionHandler);\n this.#unhandledRejectionHandler = undefined;\n }\n if (this.#uncaughtExceptionHandler) {\n process.off('uncaughtException', this.#uncaughtExceptionHandler);\n this.#uncaughtExceptionHandler = undefined;\n }\n }\n\n // Bit of a hacky way to grab the lifecycle services, potentially find a nicer way to do this\n async #getRootLifecycleImpl(): Promise<\n RootLifecycleService & {\n startup(): Promise<void>;\n beforeShutdown(): Promise<void>;\n shutdown(): Promise<void>;\n }\n > {\n const lifecycleService = await this.#serviceRegistry.get(\n coreServices.rootLifecycle,\n 'root',\n );\n\n const service = lifecycleService as any;\n if (\n service &&\n typeof service.startup === 'function' &&\n typeof service.shutdown === 'function'\n ) {\n return service;\n }\n\n throw new Error('Unexpected root lifecycle service implementation');\n }\n\n async #getPluginLifecycleImpl(\n pluginId: string,\n ): Promise<\n LifecycleService & { startup(): Promise<void>; shutdown(): Promise<void> }\n > {\n const lifecycleService = await this.#serviceRegistry.get(\n coreServices.lifecycle,\n pluginId,\n );\n\n const service = lifecycleService as any;\n if (\n service &&\n typeof service.startup === 'function' &&\n typeof service.shutdown === 'function'\n ) {\n return service;\n }\n\n throw new Error('Unexpected plugin lifecycle service implementation');\n }\n\n async #applyBackendFeatureLoaders(loaders: InternalBackendFeatureLoader[]) {\n const servicesAddedByLoaders = new Map<\n string,\n InternalBackendFeatureLoader\n >();\n\n for (const loader of loaders) {\n const deps = new Map<string, unknown>();\n const missingRefs = new Set<ServiceOrExtensionPoint>();\n\n for (const [name, ref] of Object.entries(loader.deps ?? {})) {\n if (ref.scope !== 'root') {\n throw new Error(\n `Feature loaders can only depend on root scoped services, but '${name}' is scoped to '${ref.scope}'. Offending loader is ${loader.description}`,\n );\n }\n const impl = await this.#serviceRegistry.get(\n ref as ServiceRef<unknown>,\n 'root',\n );\n if (impl) {\n deps.set(name, impl);\n } else {\n missingRefs.add(ref);\n }\n }\n\n if (missingRefs.size > 0) {\n const missing = Array.from(missingRefs).join(', ');\n throw new Error(\n `No service available for the following ref(s): ${missing}, depended on by feature loader ${loader.description}`,\n );\n }\n\n const result = await loader\n .loader(Object.fromEntries(deps))\n .then(features => features.map(unwrapFeature))\n .catch(error => {\n throw new ForwardedError(\n `Feature loader ${loader.description} failed`,\n error,\n );\n });\n\n let didAddServiceFactory = false;\n const newLoaders = new Array<InternalBackendFeatureLoader>();\n\n for await (const feature of result) {\n if (isBackendFeatureLoader(feature)) {\n newLoaders.push(feature);\n } else {\n // This block makes sure that feature loaders do not provide duplicate\n // implementations for the same service, but at the same time allows\n // service factories provided by feature loaders to be overridden by\n // ones that are explicitly installed with backend.add(serviceFactory).\n //\n // If a factory has already been explicitly installed, the service\n // factory provided by the loader will simply be ignored.\n if (isServiceFactory(feature) && !feature.service.multiton) {\n const conflictingLoader = servicesAddedByLoaders.get(\n feature.service.id,\n );\n if (conflictingLoader) {\n throw new Error(\n `Duplicate service implementations provided for ${feature.service.id} by both feature loader ${loader.description} and feature loader ${conflictingLoader.description}`,\n );\n }\n\n // Check that this service wasn't already explicitly added by backend.add(serviceFactory)\n if (!this.#serviceRegistry.hasBeenAdded(feature.service)) {\n didAddServiceFactory = true;\n servicesAddedByLoaders.set(feature.service.id, loader);\n this.#addFeature(feature);\n }\n } else {\n this.#addFeature(feature);\n }\n }\n }\n\n // Every time we add a new service factory we need to make sure that we don't have circular dependencies\n if (didAddServiceFactory) {\n this.#serviceRegistry.checkForCircularDeps();\n }\n\n // Apply loaders recursively, depth-first\n if (newLoaders.length > 0) {\n await this.#applyBackendFeatureLoaders(newLoaders);\n }\n }\n }\n}\n\nfunction toInternalBackendFeature(\n feature: BackendFeature,\n): InternalBackendFeature {\n if (feature.$$type !== '@backstage/BackendFeature') {\n throw new Error(`Invalid BackendFeature, bad type '${feature.$$type}'`);\n }\n const internal = feature as InternalBackendFeature;\n if (internal.version !== 'v1') {\n throw new Error(\n `Invalid BackendFeature, bad version '${internal.version}'`,\n );\n }\n return internal;\n}\n\nfunction isServiceFactory(\n feature: BackendFeature,\n): feature is InternalServiceFactory {\n const internal = toInternalBackendFeature(feature);\n if (internal.featureType === 'service') {\n return true;\n }\n // Backwards compatibility for v1 registrations that use duck typing\n return 'service' in internal;\n}\n\nfunction isBackendRegistrations(\n feature: BackendFeature,\n): feature is InternalBackendRegistrations {\n const internal = toInternalBackendFeature(feature);\n if (internal.featureType === 'registrations') {\n return true;\n }\n // Backwards compatibility for v1 registrations that use duck typing\n return 'getRegistrations' in internal;\n}\n\nfunction isBackendFeatureLoader(\n feature: BackendFeature,\n): feature is InternalBackendFeatureLoader {\n return toInternalBackendFeature(feature).featureType === 'loader';\n}\n"],"names":["createServiceFactory","coreServices","deepFreeze","ServiceRegistry","OpaqueExtensionPointFactoryMiddleware","connectionsServiceRef","withDeclaredConnections","rootLogger","createInitializationResultCollector","createAllowBootFailurePredicate","DependencyGraph","ConflictError","toError","lifecycleService","ForwardedError","BackendStartupError","unwrapFeature"],"mappings":";;;;;;;;;;;;;;;;;AAsEA,MAAM,gBAAA,GAAmB,IAAK,MAAM,gBAAA,CAAiB;AAAA,EACnD,WAAA,GAAc,KAAA;AAAA,EACd,UAAA,uBAAiB,GAAA,EAAwB;AAAA,EAEzC,SAAS,QAAA,EAA8B;AACrC,IAAA,IAAI,CAAC,KAAK,WAAA,EAAa;AACrB,MAAA,IAAA,CAAK,WAAA,GAAc,IAAA;AAEnB,MAAA,OAAA,CAAQ,WAAA,CAAY,SAAA,EAAW,IAAA,CAAK,YAAY,CAAA;AAChD,MAAA,OAAA,CAAQ,WAAA,CAAY,QAAA,EAAU,IAAA,CAAK,YAAY,CAAA;AAC/C,MAAA,OAAA,CAAQ,WAAA,CAAY,YAAA,EAAc,IAAA,CAAK,YAAY,CAAA;AAAA,IACrD;AAEA,IAAA,IAAA,CAAK,UAAA,CAAW,IAAI,QAAQ,CAAA;AAAA,EAC9B;AAAA,EAEA,WAAW,QAAA,EAA8B;AACvC,IAAA,I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tB;AAEA,SAAS,uBACP,OAAA,EACyC;AACzC,EAAA,MAAM,QAAA,GAAW,yBAAyB,OAAO,CAAA;AACjD,EAAA,IAAI,QAAA,CAAS,gBAAgB,eAAA,EAAiB;AAC5C,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,OAAO,kBAAA,IAAsB,QAAA;AAC/B;AAEA,SAAS,uBACP,OAAA,EACyC;AACzC,EAAA,OAAO,wBAAA,CAAyB,OAAO,CAAA,CAAE,WAAA,KAAgB,QAAA;AAC3D;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/backend-app-api",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.3-next.0",
|
|
4
4
|
"description": "Core API used by Backstage backend apps",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "node-library"
|
|
@@ -50,16 +50,17 @@
|
|
|
50
50
|
"test": "backstage-cli package test"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@backstage/backend-plugin-api": "
|
|
54
|
-
"@backstage/config": "
|
|
55
|
-
"@backstage/connections": "
|
|
56
|
-
"@backstage/errors": "
|
|
53
|
+
"@backstage/backend-plugin-api": "1.10.0-next.0",
|
|
54
|
+
"@backstage/config": "1.3.8",
|
|
55
|
+
"@backstage/connections": "0.3.0-next.0",
|
|
56
|
+
"@backstage/errors": "1.3.1",
|
|
57
|
+
"@backstage/types": "1.2.2",
|
|
58
|
+
"zod": "^3.25.76 || ^4.0.0"
|
|
57
59
|
},
|
|
58
60
|
"devDependencies": {
|
|
59
|
-
"@backstage/backend-defaults": "
|
|
60
|
-
"@backstage/backend-test-utils": "
|
|
61
|
-
"@backstage/cli": "
|
|
62
|
-
"@backstage/types": "^1.2.2"
|
|
61
|
+
"@backstage/backend-defaults": "0.17.6-next.0",
|
|
62
|
+
"@backstage/backend-test-utils": "1.11.6-next.0",
|
|
63
|
+
"@backstage/cli": "0.36.4"
|
|
63
64
|
},
|
|
64
65
|
"configSchema": "config.schema.json"
|
|
65
66
|
}
|