@backstage/backend-plugin-api 0.2.1-next.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -8,15 +8,12 @@
8
8
 
9
9
  import { Config } from '@backstage/config';
10
10
  import { Handler } from 'express';
11
- import { Logger } from 'winston';
12
- import { PermissionAuthorizer } from '@backstage/plugin-permission-common';
11
+ import { IdentityApi } from '@backstage/plugin-auth-node';
12
+ import { JsonValue } from '@backstage/types';
13
+ import { Knex } from 'knex';
13
14
  import { PermissionEvaluator } from '@backstage/plugin-permission-common';
14
- import { PluginCacheManager } from '@backstage/backend-common';
15
- import { PluginDatabaseManager } from '@backstage/backend-common';
16
15
  import { PluginTaskScheduler } from '@backstage/backend-tasks';
17
16
  import { Readable } from 'stream';
18
- import { TokenManager } from '@backstage/backend-common';
19
- import { TransportStreamOptions } from 'winston-transport';
20
17
 
21
18
  /** @public */
22
19
  export declare interface BackendFeature {
@@ -25,16 +22,16 @@ export declare interface BackendFeature {
25
22
  }
26
23
 
27
24
  /** @public */
28
- export declare interface BackendModuleConfig<TOptions> {
25
+ export declare interface BackendModuleConfig {
29
26
  pluginId: string;
30
27
  moduleId: string;
31
- register(reg: Omit<BackendRegistrationPoints, 'registerExtensionPoint'>, options: TOptions): void;
28
+ register(reg: Omit<BackendRegistrationPoints, 'registerExtensionPoint'>): void;
32
29
  }
33
30
 
34
31
  /** @public */
35
- export declare interface BackendPluginConfig<TOptions> {
32
+ export declare interface BackendPluginConfig {
36
33
  id: string;
37
- register(reg: BackendRegistrationPoints, options: TOptions): void;
34
+ register(reg: BackendRegistrationPoints): void;
38
35
  }
39
36
 
40
37
  /** @public */
@@ -50,49 +47,192 @@ export declare interface BackendRegistrationPoints {
50
47
  }): void;
51
48
  }
52
49
 
53
- /** @public */
54
- export declare type CacheService = PluginCacheManager;
55
-
56
50
  /**
51
+ * A pre-configured, storage agnostic cache client suitable for use by
52
+ * Backstage plugins.
53
+ *
57
54
  * @public
58
55
  */
59
- declare const cacheServiceRef: ServiceRef<PluginCacheManager, "plugin">;
56
+ export declare interface CacheClient {
57
+ /**
58
+ * Reads data from a cache store for the given key. If no data was found,
59
+ * returns undefined.
60
+ */
61
+ get(key: string): Promise<JsonValue | undefined>;
62
+ /**
63
+ * Writes the given data to a cache store, associated with the given key. An
64
+ * optional TTL may also be provided, otherwise it defaults to the TTL that
65
+ * was provided when the client was instantiated.
66
+ */
67
+ set(key: string, value: JsonValue, options?: CacheClientSetOptions): Promise<void>;
68
+ /**
69
+ * Removes the given key from the cache store.
70
+ */
71
+ delete(key: string): Promise<void>;
72
+ }
60
73
 
61
74
  /**
75
+ * Options given when constructing a {@link CacheClient}.
76
+ *
62
77
  * @public
63
78
  */
64
- export declare type ConfigService = Config;
79
+ export declare type CacheClientOptions = {
80
+ /**
81
+ * An optional default TTL (in milliseconds) to be set when getting a client
82
+ * instance. If not provided, data will persist indefinitely by default (or
83
+ * can be configured per entry at set-time).
84
+ */
85
+ defaultTtl?: number;
86
+ };
65
87
 
66
88
  /**
89
+ * Options passed to {@link CacheClient.set}.
90
+ *
67
91
  * @public
68
92
  */
69
- declare const configServiceRef: ServiceRef<Config, "root">;
93
+ export declare type CacheClientSetOptions = {
94
+ /**
95
+ * Optional TTL in milliseconds. Defaults to the TTL provided when the client
96
+ * was set up (or no TTL if none are provided).
97
+ */
98
+ ttl?: number;
99
+ };
70
100
 
71
- declare namespace coreServices {
72
- export {
73
- configServiceRef as config,
74
- httpRouterServiceRef as httpRouter,
75
- loggerServiceRef as logger,
76
- urlReaderServiceRef as urlReader,
77
- cacheServiceRef as cache,
78
- databaseServiceRef as database,
79
- discoveryServiceRef as discovery,
80
- tokenManagerServiceRef as tokenManager,
81
- permissionsServiceRef as permissions,
82
- schedulerServiceRef as scheduler,
83
- rootLifecycleServiceRef as rootLifecycle,
84
- rootLoggerServiceRef as rootLogger,
85
- pluginMetadataServiceRef as pluginMetadata,
86
- lifecycleServiceRef as lifecycle
87
- }
101
+ /**
102
+ * Manages access to cache stores that plugins get.
103
+ *
104
+ * @public
105
+ */
106
+ export declare interface CacheService {
107
+ /**
108
+ * Provides backend plugins cache connections for themselves.
109
+ *
110
+ * @remarks
111
+ *
112
+ * The purpose of this method is to allow plugins to get isolated data stores
113
+ * so that plugins are discouraged from cache-level integration and/or cache
114
+ * key collisions.
115
+ */
116
+ getClient: (options?: CacheClientOptions) => CacheClient;
88
117
  }
89
- export { coreServices }
90
118
 
91
119
  /**
92
120
  * @public
121
+ */
122
+ export declare interface ConfigService extends Config {
123
+ }
124
+
125
+ /**
126
+ * All core services references
93
127
  *
128
+ * @public
129
+ */
130
+ export declare namespace coreServices {
131
+ /**
132
+ * The service reference for the plugin scoped {@link CacheService}.
133
+ *
134
+ * @public
135
+ */
136
+ const cache: ServiceRef<CacheService, "plugin">;
137
+ /**
138
+ * The service reference for the root scoped {@link ConfigService}.
139
+ *
140
+ * @public
141
+ */
142
+ const config: ServiceRef<ConfigService, "root">;
143
+ /**
144
+ * The service reference for the plugin scoped {@link DatabaseService}.
145
+ *
146
+ * @public
147
+ */
148
+ const database: ServiceRef<DatabaseService, "plugin">;
149
+ /**
150
+ * The service reference for the plugin scoped {@link DiscoveryService}.
151
+ *
152
+ * @public
153
+ */
154
+ const discovery: ServiceRef<DiscoveryService, "plugin">;
155
+ /**
156
+ * The service reference for the plugin scoped {@link HttpRouterService}.
157
+ *
158
+ * @public
159
+ */
160
+ const httpRouter: ServiceRef<HttpRouterService, "plugin">;
161
+ /**
162
+ * The service reference for the plugin scoped {@link LifecycleService}.
163
+ *
164
+ * @public
165
+ */
166
+ const lifecycle: ServiceRef<LifecycleService, "plugin">;
167
+ /**
168
+ * The service reference for the plugin scoped {@link LoggerService}.
169
+ *
170
+ * @public
171
+ */
172
+ const logger: ServiceRef<LoggerService, "plugin">;
173
+ /**
174
+ * The service reference for the plugin scoped {@link PermissionsService}.
175
+ *
176
+ * @public
177
+ */
178
+ const permissions: ServiceRef<PermissionsService, "plugin">;
179
+ /**
180
+ * The service reference for the plugin scoped {@link PluginMetadataService}.
181
+ *
182
+ * @public
183
+ */
184
+ const pluginMetadata: ServiceRef<PluginMetadataService, "plugin">;
185
+ /**
186
+ * The service reference for the root scoped {@link RootHttpRouterService}.
187
+ *
188
+ * @public
189
+ */
190
+ const rootHttpRouter: ServiceRef<RootHttpRouterService, "root">;
191
+ /**
192
+ * The service reference for the root scoped {@link RootLifecycleService}.
193
+ *
194
+ * @public
195
+ */
196
+ const rootLifecycle: ServiceRef<RootLifecycleService, "root">;
197
+ /**
198
+ * The service reference for the root scoped {@link RootLoggerService}.
199
+ *
200
+ * @public
201
+ */
202
+ const rootLogger: ServiceRef<RootLoggerService, "root">;
203
+ /**
204
+ * The service reference for the plugin scoped {@link SchedulerService}.
205
+ *
206
+ * @public
207
+ */
208
+ const scheduler: ServiceRef<SchedulerService, "plugin">;
209
+ /**
210
+ * The service reference for the plugin scoped {@link TokenManagerService}.
211
+ *
212
+ * @public
213
+ */
214
+ const tokenManager: ServiceRef<TokenManagerService, "plugin">;
215
+ /**
216
+ * The service reference for the plugin scoped {@link UrlReaderService}.
217
+ *
218
+ * @public
219
+ */
220
+ const urlReader: ServiceRef<UrlReaderService, "plugin">;
221
+ /**
222
+ * The service reference for the plugin scoped {@link IdentityService}.
223
+ *
224
+ * @public
225
+ */
226
+ const identity: ServiceRef<IdentityService, "plugin">;
227
+ }
228
+
229
+ /**
94
230
  * Creates a new backend module for a given plugin.
95
231
  *
232
+ * @public
233
+ *
234
+ * @remarks
235
+ *
96
236
  * The `moduleId` should be equal to the module-specific prefix of the exported name, such
97
237
  * that the full name is `moduleId + PluginId + "Module"`. For example, a GitHub entity
98
238
  * provider module for the `catalog` plugin might have the module ID `'githubEntityProvider'`,
@@ -100,51 +240,119 @@ export { coreServices }
100
240
  *
101
241
  * The `pluginId` should exactly match the `id` of the plugin that the module extends.
102
242
  */
103
- export declare function createBackendModule<TOptions extends object | undefined = undefined>(config: BackendModuleConfig<TOptions>): undefined extends TOptions ? (options?: TOptions) => BackendFeature : (options: TOptions) => BackendFeature;
243
+ export declare function createBackendModule<TOptions extends [options?: object] = []>(config: BackendModuleConfig | ((...params: TOptions) => BackendModuleConfig)): (...params: TOptions) => BackendFeature;
104
244
 
105
245
  /** @public */
106
- export declare function createBackendPlugin<TOptions extends object | undefined = undefined>(config: {
107
- id: string;
108
- register(reg: BackendRegistrationPoints, options: TOptions): void;
109
- }): undefined extends TOptions ? (options?: TOptions) => BackendFeature : (options: TOptions) => BackendFeature;
246
+ export declare function createBackendPlugin<TOptions extends [options?: object] = []>(config: BackendPluginConfig | ((...params: TOptions) => BackendPluginConfig)): (...params: TOptions) => BackendFeature;
110
247
 
111
248
  /** @public */
112
- export declare function createExtensionPoint<T>(options: {
113
- id: string;
114
- }): ExtensionPoint<T>;
249
+ export declare function createExtensionPoint<T>(config: ExtensionPointConfig): ExtensionPoint<T>;
115
250
 
116
251
  /**
252
+ * Creates a root scoped service factory without options.
253
+ *
117
254
  * @public
255
+ * @param config - The service factory configuration.
118
256
  */
119
- export declare function createServiceFactory<TService, TScope extends 'root' | 'plugin', TImpl extends TService, TDeps extends {
257
+ export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
120
258
  [name in string]: ServiceRef<unknown>;
121
- }, TOpts extends object | undefined = undefined>(config: {
122
- service: ServiceRef<TService, TScope>;
123
- deps: TDeps;
124
- factory(deps: ServiceRefsToInstances<TDeps, 'root'>, options: TOpts): TScope extends 'root' ? Promise<TImpl> : Promise<(deps: ServiceRefsToInstances<TDeps>) => Promise<TImpl>>;
125
- }): undefined extends TOpts ? (options?: TOpts) => ServiceFactory<TService> : (options: TOpts) => ServiceFactory<TService>;
259
+ }, TOpts extends object | undefined = undefined>(config: RootServiceFactoryConfig<TService, TImpl, TDeps>): () => ServiceFactory<TService>;
126
260
 
127
- /** @public */
128
- export declare function createServiceRef<T>(options: {
129
- id: string;
130
- scope?: 'plugin';
131
- defaultFactory?: (service: ServiceRef<T, 'plugin'>) => Promise<ServiceFactory<T> | (() => ServiceFactory<T>)>;
132
- }): ServiceRef<T, 'plugin'>;
261
+ /**
262
+ * Creates a root scoped service factory with optional options.
263
+ *
264
+ * @public
265
+ * @param config - The service factory configuration.
266
+ */
267
+ export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
268
+ [name in string]: ServiceRef<unknown>;
269
+ }, TOpts extends object | undefined = undefined>(config: (options?: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>): (options?: TOpts) => ServiceFactory<TService>;
133
270
 
134
- /** @public */
135
- export declare function createServiceRef<T>(options: {
136
- id: string;
137
- scope: 'root';
138
- defaultFactory?: (service: ServiceRef<T, 'root'>) => Promise<ServiceFactory<T> | (() => ServiceFactory<T>)>;
139
- }): ServiceRef<T, 'root'>;
271
+ /**
272
+ * Creates a root scoped service factory with required options.
273
+ *
274
+ * @public
275
+ * @param config - The service factory configuration.
276
+ */
277
+ export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
278
+ [name in string]: ServiceRef<unknown>;
279
+ }, TOpts extends object | undefined = undefined>(config: (options: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>): (options: TOpts) => ServiceFactory<TService>;
140
280
 
141
- /** @public */
142
- export declare type DatabaseService = PluginDatabaseManager;
281
+ /**
282
+ * Creates a plugin scoped service factory without options.
283
+ *
284
+ * @public
285
+ * @param config - The service factory configuration.
286
+ */
287
+ export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
288
+ [name in string]: ServiceRef<unknown>;
289
+ }, TContext = undefined, TOpts extends object | undefined = undefined>(config: PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>): () => ServiceFactory<TService>;
290
+
291
+ /**
292
+ * Creates a plugin scoped service factory with optional options.
293
+ *
294
+ * @public
295
+ * @param config - The service factory configuration.
296
+ */
297
+ export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
298
+ [name in string]: ServiceRef<unknown>;
299
+ }, TContext = undefined, TOpts extends object | undefined = undefined>(config: (options?: TOpts) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>): (options?: TOpts) => ServiceFactory<TService>;
300
+
301
+ /**
302
+ * Creates a plugin scoped service factory with required options.
303
+ *
304
+ * @public
305
+ * @param config - The service factory configuration.
306
+ */
307
+ export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
308
+ [name in string]: ServiceRef<unknown>;
309
+ }, TContext = undefined, TOpts extends object | undefined = undefined>(config: PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps> | ((options: TOpts) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>)): (options: TOpts) => ServiceFactory<TService>;
310
+
311
+ /**
312
+ * Creates a new service definition. This overload is used to create plugin scoped services.
313
+ *
314
+ * @public
315
+ */
316
+ export declare function createServiceRef<TService>(config: ServiceRefConfig<TService, 'plugin'>): ServiceRef<TService, 'plugin'>;
317
+
318
+ /**
319
+ * Creates a new service definition. This overload is used to create root scoped services.
320
+ *
321
+ * @public
322
+ */
323
+ export declare function createServiceRef<TService>(config: ServiceRefConfig<TService, 'root'>): ServiceRef<TService, 'root'>;
143
324
 
