@backstage/backend-test-utils 0.1.34 → 0.1.35-next.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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # @backstage/backend-test-utils
2
2
 
3
+ ## 0.1.35-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 928a12a9b3: Internal refactor of `/alpha` exports.
8
+ - Updated dependencies
9
+ - @backstage/backend-plugin-api@0.4.1-next.0
10
+ - @backstage/backend-app-api@0.4.1-next.0
11
+ - @backstage/backend-common@0.18.3-next.0
12
+ - @backstage/config@1.0.6
13
+ - @backstage/types@1.0.2
14
+ - @backstage/plugin-auth-node@0.2.12-next.0
15
+
3
16
  ## 0.1.34
4
17
 
5
18
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,138 +1,19 @@
1
- /**
2
- * Test helpers library for Backstage backends
3
- *
4
- * @packageDocumentation
5
- */
6
-
7
- import { Backend } from '@backstage/backend-app-api';
8
- import { BackendFeature } from '@backstage/backend-plugin-api';
9
- import { CacheService } from '@backstage/backend-plugin-api';
10
- import { ConfigService } from '@backstage/backend-plugin-api';
11
- import { DatabaseService } from '@backstage/backend-plugin-api';
12
- import { ExtendedHttpServer } from '@backstage/backend-app-api';
13
- import { ExtensionPoint } from '@backstage/backend-plugin-api';
14
- import { HttpRouterFactoryOptions } from '@backstage/backend-app-api';
15
- import { HttpRouterService } from '@backstage/backend-plugin-api';
16
- import { IdentityService } from '@backstage/backend-plugin-api';
17
- import { JsonObject } from '@backstage/types';
18
1
  import { Knex } from 'knex';
19
- import { LifecycleService } from '@backstage/backend-plugin-api';
20
- import { LoggerService } from '@backstage/backend-plugin-api';
21
- import { PermissionsService } from '@backstage/backend-plugin-api';
22
- import { RootLifecycleService } from '@backstage/backend-plugin-api';
23
- import { SchedulerService } from '@backstage/backend-plugin-api';
24
- import { ServiceFactory } from '@backstage/backend-plugin-api';
25
- import { ServiceRef } from '@backstage/backend-plugin-api';
26
- import { TokenManagerService } from '@backstage/backend-plugin-api';
27
- import { UrlReaderService } from '@backstage/backend-plugin-api';
28
-
29
- /** @public */
30
- export declare function isDockerDisabledForTests(): boolean;
31
-
32
- /**
33
- * @public
34
- */
35
- export declare namespace mockServices {
36
- export function config(options?: config.Options): ConfigService;
37
- export namespace config {
38
- export type Options = {
39
- data?: JsonObject;
40
- };
41
- const factory: (options?: Options | undefined) => ServiceFactory<ConfigService, "root">;
42
- }
43
- export function rootLogger(options?: rootLogger.Options): LoggerService;
44
- export namespace rootLogger {
45
- export type Options = {
46
- level?: 'none' | 'error' | 'warn' | 'info' | 'debug';
47
- };
48
- const factory: (options?: Options | undefined) => ServiceFactory<LoggerService, "root">;
49
- }
50
- export function tokenManager(): TokenManagerService;
51
- export namespace tokenManager {
52
- const factory: () => ServiceFactory<TokenManagerService, "plugin">;
53
- }
54
- export function identity(): IdentityService;
55
- export namespace identity {
56
- const factory: () => ServiceFactory<IdentityService, "plugin">;
57
- }
58
- export namespace cache {
59
- const factory: () => ServiceFactory<CacheService, "plugin">;
60
- }
61
- export namespace database {
62
- const factory: () => ServiceFactory<DatabaseService, "plugin">;
63
- }
64
- export namespace httpRouter {
65
- const factory: (options?: HttpRouterFactoryOptions | undefined) => ServiceFactory<HttpRouterService, "plugin">;
66
- }
67
- export namespace lifecycle {
68
- const factory: () => ServiceFactory<LifecycleService, "plugin">;
69
- }
70
- export namespace logger {
71
- const factory: () => ServiceFactory<LoggerService, "plugin">;
72
- }
73
- export namespace permissions {
74
- const factory: () => ServiceFactory<PermissionsService, "plugin">;
75
- }
76
- export namespace rootLifecycle {
77
- const factory: () => ServiceFactory<RootLifecycleService, "root">;
78
- }
79
- export namespace scheduler {
80
- const factory: () => ServiceFactory<SchedulerService, "plugin">;
81
- }
82
- export namespace urlReader {
83
- const factory: () => ServiceFactory<UrlReaderService, "plugin">;
84
- }
85
- }
86
-
87
- /**
88
- * Sets up handlers for request mocking
89
- * @public
90
- * @param worker - service worker
91
- */
92
- export declare function setupRequestMockHandlers(worker: {
93
- listen: (t: any) => void;
94
- close: () => void;
95
- resetHandlers: () => void;
96
- }): void;
97
-
98
- /** @public */
99
- export declare function startTestBackend<TServices extends any[], TExtensionPoints extends any[]>(options: TestBackendOptions<TServices, TExtensionPoints>): Promise<TestBackend>;
100
-
101
- /** @public */
102
- export declare interface TestBackend extends Backend {
103
- /**
104
- * Provides access to the underling HTTP server for use with utilities
105
- * such as `supertest`.
106
- *
107
- * If the root http router service has been replaced, this will throw an error.
108
- */
109
- readonly server: ExtendedHttpServer;
110
- }
2
+ import * as _backstage_backend_app_api from '@backstage/backend-app-api';
3
+ import { Backend, ExtendedHttpServer } from '@backstage/backend-app-api';
4
+ import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
5
+ import { ServiceFactory, ServiceRef, ExtensionPoint, BackendFeature, ConfigService, LoggerService, TokenManagerService, IdentityService } from '@backstage/backend-plugin-api';
6
+ import { JsonObject } from '@backstage/types';
111
7
 
