@backstage/backend-app-api 0.3.0-next.1 → 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.

Potentially problematic release.


This version of @backstage/backend-app-api might be problematic. Click here for more details.

package/dist/index.d.ts CHANGED
@@ -13,11 +13,16 @@ import { CorsOptions } from 'cors';
13
13
  import { ErrorRequestHandler } from 'express';
14
14
  import { Express as Express_2 } from 'express';
15
15
  import { ExtensionPoint } from '@backstage/backend-plugin-api';
16
+ import { Format } from 'logform';
17
+ import { Handler } from 'express';
16
18
  import { HelmetOptions } from 'helmet';
17
19
  import * as http from 'http';
18
20
  import { HttpRouterService } from '@backstage/backend-plugin-api';
21
+ import { IdentityService } from '@backstage/backend-plugin-api';
19
22
  import { LifecycleService } from '@backstage/backend-plugin-api';
23
+ import { LoadConfigOptionsRemote } from '@backstage/config-loader';
20
24
  import { LoggerService } from '@backstage/backend-plugin-api';
25
+ import { LogMeta } from '@backstage/backend-plugin-api';
21
26
  import { PermissionsService } from '@backstage/backend-plugin-api';
22
27
  import { PluginCacheManager } from '@backstage/backend-common';
23
28
  import { PluginDatabaseManager } from '@backstage/backend-common';
@@ -32,6 +37,7 @@ import { ServiceFactory } from '@backstage/backend-plugin-api';
32
37
  import { ServiceFactoryOrFunction } from '@backstage/backend-plugin-api';
33
38
  import { ServiceRef } from '@backstage/backend-plugin-api';
34
39
  import { TokenManagerService } from '@backstage/backend-plugin-api';
40
+ import { transport } from 'winston';
35
41
  import { UrlReader } from '@backstage/backend-common';
36
42
 
37
43
  /**
@@ -44,10 +50,28 @@ export declare interface Backend {
44
50
  }
45
51
 
46
52
  /** @public */
47
- export declare const cacheFactory: (options?: undefined) => ServiceFactory<PluginCacheManager>;
53
+ export declare const cacheFactory: () => ServiceFactory<PluginCacheManager>;
48
54
 
49
55
  /** @public */
50
- export declare const configFactory: (options?: undefined) => ServiceFactory<ConfigService>;
56
+ export declare const configFactory: () => ServiceFactory<ConfigService>;
57
+
58
+ /** @public */
59
+ export declare interface ConfigFactoryOptions {
60
+ /**
61
+ * Process arguments to use instead of the default `process.argv()`.
62
+ */
63
+ argv?: string[];
64
+ /**
65
+ * Enables and sets options for remote configuration loading.
66
+ */
67
+ remote?: LoadConfigOptionsRemote;
68
+ }
69
+
70
+ /** @public */
71
+ export declare function createConfigSecretEnumerator(options: {
72
+ logger: LoggerService;
73
+ dir?: string;
74
+ }): Promise<(config: Config) => Iterable<string>>;
51
75
 
52
76
  /**
53
77
  * Creates a Node.js HTTP or HTTPS server instance.
@@ -71,10 +95,37 @@ export declare interface CreateSpecializedBackendOptions {
71
95
  }
72
96
 
73
97
  /** @public */
74
- export declare const databaseFactory: (options?: undefined) => ServiceFactory<PluginDatabaseManager>;
98
+ export declare const databaseFactory: () => ServiceFactory<PluginDatabaseManager>;
99
+
100
+ /**
101
+ * The default implementation of the {@link @backstage/backend-plugin-api#RootHttpRouterService} interface for
102
+ * {@link @backstage/backend-plugin-api#coreServices.rootHttpRouter}.
103
+ *
104
+ * @public
105
+ */
106
+ export declare class DefaultRootHttpRouter implements RootHttpRouterService {
107
+ #private;
108
+ static create(options?: DefaultRootHttpRouterOptions): DefaultRootHttpRouter;
109
+ private constructor();
110
+ use(path: string, handler: Handler): void;
111
+ handler(): Handler;
112
+ }
113
+
114
+ /**
115
+ * Options for the {@link DefaultRootHttpRouter} class.
116
+ *
117
+ * @public
118
+ */
119
+ export declare interface DefaultRootHttpRouterOptions {
120
+ /**
121
+ * The path to forward all unmatched requests to. Defaults to '/api/app' if
122
+ * not given. Disables index path behavior if false is given.
123
+ */
124
+ indexPath?: string | false;
125
+ }
75
126
 
76
127
  /** @public */
77
- export declare const discoveryFactory: (options?: undefined) => ServiceFactory<PluginEndpointDiscovery>;
128
+ export declare const discoveryFactory: () => ServiceFactory<PluginEndpointDiscovery>;
78
129
 