144
325
  /**
326
+ * Creates a shared backend environment which can be used to create multiple backends
145
327
  * @public
146
328
  */
147
- declare const databaseServiceRef: ServiceRef<PluginDatabaseManager, "plugin">;
329
+ export declare function createSharedEnvironment<TOptions extends [options?: object] = []>(config: SharedBackendEnvironmentConfig | ((...params: TOptions) => SharedBackendEnvironmentConfig)): (...options: TOptions) => SharedBackendEnvironment;
330
+
331
+ /**
332
+ * The DatabaseService manages access to databases that Plugins get.
333
+ *
334
+ * @public
335
+ */
336
+ export declare interface DatabaseService {
337
+ /**
338
+ * getClient provides backend plugins database connections for itself.
339
+ *
340
+ * The purpose of this method is to allow plugins to get isolated data
341
+ * stores so that plugins are discouraged from database integration.
342
+ */
343
+ getClient(): Promise<Knex>;
344
+ /**
345
+ * This property is used to control the behavior of database migrations.
346
+ */
347
+ migrations?: {
348
+ /**
349
+ * skip database migrations. Useful if connecting to a read-only database.
350
+ *
351
+ * @defaultValue false
352
+ */
353
+ skip?: boolean;
354
+ };
355
+ }
148
356
 
