@backstage/plugin-events-node 0.4.13 → 0.4.14
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 +16 -0
- package/dist/api/DefaultEventsService.cjs.js.map +1 -1
- package/dist/api/EventRouter.cjs.js.map +1 -1
- package/dist/api/EventsService.cjs.js.map +1 -1
- package/dist/api/SubTopicEventRouter.cjs.js.map +1 -1
- package/dist/extensions.cjs.js.map +1 -1
- package/dist/generated/apis/DefaultApi.client.cjs.js.map +1 -1
- package/dist/generated/pluginId.cjs.js.map +1 -1
- package/dist/service.cjs.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @backstage/plugin-events-node
|
|
2
2
|
|
|
3
|
+
## 0.4.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/backend-plugin-api@1.4.2
|
|
9
|
+
|
|
10
|
+
## 0.4.14-next.0
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
- @backstage/backend-plugin-api@1.4.2-next.0
|
|
16
|
+
- @backstage/errors@1.2.7
|
|
17
|
+
- @backstage/types@1.2.1
|
|
18
|
+
|
|
3
19
|
## 0.4.13
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultEventsService.cjs.js","sources":["../../src/api/DefaultEventsService.ts"],"sourcesContent":["/*\n * Copyright 2024 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 AuthService,\n DiscoveryService,\n LifecycleService,\n LoggerService,\n RootConfigService,\n} from '@backstage/backend-plugin-api';\nimport { EventParams } from './EventParams';\nimport {\n EVENTS_NOTIFY_TIMEOUT_HEADER,\n EventsService,\n EventsServiceSubscribeOptions,\n} from './EventsService';\nimport { DefaultApiClient } from '../generated';\nimport { ResponseError } from '@backstage/errors';\n\nconst POLL_BACKOFF_START_MS = 1_000;\nconst POLL_BACKOFF_MAX_MS = 60_000;\nconst POLL_BACKOFF_FACTOR = 2;\n\nconst EVENT_BUS_MODES = ['never', 'always', 'auto'] as const;\n\n/**\n * @public\n */\nexport type EventBusMode = 'never' | 'always' | 'auto';\n\n/**\n * Local event bus for subscribers within the same process.\n *\n * When publishing events we'll keep track of which subscribers we managed to\n * reach locally, and forward those subscriber IDs to the events backend if it\n * is in use. The events backend will then both avoid forwarding the same events\n * to those subscribers again, but also avoid storing the event altogether if\n * there are no other subscribers.\n * @internal\n */\nexport class LocalEventBus {\n readonly #logger: LoggerService;\n\n readonly #subscribers = new Map<\n string,\n Omit<EventsServiceSubscribeOptions, 'topics'>[]\n >();\n\n constructor(logger: LoggerService) {\n this.#logger = logger;\n }\n\n async publish(\n params: EventParams,\n ): Promise<{ notifiedSubscribers: string[] }> {\n this.#logger.debug(\n `Event received: topic=${params.topic}, metadata=${JSON.stringify(\n params.metadata,\n )}, payload=${JSON.stringify(params.eventPayload)}`,\n );\n\n if (!this.#subscribers.has(params.topic)) {\n return { notifiedSubscribers: [] };\n }\n\n const onEventPromises: Promise<string>[] = [];\n this.#subscribers.get(params.topic)?.forEach(subscription => {\n onEventPromises.push(\n (async () => {\n try {\n await subscription.onEvent(params);\n } catch (error) {\n this.#logger.warn(\n `Subscriber \"${subscription.id}\" failed to process event for topic \"${params.topic}\"`,\n error,\n );\n }\n return subscription.id;\n })(),\n );\n });\n\n return { notifiedSubscribers: await Promise.all(onEventPromises) };\n }\n\n async subscribe(options: EventsServiceSubscribeOptions): Promise<void> {\n options.topics.forEach(topic => {\n if (!this.#subscribers.has(topic)) {\n this.#subscribers.set(topic, []);\n }\n\n this.#subscribers.get(topic)!.push({\n id: options.id,\n onEvent: options.onEvent,\n });\n });\n }\n}\n\n/**\n * Plugin specific events bus that delegates to the local bus, as well as the\n * events backend if it is available.\n */\nclass PluginEventsService implements EventsService {\n constructor(\n private readonly pluginId: string,\n private readonly localBus: LocalEventBus,\n private readonly logger: LoggerService,\n private readonly mode: EventBusMode,\n private client?: DefaultApiClient,\n private readonly auth?: AuthService,\n ) {}\n\n async publish(params: EventParams): Promise<void> {\n const lock = this.#getShutdownLock();\n if (!lock) {\n throw new Error('Service is shutting down');\n }\n try {\n const { notifiedSubscribers } = await this.localBus.publish(params);\n\n const client = this.client;\n if (!client) {\n return;\n }\n const token = await this.#getToken();\n if (!token) {\n return;\n }\n const res = await client.postEvent(\n {\n body: {\n event: { payload: params.eventPayload, topic: params.topic },\n notifiedSubscribers,\n },\n },\n { token },\n );\n\n if (!res.ok) {\n if (res.status === 404 && this.mode !== 'always') {\n this.logger.warn(\n `Event publish request failed with status 404, events backend not found. Future events will not be persisted.`,\n );\n delete this.client;\n return;\n }\n throw await ResponseError.fromResponse(res);\n }\n } finally {\n lock.release();\n }\n }\n\n async subscribe(options: EventsServiceSubscribeOptions): Promise<void> {\n const subscriptionId = `${this.pluginId}.${options.id}`;\n\n await this.localBus.subscribe({\n id: subscriptionId,\n topics: options.topics,\n onEvent: options.onEvent,\n });\n\n if (!this.client) {\n return;\n }\n\n this.#startPolling(subscriptionId, options.topics, options.onEvent);\n }\n\n #startPolling(\n subscriptionId: string,\n topics: string[],\n onEvent: EventsServiceSubscribeOptions['onEvent'],\n ) {\n let hasSubscription = false;\n let backoffMs = POLL_BACKOFF_START_MS;\n const poll = async () => {\n const client = this.client;\n if (!client) {\n return;\n }\n const lock = this.#getShutdownLock();\n if (!lock) {\n return; // shutting down\n }\n try {\n const token = await this.#getToken();\n if (!token) {\n return;\n }\n\n if (hasSubscription) {\n const res = await client.getSubscriptionEvents(\n {\n path: { subscriptionId },\n },\n { token },\n );\n\n if (res.status === 202) {\n // 202 means there were no immediately available events, but the\n // response will block until either new events are available or the\n // request times out. In both cases we should should try to read events\n // immediately again\n\n lock.release();\n\n const notifyTimeoutHeader = res.headers.get(\n EVENTS_NOTIFY_TIMEOUT_HEADER,\n );\n\n // Add 1s to the timeout to allow the server to potentially timeout first\n const notifyTimeoutMs =\n notifyTimeoutHeader && !isNaN(parseInt(notifyTimeoutHeader, 10))\n ? Number(notifyTimeoutHeader) + 1_000\n : null;\n\n await Promise.race(\n [\n // We don't actually expect any response body here, but waiting for\n // an empty body to be returned has been more reliable that waiting\n // for the response body stream to close.\n res.text(),\n notifyTimeoutMs\n ? new Promise(resolve => setTimeout(resolve, notifyTimeoutMs))\n : null,\n ].filter(Boolean),\n );\n } else if (res.status === 200) {\n const data = await res.json();\n if (data) {\n for (const event of data.events ?? []) {\n try {\n await onEvent({\n topic: event.topic,\n eventPayload: event.payload,\n });\n } catch (error) {\n this.logger.warn(\n `Subscriber \"${subscriptionId}\" failed to process event for topic \"${event.topic}\"`,\n error,\n );\n }\n }\n }\n } else {\n if (res.status === 404) {\n this.logger.info(\n `Polling event subscription resulted in a 404, recreating subscription`,\n );\n hasSubscription = false;\n } else {\n throw await ResponseError.fromResponse(res);\n }\n }\n }\n\n // If we haven't yet created the subscription, or if it was removed, create a new one\n if (!hasSubscription) {\n const res = await client.putSubscription(\n {\n path: { subscriptionId },\n body: { topics },\n },\n { token },\n );\n hasSubscription = true;\n if (!res.ok) {\n if (res.status === 404 && this.mode !== 'always') {\n this.logger.warn(\n `Event subscribe request failed with status 404, events backend not found. Will only receive events that were sent locally on this process.`,\n );\n // Events backend is not present and not configured to always be used, bail out and stop polling\n delete this.client;\n return;\n }\n throw await ResponseError.fromResponse(res);\n }\n }\n\n // No errors, reset backoff\n backoffMs = POLL_BACKOFF_START_MS;\n\n process.nextTick(poll);\n } catch (error) {\n this.logger.warn(\n `Poll failed for subscription \"${subscriptionId}\", retrying in ${backoffMs.toFixed(\n 0,\n )}ms`,\n error,\n );\n setTimeout(poll, backoffMs);\n backoffMs = Math.min(\n backoffMs * POLL_BACKOFF_FACTOR,\n POLL_BACKOFF_MAX_MS,\n );\n } finally {\n lock.release();\n }\n };\n poll();\n }\n\n async #getToken() {\n if (!this.auth) {\n throw new Error('Auth service not available');\n }\n\n try {\n const { token } = await this.auth.getPluginRequestToken({\n onBehalfOf: await this.auth.getOwnServiceCredentials(),\n targetPluginId: 'events',\n });\n return token;\n } catch (error) {\n // This is a bit hacky, but handles the case where new auth is used\n // without legacy auth fallback, and the events backend is not installed\n if (\n String(error).includes('Unable to generate legacy token') &&\n this.mode !== 'always'\n ) {\n this.logger.warn(\n `The events backend is not available and neither is legacy auth. Future events will not be persisted.`,\n );\n delete this.client;\n return undefined;\n }\n throw error;\n }\n }\n\n async shutdown() {\n this.#isShuttingDown = true;\n await Promise.all(this.#shutdownLocks);\n }\n\n #isShuttingDown = false;\n #shutdownLocks = new Set<Promise<void>>();\n\n // This locking mechanism helps ensure that we are either idle or waiting for\n // a blocked events call before shutting down. It increases out changes of\n // never dropping any events on shutdown.\n #getShutdownLock(): { release(): void } | undefined {\n if (this.#isShuttingDown) {\n return undefined;\n }\n\n let release: () => void;\n\n const lock = new Promise<void>(resolve => {\n release = () => {\n resolve();\n this.#shutdownLocks.delete(lock);\n };\n });\n this.#shutdownLocks.add(lock);\n return { release: release! };\n }\n}\n\n/**\n * In-process event broker which will pass the event to all registered subscribers\n * interested in it.\n * Events will not be persisted in any form.\n * Events will not be passed to subscribers at other instances of the same cluster.\n *\n * @public\n */\n// TODO(pjungermann): add opentelemetry? (see plugins/catalog-backend/src/util/opentelemetry.ts, etc.)\nexport class DefaultEventsService implements EventsService {\n private constructor(\n private readonly logger: LoggerService,\n private readonly localBus: LocalEventBus,\n private readonly mode: EventBusMode,\n ) {}\n\n static create(options: {\n logger: LoggerService;\n config?: RootConfigService;\n useEventBus?: EventBusMode;\n }): DefaultEventsService {\n const eventBusMode =\n options.useEventBus ??\n ((options.config?.getOptionalString('events.useEventBus') ??\n 'auto') as EventBusMode);\n if (!EVENT_BUS_MODES.includes(eventBusMode)) {\n throw new Error(\n `Invalid events.useEventBus config, must be one of ${EVENT_BUS_MODES.join(\n ', ',\n )}, got '${eventBusMode}'`,\n );\n }\n\n return new DefaultEventsService(\n options.logger,\n new LocalEventBus(options.logger),\n eventBusMode,\n );\n }\n\n /**\n * Returns a plugin-scoped context of the `EventService`\n * that ensures to prefix subscriber IDs with the plugin ID.\n *\n * @param pluginId - The plugin that the `EventService` should be created for.\n */\n forPlugin(\n pluginId: string,\n options?: {\n discovery: DiscoveryService;\n logger: LoggerService;\n auth: AuthService;\n lifecycle: LifecycleService;\n },\n ): EventsService {\n const client =\n options && this.mode !== 'never'\n ? new DefaultApiClient({\n discoveryApi: options.discovery,\n fetchApi: { fetch }, // use native node fetch\n })\n : undefined;\n const logger = options?.logger ?? this.logger;\n const service = new PluginEventsService(\n pluginId,\n this.localBus,\n logger,\n this.mode,\n client,\n options?.auth,\n );\n options?.lifecycle.addShutdownHook(async () => {\n await service.shutdown();\n });\n return service;\n }\n\n async publish(params: EventParams): Promise<void> {\n await this.localBus.publish(params);\n }\n\n async subscribe(options: EventsServiceSubscribeOptions): Promise<void> {\n this.localBus.subscribe(options);\n }\n}\n"],"names":["ResponseError","EVENTS_NOTIFY_TIMEOUT_HEADER","DefaultApiClient"],"mappings":";;;;;;AAgCA,MAAM,qBAAwB,GAAA,GAAA;AAC9B,MAAM,mBAAsB,GAAA,GAAA;AAC5B,MAAM,mBAAsB,GAAA,CAAA;AAE5B,MAAM,eAAkB,GAAA,CAAC,OAAS,EAAA,QAAA,EAAU,MAAM,CAAA;AAiB3C,MAAM,aAAc,CAAA;AAAA,EAChB,OAAA;AAAA,EAEA,YAAA,uBAAmB,GAG1B,EAAA;AAAA,EAE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AA,MACT,OAAQ,CAAA,MAAA;AAAA,MACR,IAAI,aAAc,CAAA,OAAA,CAAQ,MAAM,CAAA;AAAA,MAChC;AAAA,KACF;AAAA;AACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,SAAA,CACE,UACA,OAMe,EAAA;AACf,IAAA,MAAM,SACJ,OAAW,IAAA,IAAA,CAAK,IAAS,KAAA,OAAA,GACrB,IAAIE,kCAAiB,CAAA;AAAA,MACnB,cAAc,OAAQ,CAAA,SAAA;AAAA,MACtB,QAAA,EAAU,EAAE,KAAM;AAAA;AAAA,KACnB,CACD,GAAA,KAAA,CAAA;AACN,IAAM,MAAA,MAAA,GAAS,OAAS,EAAA,MAAA,IAAU,IAAK,CAAA,MAAA;AACvC,IAAA,MAAM,UAAU,IAAI,mBAAA;AAAA,MAClB,QAAA;AAAA,MACA,IAAK,CAAA,QAAA;AAAA,MACL,MAAA;AAAA,MACA,IAAK,CAAA,IAAA;AAAA,MACL,MAAA;AAAA,MACA,OAAS,EAAA;AAAA,KACX;AACA,IAAS,OAAA,EAAA,SAAA,CAAU,gBAAgB,YAAY;AAC7C,MAAA,MAAM,QAAQ,QAAS,EAAA;AAAA,KACxB,CAAA;AACD,IAAO,OAAA,OAAA;AAAA;AACT,EAEA,MAAM,QAAQ,MAAoC,EAAA;AAChD,IAAM,MAAA,IAAA,CAAK,QAAS,CAAA,OAAA,CAAQ,MAAM,CAAA;AAAA;AACpC,EAEA,MAAM,UAAU,OAAuD,EAAA;AACrE,IAAK,IAAA,CAAA,QAAA,CAAS,UAAU,OAAO,CAAA;AAAA;AAEnC;;;;;"}
|
|
1
|
+
{"version":3,"file":"DefaultEventsService.cjs.js","sources":["../../src/api/DefaultEventsService.ts"],"sourcesContent":["/*\n * Copyright 2024 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 AuthService,\n DiscoveryService,\n LifecycleService,\n LoggerService,\n RootConfigService,\n} from '@backstage/backend-plugin-api';\nimport { EventParams } from './EventParams';\nimport {\n EVENTS_NOTIFY_TIMEOUT_HEADER,\n EventsService,\n EventsServiceSubscribeOptions,\n} from './EventsService';\nimport { DefaultApiClient } from '../generated';\nimport { ResponseError } from '@backstage/errors';\n\nconst POLL_BACKOFF_START_MS = 1_000;\nconst POLL_BACKOFF_MAX_MS = 60_000;\nconst POLL_BACKOFF_FACTOR = 2;\n\nconst EVENT_BUS_MODES = ['never', 'always', 'auto'] as const;\n\n/**\n * @public\n */\nexport type EventBusMode = 'never' | 'always' | 'auto';\n\n/**\n * Local event bus for subscribers within the same process.\n *\n * When publishing events we'll keep track of which subscribers we managed to\n * reach locally, and forward those subscriber IDs to the events backend if it\n * is in use. The events backend will then both avoid forwarding the same events\n * to those subscribers again, but also avoid storing the event altogether if\n * there are no other subscribers.\n * @internal\n */\nexport class LocalEventBus {\n readonly #logger: LoggerService;\n\n readonly #subscribers = new Map<\n string,\n Omit<EventsServiceSubscribeOptions, 'topics'>[]\n >();\n\n constructor(logger: LoggerService) {\n this.#logger = logger;\n }\n\n async publish(\n params: EventParams,\n ): Promise<{ notifiedSubscribers: string[] }> {\n this.#logger.debug(\n `Event received: topic=${params.topic}, metadata=${JSON.stringify(\n params.metadata,\n )}, payload=${JSON.stringify(params.eventPayload)}`,\n );\n\n if (!this.#subscribers.has(params.topic)) {\n return { notifiedSubscribers: [] };\n }\n\n const onEventPromises: Promise<string>[] = [];\n this.#subscribers.get(params.topic)?.forEach(subscription => {\n onEventPromises.push(\n (async () => {\n try {\n await subscription.onEvent(params);\n } catch (error) {\n this.#logger.warn(\n `Subscriber \"${subscription.id}\" failed to process event for topic \"${params.topic}\"`,\n error,\n );\n }\n return subscription.id;\n })(),\n );\n });\n\n return { notifiedSubscribers: await Promise.all(onEventPromises) };\n }\n\n async subscribe(options: EventsServiceSubscribeOptions): Promise<void> {\n options.topics.forEach(topic => {\n if (!this.#subscribers.has(topic)) {\n this.#subscribers.set(topic, []);\n }\n\n this.#subscribers.get(topic)!.push({\n id: options.id,\n onEvent: options.onEvent,\n });\n });\n }\n}\n\n/**\n * Plugin specific events bus that delegates to the local bus, as well as the\n * events backend if it is available.\n */\nclass PluginEventsService implements EventsService {\n constructor(\n private readonly pluginId: string,\n private readonly localBus: LocalEventBus,\n private readonly logger: LoggerService,\n private readonly mode: EventBusMode,\n private client?: DefaultApiClient,\n private readonly auth?: AuthService,\n ) {}\n\n async publish(params: EventParams): Promise<void> {\n const lock = this.#getShutdownLock();\n if (!lock) {\n throw new Error('Service is shutting down');\n }\n try {\n const { notifiedSubscribers } = await this.localBus.publish(params);\n\n const client = this.client;\n if (!client) {\n return;\n }\n const token = await this.#getToken();\n if (!token) {\n return;\n }\n const res = await client.postEvent(\n {\n body: {\n event: { payload: params.eventPayload, topic: params.topic },\n notifiedSubscribers,\n },\n },\n { token },\n );\n\n if (!res.ok) {\n if (res.status === 404 && this.mode !== 'always') {\n this.logger.warn(\n `Event publish request failed with status 404, events backend not found. Future events will not be persisted.`,\n );\n delete this.client;\n return;\n }\n throw await ResponseError.fromResponse(res);\n }\n } finally {\n lock.release();\n }\n }\n\n async subscribe(options: EventsServiceSubscribeOptions): Promise<void> {\n const subscriptionId = `${this.pluginId}.${options.id}`;\n\n await this.localBus.subscribe({\n id: subscriptionId,\n topics: options.topics,\n onEvent: options.onEvent,\n });\n\n if (!this.client) {\n return;\n }\n\n this.#startPolling(subscriptionId, options.topics, options.onEvent);\n }\n\n #startPolling(\n subscriptionId: string,\n topics: string[],\n onEvent: EventsServiceSubscribeOptions['onEvent'],\n ) {\n let hasSubscription = false;\n let backoffMs = POLL_BACKOFF_START_MS;\n const poll = async () => {\n const client = this.client;\n if (!client) {\n return;\n }\n const lock = this.#getShutdownLock();\n if (!lock) {\n return; // shutting down\n }\n try {\n const token = await this.#getToken();\n if (!token) {\n return;\n }\n\n if (hasSubscription) {\n const res = await client.getSubscriptionEvents(\n {\n path: { subscriptionId },\n },\n { token },\n );\n\n if (res.status === 202) {\n // 202 means there were no immediately available events, but the\n // response will block until either new events are available or the\n // request times out. In both cases we should should try to read events\n // immediately again\n\n lock.release();\n\n const notifyTimeoutHeader = res.headers.get(\n EVENTS_NOTIFY_TIMEOUT_HEADER,\n );\n\n // Add 1s to the timeout to allow the server to potentially timeout first\n const notifyTimeoutMs =\n notifyTimeoutHeader && !isNaN(parseInt(notifyTimeoutHeader, 10))\n ? Number(notifyTimeoutHeader) + 1_000\n : null;\n\n await Promise.race(\n [\n // We don't actually expect any response body here, but waiting for\n // an empty body to be returned has been more reliable that waiting\n // for the response body stream to close.\n res.text(),\n notifyTimeoutMs\n ? new Promise(resolve => setTimeout(resolve, notifyTimeoutMs))\n : null,\n ].filter(Boolean),\n );\n } else if (res.status === 200) {\n const data = await res.json();\n if (data) {\n for (const event of data.events ?? []) {\n try {\n await onEvent({\n topic: event.topic,\n eventPayload: event.payload,\n });\n } catch (error) {\n this.logger.warn(\n `Subscriber \"${subscriptionId}\" failed to process event for topic \"${event.topic}\"`,\n error,\n );\n }\n }\n }\n } else {\n if (res.status === 404) {\n this.logger.info(\n `Polling event subscription resulted in a 404, recreating subscription`,\n );\n hasSubscription = false;\n } else {\n throw await ResponseError.fromResponse(res);\n }\n }\n }\n\n // If we haven't yet created the subscription, or if it was removed, create a new one\n if (!hasSubscription) {\n const res = await client.putSubscription(\n {\n path: { subscriptionId },\n body: { topics },\n },\n { token },\n );\n hasSubscription = true;\n if (!res.ok) {\n if (res.status === 404 && this.mode !== 'always') {\n this.logger.warn(\n `Event subscribe request failed with status 404, events backend not found. Will only receive events that were sent locally on this process.`,\n );\n // Events backend is not present and not configured to always be used, bail out and stop polling\n delete this.client;\n return;\n }\n throw await ResponseError.fromResponse(res);\n }\n }\n\n // No errors, reset backoff\n backoffMs = POLL_BACKOFF_START_MS;\n\n process.nextTick(poll);\n } catch (error) {\n this.logger.warn(\n `Poll failed for subscription \"${subscriptionId}\", retrying in ${backoffMs.toFixed(\n 0,\n )}ms`,\n error,\n );\n setTimeout(poll, backoffMs);\n backoffMs = Math.min(\n backoffMs * POLL_BACKOFF_FACTOR,\n POLL_BACKOFF_MAX_MS,\n );\n } finally {\n lock.release();\n }\n };\n poll();\n }\n\n async #getToken() {\n if (!this.auth) {\n throw new Error('Auth service not available');\n }\n\n try {\n const { token } = await this.auth.getPluginRequestToken({\n onBehalfOf: await this.auth.getOwnServiceCredentials(),\n targetPluginId: 'events',\n });\n return token;\n } catch (error) {\n // This is a bit hacky, but handles the case where new auth is used\n // without legacy auth fallback, and the events backend is not installed\n if (\n String(error).includes('Unable to generate legacy token') &&\n this.mode !== 'always'\n ) {\n this.logger.warn(\n `The events backend is not available and neither is legacy auth. Future events will not be persisted.`,\n );\n delete this.client;\n return undefined;\n }\n throw error;\n }\n }\n\n async shutdown() {\n this.#isShuttingDown = true;\n await Promise.all(this.#shutdownLocks);\n }\n\n #isShuttingDown = false;\n #shutdownLocks = new Set<Promise<void>>();\n\n // This locking mechanism helps ensure that we are either idle or waiting for\n // a blocked events call before shutting down. It increases out changes of\n // never dropping any events on shutdown.\n #getShutdownLock(): { release(): void } | undefined {\n if (this.#isShuttingDown) {\n return undefined;\n }\n\n let release: () => void;\n\n const lock = new Promise<void>(resolve => {\n release = () => {\n resolve();\n this.#shutdownLocks.delete(lock);\n };\n });\n this.#shutdownLocks.add(lock);\n return { release: release! };\n }\n}\n\n/**\n * In-process event broker which will pass the event to all registered subscribers\n * interested in it.\n * Events will not be persisted in any form.\n * Events will not be passed to subscribers at other instances of the same cluster.\n *\n * @public\n */\n// TODO(pjungermann): add opentelemetry? (see plugins/catalog-backend/src/util/opentelemetry.ts, etc.)\nexport class DefaultEventsService implements EventsService {\n private constructor(\n private readonly logger: LoggerService,\n private readonly localBus: LocalEventBus,\n private readonly mode: EventBusMode,\n ) {}\n\n static create(options: {\n logger: LoggerService;\n config?: RootConfigService;\n useEventBus?: EventBusMode;\n }): DefaultEventsService {\n const eventBusMode =\n options.useEventBus ??\n ((options.config?.getOptionalString('events.useEventBus') ??\n 'auto') as EventBusMode);\n if (!EVENT_BUS_MODES.includes(eventBusMode)) {\n throw new Error(\n `Invalid events.useEventBus config, must be one of ${EVENT_BUS_MODES.join(\n ', ',\n )}, got '${eventBusMode}'`,\n );\n }\n\n return new DefaultEventsService(\n options.logger,\n new LocalEventBus(options.logger),\n eventBusMode,\n );\n }\n\n /**\n * Returns a plugin-scoped context of the `EventService`\n * that ensures to prefix subscriber IDs with the plugin ID.\n *\n * @param pluginId - The plugin that the `EventService` should be created for.\n */\n forPlugin(\n pluginId: string,\n options?: {\n discovery: DiscoveryService;\n logger: LoggerService;\n auth: AuthService;\n lifecycle: LifecycleService;\n },\n ): EventsService {\n const client =\n options && this.mode !== 'never'\n ? new DefaultApiClient({\n discoveryApi: options.discovery,\n fetchApi: { fetch }, // use native node fetch\n })\n : undefined;\n const logger = options?.logger ?? this.logger;\n const service = new PluginEventsService(\n pluginId,\n this.localBus,\n logger,\n this.mode,\n client,\n options?.auth,\n );\n options?.lifecycle.addShutdownHook(async () => {\n await service.shutdown();\n });\n return service;\n }\n\n async publish(params: EventParams): Promise<void> {\n await this.localBus.publish(params);\n }\n\n async subscribe(options: EventsServiceSubscribeOptions): Promise<void> {\n this.localBus.subscribe(options);\n }\n}\n"],"names":["ResponseError","EVENTS_NOTIFY_TIMEOUT_HEADER","DefaultApiClient"],"mappings":";;;;;;AAgCA,MAAM,qBAAA,GAAwB,GAAA;AAC9B,MAAM,mBAAA,GAAsB,GAAA;AAC5B,MAAM,mBAAA,GAAsB,CAAA;AAE5B,MAAM,eAAA,GAAkB,CAAC,OAAA,EAAS,QAAA,EAAU,MAAM,CAAA;AAiB3C,MAAM,aAAA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CAAQ,MAAM,CAAA;AAAA,EACpC;AAAA,EAEA,MAAM,UAAU,OAAA,EAAuD;AACrE,IAAA,IAAA,CAAK,QAAA,CAAS,UAAU,OAAO,CAAA;AAAA,EACjC;AACF;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventRouter.cjs.js","sources":["../../src/api/EventRouter.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\nimport { EventParams } from './EventParams';\nimport { EventsService } from './EventsService';\n\n/**\n * Subscribes to a topic and - depending on a set of conditions -\n * republishes the event to another topic.\n *\n * @see {@link https://www.enterpriseintegrationpatterns.com/MessageRouter.html | Message Router pattern}.\n * @public\n */\nexport abstract class EventRouter {\n private readonly events: EventsService;\n private readonly topics: string[];\n private subscribed: boolean = false;\n\n protected constructor(options: { events: EventsService; topics: string[] }) {\n this.events = options.events;\n this.topics = options.topics;\n }\n\n protected abstract getSubscriberId(): string;\n\n protected abstract determineDestinationTopic(\n params: EventParams,\n ): string | undefined;\n\n /**\n * Subscribes itself to the topic(s),\n * after which events potentially can be received\n * and processed by {@link EventRouter.onEvent}.\n */\n async subscribe(): Promise<void> {\n if (this.subscribed) {\n return;\n }\n\n this.subscribed = true;\n\n await this.events.subscribe({\n id: this.getSubscriberId(),\n topics: this.topics,\n onEvent: this.onEvent.bind(this),\n });\n }\n\n async onEvent(params: EventParams): Promise<void> {\n const topic = this.determineDestinationTopic(params);\n\n if (!topic) {\n return;\n }\n\n // republish to different topic\n await this.events.publish({\n ...params,\n topic,\n });\n }\n}\n"],"names":[],"mappings":";;AA0BO,MAAe,
|
|
1
|
+
{"version":3,"file":"EventRouter.cjs.js","sources":["../../src/api/EventRouter.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\nimport { EventParams } from './EventParams';\nimport { EventsService } from './EventsService';\n\n/**\n * Subscribes to a topic and - depending on a set of conditions -\n * republishes the event to another topic.\n *\n * @see {@link https://www.enterpriseintegrationpatterns.com/MessageRouter.html | Message Router pattern}.\n * @public\n */\nexport abstract class EventRouter {\n private readonly events: EventsService;\n private readonly topics: string[];\n private subscribed: boolean = false;\n\n protected constructor(options: { events: EventsService; topics: string[] }) {\n this.events = options.events;\n this.topics = options.topics;\n }\n\n protected abstract getSubscriberId(): string;\n\n protected abstract determineDestinationTopic(\n params: EventParams,\n ): string | undefined;\n\n /**\n * Subscribes itself to the topic(s),\n * after which events potentially can be received\n * and processed by {@link EventRouter.onEvent}.\n */\n async subscribe(): Promise<void> {\n if (this.subscribed) {\n return;\n }\n\n this.subscribed = true;\n\n await this.events.subscribe({\n id: this.getSubscriberId(),\n topics: this.topics,\n onEvent: this.onEvent.bind(this),\n });\n }\n\n async onEvent(params: EventParams): Promise<void> {\n const topic = this.determineDestinationTopic(params);\n\n if (!topic) {\n return;\n }\n\n // republish to different topic\n await this.events.publish({\n ...params,\n topic,\n });\n }\n}\n"],"names":[],"mappings":";;AA0BO,MAAe,WAAA,CAAY;AAAA,EACf,MAAA;AAAA,EACA,MAAA;AAAA,EACT,UAAA,GAAsB,KAAA;AAAA,EAEpB,YAAY,OAAA,EAAsD;AAC1E,IAAA,IAAA,CAAK,SAAS,OAAA,CAAQ,MAAA;AACtB,IAAA,IAAA,CAAK,SAAS,OAAA,CAAQ,MAAA;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,MAAM,SAAA,GAA2B;AAC/B,IAAA,IAAI,KAAK,UAAA,EAAY;AACnB,MAAA;AAAA,IACF;AAEA,IAAA,IAAA,CAAK,UAAA,GAAa,IAAA;AAElB,IAAA,MAAM,IAAA,CAAK,OAAO,SAAA,CAAU;AAAA,MAC1B,EAAA,EAAI,KAAK,eAAA,EAAgB;AAAA,MACzB,QAAQ,IAAA,CAAK,MAAA;AAAA,MACb,OAAA,EAAS,IAAA,CAAK,OAAA,CAAQ,IAAA,CAAK,IAAI;AAAA,KAChC,CAAA;AAAA,EACH;AAAA,EAEA,MAAM,QAAQ,MAAA,EAAoC;AAChD,IAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,yBAAA,CAA0B,MAAM,CAAA;AAEnD,IAAA,IAAI,CAAC,KAAA,EAAO;AACV,MAAA;AAAA,IACF;AAGA,IAAA,MAAM,IAAA,CAAK,OAAO,OAAA,CAAQ;AAAA,MACxB,GAAG,MAAA;AAAA,MACH;AAAA,KACD,CAAA;AAAA,EACH;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventsService.cjs.js","sources":["../../src/api/EventsService.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { EventParams } from './EventParams';\n\n/**\n * Allows a decoupled and asynchronous communication between components.\n * Components can publish events for a given topic and\n * others can subscribe for future events for topics they are interested in.\n *\n * @public\n */\nexport interface EventsService {\n /**\n * Publishes an event for the topic.\n *\n * @param params - parameters for the to be published event.\n */\n publish(params: EventParams): Promise<void>;\n\n /**\n * Subscribes to one or more topics, registering an event handler for them.\n *\n * @param options - event subscription options.\n */\n subscribe(options: EventsServiceSubscribeOptions): Promise<void>;\n}\n\n/**\n * @public\n */\nexport type EventsServiceSubscribeOptions = {\n /**\n * Subscriber ID that is scoped to the calling plugin. Subscribers with the same ID will have events distributed between them.\n */\n id: string;\n topics: string[];\n onEvent: EventsServiceEventHandler;\n};\n\n/**\n * @public\n */\nexport type EventsServiceEventHandler = (params: EventParams) => Promise<void>;\n\n/**\n * @public\n */\nexport const EVENTS_NOTIFY_TIMEOUT_HEADER = 'backstage-events-notify-timeout';\n"],"names":[],"mappings":";;AA6DO,MAAM,
|
|
1
|
+
{"version":3,"file":"EventsService.cjs.js","sources":["../../src/api/EventsService.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { EventParams } from './EventParams';\n\n/**\n * Allows a decoupled and asynchronous communication between components.\n * Components can publish events for a given topic and\n * others can subscribe for future events for topics they are interested in.\n *\n * @public\n */\nexport interface EventsService {\n /**\n * Publishes an event for the topic.\n *\n * @param params - parameters for the to be published event.\n */\n publish(params: EventParams): Promise<void>;\n\n /**\n * Subscribes to one or more topics, registering an event handler for them.\n *\n * @param options - event subscription options.\n */\n subscribe(options: EventsServiceSubscribeOptions): Promise<void>;\n}\n\n/**\n * @public\n */\nexport type EventsServiceSubscribeOptions = {\n /**\n * Subscriber ID that is scoped to the calling plugin. Subscribers with the same ID will have events distributed between them.\n */\n id: string;\n topics: string[];\n onEvent: EventsServiceEventHandler;\n};\n\n/**\n * @public\n */\nexport type EventsServiceEventHandler = (params: EventParams) => Promise<void>;\n\n/**\n * @public\n */\nexport const EVENTS_NOTIFY_TIMEOUT_HEADER = 'backstage-events-notify-timeout';\n"],"names":[],"mappings":";;AA6DO,MAAM,4BAAA,GAA+B;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubTopicEventRouter.cjs.js","sources":["../../src/api/SubTopicEventRouter.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\nimport { EventParams } from './EventParams';\nimport { EventRouter } from './EventRouter';\nimport { EventsService } from './EventsService';\n\n/**\n * Subscribes to the provided (generic) topic\n * and publishes the events under the more concrete sub-topic\n * depending on the implemented logic for determining it.\n * Implementing classes might use information from `metadata`\n * and/or properties within the payload.\n *\n * @public\n */\nexport abstract class SubTopicEventRouter extends EventRouter {\n protected constructor(options: { events: EventsService; topic: string }) {\n super({\n events: options.events,\n topics: [options.topic],\n });\n }\n\n protected abstract determineSubTopic(params: EventParams): string | undefined;\n\n protected determineDestinationTopic(params: EventParams): string | undefined {\n const subTopic = this.determineSubTopic(params);\n return subTopic ? `${params.topic}.${subTopic}` : undefined;\n }\n}\n"],"names":["EventRouter"],"mappings":";;;;AA6BO,MAAe,4BAA4BA,
|
|
1
|
+
{"version":3,"file":"SubTopicEventRouter.cjs.js","sources":["../../src/api/SubTopicEventRouter.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\nimport { EventParams } from './EventParams';\nimport { EventRouter } from './EventRouter';\nimport { EventsService } from './EventsService';\n\n/**\n * Subscribes to the provided (generic) topic\n * and publishes the events under the more concrete sub-topic\n * depending on the implemented logic for determining it.\n * Implementing classes might use information from `metadata`\n * and/or properties within the payload.\n *\n * @public\n */\nexport abstract class SubTopicEventRouter extends EventRouter {\n protected constructor(options: { events: EventsService; topic: string }) {\n super({\n events: options.events,\n topics: [options.topic],\n });\n }\n\n protected abstract determineSubTopic(params: EventParams): string | undefined;\n\n protected determineDestinationTopic(params: EventParams): string | undefined {\n const subTopic = this.determineSubTopic(params);\n return subTopic ? `${params.topic}.${subTopic}` : undefined;\n }\n}\n"],"names":["EventRouter"],"mappings":";;;;AA6BO,MAAe,4BAA4BA,uBAAA,CAAY;AAAA,EAClD,YAAY,OAAA,EAAmD;AACvE,IAAA,KAAA,CAAM;AAAA,MACJ,QAAQ,OAAA,CAAQ,MAAA;AAAA,MAChB,MAAA,EAAQ,CAAC,OAAA,CAAQ,KAAK;AAAA,KACvB,CAAA;AAAA,EACH;AAAA,EAIU,0BAA0B,MAAA,EAAyC;AAC3E,IAAA,MAAM,QAAA,GAAW,IAAA,CAAK,iBAAA,CAAkB,MAAM,CAAA;AAC9C,IAAA,OAAO,WAAW,CAAA,EAAG,MAAA,CAAO,KAAK,CAAA,CAAA,EAAI,QAAQ,CAAA,CAAA,GAAK,MAAA;AAAA,EACpD;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions.cjs.js","sources":["../src/extensions.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\nimport { createExtensionPoint } from '@backstage/backend-plugin-api';\nimport {\n EventBroker,\n EventPublisher,\n EventSubscriber,\n HttpBodyParserOptions,\n HttpPostIngressOptions,\n} from '@backstage/plugin-events-node';\n\n/**\n * @alpha\n */\nexport interface EventsExtensionPoint {\n /**\n * @deprecated use `eventsServiceRef` and `eventsServiceFactory` instead\n */\n setEventBroker(eventBroker: EventBroker): void;\n\n /**\n * @deprecated use `EventsService.publish` instead\n */\n addPublishers(\n ...publishers: Array<EventPublisher | Array<EventPublisher>>\n ): void;\n\n /**\n * @deprecated use `EventsService.subscribe` instead\n */\n addSubscribers(\n ...subscribers: Array<EventSubscriber | Array<EventSubscriber>>\n ): void;\n\n addHttpPostIngress(options: HttpPostIngressOptions): void;\n\n addHttpPostBodyParser(options: HttpBodyParserOptions): void;\n}\n\n/**\n * @alpha\n */\nexport const eventsExtensionPoint = createExtensionPoint<EventsExtensionPoint>({\n id: 'events',\n});\n"],"names":["createExtensionPoint"],"mappings":";;;;AAwDO,MAAM,uBAAuBA,
|
|
1
|
+
{"version":3,"file":"extensions.cjs.js","sources":["../src/extensions.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\nimport { createExtensionPoint } from '@backstage/backend-plugin-api';\nimport {\n EventBroker,\n EventPublisher,\n EventSubscriber,\n HttpBodyParserOptions,\n HttpPostIngressOptions,\n} from '@backstage/plugin-events-node';\n\n/**\n * @alpha\n */\nexport interface EventsExtensionPoint {\n /**\n * @deprecated use `eventsServiceRef` and `eventsServiceFactory` instead\n */\n setEventBroker(eventBroker: EventBroker): void;\n\n /**\n * @deprecated use `EventsService.publish` instead\n */\n addPublishers(\n ...publishers: Array<EventPublisher | Array<EventPublisher>>\n ): void;\n\n /**\n * @deprecated use `EventsService.subscribe` instead\n */\n addSubscribers(\n ...subscribers: Array<EventSubscriber | Array<EventSubscriber>>\n ): void;\n\n addHttpPostIngress(options: HttpPostIngressOptions): void;\n\n addHttpPostBodyParser(options: HttpBodyParserOptions): void;\n}\n\n/**\n * @alpha\n */\nexport const eventsExtensionPoint = createExtensionPoint<EventsExtensionPoint>({\n id: 'events',\n});\n"],"names":["createExtensionPoint"],"mappings":";;;;AAwDO,MAAM,uBAAuBA,qCAAA,CAA2C;AAAA,EAC7E,EAAA,EAAI;AACN,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultApi.client.cjs.js","sources":["../../../src/generated/apis/DefaultApi.client.ts"],"sourcesContent":["/*\n * Copyright 2024 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// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *\n// ******************************************************************\nimport { DiscoveryApi } from '../types/discovery';\nimport { FetchApi } from '../types/fetch';\nimport crossFetch from 'cross-fetch';\nimport { pluginId } from '../pluginId';\nimport * as parser from 'uri-template';\n\nimport { GetSubscriptionEvents200Response } from '../models/GetSubscriptionEvents200Response.model';\nimport { PostEventRequest } from '../models/PostEventRequest.model';\nimport { PutSubscriptionRequest } from '../models/PutSubscriptionRequest.model';\n\n/**\n * Wraps the Response type to convey a type on the json call.\n *\n * @public\n */\nexport type TypedResponse<T> = Omit<Response, 'json'> & {\n json: () => Promise<T>;\n};\n\n/**\n * Options you can pass into a request for additional information.\n *\n * @public\n */\nexport interface RequestOptions {\n token?: string;\n}\n\n/**\n * no description\n */\nexport class DefaultApiClient {\n private readonly discoveryApi: DiscoveryApi;\n private readonly fetchApi: FetchApi;\n\n constructor(options: {\n discoveryApi: { getBaseUrl(pluginId: string): Promise<string> };\n fetchApi?: { fetch: typeof fetch };\n }) {\n this.discoveryApi = options.discoveryApi;\n this.fetchApi = options.fetchApi || { fetch: crossFetch };\n }\n\n /**\n * Get new events for the provided subscription\n * @param subscriptionId\n */\n public async getSubscriptionEvents(\n // @ts-ignore\n request: {\n path: {\n subscriptionId: string;\n };\n },\n options?: RequestOptions,\n ): Promise<TypedResponse<void | GetSubscriptionEvents200Response>> {\n const baseUrl = await this.discoveryApi.getBaseUrl(pluginId);\n\n const uriTemplate = `/bus/v1/subscriptions/{subscriptionId}/events`;\n\n const uri = parser.parse(uriTemplate).expand({\n subscriptionId: request.path.subscriptionId,\n });\n\n return await this.fetchApi.fetch(`${baseUrl}${uri}`, {\n headers: {\n 'Content-Type': 'application/json',\n ...(options?.token && { Authorization: `Bearer ${options?.token}` }),\n },\n method: 'GET',\n });\n }\n\n /**\n * Publish a new event\n * @param postEventRequest\n */\n public async postEvent(\n // @ts-ignore\n request: {\n body: PostEventRequest;\n },\n options?: RequestOptions,\n ): Promise<TypedResponse<void>> {\n const baseUrl = await this.discoveryApi.getBaseUrl(pluginId);\n\n const uriTemplate = `/bus/v1/events`;\n\n const uri = parser.parse(uriTemplate).expand({});\n\n return await this.fetchApi.fetch(`${baseUrl}${uri}`, {\n headers: {\n 'Content-Type': 'application/json',\n ...(options?.token && { Authorization: `Bearer ${options?.token}` }),\n },\n method: 'POST',\n body: JSON.stringify(request.body),\n });\n }\n\n /**\n * Ensures that the subscription exists with the provided configuration\n * @param subscriptionId\n * @param putSubscriptionRequest\n */\n public async putSubscription(\n // @ts-ignore\n request: {\n path: {\n subscriptionId: string;\n };\n body: PutSubscriptionRequest;\n },\n options?: RequestOptions,\n ): Promise<TypedResponse<void>> {\n const baseUrl = await this.discoveryApi.getBaseUrl(pluginId);\n\n const uriTemplate = `/bus/v1/subscriptions/{subscriptionId}`;\n\n const uri = parser.parse(uriTemplate).expand({\n subscriptionId: request.path.subscriptionId,\n });\n\n return await this.fetchApi.fetch(`${baseUrl}${uri}`, {\n headers: {\n 'Content-Type': 'application/json',\n ...(options?.token && { Authorization: `Bearer ${options?.token}` }),\n },\n method: 'PUT',\n body: JSON.stringify(request.body),\n });\n }\n}\n"],"names":["crossFetch","pluginId","parser"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDO,MAAM,
|
|
1
|
+
{"version":3,"file":"DefaultApi.client.cjs.js","sources":["../../../src/generated/apis/DefaultApi.client.ts"],"sourcesContent":["/*\n * Copyright 2024 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// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *\n// ******************************************************************\nimport { DiscoveryApi } from '../types/discovery';\nimport { FetchApi } from '../types/fetch';\nimport crossFetch from 'cross-fetch';\nimport { pluginId } from '../pluginId';\nimport * as parser from 'uri-template';\n\nimport { GetSubscriptionEvents200Response } from '../models/GetSubscriptionEvents200Response.model';\nimport { PostEventRequest } from '../models/PostEventRequest.model';\nimport { PutSubscriptionRequest } from '../models/PutSubscriptionRequest.model';\n\n/**\n * Wraps the Response type to convey a type on the json call.\n *\n * @public\n */\nexport type TypedResponse<T> = Omit<Response, 'json'> & {\n json: () => Promise<T>;\n};\n\n/**\n * Options you can pass into a request for additional information.\n *\n * @public\n */\nexport interface RequestOptions {\n token?: string;\n}\n\n/**\n * no description\n */\nexport class DefaultApiClient {\n private readonly discoveryApi: DiscoveryApi;\n private readonly fetchApi: FetchApi;\n\n constructor(options: {\n discoveryApi: { getBaseUrl(pluginId: string): Promise<string> };\n fetchApi?: { fetch: typeof fetch };\n }) {\n this.discoveryApi = options.discoveryApi;\n this.fetchApi = options.fetchApi || { fetch: crossFetch };\n }\n\n /**\n * Get new events for the provided subscription\n * @param subscriptionId\n */\n public async getSubscriptionEvents(\n // @ts-ignore\n request: {\n path: {\n subscriptionId: string;\n };\n },\n options?: RequestOptions,\n ): Promise<TypedResponse<void | GetSubscriptionEvents200Response>> {\n const baseUrl = await this.discoveryApi.getBaseUrl(pluginId);\n\n const uriTemplate = `/bus/v1/subscriptions/{subscriptionId}/events`;\n\n const uri = parser.parse(uriTemplate).expand({\n subscriptionId: request.path.subscriptionId,\n });\n\n return await this.fetchApi.fetch(`${baseUrl}${uri}`, {\n headers: {\n 'Content-Type': 'application/json',\n ...(options?.token && { Authorization: `Bearer ${options?.token}` }),\n },\n method: 'GET',\n });\n }\n\n /**\n * Publish a new event\n * @param postEventRequest\n */\n public async postEvent(\n // @ts-ignore\n request: {\n body: PostEventRequest;\n },\n options?: RequestOptions,\n ): Promise<TypedResponse<void>> {\n const baseUrl = await this.discoveryApi.getBaseUrl(pluginId);\n\n const uriTemplate = `/bus/v1/events`;\n\n const uri = parser.parse(uriTemplate).expand({});\n\n return await this.fetchApi.fetch(`${baseUrl}${uri}`, {\n headers: {\n 'Content-Type': 'application/json',\n ...(options?.token && { Authorization: `Bearer ${options?.token}` }),\n },\n method: 'POST',\n body: JSON.stringify(request.body),\n });\n }\n\n /**\n * Ensures that the subscription exists with the provided configuration\n * @param subscriptionId\n * @param putSubscriptionRequest\n */\n public async putSubscription(\n // @ts-ignore\n request: {\n path: {\n subscriptionId: string;\n };\n body: PutSubscriptionRequest;\n },\n options?: RequestOptions,\n ): Promise<TypedResponse<void>> {\n const baseUrl = await this.discoveryApi.getBaseUrl(pluginId);\n\n const uriTemplate = `/bus/v1/subscriptions/{subscriptionId}`;\n\n const uri = parser.parse(uriTemplate).expand({\n subscriptionId: request.path.subscriptionId,\n });\n\n return await this.fetchApi.fetch(`${baseUrl}${uri}`, {\n headers: {\n 'Content-Type': 'application/json',\n ...(options?.token && { Authorization: `Bearer ${options?.token}` }),\n },\n method: 'PUT',\n body: JSON.stringify(request.body),\n });\n }\n}\n"],"names":["crossFetch","pluginId","parser"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDO,MAAM,gBAAA,CAAiB;AAAA,EACX,YAAA;AAAA,EACA,QAAA;AAAA,EAEjB,YAAY,OAAA,EAGT;AACD,IAAA,IAAA,CAAK,eAAe,OAAA,CAAQ,YAAA;AAC5B,IAAA,IAAA,CAAK,QAAA,GAAW,OAAA,CAAQ,QAAA,IAAY,EAAE,OAAOA,2BAAA,EAAW;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAa,qBAAA,CAEX,OAAA,EAKA,OAAA,EACiE;AACjE,IAAA,MAAM,OAAA,GAAU,MAAM,IAAA,CAAK,YAAA,CAAa,WAAWC,iBAAQ,CAAA;AAE3D,IAAA,MAAM,WAAA,GAAc,CAAA,6CAAA,CAAA;AAEpB,IAAA,MAAM,GAAA,GAAMC,iBAAA,CAAO,KAAA,CAAM,WAAW,EAAE,MAA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a,WAAWD,iBAAQ,CAAA;AAE3D,IAAA,MAAM,WAAA,GAAc,CAAA,sCAAA,CAAA;AAEpB,IAAA,MAAM,GAAA,GAAMC,iBAAA,CAAO,KAAA,CAAM,WAAW,EAAE,MAAA,CAAO;AAAA,MAC3C,cAAA,EAAgB,QAAQ,IAAA,CAAK;AAAA,KAC9B,CAAA;AAED,IAAA,OAAO,MAAM,KAAK,QAAA,CAAS,KAAA,CAAM,GAAG,OAAO,CAAA,EAAG,GAAG,CAAA,CAAA,EAAI;AAAA,MACnD,OAAA,EAAS;AAAA,QACP,cAAA,EAAgB,kBAAA;AAAA,QAChB,GAAI,SAAS,KAAA,IAAS,EAAE,eAAe,CAAA,OAAA,EAAU,OAAA,EAAS,KAAK,CAAA,CAAA;AAAG,OACpE;AAAA,MACA,MAAA,EAAQ,KAAA;AAAA,MACR,IAAA,EAAM,IAAA,CAAK,SAAA,CAAU,OAAA,CAAQ,IAAI;AAAA,KAClC,CAAA;AAAA,EACH;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pluginId.cjs.js","sources":["../../src/generated/pluginId.ts"],"sourcesContent":["/*\n * Copyright 2024 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\nexport const pluginId = 'events';\n"],"names":[],"mappings":";;AAgBO,MAAM,
|
|
1
|
+
{"version":3,"file":"pluginId.cjs.js","sources":["../../src/generated/pluginId.ts"],"sourcesContent":["/*\n * Copyright 2024 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\nexport const pluginId = 'events';\n"],"names":[],"mappings":";;AAgBO,MAAM,QAAA,GAAW;;;;"}
|
package/dist/service.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.cjs.js","sources":["../src/service.ts"],"sourcesContent":["/*\n * Copyright 2024 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 coreServices,\n createServiceFactory,\n createServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { EventsService, DefaultEventsService } from './api';\n\n/**\n * The {@link EventsService} that allows to publish events, and subscribe to topics.\n * Uses the `root` scope so that events can be shared across all plugins, modules, and more.\n *\n * @public\n */\nexport const eventsServiceRef = createServiceRef<EventsService>({\n id: 'events.service',\n scope: 'plugin',\n});\n\n/** @public */\nexport const eventsServiceFactory = createServiceFactory({\n service: eventsServiceRef,\n deps: {\n pluginMetadata: coreServices.pluginMetadata,\n rootLogger: coreServices.rootLogger,\n discovery: coreServices.discovery,\n logger: coreServices.logger,\n lifecycle: coreServices.lifecycle,\n auth: coreServices.auth,\n config: coreServices.rootConfig,\n },\n async createRootContext({ rootLogger, config }) {\n return DefaultEventsService.create({ logger: rootLogger, config });\n },\n async factory(\n { pluginMetadata, discovery, logger, lifecycle, auth },\n eventsService,\n ) {\n return eventsService.forPlugin(pluginMetadata.getId(), {\n discovery,\n logger,\n lifecycle,\n auth,\n });\n },\n});\n"],"names":["createServiceRef","createServiceFactory","coreServices","DefaultEventsService"],"mappings":";;;;;AA6BO,MAAM,mBAAmBA,
|
|
1
|
+
{"version":3,"file":"service.cjs.js","sources":["../src/service.ts"],"sourcesContent":["/*\n * Copyright 2024 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 coreServices,\n createServiceFactory,\n createServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { EventsService, DefaultEventsService } from './api';\n\n/**\n * The {@link EventsService} that allows to publish events, and subscribe to topics.\n * Uses the `root` scope so that events can be shared across all plugins, modules, and more.\n *\n * @public\n */\nexport const eventsServiceRef = createServiceRef<EventsService>({\n id: 'events.service',\n scope: 'plugin',\n});\n\n/** @public */\nexport const eventsServiceFactory = createServiceFactory({\n service: eventsServiceRef,\n deps: {\n pluginMetadata: coreServices.pluginMetadata,\n rootLogger: coreServices.rootLogger,\n discovery: coreServices.discovery,\n logger: coreServices.logger,\n lifecycle: coreServices.lifecycle,\n auth: coreServices.auth,\n config: coreServices.rootConfig,\n },\n async createRootContext({ rootLogger, config }) {\n return DefaultEventsService.create({ logger: rootLogger, config });\n },\n async factory(\n { pluginMetadata, discovery, logger, lifecycle, auth },\n eventsService,\n ) {\n return eventsService.forPlugin(pluginMetadata.getId(), {\n discovery,\n logger,\n lifecycle,\n auth,\n });\n },\n});\n"],"names":["createServiceRef","createServiceFactory","coreServices","DefaultEventsService"],"mappings":";;;;;AA6BO,MAAM,mBAAmBA,iCAAA,CAAgC;AAAA,EAC9D,EAAA,EAAI,gBAAA;AAAA,EACJ,KAAA,EAAO;AACT,CAAC;AAGM,MAAM,uBAAuBC,qCAAA,CAAqB;AAAA,EACvD,OAAA,EAAS,gBAAA;AAAA,EACT,IAAA,EAAM;AAAA,IACJ,gBAAgBC,6BAAA,CAAa,cAAA;AAAA,IAC7B,YAAYA,6BAAA,CAAa,UAAA;AAAA,IACzB,WAAWA,6BAAA,CAAa,SAAA;AAAA,IACxB,QAAQA,6BAAA,CAAa,MAAA;AAAA,IACrB,WAAWA,6BAAA,CAAa,SAAA;AAAA,IACxB,MAAMA,6BAAA,CAAa,IAAA;AAAA,IACnB,QAAQA,6BAAA,CAAa;AAAA,GACvB;AAAA,EACA,MAAM,iBAAA,CAAkB,EAAE,UAAA,EAAY,QAAO,EAAG;AAC9C,IAAA,OAAOC,0CAAqB,MAAA,CAAO,EAAE,MAAA,EAAQ,UAAA,EAAY,QAAQ,CAAA;AAAA,EACnE,CAAA;AAAA,EACA,MAAM,QACJ,EAAE,cAAA,EAAgB,WAAW,MAAA,EAAQ,SAAA,EAAW,IAAA,EAAK,EACrD,aAAA,EACA;AACA,IAAA,OAAO,aAAA,CAAc,SAAA,CAAU,cAAA,CAAe,KAAA,EAAM,EAAG;AAAA,MACrD,SAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA,EACH;AACF,CAAC;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-events-node",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.14",
|
|
4
4
|
"description": "The plugin-events-node module for @backstage/plugin-events-backend",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "node-library",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"test": "backstage-cli package test"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@backstage/backend-plugin-api": "^1.4.
|
|
63
|
+
"@backstage/backend-plugin-api": "^1.4.2",
|
|
64
64
|
"@backstage/errors": "^1.2.7",
|
|
65
65
|
"@backstage/types": "^1.2.1",
|
|
66
66
|
"@types/content-type": "^1.1.8",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"uri-template": "^2.0.0"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@backstage/backend-test-utils": "^1.
|
|
75
|
-
"@backstage/cli": "^0.
|
|
74
|
+
"@backstage/backend-test-utils": "^1.8.0",
|
|
75
|
+
"@backstage/cli": "^0.34.0",
|
|
76
76
|
"msw": "^1.0.0"
|
|
77
77
|
},
|
|
78
78
|
"configSchema": "config.d.ts"
|