Merge pull request #15720 from backstage/rugvip/refactory
backend-app-api: switch factory functions to be defined with options as a top-level callback
This commit is contained in:
@@ -70,9 +70,9 @@ export type AppPluginOptions = {
|
||||
* The App plugin is responsible for serving the frontend app bundle and static assets.
|
||||
* @alpha
|
||||
*/
|
||||
export const appPlugin = createBackendPlugin({
|
||||
export const appPlugin = createBackendPlugin((options: AppPluginOptions) => ({
|
||||
id: 'app',
|
||||
register(env, options: AppPluginOptions) {
|
||||
register(env) {
|
||||
env.registerInit({
|
||||
deps: {
|
||||
logger: coreServices.logger,
|
||||
@@ -101,4 +101,4 @@ export const appPlugin = createBackendPlugin({
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -90,7 +90,5 @@ export class AwsS3EntityProvider implements EntityProvider {
|
||||
}
|
||||
|
||||
// @alpha
|
||||
export const awsS3EntityProviderCatalogModule: (
|
||||
options?: undefined,
|
||||
) => BackendFeature;
|
||||
export const awsS3EntityProviderCatalogModule: () => BackendFeature;
|
||||
```
|
||||
|
||||
@@ -58,7 +58,5 @@ export class AzureDevOpsEntityProvider implements EntityProvider {
|
||||
}
|
||||
|
||||
// @alpha
|
||||
export const azureDevOpsEntityProviderCatalogModule: (
|
||||
options?: undefined,
|
||||
) => BackendFeature;
|
||||
export const azureDevOpsEntityProviderCatalogModule: () => BackendFeature;
|
||||
```
|
||||
|
||||
@@ -48,7 +48,5 @@ export class BitbucketCloudEntityProvider
|
||||
}
|
||||
|
||||
// @alpha (undocumented)
|
||||
export const bitbucketCloudEntityProviderCatalogModule: (
|
||||
options?: undefined,
|
||||
) => BackendFeature;
|
||||
export const bitbucketCloudEntityProviderCatalogModule: () => BackendFeature;
|
||||
```
|
||||
|
||||
@@ -69,9 +69,7 @@ export class BitbucketServerEntityProvider implements EntityProvider {
|
||||
}
|
||||
|
||||
// @alpha (undocumented)
|
||||
export const bitbucketServerEntityProviderCatalogModule: (
|
||||
options?: undefined,
|
||||
) => BackendFeature;
|
||||
export const bitbucketServerEntityProviderCatalogModule: () => BackendFeature;
|
||||
|
||||
// @public (undocumented)
|
||||
export type BitbucketServerListOptions = {
|
||||
|
||||
@@ -31,9 +31,7 @@ export class GerritEntityProvider implements EntityProvider {
|
||||
}
|
||||
|
||||
// @alpha (undocumented)
|
||||
export const gerritEntityProviderCatalogModule: (
|
||||
options?: undefined,
|
||||
) => BackendFeature;
|
||||
export const gerritEntityProviderCatalogModule: () => BackendFeature;
|
||||
|
||||
// (No @packageDocumentation comment for this package)
|
||||
```
|
||||
|
||||
@@ -101,9 +101,7 @@ export class GithubEntityProvider implements EntityProvider, EventSubscriber {
|
||||
}
|
||||
|
||||
// @alpha
|
||||
export const githubEntityProviderCatalogModule: (
|
||||
options?: undefined,
|
||||
) => BackendFeature;
|
||||
export const githubEntityProviderCatalogModule: () => BackendFeature;
|
||||
|
||||
// @public (undocumented)
|
||||
export class GithubLocationAnalyzer implements ScmLocationAnalyzer {
|
||||
|
||||
@@ -34,9 +34,7 @@ export class GitlabDiscoveryEntityProvider implements EntityProvider {
|
||||
}
|
||||
|
||||
// @alpha
|
||||
export const gitlabDiscoveryEntityProviderCatalogModule: (
|
||||
options?: undefined,
|
||||
) => BackendFeature;
|
||||
export const gitlabDiscoveryEntityProviderCatalogModule: () => BackendFeature;
|
||||
|
||||
// @public
|
||||
export class GitLabDiscoveryProcessor implements CatalogProcessor {
|
||||
|
||||
+42
-43
@@ -31,51 +31,50 @@ import { WrapperProviders } from './WrapperProviders';
|
||||
* @alpha
|
||||
*/
|
||||
export const incrementalIngestionEntityProviderCatalogModule =
|
||||
createBackendModule({
|
||||
pluginId: 'catalog',
|
||||
moduleId: 'incrementalIngestionEntityProvider',
|
||||
register(
|
||||
env,
|
||||
options: {
|
||||
providers: Array<{
|
||||
provider: IncrementalEntityProvider<unknown, unknown>;
|
||||
options: IncrementalEntityProviderOptions;
|
||||
}>;
|
||||
},
|
||||
) {
|
||||
env.registerInit({
|
||||
deps: {
|
||||
catalog: catalogProcessingExtensionPoint,
|
||||
config: coreServices.config,
|
||||
database: coreServices.database,
|
||||
httpRouter: coreServices.httpRouter,
|
||||
logger: coreServices.logger,
|
||||
scheduler: coreServices.scheduler,
|
||||
},
|
||||
async init({
|
||||
catalog,
|
||||
config,
|
||||
database,
|
||||
httpRouter,
|
||||
logger,
|
||||
scheduler,
|
||||
}) {
|
||||
const client = await database.getClient();
|
||||
|
||||
const providers = new WrapperProviders({
|
||||
createBackendModule(
|
||||
(options: {
|
||||
providers: Array<{
|
||||
provider: IncrementalEntityProvider<unknown, unknown>;
|
||||
options: IncrementalEntityProviderOptions;
|
||||
}>;
|
||||
}) => ({
|
||||
pluginId: 'catalog',
|
||||
moduleId: 'incrementalIngestionEntityProvider',
|
||||
register(env) {
|
||||
env.registerInit({
|
||||
deps: {
|
||||
catalog: catalogProcessingExtensionPoint,
|
||||
config: coreServices.config,
|
||||
database: coreServices.database,
|
||||
httpRouter: coreServices.httpRouter,
|
||||
logger: coreServices.logger,
|
||||
scheduler: coreServices.scheduler,
|
||||
},
|
||||
async init({
|
||||
catalog,
|
||||
config,
|
||||
database,
|
||||
httpRouter,
|
||||
logger,
|
||||
client,
|
||||
scheduler,
|
||||
});
|
||||
}) {
|
||||
const client = await database.getClient();
|
||||
|
||||
for (const entry of options.providers) {
|
||||
const wrapped = providers.wrap(entry.provider, entry.options);
|
||||
catalog.addEntityProvider(wrapped);
|
||||
}
|
||||
const providers = new WrapperProviders({
|
||||
config,
|
||||
logger,
|
||||
client,
|
||||
scheduler,
|
||||
});
|
||||
|
||||
httpRouter.use(await providers.adminRouter());
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
for (const entry of options.providers) {
|
||||
const wrapped = providers.wrap(entry.provider, entry.options);
|
||||
catalog.addEntityProvider(wrapped);
|
||||
}
|
||||
|
||||
httpRouter.use(await providers.adminRouter());
|
||||
},
|
||||
});
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -135,9 +135,7 @@ export class MicrosoftGraphOrgEntityProvider implements EntityProvider {
|
||||
}
|
||||
|
||||
// @alpha
|
||||
export const microsoftGraphOrgEntityProviderCatalogModule: (
|
||||
options?: MicrosoftGraphOrgEntityProviderCatalogModuleOptions | undefined,
|
||||
) => BackendFeature;
|
||||
export const microsoftGraphOrgEntityProviderCatalogModule: () => BackendFeature;
|
||||
|
||||
// @alpha
|
||||
export interface MicrosoftGraphOrgEntityProviderCatalogModuleOptions {
|
||||
|
||||
@@ -237,7 +237,7 @@ export type CatalogPermissionRule<
|
||||
> = PermissionRule<Entity, EntitiesSearchFilter, 'catalog-entity', TParams>;
|
||||
|
||||
// @alpha
|
||||
export const catalogPlugin: (options?: undefined) => BackendFeature;
|
||||
export const catalogPlugin: () => BackendFeature;
|
||||
|
||||
// @public
|
||||
export interface CatalogProcessingEngine {
|
||||
|
||||
@@ -23,7 +23,5 @@ export class AwsSqsConsumingEventPublisher implements EventPublisher {
|
||||
}
|
||||
|
||||
// @alpha
|
||||
export const awsSqsConsumingEventPublisherEventsModule: (
|
||||
options?: undefined,
|
||||
) => BackendFeature;
|
||||
export const awsSqsConsumingEventPublisherEventsModule: () => BackendFeature;
|
||||
```
|
||||
|
||||
@@ -15,7 +15,5 @@ export class AzureDevOpsEventRouter extends SubTopicEventRouter {
|
||||
}
|
||||
|
||||
// @alpha
|
||||
export const azureDevOpsEventRouterEventsModule: (
|
||||
options?: undefined,
|
||||
) => BackendFeature;
|
||||
export const azureDevOpsEventRouterEventsModule: () => BackendFeature;
|
||||
```
|
||||
|
||||
@@ -15,7 +15,5 @@ export class BitbucketCloudEventRouter extends SubTopicEventRouter {
|
||||
}
|
||||
|
||||
// @alpha
|
||||
export const bitbucketCloudEventRouterEventsModule: (
|
||||
options?: undefined,
|
||||
) => BackendFeature;
|
||||
export const bitbucketCloudEventRouterEventsModule: () => BackendFeature;
|
||||
```
|
||||
|
||||
@@ -15,7 +15,5 @@ export class GerritEventRouter extends SubTopicEventRouter {
|
||||
}
|
||||
|
||||
// @alpha
|
||||
export const gerritEventRouterEventsModule: (
|
||||
options?: undefined,
|
||||
) => BackendFeature;
|
||||
export const gerritEventRouterEventsModule: () => BackendFeature;
|
||||
```
|
||||
|
||||
@@ -22,10 +22,8 @@ export class GithubEventRouter extends SubTopicEventRouter {
|
||||
}
|
||||
|
||||
// @alpha
|
||||
export const githubEventRouterEventsModule: (
|
||||
options?: undefined,
|
||||
) => BackendFeature;
|
||||
export const githubEventRouterEventsModule: () => BackendFeature;
|
||||
|
||||
// @alpha
|
||||
export const githubWebhookEventsModule: (options?: undefined) => BackendFeature;
|
||||
export const githubWebhookEventsModule: () => BackendFeature;
|
||||
```
|
||||
|
||||
@@ -20,10 +20,8 @@ export class GitlabEventRouter extends SubTopicEventRouter {
|
||||
}
|
||||
|
||||
// @alpha
|
||||
export const gitlabEventRouterEventsModule: (
|
||||
options?: undefined,
|
||||
) => BackendFeature;
|
||||
export const gitlabEventRouterEventsModule: () => BackendFeature;
|
||||
|
||||
// @alpha
|
||||
export const gitlabWebhookEventsModule: (options?: undefined) => BackendFeature;
|
||||
export const gitlabWebhookEventsModule: () => BackendFeature;
|
||||
```
|
||||
|
||||
@@ -29,7 +29,7 @@ export class EventsBackend {
|
||||
}
|
||||
|
||||
// @alpha
|
||||
export const eventsPlugin: (options?: undefined) => BackendFeature;
|
||||
export const eventsPlugin: () => BackendFeature;
|
||||
|
||||
// @public
|
||||
export class HttpPostIngressEventPublisher implements EventPublisher {
|
||||
|
||||
@@ -625,7 +625,7 @@ export type RunCommandOptions = {
|
||||
};
|
||||
|
||||
// @alpha
|
||||
export const scaffolderCatalogModule: (options?: undefined) => BackendFeature;
|
||||
export const scaffolderCatalogModule: () => BackendFeature;
|
||||
|
||||
// @public (undocumented)
|
||||
export class ScaffolderEntitiesProcessor implements CatalogProcessor {
|
||||
|
||||
@@ -70,72 +70,74 @@ export const scaffolderActionsExtensionPoint =
|
||||
* Catalog plugin
|
||||
* @alpha
|
||||
*/
|
||||
export const scaffolderPlugin = createBackendPlugin({
|
||||
id: 'scaffolder',
|
||||
register(env, options: ScaffolderPluginOptions) {
|
||||
const actionsExtensions = new ScaffolderActionsExtensionPointImpl();
|
||||
env.registerExtensionPoint(
|
||||
scaffolderActionsExtensionPoint,
|
||||
actionsExtensions,
|
||||
);
|
||||
export const scaffolderPlugin = createBackendPlugin(
|
||||
(options: ScaffolderPluginOptions) => ({
|
||||
id: 'scaffolder',
|
||||
register(env) {
|
||||
const actionsExtensions = new ScaffolderActionsExtensionPointImpl();
|
||||
env.registerExtensionPoint(
|
||||
scaffolderActionsExtensionPoint,
|
||||
actionsExtensions,
|
||||
);
|
||||
|
||||
env.registerInit({
|
||||
deps: {
|
||||
logger: coreServices.logger,
|
||||
config: coreServices.config,
|
||||
reader: coreServices.urlReader,
|
||||
permissions: coreServices.permissions,
|
||||
database: coreServices.database,
|
||||
httpRouter: coreServices.httpRouter,
|
||||
catalogClient: catalogServiceRef,
|
||||
},
|
||||
async init({
|
||||
logger,
|
||||
config,
|
||||
reader,
|
||||
database,
|
||||
httpRouter,
|
||||
catalogClient,
|
||||
}) {
|
||||
const {
|
||||
additionalTemplateFilters,
|
||||
taskBroker,
|
||||
taskWorkers,
|
||||
additionalTemplateGlobals,
|
||||
} = options;
|
||||
const log = loggerToWinstonLogger(logger);
|
||||
env.registerInit({
|
||||
deps: {
|
||||
logger: coreServices.logger,
|
||||
config: coreServices.config,
|
||||
reader: coreServices.urlReader,
|
||||
permissions: coreServices.permissions,
|
||||
database: coreServices.database,
|
||||
httpRouter: coreServices.httpRouter,
|
||||
catalogClient: catalogServiceRef,
|
||||
},
|
||||
async init({
|
||||
logger,
|
||||
config,
|
||||
reader,
|
||||
database,
|
||||
httpRouter,
|
||||
catalogClient,
|
||||
}) {
|
||||
const {
|
||||
additionalTemplateFilters,
|
||||
taskBroker,
|
||||
taskWorkers,
|
||||
additionalTemplateGlobals,
|
||||
} = options;
|
||||
const log = loggerToWinstonLogger(logger);
|
||||
|
||||
const actions = options.actions || [
|
||||
...actionsExtensions.actions,
|
||||
...createBuiltinActions({
|
||||
integrations: ScmIntegrations.fromConfig(config),
|
||||
const actions = options.actions || [
|
||||
...actionsExtensions.actions,
|
||||
...createBuiltinActions({
|
||||
integrations: ScmIntegrations.fromConfig(config),
|
||||
catalogClient,
|
||||
reader,
|
||||
config,
|
||||
additionalTemplateFilters,
|
||||
additionalTemplateGlobals,
|
||||
}),
|
||||
];
|
||||
|
||||
const actionIds = actions.map(action => action.id).join(', ');
|
||||
log.info(
|
||||
`Starting scaffolder with the following actions enabled ${actionIds}`,
|
||||
);
|
||||
|
||||
const router = await createRouter({
|
||||
logger: log,
|
||||
config,
|
||||
database,
|
||||
catalogClient,
|
||||
reader,
|
||||
config,
|
||||
actions,
|
||||
taskBroker,
|
||||
taskWorkers,
|
||||
additionalTemplateFilters,
|
||||
additionalTemplateGlobals,
|
||||
}),
|
||||
];
|
||||
|
||||
const actionIds = actions.map(action => action.id).join(', ');
|
||||
log.info(
|
||||
`Starting scaffolder with the following actions enabled ${actionIds}`,
|
||||
);
|
||||
|
||||
const router = await createRouter({
|
||||
logger: log,
|
||||
config,
|
||||
database,
|
||||
catalogClient,
|
||||
reader,
|
||||
actions,
|
||||
taskBroker,
|
||||
taskWorkers,
|
||||
additionalTemplateFilters,
|
||||
additionalTemplateGlobals,
|
||||
});
|
||||
httpRouter.use(router);
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
httpRouter.use(router);
|
||||
},
|
||||
});
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user