@backstage/backend-plugin-api 0.0.0-nightly-20220816025405 → 0.0.0-nightly-20220823025832
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 +14 -3
- package/alpha/package.json +1 -1
- package/dist/index.alpha.d.ts +20 -13
- package/dist/index.beta.d.ts +20 -13
- package/dist/index.cjs.js +3 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +20 -13
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
# @backstage/backend-plugin-api
|
|
2
2
|
|
|
3
|
-
## 0.0.0-nightly-
|
|
3
|
+
## 0.0.0-nightly-20220823025832
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- eef91a2558: Simplified the `ServiceFactory` type and removed `AnyServiceFactory`.
|
|
8
|
+
- 68513f169a: When defining a new `ServiceRef` you can now also include a `defaultFactory`, which will be used to construct instances of the service in case there is no explicit factory defined.
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
- @backstage/backend-tasks@0.0.0-nightly-20220823025832
|
|
11
|
+
- @backstage/backend-common@0.0.0-nightly-20220823025832
|
|
12
|
+
- @backstage/plugin-permission-common@0.0.0-nightly-20220823025832
|
|
13
|
+
|
|
14
|
+
## 0.1.1
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
6
17
|
|
|
7
18
|
- 0599732ec0: Refactored experimental backend system with new type names.
|
|
8
19
|
- 34c2f5aca1: The factory returned by `createBackendPlugin` and `createBackendModule` no longer require a parameter to be passed if the options are optional.
|
|
9
20
|
- Updated dependencies
|
|
10
|
-
- @backstage/backend-common@0.
|
|
11
|
-
- @backstage/backend-tasks@0.
|
|
21
|
+
- @backstage/backend-common@0.15.0
|
|
22
|
+
- @backstage/backend-tasks@0.3.4
|
|
12
23
|
|
|
13
24
|
## 0.1.1-next.0
|
|
14
25
|
|
package/alpha/package.json
CHANGED
package/dist/index.alpha.d.ts
CHANGED
|
@@ -17,11 +17,6 @@ import { TokenManager } from '@backstage/backend-common';
|
|
|
17
17
|
import { TransportStreamOptions } from 'winston-transport';
|
|
18
18
|
import { UrlReader } from '@backstage/backend-common';
|
|
19
19
|
|
|
20
|
-
/** @public */
|
|
21
|
-
export declare type AnyServiceFactory = ServiceFactory<unknown, unknown, {
|
|
22
|
-
[key in string]: unknown;
|
|
23
|
-
}>;
|
|
24
|
-
|
|
25
20
|
/** @public */
|
|
26
21
|
export declare interface BackendFeature {
|
|
27
22
|
id: string;
|
|
@@ -78,15 +73,20 @@ export declare function createExtensionPoint<T>(options: {
|
|
|
78
73
|
/**
|
|
79
74
|
* @public
|
|
80
75
|
*/
|
|
81
|
-
export declare function createServiceFactory<
|
|
76
|
+
export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
|
|
82
77
|
[name in string]: unknown;
|
|
83
|
-
}>(factory:
|
|
78
|
+
}>(factory: {
|
|
79
|
+
service: ServiceRef<TService>;
|
|
80
|
+
deps: TypesToServiceRef<TDeps>;
|
|
81
|
+
factory(deps: DepsToDepFactories<TDeps>): Promise<FactoryFunc<TImpl>>;
|
|
82
|
+
}): ServiceFactory<TService>;
|
|
84
83
|
|
|
85
84
|
/**
|
|
86
85
|
* @public
|
|
87
86
|
*/
|
|
88
87
|
export declare function createServiceRef<T>(options: {
|
|
89
88
|
id: string;
|
|
89
|
+
defaultFactory?: (service: ServiceRef<T>) => Promise<ServiceFactory<T>>;
|
|
90
90
|
}): ServiceRef<T>;
|
|
91
91
|
|
|
92
92
|
/**
|
|
@@ -164,12 +164,14 @@ export declare const permissionsServiceRef: ServiceRef<PermissionAuthorizer | Pe
|
|
|
164
164
|
export declare const schedulerServiceRef: ServiceRef<PluginTaskScheduler>;
|
|
165
165
|
|
|
166
166
|
/** @public */
|
|
167
|
-
export declare type ServiceFactory<
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
factory(deps:
|
|
167
|
+
export declare type ServiceFactory<TService = unknown> = {
|
|
168
|
+
service: ServiceRef<TService>;
|
|
169
|
+
deps: {
|
|
170
|
+
[key in string]: ServiceRef<unknown>;
|
|
171
|
+
};
|
|
172
|
+
factory(deps: {
|
|
173
|
+
[key in string]: unknown;
|
|
174
|
+
}): Promise<FactoryFunc<TService>>;
|
|
173
175
|
};
|
|
174
176
|
|
|
175
177
|
/**
|
|
@@ -184,6 +186,11 @@ export declare type ServiceRef<T> = {
|
|
|
184
186
|
* Attempting to actually read this value will result in an exception.
|
|
185
187
|
*/
|
|
186
188
|
T: T;
|
|
189
|
+
/**
|
|
190
|
+
* The default factory that will be used to create service
|
|
191
|
+
* instances if no other factory is provided.
|
|
192
|
+
*/
|
|
193
|
+
defaultFactory?: (service: ServiceRef<T>) => Promise<ServiceFactory<T>>;
|
|
187
194
|
toString(): string;
|
|
188
195
|
$$ref: 'service';
|
|
189
196
|
};
|
package/dist/index.beta.d.ts
CHANGED
|
@@ -17,11 +17,6 @@ import { TokenManager } from '@backstage/backend-common';
|
|
|
17
17
|
import { TransportStreamOptions } from 'winston-transport';
|
|
18
18
|
import { UrlReader } from '@backstage/backend-common';
|
|
19
19
|
|
|
20
|
-
/** @public */
|
|
21
|
-
export declare type AnyServiceFactory = ServiceFactory<unknown, unknown, {
|
|
22
|
-
[key in string]: unknown;
|
|
23
|
-
}>;
|
|
24
|
-
|
|
25
20
|
/** @public */
|
|
26
21
|
export declare interface BackendFeature {
|
|
27
22
|
id: string;
|
|
@@ -78,15 +73,20 @@ export declare function createExtensionPoint<T>(options: {
|
|
|
78
73
|
/**
|
|
79
74
|
* @public
|
|
80
75
|
*/
|
|
81
|
-
export declare function createServiceFactory<
|
|
76
|
+
export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
|
|
82
77
|
[name in string]: unknown;
|
|
83
|
-
}>(factory:
|
|
78
|
+
}>(factory: {
|
|
79
|
+
service: ServiceRef<TService>;
|
|
80
|
+
deps: TypesToServiceRef<TDeps>;
|
|
81
|
+
factory(deps: DepsToDepFactories<TDeps>): Promise<FactoryFunc<TImpl>>;
|
|
82
|
+
}): ServiceFactory<TService>;
|
|
84
83
|
|
|
85
84
|
/**
|
|
86
85
|
* @public
|
|
87
86
|
*/
|
|
88
87
|
export declare function createServiceRef<T>(options: {
|
|
89
88
|
id: string;
|
|
89
|
+
defaultFactory?: (service: ServiceRef<T>) => Promise<ServiceFactory<T>>;
|
|
90
90
|
}): ServiceRef<T>;
|
|
91
91
|
|
|
92
92
|
/**
|
|
@@ -164,12 +164,14 @@ export declare const permissionsServiceRef: ServiceRef<PermissionAuthorizer | Pe
|
|
|
164
164
|
export declare const schedulerServiceRef: ServiceRef<PluginTaskScheduler>;
|
|
165
165
|
|
|
166
166
|
/** @public */
|
|
167
|
-
export declare type ServiceFactory<
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
factory(deps:
|
|
167
|
+
export declare type ServiceFactory<TService = unknown> = {
|
|
168
|
+
service: ServiceRef<TService>;
|
|
169
|
+
deps: {
|
|
170
|
+
[key in string]: ServiceRef<unknown>;
|
|
171
|
+
};
|
|
172
|
+
factory(deps: {
|
|
173
|
+
[key in string]: unknown;
|
|
174
|
+
}): Promise<FactoryFunc<TService>>;
|
|
173
175
|
};
|
|
174
176
|
|
|
175
177
|
/**
|
|
@@ -184,6 +186,11 @@ export declare type ServiceRef<T> = {
|
|
|
184
186
|
* Attempting to actually read this value will result in an exception.
|
|
185
187
|
*/
|
|
186
188
|
T: T;
|
|
189
|
+
/**
|
|
190
|
+
* The default factory that will be used to create service
|
|
191
|
+
* instances if no other factory is provided.
|
|
192
|
+
*/
|
|
193
|
+
defaultFactory?: (service: ServiceRef<T>) => Promise<ServiceFactory<T>>;
|
|
187
194
|
toString(): string;
|
|
188
195
|
$$ref: 'service';
|
|
189
196
|
};
|
package/dist/index.cjs.js
CHANGED
|
@@ -10,11 +10,13 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
10
10
|
var Transport__default = /*#__PURE__*/_interopDefaultLegacy(Transport);
|
|
11
11
|
|
|
12
12
|
function createServiceRef(options) {
|
|
13
|
+
const { id, defaultFactory } = options;
|
|
13
14
|
return {
|
|
14
|
-
id
|
|
15
|
+
id,
|
|
15
16
|
get T() {
|
|
16
17
|
throw new Error(`tried to read ServiceRef.T of ${this}`);
|
|
17
18
|
},
|
|
19
|
+
defaultFactory,
|
|
18
20
|
toString() {
|
|
19
21
|
return `serviceRef{${options.id}}`;
|
|
20
22
|
},
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/services/system/types.ts","../src/services/definitions/configServiceRef.ts","../src/services/definitions/httpRouterServiceRef.ts","../src/services/definitions/loggerServiceRef.ts","../src/services/definitions/urlReaderServiceRef.ts","../src/services/definitions/cacheServiceRef.ts","../src/services/definitions/databaseServiceRef.ts","../src/services/definitions/discoveryServiceRef.ts","../src/services/definitions/tokenManagerServiceRef.ts","../src/services/definitions/permissionsServiceRef.ts","../src/services/definitions/schedulerServiceRef.ts","../src/services/helpers/loggerToWinstonLogger.ts","../src/wiring/factories.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * TODO\n *\n * @public\n */\nexport type ServiceRef<T> = {\n id: string;\n\n /**\n * Utility for getting the type of the service, using `typeof serviceRef.T`.\n * Attempting to actually read this value will result in an exception.\n */\n T: T;\n\n toString(): string;\n\n $$ref: 'service';\n};\n\n/** @public */\nexport type TypesToServiceRef<T> = { [key in keyof T]: ServiceRef<T[key]> };\n\n/** @public */\nexport type DepsToDepFactories<T> = {\n [key in keyof T]: (pluginId: string) => Promise<T[key]>;\n};\n\n/** @public */\nexport type FactoryFunc<Impl> = (pluginId: string) => Promise<Impl>;\n\n/** @public */\nexport type ServiceFactory<\n TApi,\n TImpl extends TApi,\n TDeps extends { [name in string]: unknown },\n> = {\n service: ServiceRef<TApi>;\n deps: TypesToServiceRef<TDeps>;\n factory(deps: DepsToDepFactories<TDeps>): Promise<FactoryFunc<TImpl>>;\n};\n\n/** @public */\nexport type AnyServiceFactory = ServiceFactory<\n unknown,\n unknown,\n { [key in string]: unknown }\n>;\n\n/**\n * @public\n */\nexport function createServiceRef<T>(options: { id: string }): ServiceRef<T> {\n return {\n id: options.id,\n get T(): T {\n throw new Error(`tried to read ServiceRef.T of ${this}`);\n },\n toString() {\n return `serviceRef{${options.id}}`;\n },\n $$ref: 'service', // TODO: declare\n };\n}\n\n/**\n * @public\n */\nexport function createServiceFactory<\n Api,\n Impl extends Api,\n Deps extends { [name in string]: unknown },\n>(factory: ServiceFactory<Api, Impl, Deps>): ServiceFactory<Api, Api, {}> {\n return factory;\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport { createServiceRef } from '../system/types';\n\n/**\n * @public\n */\nexport const configServiceRef = createServiceRef<Config>({\n id: 'core.config',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system/types';\nimport { Handler } from 'express';\n\n/**\n * @public\n */\nexport interface HttpRouterService {\n use(handler: Handler): void;\n}\n\n/**\n * @public\n */\nexport const httpRouterServiceRef = createServiceRef<HttpRouterService>({\n id: 'core.httpRouter',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system/types';\n\n/**\n * @public\n */\nexport interface Logger {\n info(message: string): void;\n child(fields: { [name: string]: string }): Logger;\n}\n\n/**\n * @public\n */\nexport const loggerServiceRef = createServiceRef<Logger>({\n id: 'core.logger',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system/types';\nimport { UrlReader } from '@backstage/backend-common';\n\n/**\n * @public\n */\nexport const urlReaderServiceRef = createServiceRef<UrlReader>({\n id: 'core.urlReader',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system/types';\nimport { PluginCacheManager } from '@backstage/backend-common';\n\n/**\n * @public\n */\nexport const cacheServiceRef = createServiceRef<PluginCacheManager>({\n id: 'core.cache',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { PluginDatabaseManager } from '@backstage/backend-common';\nimport { createServiceRef } from '../system/types';\n\n/**\n * @public\n */\nexport const databaseServiceRef = createServiceRef<PluginDatabaseManager>({\n id: 'core.database',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system/types';\nimport { PluginEndpointDiscovery } from '@backstage/backend-common';\n\n/**\n * @public\n */\nexport const discoveryServiceRef = createServiceRef<PluginEndpointDiscovery>({\n id: 'core.discovery',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system/types';\nimport { TokenManager } from '@backstage/backend-common';\n\n/**\n * @public\n */\nexport const tokenManagerServiceRef = createServiceRef<TokenManager>({\n id: 'core.tokenManager',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system/types';\nimport {\n PermissionAuthorizer,\n PermissionEvaluator,\n} from '@backstage/plugin-permission-common';\n\n/**\n * @public\n */\nexport const permissionsServiceRef = createServiceRef<\n PermissionEvaluator | PermissionAuthorizer\n>({\n id: 'core.permissions',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system/types';\nimport { PluginTaskScheduler } from '@backstage/backend-tasks';\n\n/**\n * @public\n */\nexport const schedulerServiceRef = createServiceRef<PluginTaskScheduler>({\n id: 'core.scheduler',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Logger as BackstageLogger } from '../definitions';\nimport { Logger as WinstonLogger, createLogger } from 'winston';\nimport Transport, { TransportStreamOptions } from 'winston-transport';\n\nclass BackstageLoggerTransport extends Transport {\n constructor(\n private readonly backstageLogger: BackstageLogger,\n opts?: TransportStreamOptions,\n ) {\n super(opts);\n }\n\n log(info: { message: string }, callback: VoidFunction) {\n // TODO: add support for levels and fields\n this.backstageLogger.info(info.message);\n callback();\n }\n}\n\n/** @public */\nexport function loggerToWinstonLogger(\n logger: BackstageLogger,\n opts?: TransportStreamOptions,\n): WinstonLogger {\n return createLogger({\n transports: [new BackstageLoggerTransport(logger, opts)],\n });\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n BackendRegistrationPoints,\n BackendFeature,\n ExtensionPoint,\n} from './types';\n\n/** @public */\nexport function createExtensionPoint<T>(options: {\n id: string;\n}): ExtensionPoint<T> {\n return {\n id: options.id,\n get T(): T {\n throw new Error(`tried to read ExtensionPoint.T of ${this}`);\n },\n toString() {\n return `extensionPoint{${options.id}}`;\n },\n $$ref: 'extension-point', // TODO: declare\n };\n}\n\n/** @public */\nexport interface BackendPluginConfig<TOptions> {\n id: string;\n register(reg: BackendRegistrationPoints, options: TOptions): void;\n}\n\n/** @public */\nexport function createBackendPlugin<TOptions>(\n config: BackendPluginConfig<TOptions>,\n): undefined extends TOptions\n ? (options?: TOptions) => BackendFeature\n : (options: TOptions) => BackendFeature {\n return (options?: TOptions) => ({\n id: config.id,\n register(register: BackendRegistrationPoints) {\n return config.register(register, options!);\n },\n });\n}\n\n/** @public */\nexport interface BackendModuleConfig<TOptions> {\n pluginId: string;\n moduleId: string;\n register(\n reg: Omit<BackendRegistrationPoints, 'registerExtensionPoint'>,\n options: TOptions,\n ): void;\n}\n\n/** @public */\nexport function createBackendModule<TOptions>(\n config: BackendModuleConfig<TOptions>,\n): undefined extends TOptions\n ? (options?: TOptions) => BackendFeature\n : (options: TOptions) => BackendFeature {\n return (options?: TOptions) => ({\n id: `${config.pluginId}.${config.moduleId}`,\n register(register: BackendRegistrationPoints) {\n // TODO: Hide registerExtensionPoint\n return config.register(register, options!);\n },\n });\n}\n"],"names":["Transport","createLogger"],"mappings":";;;;;;;;;;;AAAO,SAAS,gBAAgB,CAAC,OAAO,EAAE;AAC1C,EAAE,OAAO;AACT,IAAI,EAAE,EAAE,OAAO,CAAC,EAAE;AAClB,IAAI,IAAI,CAAC,GAAG;AACZ,MAAM,MAAM,IAAI,KAAK,CAAC,CAAC,8BAA8B,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AAC/D,KAAK;AACL,IAAI,QAAQ,GAAG;AACf,MAAM,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACzC,KAAK;AACL,IAAI,KAAK,EAAE,SAAS;AACpB,GAAG,CAAC;AACJ,CAAC;AACM,SAAS,oBAAoB,CAAC,OAAO,EAAE;AAC9C,EAAE,OAAO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;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/services/system/types.ts","../src/services/definitions/configServiceRef.ts","../src/services/definitions/httpRouterServiceRef.ts","../src/services/definitions/loggerServiceRef.ts","../src/services/definitions/urlReaderServiceRef.ts","../src/services/definitions/cacheServiceRef.ts","../src/services/definitions/databaseServiceRef.ts","../src/services/definitions/discoveryServiceRef.ts","../src/services/definitions/tokenManagerServiceRef.ts","../src/services/definitions/permissionsServiceRef.ts","../src/services/definitions/schedulerServiceRef.ts","../src/services/helpers/loggerToWinstonLogger.ts","../src/wiring/factories.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * TODO\n *\n * @public\n */\nexport type ServiceRef<T> = {\n id: string;\n\n /**\n * Utility for getting the type of the service, using `typeof serviceRef.T`.\n * Attempting to actually read this value will result in an exception.\n */\n T: T;\n\n /**\n * The default factory that will be used to create service\n * instances if no other factory is provided.\n */\n defaultFactory?: (service: ServiceRef<T>) => Promise<ServiceFactory<T>>;\n\n toString(): string;\n\n $$ref: 'service';\n};\n\n/** @public */\nexport type TypesToServiceRef<T> = { [key in keyof T]: ServiceRef<T[key]> };\n\n/** @public */\nexport type DepsToDepFactories<T> = {\n [key in keyof T]: (pluginId: string) => Promise<T[key]>;\n};\n\n/** @public */\nexport type FactoryFunc<Impl> = (pluginId: string) => Promise<Impl>;\n\n/** @public */\nexport type ServiceFactory<TService = unknown> = {\n service: ServiceRef<TService>;\n deps: { [key in string]: ServiceRef<unknown> };\n factory(deps: { [key in string]: unknown }): Promise<FactoryFunc<TService>>;\n};\n\n/**\n * @public\n */\nexport function createServiceRef<T>(options: {\n id: string;\n defaultFactory?: (service: ServiceRef<T>) => Promise<ServiceFactory<T>>;\n}): ServiceRef<T> {\n const { id, defaultFactory } = options;\n return {\n id,\n get T(): T {\n throw new Error(`tried to read ServiceRef.T of ${this}`);\n },\n defaultFactory,\n toString() {\n return `serviceRef{${options.id}}`;\n },\n $$ref: 'service', // TODO: declare\n };\n}\n\n/**\n * @public\n */\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: unknown },\n>(factory: {\n service: ServiceRef<TService>;\n deps: TypesToServiceRef<TDeps>;\n factory(deps: DepsToDepFactories<TDeps>): Promise<FactoryFunc<TImpl>>;\n}): ServiceFactory<TService> {\n return factory as ServiceFactory<TService>;\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport { createServiceRef } from '../system/types';\n\n/**\n * @public\n */\nexport const configServiceRef = createServiceRef<Config>({\n id: 'core.config',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system/types';\nimport { Handler } from 'express';\n\n/**\n * @public\n */\nexport interface HttpRouterService {\n use(handler: Handler): void;\n}\n\n/**\n * @public\n */\nexport const httpRouterServiceRef = createServiceRef<HttpRouterService>({\n id: 'core.httpRouter',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system/types';\n\n/**\n * @public\n */\nexport interface Logger {\n info(message: string): void;\n child(fields: { [name: string]: string }): Logger;\n}\n\n/**\n * @public\n */\nexport const loggerServiceRef = createServiceRef<Logger>({\n id: 'core.logger',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system/types';\nimport { UrlReader } from '@backstage/backend-common';\n\n/**\n * @public\n */\nexport const urlReaderServiceRef = createServiceRef<UrlReader>({\n id: 'core.urlReader',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system/types';\nimport { PluginCacheManager } from '@backstage/backend-common';\n\n/**\n * @public\n */\nexport const cacheServiceRef = createServiceRef<PluginCacheManager>({\n id: 'core.cache',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { PluginDatabaseManager } from '@backstage/backend-common';\nimport { createServiceRef } from '../system/types';\n\n/**\n * @public\n */\nexport const databaseServiceRef = createServiceRef<PluginDatabaseManager>({\n id: 'core.database',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system/types';\nimport { PluginEndpointDiscovery } from '@backstage/backend-common';\n\n/**\n * @public\n */\nexport const discoveryServiceRef = createServiceRef<PluginEndpointDiscovery>({\n id: 'core.discovery',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system/types';\nimport { TokenManager } from '@backstage/backend-common';\n\n/**\n * @public\n */\nexport const tokenManagerServiceRef = createServiceRef<TokenManager>({\n id: 'core.tokenManager',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system/types';\nimport {\n PermissionAuthorizer,\n PermissionEvaluator,\n} from '@backstage/plugin-permission-common';\n\n/**\n * @public\n */\nexport const permissionsServiceRef = createServiceRef<\n PermissionEvaluator | PermissionAuthorizer\n>({\n id: 'core.permissions',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system/types';\nimport { PluginTaskScheduler } from '@backstage/backend-tasks';\n\n/**\n * @public\n */\nexport const schedulerServiceRef = createServiceRef<PluginTaskScheduler>({\n id: 'core.scheduler',\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Logger as BackstageLogger } from '../definitions';\nimport { Logger as WinstonLogger, createLogger } from 'winston';\nimport Transport, { TransportStreamOptions } from 'winston-transport';\n\nclass BackstageLoggerTransport extends Transport {\n constructor(\n private readonly backstageLogger: BackstageLogger,\n opts?: TransportStreamOptions,\n ) {\n super(opts);\n }\n\n log(info: { message: string }, callback: VoidFunction) {\n // TODO: add support for levels and fields\n this.backstageLogger.info(info.message);\n callback();\n }\n}\n\n/** @public */\nexport function loggerToWinstonLogger(\n logger: BackstageLogger,\n opts?: TransportStreamOptions,\n): WinstonLogger {\n return createLogger({\n transports: [new BackstageLoggerTransport(logger, opts)],\n });\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n BackendRegistrationPoints,\n BackendFeature,\n ExtensionPoint,\n} from './types';\n\n/** @public */\nexport function createExtensionPoint<T>(options: {\n id: string;\n}): ExtensionPoint<T> {\n return {\n id: options.id,\n get T(): T {\n throw new Error(`tried to read ExtensionPoint.T of ${this}`);\n },\n toString() {\n return `extensionPoint{${options.id}}`;\n },\n $$ref: 'extension-point', // TODO: declare\n };\n}\n\n/** @public */\nexport interface BackendPluginConfig<TOptions> {\n id: string;\n register(reg: BackendRegistrationPoints, options: TOptions): void;\n}\n\n/** @public */\nexport function createBackendPlugin<TOptions>(\n config: BackendPluginConfig<TOptions>,\n): undefined extends TOptions\n ? (options?: TOptions) => BackendFeature\n : (options: TOptions) => BackendFeature {\n return (options?: TOptions) => ({\n id: config.id,\n register(register: BackendRegistrationPoints) {\n return config.register(register, options!);\n },\n });\n}\n\n/** @public */\nexport interface BackendModuleConfig<TOptions> {\n pluginId: string;\n moduleId: string;\n register(\n reg: Omit<BackendRegistrationPoints, 'registerExtensionPoint'>,\n options: TOptions,\n ): void;\n}\n\n/** @public */\nexport function createBackendModule<TOptions>(\n config: BackendModuleConfig<TOptions>,\n): undefined extends TOptions\n ? (options?: TOptions) => BackendFeature\n : (options: TOptions) => BackendFeature {\n return (options?: TOptions) => ({\n id: `${config.pluginId}.${config.moduleId}`,\n register(register: BackendRegistrationPoints) {\n // TODO: Hide registerExtensionPoint\n return config.register(register, options!);\n },\n });\n}\n"],"names":["Transport","createLogger"],"mappings":";;;;;;;;;;;AAAO,SAAS,gBAAgB,CAAC,OAAO,EAAE;AAC1C,EAAE,MAAM,EAAE,EAAE,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;AACzC,EAAE,OAAO;AACT,IAAI,EAAE;AACN,IAAI,IAAI,CAAC,GAAG;AACZ,MAAM,MAAM,IAAI,KAAK,CAAC,CAAC,8BAA8B,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AAC/D,KAAK;AACL,IAAI,cAAc;AAClB,IAAI,QAAQ,GAAG;AACf,MAAM,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACzC,KAAK;AACL,IAAI,KAAK,EAAE,SAAS;AACpB,GAAG,CAAC;AACJ,CAAC;AACM,SAAS,oBAAoB,CAAC,OAAO,EAAE;AAC9C,EAAE,OAAO,OAAO,CAAC;AACjB;;ACfY,MAAC,gBAAgB,GAAG,gBAAgB,CAAC;AACjD,EAAE,EAAE,EAAE,aAAa;AACnB,CAAC;;ACFW,MAAC,oBAAoB,GAAG,gBAAgB,CAAC;AACrD,EAAE,EAAE,EAAE,iBAAiB;AACvB,CAAC;;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AAC,CAAC;AACL;;AChBO,SAAS,oBAAoB,CAAC,OAAO,EAAE;AAC9C,EAAE,OAAO;AACT,IAAI,EAAE,EAAE,OAAO,CAAC,EAAE;AAClB,IAAI,IAAI,CAAC,GAAG;AACZ,MAAM,MAAM,IAAI,KAAK,CAAC,CAAC,kCAAkC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AACnE,KAAK;AACL,IAAI,QAAQ,GAAG;AACf,MAAM,OAAO,CAAC,eAAe,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC7C,KAAK;AACL,IAAI,KAAK,EAAE,iBAAiB;AAC5B,GAAG,CAAC;AACJ,CAAC;AACM,SAAS,mBAAmB,CAAC,MAAM,EAAE;AAC5C,EAAE,OAAO,CAAC,OAAO,MAAM;AACvB,IAAI,EAAE,EAAE,MAAM,CAAC,EAAE;AACjB,IAAI,QAAQ,CAAC,QAAQ,EAAE;AACvB,MAAM,OAAO,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAChD,KAAK;AACL,GAAG,CAAC,CAAC;AACL,CAAC;AACM,SAAS,mBAAmB,CAAC,MAAM,EAAE;AAC5C,EAAE,OAAO,CAAC,OAAO,MAAM;AACvB,IAAI,EAAE,EAAE,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC/C,IAAI,QAAQ,CAAC,QAAQ,EAAE;AACvB,MAAM,OAAO,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAChD,KAAK;AACL,GAAG,CAAC,CAAC;AACL;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -17,11 +17,6 @@ import { TokenManager } from '@backstage/backend-common';
|
|
|
17
17
|
import { TransportStreamOptions } from 'winston-transport';
|
|
18
18
|
import { UrlReader } from '@backstage/backend-common';
|
|
19
19
|
|
|
20
|
-
/** @public */
|
|
21
|
-
export declare type AnyServiceFactory = ServiceFactory<unknown, unknown, {
|
|
22
|
-
[key in string]: unknown;
|
|
23
|
-
}>;
|
|
24
|
-
|
|
25
20
|
/** @public */
|
|
26
21
|
export declare interface BackendFeature {
|
|
27
22
|
id: string;
|
|
@@ -78,15 +73,20 @@ export declare function createExtensionPoint<T>(options: {
|
|
|
78
73
|
/**
|
|
79
74
|
* @public
|
|
80
75
|
*/
|
|
81
|
-
export declare function createServiceFactory<
|
|
76
|
+
export declare function createServiceFactory<TService, TImpl extends TService, TDeps extends {
|
|
82
77
|
[name in string]: unknown;
|
|
83
|
-
}>(factory:
|
|
78
|
+
}>(factory: {
|
|
79
|
+
service: ServiceRef<TService>;
|
|
80
|
+
deps: TypesToServiceRef<TDeps>;
|
|
81
|
+
factory(deps: DepsToDepFactories<TDeps>): Promise<FactoryFunc<TImpl>>;
|
|
82
|
+
}): ServiceFactory<TService>;
|
|
84
83
|
|
|
85
84
|
/**
|
|
86
85
|
* @public
|
|
87
86
|
*/
|
|
88
87
|
export declare function createServiceRef<T>(options: {
|
|
89
88
|
id: string;
|
|
89
|
+
defaultFactory?: (service: ServiceRef<T>) => Promise<ServiceFactory<T>>;
|
|
90
90
|
}): ServiceRef<T>;
|
|
91
91
|
|
|
92
92
|
/**
|
|
@@ -164,12 +164,14 @@ export declare const permissionsServiceRef: ServiceRef<PermissionAuthorizer | Pe
|
|
|
164
164
|
export declare const schedulerServiceRef: ServiceRef<PluginTaskScheduler>;
|
|
165
165
|
|
|
166
166
|
/** @public */
|
|
167
|
-
export declare type ServiceFactory<
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
factory(deps:
|
|
167
|
+
export declare type ServiceFactory<TService = unknown> = {
|
|
168
|
+
service: ServiceRef<TService>;
|
|
169
|
+
deps: {
|
|
170
|
+
[key in string]: ServiceRef<unknown>;
|
|
171
|
+
};
|
|
172
|
+
factory(deps: {
|
|
173
|
+
[key in string]: unknown;
|
|
174
|
+
}): Promise<FactoryFunc<TService>>;
|
|
173
175
|
};
|
|
174
176
|
|
|
175
177
|
/**
|
|
@@ -184,6 +186,11 @@ export declare type ServiceRef<T> = {
|
|
|
184
186
|
* Attempting to actually read this value will result in an exception.
|
|
185
187
|
*/
|
|
186
188
|
T: T;
|
|
189
|
+
/**
|
|
190
|
+
* The default factory that will be used to create service
|
|
191
|
+
* instances if no other factory is provided.
|
|
192
|
+
*/
|
|
193
|
+
defaultFactory?: (service: ServiceRef<T>) => Promise<ServiceFactory<T>>;
|
|
187
194
|
toString(): string;
|
|
188
195
|
$$ref: 'service';
|
|
189
196
|
};
|
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.0.0-nightly-
|
|
4
|
+
"version": "0.0.0-nightly-20220823025832",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"private": false,
|
|
@@ -35,16 +35,16 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@backstage/config": "^1.0.1",
|
|
38
|
-
"@backstage/backend-common": "0.0.0-nightly-
|
|
39
|
-
"@backstage/plugin-permission-common": "
|
|
40
|
-
"@backstage/backend-tasks": "0.0.0-nightly-
|
|
38
|
+
"@backstage/backend-common": "0.0.0-nightly-20220823025832",
|
|
39
|
+
"@backstage/plugin-permission-common": "0.0.0-nightly-20220823025832",
|
|
40
|
+
"@backstage/backend-tasks": "0.0.0-nightly-20220823025832",
|
|
41
41
|
"@types/express": "^4.17.6",
|
|
42
42
|
"express": "^4.17.1",
|
|
43
43
|
"winston": "^3.2.1",
|
|
44
44
|
"winston-transport": "^4.5.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@backstage/cli": "0.0.0-nightly-
|
|
47
|
+
"@backstage/cli": "0.0.0-nightly-20220823025832"
|
|
48
48
|
},
|
|
49
49
|
"files": [
|
|
50
50
|
"dist",
|