79
130
  /**
80
131
  * An HTTP server extended with utility methods.
@@ -93,12 +144,12 @@ export declare const httpRouterFactory: (options?: HttpRouterFactoryOptions | un
93
144
  /**
94
145
  * @public
95
146
  */
96
- export declare type HttpRouterFactoryOptions = {
147
+ export declare interface HttpRouterFactoryOptions {
97
148
  /**
98
149
  * A callback used to generate the path for each plugin, defaults to `/api/{pluginId}`.
99
150
  */
100
151
  getPath(pluginId: string): string;
101
- };
152
+ }
102
153
 
103
154
  /**
104
155
  * Options for configuring HTTPS for an HTTP server.
@@ -129,13 +180,42 @@ export declare type HttpServerOptions = {
129
180
  };
130
181
  };
131
182
 
183
+ /** @public */
184
+ export declare const identityFactory: (options?: IdentityFactoryOptions | undefined) => ServiceFactory<IdentityService>;
185
+
186
+ /**
187
+ * An identity client options object which allows extra configurations
188
+ *
189
+ * @public
190
+ */
191
+ export declare type IdentityFactoryOptions = {
192
+ issuer?: string;
193
+ /** JWS "alg" (Algorithm) Header Parameter values. Defaults to an array containing just ES256.
194
+ * More info on supported algorithms: https://github.com/panva/jose */
195
+ algorithms?: string[];
196
+ };
197
+
132
198
  /**
133
199
  * Allows plugins to register shutdown hooks that are run when the process is about to exit.
134
200
  * @public */
135
- export declare const lifecycleFactory: (options?: undefined) => ServiceFactory<LifecycleService>;
201
+ export declare const lifecycleFactory: () => ServiceFactory<LifecycleService>;
202
+
203
+ /**
204
+ * Load configuration for a Backend.
205
+ *
206
+ * This function should only be called once, during the initialization of the backend.
207
+ *
208
+ * @public
209
+ */
210
+ export declare function loadBackendConfig(options: {
211
+ remote?: LoadConfigOptionsRemote;
212
+ argv: string[];
213
+ }): Promise<{
214
+ config: Config;
215
+ }>;
136
216
 
137
217
  /** @public */
138
- export declare const loggerFactory: (options?: undefined) => ServiceFactory<LoggerService>;
218
+ export declare const loggerFactory: () => ServiceFactory<LoggerService>;
139
219
 
140
220
  /**
141
221
  * A utility to configure common middleware.
@@ -261,7 +341,7 @@ export declare interface MiddlewareFactoryOptions {
261
341
  }
262
342
 
263
343
  /** @public */
264
- export declare const permissionsFactory: (options?: undefined) => ServiceFactory<PermissionsService>;
344
+ export declare const permissionsFactory: () => ServiceFactory<PermissionsService>;
265
345
 
266
346
  /**
267
347
  * Attempts to read a CORS options object from the backend configuration object.
@@ -320,14 +400,15 @@ export declare interface RootHttpRouterConfigureOptions {
320
400
  }
321
401
 
322
402
  /** @public */
323
- export declare const rootHttpRouterFactory: (options?: RootHttpRouterFactoryOptions | undefined) => ServiceFactory<RootHttpRouterService>;
403
+ export declare const rootHttpRouterFactory: () => ServiceFactory<RootHttpRouterService>;
324
404
 
325
405
  /**
326
406
  * @public
327
407
  */