112
8
  /** @public */
113
- export declare interface TestBackendOptions<TServices extends any[], TExtensionPoints extends any[]> {
114
- services?: readonly [
115
- ...{
116
- [index in keyof TServices]: ServiceFactory<TServices[index]> | (() => ServiceFactory<TServices[index]>) | [ServiceRef<TServices[index]>, Partial<TServices[index]>];
117
- }
118
- ];
119
- extensionPoints?: readonly [
120
- ...{
121
- [index in keyof TExtensionPoints]: [
122
- ExtensionPoint<TExtensionPoints[index]>,
123
- Partial<TExtensionPoints[index]>
124
- ];
125
- }
126
- ];
127
- features?: BackendFeature[];
128
- }
9
+ declare function isDockerDisabledForTests(): boolean;
129
10
 
130
11
  /**
131
12
  * The possible databases to test against.
132
13
  *
133
14
  * @public
134
15
  */
135
- export declare type TestDatabaseId = 'POSTGRES_13' | 'POSTGRES_9' | 'MYSQL_8' | 'SQLITE_3';
16
+ declare type TestDatabaseId = 'POSTGRES_13' | 'POSTGRES_9' | 'MYSQL_8' | 'SQLITE_3';
136
17
 
137
18
  /**
138
19
  * Encapsulates the creation of ephemeral test database instances for use
@@ -140,7 +21,7 @@ export declare type TestDatabaseId = 'POSTGRES_13' | 'POSTGRES_9' | 'MYSQL_8' |
140
21
  *
141
22
  * @public
142
23
  */