149
357
  /**
150
358
  * The DiscoveryService is used to provide a mechanism for backend
@@ -160,7 +368,7 @@ declare const databaseServiceRef: ServiceRef<PluginDatabaseManager, "plugin">;
160
368
  *
161
369
  * @public
162
370
  */
163
- export declare type DiscoveryService = {
371
+ export declare interface DiscoveryService {
164
372
  /**
165
373
  * Returns the internal HTTP base URL for a given plugin, without a trailing slash.
166
374
  *
@@ -191,12 +399,7 @@ export declare type DiscoveryService = {
191
399
  * like `https://backstage.example.com/api/catalog`
192
400
  */
193
401
  getExternalBaseUrl(pluginId: string): Promise<string>;
194
- };
195
-
196
- /**
197
- * @public
198
- */
199
- declare const discoveryServiceRef: ServiceRef<DiscoveryService, "plugin">;
402
+ }
200
403
 
201
404
  /**
202
405
  * TODO
@@ -214,6 +417,11 @@ export declare type ExtensionPoint<T> = {
214
417
  $$ref: 'extension-point';
215
418
  };
216
419
 
420
+ /** @public */
421
+ export declare interface ExtensionPointConfig {
422
+ id: string;
423
+ }
424
+
217
425
  /**
218
426
  * @public
219
427
  */
