@backstage/backend-plugin-api 0.0.0-nightly-20230103022231 → 0.0.0-nightly-20230105022800
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 +28 -5
- package/alpha/package.json +1 -1
- package/dist/index.alpha.d.ts +509 -73
- package/dist/index.beta.d.ts +509 -73
- package/dist/index.cjs.js +21 -117
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +509 -73
- package/package.json +7 -8
package/dist/index.alpha.d.ts
CHANGED
|
@@ -4,18 +4,15 @@
|
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
/// <reference types="node" />
|
|
8
|
+
|
|
7
9
|
import { Config } from '@backstage/config';
|
|
8
10
|
import { Handler } from 'express';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
+
import { JsonValue } from '@backstage/types';
|
|
12
|
+
import { Knex } from 'knex';
|
|
11
13
|
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
14
|
import { PluginTaskScheduler } from '@backstage/backend-tasks';
|
|
16
|
-
import {
|
|
17
|
-
import { TransportStreamOptions } from 'winston-transport';
|
|
18
|
-
import { UrlReader } from '@backstage/backend-common';
|
|
15
|
+
import { Readable } from 'stream';
|
|
19
16
|
|
|
20
17
|
/** @public */
|
|
21
18
|
export declare interface BackendFeature {
|
|
@@ -49,42 +46,178 @@ export declare interface BackendRegistrationPoints {
|
|
|
49
46
|
}): void;
|
|
50
47
|
}
|
|
51
48
|
|
|
52
|
-
/**
|
|
53
|
-
|
|
49
|
+
/**
|
|
50
|
+
* A pre-configured, storage agnostic cache client suitable for use by
|
|
51
|
+
* Backstage plugins.
|
|
52
|
+
*
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
export declare interface CacheClient {
|
|
56
|
+
/**
|
|
57
|
+
* Reads data from a cache store for the given key. If no data was found,
|
|
58
|
+
* returns undefined.
|
|
59
|
+
*/
|
|
60
|
+
get(key: string): Promise<JsonValue | undefined>;
|
|
61
|
+
/**
|
|
62
|
+
* Writes the given data to a cache store, associated with the given key. An
|
|
63
|
+
* optional TTL may also be provided, otherwise it defaults to the TTL that
|
|
64
|
+
* was provided when the client was instantiated.
|
|
65
|
+
*/
|
|
66
|
+
set(key: string, value: JsonValue, options?: CacheClientSetOptions): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Removes the given key from the cache store.
|
|
69
|
+
*/
|
|
70
|
+
delete(key: string): Promise<void>;
|
|
71
|
+
}
|
|
54
72
|
|
|
55
73
|
/**
|
|
74
|
+
* Options given when constructing a {@link CacheClient}.
|
|
75
|
+
*
|
|
56
76
|
* @public
|
|
57
77
|
*/
|
|
58
|
-
declare
|
|
78
|
+
export declare type CacheClientOptions = {
|
|
79
|
+
/**
|
|
80
|
+
* An optional default TTL (in milliseconds) to be set when getting a client
|
|
81
|
+
* instance. If not provided, data will persist indefinitely by default (or
|
|
82
|
+
* can be configured per entry at set-time).
|
|
83
|
+
*/
|
|
84
|
+
defaultTtl?: number;
|
|
85
|
+
};
|
|
59
86
|
|
|
60
87
|
/**
|
|
88
|
+
* Options passed to {@link CacheClient.set}.
|
|
89
|
+
*
|
|
90
|
+
* @public
|
|
91
|
+
*/
|
|
92
|
+
export declare type CacheClientSetOptions = {
|
|
93
|
+
/**
|
|
94
|
+
* Optional TTL in milliseconds. Defaults to the TTL provided when the client
|
|
95
|
+
* was set up (or no TTL if none are provided).
|
|
96
|
+
*/
|
|
97
|
+
ttl?: number;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Manages access to cache stores that plugins get.
|
|
102
|
+
*
|
|
61
103
|
* @public
|
|
62
104
|
*/
|
|
63
|
-
export declare
|
|
105
|
+
export declare interface CacheService {
|
|
106
|
+
/**
|
|
107
|
+
* Provides backend plugins cache connections for themselves.
|
|
108
|
+
*
|
|
109
|
+
* @remarks
|
|
110
|
+
*
|
|
111
|
+
* The purpose of this method is to allow plugins to get isolated data stores
|
|
112
|
+
* so that plugins are discouraged from cache-level integration and/or cache
|
|
113
|
+
* key collisions.
|
|
114
|
+
*/
|
|
115
|
+
getClient: (options?: CacheClientOptions) => CacheClient;
|
|
116
|
+
}
|
|
64
117
|
|
|
65
118
|
/**
|
|
66
119
|
* @public
|
|
67
120
|
*/
|
|
68
|
-
declare
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
121
|
+
export declare interface ConfigService extends Config {
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* All core services references
|
|
126
|
+
*
|
|
127
|
+
* @public
|
|
128
|
+
*/
|
|
129
|
+
export declare namespace coreServices {
|
|
130
|
+
/**
|
|
131
|
+
* The service reference for the plugin scoped {@link CacheService}.
|
|
132
|
+
*
|
|
133
|
+
* @public
|
|
134
|
+
*/
|
|
135
|
+
const cache: ServiceRef<CacheService, "plugin">;
|
|
136
|
+
/**
|
|
137
|
+
* The service reference for the root scoped {@link ConfigService}.
|
|
138
|
+
*
|
|
139
|
+
* @public
|
|
140
|
+
*/
|
|
141
|
+
const config: ServiceRef<ConfigService, "root">;
|
|
142
|
+
/**
|
|
143
|
+
* The service reference for the plugin scoped {@link DatabaseService}.
|
|
144
|
+
*
|
|
145
|
+
* @public
|
|
146
|
+
*/
|
|
147
|
+
const database: ServiceRef<DatabaseService, "plugin">;
|
|
148
|
+
/**
|
|
149
|
+
* The service reference for the plugin scoped {@link DiscoveryService}.
|
|
150
|
+
*
|
|
151
|
+
* @public
|
|
152
|
+
*/
|
|
153
|
+
const discovery: ServiceRef<DiscoveryService, "plugin">;
|
|
154
|
+
/**
|
|
155
|
+
* The service reference for the plugin scoped {@link HttpRouterService}.
|
|
156
|
+
*
|
|
157
|
+
* @public
|
|
158
|
+
*/
|
|
159
|
+
const httpRouter: ServiceRef<HttpRouterService, "plugin">;
|
|
160
|
+
/**
|
|
161
|
+
* The service reference for the plugin scoped {@link LifecycleService}.
|
|
162
|
+
*
|
|
163
|
+
* @public
|
|
164
|
+
*/
|
|
165
|
+
const lifecycle: ServiceRef<LifecycleService, "plugin">;
|
|
166
|
+
/**
|
|
167
|
+
* The service reference for the plugin scoped {@link LoggerService}.
|
|
168
|
+
*
|
|
169
|
+
* @public
|
|
170
|
+
*/
|
|
171
|
+
const logger: ServiceRef<LoggerService, "plugin">;
|
|
172
|
+
/**
|
|
173
|
+
* The service reference for the plugin scoped {@link PermissionsService}.
|
|
174
|
+
*
|
|
175
|
+
* @public
|
|
176
|
+
*/
|
|
177
|
+
const permissions: ServiceRef<PermissionsService, "plugin">;
|
|
178
|
+
/**
|
|
179
|
+
* The service reference for the plugin scoped {@link PluginMetadataService}.
|
|
180
|
+
*
|
|
181
|
+
* @public
|
|
182
|
+
*/
|
|
183
|
+
const pluginMetadata: ServiceRef<PluginMetadataService, "plugin">;
|
|
184
|
+
/**
|
|
185
|
+
* The service reference for the root scoped {@link RootHttpRouterService}.
|
|
186
|
+
*
|
|
187
|
+
* @public
|
|
188
|
+
*/
|
|
189
|
+
const rootHttpRouter: ServiceRef<RootHttpRouterService, "root">;
|
|
190
|
+
/**
|
|
191
|
+
* The service reference for the root scoped {@link RootLifecycleService}.
|
|
192
|
+
*
|
|
193
|
+
* @public
|
|
194
|
+
*/
|
|
195
|
+
const rootLifecycle: ServiceRef<RootLifecycleService, "root">;
|
|
196
|
+
/**
|
|
197
|
+
* The service reference for the root scoped {@link RootLoggerService}.
|
|
198
|
+
*
|
|
199
|
+
* @public
|
|
200
|
+
*/
|
|
201
|
+
const rootLogger: ServiceRef<RootLoggerService, "root">;
|
|
202
|
+
/**
|
|
203
|
+
* The service reference for the plugin scoped {@link SchedulerService}.
|
|
204
|
+
*
|
|
205
|
+
* @public
|
|
206
|
+
*/
|
|
207
|
+
const scheduler: ServiceRef<SchedulerService, "plugin">;
|
|
208
|
+
/**
|
|
209
|
+
* The service reference for the plugin scoped {@link TokenManagerService}.
|
|
210
|
+
*
|
|
211
|
+
* @public
|
|
212
|
+
*/
|
|
213
|
+
const tokenManager: ServiceRef<TokenManagerService, "plugin">;
|
|
214
|
+
/**
|
|
215
|
+
* The service reference for the plugin scoped {@link UrlReaderService}.
|
|
216
|
+
*
|
|
217
|
+
* @public
|
|
218
|
+
*/
|
|
219
|
+
const urlReader: ServiceRef<UrlReaderService, "plugin">;
|
|
86
220
|
}
|
|
87
|
-
export { coreServices }
|
|
88
221
|
|
|
89
222
|
/**
|
|
90
223
|
* @public
|
|
@@ -136,21 +269,78 @@ export declare function createServiceRef<T>(options: {
|
|
|
136
269
|
defaultFactory?: (service: ServiceRef<T, 'root'>) => Promise<ServiceFactory<T> | (() => ServiceFactory<T>)>;
|
|
137
270
|
}): ServiceRef<T, 'root'>;
|
|
138
271
|
|
|
139
|
-
/** @public */
|
|
140
|
-
export declare type DatabaseService = PluginDatabaseManager;
|
|
141
|
-
|
|
142
272
|
/**
|
|
273
|
+
* The DatabaseService manages access to databases that Plugins get.
|
|
274
|
+
*gs
|
|
143
275
|
* @public
|
|
144
276
|
*/
|
|
145
|
-
declare
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
277
|
+
export declare interface DatabaseService {
|
|
278
|
+
/**
|
|
279
|
+
* getClient provides backend plugins database connections for itself.
|
|
280
|
+
*
|
|
281
|
+
* The purpose of this method is to allow plugins to get isolated data
|
|
282
|
+
* stores so that plugins are discouraged from database integration.
|
|
283
|
+
*/
|
|
284
|
+
getClient(): Promise<Knex>;
|
|
285
|
+
/**
|
|
286
|
+
* This property is used to control the behavior of database migrations.
|
|
287
|
+
*/
|
|
288
|
+
migrations?: {
|
|
289
|
+
/**
|
|
290
|
+
* skip database migrations. Useful if connecting to a read-only database.
|
|
291
|
+
*
|
|
292
|
+
* @defaultValue false
|
|
293
|
+
*/
|
|
294
|
+
skip?: boolean;
|
|
295
|
+
};
|
|
296
|
+
}
|
|
149
297
|
|
|
150
298
|
/**
|
|
299
|
+
* The DiscoveryService is used to provide a mechanism for backend
|
|
300
|
+
* plugins to discover the endpoints for itself or other backend plugins.
|
|
301
|
+
*
|
|
302
|
+
* The purpose of the discovery API is to allow for many different deployment
|
|
303
|
+
* setups and routing methods through a central configuration, instead
|
|
304
|
+
* of letting each individual plugin manage that configuration.
|
|
305
|
+
*
|
|
306
|
+
* Implementations of the discovery API can be as simple as a URL pattern
|
|
307
|
+
* using the pluginId, but could also have overrides for individual plugins,
|
|
308
|
+
* or query a separate discovery service.
|
|
309
|
+
*
|
|
151
310
|
* @public
|
|
152
311
|
*/
|
|
153
|
-
declare
|
|
312
|
+
export declare interface DiscoveryService {
|
|
313
|
+
/**
|
|
314
|
+
* Returns the internal HTTP base URL for a given plugin, without a trailing slash.
|
|
315
|
+
*
|
|
316
|
+
* The returned URL should point to an internal endpoint for the plugin, with
|
|
317
|
+
* the shortest route possible. The URL should be used for service-to-service
|
|
318
|
+
* communication within a Backstage backend deployment.
|
|
319
|
+
*
|
|
320
|
+
* This method must always be called just before making a request, as opposed to
|
|
321
|
+
* fetching the URL when constructing an API client. That is to ensure that more
|
|
322
|
+
* flexible routing patterns can be supported.
|
|
323
|
+
*
|
|
324
|
+
* For example, asking for the URL for `catalog` may return something
|
|
325
|
+
* like `http://10.1.2.3/api/catalog`
|
|
326
|
+
*/
|
|
327
|
+
getBaseUrl(pluginId: string): Promise<string>;
|
|
328
|
+
/**
|
|
329
|
+
* Returns the external HTTP base backend URL for a given plugin, without a trailing slash.
|
|
330
|
+
*
|
|
331
|
+
* The returned URL should point to an external endpoint for the plugin, such that
|
|
332
|
+
* it is reachable from the Backstage frontend and other external services. The returned
|
|
333
|
+
* URL should be usable for example as a callback / webhook URL.
|
|
334
|
+
*
|
|
335
|
+
* The returned URL should be stable and in general not change unless other static
|
|
336
|
+
* or external configuration is changed. Changes should not come as a surprise
|
|
337
|
+
* to an operator of the Backstage backend.
|
|
338
|
+
*
|
|
339
|
+
* For example, asking for the URL for `catalog` may return something
|
|
340
|
+
* like `https://backstage.example.com/api/catalog`
|
|
341
|
+
*/
|
|
342
|
+
getExternalBaseUrl(pluginId: string): Promise<string>;
|
|
343
|
+
}
|
|
154
344
|
|
|
155
345
|
/**
|
|
156
346
|
* TODO
|
|
@@ -175,11 +365,6 @@ export declare interface HttpRouterService {
|
|
|
175
365
|
use(handler: Handler): void;
|
|
176
366
|
}
|
|
177
367
|
|
|
178
|
-
/**
|
|
179
|
-
* @public
|
|
180
|
-
*/
|
|
181
|
-
declare const httpRouterServiceRef: ServiceRef<HttpRouterService, "plugin">;
|
|
182
|
-
|
|
183
368
|
/**
|
|
184
369
|
* @public
|
|
185
370
|
**/
|
|
@@ -190,19 +375,18 @@ export declare interface LifecycleService {
|
|
|
190
375
|
addShutdownHook(options: LifecycleServiceShutdownHook): void;
|
|
191
376
|
}
|
|
192
377
|
|
|
193
|
-
/**
|
|
194
|
-
* @public
|
|
195
|
-
*/
|
|
196
|
-
declare const lifecycleServiceRef: ServiceRef<LifecycleService, "plugin">;
|
|
197
|
-
|
|
198
378
|
/**
|
|
199
379
|
* @public
|
|
200
380
|
**/
|
|
201
381
|
export declare type LifecycleServiceShutdownHook = {
|
|
202
382
|
fn: () => void | Promise<void>;
|
|
383
|
+
/** Labels to help identify the shutdown hook */
|
|
384
|
+
labels?: Record<string, string>;
|
|
203
385
|
};
|
|
204
386
|
|
|
205
387
|
/**
|
|
388
|
+
* A service that provides a logging facility.
|
|
389
|
+
*
|
|
206
390
|
* @public
|
|
207
391
|
*/
|
|
208
392
|
export declare interface LoggerService {
|
|
@@ -216,53 +400,276 @@ export declare interface LoggerService {
|
|
|
216
400
|
/**
|
|
217
401
|
* @public
|
|
218
402
|
*/
|
|
219
|
-
declare
|
|
403
|
+
export declare type LogMeta = {
|
|
404
|
+
[name: string]: unknown;
|
|
405
|
+
};
|
|
220
406
|
|
|
221
407
|
/** @public */
|
|
222
|
-
export declare
|
|
408
|
+
export declare interface PermissionsService extends PermissionEvaluator {
|
|
409
|
+
}
|
|
223
410
|
|
|
224
411
|
/**
|
|
225
412
|
* @public
|
|
226
413
|
*/
|
|
227
|
-
export declare
|
|
228
|
-
|
|
414
|
+
export declare interface PluginMetadataService {
|
|
415
|
+
getId(): string;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* An options object for {@link UrlReaderService.readTree} operations.
|
|
420
|
+
*
|
|
421
|
+
* @public
|
|
422
|
+
*/
|
|
423
|
+
export declare type ReadTreeOptions = {
|
|
424
|
+
/**
|
|
425
|
+
* A filter that can be used to select which files should be included.
|
|
426
|
+
*
|
|
427
|
+
* @remarks
|
|
428
|
+
*
|
|
429
|
+
* The path passed to the filter function is the relative path from the URL
|
|
430
|
+
* that the file tree is fetched from, without any leading '/'.
|
|
431
|
+
*
|
|
432
|
+
* For example, given the URL https://github.com/my/repo/tree/master/my-dir, a file
|
|
433
|
+
* at https://github.com/my/repo/blob/master/my-dir/my-subdir/my-file.txt will
|
|
434
|
+
* be represented as my-subdir/my-file.txt
|
|
435
|
+
*
|
|
436
|
+
* If no filter is provided, all files are extracted.
|
|
437
|
+
*/
|
|
438
|
+
filter?(path: string, info?: {
|
|
439
|
+
size: number;
|
|
440
|
+
}): boolean;
|
|
441
|
+
/**
|
|
442
|
+
* An ETag which can be provided to check whether a
|
|
443
|
+
* {@link UrlReaderService.readTree} response has changed from a previous execution.
|
|
444
|
+
*
|
|
445
|
+
* @remarks
|
|
446
|
+
*
|
|
447
|
+
* In the {@link UrlReaderService.readTree} response, an ETag is returned along with
|
|
448
|
+
* the tree blob. The ETag is a unique identifier of the tree blob, usually
|
|
449
|
+
* the commit SHA or ETag from the target.
|
|
450
|
+
*
|
|
451
|
+
* When an ETag is given as a request option, {@link UrlReaderService.readTree} will
|
|
452
|
+
* first compare the ETag against the ETag on the target branch. If they
|
|
453
|
+
* match, {@link UrlReaderService.readTree} will throw a
|
|
454
|
+
* {@link @backstage/errors#NotModifiedError} indicating that the response
|
|
455
|
+
* will not differ from the previous response which included this particular
|
|
456
|
+
* ETag. If they do not match, {@link UrlReaderService.readTree} will return the
|
|
457
|
+
* rest of the response along with a new ETag.
|
|
458
|
+
*/
|
|
459
|
+
etag?: string;
|
|
460
|
+
/**
|
|
461
|
+
* An abort signal to pass down to the underlying request.
|
|
462
|
+
*
|
|
463
|
+
* @remarks
|
|
464
|
+
*
|
|
465
|
+
* Not all reader implementations may take this field into account.
|
|
466
|
+
*/
|
|
467
|
+
signal?: AbortSignal;
|
|
229
468
|
};
|
|
230
469
|
|
|
231
|
-
/**
|
|
232
|
-
|
|
470
|
+
/**
|
|
471
|
+
* A response object for {@link UrlReaderService.readTree} operations.
|
|
472
|
+
*
|
|
473
|
+
* @public
|
|
474
|
+
*/
|
|
475
|
+
export declare type ReadTreeResponse = {
|
|
476
|
+
/**
|
|
477
|
+
* Returns an array of all the files inside the tree, and corresponding
|
|
478
|
+
* functions to read their content.
|
|
479
|
+
*/
|
|
480
|
+
files(): Promise<ReadTreeResponseFile[]>;
|
|
481
|
+
/**
|
|
482
|
+
* Returns the tree contents as a binary archive, using a stream.
|
|
483
|
+
*/
|
|
484
|
+
archive(): Promise<NodeJS.ReadableStream>;
|
|
485
|
+
/**
|
|
486
|
+
* Extracts the tree response into a directory and returns the path of the
|
|
487
|
+
* directory.
|
|
488
|
+
*
|
|
489
|
+
* **NOTE**: It is the responsibility of the caller to remove the directory after use.
|
|
490
|
+
*/
|
|
491
|
+
dir(options?: ReadTreeResponseDirOptions): Promise<string>;
|
|
492
|
+
/**
|
|
493
|
+
* Etag returned by content provider.
|
|
494
|
+
*
|
|
495
|
+
* @remarks
|
|
496
|
+
*
|
|
497
|
+
* Can be used to compare and cache responses when doing subsequent calls.
|
|
498
|
+
*/
|
|
499
|
+
etag: string;
|
|
500
|
+
};
|
|
233
501
|
|
|
234
502
|
/**
|
|
503
|
+
* Options that control {@link ReadTreeResponse.dir} execution.
|
|
504
|
+
*
|
|
235
505
|
* @public
|
|
236
506
|
*/
|
|
237
|
-
declare
|
|
507
|
+
export declare type ReadTreeResponseDirOptions = {
|
|
508
|
+
/**
|
|
509
|
+
* The directory to write files to.
|
|
510
|
+
*
|
|
511
|
+
* @remarks
|
|
512
|
+
*
|
|
513
|
+
* Defaults to the OS tmpdir, or `backend.workingDirectory` if set in config.
|
|
514
|
+
*/
|
|
515
|
+
targetDir?: string;
|
|
516
|
+
};
|
|
238
517
|
|
|
239
518
|
/**
|
|
519
|
+
* Represents a single file in a {@link UrlReaderService.readTree} response.
|
|
520
|
+
*
|
|
240
521
|
* @public
|
|
241
522
|
*/
|
|
242
|
-
export declare
|
|
243
|
-
|
|
244
|
-
|
|
523
|
+
export declare type ReadTreeResponseFile = {
|
|
524
|
+
path: string;
|
|
525
|
+
content(): Promise<Buffer>;
|
|
526
|
+
};
|
|
245
527
|
|
|
246
528
|
/**
|
|
529
|
+
* An options object for readUrl operations.
|
|
530
|
+
*
|
|
247
531
|
* @public
|
|
248
532
|
*/
|
|
249
|
-
declare
|
|
533
|
+
export declare type ReadUrlOptions = {
|
|
534
|
+
/**
|
|
535
|
+
* An ETag which can be provided to check whether a
|
|
536
|
+
* {@link UrlReaderService.readUrl} response has changed from a previous execution.
|
|
537
|
+
*
|
|
538
|
+
* @remarks
|
|
539
|
+
*
|
|
540
|
+
* In the {@link UrlReaderService.readUrl} response, an ETag is returned along with
|
|
541
|
+
* the data. The ETag is a unique identifier of the data, usually the commit
|
|
542
|
+
* SHA or ETag from the target.
|
|
543
|
+
*
|
|
544
|
+
* When an ETag is given in ReadUrlOptions, {@link UrlReaderService.readUrl} will
|
|
545
|
+
* first compare the ETag against the ETag of the target. If they match,
|
|
546
|
+
* {@link UrlReaderService.readUrl} will throw a
|
|
547
|
+
* {@link @backstage/errors#NotModifiedError} indicating that the response
|
|
548
|
+
* will not differ from the previous response which included this particular
|
|
549
|
+
* ETag. If they do not match, {@link UrlReaderService.readUrl} will return the rest
|
|
550
|
+
* of the response along with a new ETag.
|
|
551
|
+
*/
|
|
552
|
+
etag?: string;
|
|
553
|
+
/**
|
|
554
|
+
* An abort signal to pass down to the underlying request.
|
|
555
|
+
*
|
|
556
|
+
* @remarks
|
|
557
|
+
*
|
|
558
|
+
* Not all reader implementations may take this field into account.
|
|
559
|
+
*/
|
|
560
|
+
signal?: AbortSignal;
|
|
561
|
+
};
|
|
250
562
|
|
|
251
|
-
/**
|
|
252
|
-
|
|
563
|
+
/**
|
|
564
|
+
* A response object for {@link UrlReaderService.readUrl} operations.
|
|
565
|
+
*
|
|
566
|
+
* @public
|
|
567
|
+
*/
|
|
568
|
+
export declare type ReadUrlResponse = {
|
|
569
|
+
/**
|
|
570
|
+
* Returns the data that was read from the remote URL.
|
|
571
|
+
*/
|
|
572
|
+
buffer(): Promise<Buffer>;
|
|
573
|
+
/**
|
|
574
|
+
* Returns the data that was read from the remote URL as a Readable stream.
|
|
575
|
+
*
|
|
576
|
+
* @remarks
|
|
577
|
+
*
|
|
578
|
+
* This method will be required in a future release.
|
|
579
|
+
*/
|
|
580
|
+
stream?(): Readable;
|
|
581
|
+
/**
|
|
582
|
+
* Etag returned by content provider.
|
|
583
|
+
*
|
|
584
|
+
* @remarks
|
|
585
|
+
*
|
|
586
|
+
* Can be used to compare and cache responses when doing subsequent calls.
|
|
587
|
+
*/
|
|
588
|
+
etag?: string;
|
|
589
|
+
};
|
|
253
590
|
|
|
254
591
|
/**
|
|
255
592
|
* @public
|
|
256
593
|
*/
|
|
257
|
-
declare
|
|
594
|
+
export declare interface RootHttpRouterService {
|
|
595
|
+
/**
|
|
596
|
+
* Registers a handler at the root of the backend router.
|
|
597
|
+
* The path is required and may not be empty.
|
|
598
|
+
*/
|
|
599
|
+
use(path: string, handler: Handler): void;
|
|
600
|
+
}
|
|
258
601
|
|
|
259
602
|
/** @public */
|
|
260
|
-
export declare
|
|
603
|
+
export declare interface RootLifecycleService extends LifecycleService {
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/** @public */
|
|
607
|
+
export declare interface RootLoggerService extends LoggerService {
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/** @public */
|
|
611
|
+
export declare interface SchedulerService extends PluginTaskScheduler {
|
|
612
|
+
}
|
|
261
613
|
|
|
262
614
|
/**
|
|
615
|
+
* An options object for search operations.
|
|
616
|
+
*
|
|
263
617
|
* @public
|
|
264
618
|
*/
|
|
265
|
-
declare
|
|
619
|
+
export declare type SearchOptions = {
|
|
620
|
+
/**
|
|
621
|
+
* An etag can be provided to check whether the search response has changed from a previous execution.
|
|
622
|
+
*
|
|
623
|
+
* In the search() response, an etag is returned along with the files. The etag is a unique identifier
|
|
624
|
+
* of the current tree, usually the commit SHA or etag from the target.
|
|
625
|
+
*
|
|
626
|
+
* When an etag is given in SearchOptions, search will first compare the etag against the etag
|
|
627
|
+
* on the target branch. If they match, search will throw a NotModifiedError indicating that the search
|
|
628
|
+
* response will not differ from the previous response which included this particular etag. If they mismatch,
|
|
629
|
+
* search will return the rest of SearchResponse along with a new etag.
|
|
630
|
+
*/
|
|
631
|
+
etag?: string;
|
|
632
|
+
/**
|
|
633
|
+
* An abort signal to pass down to the underlying request.
|
|
634
|
+
*
|
|
635
|
+
* @remarks
|
|
636
|
+
*
|
|
637
|
+
* Not all reader implementations may take this field into account.
|
|
638
|
+
*/
|
|
639
|
+
signal?: AbortSignal;
|
|
640
|
+
};
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* The output of a search operation.
|
|
644
|
+
*
|
|
645
|
+
* @public
|
|
646
|
+
*/
|
|
647
|
+
export declare type SearchResponse = {
|
|
648
|
+
/**
|
|
649
|
+
* The files that matched the search query.
|
|
650
|
+
*/
|
|
651
|
+
files: SearchResponseFile[];
|
|
652
|
+
/**
|
|
653
|
+
* A unique identifier of the current remote tree, usually the commit SHA or etag from the target.
|
|
654
|
+
*/
|
|
655
|
+
etag: string;
|
|
656
|
+
};
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* Represents a single file in a search response.
|
|
660
|
+
*
|
|
661
|
+
* @public
|
|
662
|
+
*/
|
|
663
|
+
export declare type SearchResponseFile = {
|
|
664
|
+
/**
|
|
665
|
+
* The full URL to the file.
|
|
666
|
+
*/
|
|
667
|
+
url: string;
|
|
668
|
+
/**
|
|
669
|
+
* The binary contents of the file.
|
|
670
|
+
*/
|
|
671
|
+
content(): Promise<Buffer>;
|
|
672
|
+
};
|
|
266
673
|
|
|
267
674
|
/** @public */
|
|
268
675
|
export declare type ServiceFactory<TService = unknown> = {
|
|
@@ -322,25 +729,54 @@ declare type ServiceRefsToInstances<T extends {
|
|
|
322
729
|
}[keyof T]]: T[name] extends ServiceRef<infer TImpl> ? TImpl : never;
|
|
323
730
|
};
|
|
324
731
|
|
|
325
|
-
/** @public */
|
|
326
|
-
export declare type TokenManagerService = TokenManager;
|
|
327
|
-
|
|
328
732
|
/**
|
|
733
|
+
* Interface for creating and validating tokens.
|
|
734
|
+
*
|
|
329
735
|
* @public
|
|
330
736
|
*/
|
|
331
|
-
declare
|
|
737
|
+
export declare interface TokenManagerService {
|
|
738
|
+
/**
|
|
739
|
+
* Fetches a valid token.
|
|
740
|
+
*
|
|
741
|
+
* @remarks
|
|
742
|
+
*
|
|
743
|
+
* Tokens are valid for roughly one hour; the actual deadline is set in the
|
|
744
|
+
* payload `exp` claim. Never hold on to tokens for reuse; always ask for a
|
|
745
|
+
* new one for each outgoing request. This ensures that you always get a
|
|
746
|
+
* valid, fresh one.
|
|
747
|
+
*/
|
|
748
|
+
getToken(): Promise<{
|
|
749
|
+
token: string;
|
|
750
|
+
}>;
|
|
751
|
+
/**
|
|
752
|
+
* Validates a given token.
|
|
753
|
+
*/
|
|
754
|
+
authenticate(token: string): Promise<void>;
|
|
755
|
+
}
|
|
332
756
|
|
|
333
757
|
/** @public */
|
|
334
758
|
export declare type TypesToServiceRef<T> = {
|
|
335
759
|
[key in keyof T]: ServiceRef<T[key]>;
|
|
336
760
|
};
|
|
337
761
|
|
|
338
|
-
/** @public */
|
|
339
|
-
export declare type UrlReaderService = UrlReader;
|
|
340
|
-
|
|
341
762
|
/**
|
|
763
|
+
* A generic interface for fetching plain data from URLs.
|
|
764
|
+
*
|
|
342
765
|
* @public
|
|
343
766
|
*/
|
|
344
|
-
declare
|
|
767
|
+
export declare interface UrlReaderService {
|
|
768
|
+
/**
|
|
769
|
+
* Reads a single file and return its content.
|
|
770
|
+
*/
|
|
771
|
+
readUrl(url: string, options?: ReadUrlOptions): Promise<ReadUrlResponse>;
|
|
772
|
+
/**
|
|
773
|
+
* Reads a full or partial file tree.
|
|
774
|
+
*/
|
|
775
|
+
readTree(url: string, options?: ReadTreeOptions): Promise<ReadTreeResponse>;
|
|
776
|
+
/**
|
|
777
|
+
* Searches for a file in a tree using a glob pattern.
|
|
778
|
+
*/
|
|
779
|
+
search(url: string, options?: SearchOptions): Promise<SearchResponse>;
|
|
780
|
+
}
|
|
345
781
|
|
|
346
782
|
export { }
|