143
- export declare class TestDatabases {
24
+ declare class TestDatabases {
144
25
  private readonly instanceById;
145
26
  private readonly supportedIds;
146
27
  /**
@@ -176,4 +57,100 @@ export declare class TestDatabases {
176
57
  private shutdown;
177
58
  }
178
59
 
179
- export { }
60
+ /**
61
+ * Sets up handlers for request mocking
62
+ * @public
63
+ * @param worker - service worker
64
+ */
65
+ declare function setupRequestMockHandlers(worker: {
66
+ listen: (t: any) => void;
67
+ close: () => void;
68
+ resetHandlers: () => void;
69
+ }): void;
70
+
71
+ /** @public */
72
+ interface TestBackendOptions<TServices extends any[], TExtensionPoints extends any[]> {
73
+ services?: readonly [
74
+ ...{
75
+ [index in keyof TServices]: ServiceFactory<TServices[index]> | (() => ServiceFactory<TServices[index]>) | [ServiceRef<TServices[index]>, Partial<TServices[index]>];
76
+ }
77
+ ];
78
+ extensionPoints?: readonly [
79
+ ...{
80
+ [index in keyof TExtensionPoints]: [
81
+ ExtensionPoint<TExtensionPoints[index]>,
82
+ Partial<TExtensionPoints[index]>
83
+ ];
84
+ }
85
+ ];
86
+ features?: BackendFeature[];
87
+ }
88
+ /** @public */
89
+ interface TestBackend extends Backend {
90
+ /**
91
+ * Provides access to the underling HTTP server for use with utilities
92
+ * such as `supertest`.
93
+ *
94
+ * If the root http router service has been replaced, this will throw an error.
95
+ */
96
+ readonly server: ExtendedHttpServer;
97
+ }
98
+ /** @public */
99
+ declare function startTestBackend<TServices extends any[], TExtensionPoints extends any[]>(options: TestBackendOptions<TServices, TExtensionPoints>): Promise<TestBackend>;
100
+
101
+ /**
102
+ * @public
103
+ */
104
+ declare namespace mockServices {
105
+ function config(options?: config.Options): ConfigService;
106
+ namespace config {
107
+ type Options = {
108
+ data?: JsonObject;
109
+ };
110
+ const factory: (options?: Options | undefined) => ServiceFactory<ConfigService, "root">;
111
+ }
112
+ function rootLogger(options?: rootLogger.Options): LoggerService;
113
+ namespace rootLogger {
114
+ type Options = {
115
+ level?: 'none' | 'error' | 'warn' | 'info' | 'debug';
116
+ };
117
+ const factory: (options?: Options | undefined) => ServiceFactory<LoggerService, "root">;
118
+ }
119
+ function tokenManager(): TokenManagerService;
120
+ namespace tokenManager {
121
+ const factory: () => ServiceFactory<TokenManagerService, "plugin">;
122
+ }
123
+ function identity(): IdentityService;
124
+ namespace identity {
125
+ const factory: () => ServiceFactory<IdentityService, "plugin">;
126
+ }
127
+ namespace cache {
128
+ const factory: () => ServiceFactory<_backstage_backend_plugin_api.CacheService, "plugin">;
129
+ }
130
+ namespace database {
131
+ const factory: () => ServiceFactory<_backstage_backend_plugin_api.DatabaseService, "plugin">;
132
+ }
133
+ namespace httpRouter {
134
+ const factory: (options?: _backstage_backend_app_api.HttpRouterFactoryOptions | undefined) => ServiceFactory<_backstage_backend_plugin_api.HttpRouterService, "plugin">;
135
+ }
136
+ namespace lifecycle {
137
+ const factory: () => ServiceFactory<_backstage_backend_plugin_api.LifecycleService, "plugin">;
138
+ }
139
+ namespace logger {
140
+ const factory: () => ServiceFactory<LoggerService, "plugin">;
141
+ }
142
+ namespace permissions {
143
+ const factory: () => ServiceFactory<_backstage_backend_plugin_api.PermissionsService, "plugin">;
144
+ }
145
+ namespace rootLifecycle {
146
+ const factory: () => ServiceFactory<_backstage_backend_plugin_api.RootLifecycleService, "root">;
147
+ }
148
+ namespace scheduler {
149
+ const factory: () => ServiceFactory<_backstage_backend_plugin_api.SchedulerService, "plugin">;
150
+ }
151
+ namespace urlReader {
152
+ const factory: () => ServiceFactory<_backstage_backend_plugin_api.UrlReaderService, "plugin">;
153
+ }
154
+ }
155
+
156
+ export { TestBackend, TestBackendOptions, TestDatabaseId, TestDatabases, isDockerDisabledForTests, mockServices, setupRequestMockHandlers, startTestBackend };
package/package.json CHANGED
@@ -1,14 +1,19 @@
1
1
  {
2
2
  "name": "@backstage/backend-test-utils",
3
3
  "description": "Test helpers library for Backstage backends",
4
- "version": "0.1.34",
5
- "main": "dist/index.cjs.js",
6
- "types": "dist/index.d.ts",
4
+ "version": "0.1.35-next.0",
5
+ "main": "./dist/index.cjs.js",
6
+ "types": "./dist/index.d.ts",
7
7
  "publishConfig": {
8
- "access": "public",
9
- "main": "dist/index.cjs.js",
10
- "types": "dist/index.d.ts",
11
- "alphaTypes": "dist/index.alpha.d.ts"
8
+ "access": "public"
9
+ },
10
+ "exports": {
11
+ ".": {
12
+ "require": "./dist/index.cjs.js",
13
+ "types": "./dist/index.d.ts",
14
+ "default": "./dist/index.cjs.js"
15
+ },
16
+ "./package.json": "./package.json"
12
17
  },
13
18
  "backstage": {
14
19
  "role": "node-library"
@@ -25,7 +30,7 @@
25
30
  ],
26
31
  "license": "Apache-2.0",
27
32
  "scripts": {
28
- "build": "backstage-cli package build --experimental-type-build",
33
+ "build": "backstage-cli package build",
29
34
  "lint": "backstage-cli package lint",
30
35
  "test": "backstage-cli package test",
31
36
  "prepack": "backstage-cli package prepack",
@@ -34,11 +39,11 @@
34
39
  "start": "backstage-cli package start"
35
40
  },
36
41
  "dependencies": {
37
- "@backstage/backend-app-api": "^0.4.0",
38
- "@backstage/backend-common": "^0.18.2",
39
- "@backstage/backend-plugin-api": "^0.4.0",
42
+ "@backstage/backend-app-api": "^0.4.1-next.0",
43
+ "@backstage/backend-common": "^0.18.3-next.0",
44
+ "@backstage/backend-plugin-api": "^0.4.1-next.0",
40
45
  "@backstage/config": "^1.0.6",
41
- "@backstage/plugin-auth-node": "^0.2.11",
46
+ "@backstage/plugin-auth-node": "^0.2.12-next.0",
42
47
  "@backstage/types": "^1.0.2",
43
48
  "better-sqlite3": "^8.0.0",
44
49
  "express": "^4.17.1",
@@ -50,12 +55,11 @@
50
55
  "uuid": "^8.0.0"
51
56
  },
52
57
  "devDependencies": {
53
- "@backstage/cli": "^0.22.2",
58
+ "@backstage/cli": "^0.22.4-next.0",
54
59
  "@types/supertest": "^2.0.8",
55
60
  "supertest": "^6.1.3"
56
61
  },
57
62
  "files": [
58
- "dist",
59
- "alpha"
63
+ "dist"
60
64
  ]
61
65
  }
@@ -1,6 +0,0 @@
1
- {
2
- "name": "@backstage/backend-test-utils",
3
- "version": "0.1.34",
4
- "main": "../dist/index.cjs.js",
5
- "types": "../dist/index.alpha.d.ts"
6
- }
@@ -1,179 +0,0 @@
1
- /**
2
- * Test helpers library for Backstage backends
3
- *
4
- * @packageDocumentation
5
- */
6
-
7
- import { Backend } from '@backstage/backend-app-api';
8
- import { BackendFeature } from '@backstage/backend-plugin-api';
9
- import { CacheService } from '@backstage/backend-plugin-api';
10
- import { ConfigService } from '@backstage/backend-plugin-api';
11
- import { DatabaseService } from '@backstage/backend-plugin-api';
12
- import { ExtendedHttpServer } from '@backstage/backend-app-api';
13
- import { ExtensionPoint } from '@backstage/backend-plugin-api';
14
- import { HttpRouterFactoryOptions } from '@backstage/backend-app-api';
15
- import { HttpRouterService } from '@backstage/backend-plugin-api';
16
- import { IdentityService } from '@backstage/backend-plugin-api';
17
- import { JsonObject } from '@backstage/types';
18
- import { Knex } from 'knex';
19
- import { LifecycleService } from '@backstage/backend-plugin-api';
20
- import { LoggerService } from '@backstage/backend-plugin-api';
21
- import { PermissionsService } from '@backstage/backend-plugin-api';
22
- import { RootLifecycleService } from '@backstage/backend-plugin-api';
23
- import { SchedulerService } from '@backstage/backend-plugin-api';
24
- import { ServiceFactory } from '@backstage/backend-plugin-api';
25
- import { ServiceRef } from '@backstage/backend-plugin-api';
26
- import { TokenManagerService } from '@backstage/backend-plugin-api';
27
- import { UrlReaderService } from '@backstage/backend-plugin-api';
28
-
29
- /** @public */
30
- export declare function isDockerDisabledForTests(): boolean;
31
-
32
- /**
33
- * @public
34
- */
35
- export declare namespace mockServices {
36
- export function config(options?: config.Options): ConfigService;
37
- export namespace config {
38
- export type Options = {
39
- data?: JsonObject;
40
- };
41
- const factory: (options?: Options | undefined) => ServiceFactory<ConfigService, "root">;
42
- }
43
- export function rootLogger(options?: rootLogger.Options): LoggerService;
44
- export namespace rootLogger {
45
- export type Options = {
46
- level?: 'none' | 'error' | 'warn' | 'info' | 'debug';
47
- };
48
- const factory: (options?: Options | undefined) => ServiceFactory<LoggerService, "root">;
49
- }
50
- export function tokenManager(): TokenManagerService;
51
- export namespace tokenManager {
52
- const factory: () => ServiceFactory<TokenManagerService, "plugin">;
53
- }
54
- export function identity(): IdentityService;
55
- export namespace identity {
56
- const factory: () => ServiceFactory<IdentityService, "plugin">;
57
- }
58
- export namespace cache {
59
- const factory: () => ServiceFactory<CacheService, "plugin">;
60
- }
61
- export namespace database {
62
- const factory: () => ServiceFactory<DatabaseService, "plugin">;
63
- }
64
- export namespace httpRouter {
65
- const factory: (options?: HttpRouterFactoryOptions | undefined) => ServiceFactory<HttpRouterService, "plugin">;
66
- }
67
- export namespace lifecycle {
68
- const factory: () => ServiceFactory<LifecycleService, "plugin">;
69
- }
70
- export namespace logger {
71
- const factory: () => ServiceFactory<LoggerService, "plugin">;
72
- }
73
- export namespace permissions {
74
- const factory: () => ServiceFactory<PermissionsService, "plugin">;
75
- }
76
- export namespace rootLifecycle {
77
- const factory: () => ServiceFactory<RootLifecycleService, "root">;
78
- }
79
- export namespace scheduler {
80
- const factory: () => ServiceFactory<SchedulerService, "plugin">;
81
- }
82
- export namespace urlReader {
83
- const factory: () => ServiceFactory<UrlReaderService, "plugin">;
84
- }
85
- }
86
-
87
- /**
88
- * Sets up handlers for request mocking
89
- * @public
90
- * @param worker - service worker
91
- */
92
- export declare function setupRequestMockHandlers(worker: {
93
- listen: (t: any) => void;
94
- close: () => void;
95
- resetHandlers: () => void;
96
- }): void;
97
-
98
- /** @public */
99
- export declare function startTestBackend<TServices extends any[], TExtensionPoints extends any[]>(options: TestBackendOptions<TServices, TExtensionPoints>): Promise<TestBackend>;
100
-
101
- /** @public */
102
- export declare interface TestBackend extends Backend {
103
- /**
104
- * Provides access to the underling HTTP server for use with utilities
105
- * such as `supertest`.
106
- *
107
- * If the root http router service has been replaced, this will throw an error.
108
- */
109
- readonly server: ExtendedHttpServer;
110
- }
111
-
112
- /** @public */
113
- export declare interface TestBackendOptions<TServices extends any[], TExtensionPoints extends any[]> {
114
- services?: readonly [
115
- ...{
116
- [index in keyof TServices]: ServiceFactory<TServices[index]> | (() => ServiceFactory<TServices[index]>) | [ServiceRef<TServices[index]>, Partial<TServices[index]>];
117
- }
118
- ];
119
- extensionPoints?: readonly [
120
- ...{
121
- [index in keyof TExtensionPoints]: [
122
- ExtensionPoint<TExtensionPoints[index]>,
123
- Partial<TExtensionPoints[index]>
124
- ];
125
- }
126
- ];
127
- features?: BackendFeature[];
128
- }
129
-
130
- /**
131
- * The possible databases to test against.
132
- *
133
- * @public
134
- */
135
- export declare type TestDatabaseId = 'POSTGRES_13' | 'POSTGRES_9' | 'MYSQL_8' | 'SQLITE_3';
136
-
137
- /**
138
- * Encapsulates the creation of ephemeral test database instances for use
139
- * inside unit or integration tests.
140
- *
141
- * @public
142
- */
143
- export declare class TestDatabases {
144
- private readonly instanceById;
145
- private readonly supportedIds;
146
- /**
147
- * Creates an empty `TestDatabases` instance, and sets up Jest to clean up
148
- * all of its acquired resources after all tests finish.
149
- *
150
- * You typically want to create just a single instance like this at the top
151
- * of your test file or `describe` block, and then call `init` many times on
152
- * that instance inside the individual tests. Spinning up a "physical"
153
- * database instance takes a considerable amount of time, slowing down tests.
154
- * But initializing a new logical database inside that instance using `init`
155
- * is very fast.
156
- */
157
- static create(options?: {
158
- ids?: TestDatabaseId[];
159
- disableDocker?: boolean;
160
- }): TestDatabases;
161
- private constructor();
162
- supports(id: TestDatabaseId): boolean;
163
- eachSupportedId(): [TestDatabaseId][];
164
- /**
165
- * Returns a fresh, unique, empty logical database on an instance of the
166
- * given database ID platform.
167
- *
168
- * @param id - The ID of the database platform to use, e.g. 'POSTGRES_13'
169
- * @returns A `Knex` connection object
170
- */
171
- init(id: TestDatabaseId): Promise<Knex>;
172
- private initAny;
173
- private initPostgres;
174
- private initMysql;
175
- private initSqlite;
176
- private shutdown;
177
- }
178
-
179
- export { }
@@ -1,179 +0,0 @@
1
- /**
2
- * Test helpers library for Backstage backends
3
- *
4
- * @packageDocumentation
5
- */
6
-
7
- import { Backend } from '@backstage/backend-app-api';
8
- import { BackendFeature } from '@backstage/backend-plugin-api';
9
- import { CacheService } from '@backstage/backend-plugin-api';
10
- import { ConfigService } from '@backstage/backend-plugin-api';
11
- import { DatabaseService } from '@backstage/backend-plugin-api';
12
- import { ExtendedHttpServer } from '@backstage/backend-app-api';
13
- import { ExtensionPoint } from '@backstage/backend-plugin-api';
14
- import { HttpRouterFactoryOptions } from '@backstage/backend-app-api';
15
- import { HttpRouterService } from '@backstage/backend-plugin-api';
16
- import { IdentityService } from '@backstage/backend-plugin-api';
17
- import { JsonObject } from '@backstage/types';
18
- import { Knex } from 'knex';
19
- import { LifecycleService } from '@backstage/backend-plugin-api';
20
- import { LoggerService } from '@backstage/backend-plugin-api';
21
- import { PermissionsService } from '@backstage/backend-plugin-api';
22
- import { RootLifecycleService } from '@backstage/backend-plugin-api';
23
- import { SchedulerService } from '@backstage/backend-plugin-api';
24
- import { ServiceFactory } from '@backstage/backend-plugin-api';
25
- import { ServiceRef } from '@backstage/backend-plugin-api';
26
- import { TokenManagerService } from '@backstage/backend-plugin-api';
27
- import { UrlReaderService } from '@backstage/backend-plugin-api';
28
-
29
- /** @public */
30
- export declare function isDockerDisabledForTests(): boolean;
31
-
32
- /**
33
- * @public
34
- */
35
- export declare namespace mockServices {
36
- export function config(options?: config.Options): ConfigService;
37
- export namespace config {
38
- export type Options = {
39
- data?: JsonObject;
40
- };
41
- const factory: (options?: Options | undefined) => ServiceFactory<ConfigService, "root">;
42
- }
43
- export function rootLogger(options?: rootLogger.Options): LoggerService;
44
- export namespace rootLogger {
45
- export type Options = {
46
- level?: 'none' | 'error' | 'warn' | 'info' | 'debug';
47
- };
48
- const factory: (options?: Options | undefined) => ServiceFactory<LoggerService, "root">;
49
- }
50
- export function tokenManager(): TokenManagerService;
51
- export namespace tokenManager {
52
- const factory: () => ServiceFactory<TokenManagerService, "plugin">;
53
- }
54
- export function identity(): IdentityService;
55
- export namespace identity {
56
- const factory: () => ServiceFactory<IdentityService, "plugin">;
57
- }
58
- export namespace cache {
59
- const factory: () => ServiceFactory<CacheService, "plugin">;
60
- }
61
- export namespace database {
62
- const factory: () => ServiceFactory<DatabaseService, "plugin">;
63
- }
64
- export namespace httpRouter {
65
- const factory: (options?: HttpRouterFactoryOptions | undefined) => ServiceFactory<HttpRouterService, "plugin">;
66
- }
67
- export namespace lifecycle {
68
- const factory: () => ServiceFactory<LifecycleService, "plugin">;
69
- }
70
- export namespace logger {
71
- const factory: () => ServiceFactory<LoggerService, "plugin">;
72
- }
73
- export namespace permissions {
74
- const factory: () => ServiceFactory<PermissionsService, "plugin">;
75
- }
76
- export namespace rootLifecycle {
77
- const factory: () => ServiceFactory<RootLifecycleService, "root">;
78
- }
79
- export namespace scheduler {
80
- const factory: () => ServiceFactory<SchedulerService, "plugin">;
81
- }
82
- export namespace urlReader {
83
- const factory: () => ServiceFactory<UrlReaderService, "plugin">;
84
- }
85
- }
86
-
87
- /**
88
- * Sets up handlers for request mocking
89
- * @public
90
- * @param worker - service worker
91
- */
92
- export declare function setupRequestMockHandlers(worker: {
93
- listen: (t: any) => void;
94
- close: () => void;
95
- resetHandlers: () => void;
96
- }): void;
97
-
98
- /** @public */
99
- export declare function startTestBackend<TServices extends any[], TExtensionPoints extends any[]>(options: TestBackendOptions<TServices, TExtensionPoints>): Promise<TestBackend>;
100
-
101
- /** @public */
102
- export declare interface TestBackend extends Backend {
103
- /**
104
- * Provides access to the underling HTTP server for use with utilities
105
- * such as `supertest`.
106
- *
107
- * If the root http router service has been replaced, this will throw an error.
108
- */
109
- readonly server: ExtendedHttpServer;
110
- }
111
-
112
- /** @public */
113
- export declare interface TestBackendOptions<TServices extends any[], TExtensionPoints extends any[]> {
114
- services?: readonly [
115
- ...{
116
- [index in keyof TServices]: ServiceFactory<TServices[index]> | (() => ServiceFactory<TServices[index]>) | [ServiceRef<TServices[index]>, Partial<TServices[index]>];
117
- }
118
- ];
119
- extensionPoints?: readonly [
120
- ...{
121
- [index in keyof TExtensionPoints]: [
122
- ExtensionPoint<TExtensionPoints[index]>,
123
- Partial<TExtensionPoints[index]>
124
- ];
125
- }
126
- ];
127
- features?: BackendFeature[];
128
- }
129
-
130
- /**
131
- * The possible databases to test against.
132
- *
133
- * @public
134
- */
135
- export declare type TestDatabaseId = 'POSTGRES_13' | 'POSTGRES_9' | 'MYSQL_8' | 'SQLITE_3';
136
-
137
- /**
138
- * Encapsulates the creation of ephemeral test database instances for use
139
- * inside unit or integration tests.
140
- *
141
- * @public
142
- */
143
- export declare class TestDatabases {
144
- private readonly instanceById;
145
- private readonly supportedIds;
146
- /**
147
- * Creates an empty `TestDatabases` instance, and sets up Jest to clean up
148
- * all of its acquired resources after all tests finish.
149
- *
150
- * You typically want to create just a single instance like this at the top
151
- * of your test file or `describe` block, and then call `init` many times on
152
- * that instance inside the individual tests. Spinning up a "physical"
153
- * database instance takes a considerable amount of time, slowing down tests.
154
- * But initializing a new logical database inside that instance using `init`
155
- * is very fast.
156
- */
157
- static create(options?: {
158
- ids?: TestDatabaseId[];
159
- disableDocker?: boolean;
160
- }): TestDatabases;
161
- private constructor();
162
- supports(id: TestDatabaseId): boolean;
163
- eachSupportedId(): [TestDatabaseId][];
164
- /**
165
- * Returns a fresh, unique, empty logical database on an instance of the
166
- * given database ID platform.
167
- *
168
- * @param id - The ID of the database platform to use, e.g. 'POSTGRES_13'
169
- * @returns A `Knex` connection object
170
- */
171
- init(id: TestDatabaseId): Promise<Knex>;
172
- private initAny;
173
- private initPostgres;
174
- private initMysql;
175
- private initSqlite;
176
- private shutdown;
177
- }
178
-
179
- export { }