@@ -221,10 +429,9 @@ export declare interface HttpRouterService {
221
429
  use(handler: Handler): void;
222
430
  }
223
431
 
224
- /**
225
- * @public
226
- */
227
- declare const httpRouterServiceRef: ServiceRef<HttpRouterService, "plugin">;
432
+ /** @public */
433
+ export declare interface IdentityService extends IdentityApi {
434
+ }
228
435
 
229
436
  /**
230
437
  * @public
@@ -236,21 +443,20 @@ export declare interface LifecycleService {
236
443
  addShutdownHook(options: LifecycleServiceShutdownHook): void;
237
444
  }
238
445
 
239
- /**
240
- * @public
241
- */
242
- declare const lifecycleServiceRef: ServiceRef<LifecycleService, "plugin">;
243
-
244
446
  /**
245
447
  * @public
246
448
  **/
247
449
  export declare type LifecycleServiceShutdownHook = {
248
450
  fn: () => void | Promise<void>;
249
- /** Labels to help identify the shutdown hook */
250
- labels?: Record<string, string>;
451
+ /**
452
+ * Optional {@link LoggerService} that will be used for logging instead of the default logger.
453
+ */
454
+ logger?: LoggerService;
251
455
  };
252
456
 
253
457
  /**
458
+ * A service that provides a logging facility.
459
+ *
254
460
  * @public
255
461
  */
