@backstage/backend-plugin-api 0.3.2-next.1 → 0.4.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/CHANGELOG.md +49 -0
- package/README.md +5 -4
- package/alpha/package.json +1 -1
- package/dist/index.alpha.d.ts +45 -104
- package/dist/index.beta.d.ts +45 -104
- package/dist/index.cjs.js +108 -29
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +45 -104
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { Config } from '@backstage/config';
|
|
10
10
|
import { Handler } from 'express';
|
|
11
11
|
import { IdentityApi } from '@backstage/plugin-auth-node';
|
|
12
|
+
import { JsonObject } from '@backstage/types';
|
|
12
13
|
import { JsonValue } from '@backstage/types';
|
|
13
14
|
import { Knex } from 'knex';
|
|
14
15
|
import { PermissionEvaluator } from '@backstage/plugin-permission-common';
|
|
@@ -17,8 +18,7 @@ import { Readable } from 'stream';
|
|
|
17
18
|
|
|
18
19
|
/** @public */
|
|
19
20
|
export declare interface BackendFeature {
|
|
20
|
-
|
|
21
|
-
register(reg: BackendRegistrationPoints): void;
|
|
21
|
+
$$type: '@backstage/BackendFeature';
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/**
|
|
@@ -71,7 +71,7 @@ export declare interface BackendPluginConfig {
|
|
|
71
71
|
*
|
|
72
72
|
* @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}
|
|
73
73
|
*/
|
|
74
|
-
|
|
74
|
+
pluginId: string;
|
|
75
75
|
register(reg: BackendPluginRegistrationPoints): void;
|
|
76
76
|
}
|
|
77
77
|
|
|
@@ -93,54 +93,39 @@ export declare interface BackendPluginRegistrationPoints {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
|
-
*
|
|
97
|
-
* essentially a superset of {@link BackendPluginRegistrationPoints} and
|
|
98
|
-
* {@link BackendModuleRegistrationPoints}.
|
|
99
|
-
*
|
|
100
|
-
* @public
|
|
101
|
-
*/
|
|
102
|
-
export declare interface BackendRegistrationPoints {
|
|
103
|
-
registerExtensionPoint<TExtensionPoint>(ref: ExtensionPoint<TExtensionPoint>, impl: TExtensionPoint): void;
|
|
104
|
-
registerInit<Deps extends {
|
|
105
|
-
[name in string]: unknown;
|
|
106
|
-
}>(options: {
|
|
107
|
-
deps: {
|
|
108
|
-
[name in keyof Deps]: ServiceRef<Deps[name]> | ExtensionPoint<Deps[name]>;
|
|
109
|
-
};
|
|
110
|
-
init(deps: Deps): Promise<void>;
|
|
111
|
-
}): void;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* A pre-configured, storage agnostic cache client suitable for use by
|
|
96
|
+
* A pre-configured, storage agnostic cache service suitable for use by
|
|
116
97
|
* Backstage plugins.
|
|
117
98
|
*
|
|
118
99
|
* @public
|
|
119
100
|
*/
|
|
120
|
-
export declare interface
|
|
101
|
+
export declare interface CacheService {
|
|
121
102
|
/**
|
|
122
103
|
* Reads data from a cache store for the given key. If no data was found,
|
|
123
104
|
* returns undefined.
|
|
124
105
|
*/
|
|
125
|
-
get(key: string): Promise<
|
|
106
|
+
get<TValue extends JsonValue>(key: string): Promise<TValue | undefined>;
|
|
126
107
|
/**
|
|
127
108
|
* Writes the given data to a cache store, associated with the given key. An
|
|
128
109
|
* optional TTL may also be provided, otherwise it defaults to the TTL that
|
|
129
110
|
* was provided when the client was instantiated.
|
|
130
111
|
*/
|
|
131
|
-
set(key: string, value: JsonValue, options?:
|
|
112
|
+
set(key: string, value: JsonValue, options?: CacheServiceSetOptions): Promise<void>;
|
|
132
113
|
/**
|
|
133
114
|
* Removes the given key from the cache store.
|
|
134
115
|
*/
|
|
135
116
|
delete(key: string): Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* Creates a new {@link CacheService} instance with the given options.
|
|
119
|
+
*/
|
|
120
|
+
withOptions(options: CacheServiceOptions): CacheService;
|
|
136
121
|
}
|
|
137
122
|
|
|
138
123
|
/**
|
|
139
|
-
* Options
|
|
124
|
+
* Options passed to {@link CacheService.withOptions}.
|
|
140
125
|
*
|
|
141
126
|
* @public
|
|
142
127
|
*/
|
|
143
|
-
export declare type
|
|
128
|
+
export declare type CacheServiceOptions = {
|
|
144
129
|
/**
|
|
145
130
|
* An optional default TTL (in milliseconds) to be set when getting a client
|
|
146
131
|
* instance. If not provided, data will persist indefinitely by default (or
|
|
@@ -150,11 +135,11 @@ export declare type CacheClientOptions = {
|
|
|
150
135
|
};
|
|
151
136
|
|
|
152
137
|
/**
|
|
153
|
-
* Options passed to {@link
|
|
138
|
+
* Options passed to {@link CacheService.set}.
|
|
154
139
|
*
|
|
155
140
|
* @public
|
|
156
141
|
*/
|
|
157
|
-
export declare type
|
|
142
|
+
export declare type CacheServiceSetOptions = {
|
|
158
143
|
/**
|
|
159
144
|
* Optional TTL in milliseconds. Defaults to the TTL provided when the client
|
|
160
145
|
* was set up (or no TTL if none are provided).
|
|
@@ -162,24 +147,6 @@ export declare type CacheClientSetOptions = {
|
|
|
162
147
|
ttl?: number;
|
|
163
148
|
};
|
|
164
149
|
|
|
165
|
-
/**
|
|
166
|
-
* Manages access to cache stores that plugins get.
|
|
167
|
-
*
|
|
168
|
-
* @public
|
|
169
|
-
*/
|
|
170
|
-
export declare interface CacheService {
|
|
171
|
-
/**
|
|
172
|
-
* Provides backend plugins cache connections for themselves.
|
|
173
|
-
*
|
|
174
|
-
* @remarks
|
|
175
|
-
*
|
|
176
|
-
* The purpose of this method is to allow plugins to get isolated data stores
|
|
177
|
-
* so that plugins are discouraged from cache-level integration and/or cache
|
|
178
|
-
* key collisions.
|
|
179
|
-
*/
|
|
180
|
-
getClient: (options?: CacheClientOptions) => CacheClient;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
150
|
/**
|
|
184
151
|
* @public
|
|
185
152
|
*/
|
|
@@ -324,7 +291,7 @@ export declare function createExtensionPoint<T>(config: ExtensionPointConfig): E
|
|
|
324
291
|
*/
|
|
325
292
|
export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
|
|
326
293
|
[name in string]: ServiceRef<unknown>;
|
|
327
|
-
}, TOpts extends object | undefined = undefined>(config: RootServiceFactoryConfig<TService, TImpl, TDeps>): () => ServiceFactory<TService>;
|
|
294
|
+
}, TOpts extends object | undefined = undefined>(config: RootServiceFactoryConfig<TService, TImpl, TDeps>): () => ServiceFactory<TService, 'root'>;
|
|
328
295
|
|
|
329
296
|
/**
|
|
330
297
|
* Creates a root scoped service factory with optional options.
|
|
@@ -334,7 +301,7 @@ export declare function createServiceFactory<TService, TImpl extends TService, T
|
|
|
334
301
|
*/
|
|
335
302
|
export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
|
|
336
303
|
[name in string]: ServiceRef<unknown>;
|
|
337
|
-
}, TOpts extends object | undefined = undefined>(config: (options?: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>): (options?: TOpts) => ServiceFactory<TService>;
|
|
304
|
+
}, TOpts extends object | undefined = undefined>(config: (options?: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>): (options?: TOpts) => ServiceFactory<TService, 'root'>;
|
|
338
305
|
|
|
339
306
|
/**
|
|
340
307
|
* Creates a root scoped service factory with required options.
|
|
@@ -344,7 +311,7 @@ export declare function createServiceFactory<TService, TImpl extends TService, T
|
|
|
344
311
|
*/
|
|
345
312
|
export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
|
|
346
313
|
[name in string]: ServiceRef<unknown>;
|
|
347
|
-
}, TOpts extends object | undefined = undefined>(config: (options: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>): (options: TOpts) => ServiceFactory<TService>;
|
|
314
|
+
}, TOpts extends object | undefined = undefined>(config: (options: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>): (options: TOpts) => ServiceFactory<TService, 'root'>;
|
|
348
315
|
|
|
349
316
|
/**
|
|
350
317
|
* Creates a plugin scoped service factory without options.
|
|
@@ -354,7 +321,7 @@ export declare function createServiceFactory<TService, TImpl extends TService, T
|
|
|
354
321
|
*/
|
|
355
322
|
export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
|
|
356
323
|
[name in string]: ServiceRef<unknown>;
|
|
357
|
-
}, TContext = undefined, TOpts extends object | undefined = undefined>(config: PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>): () => ServiceFactory<TService>;
|
|
324
|
+
}, TContext = undefined, TOpts extends object | undefined = undefined>(config: PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>): () => ServiceFactory<TService, 'plugin'>;
|
|
358
325
|
|
|
359
326
|
/**
|
|
360
327
|
* Creates a plugin scoped service factory with optional options.
|
|
@@ -364,7 +331,7 @@ export declare function createServiceFactory<TService, TImpl extends TService, T
|
|
|
364
331
|
*/
|
|
365
332
|
export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
|
|
366
333
|
[name in string]: ServiceRef<unknown>;
|
|
367
|
-
}, TContext = undefined, TOpts extends object | undefined = undefined>(config: (options?: TOpts) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>): (options?: TOpts) => ServiceFactory<TService>;
|
|
334
|
+
}, TContext = undefined, TOpts extends object | undefined = undefined>(config: (options?: TOpts) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>): (options?: TOpts) => ServiceFactory<TService, 'plugin'>;
|
|
368
335
|
|
|
369
336
|
/**
|
|
370
337
|
* Creates a plugin scoped service factory with required options.
|
|
@@ -374,7 +341,7 @@ export declare function createServiceFactory<TService, TImpl extends TService, T
|
|
|
374
341
|
*/
|
|
375
342
|
export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
|
|
376
343
|
[name in string]: ServiceRef<unknown>;
|
|
377
|
-
}, TContext = undefined, TOpts extends object | undefined = undefined>(config: PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps> | ((options: TOpts) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>)): (options: TOpts) => ServiceFactory<TService>;
|
|
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'>;
|
|
378
345
|
|
|
379
346
|
/**
|
|
380
347
|
* Creates a new service definition. This overload is used to create plugin scoped services.
|
|
@@ -484,7 +451,7 @@ export declare type ExtensionPoint<T> = {
|
|
|
484
451
|
*/
|
|
485
452
|
T: T;
|
|
486
453
|
toString(): string;
|
|
487
|
-
$$
|
|
454
|
+
$$type: '@backstage/ExtensionPoint';
|
|
488
455
|
};
|
|
489
456
|
|
|
490
457
|
/**
|
|
@@ -516,24 +483,28 @@ export declare interface IdentityService extends IdentityApi {
|
|
|
516
483
|
|
|
517
484
|
/**
|
|
518
485
|
* @public
|
|
519
|
-
|
|
486
|
+
*/
|
|
520
487
|
export declare interface LifecycleService {
|
|
521
488
|
/**
|
|
522
489
|
* Register a function to be called when the backend is shutting down.
|
|
523
490
|
*/
|
|
524
|
-
addShutdownHook(
|
|
491
|
+
addShutdownHook(hook: LifecycleServiceShutdownHook, options?: LifecycleServiceShutdownOptions): void;
|
|
525
492
|
}
|
|
526
493
|
|
|
527
494
|
/**
|
|
528
495
|
* @public
|
|
529
|
-
|
|
530
|
-
export declare type LifecycleServiceShutdownHook =
|
|
531
|
-
|
|
496
|
+
*/
|
|
497
|
+
export declare type LifecycleServiceShutdownHook = () => void | Promise<void>;
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* @public
|
|
501
|
+
*/
|
|
502
|
+
export declare interface LifecycleServiceShutdownOptions {
|
|
532
503
|
/**
|
|
533
504
|
* Optional {@link LoggerService} that will be used for logging instead of the default logger.
|
|
534
505
|
*/
|
|
535
506
|
logger?: LoggerService;
|
|
536
|
-
}
|
|
507
|
+
}
|
|
537
508
|
|
|
538
509
|
/**
|
|
539
510
|
* A service that provides a logging facility.
|
|
@@ -541,20 +512,13 @@ export declare type LifecycleServiceShutdownHook = {
|
|
|
541
512
|
* @public
|
|
542
513
|
*/
|
|
543
514
|
export declare interface LoggerService {
|
|
544
|
-
error(message: string, meta?: Error |
|
|
545
|
-
warn(message: string, meta?: Error |
|
|
546
|
-
info(message: string, meta?: Error |
|
|
547
|
-
debug(message: string, meta?: Error |
|
|
548
|
-
child(meta:
|
|
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;
|
|
549
520
|
}
|
|
550
521
|
|
|
551
|
-
/**
|
|
552
|
-
* @public
|
|
553
|
-
*/
|
|
554
|
-
export declare type LogMeta = {
|
|
555
|
-
[name: string]: unknown;
|
|
556
|
-
};
|
|
557
|
-
|
|
558
522
|
/** @public */
|
|
559
523
|
export declare interface PermissionsService extends PermissionEvaluator {
|
|
560
524
|
}
|
|
@@ -842,35 +806,17 @@ export declare type SearchResponseFile = {
|
|
|
842
806
|
};
|
|
843
807
|
|
|
844
808
|
/** @public */
|
|
845
|
-
export declare
|
|
846
|
-
|
|
847
|
-
service: ServiceRef<TService,
|
|
848
|
-
|
|
849
|
-
[key in string]: ServiceRef<unknown>;
|
|
850
|
-
};
|
|
851
|
-
factory(deps: {
|
|
852
|
-
[key in string]: unknown;
|
|
853
|
-
}): Promise<TService>;
|
|
854
|
-
} | {
|
|
855
|
-
scope: 'plugin';
|
|
856
|
-
service: ServiceRef<TService, 'plugin'>;
|
|
857
|
-
deps: {
|
|
858
|
-
[key in string]: ServiceRef<unknown>;
|
|
859
|
-
};
|
|
860
|
-
createRootContext?(deps: {
|
|
861
|
-
[key in string]: unknown;
|
|
862
|
-
}): Promise<unknown>;
|
|
863
|
-
factory(deps: {
|
|
864
|
-
[key in string]: unknown;
|
|
865
|
-
}, context: unknown): Promise<TService>;
|
|
866
|
-
};
|
|
809
|
+
export declare interface ServiceFactory<TService = unknown, TScope extends 'plugin' | 'root' = 'plugin' | 'root'> {
|
|
810
|
+
$$type: '@backstage/ServiceFactory';
|
|
811
|
+
service: ServiceRef<TService, TScope>;
|
|
812
|
+
}
|
|
867
813
|
|
|
868
814
|
/**
|
|
869
815
|
* Represents either a {@link ServiceFactory} or a function that returns one.
|
|
870
816
|
*
|
|
871
817
|
* @public
|
|
872
818
|
*/
|
|
873
|
-
export declare type ServiceFactoryOrFunction
|
|
819
|
+
export declare type ServiceFactoryOrFunction = ServiceFactory | (() => ServiceFactory);
|
|
874
820
|
|
|
875
821
|
/**
|
|
876
822
|
* TODO
|
|
@@ -895,14 +841,14 @@ export declare type ServiceRef<TService, TScope extends 'root' | 'plugin' = 'roo
|
|
|
895
841
|
*/
|
|
896
842
|
T: TService;
|
|
897
843
|
toString(): string;
|
|
898
|
-
$$
|
|
844
|
+
$$type: '@backstage/ServiceRef';
|
|
899
845
|
};
|
|
900
846
|
|
|
901
847
|
/** @public */
|
|
902
848
|
export declare interface ServiceRefConfig<TService, TScope extends 'root' | 'plugin'> {
|
|
903
849
|
id: string;
|
|
904
850
|
scope?: TScope;
|
|
905
|
-
defaultFactory?: (service: ServiceRef<TService, TScope>) => Promise<ServiceFactoryOrFunction
|
|
851
|
+
defaultFactory?: (service: ServiceRef<TService, TScope>) => Promise<ServiceFactoryOrFunction>;
|
|
906
852
|
}
|
|
907
853
|
|
|
908
854
|
/** @ignore */
|
|
@@ -918,7 +864,7 @@ declare type ServiceRefsToInstances<T extends {
|
|
|
918
864
|
* @public
|
|
919
865
|
*/
|
|
920
866
|
export declare interface SharedBackendEnvironment {
|
|
921
|
-
$$type: 'SharedBackendEnvironment';
|
|
867
|
+
$$type: '@backstage/SharedBackendEnvironment';
|
|
922
868
|
}
|
|
923
869
|
|
|
924
870
|
/**
|
|
@@ -955,11 +901,6 @@ export declare interface TokenManagerService {
|
|
|
955
901
|
authenticate(token: string): Promise<void>;
|
|
956
902
|
}
|
|
957
903
|
|
|
958
|
-
/** @public */
|
|
959
|
-
export declare type TypesToServiceRef<T> = {
|
|
960
|
-
[key in keyof T]: ServiceRef<T[key]>;
|
|
961
|
-
};
|
|
962
|
-
|
|
963
904
|
/**
|
|
964
905
|
* A generic interface for fetching plain data from URLs.
|
|
965
906
|
*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/backend-plugin-api",
|
|
3
3
|
"description": "Core API used by Backstage backend plugins",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"publishConfig": {
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"start": "backstage-cli package start"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@backstage/backend-tasks": "^0.4.3
|
|
36
|
+
"@backstage/backend-tasks": "^0.4.3",
|
|
37
37
|
"@backstage/config": "^1.0.6",
|
|
38
|
-
"@backstage/plugin-auth-node": "^0.2.11
|
|
38
|
+
"@backstage/plugin-auth-node": "^0.2.11",
|
|
39
39
|
"@backstage/plugin-permission-common": "^0.7.3",
|
|
40
40
|
"@backstage/types": "^1.0.2",
|
|
41
41
|
"@types/express": "^4.17.6",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"knex": "^2.0.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@backstage/cli": "^0.22.2
|
|
46
|
+
"@backstage/cli": "^0.22.2"
|
|
47
47
|
},
|
|
48
48
|
"files": [
|
|
49
49
|
"dist",
|