@backstage/backend-app-api 0.1.1-next.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @backstage/backend-app-api might be problematic. Click here for more details.
- package/CHANGELOG.md +16 -0
- package/alpha/package.json +1 -1
- package/dist/index.alpha.d.ts +54 -5
- package/dist/index.beta.d.ts +54 -5
- package/dist/index.cjs.js +227 -226
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +54 -5
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @backstage/backend-app-api
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 5df230d48c: Introduced a new `backend-defaults` package carrying `createBackend` which was previously exported from `backend-app-api`.
|
|
8
|
+
The `backend-app-api` package now exports the `createSpecializedBacked` that does not add any service factories by default.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- 0599732ec0: Refactored experimental backend system with new type names.
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
- @backstage/backend-common@0.15.0
|
|
15
|
+
- @backstage/backend-plugin-api@0.1.1
|
|
16
|
+
- @backstage/backend-tasks@0.3.4
|
|
17
|
+
- @backstage/plugin-permission-node@0.6.4
|
|
18
|
+
|
|
3
19
|
## 0.1.1-next.0
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/alpha/package.json
CHANGED
package/dist/index.alpha.d.ts
CHANGED
|
@@ -5,26 +5,75 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { AnyServiceFactory } from '@backstage/backend-plugin-api';
|
|
8
|
-
import {
|
|
8
|
+
import { BackendFeature } from '@backstage/backend-plugin-api';
|
|
9
|
+
import { Config } from '@backstage/config';
|
|
10
|
+
import { ExtensionPoint } from '@backstage/backend-plugin-api';
|
|
11
|
+
import { HttpRouterService } from '@backstage/backend-plugin-api';
|
|
12
|
+
import { Logger } from '@backstage/backend-plugin-api';
|
|
13
|
+
import { PermissionAuthorizer } from '@backstage/plugin-permission-common';
|
|
14
|
+
import { PermissionEvaluator } from '@backstage/plugin-permission-common';
|
|
15
|
+
import { PluginCacheManager } from '@backstage/backend-common';
|
|
16
|
+
import { PluginDatabaseManager } from '@backstage/backend-common';
|
|
17
|
+
import { PluginEndpointDiscovery } from '@backstage/backend-common';
|
|
18
|
+
import { PluginTaskScheduler } from '@backstage/backend-tasks';
|
|
19
|
+
import { ServiceFactory } from '@backstage/backend-plugin-api';
|
|
20
|
+
import { ServiceRef } from '@backstage/backend-plugin-api';
|
|
21
|
+
import { TokenManager } from '@backstage/backend-common';
|
|
22
|
+
import { UrlReader } from '@backstage/backend-common';
|
|
9
23
|
|
|
10
24
|
/**
|
|
11
25
|
* @public
|
|
12
26
|
*/
|
|
13
27
|
export declare interface Backend {
|
|
14
|
-
add(
|
|
28
|
+
add(feature: BackendFeature): void;
|
|
15
29
|
start(): Promise<void>;
|
|
16
30
|
}
|
|
17
31
|
|
|
32
|
+
/** @public */
|
|
33
|
+
export declare const cacheFactory: ServiceFactory<PluginCacheManager, PluginCacheManager, {}>;
|
|
34
|
+
|
|
35
|
+
/** @public */
|
|
36
|
+
export declare const configFactory: ServiceFactory<Config, Config, {}>;
|
|
37
|
+
|
|
18
38
|
/**
|
|
19
39
|
* @public
|
|
20
40
|
*/
|
|
21
|
-
export declare function
|
|
41
|
+
export declare function createSpecializedBackend(options: CreateSpecializedBackendOptions): Backend;
|
|
22
42
|
|
|
23
43
|
/**
|
|
24
44
|
* @public
|
|
25
45
|
*/
|
|
26
|
-
export declare interface
|
|
27
|
-
|
|
46
|
+
export declare interface CreateSpecializedBackendOptions {
|
|
47
|
+
services: AnyServiceFactory[];
|
|
28
48
|
}
|
|
29
49
|
|
|
50
|
+
/** @public */
|
|
51
|
+
export declare const databaseFactory: ServiceFactory<PluginDatabaseManager, PluginDatabaseManager, {}>;
|
|
52
|
+
|
|
53
|
+
/** @public */
|
|
54
|
+
export declare const discoveryFactory: ServiceFactory<PluginEndpointDiscovery, PluginEndpointDiscovery, {}>;
|
|
55
|
+
|
|
56
|
+
/** @public */
|
|
57
|
+
export declare const httpRouterFactory: ServiceFactory<HttpRouterService, HttpRouterService, {}>;
|
|
58
|
+
|
|
59
|
+
/** @public */
|
|
60
|
+
export declare const loggerFactory: ServiceFactory<Logger, Logger, {}>;
|
|
61
|
+
|
|
62
|
+
/** @public */
|
|
63
|
+
export declare const permissionsFactory: ServiceFactory<PermissionAuthorizer | PermissionEvaluator, PermissionAuthorizer | PermissionEvaluator, {}>;
|
|
64
|
+
|
|
65
|
+
/** @public */
|
|
66
|
+
export declare const schedulerFactory: ServiceFactory<PluginTaskScheduler, PluginTaskScheduler, {}>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
71
|
+
export declare type ServiceOrExtensionPoint<T = unknown> = ExtensionPoint<T> | ServiceRef<T>;
|
|
72
|
+
|
|
73
|
+
/** @public */
|
|
74
|
+
export declare const tokenManagerFactory: ServiceFactory<TokenManager, TokenManager, {}>;
|
|
75
|
+
|
|
76
|
+
/** @public */
|
|
77
|
+
export declare const urlReaderFactory: ServiceFactory<UrlReader, UrlReader, {}>;
|
|
78
|
+
|
|
30
79
|
export { }
|
package/dist/index.beta.d.ts
CHANGED
|
@@ -5,26 +5,75 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { AnyServiceFactory } from '@backstage/backend-plugin-api';
|
|
8
|
-
import {
|
|
8
|
+
import { BackendFeature } from '@backstage/backend-plugin-api';
|
|
9
|
+
import { Config } from '@backstage/config';
|
|
10
|
+
import { ExtensionPoint } from '@backstage/backend-plugin-api';
|
|
11
|
+
import { HttpRouterService } from '@backstage/backend-plugin-api';
|
|
12
|
+
import { Logger } from '@backstage/backend-plugin-api';
|
|
13
|
+
import { PermissionAuthorizer } from '@backstage/plugin-permission-common';
|
|
14
|
+
import { PermissionEvaluator } from '@backstage/plugin-permission-common';
|
|
15
|
+
import { PluginCacheManager } from '@backstage/backend-common';
|
|
16
|
+
import { PluginDatabaseManager } from '@backstage/backend-common';
|
|
17
|
+
import { PluginEndpointDiscovery } from '@backstage/backend-common';
|
|
18
|
+
import { PluginTaskScheduler } from '@backstage/backend-tasks';
|
|
19
|
+
import { ServiceFactory } from '@backstage/backend-plugin-api';
|
|
20
|
+
import { ServiceRef } from '@backstage/backend-plugin-api';
|
|
21
|
+
import { TokenManager } from '@backstage/backend-common';
|
|
22
|
+
import { UrlReader } from '@backstage/backend-common';
|
|
9
23
|
|
|
10
24
|
/**
|
|
11
25
|
* @public
|
|
12
26
|
*/
|
|
13
27
|
export declare interface Backend {
|
|
14
|
-
add(
|
|
28
|
+
add(feature: BackendFeature): void;
|
|
15
29
|
start(): Promise<void>;
|
|
16
30
|
}
|
|
17
31
|
|
|
32
|
+
/** @public */
|
|
33
|
+
export declare const cacheFactory: ServiceFactory<PluginCacheManager, PluginCacheManager, {}>;
|
|
34
|
+
|
|
35
|
+
/** @public */
|
|
36
|
+
export declare const configFactory: ServiceFactory<Config, Config, {}>;
|
|
37
|
+
|
|
18
38
|
/**
|
|
19
39
|
* @public
|
|
20
40
|
*/
|
|
21
|
-
export declare function
|
|
41
|
+
export declare function createSpecializedBackend(options: CreateSpecializedBackendOptions): Backend;
|
|
22
42
|
|
|
23
43
|
/**
|
|
24
44
|
* @public
|
|
25
45
|
*/
|
|
26
|
-
export declare interface
|
|
27
|
-
|
|
46
|
+
export declare interface CreateSpecializedBackendOptions {
|
|
47
|
+
services: AnyServiceFactory[];
|
|
28
48
|
}
|
|
29
49
|
|
|
50
|
+
/** @public */
|
|
51
|
+
export declare const databaseFactory: ServiceFactory<PluginDatabaseManager, PluginDatabaseManager, {}>;
|
|
52
|
+
|
|
53
|
+
/** @public */
|
|
54
|
+
export declare const discoveryFactory: ServiceFactory<PluginEndpointDiscovery, PluginEndpointDiscovery, {}>;
|
|
55
|
+
|
|
56
|
+
/** @public */
|
|
57
|
+
export declare const httpRouterFactory: ServiceFactory<HttpRouterService, HttpRouterService, {}>;
|
|
58
|
+
|
|
59
|
+
/** @public */
|
|
60
|
+
export declare const loggerFactory: ServiceFactory<Logger, Logger, {}>;
|
|
61
|
+
|
|
62
|
+
/** @public */
|
|
63
|
+
export declare const permissionsFactory: ServiceFactory<PermissionAuthorizer | PermissionEvaluator, PermissionAuthorizer | PermissionEvaluator, {}>;
|
|
64
|
+
|
|
65
|
+
/** @public */
|
|
66
|
+
export declare const schedulerFactory: ServiceFactory<PluginTaskScheduler, PluginTaskScheduler, {}>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
71
|
+
export declare type ServiceOrExtensionPoint<T = unknown> = ExtensionPoint<T> | ServiceRef<T>;
|
|
72
|
+
|
|
73
|
+
/** @public */
|
|
74
|
+
export declare const tokenManagerFactory: ServiceFactory<TokenManager, TokenManager, {}>;
|
|
75
|
+
|
|
76
|
+
/** @public */
|
|
77
|
+
export declare const urlReaderFactory: ServiceFactory<UrlReader, UrlReader, {}>;
|
|
78
|
+
|
|
30
79
|
export { }
|
package/dist/index.cjs.js
CHANGED
|
@@ -12,192 +12,6 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
12
12
|
|
|
13
13
|
var Router__default = /*#__PURE__*/_interopDefaultLegacy(Router);
|
|
14
14
|
|
|
15
|
-
const cacheFactory = backendPluginApi.createServiceFactory({
|
|
16
|
-
service: backendPluginApi.cacheServiceRef,
|
|
17
|
-
deps: {
|
|
18
|
-
configFactory: backendPluginApi.configServiceRef
|
|
19
|
-
},
|
|
20
|
-
factory: async ({ configFactory }) => {
|
|
21
|
-
const config = await configFactory("root");
|
|
22
|
-
const cacheManager = backendCommon.CacheManager.fromConfig(config);
|
|
23
|
-
return async (pluginId) => {
|
|
24
|
-
return cacheManager.forPlugin(pluginId);
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const configFactory = backendPluginApi.createServiceFactory({
|
|
30
|
-
service: backendPluginApi.configServiceRef,
|
|
31
|
-
deps: {
|
|
32
|
-
loggerFactory: backendPluginApi.loggerServiceRef
|
|
33
|
-
},
|
|
34
|
-
factory: async ({ loggerFactory }) => {
|
|
35
|
-
const logger = await loggerFactory("root");
|
|
36
|
-
const config = await backendCommon.loadBackendConfig({
|
|
37
|
-
argv: process.argv,
|
|
38
|
-
logger: backendPluginApi.loggerToWinstonLogger(logger)
|
|
39
|
-
});
|
|
40
|
-
return async () => {
|
|
41
|
-
return config;
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
const databaseFactory = backendPluginApi.createServiceFactory({
|
|
47
|
-
service: backendPluginApi.databaseServiceRef,
|
|
48
|
-
deps: {
|
|
49
|
-
configFactory: backendPluginApi.configServiceRef
|
|
50
|
-
},
|
|
51
|
-
factory: async ({ configFactory }) => {
|
|
52
|
-
const config = await configFactory("root");
|
|
53
|
-
const databaseManager = backendCommon.DatabaseManager.fromConfig(config);
|
|
54
|
-
return async (pluginId) => {
|
|
55
|
-
return databaseManager.forPlugin(pluginId);
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
const discoveryFactory = backendPluginApi.createServiceFactory({
|
|
61
|
-
service: backendPluginApi.discoveryServiceRef,
|
|
62
|
-
deps: {
|
|
63
|
-
configFactory: backendPluginApi.configServiceRef
|
|
64
|
-
},
|
|
65
|
-
factory: async ({ configFactory }) => {
|
|
66
|
-
const config = await configFactory("root");
|
|
67
|
-
const discovery = backendCommon.SingleHostDiscovery.fromConfig(config);
|
|
68
|
-
return async () => {
|
|
69
|
-
return discovery;
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
class BackstageLogger {
|
|
75
|
-
constructor(winston) {
|
|
76
|
-
this.winston = winston;
|
|
77
|
-
}
|
|
78
|
-
static fromWinston(logger) {
|
|
79
|
-
return new BackstageLogger(logger);
|
|
80
|
-
}
|
|
81
|
-
info(message, ...meta) {
|
|
82
|
-
this.winston.info(message, ...meta);
|
|
83
|
-
}
|
|
84
|
-
child(fields) {
|
|
85
|
-
return new BackstageLogger(this.winston.child(fields));
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
const loggerFactory = backendPluginApi.createServiceFactory({
|
|
89
|
-
service: backendPluginApi.loggerServiceRef,
|
|
90
|
-
deps: {},
|
|
91
|
-
factory: async () => {
|
|
92
|
-
const root = BackstageLogger.fromWinston(backendCommon.createRootLogger());
|
|
93
|
-
return async (pluginId) => {
|
|
94
|
-
return root.child({ pluginId });
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
const permissionsFactory = backendPluginApi.createServiceFactory({
|
|
100
|
-
service: backendPluginApi.permissionsServiceRef,
|
|
101
|
-
deps: {
|
|
102
|
-
configFactory: backendPluginApi.configServiceRef,
|
|
103
|
-
discoveryFactory: backendPluginApi.discoveryServiceRef,
|
|
104
|
-
tokenManagerFactory: backendPluginApi.tokenManagerServiceRef
|
|
105
|
-
},
|
|
106
|
-
factory: async ({ configFactory, discoveryFactory, tokenManagerFactory }) => {
|
|
107
|
-
const config = await configFactory("root");
|
|
108
|
-
const discovery = await discoveryFactory("root");
|
|
109
|
-
const tokenManager = await tokenManagerFactory("root");
|
|
110
|
-
const permissions = pluginPermissionNode.ServerPermissionClient.fromConfig(config, {
|
|
111
|
-
discovery,
|
|
112
|
-
tokenManager
|
|
113
|
-
});
|
|
114
|
-
return async (_pluginId) => {
|
|
115
|
-
return permissions;
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
const schedulerFactory = backendPluginApi.createServiceFactory({
|
|
121
|
-
service: backendPluginApi.schedulerServiceRef,
|
|
122
|
-
deps: {
|
|
123
|
-
configFactory: backendPluginApi.configServiceRef
|
|
124
|
-
},
|
|
125
|
-
factory: async ({ configFactory }) => {
|
|
126
|
-
const config = await configFactory("root");
|
|
127
|
-
const taskScheduler = backendTasks.TaskScheduler.fromConfig(config);
|
|
128
|
-
return async (pluginId) => {
|
|
129
|
-
return taskScheduler.forPlugin(pluginId);
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
const tokenManagerFactory = backendPluginApi.createServiceFactory({
|
|
135
|
-
service: backendPluginApi.tokenManagerServiceRef,
|
|
136
|
-
deps: {
|
|
137
|
-
configFactory: backendPluginApi.configServiceRef,
|
|
138
|
-
loggerFactory: backendPluginApi.loggerServiceRef
|
|
139
|
-
},
|
|
140
|
-
factory: async ({ configFactory, loggerFactory }) => {
|
|
141
|
-
const logger = await loggerFactory("root");
|
|
142
|
-
const config = await configFactory("root");
|
|
143
|
-
return async (_pluginId) => {
|
|
144
|
-
return backendCommon.ServerTokenManager.fromConfig(config, {
|
|
145
|
-
logger: backendPluginApi.loggerToWinstonLogger(logger)
|
|
146
|
-
});
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
const urlReaderFactory = backendPluginApi.createServiceFactory({
|
|
152
|
-
service: backendPluginApi.urlReaderServiceRef,
|
|
153
|
-
deps: {
|
|
154
|
-
configFactory: backendPluginApi.configServiceRef,
|
|
155
|
-
loggerFactory: backendPluginApi.loggerServiceRef
|
|
156
|
-
},
|
|
157
|
-
factory: async ({ configFactory, loggerFactory }) => {
|
|
158
|
-
return async (pluginId) => {
|
|
159
|
-
const logger = await loggerFactory(pluginId);
|
|
160
|
-
return backendCommon.UrlReaders.default({
|
|
161
|
-
logger: backendPluginApi.loggerToWinstonLogger(logger),
|
|
162
|
-
config: await configFactory(pluginId)
|
|
163
|
-
});
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
const httpRouterFactory = backendPluginApi.createServiceFactory({
|
|
169
|
-
service: backendPluginApi.httpRouterServiceRef,
|
|
170
|
-
deps: {
|
|
171
|
-
configFactory: backendPluginApi.configServiceRef
|
|
172
|
-
},
|
|
173
|
-
factory: async ({ configFactory }) => {
|
|
174
|
-
const rootRouter = Router__default["default"]();
|
|
175
|
-
const service = backendCommon.createServiceBuilder(module).loadConfig(await configFactory("root")).addRouter("", rootRouter);
|
|
176
|
-
await service.start();
|
|
177
|
-
return async (pluginId) => {
|
|
178
|
-
const path = pluginId ? `/api/${pluginId}` : "";
|
|
179
|
-
return {
|
|
180
|
-
use(handler) {
|
|
181
|
-
rootRouter.use(path, handler);
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
const defaultServiceFactories = [
|
|
189
|
-
cacheFactory,
|
|
190
|
-
configFactory,
|
|
191
|
-
databaseFactory,
|
|
192
|
-
discoveryFactory,
|
|
193
|
-
loggerFactory,
|
|
194
|
-
permissionsFactory,
|
|
195
|
-
schedulerFactory,
|
|
196
|
-
tokenManagerFactory,
|
|
197
|
-
urlReaderFactory,
|
|
198
|
-
httpRouterFactory
|
|
199
|
-
];
|
|
200
|
-
|
|
201
15
|
var __accessCheck$2 = (obj, member, msg) => {
|
|
202
16
|
if (!member.has(obj))
|
|
203
17
|
throw TypeError("Cannot " + msg);
|
|
@@ -220,37 +34,33 @@ var __privateMethod = (obj, member, method) => {
|
|
|
220
34
|
__accessCheck$2(obj, member, "access private method");
|
|
221
35
|
return method;
|
|
222
36
|
};
|
|
223
|
-
var _started,
|
|
37
|
+
var _started, _features, _registerInits, _extensionPoints, _serviceHolder, _getInitDeps, getInitDeps_fn, _resolveInitOrder, resolveInitOrder_fn;
|
|
224
38
|
class BackendInitializer {
|
|
225
39
|
constructor(serviceHolder) {
|
|
226
40
|
__privateAdd$2(this, _getInitDeps);
|
|
227
41
|
__privateAdd$2(this, _resolveInitOrder);
|
|
228
42
|
__privateAdd$2(this, _started, false);
|
|
229
|
-
__privateAdd$2(this,
|
|
43
|
+
__privateAdd$2(this, _features, /* @__PURE__ */ new Map());
|
|
230
44
|
__privateAdd$2(this, _registerInits, new Array());
|
|
231
45
|
__privateAdd$2(this, _extensionPoints, /* @__PURE__ */ new Map());
|
|
232
46
|
__privateAdd$2(this, _serviceHolder, void 0);
|
|
233
47
|
__privateSet$2(this, _serviceHolder, serviceHolder);
|
|
234
48
|
}
|
|
235
|
-
add(
|
|
49
|
+
add(feature, options) {
|
|
236
50
|
if (__privateGet$2(this, _started)) {
|
|
237
|
-
throw new Error(
|
|
238
|
-
"extension can not be added after the backend has started"
|
|
239
|
-
);
|
|
51
|
+
throw new Error("feature can not be added after the backend has started");
|
|
240
52
|
}
|
|
241
|
-
__privateGet$2(this,
|
|
53
|
+
__privateGet$2(this, _features).set(feature, options);
|
|
242
54
|
}
|
|
243
55
|
async start() {
|
|
244
|
-
console.log(`Starting backend`);
|
|
245
56
|
if (__privateGet$2(this, _started)) {
|
|
246
57
|
throw new Error("Backend has already started");
|
|
247
58
|
}
|
|
248
59
|
__privateSet$2(this, _started, true);
|
|
249
|
-
for (const [
|
|
60
|
+
for (const [feature] of __privateGet$2(this, _features)) {
|
|
250
61
|
const provides = /* @__PURE__ */ new Set();
|
|
251
62
|
let registerInit = void 0;
|
|
252
|
-
|
|
253
|
-
extension.register({
|
|
63
|
+
feature.register({
|
|
254
64
|
registerExtensionPoint: (extensionPointRef, impl) => {
|
|
255
65
|
if (registerInit) {
|
|
256
66
|
throw new Error("registerExtensionPoint called after registerInit");
|
|
@@ -266,7 +76,7 @@ class BackendInitializer {
|
|
|
266
76
|
throw new Error("registerInit must only be called once");
|
|
267
77
|
}
|
|
268
78
|
registerInit = {
|
|
269
|
-
id:
|
|
79
|
+
id: feature.id,
|
|
270
80
|
provides,
|
|
271
81
|
consumes: new Set(Object.values(registerOptions.deps)),
|
|
272
82
|
deps: registerOptions.deps,
|
|
@@ -276,38 +86,51 @@ class BackendInitializer {
|
|
|
276
86
|
});
|
|
277
87
|
if (!registerInit) {
|
|
278
88
|
throw new Error(
|
|
279
|
-
`registerInit was not called by register in ${
|
|
89
|
+
`registerInit was not called by register in ${feature.id}`
|
|
280
90
|
);
|
|
281
91
|
}
|
|
282
92
|
__privateGet$2(this, _registerInits).push(registerInit);
|
|
283
93
|
}
|
|
284
|
-
this.validateSetup();
|
|
285
94
|
const orderedRegisterResults = __privateMethod(this, _resolveInitOrder, resolveInitOrder_fn).call(this, __privateGet$2(this, _registerInits));
|
|
286
95
|
for (const registerInit of orderedRegisterResults) {
|
|
287
96
|
const deps = await __privateMethod(this, _getInitDeps, getInitDeps_fn).call(this, registerInit.deps, registerInit.id);
|
|
288
97
|
await registerInit.init(deps);
|
|
289
98
|
}
|
|
290
99
|
}
|
|
291
|
-
validateSetup() {
|
|
292
|
-
}
|
|
293
100
|
}
|
|
294
101
|
_started = new WeakMap();
|
|
295
|
-
|
|
102
|
+
_features = new WeakMap();
|
|
296
103
|
_registerInits = new WeakMap();
|
|
297
104
|
_extensionPoints = new WeakMap();
|
|
298
105
|
_serviceHolder = new WeakMap();
|
|
299
106
|
_getInitDeps = new WeakSet();
|
|
300
107
|
getInitDeps_fn = async function(deps, pluginId) {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
108
|
+
const result = /* @__PURE__ */ new Map();
|
|
109
|
+
const missingRefs = /* @__PURE__ */ new Set();
|
|
110
|
+
for (const [name, ref] of Object.entries(deps)) {
|
|
111
|
+
const extensionPoint = __privateGet$2(this, _extensionPoints).get(
|
|
112
|
+
ref
|
|
113
|
+
);
|
|
114
|
+
if (extensionPoint) {
|
|
115
|
+
result.set(name, extensionPoint);
|
|
116
|
+
} else {
|
|
117
|
+
const factory = await __privateGet$2(this, _serviceHolder).get(
|
|
118
|
+
ref
|
|
119
|
+
);
|
|
120
|
+
if (factory) {
|
|
121
|
+
result.set(name, await factory(pluginId));
|
|
122
|
+
} else {
|
|
123
|
+
missingRefs.add(ref);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (missingRefs.size > 0) {
|
|
128
|
+
const missing = Array.from(missingRefs).join(", ");
|
|
129
|
+
throw new Error(
|
|
130
|
+
`No extension point or service available for the following ref(s): ${missing}`
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
return Object.fromEntries(result);
|
|
311
134
|
};
|
|
312
135
|
_resolveInitOrder = new WeakSet();
|
|
313
136
|
resolveInitOrder_fn = function(registerInits) {
|
|
@@ -317,15 +140,14 @@ resolveInitOrder_fn = function(registerInits) {
|
|
|
317
140
|
const toRemove = /* @__PURE__ */ new Set();
|
|
318
141
|
for (const registerInit of registerInitsToOrder) {
|
|
319
142
|
const unInitializedDependents = [];
|
|
320
|
-
for (const
|
|
143
|
+
for (const provided of registerInit.provides) {
|
|
321
144
|
if (registerInitsToOrder.some(
|
|
322
|
-
(init) => init !== registerInit && init.consumes.has(
|
|
145
|
+
(init) => init !== registerInit && init.consumes.has(provided)
|
|
323
146
|
)) {
|
|
324
|
-
unInitializedDependents.push(
|
|
147
|
+
unInitializedDependents.push(provided);
|
|
325
148
|
}
|
|
326
149
|
}
|
|
327
150
|
if (unInitializedDependents.length === 0) {
|
|
328
|
-
console.log(`DEBUG: pushed ${registerInit.id} to results`);
|
|
329
151
|
orderedRegisterInits.push(registerInit);
|
|
330
152
|
toRemove.add(registerInit);
|
|
331
153
|
}
|
|
@@ -418,8 +240,8 @@ class BackstageBackend {
|
|
|
418
240
|
__privateSet(this, _services, new ServiceRegistry(apiFactories));
|
|
419
241
|
__privateSet(this, _initializer, new BackendInitializer(__privateGet(this, _services)));
|
|
420
242
|
}
|
|
421
|
-
add(
|
|
422
|
-
__privateGet(this, _initializer).add(
|
|
243
|
+
add(feature) {
|
|
244
|
+
__privateGet(this, _initializer).add(feature);
|
|
423
245
|
}
|
|
424
246
|
async start() {
|
|
425
247
|
await __privateGet(this, _initializer).start();
|
|
@@ -428,13 +250,192 @@ class BackstageBackend {
|
|
|
428
250
|
_services = new WeakMap();
|
|
429
251
|
_initializer = new WeakMap();
|
|
430
252
|
|
|
431
|
-
function
|
|
432
|
-
|
|
433
|
-
return new BackstageBackend([
|
|
434
|
-
...defaultServiceFactories,
|
|
435
|
-
...(_a = options == null ? void 0 : options.apis) != null ? _a : []
|
|
436
|
-
]);
|
|
253
|
+
function createSpecializedBackend(options) {
|
|
254
|
+
return new BackstageBackend(options.services);
|
|
437
255
|
}
|
|
438
256
|
|
|
439
|
-
|
|
257
|
+
const cacheFactory = backendPluginApi.createServiceFactory({
|
|
258
|
+
service: backendPluginApi.cacheServiceRef,
|
|
259
|
+
deps: {
|
|
260
|
+
configFactory: backendPluginApi.configServiceRef
|
|
261
|
+
},
|
|
262
|
+
factory: async ({ configFactory }) => {
|
|
263
|
+
const config = await configFactory("root");
|
|
264
|
+
const cacheManager = backendCommon.CacheManager.fromConfig(config);
|
|
265
|
+
return async (pluginId) => {
|
|
266
|
+
return cacheManager.forPlugin(pluginId);
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
const configFactory = backendPluginApi.createServiceFactory({
|
|
272
|
+
service: backendPluginApi.configServiceRef,
|
|
273
|
+
deps: {
|
|
274
|
+
loggerFactory: backendPluginApi.loggerServiceRef
|
|
275
|
+
},
|
|
276
|
+
factory: async ({ loggerFactory }) => {
|
|
277
|
+
const logger = await loggerFactory("root");
|
|
278
|
+
const config = await backendCommon.loadBackendConfig({
|
|
279
|
+
argv: process.argv,
|
|
280
|
+
logger: backendPluginApi.loggerToWinstonLogger(logger)
|
|
281
|
+
});
|
|
282
|
+
return async () => {
|
|
283
|
+
return config;
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
const databaseFactory = backendPluginApi.createServiceFactory({
|
|
289
|
+
service: backendPluginApi.databaseServiceRef,
|
|
290
|
+
deps: {
|
|
291
|
+
configFactory: backendPluginApi.configServiceRef
|
|
292
|
+
},
|
|
293
|
+
factory: async ({ configFactory }) => {
|
|
294
|
+
const config = await configFactory("root");
|
|
295
|
+
const databaseManager = backendCommon.DatabaseManager.fromConfig(config);
|
|
296
|
+
return async (pluginId) => {
|
|
297
|
+
return databaseManager.forPlugin(pluginId);
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
const discoveryFactory = backendPluginApi.createServiceFactory({
|
|
303
|
+
service: backendPluginApi.discoveryServiceRef,
|
|
304
|
+
deps: {
|
|
305
|
+
configFactory: backendPluginApi.configServiceRef
|
|
306
|
+
},
|
|
307
|
+
factory: async ({ configFactory }) => {
|
|
308
|
+
const config = await configFactory("root");
|
|
309
|
+
const discovery = backendCommon.SingleHostDiscovery.fromConfig(config);
|
|
310
|
+
return async () => {
|
|
311
|
+
return discovery;
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
class BackstageLogger {
|
|
317
|
+
constructor(winston) {
|
|
318
|
+
this.winston = winston;
|
|
319
|
+
}
|
|
320
|
+
static fromWinston(logger) {
|
|
321
|
+
return new BackstageLogger(logger);
|
|
322
|
+
}
|
|
323
|
+
info(message, ...meta) {
|
|
324
|
+
this.winston.info(message, ...meta);
|
|
325
|
+
}
|
|
326
|
+
child(fields) {
|
|
327
|
+
return new BackstageLogger(this.winston.child(fields));
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
const loggerFactory = backendPluginApi.createServiceFactory({
|
|
331
|
+
service: backendPluginApi.loggerServiceRef,
|
|
332
|
+
deps: {},
|
|
333
|
+
factory: async () => {
|
|
334
|
+
const root = BackstageLogger.fromWinston(backendCommon.createRootLogger());
|
|
335
|
+
return async (pluginId) => {
|
|
336
|
+
return root.child({ pluginId });
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
const permissionsFactory = backendPluginApi.createServiceFactory({
|
|
342
|
+
service: backendPluginApi.permissionsServiceRef,
|
|
343
|
+
deps: {
|
|
344
|
+
configFactory: backendPluginApi.configServiceRef,
|
|
345
|
+
discoveryFactory: backendPluginApi.discoveryServiceRef,
|
|
346
|
+
tokenManagerFactory: backendPluginApi.tokenManagerServiceRef
|
|
347
|
+
},
|
|
348
|
+
factory: async ({ configFactory, discoveryFactory, tokenManagerFactory }) => {
|
|
349
|
+
const config = await configFactory("root");
|
|
350
|
+
const discovery = await discoveryFactory("root");
|
|
351
|
+
const tokenManager = await tokenManagerFactory("root");
|
|
352
|
+
const permissions = pluginPermissionNode.ServerPermissionClient.fromConfig(config, {
|
|
353
|
+
discovery,
|
|
354
|
+
tokenManager
|
|
355
|
+
});
|
|
356
|
+
return async (_pluginId) => {
|
|
357
|
+
return permissions;
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
const schedulerFactory = backendPluginApi.createServiceFactory({
|
|
363
|
+
service: backendPluginApi.schedulerServiceRef,
|
|
364
|
+
deps: {
|
|
365
|
+
configFactory: backendPluginApi.configServiceRef
|
|
366
|
+
},
|
|
367
|
+
factory: async ({ configFactory }) => {
|
|
368
|
+
const config = await configFactory("root");
|
|
369
|
+
const taskScheduler = backendTasks.TaskScheduler.fromConfig(config);
|
|
370
|
+
return async (pluginId) => {
|
|
371
|
+
return taskScheduler.forPlugin(pluginId);
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
const tokenManagerFactory = backendPluginApi.createServiceFactory({
|
|
377
|
+
service: backendPluginApi.tokenManagerServiceRef,
|
|
378
|
+
deps: {
|
|
379
|
+
configFactory: backendPluginApi.configServiceRef,
|
|
380
|
+
loggerFactory: backendPluginApi.loggerServiceRef
|
|
381
|
+
},
|
|
382
|
+
factory: async ({ configFactory, loggerFactory }) => {
|
|
383
|
+
const logger = await loggerFactory("root");
|
|
384
|
+
const config = await configFactory("root");
|
|
385
|
+
return async (_pluginId) => {
|
|
386
|
+
return backendCommon.ServerTokenManager.fromConfig(config, {
|
|
387
|
+
logger: backendPluginApi.loggerToWinstonLogger(logger)
|
|
388
|
+
});
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
const urlReaderFactory = backendPluginApi.createServiceFactory({
|
|
394
|
+
service: backendPluginApi.urlReaderServiceRef,
|
|
395
|
+
deps: {
|
|
396
|
+
configFactory: backendPluginApi.configServiceRef,
|
|
397
|
+
loggerFactory: backendPluginApi.loggerServiceRef
|
|
398
|
+
},
|
|
399
|
+
factory: async ({ configFactory, loggerFactory }) => {
|
|
400
|
+
return async (pluginId) => {
|
|
401
|
+
const logger = await loggerFactory(pluginId);
|
|
402
|
+
return backendCommon.UrlReaders.default({
|
|
403
|
+
logger: backendPluginApi.loggerToWinstonLogger(logger),
|
|
404
|
+
config: await configFactory(pluginId)
|
|
405
|
+
});
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
const httpRouterFactory = backendPluginApi.createServiceFactory({
|
|
411
|
+
service: backendPluginApi.httpRouterServiceRef,
|
|
412
|
+
deps: {
|
|
413
|
+
configFactory: backendPluginApi.configServiceRef
|
|
414
|
+
},
|
|
415
|
+
factory: async ({ configFactory }) => {
|
|
416
|
+
const rootRouter = Router__default["default"]();
|
|
417
|
+
const service = backendCommon.createServiceBuilder(module).loadConfig(await configFactory("root")).addRouter("", rootRouter);
|
|
418
|
+
await service.start();
|
|
419
|
+
return async (pluginId) => {
|
|
420
|
+
const path = pluginId ? `/api/${pluginId}` : "";
|
|
421
|
+
return {
|
|
422
|
+
use(handler) {
|
|
423
|
+
rootRouter.use(path, handler);
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
exports.cacheFactory = cacheFactory;
|
|
431
|
+
exports.configFactory = configFactory;
|
|
432
|
+
exports.createSpecializedBackend = createSpecializedBackend;
|
|
433
|
+
exports.databaseFactory = databaseFactory;
|
|
434
|
+
exports.discoveryFactory = discoveryFactory;
|
|
435
|
+
exports.httpRouterFactory = httpRouterFactory;
|
|
436
|
+
exports.loggerFactory = loggerFactory;
|
|
437
|
+
exports.permissionsFactory = permissionsFactory;
|
|
438
|
+
exports.schedulerFactory = schedulerFactory;
|
|
439
|
+
exports.tokenManagerFactory = tokenManagerFactory;
|
|
440
|
+
exports.urlReaderFactory = urlReaderFactory;
|
|
440
441
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/services/implementations/cacheService.ts","../src/services/implementations/configService.ts","../src/services/implementations/databaseService.ts","../src/services/implementations/discoveryService.ts","../src/services/implementations/loggerService.ts","../src/services/implementations/permissionsService.ts","../src/services/implementations/schedulerService.ts","../src/services/implementations/tokenManagerService.ts","../src/services/implementations/urlReaderService.ts","../src/services/implementations/httpRouterService.ts","../src/services/implementations/index.ts","../src/wiring/BackendInitializer.ts","../src/wiring/ServiceRegistry.ts","../src/wiring/BackstageBackend.ts","../src/wiring/types.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 { CacheManager } from '@backstage/backend-common';\nimport {\n configServiceRef,\n createServiceFactory,\n cacheServiceRef,\n} from '@backstage/backend-plugin-api';\n\n// TODO: Work out some naming and implementation patterns for these\nexport const cacheFactory = createServiceFactory({\n service: cacheServiceRef,\n deps: {\n configFactory: configServiceRef,\n },\n factory: async ({ configFactory }) => {\n const config = await configFactory('root');\n const cacheManager = CacheManager.fromConfig(config);\n return async (pluginId: string) => {\n return cacheManager.forPlugin(pluginId);\n };\n },\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { loadBackendConfig } from '@backstage/backend-common';\nimport {\n configServiceRef,\n createServiceFactory,\n loggerToWinstonLogger,\n loggerServiceRef,\n} from '@backstage/backend-plugin-api';\n\nexport const configFactory = createServiceFactory({\n service: configServiceRef,\n deps: {\n loggerFactory: loggerServiceRef,\n },\n factory: async ({ loggerFactory }) => {\n const logger = await loggerFactory('root');\n const config = await loadBackendConfig({\n argv: process.argv,\n logger: loggerToWinstonLogger(logger),\n });\n return async () => {\n return config;\n };\n },\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DatabaseManager } from '@backstage/backend-common';\nimport {\n configServiceRef,\n createServiceFactory,\n databaseServiceRef,\n} from '@backstage/backend-plugin-api';\n\nexport const databaseFactory = createServiceFactory({\n service: databaseServiceRef,\n deps: {\n configFactory: configServiceRef,\n },\n factory: async ({ configFactory }) => {\n const config = await configFactory('root');\n const databaseManager = DatabaseManager.fromConfig(config);\n return async (pluginId: string) => {\n return databaseManager.forPlugin(pluginId);\n };\n },\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SingleHostDiscovery } from '@backstage/backend-common';\nimport {\n configServiceRef,\n createServiceFactory,\n discoveryServiceRef,\n} from '@backstage/backend-plugin-api';\n\nexport const discoveryFactory = createServiceFactory({\n service: discoveryServiceRef,\n deps: {\n configFactory: configServiceRef,\n },\n factory: async ({ configFactory }) => {\n const config = await configFactory('root');\n const discovery = SingleHostDiscovery.fromConfig(config);\n return async () => {\n return discovery;\n };\n },\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createRootLogger } from '@backstage/backend-common';\nimport {\n createServiceFactory,\n Logger,\n loggerServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { Logger as WinstonLogger } from 'winston';\n\nclass BackstageLogger implements Logger {\n static fromWinston(logger: WinstonLogger): BackstageLogger {\n return new BackstageLogger(logger);\n }\n\n private constructor(private readonly winston: WinstonLogger) {}\n\n info(message: string, ...meta: any[]): void {\n this.winston.info(message, ...meta);\n }\n\n child(fields: { [name: string]: string }): Logger {\n return new BackstageLogger(this.winston.child(fields));\n }\n}\n\nexport const loggerFactory = createServiceFactory({\n service: loggerServiceRef,\n deps: {},\n factory: async () => {\n const root = BackstageLogger.fromWinston(createRootLogger());\n return async (pluginId: string) => {\n return root.child({ pluginId });\n };\n },\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n configServiceRef,\n createServiceFactory,\n discoveryServiceRef,\n permissionsServiceRef,\n tokenManagerServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { ServerPermissionClient } from '@backstage/plugin-permission-node';\n\nexport const permissionsFactory = createServiceFactory({\n service: permissionsServiceRef,\n deps: {\n configFactory: configServiceRef,\n discoveryFactory: discoveryServiceRef,\n tokenManagerFactory: tokenManagerServiceRef,\n },\n factory: async ({ configFactory, discoveryFactory, tokenManagerFactory }) => {\n const config = await configFactory('root');\n const discovery = await discoveryFactory('root');\n const tokenManager = await tokenManagerFactory('root');\n const permissions = ServerPermissionClient.fromConfig(config, {\n discovery,\n tokenManager,\n });\n return async (_pluginId: string) => {\n return permissions;\n };\n },\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n configServiceRef,\n createServiceFactory,\n schedulerServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { TaskScheduler } from '@backstage/backend-tasks';\n\nexport const schedulerFactory = createServiceFactory({\n service: schedulerServiceRef,\n deps: {\n configFactory: configServiceRef,\n },\n factory: async ({ configFactory }) => {\n const config = await configFactory('root');\n const taskScheduler = TaskScheduler.fromConfig(config);\n return async (pluginId: string) => {\n return taskScheduler.forPlugin(pluginId);\n };\n },\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n configServiceRef,\n loggerServiceRef,\n createServiceFactory,\n tokenManagerServiceRef,\n loggerToWinstonLogger,\n} from '@backstage/backend-plugin-api';\nimport { ServerTokenManager } from '@backstage/backend-common';\n\nexport const tokenManagerFactory = createServiceFactory({\n service: tokenManagerServiceRef,\n deps: {\n configFactory: configServiceRef,\n loggerFactory: loggerServiceRef,\n },\n factory: async ({ configFactory, loggerFactory }) => {\n const logger = await loggerFactory('root');\n const config = await configFactory('root');\n return async (_pluginId: string) => {\n // doesn't the logger want to be inferred from the plugin tho here?\n // maybe ... also why do we recreate it every time otherwise\n // we should memoize on a per plugin right? so I think it's should be fine to re-use the plugin one\n // we shouldn't recreate on a per plugin basis.\n // hm - on the other hand, is this really ever called more than once?\n // not this function right. should only be called when the plugin requests this serviceRef\n // yeah so no need to worry about memo probably\n // but we still want to scope the logger to the ServrTokenmanagfer>?\n // mm sure maybe\n // maybe in this case it doesn't provide so much value b\n // oh hang on - isn't it up to THE MANAGER to make a child internally if it wants to do that\n // so that it becomes a property intrinsic to that class, no matter how it's constructed\n // or is that too much responsibility for it - making the constructor complex so to speak, making it harder to tweak that behavior\n // this is not ultra efficient :)\n\n // I think the naming here is wrong to be gonest\n // this isn't like the cache manager or the database manager\n // the manager name is confusuion i think\n // aye perhaps\n return ServerTokenManager.fromConfig(config, {\n logger: loggerToWinstonLogger(logger),\n });\n };\n },\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { UrlReaders } from '@backstage/backend-common';\nimport {\n configServiceRef,\n createServiceFactory,\n loggerServiceRef,\n loggerToWinstonLogger,\n urlReaderServiceRef,\n} from '@backstage/backend-plugin-api';\n\nexport const urlReaderFactory = createServiceFactory({\n service: urlReaderServiceRef,\n deps: {\n configFactory: configServiceRef,\n loggerFactory: loggerServiceRef,\n },\n factory: async ({ configFactory, loggerFactory }) => {\n return async (pluginId: string) => {\n const logger = await loggerFactory(pluginId);\n return UrlReaders.default({\n logger: loggerToWinstonLogger(logger),\n config: await configFactory(pluginId),\n });\n };\n },\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n createServiceFactory,\n httpRouterServiceRef,\n configServiceRef,\n} from '@backstage/backend-plugin-api';\nimport Router from 'express-promise-router';\nimport { Handler } from 'express';\nimport { createServiceBuilder } from '@backstage/backend-common';\n\nexport const httpRouterFactory = createServiceFactory({\n service: httpRouterServiceRef,\n deps: {\n configFactory: configServiceRef,\n },\n factory: async ({ configFactory }) => {\n const rootRouter = Router();\n\n const service = createServiceBuilder(module)\n .loadConfig(await configFactory('root'))\n .addRouter('', rootRouter);\n\n await service.start();\n\n return async (pluginId?: string) => {\n const path = pluginId ? `/api/${pluginId}` : '';\n return {\n use(handler: Handler) {\n rootRouter.use(path, handler);\n },\n };\n };\n },\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { cacheFactory } from './cacheService';\nimport { configFactory } from './configService';\nimport { databaseFactory } from './databaseService';\nimport { discoveryFactory } from './discoveryService';\nimport { loggerFactory } from './loggerService';\nimport { permissionsFactory } from './permissionsService';\nimport { schedulerFactory } from './schedulerService';\nimport { tokenManagerFactory } from './tokenManagerService';\nimport { urlReaderFactory } from './urlReaderService';\nimport { httpRouterFactory } from './httpRouterService';\n\nexport const defaultServiceFactories = [\n cacheFactory,\n configFactory,\n databaseFactory,\n discoveryFactory,\n loggerFactory,\n permissionsFactory,\n schedulerFactory,\n tokenManagerFactory,\n urlReaderFactory,\n httpRouterFactory,\n];\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n BackendRegistrable,\n ExtensionPoint,\n ServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { BackendRegisterInit, ServiceHolder } from './types';\n\ntype ServiceOrExtensionPoint = ExtensionPoint<unknown> | ServiceRef<unknown>;\n\nexport class BackendInitializer {\n #started = false;\n #extensions = new Map<BackendRegistrable, unknown>();\n #registerInits = new Array<BackendRegisterInit>();\n #extensionPoints = new Map<ServiceOrExtensionPoint, unknown>();\n #serviceHolder: ServiceHolder;\n\n constructor(serviceHolder: ServiceHolder) {\n this.#serviceHolder = serviceHolder;\n }\n\n async #getInitDeps(\n deps: { [name: string]: ServiceOrExtensionPoint },\n pluginId: string,\n ) {\n return Object.fromEntries(\n await Promise.all(\n Object.entries(deps).map(async ([name, ref]) => [\n name,\n this.#extensionPoints.get(ref) ||\n (await this.#serviceHolder.get(ref as ServiceRef<unknown>)!(\n pluginId,\n )),\n ]),\n ),\n );\n }\n\n add<TOptions>(extension: BackendRegistrable, options?: TOptions) {\n if (this.#started) {\n throw new Error(\n 'extension can not be added after the backend has started',\n );\n }\n this.#extensions.set(extension, options);\n }\n\n async start(): Promise<void> {\n console.log(`Starting backend`);\n if (this.#started) {\n throw new Error('Backend has already started');\n }\n this.#started = true;\n\n for (const [extension] of this.#extensions) {\n const provides = new Set<ServiceRef<unknown>>();\n\n let registerInit: BackendRegisterInit | undefined = undefined;\n\n console.log('Registering', extension.id);\n extension.register({\n registerExtensionPoint: (extensionPointRef, impl) => {\n if (registerInit) {\n throw new Error('registerExtensionPoint called after registerInit');\n }\n if (this.#extensionPoints.has(extensionPointRef)) {\n throw new Error(`API ${extensionPointRef.id} already registered`);\n }\n this.#extensionPoints.set(extensionPointRef, impl);\n provides.add(extensionPointRef);\n },\n registerInit: registerOptions => {\n if (registerInit) {\n throw new Error('registerInit must only be called once');\n }\n registerInit = {\n id: extension.id,\n provides,\n consumes: new Set(Object.values(registerOptions.deps)),\n deps: registerOptions.deps,\n init: registerOptions.init as BackendRegisterInit['init'],\n };\n },\n });\n\n if (!registerInit) {\n throw new Error(\n `registerInit was not called by register in ${extension.id}`,\n );\n }\n\n this.#registerInits.push(registerInit);\n }\n\n this.validateSetup();\n\n const orderedRegisterResults = this.#resolveInitOrder(this.#registerInits);\n\n for (const registerInit of orderedRegisterResults) {\n const deps = await this.#getInitDeps(registerInit.deps, registerInit.id);\n await registerInit.init(deps);\n }\n }\n\n private validateSetup() {}\n\n #resolveInitOrder(registerInits: Array<BackendRegisterInit>) {\n let registerInitsToOrder = registerInits.slice();\n const orderedRegisterInits = new Array<BackendRegisterInit>();\n\n // TODO: Validate duplicates\n\n while (registerInitsToOrder.length > 0) {\n const toRemove = new Set<unknown>();\n\n for (const registerInit of registerInitsToOrder) {\n const unInitializedDependents = [];\n\n for (const serviceRef of registerInit.provides) {\n if (\n registerInitsToOrder.some(\n init => init !== registerInit && init.consumes.has(serviceRef),\n )\n ) {\n unInitializedDependents.push(serviceRef);\n }\n }\n\n if (unInitializedDependents.length === 0) {\n console.log(`DEBUG: pushed ${registerInit.id} to results`);\n orderedRegisterInits.push(registerInit);\n toRemove.add(registerInit);\n }\n }\n\n registerInitsToOrder = registerInitsToOrder.filter(r => !toRemove.has(r));\n }\n return orderedRegisterInits;\n }\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n AnyServiceFactory,\n FactoryFunc,\n ServiceRef,\n} from '@backstage/backend-plugin-api';\n\nexport class ServiceRegistry {\n readonly #implementations: Map<string, Map<string, unknown>>;\n readonly #factories: Map<string, AnyServiceFactory>;\n\n constructor(factories: AnyServiceFactory[]) {\n this.#factories = new Map(factories.map(f => [f.service.id, f]));\n this.#implementations = new Map();\n }\n\n get<T>(ref: ServiceRef<T>): FactoryFunc<T> | undefined {\n const factory = this.#factories.get(ref.id);\n if (!factory) {\n return undefined;\n }\n\n return async (pluginId: string): Promise<T> => {\n let implementations = this.#implementations.get(ref.id);\n if (implementations) {\n if (implementations.has(pluginId)) {\n return implementations.get(pluginId) as T;\n }\n } else {\n implementations = new Map();\n this.#implementations.set(ref.id, implementations);\n }\n\n const factoryDeps = Object.fromEntries(\n Object.entries(factory.deps).map(([name, serviceRef]) => [\n name,\n this.get(serviceRef)!, // TODO: throw\n ]),\n );\n\n const factoryFunc = await factory.factory(factoryDeps);\n const implementation = await factoryFunc(pluginId);\n\n implementations.set(pluginId, implementation);\n\n return implementation as T;\n };\n }\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n AnyServiceFactory,\n BackendRegistrable,\n} from '@backstage/backend-plugin-api';\nimport { BackendInitializer } from './BackendInitializer';\nimport { ServiceRegistry } from './ServiceRegistry';\nimport { Backend } from './types';\n\nexport class BackstageBackend implements Backend {\n #services: ServiceRegistry;\n #initializer: BackendInitializer;\n\n constructor(apiFactories: AnyServiceFactory[]) {\n this.#services = new ServiceRegistry(apiFactories);\n this.#initializer = new BackendInitializer(this.#services);\n }\n\n add(extension: BackendRegistrable): void {\n this.#initializer.add(extension);\n }\n\n async start(): Promise<void> {\n await this.#initializer.start();\n }\n\n // async stop(): Promise<void> {\n // await this.#initializer.stop();\n // }\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n AnyServiceFactory,\n BackendRegistrable,\n FactoryFunc,\n ServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { defaultServiceFactories } from '../services/implementations';\nimport { BackstageBackend } from './BackstageBackend';\n\n/**\n * @public\n */\nexport interface Backend {\n add(extension: BackendRegistrable): void;\n start(): Promise<void>;\n}\n\nexport interface BackendRegisterInit {\n id: string;\n consumes: Set<ServiceRef<unknown>>;\n provides: Set<ServiceRef<unknown>>;\n deps: { [name: string]: ServiceRef<unknown> };\n init: (deps: { [name: string]: unknown }) => Promise<void>;\n}\n\n/**\n * @public\n */\nexport interface CreateBackendOptions {\n apis: AnyServiceFactory[];\n}\n\nexport type ServiceHolder = {\n get<T>(api: ServiceRef<T>): FactoryFunc<T> | undefined;\n};\n\n/**\n * @public\n */\nexport function createBackend(options?: CreateBackendOptions): Backend {\n // TODO: merge with provided APIs\n return new BackstageBackend([\n ...defaultServiceFactories,\n ...(options?.apis ?? []),\n ]);\n}\n"],"names":["createServiceFactory","cacheServiceRef","configServiceRef","CacheManager","loggerServiceRef","loadBackendConfig","loggerToWinstonLogger","databaseServiceRef","DatabaseManager","discoveryServiceRef","SingleHostDiscovery","createRootLogger","permissionsServiceRef","tokenManagerServiceRef","ServerPermissionClient","schedulerServiceRef","TaskScheduler","ServerTokenManager","urlReaderServiceRef","U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":"index.cjs.js","sources":["../src/wiring/BackendInitializer.ts","../src/wiring/ServiceRegistry.ts","../src/wiring/BackstageBackend.ts","../src/wiring/types.ts","../src/services/implementations/cacheService.ts","../src/services/implementations/configService.ts","../src/services/implementations/databaseService.ts","../src/services/implementations/discoveryService.ts","../src/services/implementations/loggerService.ts","../src/services/implementations/permissionsService.ts","../src/services/implementations/schedulerService.ts","../src/services/implementations/tokenManagerService.ts","../src/services/implementations/urlReaderService.ts","../src/services/implementations/httpRouterService.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n BackendFeature,\n ExtensionPoint,\n ServiceRef,\n} from '@backstage/backend-plugin-api';\nimport {\n BackendRegisterInit,\n ServiceHolder,\n ServiceOrExtensionPoint,\n} from './types';\n\nexport class BackendInitializer {\n #started = false;\n #features = new Map<BackendFeature, unknown>();\n #registerInits = new Array<BackendRegisterInit>();\n #extensionPoints = new Map<ExtensionPoint<unknown>, unknown>();\n #serviceHolder: ServiceHolder;\n\n constructor(serviceHolder: ServiceHolder) {\n this.#serviceHolder = serviceHolder;\n }\n\n async #getInitDeps(\n deps: { [name: string]: ServiceOrExtensionPoint },\n pluginId: string,\n ) {\n const result = new Map<string, unknown>();\n const missingRefs = new Set<ServiceOrExtensionPoint>();\n\n for (const [name, ref] of Object.entries(deps)) {\n const extensionPoint = this.#extensionPoints.get(\n ref as ExtensionPoint<unknown>,\n );\n if (extensionPoint) {\n result.set(name, extensionPoint);\n } else {\n const factory = await this.#serviceHolder.get(\n ref as ServiceRef<unknown>,\n );\n if (factory) {\n result.set(name, await factory(pluginId));\n } else {\n missingRefs.add(ref);\n }\n }\n }\n\n if (missingRefs.size > 0) {\n const missing = Array.from(missingRefs).join(', ');\n throw new Error(\n `No extension point or service available for the following ref(s): ${missing}`,\n );\n }\n\n return Object.fromEntries(result);\n }\n\n add<TOptions>(feature: BackendFeature, options?: TOptions) {\n if (this.#started) {\n throw new Error('feature can not be added after the backend has started');\n }\n this.#features.set(feature, options);\n }\n\n async start(): Promise<void> {\n if (this.#started) {\n throw new Error('Backend has already started');\n }\n this.#started = true;\n\n for (const [feature] of this.#features) {\n const provides = new Set<ExtensionPoint<unknown>>();\n\n let registerInit: BackendRegisterInit | undefined = undefined;\n\n feature.register({\n registerExtensionPoint: (extensionPointRef, impl) => {\n if (registerInit) {\n throw new Error('registerExtensionPoint called after registerInit');\n }\n if (this.#extensionPoints.has(extensionPointRef)) {\n throw new Error(`API ${extensionPointRef.id} already registered`);\n }\n this.#extensionPoints.set(extensionPointRef, impl);\n provides.add(extensionPointRef);\n },\n registerInit: registerOptions => {\n if (registerInit) {\n throw new Error('registerInit must only be called once');\n }\n registerInit = {\n id: feature.id,\n provides,\n consumes: new Set(Object.values(registerOptions.deps)),\n deps: registerOptions.deps,\n init: registerOptions.init as BackendRegisterInit['init'],\n };\n },\n });\n\n if (!registerInit) {\n throw new Error(\n `registerInit was not called by register in ${feature.id}`,\n );\n }\n\n this.#registerInits.push(registerInit);\n }\n\n const orderedRegisterResults = this.#resolveInitOrder(this.#registerInits);\n\n for (const registerInit of orderedRegisterResults) {\n const deps = await this.#getInitDeps(registerInit.deps, registerInit.id);\n await registerInit.init(deps);\n }\n }\n\n #resolveInitOrder(registerInits: Array<BackendRegisterInit>) {\n let registerInitsToOrder = registerInits.slice();\n const orderedRegisterInits = new Array<BackendRegisterInit>();\n\n // TODO: Validate duplicates\n\n while (registerInitsToOrder.length > 0) {\n const toRemove = new Set<unknown>();\n\n for (const registerInit of registerInitsToOrder) {\n const unInitializedDependents = [];\n\n for (const provided of registerInit.provides) {\n if (\n registerInitsToOrder.some(\n init => init !== registerInit && init.consumes.has(provided),\n )\n ) {\n unInitializedDependents.push(provided);\n }\n }\n\n if (unInitializedDependents.length === 0) {\n orderedRegisterInits.push(registerInit);\n toRemove.add(registerInit);\n }\n }\n\n registerInitsToOrder = registerInitsToOrder.filter(r => !toRemove.has(r));\n }\n\n return orderedRegisterInits;\n }\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n AnyServiceFactory,\n FactoryFunc,\n ServiceRef,\n} from '@backstage/backend-plugin-api';\n\nexport class ServiceRegistry {\n readonly #implementations: Map<string, Map<string, unknown>>;\n readonly #factories: Map<string, AnyServiceFactory>;\n\n constructor(factories: AnyServiceFactory[]) {\n this.#factories = new Map(factories.map(f => [f.service.id, f]));\n this.#implementations = new Map();\n }\n\n get<T>(ref: ServiceRef<T>): FactoryFunc<T> | undefined {\n const factory = this.#factories.get(ref.id);\n if (!factory) {\n return undefined;\n }\n\n return async (pluginId: string): Promise<T> => {\n let implementations = this.#implementations.get(ref.id);\n if (implementations) {\n if (implementations.has(pluginId)) {\n return implementations.get(pluginId) as T;\n }\n } else {\n implementations = new Map();\n this.#implementations.set(ref.id, implementations);\n }\n\n const factoryDeps = Object.fromEntries(\n Object.entries(factory.deps).map(([name, serviceRef]) => [\n name,\n this.get(serviceRef)!, // TODO: throw\n ]),\n );\n\n const factoryFunc = await factory.factory(factoryDeps);\n const implementation = await factoryFunc(pluginId);\n\n implementations.set(pluginId, implementation);\n\n return implementation as T;\n };\n }\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n AnyServiceFactory,\n BackendFeature,\n} from '@backstage/backend-plugin-api';\nimport { BackendInitializer } from './BackendInitializer';\nimport { ServiceRegistry } from './ServiceRegistry';\nimport { Backend } from './types';\n\nexport class BackstageBackend implements Backend {\n #services: ServiceRegistry;\n #initializer: BackendInitializer;\n\n constructor(apiFactories: AnyServiceFactory[]) {\n this.#services = new ServiceRegistry(apiFactories);\n this.#initializer = new BackendInitializer(this.#services);\n }\n\n add(feature: BackendFeature): void {\n this.#initializer.add(feature);\n }\n\n async start(): Promise<void> {\n await this.#initializer.start();\n }\n\n // async stop(): Promise<void> {\n // await this.#initializer.stop();\n // }\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n AnyServiceFactory,\n BackendFeature,\n ExtensionPoint,\n FactoryFunc,\n ServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { BackstageBackend } from './BackstageBackend';\n\n/**\n * @public\n */\nexport interface Backend {\n add(feature: BackendFeature): void;\n start(): Promise<void>;\n}\n\nexport interface BackendRegisterInit {\n id: string;\n consumes: Set<ServiceOrExtensionPoint>;\n provides: Set<ServiceOrExtensionPoint>;\n deps: { [name: string]: ServiceOrExtensionPoint };\n init: (deps: { [name: string]: unknown }) => Promise<void>;\n}\n\n/**\n * @public\n */\nexport interface CreateSpecializedBackendOptions {\n services: AnyServiceFactory[];\n}\n\nexport type ServiceHolder = {\n get<T>(api: ServiceRef<T>): FactoryFunc<T> | undefined;\n};\n\n/**\n * @public\n */\nexport function createSpecializedBackend(\n options: CreateSpecializedBackendOptions,\n): Backend {\n return new BackstageBackend(options.services);\n}\n\n/**\n * @public\n */\nexport type ServiceOrExtensionPoint<T = unknown> =\n | ExtensionPoint<T>\n | ServiceRef<T>;\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CacheManager } from '@backstage/backend-common';\nimport {\n configServiceRef,\n createServiceFactory,\n cacheServiceRef,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const cacheFactory = createServiceFactory({\n service: cacheServiceRef,\n deps: {\n configFactory: configServiceRef,\n },\n factory: async ({ configFactory }) => {\n const config = await configFactory('root');\n const cacheManager = CacheManager.fromConfig(config);\n return async (pluginId: string) => {\n return cacheManager.forPlugin(pluginId);\n };\n },\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { loadBackendConfig } from '@backstage/backend-common';\nimport {\n configServiceRef,\n createServiceFactory,\n loggerToWinstonLogger,\n loggerServiceRef,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const configFactory = createServiceFactory({\n service: configServiceRef,\n deps: {\n loggerFactory: loggerServiceRef,\n },\n factory: async ({ loggerFactory }) => {\n const logger = await loggerFactory('root');\n const config = await loadBackendConfig({\n argv: process.argv,\n logger: loggerToWinstonLogger(logger),\n });\n return async () => {\n return config;\n };\n },\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DatabaseManager } from '@backstage/backend-common';\nimport {\n configServiceRef,\n createServiceFactory,\n databaseServiceRef,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const databaseFactory = createServiceFactory({\n service: databaseServiceRef,\n deps: {\n configFactory: configServiceRef,\n },\n factory: async ({ configFactory }) => {\n const config = await configFactory('root');\n const databaseManager = DatabaseManager.fromConfig(config);\n return async (pluginId: string) => {\n return databaseManager.forPlugin(pluginId);\n };\n },\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SingleHostDiscovery } from '@backstage/backend-common';\nimport {\n configServiceRef,\n createServiceFactory,\n discoveryServiceRef,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const discoveryFactory = createServiceFactory({\n service: discoveryServiceRef,\n deps: {\n configFactory: configServiceRef,\n },\n factory: async ({ configFactory }) => {\n const config = await configFactory('root');\n const discovery = SingleHostDiscovery.fromConfig(config);\n return async () => {\n return discovery;\n };\n },\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createRootLogger } from '@backstage/backend-common';\nimport {\n createServiceFactory,\n Logger,\n loggerServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { Logger as WinstonLogger } from 'winston';\n\nclass BackstageLogger implements Logger {\n static fromWinston(logger: WinstonLogger): BackstageLogger {\n return new BackstageLogger(logger);\n }\n\n private constructor(private readonly winston: WinstonLogger) {}\n\n info(message: string, ...meta: any[]): void {\n this.winston.info(message, ...meta);\n }\n\n child(fields: { [name: string]: string }): Logger {\n return new BackstageLogger(this.winston.child(fields));\n }\n}\n\n/** @public */\nexport const loggerFactory = createServiceFactory({\n service: loggerServiceRef,\n deps: {},\n factory: async () => {\n const root = BackstageLogger.fromWinston(createRootLogger());\n return async (pluginId: string) => {\n return root.child({ pluginId });\n };\n },\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n configServiceRef,\n createServiceFactory,\n discoveryServiceRef,\n permissionsServiceRef,\n tokenManagerServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { ServerPermissionClient } from '@backstage/plugin-permission-node';\n\n/** @public */\nexport const permissionsFactory = createServiceFactory({\n service: permissionsServiceRef,\n deps: {\n configFactory: configServiceRef,\n discoveryFactory: discoveryServiceRef,\n tokenManagerFactory: tokenManagerServiceRef,\n },\n factory: async ({ configFactory, discoveryFactory, tokenManagerFactory }) => {\n const config = await configFactory('root');\n const discovery = await discoveryFactory('root');\n const tokenManager = await tokenManagerFactory('root');\n const permissions = ServerPermissionClient.fromConfig(config, {\n discovery,\n tokenManager,\n });\n return async (_pluginId: string) => {\n return permissions;\n };\n },\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n configServiceRef,\n createServiceFactory,\n schedulerServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { TaskScheduler } from '@backstage/backend-tasks';\n\n/** @public */\nexport const schedulerFactory = createServiceFactory({\n service: schedulerServiceRef,\n deps: {\n configFactory: configServiceRef,\n },\n factory: async ({ configFactory }) => {\n const config = await configFactory('root');\n const taskScheduler = TaskScheduler.fromConfig(config);\n return async (pluginId: string) => {\n return taskScheduler.forPlugin(pluginId);\n };\n },\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n configServiceRef,\n loggerServiceRef,\n createServiceFactory,\n tokenManagerServiceRef,\n loggerToWinstonLogger,\n} from '@backstage/backend-plugin-api';\nimport { ServerTokenManager } from '@backstage/backend-common';\n\n/** @public */\nexport const tokenManagerFactory = createServiceFactory({\n service: tokenManagerServiceRef,\n deps: {\n configFactory: configServiceRef,\n loggerFactory: loggerServiceRef,\n },\n factory: async ({ configFactory, loggerFactory }) => {\n const logger = await loggerFactory('root');\n const config = await configFactory('root');\n return async (_pluginId: string) => {\n // doesn't the logger want to be inferred from the plugin tho here?\n // maybe ... also why do we recreate it every time otherwise\n // we should memoize on a per plugin right? so I think it's should be fine to re-use the plugin one\n // we shouldn't recreate on a per plugin basis.\n // hm - on the other hand, is this really ever called more than once?\n // not this function right. should only be called when the plugin requests this serviceRef\n // yeah so no need to worry about memo probably\n // but we still want to scope the logger to the ServrTokenmanagfer>?\n // mm sure maybe\n // maybe in this case it doesn't provide so much value b\n // oh hang on - isn't it up to THE MANAGER to make a child internally if it wants to do that\n // so that it becomes a property intrinsic to that class, no matter how it's constructed\n // or is that too much responsibility for it - making the constructor complex so to speak, making it harder to tweak that behavior\n // this is not ultra efficient :)\n\n // I think the naming here is wrong to be gonest\n // this isn't like the cache manager or the database manager\n // the manager name is confusuion i think\n // aye perhaps\n return ServerTokenManager.fromConfig(config, {\n logger: loggerToWinstonLogger(logger),\n });\n };\n },\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { UrlReaders } from '@backstage/backend-common';\nimport {\n configServiceRef,\n createServiceFactory,\n loggerServiceRef,\n loggerToWinstonLogger,\n urlReaderServiceRef,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const urlReaderFactory = createServiceFactory({\n service: urlReaderServiceRef,\n deps: {\n configFactory: configServiceRef,\n loggerFactory: loggerServiceRef,\n },\n factory: async ({ configFactory, loggerFactory }) => {\n return async (pluginId: string) => {\n const logger = await loggerFactory(pluginId);\n return UrlReaders.default({\n logger: loggerToWinstonLogger(logger),\n config: await configFactory(pluginId),\n });\n };\n },\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n createServiceFactory,\n httpRouterServiceRef,\n configServiceRef,\n} from '@backstage/backend-plugin-api';\nimport Router from 'express-promise-router';\nimport { Handler } from 'express';\nimport { createServiceBuilder } from '@backstage/backend-common';\n\n/** @public */\nexport const httpRouterFactory = createServiceFactory({\n service: httpRouterServiceRef,\n deps: {\n configFactory: configServiceRef,\n },\n factory: async ({ configFactory }) => {\n const rootRouter = Router();\n\n const service = createServiceBuilder(module)\n .loadConfig(await configFactory('root'))\n .addRouter('', rootRouter);\n\n await service.start();\n\n return async (pluginId?: string) => {\n const path = pluginId ? `/api/${pluginId}` : '';\n return {\n use(handler: Handler) {\n rootRouter.use(path, handler);\n },\n };\n };\n },\n});\n"],"names":["__accessCheck","__privateGet","__privateAdd","__privateSet","createServiceFactory","cacheServiceRef","configServiceRef","CacheManager","loggerServiceRef","loadBackendConfig","loggerToWinstonLogger","databaseServiceRef","DatabaseManager","discoveryServiceRef","SingleHostDiscovery","createRootLogger","permissionsServiceRef","tokenManagerServiceRef","ServerPermissionClient","schedulerServiceRef","TaskScheduler","ServerTokenManager","urlReaderServiceRef","UrlReaders","httpRouterServiceRef","Router","createServiceBuilder"],"mappings":";;;;;;;;;;;;;;AAAA,IAAIA,eAAa,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,KAAK;AAC1C,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;AACtB,IAAI,MAAM,SAAS,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC;AACrC,CAAC,CAAC;AACF,IAAIC,cAAY,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,KAAK;AAC5C,EAAED,eAAa,CAAC,GAAG,EAAE,MAAM,EAAE,yBAAyB,CAAC,CAAC;AACxD,EAAE,OAAO,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACrD,CAAC,CAAC;AACF,IAAIE,cAAY,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,KAAK;AAC3C,EAAE,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;AACrB,IAAI,MAAM,SAAS,CAAC,mDAAmD,CAAC,CAAC;AACzE,EAAE,MAAM,YAAY,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACvE,CAAC,CAAC;AACF,IAAIC,cAAY,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK;AACnD,EAAEH,eAAa,CAAC,GAAG,EAAE,MAAM,EAAE,wBAAwB,CAAC,CAAC;AACvD,EAAE,MAAM,GAAG,MAAM,CAAC,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;;;;;;;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,26 +5,75 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { AnyServiceFactory } from '@backstage/backend-plugin-api';
|
|
8
|
-
import {
|
|
8
|
+
import { BackendFeature } from '@backstage/backend-plugin-api';
|
|
9
|
+
import { Config } from '@backstage/config';
|
|
10
|
+
import { ExtensionPoint } from '@backstage/backend-plugin-api';
|
|
11
|
+
import { HttpRouterService } from '@backstage/backend-plugin-api';
|
|
12
|
+
import { Logger } from '@backstage/backend-plugin-api';
|
|
13
|
+
import { PermissionAuthorizer } from '@backstage/plugin-permission-common';
|
|
14
|
+
import { PermissionEvaluator } from '@backstage/plugin-permission-common';
|
|
15
|
+
import { PluginCacheManager } from '@backstage/backend-common';
|
|
16
|
+
import { PluginDatabaseManager } from '@backstage/backend-common';
|
|
17
|
+
import { PluginEndpointDiscovery } from '@backstage/backend-common';
|
|
18
|
+
import { PluginTaskScheduler } from '@backstage/backend-tasks';
|
|
19
|
+
import { ServiceFactory } from '@backstage/backend-plugin-api';
|
|
20
|
+
import { ServiceRef } from '@backstage/backend-plugin-api';
|
|
21
|
+
import { TokenManager } from '@backstage/backend-common';
|
|
22
|
+
import { UrlReader } from '@backstage/backend-common';
|
|
9
23
|
|
|
10
24
|
/**
|
|
11
25
|
* @public
|
|
12
26
|
*/
|
|
13
27
|
export declare interface Backend {
|
|
14
|
-
add(
|
|
28
|
+
add(feature: BackendFeature): void;
|
|
15
29
|
start(): Promise<void>;
|
|
16
30
|
}
|
|
17
31
|
|
|
32
|
+
/** @public */
|
|
33
|
+
export declare const cacheFactory: ServiceFactory<PluginCacheManager, PluginCacheManager, {}>;
|
|
34
|
+
|
|
35
|
+
/** @public */
|
|
36
|
+
export declare const configFactory: ServiceFactory<Config, Config, {}>;
|
|
37
|
+
|
|
18
38
|
/**
|
|
19
39
|
* @public
|
|
20
40
|
*/
|
|
21
|
-
export declare function
|
|
41
|
+
export declare function createSpecializedBackend(options: CreateSpecializedBackendOptions): Backend;
|
|
22
42
|
|
|
23
43
|
/**
|
|
24
44
|
* @public
|
|
25
45
|
*/
|
|
26
|
-
export declare interface
|
|
27
|
-
|
|
46
|
+
export declare interface CreateSpecializedBackendOptions {
|
|
47
|
+
services: AnyServiceFactory[];
|
|
28
48
|
}
|
|
29
49
|
|
|
50
|
+
/** @public */
|
|
51
|
+
export declare const databaseFactory: ServiceFactory<PluginDatabaseManager, PluginDatabaseManager, {}>;
|
|
52
|
+
|
|
53
|
+
/** @public */
|
|
54
|
+
export declare const discoveryFactory: ServiceFactory<PluginEndpointDiscovery, PluginEndpointDiscovery, {}>;
|
|
55
|
+
|
|
56
|
+
/** @public */
|
|
57
|
+
export declare const httpRouterFactory: ServiceFactory<HttpRouterService, HttpRouterService, {}>;
|
|
58
|
+
|
|
59
|
+
/** @public */
|
|
60
|
+
export declare const loggerFactory: ServiceFactory<Logger, Logger, {}>;
|
|
61
|
+
|
|
62
|
+
/** @public */
|
|
63
|
+
export declare const permissionsFactory: ServiceFactory<PermissionAuthorizer | PermissionEvaluator, PermissionAuthorizer | PermissionEvaluator, {}>;
|
|
64
|
+
|
|
65
|
+
/** @public */
|
|
66
|
+
export declare const schedulerFactory: ServiceFactory<PluginTaskScheduler, PluginTaskScheduler, {}>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
71
|
+
export declare type ServiceOrExtensionPoint<T = unknown> = ExtensionPoint<T> | ServiceRef<T>;
|
|
72
|
+
|
|
73
|
+
/** @public */
|
|
74
|
+
export declare const tokenManagerFactory: ServiceFactory<TokenManager, TokenManager, {}>;
|
|
75
|
+
|
|
76
|
+
/** @public */
|
|
77
|
+
export declare const urlReaderFactory: ServiceFactory<UrlReader, UrlReader, {}>;
|
|
78
|
+
|
|
30
79
|
export { }
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/backend-app-api",
|
|
3
3
|
"description": "Core API used by Backstage backend apps",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"private": false,
|
|
@@ -34,20 +34,20 @@
|
|
|
34
34
|
"start": "backstage-cli package start"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@backstage/backend-common": "^0.15.0
|
|
38
|
-
"@backstage/backend-plugin-api": "^0.1.1
|
|
39
|
-
"@backstage/backend-tasks": "^0.3.4
|
|
40
|
-
"@backstage/plugin-permission-node": "^0.6.4
|
|
37
|
+
"@backstage/backend-common": "^0.15.0",
|
|
38
|
+
"@backstage/backend-plugin-api": "^0.1.1",
|
|
39
|
+
"@backstage/backend-tasks": "^0.3.4",
|
|
40
|
+
"@backstage/plugin-permission-node": "^0.6.4",
|
|
41
41
|
"express": "^4.17.1",
|
|
42
42
|
"express-promise-router": "^4.1.0",
|
|
43
43
|
"winston": "^3.2.1"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@backstage/cli": "^0.18.1
|
|
46
|
+
"@backstage/cli": "^0.18.1"
|
|
47
47
|
},
|
|
48
48
|
"files": [
|
|
49
49
|
"dist",
|
|
50
50
|
"alpha"
|
|
51
51
|
],
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "a12f6269e3bf224aa7f52475be9152bc52addeed"
|
|
53
53
|
}
|