256
462
  export declare interface LoggerService {
@@ -261,14 +467,6 @@ export declare interface LoggerService {
261
467
  child(meta: LogMeta): LoggerService;
262
468
  }
263
469
 
264
- /**
265
- * @public
266
- */
267
- declare const loggerServiceRef: ServiceRef<LoggerService, "plugin">;
268
-
269
- /** @public */
270
- export declare function loggerToWinstonLogger(logger: LoggerService, opts?: TransportStreamOptions): Logger;
271
-
272
470
  /**
273
471
  * @public
274
472
  */
@@ -277,12 +475,8 @@ export declare type LogMeta = {
277
475
  };
278
476
 
279
477
  /** @public */
280
- export declare type PermissionsService = PermissionEvaluator | PermissionAuthorizer;
281
-
282
- /**
283
- * @public
284
- */
285
- declare const permissionsServiceRef: ServiceRef<PermissionsService, "plugin">;
478
+ export declare interface PermissionsService extends PermissionEvaluator {
479
+ }
286
480
 
287
481
  /**
288
482
  * @public
@@ -291,10 +485,15 @@ export declare interface PluginMetadataService {
291
485
  getId(): string;
292
486
  }
293
487
 
294
- /**
295
- * @public
296
- */
297
- declare const pluginMetadataServiceRef: ServiceRef<PluginMetadataService, "plugin">;
488
+ /** @public */
489
+ export declare interface PluginServiceFactoryConfig<TService, TContext, TImpl extends TService, TDeps extends {
490
+ [name in string]: ServiceRef<unknown>;
491
+ }> {
492
+ service: ServiceRef<TService, 'plugin'>;
493
+ deps: TDeps;
494
+ createRootContext?(deps: ServiceRefsToInstances<TDeps, 'root'>): TContext | Promise<TContext>;
495
+ factory(deps: ServiceRefsToInstances<TDeps>, context: TContext): TImpl | Promise<TImpl>;
496
+ }
298
497
 
299
498
  /**
300
499
  * An options object for {@link UrlReaderService.readTree} operations.
@@ -469,29 +668,37 @@ export declare type ReadUrlResponse = {
469
668
  etag?: string;
470
669
  };
471
670
 
472
- /** @public */
473
- export declare type RootLifecycleService = LifecycleService;
474
-
475
671
  /**
476
672
  * @public
477
673
  */
478
- declare const rootLifecycleServiceRef: ServiceRef<LifecycleService, "root">;
674
+ export declare interface RootHttpRouterService {
675
+ /**
676
+ * Registers a handler at the root of the backend router.
677
+ * The path is required and may not be empty.
678
+ */
679
+ use(path: string, handler: Handler): void;
680
+ }
479
681
 
480
682
  /** @public */
481
- export declare type RootLoggerService = LoggerService;
683
+ export declare interface RootLifecycleService extends LifecycleService {
684
+ }
482
685
 
483
- /**
484
- * @public
485
- */
486
- declare const rootLoggerServiceRef: ServiceRef<LoggerService, "root">;
686
+ /** @public */
687
+ export declare interface RootLoggerService extends LoggerService {
688
+ }
487
689
 
488
690
  /** @public */
489
- export declare type SchedulerService = PluginTaskScheduler;
691
+ export declare interface RootServiceFactoryConfig<TService, TImpl extends TService, TDeps extends {
692
+ [name in string]: ServiceRef<unknown>;
693
+ }> {
694
+ service: ServiceRef<TService, 'root'>;
695
+ deps: TDeps;
696
+ factory(deps: ServiceRefsToInstances<TDeps, 'root'>): TImpl | Promise<TImpl>;
697
+ }
490
698
 
491
- /**
492
- * @public
493
- */
494
- declare const schedulerServiceRef: ServiceRef<PluginTaskScheduler, "plugin">;
699
+ /** @public */
700
+ export declare interface SchedulerService extends PluginTaskScheduler {
701
+ }
495
702
 
496
703
  /**
497
704
  * An options object for search operations.
@@ -569,13 +776,21 @@ export declare type ServiceFactory<TService = unknown> = {
569
776
  deps: {
570
777
  [key in string]: ServiceRef<unknown>;
571
778
  };
572
- factory(deps: {
779
+ createRootContext?(deps: {
573
780
  [key in string]: unknown;
574
- }): Promise<(deps: {
781
+ }): Promise<unknown>;
782
+ factory(deps: {
575
783
  [key in string]: unknown;
576
- }) => Promise<TService>>;
784
+ }, context: unknown): Promise<TService>;
577
785
  };
578
786
 
787
+ /**
788
+ * Represents either a {@link ServiceFactory} or a function that returns one.
789
+ *
790
+ * @public
791
+ */
792
+ export declare type ServiceFactoryOrFunction<TService = unknown> = ServiceFactory<TService> | (() => ServiceFactory<TService>);
793
+
579
794
  /**
580
795
  * TODO
581
796
  *
@@ -602,22 +817,56 @@ export declare type ServiceRef<TService, TScope extends 'root' | 'plugin' = 'roo
602
817
  $$ref: 'service';
603
818
  };
604
819
 
820
+ /** @public */
821
+ export declare interface ServiceRefConfig<TService, TScope extends 'root' | 'plugin'> {
822
+ id: string;
823
+ scope?: TScope;
824
+ defaultFactory?: (service: ServiceRef<TService, TScope>) => Promise<ServiceFactoryOrFunction<TService>>;
825
+ }
826
+
605
827
  /** @ignore */
606
828
  declare type ServiceRefsToInstances<T extends {
607
829
  [key in string]: ServiceRef<unknown>;
608
830
  }, TScope extends 'root' | 'plugin' = 'root' | 'plugin'> = {
609
- [name in {
610
- [key in keyof T]: T[key] extends ServiceRef<unknown, TScope> ? key : never;
611
- }[keyof T]]: T[name] extends ServiceRef<infer TImpl> ? TImpl : never;
831
+ [key in keyof T as T[key]['scope'] extends TScope ? key : never]: T[key]['T'];
612
832
  };
613
833
 
834
+ /**
835
+ * @public
836
+ */
837
+ export declare interface SharedBackendEnvironment {
838
+ $$type: 'SharedBackendEnvironment';
839
+ }
840
+
614
841
  /** @public */
615
- export declare type TokenManagerService = TokenManager;
842
+ export declare interface SharedBackendEnvironmentConfig {
843
+ services?: ServiceFactoryOrFunction[];
844
+ }
616
845
 
617
846
  /**
847
+ * Interface for creating and validating tokens.
848
+ *
618
849
  * @public
619
850
  */
620
- declare const tokenManagerServiceRef: ServiceRef<TokenManager, "plugin">;
851
+ export declare interface TokenManagerService {
852
+ /**
853
+ * Fetches a valid token.
854
+ *
855
+ * @remarks
856
+ *
857
+ * Tokens are valid for roughly one hour; the actual deadline is set in the
858
+ * payload `exp` claim. Never hold on to tokens for reuse; always ask for a
859
+ * new one for each outgoing request. This ensures that you always get a
860
+ * valid, fresh one.
861
+ */
862
+ getToken(): Promise<{
863
+ token: string;
864
+ }>;
865
+ /**
866
+ * Validates a given token.
867
+ */
868
+ authenticate(token: string): Promise<void>;
869
+ }
621
870
 
622
871
  /** @public */
623
872
  export declare type TypesToServiceRef<T> = {
@@ -629,7 +878,7 @@ export declare type TypesToServiceRef<T> = {
629
878
  *
630
879
  * @public
631
880
  */
632
- export declare type UrlReaderService = {
881
+ export declare interface UrlReaderService {
633
882
  /**
634
883
  * Reads a single file and return its content.
635
884
  */
@@ -642,11 +891,6 @@ export declare type UrlReaderService = {
642
891
  * Searches for a file in a tree using a glob pattern.
643
892
  */
644
893
  search(url: string, options?: SearchOptions): Promise<SearchResponse>;
645
- };
646
-
647
- /**
648
- * @public
649
- */
650
- declare const urlReaderServiceRef: ServiceRef<UrlReaderService, "plugin">;
894
+ }
651
895
 
652
896
  export { }