328
408
  export declare type RootHttpRouterFactoryOptions = {
329
409
  /**
330
- * The path to forward all unmatched requests to. Defaults to '/api/app'
410
+ * The path to forward all unmatched requests to. Defaults to '/api/app' if
411
+ * not given. Disables index path behavior if false is given.
331
412
  */
332
413
  indexPath?: string | false;
333
414
  configure?(options: RootHttpRouterConfigureOptions): void;
@@ -336,13 +417,13 @@ export declare type RootHttpRouterFactoryOptions = {
336
417
  /**
337
418
  * Allows plugins to register shutdown hooks that are run when the process is about to exit.
338
419
  * @public */
339
- export declare const rootLifecycleFactory: (options?: undefined) => ServiceFactory<RootLifecycleService>;
420
+ export declare const rootLifecycleFactory: () => ServiceFactory<RootLifecycleService>;
340
421
 
341
422
  /** @public */
342
- export declare const rootLoggerFactory: (options?: undefined) => ServiceFactory<RootLoggerService>;
423
+ export declare const rootLoggerFactory: () => ServiceFactory<RootLoggerService>;
343
424
 
344
425
  /** @public */
345
- export declare const schedulerFactory: (options?: undefined) => ServiceFactory<SchedulerService>;
426
+ export declare const schedulerFactory: () => ServiceFactory<SchedulerService>;
346
427
 
347
428
  /**
348
429
  * @public
@@ -350,9 +431,50 @@ export declare const schedulerFactory: (options?: undefined) => ServiceFactory<S
350
431
  export declare type ServiceOrExtensionPoint<T = unknown> = ExtensionPoint<T> | ServiceRef<T>;
351
432
 
352
433
  /** @public */
353
- export declare const tokenManagerFactory: (options?: undefined) => ServiceFactory<TokenManagerService>;
434
+ export declare const tokenManagerFactory: () => ServiceFactory<TokenManagerService>;
354
435
 
355
436
  /** @public */
356
- export declare const urlReaderFactory: (options?: undefined) => ServiceFactory<UrlReader>;
437
+ export declare const urlReaderFactory: () => ServiceFactory<UrlReader>;
438
+
439
+ /**
440
+ * A {@link @backstage/backend-plugin-api#LoggerService} implementation based on winston.
441
+ *
442
+ * @public
443
+ */
444
+ export declare class WinstonLogger implements RootLoggerService {
445
+ #private;
446
+ /**
447
+ * Creates a {@link WinstonLogger} instance.
448
+ */
449
+ static create(options: WinstonLoggerOptions): WinstonLogger;
450
+ /**
451
+ * Creates a winston log formatter for redacting secrets.
452
+ */
453
+ static redacter(): {
454
+ format: Format;
455
+ add: (redactions: Iterable<string>) => void;
456
+ };
457
+ /**
458
+ * Creates a pretty printed winston log formatter.
459
+ */
460
+ static colorFormat(): Format;
461
+ private constructor();
462
+ error(message: string, meta?: LogMeta): void;
463
+ warn(message: string, meta?: LogMeta): void;
464
+ info(message: string, meta?: LogMeta): void;
465
+ debug(message: string, meta?: LogMeta): void;
466
+ child(meta: LogMeta): LoggerService;
467
+ addRedactions(redactions: Iterable<string>): void;
468
+ }
469
+
470
+ /**
471
+ * @public
472
+ */
473
+ export declare interface WinstonLoggerOptions {
474
+ meta?: LogMeta;
475
+ level: string;
476
+ format: Format;
477
+ transports: transport[];
478
+ }
357
479
 
358
480
  export { }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@backstage/backend-app-api",
3
3
  "description": "Core API used by Backstage backend apps",
4
- "version": "0.3.0-next.1",
4
+ "version": "0.3.0",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "publishConfig": {
@@ -33,12 +33,17 @@
33
33
  "start": "backstage-cli package start"
34
34
  },
35
35
  "dependencies": {
36
- "@backstage/backend-common": "^0.18.0-next.1",
37
- "@backstage/backend-plugin-api": "^0.3.0-next.1",
38
- "@backstage/backend-tasks": "^0.4.1-next.1",
39
- "@backstage/config": "^1.0.6-next.0",
36
+ "@backstage/backend-common": "^0.18.0",
37
+ "@backstage/backend-plugin-api": "^0.3.0",
38
+ "@backstage/backend-tasks": "^0.4.1",
39
+ "@backstage/cli-common": "^0.1.11",
40
+ "@backstage/config": "^1.0.6",
41
+ "@backstage/config-loader": "^1.1.8",
40
42
  "@backstage/errors": "^1.1.4",
41
- "@backstage/plugin-permission-node": "^0.7.3-next.1",
43
+ "@backstage/plugin-auth-node": "^0.2.9",
44
+ "@backstage/plugin-permission-node": "^0.7.3",
45
+ "@backstage/types": "^1.0.2",
46
+ "@manypkg/get-packages": "^1.1.3",
42
47
  "@types/cors": "^2.8.6",
43
48
  "@types/express": "^4.17.6",
44
49
  "compression": "^1.7.4",
@@ -47,18 +52,23 @@
47
52
  "express-promise-router": "^4.1.0",
48
53
  "fs-extra": "10.1.0",
49
54
  "helmet": "^6.0.0",
55
+ "lodash": "^4.17.21",
56
+ "logform": "^2.3.2",
50
57
  "minimatch": "^5.0.0",
58
+ "minimist": "^1.2.5",
51
59
  "morgan": "^1.10.0",
52
60
  "node-forge": "^1.3.1",
53
61
  "selfsigned": "^2.0.0",
54
62
  "stoppable": "^1.1.0",
55
- "winston": "^3.2.1"
63
+ "winston": "^3.2.1",
64
+ "winston-transport": "^4.5.0"
56
65
  },
57
66
  "devDependencies": {
58
- "@backstage/cli": "^0.22.1-next.2",
67
+ "@backstage/cli": "^0.22.1",
59
68
  "@types/compression": "^1.7.0",
60
69
  "@types/fs-extra": "^9.0.3",
61
70
  "@types/http-errors": "^2.0.0",
71
+ "@types/minimist": "^1.2.0",
62
72
  "@types/morgan": "^1.9.0",
63
73
  "@types/node-forge": "^1.3.0",
64
74
  "@types/stoppable": "^1.1.0",