@backstage/backend-plugin-api 0.0.0-nightly-20220709024234
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 +15 -0
- package/README.md +19 -0
- package/alpha/package.json +6 -0
- package/dist/index.alpha.d.ts +206 -0
- package/dist/index.beta.d.ts +206 -0
- package/dist/index.cjs.js +129 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +206 -0
- package/package.json +53 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @backstage/backend-plugin-api
|
|
2
|
+
|
|
3
|
+
## 0.0.0-nightly-20220709024234
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 91c1d12123: Introduced new package for creating backend plugins using the new alpha backend plugin framework.
|
|
8
|
+
This package is still considered **EXPERIMENTAL** and things will change without warning. Do not use this for production.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
- @backstage/backend-common@0.0.0-nightly-20220709024234
|
|
14
|
+
- @backstage/plugin-permission-common@0.0.0-nightly-20220709024234
|
|
15
|
+
- @backstage/backend-tasks@0.0.0-nightly-20220709024234
|
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @backstage/backend-plugin-api
|
|
2
|
+
|
|
3
|
+
**This package is HIGHLY EXPERIMENTAL, do not use this for production**
|
|
4
|
+
|
|
5
|
+
This package provides the core API used by Backstage backend plugins.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add the library to your backend plugin package:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# From your Backstage root directory
|
|
13
|
+
yarn add --cwd plugin/<plugin>-backend @backstage/backend-plugin-api
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Documentation
|
|
17
|
+
|
|
18
|
+
- [Backstage Readme](https://github.com/backstage/backstage/blob/master/README.md)
|
|
19
|
+
- [Backstage Documentation](https://github.com/backstage/backstage/blob/master/docs/README.md)
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core API used by Backstage backend plugins.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Config } from '@backstage/config';
|
|
8
|
+
import { Handler } from 'express';
|
|
9
|
+
import { Logger as Logger_2 } from 'winston';
|
|
10
|
+
import { PermissionAuthorizer } from '@backstage/plugin-permission-common';
|
|
11
|
+
import { PermissionEvaluator } from '@backstage/plugin-permission-common';
|
|
12
|
+
import { PluginCacheManager } from '@backstage/backend-common';
|
|
13
|
+
import { PluginDatabaseManager } from '@backstage/backend-common';
|
|
14
|
+
import { PluginEndpointDiscovery } from '@backstage/backend-common';
|
|
15
|
+
import { PluginTaskScheduler } from '@backstage/backend-tasks';
|
|
16
|
+
import { TokenManager } from '@backstage/backend-common';
|
|
17
|
+
import { TransportStreamOptions } from 'winston-transport';
|
|
18
|
+
import { UrlReader } from '@backstage/backend-common';
|
|
19
|
+
|
|
20
|
+
/** @public */
|
|
21
|
+
export declare type AnyServiceFactory = ServiceFactory<unknown, unknown, {
|
|
22
|
+
[key in string]: unknown;
|
|
23
|
+
}>;
|
|
24
|
+
|
|
25
|
+
/** @public */
|
|
26
|
+
export declare interface BackendInitRegistry {
|
|
27
|
+
registerExtensionPoint<TExtensionPoint>(ref: ServiceRef<TExtensionPoint>, impl: TExtensionPoint): void;
|
|
28
|
+
registerInit<Deps extends {
|
|
29
|
+
[name in string]: unknown;
|
|
30
|
+
}>(options: {
|
|
31
|
+
deps: {
|
|
32
|
+
[name in keyof Deps]: ServiceRef<Deps[name]>;
|
|
33
|
+
};
|
|
34
|
+
init: (deps: Deps) => Promise<void>;
|
|
35
|
+
}): void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** @public */
|
|
39
|
+
export declare interface BackendModuleConfig<TOptions> {
|
|
40
|
+
pluginId: string;
|
|
41
|
+
moduleId: string;
|
|
42
|
+
register(reg: Omit<BackendInitRegistry, 'registerExtensionPoint'>, options: TOptions): void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** @public */
|
|
46
|
+
export declare interface BackendPluginConfig<TOptions> {
|
|
47
|
+
id: string;
|
|
48
|
+
register(reg: BackendInitRegistry, options: TOptions): void;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** @public */
|
|
52
|
+
export declare interface BackendRegistrable {
|
|
53
|
+
id: string;
|
|
54
|
+
register(reg: BackendInitRegistry): void;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
export declare const cacheServiceRef: ServiceRef<PluginCacheManager>;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
export declare const configServiceRef: ServiceRef<Config>;
|
|
66
|
+
|
|
67
|
+
/** @public */
|
|
68
|
+
export declare function createBackendModule<TOptions>(config: BackendModuleConfig<TOptions>): (option: TOptions) => BackendRegistrable;
|
|
69
|
+
|
|
70
|
+
/** @public */
|
|
71
|
+
export declare function createBackendPlugin<TOptions>(config: BackendPluginConfig<TOptions>): (option: TOptions) => BackendRegistrable;
|
|
72
|
+
|
|
73
|
+
/** @public */
|
|
74
|
+
export declare function createExtensionPoint<T>(options: {
|
|
75
|
+
id: string;
|
|
76
|
+
}): ExtensionPoint<T>;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @public
|
|
80
|
+
*/
|
|
81
|
+
export declare function createServiceFactory<Api, Impl extends Api, Deps extends {
|
|
82
|
+
[name in string]: unknown;
|
|
83
|
+
}>(factory: ServiceFactory<Api, Impl, Deps>): ServiceFactory<Api, Api, {}>;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @public
|
|
87
|
+
*/
|
|
88
|
+
export declare function createServiceRef<T>(options: {
|
|
89
|
+
id: string;
|
|
90
|
+
}): ServiceRef<T>;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
export declare const databaseServiceRef: ServiceRef<PluginDatabaseManager>;
|
|
96
|
+
|
|
97
|
+
/** @public */
|
|
98
|
+
export declare type DepsToDepFactories<T> = {
|
|
99
|
+
[key in keyof T]: (pluginId: string) => Promise<T[key]>;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
105
|
+
export declare const discoveryServiceRef: ServiceRef<PluginEndpointDiscovery>;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* TODO
|
|
109
|
+
*
|
|
110
|
+
* @public
|
|
111
|
+
*/
|
|
112
|
+
export declare type ExtensionPoint<T> = {
|
|
113
|
+
id: string;
|
|
114
|
+
/**
|
|
115
|
+
* Utility for getting the type of the extension point, using `typeof extensionPoint.T`.
|
|
116
|
+
* Attempting to actually read this value will result in an exception.
|
|
117
|
+
*/
|
|
118
|
+
T: T;
|
|
119
|
+
toString(): string;
|
|
120
|
+
$$ref: 'extension-point';
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/** @public */
|
|
124
|
+
export declare type FactoryFunc<Impl> = (pluginId: string) => Promise<Impl>;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @public
|
|
128
|
+
*/
|
|
129
|
+
export declare interface HttpRouterService {
|
|
130
|
+
use(handler: Handler): void;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @public
|
|
135
|
+
*/
|
|
136
|
+
export declare const httpRouterServiceRef: ServiceRef<HttpRouterService>;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @public
|
|
140
|
+
*/
|
|
141
|
+
export declare interface Logger {
|
|
142
|
+
info(message: string): void;
|
|
143
|
+
child(fields: {
|
|
144
|
+
[name: string]: string;
|
|
145
|
+
}): Logger;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @public
|
|
150
|
+
*/
|
|
151
|
+
export declare const loggerServiceRef: ServiceRef<Logger>;
|
|
152
|
+
|
|
153
|
+
/** @public */
|
|
154
|
+
export declare function loggerToWinstonLogger(logger: Logger, opts?: TransportStreamOptions): Logger_2;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* @public
|
|
158
|
+
*/
|
|
159
|
+
export declare const permissionsServiceRef: ServiceRef<PermissionAuthorizer | PermissionEvaluator>;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @public
|
|
163
|
+
*/
|
|
164
|
+
export declare const schedulerServiceRef: ServiceRef<PluginTaskScheduler>;
|
|
165
|
+
|
|
166
|
+
/** @public */
|
|
167
|
+
export declare type ServiceFactory<TApi, TImpl extends TApi, TDeps extends {
|
|
168
|
+
[name in string]: unknown;
|
|
169
|
+
}> = {
|
|
170
|
+
service: ServiceRef<TApi>;
|
|
171
|
+
deps: TypesToServiceRef<TDeps>;
|
|
172
|
+
factory(deps: DepsToDepFactories<TDeps>): Promise<FactoryFunc<TImpl>>;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* TODO
|
|
177
|
+
*
|
|
178
|
+
* @public
|
|
179
|
+
*/
|
|
180
|
+
export declare type ServiceRef<T> = {
|
|
181
|
+
id: string;
|
|
182
|
+
/**
|
|
183
|
+
* Utility for getting the type of the service, using `typeof serviceRef.T`.
|
|
184
|
+
* Attempting to actually read this value will result in an exception.
|
|
185
|
+
*/
|
|
186
|
+
T: T;
|
|
187
|
+
toString(): string;
|
|
188
|
+
$$ref: 'service';
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* @public
|
|
193
|
+
*/
|
|
194
|
+
export declare const tokenManagerServiceRef: ServiceRef<TokenManager>;
|
|
195
|
+
|
|
196
|
+
/** @public */
|
|
197
|
+
export declare type TypesToServiceRef<T> = {
|
|
198
|
+
[key in keyof T]: ServiceRef<T[key]>;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* @public
|
|
203
|
+
*/
|
|
204
|
+
export declare const urlReaderServiceRef: ServiceRef<UrlReader>;
|
|
205
|
+
|
|
206
|
+
export { }
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core API used by Backstage backend plugins.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Config } from '@backstage/config';
|
|
8
|
+
import { Handler } from 'express';
|
|
9
|
+
import { Logger as Logger_2 } from 'winston';
|
|
10
|
+
import { PermissionAuthorizer } from '@backstage/plugin-permission-common';
|
|
11
|
+
import { PermissionEvaluator } from '@backstage/plugin-permission-common';
|
|
12
|
+
import { PluginCacheManager } from '@backstage/backend-common';
|
|
13
|
+
import { PluginDatabaseManager } from '@backstage/backend-common';
|
|
14
|
+
import { PluginEndpointDiscovery } from '@backstage/backend-common';
|
|
15
|
+
import { PluginTaskScheduler } from '@backstage/backend-tasks';
|
|
16
|
+
import { TokenManager } from '@backstage/backend-common';
|
|
17
|
+
import { TransportStreamOptions } from 'winston-transport';
|
|
18
|
+
import { UrlReader } from '@backstage/backend-common';
|
|
19
|
+
|
|
20
|
+
/** @public */
|
|
21
|
+
export declare type AnyServiceFactory = ServiceFactory<unknown, unknown, {
|
|
22
|
+
[key in string]: unknown;
|
|
23
|
+
}>;
|
|
24
|
+
|
|
25
|
+
/** @public */
|
|
26
|
+
export declare interface BackendInitRegistry {
|
|
27
|
+
registerExtensionPoint<TExtensionPoint>(ref: ServiceRef<TExtensionPoint>, impl: TExtensionPoint): void;
|
|
28
|
+
registerInit<Deps extends {
|
|
29
|
+
[name in string]: unknown;
|
|
30
|
+
}>(options: {
|
|
31
|
+
deps: {
|
|
32
|
+
[name in keyof Deps]: ServiceRef<Deps[name]>;
|
|
33
|
+
};
|
|
34
|
+
init: (deps: Deps) => Promise<void>;
|
|
35
|
+
}): void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** @public */
|
|
39
|
+
export declare interface BackendModuleConfig<TOptions> {
|
|
40
|
+
pluginId: string;
|
|
41
|
+
moduleId: string;
|
|
42
|
+
register(reg: Omit<BackendInitRegistry, 'registerExtensionPoint'>, options: TOptions): void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** @public */
|
|
46
|
+
export declare interface BackendPluginConfig<TOptions> {
|
|
47
|
+
id: string;
|
|
48
|
+
register(reg: BackendInitRegistry, options: TOptions): void;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** @public */
|
|
52
|
+
export declare interface BackendRegistrable {
|
|
53
|
+
id: string;
|
|
54
|
+
register(reg: BackendInitRegistry): void;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
export declare const cacheServiceRef: ServiceRef<PluginCacheManager>;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
export declare const configServiceRef: ServiceRef<Config>;
|
|
66
|
+
|
|
67
|
+
/** @public */
|
|
68
|
+
export declare function createBackendModule<TOptions>(config: BackendModuleConfig<TOptions>): (option: TOptions) => BackendRegistrable;
|
|
69
|
+
|
|
70
|
+
/** @public */
|
|
71
|
+
export declare function createBackendPlugin<TOptions>(config: BackendPluginConfig<TOptions>): (option: TOptions) => BackendRegistrable;
|
|
72
|
+
|
|
73
|
+
/** @public */
|
|
74
|
+
export declare function createExtensionPoint<T>(options: {
|
|
75
|
+
id: string;
|
|
76
|
+
}): ExtensionPoint<T>;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @public
|
|
80
|
+
*/
|
|
81
|
+
export declare function createServiceFactory<Api, Impl extends Api, Deps extends {
|
|
82
|
+
[name in string]: unknown;
|
|
83
|
+
}>(factory: ServiceFactory<Api, Impl, Deps>): ServiceFactory<Api, Api, {}>;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @public
|
|
87
|
+
*/
|
|
88
|
+
export declare function createServiceRef<T>(options: {
|
|
89
|
+
id: string;
|
|
90
|
+
}): ServiceRef<T>;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
export declare const databaseServiceRef: ServiceRef<PluginDatabaseManager>;
|
|
96
|
+
|
|
97
|
+
/** @public */
|
|
98
|
+
export declare type DepsToDepFactories<T> = {
|
|
99
|
+
[key in keyof T]: (pluginId: string) => Promise<T[key]>;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
105
|
+
export declare const discoveryServiceRef: ServiceRef<PluginEndpointDiscovery>;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* TODO
|
|
109
|
+
*
|
|
110
|
+
* @public
|
|
111
|
+
*/
|
|
112
|
+
export declare type ExtensionPoint<T> = {
|
|
113
|
+
id: string;
|
|
114
|
+
/**
|
|
115
|
+
* Utility for getting the type of the extension point, using `typeof extensionPoint.T`.
|
|
116
|
+
* Attempting to actually read this value will result in an exception.
|
|
117
|
+
*/
|
|
118
|
+
T: T;
|
|
119
|
+
toString(): string;
|
|
120
|
+
$$ref: 'extension-point';
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/** @public */
|
|
124
|
+
export declare type FactoryFunc<Impl> = (pluginId: string) => Promise<Impl>;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @public
|
|
128
|
+
*/
|
|
129
|
+
export declare interface HttpRouterService {
|
|
130
|
+
use(handler: Handler): void;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @public
|
|
135
|
+
*/
|
|
136
|
+
export declare const httpRouterServiceRef: ServiceRef<HttpRouterService>;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @public
|
|
140
|
+
*/
|
|
141
|
+
export declare interface Logger {
|
|
142
|
+
info(message: string): void;
|
|
143
|
+
child(fields: {
|
|
144
|
+
[name: string]: string;
|
|
145
|
+
}): Logger;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @public
|
|
150
|
+
*/
|
|
151
|
+
export declare const loggerServiceRef: ServiceRef<Logger>;
|
|
152
|
+
|
|
153
|
+
/** @public */
|
|
154
|
+
export declare function loggerToWinstonLogger(logger: Logger, opts?: TransportStreamOptions): Logger_2;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* @public
|
|
158
|
+
*/
|
|
159
|
+
export declare const permissionsServiceRef: ServiceRef<PermissionAuthorizer | PermissionEvaluator>;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @public
|
|
163
|
+
*/
|
|
164
|
+
export declare const schedulerServiceRef: ServiceRef<PluginTaskScheduler>;
|
|
165
|
+
|
|
166
|
+
/** @public */
|
|
167
|
+
export declare type ServiceFactory<TApi, TImpl extends TApi, TDeps extends {
|
|
168
|
+
[name in string]: unknown;
|
|
169
|
+
}> = {
|
|
170
|
+
service: ServiceRef<TApi>;
|
|
171
|
+
deps: TypesToServiceRef<TDeps>;
|
|
172
|
+
factory(deps: DepsToDepFactories<TDeps>): Promise<FactoryFunc<TImpl>>;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* TODO
|
|
177
|
+
*
|
|
178
|
+
* @public
|
|
179
|
+
*/
|
|
180
|
+
export declare type ServiceRef<T> = {
|
|
181
|
+
id: string;
|
|
182
|
+
/**
|
|
183
|
+
* Utility for getting the type of the service, using `typeof serviceRef.T`.
|
|
184
|
+
* Attempting to actually read this value will result in an exception.
|
|
185
|
+
*/
|
|
186
|
+
T: T;
|
|
187
|
+
toString(): string;
|
|
188
|
+
$$ref: 'service';
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* @public
|
|
193
|
+
*/
|
|
194
|
+
export declare const tokenManagerServiceRef: ServiceRef<TokenManager>;
|
|
195
|
+
|
|
196
|
+
/** @public */
|
|
197
|
+
export declare type TypesToServiceRef<T> = {
|
|
198
|
+
[key in keyof T]: ServiceRef<T[key]>;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* @public
|
|
203
|
+
*/
|
|
204
|
+
export declare const urlReaderServiceRef: ServiceRef<UrlReader>;
|
|
205
|
+
|
|
206
|
+
export { }
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var winston = require('winston');
|
|
6
|
+
var Transport = require('winston-transport');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var Transport__default = /*#__PURE__*/_interopDefaultLegacy(Transport);
|
|
11
|
+
|
|
12
|
+
function createServiceRef(options) {
|
|
13
|
+
return {
|
|
14
|
+
id: options.id,
|
|
15
|
+
get T() {
|
|
16
|
+
throw new Error(`tried to read ServiceRef.T of ${this}`);
|
|
17
|
+
},
|
|
18
|
+
toString() {
|
|
19
|
+
return `serviceRef{${options.id}}`;
|
|
20
|
+
},
|
|
21
|
+
$$ref: "service"
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function createServiceFactory(factory) {
|
|
25
|
+
return factory;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const configServiceRef = createServiceRef({
|
|
29
|
+
id: "core.config"
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const httpRouterServiceRef = createServiceRef({
|
|
33
|
+
id: "core.httpRouter"
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const loggerServiceRef = createServiceRef({
|
|
37
|
+
id: "core.logger"
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const urlReaderServiceRef = createServiceRef({
|
|
41
|
+
id: "core.urlReader"
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const cacheServiceRef = createServiceRef({
|
|
45
|
+
id: "core.cache"
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const databaseServiceRef = createServiceRef({
|
|
49
|
+
id: "core.database"
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const discoveryServiceRef = createServiceRef({
|
|
53
|
+
id: "core.discovery"
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const tokenManagerServiceRef = createServiceRef({
|
|
57
|
+
id: "core.tokenManager"
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const permissionsServiceRef = createServiceRef({
|
|
61
|
+
id: "core.permissions"
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const schedulerServiceRef = createServiceRef({
|
|
65
|
+
id: "core.scheduler"
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
class BackstageLoggerTransport extends Transport__default["default"] {
|
|
69
|
+
constructor(backstageLogger, opts) {
|
|
70
|
+
super(opts);
|
|
71
|
+
this.backstageLogger = backstageLogger;
|
|
72
|
+
}
|
|
73
|
+
log(info, callback) {
|
|
74
|
+
this.backstageLogger.info(info.message);
|
|
75
|
+
callback();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function loggerToWinstonLogger(logger, opts) {
|
|
79
|
+
return winston.createLogger({
|
|
80
|
+
transports: [new BackstageLoggerTransport(logger, opts)]
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function createExtensionPoint(options) {
|
|
85
|
+
return {
|
|
86
|
+
id: options.id,
|
|
87
|
+
get T() {
|
|
88
|
+
throw new Error(`tried to read ExtensionPoint.T of ${this}`);
|
|
89
|
+
},
|
|
90
|
+
toString() {
|
|
91
|
+
return `extensionPoint{${options.id}}`;
|
|
92
|
+
},
|
|
93
|
+
$$ref: "extension-point"
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function createBackendPlugin(config) {
|
|
97
|
+
return (options) => ({
|
|
98
|
+
id: config.id,
|
|
99
|
+
register(register) {
|
|
100
|
+
return config.register(register, options);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function createBackendModule(config) {
|
|
105
|
+
return (options) => ({
|
|
106
|
+
id: `${config.pluginId}.${config.moduleId}`,
|
|
107
|
+
register(register) {
|
|
108
|
+
return config.register(register, options);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
exports.cacheServiceRef = cacheServiceRef;
|
|
114
|
+
exports.configServiceRef = configServiceRef;
|
|
115
|
+
exports.createBackendModule = createBackendModule;
|
|
116
|
+
exports.createBackendPlugin = createBackendPlugin;
|
|
117
|
+
exports.createExtensionPoint = createExtensionPoint;
|
|
118
|
+
exports.createServiceFactory = createServiceFactory;
|
|
119
|
+
exports.createServiceRef = createServiceRef;
|
|
120
|
+
exports.databaseServiceRef = databaseServiceRef;
|
|
121
|
+
exports.discoveryServiceRef = discoveryServiceRef;
|
|
122
|
+
exports.httpRouterServiceRef = httpRouterServiceRef;
|
|
123
|
+
exports.loggerServiceRef = loggerServiceRef;
|
|
124
|
+
exports.loggerToWinstonLogger = loggerToWinstonLogger;
|
|
125
|
+
exports.permissionsServiceRef = permissionsServiceRef;
|
|
126
|
+
exports.schedulerServiceRef = schedulerServiceRef;
|
|
127
|
+
exports.tokenManagerServiceRef = tokenManagerServiceRef;
|
|
128
|
+
exports.urlReaderServiceRef = urlReaderServiceRef;
|
|
129
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/services/system/types.ts","../src/services/definitions/configServiceRef.ts","../src/services/definitions/httpRouterServiceRef.ts","../src/services/definitions/loggerServiceRef.ts","../src/services/definitions/urlReaderServiceRef.ts","../src/services/definitions/cacheServiceRef.ts","../src/services/definitions/databaseServiceRef.ts","../src/services/definitions/discoveryServiceRef.ts","../src/services/definitions/tokenManagerServiceRef.ts","../src/services/definitions/permissionsServiceRef.ts","../src/services/definitions/schedulerServiceRef.ts","../src/services/helpers/loggerToWinstonLogger.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\n/**\n * TODO\n *\n * @public\n */\nexport type ServiceRef<T> = {\n id: string;\n\n /**\n * Utility for getting the type of the service, using `typeof serviceRef.T`.\n * Attempting to actually read this value will result in an exception.\n */\n T: T;\n\n toString(): string;\n\n $$ref: 'service';\n};\n\n/** @public */\nexport type TypesToServiceRef<T> = { [key in keyof T]: ServiceRef<T[key]> };\n\n/** @public */\nexport type DepsToDepFactories<T> = {\n [key in keyof T]: (pluginId: string) => Promise<T[key]>;\n};\n\n/** @public */\nexport type FactoryFunc<Impl> = (pluginId: string) => Promise<Impl>;\n\n/** @public */\nexport type ServiceFactory<\n TApi,\n TImpl extends TApi,\n TDeps extends { [name in string]: unknown },\n> = {\n service: ServiceRef<TApi>;\n deps: TypesToServiceRef<TDeps>;\n factory(deps: DepsToDepFactories<TDeps>): Promise<FactoryFunc<TImpl>>;\n};\n\n/** @public */\nexport type AnyServiceFactory = ServiceFactory<\n unknown,\n unknown,\n { [key in string]: unknown }\n>;\n\n/**\n * @public\n */\nexport function createServiceRef<T>(options: { id: string }): ServiceRef<T> {\n return {\n id: options.id,\n get T(): T {\n throw new Error(`tried to read ServiceRef.T of ${this}`);\n },\n toString() {\n return `serviceRef{${options.id}}`;\n },\n $$ref: 'service', // TODO: declare\n };\n}\n\n/**\n * @public\n */\nexport function createServiceFactory<\n Api,\n Impl extends Api,\n Deps extends { [name in string]: unknown },\n>(factory: ServiceFactory<Api, Impl, Deps>): ServiceFactory<Api, Api, {}> {\n return factory;\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport { createServiceRef } from '../system/types';\n\n/**\n * @public\n */\nexport const configServiceRef = createServiceRef<Config>({\n id: 'core.config',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system/types';\nimport { Handler } from 'express';\n\n/**\n * @public\n */\nexport interface HttpRouterService {\n use(handler: Handler): void;\n}\n\n/**\n * @public\n */\nexport const httpRouterServiceRef = createServiceRef<HttpRouterService>({\n id: 'core.httpRouter',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system/types';\n\n/**\n * @public\n */\nexport interface Logger {\n info(message: string): void;\n child(fields: { [name: string]: string }): Logger;\n}\n\n/**\n * @public\n */\nexport const loggerServiceRef = createServiceRef<Logger>({\n id: 'core.logger',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system/types';\nimport { UrlReader } from '@backstage/backend-common';\n\n/**\n * @public\n */\nexport const urlReaderServiceRef = createServiceRef<UrlReader>({\n id: 'core.urlReader',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system/types';\nimport { PluginCacheManager } from '@backstage/backend-common';\n\n/**\n * @public\n */\nexport const cacheServiceRef = createServiceRef<PluginCacheManager>({\n id: 'core.cache',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { PluginDatabaseManager } from '@backstage/backend-common';\nimport { createServiceRef } from '../system/types';\n\n/**\n * @public\n */\nexport const databaseServiceRef = createServiceRef<PluginDatabaseManager>({\n id: 'core.database',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system/types';\nimport { PluginEndpointDiscovery } from '@backstage/backend-common';\n\n/**\n * @public\n */\nexport const discoveryServiceRef = createServiceRef<PluginEndpointDiscovery>({\n id: 'core.discovery',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system/types';\nimport { TokenManager } from '@backstage/backend-common';\n\n/**\n * @public\n */\nexport const tokenManagerServiceRef = createServiceRef<TokenManager>({\n id: 'core.tokenManager',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system/types';\nimport {\n PermissionAuthorizer,\n PermissionEvaluator,\n} from '@backstage/plugin-permission-common';\n\n/**\n * @public\n */\nexport const permissionsServiceRef = createServiceRef<\n PermissionEvaluator | PermissionAuthorizer\n>({\n id: 'core.permissions',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system/types';\nimport { PluginTaskScheduler } from '@backstage/backend-tasks';\n\n/**\n * @public\n */\nexport const schedulerServiceRef = createServiceRef<PluginTaskScheduler>({\n id: 'core.scheduler',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Logger as BackstageLogger } from '../definitions';\nimport { Logger as WinstonLogger, createLogger } from 'winston';\nimport Transport, { TransportStreamOptions } from 'winston-transport';\n\nclass BackstageLoggerTransport extends Transport {\n constructor(\n private readonly backstageLogger: BackstageLogger,\n opts?: TransportStreamOptions,\n ) {\n super(opts);\n }\n\n log(info: { message: string }, callback: VoidFunction) {\n // TODO: add support for levels and fields\n this.backstageLogger.info(info.message);\n callback();\n }\n}\n\n/** @public */\nexport function loggerToWinstonLogger(\n logger: BackstageLogger,\n opts?: TransportStreamOptions,\n): WinstonLogger {\n return createLogger({\n transports: [new BackstageLoggerTransport(logger, opts)],\n });\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ServiceRef } from '../services/system/types';\n\n/**\n * TODO\n *\n * @public\n */\nexport type ExtensionPoint<T> = {\n id: string;\n\n /**\n * Utility for getting the type of the extension point, using `typeof extensionPoint.T`.\n * Attempting to actually read this value will result in an exception.\n */\n T: T;\n\n toString(): string;\n\n $$ref: 'extension-point';\n};\n\n/** @public */\nexport function createExtensionPoint<T>(options: {\n id: string;\n}): ExtensionPoint<T> {\n return {\n id: options.id,\n get T(): T {\n throw new Error(`tried to read ExtensionPoint.T of ${this}`);\n },\n toString() {\n return `extensionPoint{${options.id}}`;\n },\n $$ref: 'extension-point', // TODO: declare\n };\n}\n\n/** @public */\nexport interface BackendInitRegistry {\n registerExtensionPoint<TExtensionPoint>(\n ref: ServiceRef<TExtensionPoint>,\n impl: TExtensionPoint,\n ): void;\n registerInit<Deps extends { [name in string]: unknown }>(options: {\n deps: { [name in keyof Deps]: ServiceRef<Deps[name]> };\n init: (deps: Deps) => Promise<void>;\n }): void;\n}\n\n/** @public */\nexport interface BackendRegistrable {\n id: string;\n register(reg: BackendInitRegistry): void;\n}\n\n/** @public */\nexport interface BackendPluginConfig<TOptions> {\n id: string;\n register(reg: BackendInitRegistry, options: TOptions): void;\n}\n\n// TODO: Make option optional in the returned factory if they are indeed optional\n/** @public */\nexport function createBackendPlugin<TOptions>(\n config: BackendPluginConfig<TOptions>,\n): (option: TOptions) => BackendRegistrable {\n return options => ({\n id: config.id,\n register(register) {\n return config.register(register, options);\n },\n });\n}\n\n/** @public */\nexport interface BackendModuleConfig<TOptions> {\n pluginId: string;\n moduleId: string;\n register(\n reg: Omit<BackendInitRegistry, 'registerExtensionPoint'>,\n options: TOptions,\n ): void;\n}\n\n// TODO: Make option optional in the returned factory if they are indeed optional\n/** @public */\nexport function createBackendModule<TOptions>(\n config: BackendModuleConfig<TOptions>,\n): (option: TOptions) => BackendRegistrable {\n return options => ({\n id: `${config.pluginId}.${config.moduleId}`,\n register(register) {\n // TODO: Hide registerExtensionPoint\n return config.register(register, options);\n },\n });\n}\n"],"names":["Transport","createLogger"],"mappings":"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"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core API used by Backstage backend plugins.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Config } from '@backstage/config';
|
|
8
|
+
import { Handler } from 'express';
|
|
9
|
+
import { Logger as Logger_2 } from 'winston';
|
|
10
|
+
import { PermissionAuthorizer } from '@backstage/plugin-permission-common';
|
|
11
|
+
import { PermissionEvaluator } from '@backstage/plugin-permission-common';
|
|
12
|
+
import { PluginCacheManager } from '@backstage/backend-common';
|
|
13
|
+
import { PluginDatabaseManager } from '@backstage/backend-common';
|
|
14
|
+
import { PluginEndpointDiscovery } from '@backstage/backend-common';
|
|
15
|
+
import { PluginTaskScheduler } from '@backstage/backend-tasks';
|
|
16
|
+
import { TokenManager } from '@backstage/backend-common';
|
|
17
|
+
import { TransportStreamOptions } from 'winston-transport';
|
|
18
|
+
import { UrlReader } from '@backstage/backend-common';
|
|
19
|
+
|
|
20
|
+
/** @public */
|
|
21
|
+
export declare type AnyServiceFactory = ServiceFactory<unknown, unknown, {
|
|
22
|
+
[key in string]: unknown;
|
|
23
|
+
}>;
|
|
24
|
+
|
|
25
|
+
/** @public */
|
|
26
|
+
export declare interface BackendInitRegistry {
|
|
27
|
+
registerExtensionPoint<TExtensionPoint>(ref: ServiceRef<TExtensionPoint>, impl: TExtensionPoint): void;
|
|
28
|
+
registerInit<Deps extends {
|
|
29
|
+
[name in string]: unknown;
|
|
30
|
+
}>(options: {
|
|
31
|
+
deps: {
|
|
32
|
+
[name in keyof Deps]: ServiceRef<Deps[name]>;
|
|
33
|
+
};
|
|
34
|
+
init: (deps: Deps) => Promise<void>;
|
|
35
|
+
}): void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** @public */
|
|
39
|
+
export declare interface BackendModuleConfig<TOptions> {
|
|
40
|
+
pluginId: string;
|
|
41
|
+
moduleId: string;
|
|
42
|
+
register(reg: Omit<BackendInitRegistry, 'registerExtensionPoint'>, options: TOptions): void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** @public */
|
|
46
|
+
export declare interface BackendPluginConfig<TOptions> {
|
|
47
|
+
id: string;
|
|
48
|
+
register(reg: BackendInitRegistry, options: TOptions): void;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** @public */
|
|
52
|
+
export declare interface BackendRegistrable {
|
|
53
|
+
id: string;
|
|
54
|
+
register(reg: BackendInitRegistry): void;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
export declare const cacheServiceRef: ServiceRef<PluginCacheManager>;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
export declare const configServiceRef: ServiceRef<Config>;
|
|
66
|
+
|
|
67
|
+
/** @public */
|
|
68
|
+
export declare function createBackendModule<TOptions>(config: BackendModuleConfig<TOptions>): (option: TOptions) => BackendRegistrable;
|
|
69
|
+
|
|
70
|
+
/** @public */
|
|
71
|
+
export declare function createBackendPlugin<TOptions>(config: BackendPluginConfig<TOptions>): (option: TOptions) => BackendRegistrable;
|
|
72
|
+
|
|
73
|
+
/** @public */
|
|
74
|
+
export declare function createExtensionPoint<T>(options: {
|
|
75
|
+
id: string;
|
|
76
|
+
}): ExtensionPoint<T>;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @public
|
|
80
|
+
*/
|
|
81
|
+
export declare function createServiceFactory<Api, Impl extends Api, Deps extends {
|
|
82
|
+
[name in string]: unknown;
|
|
83
|
+
}>(factory: ServiceFactory<Api, Impl, Deps>): ServiceFactory<Api, Api, {}>;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @public
|
|
87
|
+
*/
|
|
88
|
+
export declare function createServiceRef<T>(options: {
|
|
89
|
+
id: string;
|
|
90
|
+
}): ServiceRef<T>;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
export declare const databaseServiceRef: ServiceRef<PluginDatabaseManager>;
|
|
96
|
+
|
|
97
|
+
/** @public */
|
|
98
|
+
export declare type DepsToDepFactories<T> = {
|
|
99
|
+
[key in keyof T]: (pluginId: string) => Promise<T[key]>;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
105
|
+
export declare const discoveryServiceRef: ServiceRef<PluginEndpointDiscovery>;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* TODO
|
|
109
|
+
*
|
|
110
|
+
* @public
|
|
111
|
+
*/
|
|
112
|
+
export declare type ExtensionPoint<T> = {
|
|
113
|
+
id: string;
|
|
114
|
+
/**
|
|
115
|
+
* Utility for getting the type of the extension point, using `typeof extensionPoint.T`.
|
|
116
|
+
* Attempting to actually read this value will result in an exception.
|
|
117
|
+
*/
|
|
118
|
+
T: T;
|
|
119
|
+
toString(): string;
|
|
120
|
+
$$ref: 'extension-point';
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/** @public */
|
|
124
|
+
export declare type FactoryFunc<Impl> = (pluginId: string) => Promise<Impl>;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @public
|
|
128
|
+
*/
|
|
129
|
+
export declare interface HttpRouterService {
|
|
130
|
+
use(handler: Handler): void;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @public
|
|
135
|
+
*/
|
|
136
|
+
export declare const httpRouterServiceRef: ServiceRef<HttpRouterService>;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @public
|
|
140
|
+
*/
|
|
141
|
+
export declare interface Logger {
|
|
142
|
+
info(message: string): void;
|
|
143
|
+
child(fields: {
|
|
144
|
+
[name: string]: string;
|
|
145
|
+
}): Logger;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @public
|
|
150
|
+
*/
|
|
151
|
+
export declare const loggerServiceRef: ServiceRef<Logger>;
|
|
152
|
+
|
|
153
|
+
/** @public */
|
|
154
|
+
export declare function loggerToWinstonLogger(logger: Logger, opts?: TransportStreamOptions): Logger_2;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* @public
|
|
158
|
+
*/
|
|
159
|
+
export declare const permissionsServiceRef: ServiceRef<PermissionAuthorizer | PermissionEvaluator>;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @public
|
|
163
|
+
*/
|
|
164
|
+
export declare const schedulerServiceRef: ServiceRef<PluginTaskScheduler>;
|
|
165
|
+
|
|
166
|
+
/** @public */
|
|
167
|
+
export declare type ServiceFactory<TApi, TImpl extends TApi, TDeps extends {
|
|
168
|
+
[name in string]: unknown;
|
|
169
|
+
}> = {
|
|
170
|
+
service: ServiceRef<TApi>;
|
|
171
|
+
deps: TypesToServiceRef<TDeps>;
|
|
172
|
+
factory(deps: DepsToDepFactories<TDeps>): Promise<FactoryFunc<TImpl>>;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* TODO
|
|
177
|
+
*
|
|
178
|
+
* @public
|
|
179
|
+
*/
|
|
180
|
+
export declare type ServiceRef<T> = {
|
|
181
|
+
id: string;
|
|
182
|
+
/**
|
|
183
|
+
* Utility for getting the type of the service, using `typeof serviceRef.T`.
|
|
184
|
+
* Attempting to actually read this value will result in an exception.
|
|
185
|
+
*/
|
|
186
|
+
T: T;
|
|
187
|
+
toString(): string;
|
|
188
|
+
$$ref: 'service';
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* @public
|
|
193
|
+
*/
|
|
194
|
+
export declare const tokenManagerServiceRef: ServiceRef<TokenManager>;
|
|
195
|
+
|
|
196
|
+
/** @public */
|
|
197
|
+
export declare type TypesToServiceRef<T> = {
|
|
198
|
+
[key in keyof T]: ServiceRef<T[key]>;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* @public
|
|
203
|
+
*/
|
|
204
|
+
export declare const urlReaderServiceRef: ServiceRef<UrlReader>;
|
|
205
|
+
|
|
206
|
+
export { }
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@backstage/backend-plugin-api",
|
|
3
|
+
"description": "Core API used by Backstage backend plugins",
|
|
4
|
+
"version": "0.0.0-nightly-20220709024234",
|
|
5
|
+
"main": "dist/index.cjs.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"private": false,
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public",
|
|
10
|
+
"main": "dist/index.cjs.js",
|
|
11
|
+
"types": "dist/index.d.ts",
|
|
12
|
+
"alphaTypes": "dist/index.alpha.d.ts"
|
|
13
|
+
},
|
|
14
|
+
"backstage": {
|
|
15
|
+
"role": "node-library"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://backstage.io",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/backstage/backstage",
|
|
21
|
+
"directory": "packages/backend-plugin-api"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"backstage"
|
|
25
|
+
],
|
|
26
|
+
"license": "Apache-2.0",
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "backstage-cli package build --experimental-type-build",
|
|
29
|
+
"lint": "backstage-cli package lint",
|
|
30
|
+
"test": "backstage-cli package test",
|
|
31
|
+
"prepack": "backstage-cli package prepack",
|
|
32
|
+
"postpack": "backstage-cli package postpack",
|
|
33
|
+
"clean": "backstage-cli package clean",
|
|
34
|
+
"start": "backstage-cli package start"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@backstage/config": "^1.0.1",
|
|
38
|
+
"@backstage/backend-common": "0.0.0-nightly-20220709024234",
|
|
39
|
+
"@backstage/plugin-permission-common": "0.0.0-nightly-20220709024234",
|
|
40
|
+
"@backstage/backend-tasks": "0.0.0-nightly-20220709024234",
|
|
41
|
+
"@types/express": "^4.17.6",
|
|
42
|
+
"express": "^4.17.1",
|
|
43
|
+
"winston": "^3.2.1",
|
|
44
|
+
"winston-transport": "^4.5.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@backstage/cli": "0.0.0-nightly-20220709024234"
|
|
48
|
+
},
|
|
49
|
+
"files": [
|
|
50
|
+
"dist",
|
|
51
|
+
"alpha"
|
|
52
|
+
]
|
|
53
|
+
}
|