From 44c7ad6b8e117cf5a689ca3191694acf22f9006f Mon Sep 17 00:00:00 2001 From: sblausten Date: Mon, 20 Mar 2023 16:18:05 +0100 Subject: [PATCH] Api reports and changeset Signed-off-by: sblausten --- .changeset/sweet-fans-juggle.md | 6 ++++++ plugins/catalog-backend/api-report.md | 3 +++ plugins/events-backend/api-report.md | 12 ++++++++++++ .../src/service/InMemoryEventBroker.ts | 2 ++ yarn.lock | 3 +-- 5 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 .changeset/sweet-fans-juggle.md diff --git a/.changeset/sweet-fans-juggle.md b/.changeset/sweet-fans-juggle.md new file mode 100644 index 0000000000..e90e4643f8 --- /dev/null +++ b/.changeset/sweet-fans-juggle.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-catalog-backend': patch +'@backstage/plugin-events-backend': patch +--- + +Adds an optional eventBroker for sending an event when there are conflicts, and exports InMemoryBroker for use in other plugins. diff --git a/plugins/catalog-backend/api-report.md b/plugins/catalog-backend/api-report.md index 5e7b2dee02..e22aa622fb 100644 --- a/plugins/catalog-backend/api-report.md +++ b/plugins/catalog-backend/api-report.md @@ -31,6 +31,7 @@ import { EntityProvider as EntityProvider_2 } from '@backstage/plugin-catalog-no import { EntityProviderConnection as EntityProviderConnection_2 } from '@backstage/plugin-catalog-node'; import { EntityProviderMutation as EntityProviderMutation_2 } from '@backstage/plugin-catalog-node'; import { EntityRelationSpec as EntityRelationSpec_2 } from '@backstage/plugin-catalog-node'; +import { EventBroker } from '@backstage/plugin-events-node'; import { GetEntitiesRequest } from '@backstage/catalog-client'; import { JsonValue } from '@backstage/types'; import { LocationSpec as LocationSpec_2 } from '@backstage/plugin-catalog-common'; @@ -139,6 +140,8 @@ export class CatalogBuilder { replaceEntityPolicies(policies: EntityPolicy[]): CatalogBuilder; replaceProcessors(processors: CatalogProcessor_2[]): CatalogBuilder; setAllowedLocationTypes(allowedLocationTypes: string[]): CatalogBuilder; + // (undocumented) + setConflictEventBroker(broker: EventBroker): CatalogBuilder; setEntityDataParser(parser: CatalogProcessorParser_2): CatalogBuilder; setFieldFormatValidators(validators: Partial): CatalogBuilder; setLocationAnalyzer(locationAnalyzer: LocationAnalyzer): CatalogBuilder; diff --git a/plugins/events-backend/api-report.md b/plugins/events-backend/api-report.md index 7d8ede1979..5d520f10c2 100644 --- a/plugins/events-backend/api-report.md +++ b/plugins/events-backend/api-report.md @@ -5,6 +5,7 @@ ```ts import { Config } from '@backstage/config'; import { EventBroker } from '@backstage/plugin-events-node'; +import { EventParams } from '@backstage/plugin-events-node'; import { EventPublisher } from '@backstage/plugin-events-node'; import { EventSubscriber } from '@backstage/plugin-events-node'; import express from 'express'; @@ -42,4 +43,15 @@ export class HttpPostIngressEventPublisher implements EventPublisher { // (undocumented) setEventBroker(eventBroker: EventBroker): Promise; } + +// @public +export class InMemoryEventBroker implements EventBroker { + constructor(logger: Logger); + // (undocumented) + publish(params: EventParams): Promise; + // (undocumented) + subscribe( + ...subscribers: Array> + ): void; +} ``` diff --git a/plugins/events-backend/src/service/InMemoryEventBroker.ts b/plugins/events-backend/src/service/InMemoryEventBroker.ts index 04be01f658..d800d88dc5 100644 --- a/plugins/events-backend/src/service/InMemoryEventBroker.ts +++ b/plugins/events-backend/src/service/InMemoryEventBroker.ts @@ -25,6 +25,8 @@ import { Logger } from 'winston'; * In-memory event broker which will pass the event to all registered subscribers * interested in it. * Events will not be persisted in any form. + * + * @public */ // TODO(pjungermann): add prom metrics? (see plugins/catalog-backend/src/util/metrics.ts, etc.) export class InMemoryEventBroker implements EventBroker { diff --git a/yarn.lock b/yarn.lock index f078ec6138..5ad56a501c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5006,7 +5006,7 @@ __metadata: languageName: unknown linkType: soft -"@backstage/plugin-catalog-backend-module-github@workspace:^, @backstage/plugin-catalog-backend-module-github@workspace:plugins/catalog-backend-module-github": +"@backstage/plugin-catalog-backend-module-github@workspace:plugins/catalog-backend-module-github": version: 0.0.0-use.local resolution: "@backstage/plugin-catalog-backend-module-github@workspace:plugins/catalog-backend-module-github" dependencies: @@ -22509,7 +22509,6 @@ __metadata: "@backstage/plugin-azure-sites-backend": "workspace:^" "@backstage/plugin-badges-backend": "workspace:^" "@backstage/plugin-catalog-backend": "workspace:^" - "@backstage/plugin-catalog-backend-module-github": "workspace:^" "@backstage/plugin-catalog-node": "workspace:^" "@backstage/plugin-code-coverage-backend": "workspace:^" "@backstage/plugin-entity-feedback-backend": "workspace:^"