@backstage/backend-plugin-api 0.4.0 → 0.4.1-next.1
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 +24 -0
- package/README.md +1 -1
- package/dist/index.d.ts +562 -607
- package/package.json +8 -9
- package/alpha/package.json +0 -6
- package/dist/index.alpha.d.ts +0 -924
- package/dist/index.beta.d.ts +0 -924
package/dist/index.d.ts
CHANGED
|
@@ -1,394 +1,361 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core API used by Backstage backend plugins.
|
|
3
|
-
*
|
|
4
|
-
* @packageDocumentation
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
1
|
/// <reference types="node" />
|
|
8
|
-
|
|
9
|
-
import { Config } from '@backstage/config';
|
|
10
|
-
import { Handler } from 'express';
|
|
11
2
|
import { IdentityApi } from '@backstage/plugin-auth-node';
|
|
12
|
-
import { JsonObject } from '@backstage/types';
|
|
13
|
-
import { JsonValue } from '@backstage/types';
|
|
14
|
-
import { Knex } from 'knex';
|
|
15
|
-
import { PermissionEvaluator } from '@backstage/plugin-permission-common';
|
|
16
|
-
import { PluginTaskScheduler } from '@backstage/backend-tasks';
|
|
17
3
|
import { Readable } from 'stream';
|
|
4
|
+
import { PluginTaskScheduler } from '@backstage/backend-tasks';
|
|
5
|
+
import { JsonObject, JsonValue } from '@backstage/types';
|
|
6
|
+
import { Handler } from 'express';
|
|
7
|
+
import { PermissionEvaluator } from '@backstage/plugin-permission-common';
|
|
8
|
+
import { Knex } from 'knex';
|
|
9
|
+
import { Config } from '@backstage/config';
|
|
18
10
|
|
|
19
11
|
/** @public */
|
|
20
|
-
|
|
21
|
-
$$type: '@backstage/BackendFeature';
|
|
12
|
+
interface IdentityService extends IdentityApi {
|
|
22
13
|
}
|
|
23
14
|
|
|
24
15
|
/**
|
|
25
|
-
*
|
|
16
|
+
* A generic interface for fetching plain data from URLs.
|
|
26
17
|
*
|
|
27
18
|
* @public
|
|
28
|
-
* @see {@link https://backstage.io/docs/backend-system/architecture/modules | The architecture of modules}
|
|
29
|
-
* @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}
|
|
30
19
|
*/
|
|
31
|
-
|
|
20
|
+
interface UrlReaderService {
|
|
32
21
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}
|
|
22
|
+
* Reads a single file and return its content.
|
|
36
23
|
*/
|
|
37
|
-
|
|
24
|
+
readUrl(url: string, options?: ReadUrlOptions): Promise<ReadUrlResponse>;
|
|
38
25
|
/**
|
|
39
|
-
*
|
|
26
|
+
* Reads a full or partial file tree.
|
|
40
27
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
* The callbacks passed to the `register` method of a backend module.
|
|
47
|
-
*
|
|
48
|
-
* @public
|
|
49
|
-
*/
|
|
50
|
-
export declare interface BackendModuleRegistrationPoints {
|
|
51
|
-
registerInit<Deps extends {
|
|
52
|
-
[name in string]: unknown;
|
|
53
|
-
}>(options: {
|
|
54
|
-
deps: {
|
|
55
|
-
[name in keyof Deps]: ServiceRef<Deps[name]> | ExtensionPoint<Deps[name]>;
|
|
56
|
-
};
|
|
57
|
-
init(deps: Deps): Promise<void>;
|
|
58
|
-
}): void;
|
|
28
|
+
readTree(url: string, options?: ReadTreeOptions): Promise<ReadTreeResponse>;
|
|
29
|
+
/**
|
|
30
|
+
* Searches for a file in a tree using a glob pattern.
|
|
31
|
+
*/
|
|
32
|
+
search(url: string, options?: SearchOptions): Promise<SearchResponse>;
|
|
59
33
|
}
|
|
60
|
-
|
|
61
34
|
/**
|
|
62
|
-
*
|
|
35
|
+
* An options object for readUrl operations.
|
|
63
36
|
*
|
|
64
37
|
* @public
|
|
65
|
-
* @see {@link https://backstage.io/docs/backend-system/architecture/plugins | The architecture of plugins}
|
|
66
|
-
* @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}
|
|
67
38
|
*/
|
|
68
|
-
|
|
39
|
+
declare type ReadUrlOptions = {
|
|
69
40
|
/**
|
|
70
|
-
*
|
|
41
|
+
* An ETag which can be provided to check whether a
|
|
42
|
+
* {@link UrlReaderService.readUrl} response has changed from a previous execution.
|
|
71
43
|
*
|
|
72
|
-
* @
|
|
44
|
+
* @remarks
|
|
45
|
+
*
|
|
46
|
+
* In the {@link UrlReaderService.readUrl} response, an ETag is returned along with
|
|
47
|
+
* the data. The ETag is a unique identifier of the data, usually the commit
|
|
48
|
+
* SHA or ETag from the target.
|
|
49
|
+
*
|
|
50
|
+
* When an ETag is given in ReadUrlOptions, {@link UrlReaderService.readUrl} will
|
|
51
|
+
* first compare the ETag against the ETag of the target. If they match,
|
|
52
|
+
* {@link UrlReaderService.readUrl} will throw a
|
|
53
|
+
* {@link @backstage/errors#NotModifiedError} indicating that the response
|
|
54
|
+
* will not differ from the previous response which included this particular
|
|
55
|
+
* ETag. If they do not match, {@link UrlReaderService.readUrl} will return the rest
|
|
56
|
+
* of the response along with a new ETag.
|
|
73
57
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
58
|
+
etag?: string;
|
|
59
|
+
/**
|
|
60
|
+
* An abort signal to pass down to the underlying request.
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
*
|
|
64
|
+
* Not all reader implementations may take this field into account.
|
|
65
|
+
*/
|
|
66
|
+
signal?: AbortSignal;
|
|
67
|
+
};
|
|
78
68
|
/**
|
|
79
|
-
*
|
|
69
|
+
* A response object for {@link UrlReaderService.readUrl} operations.
|
|
80
70
|
*
|
|
81
71
|
* @public
|
|
82
72
|
*/
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
73
|
+
declare type ReadUrlResponse = {
|
|
74
|
+
/**
|
|
75
|
+
* Returns the data that was read from the remote URL.
|
|
76
|
+
*/
|
|
77
|
+
buffer(): Promise<Buffer>;
|
|
78
|
+
/**
|
|
79
|
+
* Returns the data that was read from the remote URL as a Readable stream.
|
|
80
|
+
*
|
|
81
|
+
* @remarks
|
|
82
|
+
*
|
|
83
|
+
* This method will be required in a future release.
|
|
84
|
+
*/
|
|
85
|
+
stream?(): Readable;
|
|
86
|
+
/**
|
|
87
|
+
* Etag returned by content provider.
|
|
88
|
+
*
|
|
89
|
+
* @remarks
|
|
90
|
+
*
|
|
91
|
+
* Can be used to compare and cache responses when doing subsequent calls.
|
|
92
|
+
*/
|
|
93
|
+
etag?: string;
|
|
94
|
+
};
|
|
95
95
|
/**
|
|
96
|
-
*
|
|
97
|
-
* Backstage plugins.
|
|
96
|
+
* An options object for {@link UrlReaderService.readTree} operations.
|
|
98
97
|
*
|
|
99
98
|
* @public
|
|
100
99
|
*/
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Reads data from a cache store for the given key. If no data was found,
|
|
104
|
-
* returns undefined.
|
|
105
|
-
*/
|
|
106
|
-
get<TValue extends JsonValue>(key: string): Promise<TValue | undefined>;
|
|
100
|
+
declare type ReadTreeOptions = {
|
|
107
101
|
/**
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
102
|
+
* A filter that can be used to select which files should be included.
|
|
103
|
+
*
|
|
104
|
+
* @remarks
|
|
105
|
+
*
|
|
106
|
+
* The path passed to the filter function is the relative path from the URL
|
|
107
|
+
* that the file tree is fetched from, without any leading '/'.
|
|
108
|
+
*
|
|
109
|
+
* For example, given the URL https://github.com/my/repo/tree/master/my-dir, a file
|
|
110
|
+
* at https://github.com/my/repo/blob/master/my-dir/my-subdir/my-file.txt will
|
|
111
|
+
* be represented as my-subdir/my-file.txt
|
|
112
|
+
*
|
|
113
|
+
* If no filter is provided, all files are extracted.
|
|
111
114
|
*/
|
|
112
|
-
|
|
115
|
+
filter?(path: string, info?: {
|
|
116
|
+
size: number;
|
|
117
|
+
}): boolean;
|
|
113
118
|
/**
|
|
114
|
-
*
|
|
119
|
+
* An ETag which can be provided to check whether a
|
|
120
|
+
* {@link UrlReaderService.readTree} response has changed from a previous execution.
|
|
121
|
+
*
|
|
122
|
+
* @remarks
|
|
123
|
+
*
|
|
124
|
+
* In the {@link UrlReaderService.readTree} response, an ETag is returned along with
|
|
125
|
+
* the tree blob. The ETag is a unique identifier of the tree blob, usually
|
|
126
|
+
* the commit SHA or ETag from the target.
|
|
127
|
+
*
|
|
128
|
+
* When an ETag is given as a request option, {@link UrlReaderService.readTree} will
|
|
129
|
+
* first compare the ETag against the ETag on the target branch. If they
|
|
130
|
+
* match, {@link UrlReaderService.readTree} will throw a
|
|
131
|
+
* {@link @backstage/errors#NotModifiedError} indicating that the response
|
|
132
|
+
* will not differ from the previous response which included this particular
|
|
133
|
+
* ETag. If they do not match, {@link UrlReaderService.readTree} will return the
|
|
134
|
+
* rest of the response along with a new ETag.
|
|
115
135
|
*/
|
|
116
|
-
|
|
136
|
+
etag?: string;
|
|
117
137
|
/**
|
|
118
|
-
*
|
|
138
|
+
* An abort signal to pass down to the underlying request.
|
|
139
|
+
*
|
|
140
|
+
* @remarks
|
|
141
|
+
*
|
|
142
|
+
* Not all reader implementations may take this field into account.
|
|
119
143
|
*/
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
144
|
+
signal?: AbortSignal;
|
|
145
|
+
};
|
|
123
146
|
/**
|
|
124
|
-
* Options
|
|
147
|
+
* Options that control {@link ReadTreeResponse.dir} execution.
|
|
125
148
|
*
|
|
126
149
|
* @public
|
|
127
150
|
*/
|
|
128
|
-
|
|
151
|
+
declare type ReadTreeResponseDirOptions = {
|
|
129
152
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
153
|
+
* The directory to write files to.
|
|
154
|
+
*
|
|
155
|
+
* @remarks
|
|
156
|
+
*
|
|
157
|
+
* Defaults to the OS tmpdir, or `backend.workingDirectory` if set in config.
|
|
133
158
|
*/
|
|
134
|
-
|
|
159
|
+
targetDir?: string;
|
|
135
160
|
};
|
|
136
|
-
|
|
137
161
|
/**
|
|
138
|
-
*
|
|
162
|
+
* A response object for {@link UrlReaderService.readTree} operations.
|
|
139
163
|
*
|
|
140
164
|
* @public
|
|
141
165
|
*/
|
|
142
|
-
|
|
166
|
+
declare type ReadTreeResponse = {
|
|
143
167
|
/**
|
|
144
|
-
*
|
|
145
|
-
*
|
|
168
|
+
* Returns an array of all the files inside the tree, and corresponding
|
|
169
|
+
* functions to read their content.
|
|
146
170
|
*/
|
|
147
|
-
|
|
171
|
+
files(): Promise<ReadTreeResponseFile[]>;
|
|
172
|
+
/**
|
|
173
|
+
* Returns the tree contents as a binary archive, using a stream.
|
|
174
|
+
*/
|
|
175
|
+
archive(): Promise<NodeJS.ReadableStream>;
|
|
176
|
+
/**
|
|
177
|
+
* Extracts the tree response into a directory and returns the path of the
|
|
178
|
+
* directory.
|
|
179
|
+
*
|
|
180
|
+
* **NOTE**: It is the responsibility of the caller to remove the directory after use.
|
|
181
|
+
*/
|
|
182
|
+
dir(options?: ReadTreeResponseDirOptions): Promise<string>;
|
|
183
|
+
/**
|
|
184
|
+
* Etag returned by content provider.
|
|
185
|
+
*
|
|
186
|
+
* @remarks
|
|
187
|
+
*
|
|
188
|
+
* Can be used to compare and cache responses when doing subsequent calls.
|
|
189
|
+
*/
|
|
190
|
+
etag: string;
|
|
148
191
|
};
|
|
149
|
-
|
|
150
192
|
/**
|
|
193
|
+
* Represents a single file in a {@link UrlReaderService.readTree} response.
|
|
194
|
+
*
|
|
151
195
|
* @public
|
|
152
196
|
*/
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
197
|
+
declare type ReadTreeResponseFile = {
|
|
198
|
+
path: string;
|
|
199
|
+
content(): Promise<Buffer>;
|
|
200
|
+
};
|
|
156
201
|
/**
|
|
157
|
-
*
|
|
202
|
+
* An options object for search operations.
|
|
158
203
|
*
|
|
159
204
|
* @public
|
|
160
205
|
*/
|
|
161
|
-
|
|
206
|
+
declare type SearchOptions = {
|
|
162
207
|
/**
|
|
163
|
-
*
|
|
208
|
+
* An etag can be provided to check whether the search response has changed from a previous execution.
|
|
164
209
|
*
|
|
165
|
-
*
|
|
166
|
-
|
|
167
|
-
const cache: ServiceRef<CacheService, "plugin">;
|
|
168
|
-
/**
|
|
169
|
-
* The service reference for the root scoped {@link ConfigService}.
|
|
210
|
+
* In the search() response, an etag is returned along with the files. The etag is a unique identifier
|
|
211
|
+
* of the current tree, usually the commit SHA or etag from the target.
|
|
170
212
|
*
|
|
171
|
-
*
|
|
213
|
+
* When an etag is given in SearchOptions, search will first compare the etag against the etag
|
|
214
|
+
* on the target branch. If they match, search will throw a NotModifiedError indicating that the search
|
|
215
|
+
* response will not differ from the previous response which included this particular etag. If they mismatch,
|
|
216
|
+
* search will return the rest of SearchResponse along with a new etag.
|
|
172
217
|
*/
|
|
173
|
-
|
|
218
|
+
etag?: string;
|
|
174
219
|
/**
|
|
175
|
-
*
|
|
220
|
+
* An abort signal to pass down to the underlying request.
|
|
176
221
|
*
|
|
177
|
-
* @
|
|
178
|
-
*/
|
|
179
|
-
const database: ServiceRef<DatabaseService, "plugin">;
|
|
180
|
-
/**
|
|
181
|
-
* The service reference for the plugin scoped {@link DiscoveryService}.
|
|
222
|
+
* @remarks
|
|
182
223
|
*
|
|
183
|
-
*
|
|
224
|
+
* Not all reader implementations may take this field into account.
|
|
184
225
|
*/
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
* The service reference for the plugin scoped {@link LifecycleService}.
|
|
194
|
-
*
|
|
195
|
-
* @public
|
|
196
|
-
*/
|
|
197
|
-
const lifecycle: ServiceRef<LifecycleService, "plugin">;
|
|
198
|
-
/**
|
|
199
|
-
* The service reference for the plugin scoped {@link LoggerService}.
|
|
200
|
-
*
|
|
201
|
-
* @public
|
|
202
|
-
*/
|
|
203
|
-
const logger: ServiceRef<LoggerService, "plugin">;
|
|
204
|
-
/**
|
|
205
|
-
* The service reference for the plugin scoped {@link PermissionsService}.
|
|
206
|
-
*
|
|
207
|
-
* @public
|
|
208
|
-
*/
|
|
209
|
-
const permissions: ServiceRef<PermissionsService, "plugin">;
|
|
210
|
-
/**
|
|
211
|
-
* The service reference for the plugin scoped {@link PluginMetadataService}.
|
|
212
|
-
*
|
|
213
|
-
* @public
|
|
214
|
-
*/
|
|
215
|
-
const pluginMetadata: ServiceRef<PluginMetadataService, "plugin">;
|
|
226
|
+
signal?: AbortSignal;
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* The output of a search operation.
|
|
230
|
+
*
|
|
231
|
+
* @public
|
|
232
|
+
*/
|
|
233
|
+
declare type SearchResponse = {
|
|
216
234
|
/**
|
|
217
|
-
* The
|
|
218
|
-
*
|
|
219
|
-
* @public
|
|
235
|
+
* The files that matched the search query.
|
|
220
236
|
*/
|
|
221
|
-
|
|
237
|
+
files: SearchResponseFile[];
|
|
222
238
|
/**
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
* @public
|
|
239
|
+
* A unique identifier of the current remote tree, usually the commit SHA or etag from the target.
|
|
226
240
|
*/
|
|
227
|
-
|
|
241
|
+
etag: string;
|
|
242
|
+
};
|
|
243
|
+
/**
|
|
244
|
+
* Represents a single file in a search response.
|
|
245
|
+
*
|
|
246
|
+
* @public
|
|
247
|
+
*/
|
|
248
|
+
declare type SearchResponseFile = {
|
|
228
249
|
/**
|
|
229
|
-
* The
|
|
230
|
-
*
|
|
231
|
-
* @public
|
|
250
|
+
* The full URL to the file.
|
|
232
251
|
*/
|
|
233
|
-
|
|
252
|
+
url: string;
|
|
234
253
|
/**
|
|
235
|
-
* The
|
|
236
|
-
*
|
|
237
|
-
* @public
|
|
254
|
+
* The binary contents of the file.
|
|
238
255
|
*/
|
|
239
|
-
|
|
256
|
+
content(): Promise<Buffer>;
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Interface for creating and validating tokens.
|
|
261
|
+
*
|
|
262
|
+
* @public
|
|
263
|
+
*/
|
|
264
|
+
interface TokenManagerService {
|
|
240
265
|
/**
|
|
241
|
-
*
|
|
266
|
+
* Fetches a valid token.
|
|
242
267
|
*
|
|
243
|
-
* @
|
|
244
|
-
*/
|
|
245
|
-
const tokenManager: ServiceRef<TokenManagerService, "plugin">;
|
|
246
|
-
/**
|
|
247
|
-
* The service reference for the plugin scoped {@link UrlReaderService}.
|
|
268
|
+
* @remarks
|
|
248
269
|
*
|
|
249
|
-
*
|
|
270
|
+
* Tokens are valid for roughly one hour; the actual deadline is set in the
|
|
271
|
+
* payload `exp` claim. Never hold on to tokens for reuse; always ask for a
|
|
272
|
+
* new one for each outgoing request. This ensures that you always get a
|
|
273
|
+
* valid, fresh one.
|
|
250
274
|
*/
|
|
251
|
-
|
|
275
|
+
getToken(): Promise<{
|
|
276
|
+
token: string;
|
|
277
|
+
}>;
|
|
252
278
|
/**
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
* @public
|
|
279
|
+
* Validates a given token.
|
|
256
280
|
*/
|
|
257
|
-
|
|
281
|
+
authenticate(token: string): Promise<void>;
|
|
258
282
|
}
|
|
259
283
|
|
|
260
|
-
/**
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
* @public
|
|
264
|
-
* @see {@link https://backstage.io/docs/backend-system/architecture/modules | The architecture of modules}
|
|
265
|
-
* @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}
|
|
266
|
-
*/
|
|
267
|
-
export declare function createBackendModule<TOptions extends [options?: object] = []>(config: BackendModuleConfig | ((...params: TOptions) => BackendModuleConfig)): (...params: TOptions) => BackendFeature;
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* Creates a new backend plugin.
|
|
271
|
-
*
|
|
272
|
-
* @public
|
|
273
|
-
* @see {@link https://backstage.io/docs/backend-system/architecture/plugins | The architecture of plugins}
|
|
274
|
-
* @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}
|
|
275
|
-
*/
|
|
276
|
-
export declare function createBackendPlugin<TOptions extends [options?: object] = []>(config: BackendPluginConfig | ((...params: TOptions) => BackendPluginConfig)): (...params: TOptions) => BackendFeature;
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Creates a new backend extension point.
|
|
280
|
-
*
|
|
281
|
-
* @public
|
|
282
|
-
* @see {@link https://backstage.io/docs/backend-system/architecture/extension-points | The architecture of extension points}
|
|
283
|
-
*/
|
|
284
|
-
export declare function createExtensionPoint<T>(config: ExtensionPointConfig): ExtensionPoint<T>;
|
|
284
|
+
/** @public */
|
|
285
|
+
interface SchedulerService extends PluginTaskScheduler {
|
|
286
|
+
}
|
|
285
287
|
|
|
286
288
|
/**
|
|
287
|
-
*
|
|
289
|
+
* A service that provides a logging facility.
|
|
288
290
|
*
|
|
289
291
|
* @public
|
|
290
|
-
* @param config - The service factory configuration.
|
|
291
292
|
*/
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
293
|
+
interface LoggerService {
|
|
294
|
+
error(message: string, meta?: Error | JsonObject): void;
|
|
295
|
+
warn(message: string, meta?: Error | JsonObject): void;
|
|
296
|
+
info(message: string, meta?: Error | JsonObject): void;
|
|
297
|
+
debug(message: string, meta?: Error | JsonObject): void;
|
|
298
|
+
child(meta: JsonObject): LoggerService;
|
|
299
|
+
}
|
|
295
300
|
|
|
296
|
-
/**
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
* @public
|
|
300
|
-
* @param config - The service factory configuration.
|
|
301
|
-
*/
|
|
302
|
-
export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
|
|
303
|
-
[name in string]: ServiceRef<unknown>;
|
|
304
|
-
}, TOpts extends object | undefined = undefined>(config: (options?: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>): (options?: TOpts) => ServiceFactory<TService, 'root'>;
|
|
301
|
+
/** @public */
|
|
302
|
+
interface RootLoggerService extends LoggerService {
|
|
303
|
+
}
|
|
305
304
|
|
|
306
305
|
/**
|
|
307
|
-
* Creates a root scoped service factory with required options.
|
|
308
|
-
*
|
|
309
306
|
* @public
|
|
310
|
-
* @param config - The service factory configuration.
|
|
311
307
|
*/
|
|
312
|
-
|
|
313
|
-
[name in string]: ServiceRef<unknown>;
|
|
314
|
-
}, TOpts extends object | undefined = undefined>(config: (options: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>): (options: TOpts) => ServiceFactory<TService, 'root'>;
|
|
315
|
-
|
|
308
|
+
declare type LifecycleServiceShutdownHook = () => void | Promise<void>;
|
|
316
309
|
/**
|
|
317
|
-
* Creates a plugin scoped service factory without options.
|
|
318
|
-
*
|
|
319
310
|
* @public
|
|
320
|
-
* @param config - The service factory configuration.
|
|
321
311
|
*/
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
312
|
+
interface LifecycleServiceShutdownOptions {
|
|
313
|
+
/**
|
|
314
|
+
* Optional {@link LoggerService} that will be used for logging instead of the default logger.
|
|
315
|
+
*/
|
|
316
|
+
logger?: LoggerService;
|
|
317
|
+
}
|
|
326
318
|
/**
|
|
327
|
-
* Creates a plugin scoped service factory with optional options.
|
|
328
|
-
*
|
|
329
319
|
* @public
|
|
330
|
-
* @param config - The service factory configuration.
|
|
331
320
|
*/
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
321
|
+
interface LifecycleService {
|
|
322
|
+
/**
|
|
323
|
+
* Register a function to be called when the backend is shutting down.
|
|
324
|
+
*/
|
|
325
|
+
addShutdownHook(hook: LifecycleServiceShutdownHook, options?: LifecycleServiceShutdownOptions): void;
|
|
326
|
+
}
|
|
335
327
|
|
|
336
|
-
/**
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
* @public
|
|
340
|
-
* @param config - The service factory configuration.
|
|
341
|
-
*/
|
|
342
|
-
export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
|
|
343
|
-
[name in string]: ServiceRef<unknown>;
|
|
344
|
-
}, TContext = undefined, TOpts extends object | undefined = undefined>(config: PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps> | ((options: TOpts) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>)): (options: TOpts) => ServiceFactory<TService, 'plugin'>;
|
|
328
|
+
/** @public */
|
|
329
|
+
interface RootLifecycleService extends LifecycleService {
|
|
330
|
+
}
|
|
345
331
|
|
|
346
332
|
/**
|
|
347
|
-
* Creates a new service definition. This overload is used to create plugin scoped services.
|
|
348
|
-
*
|
|
349
333
|
* @public
|
|
350
334
|
*/
|
|
351
|
-
|
|
335
|
+
interface RootHttpRouterService {
|
|
336
|
+
/**
|
|
337
|
+
* Registers a handler at the root of the backend router.
|
|
338
|
+
* The path is required and may not be empty.
|
|
339
|
+
*/
|
|
340
|
+
use(path: string, handler: Handler): void;
|
|
341
|
+
}
|
|
352
342
|
|
|
353
343
|
/**
|
|
354
|
-
* Creates a new service definition. This overload is used to create root scoped services.
|
|
355
|
-
*
|
|
356
344
|
* @public
|
|
357
345
|
*/
|
|
358
|
-
|
|
346
|
+
interface PluginMetadataService {
|
|
347
|
+
getId(): string;
|
|
348
|
+
}
|
|
359
349
|
|
|
360
|
-
/**
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
*
|
|
364
|
-
* @public
|
|
365
|
-
*/
|
|
366
|
-
export declare function createSharedEnvironment<TOptions extends [options?: object] = []>(config: SharedBackendEnvironmentConfig | ((...params: TOptions) => SharedBackendEnvironmentConfig)): (...options: TOptions) => SharedBackendEnvironment;
|
|
350
|
+
/** @public */
|
|
351
|
+
interface PermissionsService extends PermissionEvaluator {
|
|
352
|
+
}
|
|
367
353
|
|
|
368
354
|
/**
|
|
369
|
-
* The DatabaseService manages access to databases that Plugins get.
|
|
370
|
-
*
|
|
371
355
|
* @public
|
|
372
356
|
*/
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
* getClient provides backend plugins database connections for itself.
|
|
376
|
-
*
|
|
377
|
-
* The purpose of this method is to allow plugins to get isolated data
|
|
378
|
-
* stores so that plugins are discouraged from database integration.
|
|
379
|
-
*/
|
|
380
|
-
getClient(): Promise<Knex>;
|
|
381
|
-
/**
|
|
382
|
-
* This property is used to control the behavior of database migrations.
|
|
383
|
-
*/
|
|
384
|
-
migrations?: {
|
|
385
|
-
/**
|
|
386
|
-
* skip database migrations. Useful if connecting to a read-only database.
|
|
387
|
-
*
|
|
388
|
-
* @defaultValue false
|
|
389
|
-
*/
|
|
390
|
-
skip?: boolean;
|
|
391
|
-
};
|
|
357
|
+
interface HttpRouterService {
|
|
358
|
+
use(handler: Handler): void;
|
|
392
359
|
}
|
|
393
360
|
|
|
394
361
|
/**
|
|
@@ -405,7 +372,7 @@ export declare interface DatabaseService {
|
|
|
405
372
|
*
|
|
406
373
|
* @public
|
|
407
374
|
*/
|
|
408
|
-
|
|
375
|
+
interface DiscoveryService {
|
|
409
376
|
/**
|
|
410
377
|
* Returns the internal HTTP base URL for a given plugin, without a trailing slash.
|
|
411
378
|
*
|
|
@@ -439,99 +406,107 @@ export declare interface DiscoveryService {
|
|
|
439
406
|
}
|
|
440
407
|
|
|
441
408
|
/**
|
|
442
|
-
*
|
|
409
|
+
* The DatabaseService manages access to databases that Plugins get.
|
|
443
410
|
*
|
|
444
411
|
* @public
|
|
445
412
|
*/
|
|
446
|
-
|
|
447
|
-
id: string;
|
|
413
|
+
interface DatabaseService {
|
|
448
414
|
/**
|
|
449
|
-
*
|
|
450
|
-
*
|
|
415
|
+
* getClient provides backend plugins database connections for itself.
|
|
416
|
+
*
|
|
417
|
+
* The purpose of this method is to allow plugins to get isolated data
|
|
418
|
+
* stores so that plugins are discouraged from database integration.
|
|
451
419
|
*/
|
|
452
|
-
|
|
453
|
-
toString(): string;
|
|
454
|
-
$$type: '@backstage/ExtensionPoint';
|
|
455
|
-
};
|
|
456
|
-
|
|
457
|
-
/**
|
|
458
|
-
* The configuration options passed to {@link createExtensionPoint}.
|
|
459
|
-
*
|
|
460
|
-
* @public
|
|
461
|
-
* @see {@link https://backstage.io/docs/backend-system/architecture/extension-points | The architecture of extension points}
|
|
462
|
-
* @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}
|
|
463
|
-
*/
|
|
464
|
-
export declare interface ExtensionPointConfig {
|
|
420
|
+
getClient(): Promise<Knex>;
|
|
465
421
|
/**
|
|
466
|
-
*
|
|
467
|
-
*
|
|
468
|
-
* @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}
|
|
422
|
+
* This property is used to control the behavior of database migrations.
|
|
469
423
|
*/
|
|
470
|
-
|
|
424
|
+
migrations?: {
|
|
425
|
+
/**
|
|
426
|
+
* skip database migrations. Useful if connecting to a read-only database.
|
|
427
|
+
*
|
|
428
|
+
* @defaultValue false
|
|
429
|
+
*/
|
|
430
|
+
skip?: boolean;
|
|
431
|
+
};
|
|
471
432
|
}
|
|
472
433
|
|
|
473
434
|
/**
|
|
474
435
|
* @public
|
|
475
436
|
*/
|
|
476
|
-
|
|
477
|
-
use(handler: Handler): void;
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
/** @public */
|
|
481
|
-
export declare interface IdentityService extends IdentityApi {
|
|
437
|
+
interface ConfigService extends Config {
|
|
482
438
|
}
|
|
483
439
|
|
|
484
440
|
/**
|
|
441
|
+
* TODO
|
|
442
|
+
*
|
|
485
443
|
* @public
|
|
486
444
|
*/
|
|
487
|
-
|
|
445
|
+
declare type ServiceRef<TService, TScope extends 'root' | 'plugin' = 'root' | 'plugin'> = {
|
|
446
|
+
id: string;
|
|
488
447
|
/**
|
|
489
|
-
*
|
|
448
|
+
* This determines the scope at which this service is available.
|
|
449
|
+
*
|
|
450
|
+
* Root scoped services are available to all other services but
|
|
451
|
+
* may only depend on other root scoped services.
|
|
452
|
+
*
|
|
453
|
+
* Plugin scoped services are only available to other plugin scoped
|
|
454
|
+
* services but may depend on all other services.
|
|
490
455
|
*/
|
|
491
|
-
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
/**
|
|
495
|
-
* @public
|
|
496
|
-
*/
|
|
497
|
-
export declare type LifecycleServiceShutdownHook = () => void | Promise<void>;
|
|
498
|
-
|
|
499
|
-
/**
|
|
500
|
-
* @public
|
|
501
|
-
*/
|
|
502
|
-
export declare interface LifecycleServiceShutdownOptions {
|
|
456
|
+
scope: TScope;
|
|
503
457
|
/**
|
|
504
|
-
*
|
|
458
|
+
* Utility for getting the type of the service, using `typeof serviceRef.T`.
|
|
459
|
+
* Attempting to actually read this value will result in an exception.
|
|
505
460
|
*/
|
|
506
|
-
|
|
461
|
+
T: TService;
|
|
462
|
+
toString(): string;
|
|
463
|
+
$$type: '@backstage/ServiceRef';
|
|
464
|
+
};
|
|
465
|
+
/** @public */
|
|
466
|
+
interface ServiceFactory<TService = unknown, TScope extends 'plugin' | 'root' = 'plugin' | 'root'> {
|
|
467
|
+
$$type: '@backstage/ServiceFactory';
|
|
468
|
+
service: ServiceRef<TService, TScope>;
|
|
507
469
|
}
|
|
508
|
-
|
|
509
470
|
/**
|
|
510
|
-
*
|
|
471
|
+
* Represents either a {@link ServiceFactory} or a function that returns one.
|
|
511
472
|
*
|
|
512
473
|
* @public
|
|
513
474
|
*/
|
|
514
|
-
|
|
515
|
-
error(message: string, meta?: Error | JsonObject): void;
|
|
516
|
-
warn(message: string, meta?: Error | JsonObject): void;
|
|
517
|
-
info(message: string, meta?: Error | JsonObject): void;
|
|
518
|
-
debug(message: string, meta?: Error | JsonObject): void;
|
|
519
|
-
child(meta: JsonObject): LoggerService;
|
|
520
|
-
}
|
|
521
|
-
|
|
475
|
+
declare type ServiceFactoryOrFunction = ServiceFactory | (() => ServiceFactory);
|
|
522
476
|
/** @public */
|
|
523
|
-
|
|
477
|
+
interface ServiceRefConfig<TService, TScope extends 'root' | 'plugin'> {
|
|
478
|
+
id: string;
|
|
479
|
+
scope?: TScope;
|
|
480
|
+
defaultFactory?: (service: ServiceRef<TService, TScope>) => Promise<ServiceFactoryOrFunction>;
|
|
524
481
|
}
|
|
525
|
-
|
|
526
482
|
/**
|
|
483
|
+
* Creates a new service definition. This overload is used to create plugin scoped services.
|
|
484
|
+
*
|
|
527
485
|
* @public
|
|
528
486
|
*/
|
|
529
|
-
|
|
530
|
-
|
|
487
|
+
declare function createServiceRef<TService>(config: ServiceRefConfig<TService, 'plugin'>): ServiceRef<TService, 'plugin'>;
|
|
488
|
+
/**
|
|
489
|
+
* Creates a new service definition. This overload is used to create root scoped services.
|
|
490
|
+
*
|
|
491
|
+
* @public
|
|
492
|
+
*/
|
|
493
|
+
declare function createServiceRef<TService>(config: ServiceRefConfig<TService, 'root'>): ServiceRef<TService, 'root'>;
|
|
494
|
+
/** @ignore */
|
|
495
|
+
declare type ServiceRefsToInstances<T extends {
|
|
496
|
+
[key in string]: ServiceRef<unknown>;
|
|
497
|
+
}, TScope extends 'root' | 'plugin' = 'root' | 'plugin'> = {
|
|
498
|
+
[key in keyof T as T[key]['scope'] extends TScope ? key : never]: T[key]['T'];
|
|
499
|
+
};
|
|
500
|
+
/** @public */
|
|
501
|
+
interface RootServiceFactoryConfig<TService, TImpl extends TService, TDeps extends {
|
|
502
|
+
[name in string]: ServiceRef<unknown>;
|
|
503
|
+
}> {
|
|
504
|
+
service: ServiceRef<TService, 'root'>;
|
|
505
|
+
deps: TDeps;
|
|
506
|
+
factory(deps: ServiceRefsToInstances<TDeps, 'root'>): TImpl | Promise<TImpl>;
|
|
531
507
|
}
|
|
532
|
-
|
|
533
508
|
/** @public */
|
|
534
|
-
|
|
509
|
+
interface PluginServiceFactoryConfig<TService, TContext, TImpl extends TService, TDeps extends {
|
|
535
510
|
[name in string]: ServiceRef<unknown>;
|
|
536
511
|
}> {
|
|
537
512
|
service: ServiceRef<TService, 'plugin'>;
|
|
@@ -539,386 +514,366 @@ export declare interface PluginServiceFactoryConfig<TService, TContext, TImpl ex
|
|
|
539
514
|
createRootContext?(deps: ServiceRefsToInstances<TDeps, 'root'>): TContext | Promise<TContext>;
|
|
540
515
|
factory(deps: ServiceRefsToInstances<TDeps>, context: TContext): TImpl | Promise<TImpl>;
|
|
541
516
|
}
|
|
517
|
+
/**
|
|
518
|
+
* Creates a root scoped service factory without options.
|
|
519
|
+
*
|
|
520
|
+
* @public
|
|
521
|
+
* @param config - The service factory configuration.
|
|
522
|
+
*/
|
|
523
|
+
declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
|
|
524
|
+
[name in string]: ServiceRef<unknown>;
|
|
525
|
+
}, TOpts extends object | undefined = undefined>(config: RootServiceFactoryConfig<TService, TImpl, TDeps>): () => ServiceFactory<TService, 'root'>;
|
|
526
|
+
/**
|
|
527
|
+
* Creates a root scoped service factory with optional options.
|
|
528
|
+
*
|
|
529
|
+
* @public
|
|
530
|
+
* @param config - The service factory configuration.
|
|
531
|
+
*/
|
|
532
|
+
declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
|
|
533
|
+
[name in string]: ServiceRef<unknown>;
|
|
534
|
+
}, TOpts extends object | undefined = undefined>(config: (options?: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>): (options?: TOpts) => ServiceFactory<TService, 'root'>;
|
|
535
|
+
/**
|
|
536
|
+
* Creates a root scoped service factory with required options.
|
|
537
|
+
*
|
|
538
|
+
* @public
|
|
539
|
+
* @param config - The service factory configuration.
|
|
540
|
+
*/
|
|
541
|
+
declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
|
|
542
|
+
[name in string]: ServiceRef<unknown>;
|
|
543
|
+
}, TOpts extends object | undefined = undefined>(config: (options: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>): (options: TOpts) => ServiceFactory<TService, 'root'>;
|
|
544
|
+
/**
|
|
545
|
+
* Creates a plugin scoped service factory without options.
|
|
546
|
+
*
|
|
547
|
+
* @public
|
|
548
|
+
* @param config - The service factory configuration.
|
|
549
|
+
*/
|
|
550
|
+
declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
|
|
551
|
+
[name in string]: ServiceRef<unknown>;
|
|
552
|
+
}, TContext = undefined, TOpts extends object | undefined = undefined>(config: PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>): () => ServiceFactory<TService, 'plugin'>;
|
|
553
|
+
/**
|
|
554
|
+
* Creates a plugin scoped service factory with optional options.
|
|
555
|
+
*
|
|
556
|
+
* @public
|
|
557
|
+
* @param config - The service factory configuration.
|
|
558
|
+
*/
|
|
559
|
+
declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
|
|
560
|
+
[name in string]: ServiceRef<unknown>;
|
|
561
|
+
}, TContext = undefined, TOpts extends object | undefined = undefined>(config: (options?: TOpts) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>): (options?: TOpts) => ServiceFactory<TService, 'plugin'>;
|
|
562
|
+
/**
|
|
563
|
+
* Creates a plugin scoped service factory with required options.
|
|
564
|
+
*
|
|
565
|
+
* @public
|
|
566
|
+
* @param config - The service factory configuration.
|
|
567
|
+
*/
|
|
568
|
+
declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
|
|
569
|
+
[name in string]: ServiceRef<unknown>;
|
|
570
|
+
}, TContext = undefined, TOpts extends object | undefined = undefined>(config: PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps> | ((options: TOpts) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>)): (options: TOpts) => ServiceFactory<TService, 'plugin'>;
|
|
542
571
|
|
|
543
572
|
/**
|
|
544
|
-
*
|
|
573
|
+
* Options passed to {@link CacheService.set}.
|
|
545
574
|
*
|
|
546
575
|
* @public
|
|
547
576
|
*/
|
|
548
|
-
|
|
577
|
+
declare type CacheServiceSetOptions = {
|
|
549
578
|
/**
|
|
550
|
-
*
|
|
551
|
-
*
|
|
552
|
-
* @remarks
|
|
553
|
-
*
|
|
554
|
-
* The path passed to the filter function is the relative path from the URL
|
|
555
|
-
* that the file tree is fetched from, without any leading '/'.
|
|
556
|
-
*
|
|
557
|
-
* For example, given the URL https://github.com/my/repo/tree/master/my-dir, a file
|
|
558
|
-
* at https://github.com/my/repo/blob/master/my-dir/my-subdir/my-file.txt will
|
|
559
|
-
* be represented as my-subdir/my-file.txt
|
|
560
|
-
*
|
|
561
|
-
* If no filter is provided, all files are extracted.
|
|
562
|
-
*/
|
|
563
|
-
filter?(path: string, info?: {
|
|
564
|
-
size: number;
|
|
565
|
-
}): boolean;
|
|
566
|
-
/**
|
|
567
|
-
* An ETag which can be provided to check whether a
|
|
568
|
-
* {@link UrlReaderService.readTree} response has changed from a previous execution.
|
|
569
|
-
*
|
|
570
|
-
* @remarks
|
|
571
|
-
*
|
|
572
|
-
* In the {@link UrlReaderService.readTree} response, an ETag is returned along with
|
|
573
|
-
* the tree blob. The ETag is a unique identifier of the tree blob, usually
|
|
574
|
-
* the commit SHA or ETag from the target.
|
|
575
|
-
*
|
|
576
|
-
* When an ETag is given as a request option, {@link UrlReaderService.readTree} will
|
|
577
|
-
* first compare the ETag against the ETag on the target branch. If they
|
|
578
|
-
* match, {@link UrlReaderService.readTree} will throw a
|
|
579
|
-
* {@link @backstage/errors#NotModifiedError} indicating that the response
|
|
580
|
-
* will not differ from the previous response which included this particular
|
|
581
|
-
* ETag. If they do not match, {@link UrlReaderService.readTree} will return the
|
|
582
|
-
* rest of the response along with a new ETag.
|
|
579
|
+
* Optional TTL in milliseconds. Defaults to the TTL provided when the client
|
|
580
|
+
* was set up (or no TTL if none are provided).
|
|
583
581
|
*/
|
|
584
|
-
|
|
582
|
+
ttl?: number;
|
|
583
|
+
};
|
|
584
|
+
/**
|
|
585
|
+
* Options passed to {@link CacheService.withOptions}.
|
|
586
|
+
*
|
|
587
|
+
* @public
|
|
588
|
+
*/
|
|
589
|
+
declare type CacheServiceOptions = {
|
|
585
590
|
/**
|
|
586
|
-
* An
|
|
587
|
-
*
|
|
588
|
-
*
|
|
589
|
-
*
|
|
590
|
-
* Not all reader implementations may take this field into account.
|
|
591
|
+
* An optional default TTL (in milliseconds) to be set when getting a client
|
|
592
|
+
* instance. If not provided, data will persist indefinitely by default (or
|
|
593
|
+
* can be configured per entry at set-time).
|
|
591
594
|
*/
|
|
592
|
-
|
|
595
|
+
defaultTtl?: number;
|
|
593
596
|
};
|
|
594
|
-
|
|
595
597
|
/**
|
|
596
|
-
* A
|
|
598
|
+
* A pre-configured, storage agnostic cache service suitable for use by
|
|
599
|
+
* Backstage plugins.
|
|
597
600
|
*
|
|
598
601
|
* @public
|
|
599
602
|
*/
|
|
600
|
-
|
|
603
|
+
interface CacheService {
|
|
601
604
|
/**
|
|
602
|
-
*
|
|
603
|
-
*
|
|
605
|
+
* Reads data from a cache store for the given key. If no data was found,
|
|
606
|
+
* returns undefined.
|
|
604
607
|
*/
|
|
605
|
-
|
|
608
|
+
get<TValue extends JsonValue>(key: string): Promise<TValue | undefined>;
|
|
606
609
|
/**
|
|
607
|
-
*
|
|
610
|
+
* Writes the given data to a cache store, associated with the given key. An
|
|
611
|
+
* optional TTL may also be provided, otherwise it defaults to the TTL that
|
|
612
|
+
* was provided when the client was instantiated.
|
|
608
613
|
*/
|
|
609
|
-
|
|
614
|
+
set(key: string, value: JsonValue, options?: CacheServiceSetOptions): Promise<void>;
|
|
610
615
|
/**
|
|
611
|
-
*
|
|
612
|
-
* directory.
|
|
613
|
-
*
|
|
614
|
-
* **NOTE**: It is the responsibility of the caller to remove the directory after use.
|
|
616
|
+
* Removes the given key from the cache store.
|
|
615
617
|
*/
|
|
616
|
-
|
|
618
|
+
delete(key: string): Promise<void>;
|
|
617
619
|
/**
|
|
618
|
-
*
|
|
619
|
-
*
|
|
620
|
-
* @remarks
|
|
621
|
-
*
|
|
622
|
-
* Can be used to compare and cache responses when doing subsequent calls.
|
|
620
|
+
* Creates a new {@link CacheService} instance with the given options.
|
|
623
621
|
*/
|
|
624
|
-
|
|
625
|
-
}
|
|
622
|
+
withOptions(options: CacheServiceOptions): CacheService;
|
|
623
|
+
}
|
|
626
624
|
|
|
627
625
|
/**
|
|
628
|
-
*
|
|
626
|
+
* All core services references
|
|
629
627
|
*
|
|
630
628
|
* @public
|
|
631
629
|
*/
|
|
632
|
-
|
|
630
|
+
declare namespace coreServices {
|
|
633
631
|
/**
|
|
634
|
-
* The
|
|
635
|
-
*
|
|
636
|
-
* @remarks
|
|
632
|
+
* The service reference for the plugin scoped {@link CacheService}.
|
|
637
633
|
*
|
|
638
|
-
*
|
|
634
|
+
* @public
|
|
639
635
|
*/
|
|
640
|
-
|
|
641
|
-
};
|
|
642
|
-
|
|
643
|
-
/**
|
|
644
|
-
* Represents a single file in a {@link UrlReaderService.readTree} response.
|
|
645
|
-
*
|
|
646
|
-
* @public
|
|
647
|
-
*/
|
|
648
|
-
export declare type ReadTreeResponseFile = {
|
|
649
|
-
path: string;
|
|
650
|
-
content(): Promise<Buffer>;
|
|
651
|
-
};
|
|
652
|
-
|
|
653
|
-
/**
|
|
654
|
-
* An options object for readUrl operations.
|
|
655
|
-
*
|
|
656
|
-
* @public
|
|
657
|
-
*/
|
|
658
|
-
export declare type ReadUrlOptions = {
|
|
636
|
+
const cache: ServiceRef<CacheService, "plugin">;
|
|
659
637
|
/**
|
|
660
|
-
*
|
|
661
|
-
* {@link UrlReaderService.readUrl} response has changed from a previous execution.
|
|
638
|
+
* The service reference for the root scoped {@link ConfigService}.
|
|
662
639
|
*
|
|
663
|
-
* @
|
|
640
|
+
* @public
|
|
641
|
+
*/
|
|
642
|
+
const config: ServiceRef<ConfigService, "root">;
|
|
643
|
+
/**
|
|
644
|
+
* The service reference for the plugin scoped {@link DatabaseService}.
|
|
664
645
|
*
|
|
665
|
-
*
|
|
666
|
-
|
|
667
|
-
|
|
646
|
+
* @public
|
|
647
|
+
*/
|
|
648
|
+
const database: ServiceRef<DatabaseService, "plugin">;
|
|
649
|
+
/**
|
|
650
|
+
* The service reference for the plugin scoped {@link DiscoveryService}.
|
|
668
651
|
*
|
|
669
|
-
*
|
|
670
|
-
* first compare the ETag against the ETag of the target. If they match,
|
|
671
|
-
* {@link UrlReaderService.readUrl} will throw a
|
|
672
|
-
* {@link @backstage/errors#NotModifiedError} indicating that the response
|
|
673
|
-
* will not differ from the previous response which included this particular
|
|
674
|
-
* ETag. If they do not match, {@link UrlReaderService.readUrl} will return the rest
|
|
675
|
-
* of the response along with a new ETag.
|
|
652
|
+
* @public
|
|
676
653
|
*/
|
|
677
|
-
|
|
654
|
+
const discovery: ServiceRef<DiscoveryService, "plugin">;
|
|
678
655
|
/**
|
|
679
|
-
*
|
|
656
|
+
* The service reference for the plugin scoped {@link HttpRouterService}.
|
|
680
657
|
*
|
|
681
|
-
* @
|
|
658
|
+
* @public
|
|
659
|
+
*/
|
|
660
|
+
const httpRouter: ServiceRef<HttpRouterService, "plugin">;
|
|
661
|
+
/**
|
|
662
|
+
* The service reference for the plugin scoped {@link LifecycleService}.
|
|
682
663
|
*
|
|
683
|
-
*
|
|
664
|
+
* @public
|
|
684
665
|
*/
|
|
685
|
-
|
|
686
|
-
};
|
|
687
|
-
|
|
688
|
-
/**
|
|
689
|
-
* A response object for {@link UrlReaderService.readUrl} operations.
|
|
690
|
-
*
|
|
691
|
-
* @public
|
|
692
|
-
*/
|
|
693
|
-
export declare type ReadUrlResponse = {
|
|
666
|
+
const lifecycle: ServiceRef<LifecycleService, "plugin">;
|
|
694
667
|
/**
|
|
695
|
-
*
|
|
668
|
+
* The service reference for the plugin scoped {@link LoggerService}.
|
|
669
|
+
*
|
|
670
|
+
* @public
|
|
696
671
|
*/
|
|
697
|
-
|
|
672
|
+
const logger: ServiceRef<LoggerService, "plugin">;
|
|
698
673
|
/**
|
|
699
|
-
*
|
|
674
|
+
* The service reference for the plugin scoped {@link PermissionsService}.
|
|
700
675
|
*
|
|
701
|
-
* @
|
|
676
|
+
* @public
|
|
677
|
+
*/
|
|
678
|
+
const permissions: ServiceRef<PermissionsService, "plugin">;
|
|
679
|
+
/**
|
|
680
|
+
* The service reference for the plugin scoped {@link PluginMetadataService}.
|
|
702
681
|
*
|
|
703
|
-
*
|
|
682
|
+
* @public
|
|
704
683
|
*/
|
|
705
|
-
|
|
684
|
+
const pluginMetadata: ServiceRef<PluginMetadataService, "plugin">;
|
|
706
685
|
/**
|
|
707
|
-
*
|
|
686
|
+
* The service reference for the root scoped {@link RootHttpRouterService}.
|
|
708
687
|
*
|
|
709
|
-
* @
|
|
688
|
+
* @public
|
|
689
|
+
*/
|
|
690
|
+
const rootHttpRouter: ServiceRef<RootHttpRouterService, "root">;
|
|
691
|
+
/**
|
|
692
|
+
* The service reference for the root scoped {@link RootLifecycleService}.
|
|
710
693
|
*
|
|
711
|
-
*
|
|
694
|
+
* @public
|
|
712
695
|
*/
|
|
713
|
-
|
|
714
|
-
};
|
|
715
|
-
|
|
716
|
-
/**
|
|
717
|
-
* @public
|
|
718
|
-
*/
|
|
719
|
-
export declare interface RootHttpRouterService {
|
|
696
|
+
const rootLifecycle: ServiceRef<RootLifecycleService, "root">;
|
|
720
697
|
/**
|
|
721
|
-
*
|
|
722
|
-
*
|
|
698
|
+
* The service reference for the root scoped {@link RootLoggerService}.
|
|
699
|
+
*
|
|
700
|
+
* @public
|
|
723
701
|
*/
|
|
724
|
-
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
/** @public */
|
|
728
|
-
export declare interface RootLifecycleService extends LifecycleService {
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
/** @public */
|
|
732
|
-
export declare interface RootLoggerService extends LoggerService {
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
/** @public */
|
|
736
|
-
export declare interface RootServiceFactoryConfig<TService, TImpl extends TService, TDeps extends {
|
|
737
|
-
[name in string]: ServiceRef<unknown>;
|
|
738
|
-
}> {
|
|
739
|
-
service: ServiceRef<TService, 'root'>;
|
|
740
|
-
deps: TDeps;
|
|
741
|
-
factory(deps: ServiceRefsToInstances<TDeps, 'root'>): TImpl | Promise<TImpl>;
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
/** @public */
|
|
745
|
-
export declare interface SchedulerService extends PluginTaskScheduler {
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
/**
|
|
749
|
-
* An options object for search operations.
|
|
750
|
-
*
|
|
751
|
-
* @public
|
|
752
|
-
*/
|
|
753
|
-
export declare type SearchOptions = {
|
|
702
|
+
const rootLogger: ServiceRef<RootLoggerService, "root">;
|
|
754
703
|
/**
|
|
755
|
-
*
|
|
704
|
+
* The service reference for the plugin scoped {@link SchedulerService}.
|
|
756
705
|
*
|
|
757
|
-
*
|
|
758
|
-
|
|
706
|
+
* @public
|
|
707
|
+
*/
|
|
708
|
+
const scheduler: ServiceRef<SchedulerService, "plugin">;
|
|
709
|
+
/**
|
|
710
|
+
* The service reference for the plugin scoped {@link TokenManagerService}.
|
|
759
711
|
*
|
|
760
|
-
*
|
|
761
|
-
* on the target branch. If they match, search will throw a NotModifiedError indicating that the search
|
|
762
|
-
* response will not differ from the previous response which included this particular etag. If they mismatch,
|
|
763
|
-
* search will return the rest of SearchResponse along with a new etag.
|
|
712
|
+
* @public
|
|
764
713
|
*/
|
|
765
|
-
|
|
714
|
+
const tokenManager: ServiceRef<TokenManagerService, "plugin">;
|
|
766
715
|
/**
|
|
767
|
-
*
|
|
716
|
+
* The service reference for the plugin scoped {@link UrlReaderService}.
|
|
768
717
|
*
|
|
769
|
-
* @
|
|
718
|
+
* @public
|
|
719
|
+
*/
|
|
720
|
+
const urlReader: ServiceRef<UrlReaderService, "plugin">;
|
|
721
|
+
/**
|
|
722
|
+
* The service reference for the plugin scoped {@link IdentityService}.
|
|
770
723
|
*
|
|
771
|
-
*
|
|
724
|
+
* @public
|
|
772
725
|
*/
|
|
773
|
-
|
|
774
|
-
}
|
|
726
|
+
const identity: ServiceRef<IdentityService, "plugin">;
|
|
727
|
+
}
|
|
775
728
|
|
|
776
729
|
/**
|
|
777
|
-
* The
|
|
730
|
+
* The configuration options passed to {@link createSharedEnvironment}.
|
|
778
731
|
*
|
|
779
732
|
* @public
|
|
780
733
|
*/
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
*/
|
|
785
|
-
files: SearchResponseFile[];
|
|
786
|
-
/**
|
|
787
|
-
* A unique identifier of the current remote tree, usually the commit SHA or etag from the target.
|
|
788
|
-
*/
|
|
789
|
-
etag: string;
|
|
790
|
-
};
|
|
791
|
-
|
|
734
|
+
interface SharedBackendEnvironmentConfig {
|
|
735
|
+
services?: ServiceFactoryOrFunction[];
|
|
736
|
+
}
|
|
792
737
|
/**
|
|
793
|
-
*
|
|
738
|
+
* An opaque type that represents the contents of a shared backend environment.
|
|
794
739
|
*
|
|
795
740
|
* @public
|
|
796
741
|
*/
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
* The full URL to the file.
|
|
800
|
-
*/
|
|
801
|
-
url: string;
|
|
802
|
-
/**
|
|
803
|
-
* The binary contents of the file.
|
|
804
|
-
*/
|
|
805
|
-
content(): Promise<Buffer>;
|
|
806
|
-
};
|
|
807
|
-
|
|
808
|
-
/** @public */
|
|
809
|
-
export declare interface ServiceFactory<TService = unknown, TScope extends 'plugin' | 'root' = 'plugin' | 'root'> {
|
|
810
|
-
$$type: '@backstage/ServiceFactory';
|
|
811
|
-
service: ServiceRef<TService, TScope>;
|
|
742
|
+
interface SharedBackendEnvironment {
|
|
743
|
+
$$type: '@backstage/SharedBackendEnvironment';
|
|
812
744
|
}
|
|
813
|
-
|
|
814
745
|
/**
|
|
815
|
-
*
|
|
746
|
+
* Creates a shared backend environment which can be used to create multiple
|
|
747
|
+
* backends.
|
|
816
748
|
*
|
|
817
749
|
* @public
|
|
818
750
|
*/
|
|
819
|
-
|
|
751
|
+
declare function createSharedEnvironment<TOptions extends [options?: object] = []>(config: SharedBackendEnvironmentConfig | ((...params: TOptions) => SharedBackendEnvironmentConfig)): (...options: TOptions) => SharedBackendEnvironment;
|
|
820
752
|
|
|
821
753
|
/**
|
|
822
754
|
* TODO
|
|
823
755
|
*
|
|
824
756
|
* @public
|
|
825
757
|
*/
|
|
826
|
-
|
|
758
|
+
declare type ExtensionPoint<T> = {
|
|
827
759
|
id: string;
|
|
828
760
|
/**
|
|
829
|
-
*
|
|
830
|
-
*
|
|
831
|
-
* Root scoped services are available to all other services but
|
|
832
|
-
* may only depend on other root scoped services.
|
|
833
|
-
*
|
|
834
|
-
* Plugin scoped services are only available to other plugin scoped
|
|
835
|
-
* services but may depend on all other services.
|
|
836
|
-
*/
|
|
837
|
-
scope: TScope;
|
|
838
|
-
/**
|
|
839
|
-
* Utility for getting the type of the service, using `typeof serviceRef.T`.
|
|
761
|
+
* Utility for getting the type of the extension point, using `typeof extensionPoint.T`.
|
|
840
762
|
* Attempting to actually read this value will result in an exception.
|
|
841
763
|
*/
|
|
842
|
-
T:
|
|
764
|
+
T: T;
|
|
843
765
|
toString(): string;
|
|
844
|
-
$$type: '@backstage/
|
|
845
|
-
};
|
|
846
|
-
|
|
847
|
-
/** @public */
|
|
848
|
-
export declare interface ServiceRefConfig<TService, TScope extends 'root' | 'plugin'> {
|
|
849
|
-
id: string;
|
|
850
|
-
scope?: TScope;
|
|
851
|
-
defaultFactory?: (service: ServiceRef<TService, TScope>) => Promise<ServiceFactoryOrFunction>;
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
/** @ignore */
|
|
855
|
-
declare type ServiceRefsToInstances<T extends {
|
|
856
|
-
[key in string]: ServiceRef<unknown>;
|
|
857
|
-
}, TScope extends 'root' | 'plugin' = 'root' | 'plugin'> = {
|
|
858
|
-
[key in keyof T as T[key]['scope'] extends TScope ? key : never]: T[key]['T'];
|
|
766
|
+
$$type: '@backstage/ExtensionPoint';
|
|
859
767
|
};
|
|
860
|
-
|
|
861
768
|
/**
|
|
862
|
-
*
|
|
769
|
+
* The callbacks passed to the `register` method of a backend plugin.
|
|
863
770
|
*
|
|
864
771
|
* @public
|
|
865
772
|
*/
|
|
866
|
-
|
|
867
|
-
|
|
773
|
+
interface BackendPluginRegistrationPoints {
|
|
774
|
+
registerExtensionPoint<TExtensionPoint>(ref: ExtensionPoint<TExtensionPoint>, impl: TExtensionPoint): void;
|
|
775
|
+
registerInit<Deps extends {
|
|
776
|
+
[name in string]: unknown;
|
|
777
|
+
}>(options: {
|
|
778
|
+
deps: {
|
|
779
|
+
[name in keyof Deps]: ServiceRef<Deps[name]>;
|
|
780
|
+
};
|
|
781
|
+
init(deps: Deps): Promise<void>;
|
|
782
|
+
}): void;
|
|
868
783
|
}
|
|
869
|
-
|
|
870
784
|
/**
|
|
871
|
-
* The
|
|
785
|
+
* The callbacks passed to the `register` method of a backend module.
|
|
872
786
|
*
|
|
873
787
|
* @public
|
|
874
788
|
*/
|
|
875
|
-
|
|
876
|
-
|
|
789
|
+
interface BackendModuleRegistrationPoints {
|
|
790
|
+
registerInit<Deps extends {
|
|
791
|
+
[name in string]: unknown;
|
|
792
|
+
}>(options: {
|
|
793
|
+
deps: {
|
|
794
|
+
[name in keyof Deps]: ServiceRef<Deps[name]> | ExtensionPoint<Deps[name]>;
|
|
795
|
+
};
|
|
796
|
+
init(deps: Deps): Promise<void>;
|
|
797
|
+
}): void;
|
|
798
|
+
}
|
|
799
|
+
/** @public */
|
|
800
|
+
interface BackendFeature {
|
|
801
|
+
$$type: '@backstage/BackendFeature';
|
|
877
802
|
}
|
|
878
803
|
|
|
879
804
|
/**
|
|
880
|
-
*
|
|
805
|
+
* The configuration options passed to {@link createExtensionPoint}.
|
|
881
806
|
*
|
|
882
807
|
* @public
|
|
808
|
+
* @see {@link https://backstage.io/docs/backend-system/architecture/extension-points | The architecture of extension points}
|
|
809
|
+
* @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}
|
|
883
810
|
*/
|
|
884
|
-
|
|
811
|
+
interface ExtensionPointConfig {
|
|
885
812
|
/**
|
|
886
|
-
*
|
|
887
|
-
*
|
|
888
|
-
* @remarks
|
|
813
|
+
* The ID of this extension point.
|
|
889
814
|
*
|
|
890
|
-
*
|
|
891
|
-
* payload `exp` claim. Never hold on to tokens for reuse; always ask for a
|
|
892
|
-
* new one for each outgoing request. This ensures that you always get a
|
|
893
|
-
* valid, fresh one.
|
|
894
|
-
*/
|
|
895
|
-
getToken(): Promise<{
|
|
896
|
-
token: string;
|
|
897
|
-
}>;
|
|
898
|
-
/**
|
|
899
|
-
* Validates a given token.
|
|
815
|
+
* @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}
|
|
900
816
|
*/
|
|
901
|
-
|
|
817
|
+
id: string;
|
|
902
818
|
}
|
|
903
|
-
|
|
904
819
|
/**
|
|
905
|
-
*
|
|
820
|
+
* Creates a new backend extension point.
|
|
906
821
|
*
|
|
907
822
|
* @public
|
|
823
|
+
* @see {@link https://backstage.io/docs/backend-system/architecture/extension-points | The architecture of extension points}
|
|
824
|
+
*/
|
|
825
|
+
declare function createExtensionPoint<T>(config: ExtensionPointConfig): ExtensionPoint<T>;
|
|
826
|
+
/**
|
|
827
|
+
* The configuration options passed to {@link createBackendPlugin}.
|
|
828
|
+
*
|
|
829
|
+
* @public
|
|
830
|
+
* @see {@link https://backstage.io/docs/backend-system/architecture/plugins | The architecture of plugins}
|
|
831
|
+
* @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}
|
|
908
832
|
*/
|
|
909
|
-
|
|
833
|
+
interface BackendPluginConfig {
|
|
910
834
|
/**
|
|
911
|
-
*
|
|
835
|
+
* The ID of this plugin.
|
|
836
|
+
*
|
|
837
|
+
* @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}
|
|
912
838
|
*/
|
|
913
|
-
|
|
839
|
+
pluginId: string;
|
|
840
|
+
register(reg: BackendPluginRegistrationPoints): void;
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* Creates a new backend plugin.
|
|
844
|
+
*
|
|
845
|
+
* @public
|
|
846
|
+
* @see {@link https://backstage.io/docs/backend-system/architecture/plugins | The architecture of plugins}
|
|
847
|
+
* @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}
|
|
848
|
+
*/
|
|
849
|
+
declare function createBackendPlugin<TOptions extends [options?: object] = []>(config: BackendPluginConfig | ((...params: TOptions) => BackendPluginConfig)): (...params: TOptions) => BackendFeature;
|
|
850
|
+
/**
|
|
851
|
+
* The configuration options passed to {@link createBackendModule}.
|
|
852
|
+
*
|
|
853
|
+
* @public
|
|
854
|
+
* @see {@link https://backstage.io/docs/backend-system/architecture/modules | The architecture of modules}
|
|
855
|
+
* @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}
|
|
856
|
+
*/
|
|
857
|
+
interface BackendModuleConfig {
|
|
914
858
|
/**
|
|
915
|
-
*
|
|
859
|
+
* The ID of this plugin.
|
|
860
|
+
*
|
|
861
|
+
* @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}
|
|
916
862
|
*/
|
|
917
|
-
|
|
863
|
+
pluginId: string;
|
|
918
864
|
/**
|
|
919
|
-
*
|
|
865
|
+
* Should exactly match the `id` of the plugin that the module extends.
|
|
920
866
|
*/
|
|
921
|
-
|
|
867
|
+
moduleId: string;
|
|
868
|
+
register(reg: BackendModuleRegistrationPoints): void;
|
|
922
869
|
}
|
|
870
|
+
/**
|
|
871
|
+
* Creates a new backend module for a given plugin.
|
|
872
|
+
*
|
|
873
|
+
* @public
|
|
874
|
+
* @see {@link https://backstage.io/docs/backend-system/architecture/modules | The architecture of modules}
|
|
875
|
+
* @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}
|
|
876
|
+
*/
|
|
877
|
+
declare function createBackendModule<TOptions extends [options?: object] = []>(config: BackendModuleConfig | ((...params: TOptions) => BackendModuleConfig)): (...params: TOptions) => BackendFeature;
|
|
923
878
|
|
|
924
|
-
export { }
|
|
879
|
+
export { BackendFeature, BackendModuleConfig, BackendModuleRegistrationPoints, BackendPluginConfig, BackendPluginRegistrationPoints, CacheService, CacheServiceOptions, CacheServiceSetOptions, ConfigService, DatabaseService, DiscoveryService, ExtensionPoint, ExtensionPointConfig, HttpRouterService, IdentityService, LifecycleService, LifecycleServiceShutdownHook, LifecycleServiceShutdownOptions, LoggerService, PermissionsService, PluginMetadataService, PluginServiceFactoryConfig, ReadTreeOptions, ReadTreeResponse, ReadTreeResponseDirOptions, ReadTreeResponseFile, ReadUrlOptions, ReadUrlResponse, RootHttpRouterService, RootLifecycleService, RootLoggerService, RootServiceFactoryConfig, SchedulerService, SearchOptions, SearchResponse, SearchResponseFile, ServiceFactory, ServiceFactoryOrFunction, ServiceRef, ServiceRefConfig, SharedBackendEnvironment, SharedBackendEnvironmentConfig, TokenManagerService, UrlReaderService, coreServices, createBackendModule, createBackendPlugin, createExtensionPoint, createServiceFactory, createServiceRef, createSharedEnvironment };
|