@backstage/plugin-notifications-backend-module-slack 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @backstage/plugin-notifications-backend-module-slack
2
2
 
3
+ ## 0.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/plugin-catalog-node@1.18.0
9
+ - @backstage/plugin-notifications-common@0.1.0
10
+ - @backstage/plugin-notifications-node@0.2.18
11
+ - @backstage/backend-plugin-api@1.4.2
12
+
13
+ ## 0.1.4-next.0
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies
18
+ - @backstage/plugin-catalog-node@1.18.0-next.0
19
+ - @backstage/plugin-notifications-node@0.2.18-next.0
20
+ - @backstage/backend-plugin-api@1.4.2-next.0
21
+ - @backstage/catalog-model@1.7.5
22
+ - @backstage/config@1.3.3
23
+ - @backstage/errors@1.2.7
24
+ - @backstage/types@1.2.1
25
+ - @backstage/plugin-notifications-common@0.0.10
26
+
3
27
  ## 0.1.3
4
28
 
5
29
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"SlackNotificationProcessor.cjs.js","sources":["../../src/lib/SlackNotificationProcessor.ts"],"sourcesContent":["/*\n * Copyright 2025 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 { AuthService, LoggerService } from '@backstage/backend-plugin-api';\nimport {\n Entity,\n isUserEntity,\n parseEntityRef,\n UserEntity,\n} from '@backstage/catalog-model';\nimport { Config } from '@backstage/config';\nimport { NotFoundError } from '@backstage/errors';\nimport { Notification } from '@backstage/plugin-notifications-common';\nimport {\n NotificationProcessor,\n NotificationSendOptions,\n} from '@backstage/plugin-notifications-node';\nimport { durationToMilliseconds } from '@backstage/types';\nimport { Counter, metrics } from '@opentelemetry/api';\nimport { ChatPostMessageArguments, WebClient } from '@slack/web-api';\nimport DataLoader from 'dataloader';\nimport pThrottle from 'p-throttle';\nimport { ANNOTATION_SLACK_BOT_NOTIFY } from './constants';\nimport { ExpiryMap, toChatPostMessageArgs } from './util';\nimport { CatalogService } from '@backstage/plugin-catalog-node';\n\nexport class SlackNotificationProcessor implements NotificationProcessor {\n private readonly logger: LoggerService;\n private readonly catalog: CatalogService;\n private readonly auth: AuthService;\n private readonly slack: WebClient;\n private readonly sendNotifications;\n private readonly messagesSent: Counter;\n private readonly messagesFailed: Counter;\n private readonly broadcastChannels?: string[];\n private readonly entityLoader: DataLoader<string, Entity | undefined>;\n\n static fromConfig(\n config: Config,\n options: {\n auth: AuthService;\n logger: LoggerService;\n catalog: CatalogService;\n slack?: WebClient;\n broadcastChannels?: string[];\n },\n ): SlackNotificationProcessor[] {\n const slackConfig =\n config.getOptionalConfigArray('notifications.processors.slack') ?? [];\n return slackConfig.map(c => {\n const token = c.getString('token');\n const slack = options.slack ?? new WebClient(token);\n const broadcastChannels = c.getOptionalStringArray('broadcastChannels');\n return new SlackNotificationProcessor({\n slack,\n broadcastChannels,\n ...options,\n });\n });\n }\n\n private constructor(options: {\n slack: WebClient;\n auth: AuthService;\n logger: LoggerService;\n catalog: CatalogService;\n broadcastChannels?: string[];\n }) {\n const { auth, catalog, logger, slack, broadcastChannels } = options;\n this.logger = logger;\n this.catalog = catalog;\n this.auth = auth;\n this.slack = slack;\n this.broadcastChannels = broadcastChannels;\n\n this.entityLoader = new DataLoader<string, Entity | undefined>(\n async entityRefs => {\n return await this.catalog\n .getEntitiesByRefs(\n {\n entityRefs: entityRefs.slice(),\n fields: [\n `kind`,\n `spec.profile.email`,\n `metadata.annotations.${ANNOTATION_SLACK_BOT_NOTIFY}`,\n ],\n },\n { credentials: await this.auth.getOwnServiceCredentials() },\n )\n .then(r => r.items);\n },\n {\n name: 'SlackNotificationProcessor.entityLoader',\n cacheMap: new ExpiryMap(durationToMilliseconds({ minutes: 10 })),\n maxBatchSize: 100,\n batchScheduleFn: cb =>\n setTimeout(cb, durationToMilliseconds({ milliseconds: 10 })),\n },\n );\n\n const meter = metrics.getMeter('default');\n this.messagesSent = meter.createCounter(\n 'notifications.processors.slack.sent.count',\n {\n description: 'Number of messages sent to Slack successfully',\n },\n );\n this.messagesFailed = meter.createCounter(\n 'notifications.processors.slack.error.count',\n {\n description: 'Number of messages that failed to send to Slack',\n },\n );\n\n const throttle = pThrottle({\n limit: 10,\n interval: durationToMilliseconds({ minutes: 1 }),\n });\n const throttled = throttle((opts: ChatPostMessageArguments) =>\n this.sendNotification(opts),\n );\n this.sendNotifications = async (opts: ChatPostMessageArguments[]) => {\n const results = await Promise.allSettled(\n opts.map(message => throttled(message)),\n );\n\n let successCount = 0;\n let failureCount = 0;\n\n results.forEach(result => {\n if (result.status === 'fulfilled') {\n successCount++;\n } else {\n this.logger.error(\n `Failed to send Slack channel notification: ${result.reason.message}`,\n );\n failureCount++;\n }\n });\n\n this.messagesSent.add(successCount);\n this.messagesFailed.add(failureCount);\n };\n }\n\n getName(): string {\n return 'SlackNotificationProcessor';\n }\n\n async processOptions(\n options: NotificationSendOptions,\n ): Promise<NotificationSendOptions> {\n if (options.recipients.type !== 'entity') {\n return options;\n }\n\n const entityRefs = [options.recipients.entityRef].flat();\n\n const outbound: ChatPostMessageArguments[] = [];\n await Promise.all(\n entityRefs.map(async entityRef => {\n const compoundEntityRef = parseEntityRef(entityRef);\n // skip users as they are sent direct messages\n if (compoundEntityRef.kind === 'user') {\n return;\n }\n\n let channel;\n try {\n channel = await this.getSlackNotificationTarget(entityRef);\n } catch (error) {\n this.logger.error(\n `Failed to get Slack channel for entity: ${\n (error as Error).message\n }`,\n );\n return;\n }\n\n if (!channel) {\n this.logger.debug(`No Slack channel found for entity: ${entityRef}`);\n return;\n }\n\n this.logger.debug(\n `Sending notification with payload: ${JSON.stringify(\n options.payload,\n )}`,\n );\n\n const payload = toChatPostMessageArgs({\n channel,\n payload: options.payload,\n });\n\n this.logger.debug(\n `Sending Slack channel notification: ${JSON.stringify(payload)}`,\n );\n outbound.push(payload);\n }),\n );\n\n await this.sendNotifications(outbound);\n\n return options;\n }\n\n async postProcess(\n notification: Notification,\n options: NotificationSendOptions,\n ): Promise<void> {\n const destinations: string[] = [];\n\n // Handle broadcast case\n if (notification.user === null) {\n destinations.push(...(this.broadcastChannels ?? []));\n } else if (options.recipients.type === 'entity') {\n // Handle user-specific notification\n const entityRefs = [options.recipients.entityRef].flat();\n if (entityRefs.some(e => parseEntityRef(e).kind === 'group')) {\n // We've already dispatched a slack channel message, so let's not send a DM.\n return;\n }\n\n const destination = await this.getSlackNotificationTarget(\n notification.user,\n );\n\n if (!destination) {\n this.logger.error(\n `No slack.com/bot-notify annotation found for user: ${notification.user}`,\n );\n return;\n }\n\n destinations.push(destination);\n }\n\n // If no destinations, nothing to do\n if (destinations.length === 0) {\n return;\n }\n\n // Prepare outbound messages\n const formattedPayload = await this.formatPayloadDescriptionForSlack(\n options.payload,\n );\n const outbound = destinations.map(channel =>\n toChatPostMessageArgs({ channel, payload: formattedPayload }),\n );\n\n // Log debug info\n outbound.forEach(payload => {\n this.logger.debug(`Sending notification: ${JSON.stringify(payload)}`);\n });\n\n // Send notifications\n await this.sendNotifications(outbound);\n }\n\n private async formatPayloadDescriptionForSlack(\n payload: Notification['payload'],\n ) {\n return {\n ...payload,\n description: await this.replaceUserRefsWithSlackIds(payload.description),\n };\n }\n\n async replaceUserRefsWithSlackIds(\n text?: string,\n ): Promise<string | undefined> {\n if (!text) return undefined;\n\n // Match user entity refs like \"<@user:default/billy>\"\n const userRefRegex = /<@(user:[^>]+)>/gi;\n const matches = [...text.matchAll(userRefRegex)];\n\n if (matches.length === 0) return text;\n\n const uniqueUserRefs = new Set(\n matches.map(match => match[1].toLowerCase()),\n );\n\n const slackIdMap = new Map<string, string>();\n\n await Promise.all(\n [...uniqueUserRefs].map(async userRef => {\n try {\n const slackId = await this.getSlackNotificationTarget(userRef);\n if (slackId) {\n slackIdMap.set(userRef, `<@${slackId}>`);\n }\n } catch (error) {\n this.logger.warn(\n `Failed to resolve Slack ID for user ref \"${userRef}\": ${error}`,\n );\n }\n }),\n );\n\n return text.replace(userRefRegex, (match, userRef) => {\n const slackId = slackIdMap.get(userRef.toLowerCase());\n return slackId ?? match;\n });\n }\n\n async getSlackNotificationTarget(\n entityRef: string,\n ): Promise<string | undefined> {\n const entity = await this.entityLoader.load(entityRef);\n if (!entity) {\n throw new NotFoundError(`Entity not found: ${entityRef}`);\n }\n\n const slackId = await this.resolveSlackId(entity);\n return slackId;\n }\n\n private async resolveSlackId(entity: Entity): Promise<string | undefined> {\n // First try to get Slack ID from annotations\n const slackId = entity.metadata?.annotations?.[ANNOTATION_SLACK_BOT_NOTIFY];\n if (slackId) {\n return slackId;\n }\n\n // If no Slack ID in annotations and entity is a User, try to find by email\n if (isUserEntity(entity)) {\n return this.findSlackIdByEmail(entity);\n }\n\n return undefined;\n }\n\n private async findSlackIdByEmail(\n entity: UserEntity,\n ): Promise<string | undefined> {\n const email = entity.spec?.profile?.email;\n if (!email) {\n return undefined;\n }\n\n try {\n const user = await this.slack.users.lookupByEmail({ email });\n return user.user?.id;\n } catch (error) {\n this.logger.warn(\n `Failed to lookup Slack user by email ${email}: ${error}`,\n );\n return undefined;\n }\n }\n\n async sendNotification(args: ChatPostMessageArguments): Promise<void> {\n const response = await this.slack.chat.postMessage(args);\n\n if (!response.ok) {\n throw new Error(`Failed to send notification: ${response.error}`);\n }\n }\n}\n"],"names":["WebClient","DataLoader","ANNOTATION_SLACK_BOT_NOTIFY","ExpiryMap","durationToMilliseconds","metrics","pThrottle","parseEntityRef","toChatPostMessageArgs","NotFoundError","isUserEnt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CAAS,KAAK,CAAE,CAAA,CAAA;AAAA;AAClE;AAEJ;;;;"}
1
+ {"version":3,"file":"SlackNotificationProcessor.cjs.js","sources":["../../src/lib/SlackNotificationProcessor.ts"],"sourcesContent":["/*\n * Copyright 2025 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 { AuthService, LoggerService } from '@backstage/backend-plugin-api';\nimport {\n Entity,\n isUserEntity,\n parseEntityRef,\n UserEntity,\n} from '@backstage/catalog-model';\nimport { Config } from '@backstage/config';\nimport { NotFoundError } from '@backstage/errors';\nimport { Notification } from '@backstage/plugin-notifications-common';\nimport {\n NotificationProcessor,\n NotificationSendOptions,\n} from '@backstage/plugin-notifications-node';\nimport { durationToMilliseconds } from '@backstage/types';\nimport { Counter, metrics } from '@opentelemetry/api';\nimport { ChatPostMessageArguments, WebClient } from '@slack/web-api';\nimport DataLoader from 'dataloader';\nimport pThrottle from 'p-throttle';\nimport { ANNOTATION_SLACK_BOT_NOTIFY } from './constants';\nimport { ExpiryMap, toChatPostMessageArgs } from './util';\nimport { CatalogService } from '@backstage/plugin-catalog-node';\n\nexport class SlackNotificationProcessor implements NotificationProcessor {\n private readonly logger: LoggerService;\n private readonly catalog: CatalogService;\n private readonly auth: AuthService;\n private readonly slack: WebClient;\n private readonly sendNotifications;\n private readonly messagesSent: Counter;\n private readonly messagesFailed: Counter;\n private readonly broadcastChannels?: string[];\n private readonly entityLoader: DataLoader<string, Entity | undefined>;\n\n static fromConfig(\n config: Config,\n options: {\n auth: AuthService;\n logger: LoggerService;\n catalog: CatalogService;\n slack?: WebClient;\n broadcastChannels?: string[];\n },\n ): SlackNotificationProcessor[] {\n const slackConfig =\n config.getOptionalConfigArray('notifications.processors.slack') ?? [];\n return slackConfig.map(c => {\n const token = c.getString('token');\n const slack = options.slack ?? new WebClient(token);\n const broadcastChannels = c.getOptionalStringArray('broadcastChannels');\n return new SlackNotificationProcessor({\n slack,\n broadcastChannels,\n ...options,\n });\n });\n }\n\n private constructor(options: {\n slack: WebClient;\n auth: AuthService;\n logger: LoggerService;\n catalog: CatalogService;\n broadcastChannels?: string[];\n }) {\n const { auth, catalog, logger, slack, broadcastChannels } = options;\n this.logger = logger;\n this.catalog = catalog;\n this.auth = auth;\n this.slack = slack;\n this.broadcastChannels = broadcastChannels;\n\n this.entityLoader = new DataLoader<string, Entity | undefined>(\n async entityRefs => {\n return await this.catalog\n .getEntitiesByRefs(\n {\n entityRefs: entityRefs.slice(),\n fields: [\n `kind`,\n `spec.profile.email`,\n `metadata.annotations.${ANNOTATION_SLACK_BOT_NOTIFY}`,\n ],\n },\n { credentials: await this.auth.getOwnServiceCredentials() },\n )\n .then(r => r.items);\n },\n {\n name: 'SlackNotificationProcessor.entityLoader',\n cacheMap: new ExpiryMap(durationToMilliseconds({ minutes: 10 })),\n maxBatchSize: 100,\n batchScheduleFn: cb =>\n setTimeout(cb, durationToMilliseconds({ milliseconds: 10 })),\n },\n );\n\n const meter = metrics.getMeter('default');\n this.messagesSent = meter.createCounter(\n 'notifications.processors.slack.sent.count',\n {\n description: 'Number of messages sent to Slack successfully',\n },\n );\n this.messagesFailed = meter.createCounter(\n 'notifications.processors.slack.error.count',\n {\n description: 'Number of messages that failed to send to Slack',\n },\n );\n\n const throttle = pThrottle({\n limit: 10,\n interval: durationToMilliseconds({ minutes: 1 }),\n });\n const throttled = throttle((opts: ChatPostMessageArguments) =>\n this.sendNotification(opts),\n );\n this.sendNotifications = async (opts: ChatPostMessageArguments[]) => {\n const results = await Promise.allSettled(\n opts.map(message => throttled(message)),\n );\n\n let successCount = 0;\n let failureCount = 0;\n\n results.forEach(result => {\n if (result.status === 'fulfilled') {\n successCount++;\n } else {\n this.logger.error(\n `Failed to send Slack channel notification: ${result.reason.message}`,\n );\n failureCount++;\n }\n });\n\n this.messagesSent.add(successCount);\n this.messagesFailed.add(failureCount);\n };\n }\n\n getName(): string {\n return 'SlackNotificationProcessor';\n }\n\n async processOptions(\n options: NotificationSendOptions,\n ): Promise<NotificationSendOptions> {\n if (options.recipients.type !== 'entity') {\n return options;\n }\n\n const entityRefs = [options.recipients.entityRef].flat();\n\n const outbound: ChatPostMessageArguments[] = [];\n await Promise.all(\n entityRefs.map(async entityRef => {\n const compoundEntityRef = parseEntityRef(entityRef);\n // skip users as they are sent direct messages\n if (compoundEntityRef.kind === 'user') {\n return;\n }\n\n let channel;\n try {\n channel = await this.getSlackNotificationTarget(entityRef);\n } catch (error) {\n this.logger.error(\n `Failed to get Slack channel for entity: ${\n (error as Error).message\n }`,\n );\n return;\n }\n\n if (!channel) {\n this.logger.debug(`No Slack channel found for entity: ${entityRef}`);\n return;\n }\n\n this.logger.debug(\n `Sending notification with payload: ${JSON.stringify(\n options.payload,\n )}`,\n );\n\n const payload = toChatPostMessageArgs({\n channel,\n payload: options.payload,\n });\n\n this.logger.debug(\n `Sending Slack channel notification: ${JSON.stringify(payload)}`,\n );\n outbound.push(payload);\n }),\n );\n\n await this.sendNotifications(outbound);\n\n return options;\n }\n\n async postProcess(\n notification: Notification,\n options: NotificationSendOptions,\n ): Promise<void> {\n const destinations: string[] = [];\n\n // Handle broadcast case\n if (notification.user === null) {\n destinations.push(...(this.broadcastChannels ?? []));\n } else if (options.recipients.type === 'entity') {\n // Handle user-specific notification\n const entityRefs = [options.recipients.entityRef].flat();\n if (entityRefs.some(e => parseEntityRef(e).kind === 'group')) {\n // We've already dispatched a slack channel message, so let's not send a DM.\n return;\n }\n\n const destination = await this.getSlackNotificationTarget(\n notification.user,\n );\n\n if (!destination) {\n this.logger.error(\n `No slack.com/bot-notify annotation found for user: ${notification.user}`,\n );\n return;\n }\n\n destinations.push(destination);\n }\n\n // If no destinations, nothing to do\n if (destinations.length === 0) {\n return;\n }\n\n // Prepare outbound messages\n const formattedPayload = await this.formatPayloadDescriptionForSlack(\n options.payload,\n );\n const outbound = destinations.map(channel =>\n toChatPostMessageArgs({ channel, payload: formattedPayload }),\n );\n\n // Log debug info\n outbound.forEach(payload => {\n this.logger.debug(`Sending notification: ${JSON.stringify(payload)}`);\n });\n\n // Send notifications\n await this.sendNotifications(outbound);\n }\n\n private async formatPayloadDescriptionForSlack(\n payload: Notification['payload'],\n ) {\n return {\n ...payload,\n description: await this.replaceUserRefsWithSlackIds(payload.description),\n };\n }\n\n async replaceUserRefsWithSlackIds(\n text?: string,\n ): Promise<string | undefined> {\n if (!text) return undefined;\n\n // Match user entity refs like \"<@user:default/billy>\"\n const userRefRegex = /<@(user:[^>]+)>/gi;\n const matches = [...text.matchAll(userRefRegex)];\n\n if (matches.length === 0) return text;\n\n const uniqueUserRefs = new Set(\n matches.map(match => match[1].toLowerCase()),\n );\n\n const slackIdMap = new Map<string, string>();\n\n await Promise.all(\n [...uniqueUserRefs].map(async userRef => {\n try {\n const slackId = await this.getSlackNotificationTarget(userRef);\n if (slackId) {\n slackIdMap.set(userRef, `<@${slackId}>`);\n }\n } catch (error) {\n this.logger.warn(\n `Failed to resolve Slack ID for user ref \"${userRef}\": ${error}`,\n );\n }\n }),\n );\n\n return text.replace(userRefRegex, (match, userRef) => {\n const slackId = slackIdMap.get(userRef.toLowerCase());\n return slackId ?? match;\n });\n }\n\n async getSlackNotificationTarget(\n entityRef: string,\n ): Promise<string | undefined> {\n const entity = await this.entityLoader.load(entityRef);\n if (!entity) {\n throw new NotFoundError(`Entity not found: ${entityRef}`);\n }\n\n const slackId = await this.resolveSlackId(entity);\n return slackId;\n }\n\n private async resolveSlackId(entity: Entity): Promise<string | undefined> {\n // First try to get Slack ID from annotations\n const slackId = entity.metadata?.annotations?.[ANNOTATION_SLACK_BOT_NOTIFY];\n if (slackId) {\n return slackId;\n }\n\n // If no Slack ID in annotations and entity is a User, try to find by email\n if (isUserEntity(entity)) {\n return this.findSlackIdByEmail(entity);\n }\n\n return undefined;\n }\n\n private async findSlackIdByEmail(\n entity: UserEntity,\n ): Promise<string | undefined> {\n const email = entity.spec?.profile?.email;\n if (!email) {\n return undefined;\n }\n\n try {\n const user = await this.slack.users.lookupByEmail({ email });\n return user.user?.id;\n } catch (error) {\n this.logger.warn(\n `Failed to lookup Slack user by email ${email}: ${error}`,\n );\n return undefined;\n }\n }\n\n async sendNotification(args: ChatPostMessageArguments): Promise<void> {\n const response = await this.slack.chat.postMessage(args);\n\n if (!response.ok) {\n throw new Error(`Failed to send notification: ${response.error}`);\n }\n }\n}\n"],"names":["WebClient","DataLoader","ANNOTATION_SLACK_BOT_NOTIFY","ExpiryMap","durationToMilliseconds","metrics","pThrottle","parseEntityRef","toChatPostMessageArgs","NotFoundError","isUserEntity"],"mappings":";;;;;;;;;;;;;;;;;AAuCO,MAAM,0BAAA,CAA4D;AAAA,EACtD,MAAA;AAAA,EACA,OAAA;AAAA,EACA,IAAA;AAAA,EACA,KAAA;AAAA,EACA,iBAAA;AAAA,EACA,YAAA;AAAA,EACA,cAAA;AAAA,EACA,iBAAA;AAAA,EACA,YAAA;AAAA,EAEjB,OAAO,UAAA,CACL,MAAA,EACA,OAAA,EAO8B;AAC9B,IAAA,MAAM,WAAA,GACJ,MAAA,CAAO,sBAAA,CAAuB,gCAAgC,KAAK,EAAC;AACtE,IAAA,OAAO,WAAA,CAAY,IAAI,CAAA,CAAA,KAAK;AAC1B,MAAA,MAAM,KAAA,GAAQ,CAAA,CAAE,SAAA,CAAU,OAAO,CAAA;AACjC,MAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,KAAA,IAAS,IAAIA,iBAAU,KAAK,CAAA;AAClD,MAAA,MAAM,iBAAA,GAAoB,CAAA,CAAE,sBAAA,CAAuB,mBAAmB,CAAA;AACtE,MAAA,OAAO,IAAI,0BAAA,CAA2B;AAAA,QACpC,KAAA;AAA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ACZ,MAAA,EAC6B;AAC7B,IAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,IAAA,EAAM,OAAA,EAAS,KAAA;AACpC,IAAA,IAAI,CAAC,KAAA,EAAO;AACV,MAAA,OAAO,MAAA;AAAA,IACT;AAEA,IAAA,IAAI;AACF,MAAA,MAAM,IAAA,GAAO,MAAM,IAAA,CAAK,KAAA,CAAM,MAAM,aAAA,CAAc,EAAE,OAAO,CAAA;AAC3D,MAAA,OAAO,KAAK,IAAA,EAAM,EAAA;AAAA,IACpB,SAAS,KAAA,EAAO;AACd,MAAA,IAAA,CAAK,MAAA,CAAO,IAAA;AAAA,QACV,CAAA,qCAAA,EAAwC,KAAK,CAAA,EAAA,EAAK,KAAK,CAAA;AAAA,OACzD;AACA,MAAA,OAAO,MAAA;AAAA,IACT;AAAA,EACF;AAAA,EAEA,MAAM,iBAAiB,IAAA,EAA+C;AACpE,IAAA,MAAM,WAAW,MAAM,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,YAAY,IAAI,CAAA;AAEvD,IAAA,IAAI,CAAC,SAAS,EAAA,EAAI;AAChB,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,6BAAA,EAAgC,QAAA,CAAS,KAAK,CAAA,CAAE,CAAA;AAAA,IAClE;AAAA,EACF;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.cjs.js","sources":["../../src/lib/constants.ts"],"sourcesContent":["/*\n * Copyright 2025 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 * @public\n * The annotation key for the entity's Slack ID. This can be\n * any valid chat.postMessage destination including:\n * - A user ID (U12345678)\n * - A channel ID (C12345678)\n * - A DM ID (D12345678)\n * - A group ID (S12345678)\n *\n * It can also be a user's email address or a channel name,\n * however IDs are preferred.\n */\nexport const ANNOTATION_SLACK_BOT_NOTIFY = 'slack.com/bot-notify';\n"],"names":[],"mappings":";;AA4BO,MAAM,2BAA8B,GAAA;;;;"}
1
+ {"version":3,"file":"constants.cjs.js","sources":["../../src/lib/constants.ts"],"sourcesContent":["/*\n * Copyright 2025 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 * @public\n * The annotation key for the entity's Slack ID. This can be\n * any valid chat.postMessage destination including:\n * - A user ID (U12345678)\n * - A channel ID (C12345678)\n * - A DM ID (D12345678)\n * - A group ID (S12345678)\n *\n * It can also be a user's email address or a channel name,\n * however IDs are preferred.\n */\nexport const ANNOTATION_SLACK_BOT_NOTIFY = 'slack.com/bot-notify';\n"],"names":[],"mappings":";;AA4BO,MAAM,2BAAA,GAA8B;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"util.cjs.js","sources":["../../src/lib/util.ts"],"sourcesContent":["/*\n * Copyright 2025 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 NotificationPayload,\n NotificationSeverity,\n} from '@backstage/plugin-notifications-common';\nimport { ChatPostMessageArguments, KnownBlock } from '@slack/web-api';\n\nexport function toChatPostMessageArgs(options: {\n channel: string;\n payload: NotificationPayload;\n}): ChatPostMessageArguments {\n const { channel, payload } = options;\n\n const args: ChatPostMessageArguments = {\n channel,\n text: payload.title,\n attachments: [\n {\n color: getColor(payload.severity),\n blocks: toSlackBlockKit(payload),\n fallback: payload.title,\n },\n ],\n };\n\n return args;\n}\n\nexport function toSlackBlockKit(payload: NotificationPayload): KnownBlock[] {\n const { description, link, severity, topic } = payload;\n return [\n {\n type: 'section',\n text: {\n type: 'mrkdwn',\n text: description ?? 'No description provided',\n },\n accessory: {\n type: 'button',\n text: {\n type: 'plain_text',\n text: 'View More',\n },\n ...(link && { url: link }),\n action_id: 'button-action',\n },\n },\n {\n type: 'context',\n elements: [\n {\n type: 'plain_text',\n text: `Severity: ${severity ?? 'normal'}`,\n emoji: true,\n },\n {\n type: 'plain_text',\n text: `Topic: ${topic ?? 'N/A'}`,\n emoji: true,\n },\n ],\n },\n ];\n}\n\nfunction getColor(severity: NotificationSeverity | undefined) {\n switch (severity) {\n case 'critical':\n return '#FF0000'; // Red\n case 'high':\n return '#FFA500'; // Orange\n case 'low':\n case 'normal':\n default:\n return '#00A699'; // Neutral color\n }\n}\n\n// Simple expiry map for the data loader, which only expects a map that implements set, get, and delete and clear\nexport class ExpiryMap<K, V> extends Map<K, V> {\n #ttlMs: number;\n #timestamps: Map<K, number> = new Map();\n\n constructor(ttlMs: number) {\n super();\n this.#ttlMs = ttlMs;\n }\n\n set(key: K, value: V) {\n const result = super.set(key, value);\n this.#timestamps.set(key, Date.now());\n return result;\n }\n\n get(key: K) {\n if (!this.has(key)) {\n return undefined;\n }\n const timestamp = this.#timestamps.get(key)!;\n if (Date.now() - timestamp > this.#ttlMs) {\n this.delete(key);\n return undefined;\n }\n return super.get(key);\n }\n\n delete(key: K) {\n this.#timestamps.delete(key);\n return super.delete(key);\n }\n\n clear() {\n this.#timestamps.clear();\n return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A,CAAA,WAAA,CAAY,OAAO,GAAG,CAAA;AAC3B,IAAO,OAAA,KAAA,CAAM,OAAO,GAAG,CAAA;AAAA;AACzB,EAEA,KAAQ,GAAA;AACN,IAAA,IAAA,CAAK,YAAY,KAAM,EAAA;AACvB,IAAA,OAAO,MAAM,KAAM,EAAA;AAAA;AAEvB;;;;;;"}
1
+ {"version":3,"file":"util.cjs.js","sources":["../../src/lib/util.ts"],"sourcesContent":["/*\n * Copyright 2025 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 NotificationPayload,\n NotificationSeverity,\n} from '@backstage/plugin-notifications-common';\nimport { ChatPostMessageArguments, KnownBlock } from '@slack/web-api';\n\nexport function toChatPostMessageArgs(options: {\n channel: string;\n payload: NotificationPayload;\n}): ChatPostMessageArguments {\n const { channel, payload } = options;\n\n const args: ChatPostMessageArguments = {\n channel,\n text: payload.title,\n attachments: [\n {\n color: getColor(payload.severity),\n blocks: toSlackBlockKit(payload),\n fallback: payload.title,\n },\n ],\n };\n\n return args;\n}\n\nexport function toSlackBlockKit(payload: NotificationPayload): KnownBlock[] {\n const { description, link, severity, topic } = payload;\n return [\n {\n type: 'section',\n text: {\n type: 'mrkdwn',\n text: description ?? 'No description provided',\n },\n accessory: {\n type: 'button',\n text: {\n type: 'plain_text',\n text: 'View More',\n },\n ...(link && { url: link }),\n action_id: 'button-action',\n },\n },\n {\n type: 'context',\n elements: [\n {\n type: 'plain_text',\n text: `Severity: ${severity ?? 'normal'}`,\n emoji: true,\n },\n {\n type: 'plain_text',\n text: `Topic: ${topic ?? 'N/A'}`,\n emoji: true,\n },\n ],\n },\n ];\n}\n\nfunction getColor(severity: NotificationSeverity | undefined) {\n switch (severity) {\n case 'critical':\n return '#FF0000'; // Red\n case 'high':\n return '#FFA500'; // Orange\n case 'low':\n case 'normal':\n default:\n return '#00A699'; // Neutral color\n }\n}\n\n// Simple expiry map for the data loader, which only expects a map that implements set, get, and delete and clear\nexport class ExpiryMap<K, V> extends Map<K, V> {\n #ttlMs: number;\n #timestamps: Map<K, number> = new Map();\n\n constructor(ttlMs: number) {\n super();\n this.#ttlMs = ttlMs;\n }\n\n set(key: K, value: V) {\n const result = super.set(key, value);\n this.#timestamps.set(key, Date.now());\n return result;\n }\n\n get(key: K) {\n if (!this.has(key)) {\n return undefined;\n }\n const timestamp = this.#timestamps.get(key)!;\n if (Date.now() - timestamp > this.#ttlMs) {\n this.delete(key);\n return undefined;\n }\n return super.get(key);\n }\n\n delete(key: K) {\n this.#timestamps.delete(key);\n return super.delete(key);\n }\n\n clear() {\n this.#timestamps.clear();\n return super.clear();\n }\n}\n"],"names":[],"mappings":";;AAsBO,SAAS,sBAAsB,OAAA,EAGT;AAC3B,EAAA,MAAM,EAAE,OAAA,EAAS,OAAA,EAAQ,GAAI,OAAA;AAE7B,EAAA,MAAM,IAAA,GAAiC;AAAA,IACrC,OAAA;AAAA,IACA,MAAM,OAAA,CAAQ,KAAA;AAAA,IACd,WAAA,EAAa;AAAA,MACX;AAAA,QACE,KAAA,EAAO,QAAA,CAAS,OAAA,CAAQ,QAAQ,CAAA;AAAA,QAChC,MAAA,EAAQ,gBAAgB,OAAO,CAAA;AAAA,QAC/B,UAAU,OAAA,CAAQ;AAAA;AACpB;AACF,GACF;AAEA,EAAA,OAAO,IAAA;AACT;AAEO,SAAS,gBAAgB,OAAA,EAA4C;AAC1E,EAAA,MAAM,EAAE,WAAA,EAAa,IAAA,EAAM,QAAA,EAAU,OAAM,GAAI,OAAA;AAC/C,EAAA,OAAO;AAAA,IACL;AAAA,MACE,IAAA,EAAM,SAAA;AAAA,MACN,IAAA,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,CAAI,GAAA,EAAK,KAAK,CAAA;AACnC,IAAA,IAAA,CAAK,WAAA,CAAY,GAAA,CAAI,GAAA,EAAK,IAAA,CAAK,KAAK,CAAA;AACpC,IAAA,OAAO,MAAA;AAAA,EACT;AAAA,EAEA,IAAI,GAAA,EAAQ;AACV,IAAA,IAAI,CAAC,IAAA,CAAK,GAAA,CAAI,GAAG,CAAA,EAAG;AAClB,MAAA,OAAO,MAAA;AAAA,IACT;AACA,IAAA,MAAM,SAAA,GAAY,IAAA,CAAK,WAAA,CAAY,GAAA,CAAI,GAAG,CAAA;AAC1C,IAAA,IAAI,IAAA,CAAK,GAAA,EAAI,GAAI,SAAA,GAAY,KAAK,MAAA,EAAQ;AACxC,MAAA,IAAA,CAAK,OAAO,GAAG,CAAA;AACf,MAAA,OAAO,MAAA;AAAA,IACT;AACA,IAAA,OAAO,KAAA,CAAM,IAAI,GAAG,CAAA;AAAA,EACtB;AAAA,EAEA,OAAO,GAAA,EAAQ;AACb,IAAA,IAAA,CAAK,WAAA,CAAY,OAAO,GAAG,CAAA;AAC3B,IAAA,OAAO,KAAA,CAAM,OAAO,GAAG,CAAA;AAAA,EACzB;AAAA,EAEA,KAAA,GAAQ;AACN,IAAA,IAAA,CAAK,YAAY,KAAA,EAAM;AACvB,IAAA,OAAO,MAAM,KAAA,EAAM;AAAA,EACrB;AACF;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"module.cjs.js","sources":["../src/module.ts"],"sourcesContent":["/*\n * Copyright 2025 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 */\nimport {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { notificationsProcessingExtensionPoint } from '@backstage/plugin-notifications-node';\nimport { SlackNotificationProcessor } from './lib/SlackNotificationProcessor';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node';\n\n/**\n * The Slack notification processor for use with the notifications plugin.\n * This allows sending of notifications via Slack DMs or to channels.\n *\n * @public\n */\nexport const notificationsModuleSlack = createBackendModule({\n pluginId: 'notifications',\n moduleId: 'slack',\n register(reg) {\n reg.registerInit({\n deps: {\n auth: coreServices.auth,\n config: coreServices.rootConfig,\n logger: coreServices.logger,\n catalog: catalogServiceRef,\n notifications: notificationsProcessingExtensionPoint,\n },\n async init({ auth, config, logger, catalog, notifications }) {\n notifications.addProcessor(\n SlackNotificationProcessor.fromConfig(config, {\n auth,\n logger,\n catalog,\n }),\n );\n },\n });\n },\n});\n"],"names":["createBackendModule","coreServices","catalogServiceRef","notificationsProcessingExtensionPoint","SlackNotificationProcessor"],"mappings":";;;;;;;AA6BO,MAAM,2BAA2BA,oCAAoB,CAAA;AAAA,EAC1D,QAAU,EAAA,eAAA;AAAA,EACV,QAAU,EAAA,OAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,MAAMC,6BAAa,CAAA,IAAA;AAAA,QACnB,QAAQA,6BAAa,CAAA,UAAA;AAAA,QACrB,QAAQA,6BAAa,CAAA,MAAA;AAAA,QACrB,OAAS,EAAAC,mCAAA;AAAA,QACT,aAAe,EAAAC;AAAA,OACjB;AAAA,MACA,MAAM,KAAK,EAAE,IAAA,EAAM,QAAQ,MAAQ,EAAA,OAAA,EAAS,eAAiB,EAAA;AAC3D,QAAc,aAAA,CAAA,YAAA;AAAA,UACZC,qDAAA,CAA2B,WAAW,MAAQ,EAAA;AAAA,YAC5C,IAAA;AAAA,YACA,MAAA;AAAA,YACA;AAAA,WACD;AAAA,SACH;AAAA;AACF,KACD,CAAA;AAAA;AAEL,CAAC;;;;"}
1
+ {"version":3,"file":"module.cjs.js","sources":["../src/module.ts"],"sourcesContent":["/*\n * Copyright 2025 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 */\nimport {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { notificationsProcessingExtensionPoint } from '@backstage/plugin-notifications-node';\nimport { SlackNotificationProcessor } from './lib/SlackNotificationProcessor';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node';\n\n/**\n * The Slack notification processor for use with the notifications plugin.\n * This allows sending of notifications via Slack DMs or to channels.\n *\n * @public\n */\nexport const notificationsModuleSlack = createBackendModule({\n pluginId: 'notifications',\n moduleId: 'slack',\n register(reg) {\n reg.registerInit({\n deps: {\n auth: coreServices.auth,\n config: coreServices.rootConfig,\n logger: coreServices.logger,\n catalog: catalogServiceRef,\n notifications: notificationsProcessingExtensionPoint,\n },\n async init({ auth, config, logger, catalog, notifications }) {\n notifications.addProcessor(\n SlackNotificationProcessor.fromConfig(config, {\n auth,\n logger,\n catalog,\n }),\n );\n },\n });\n },\n});\n"],"names":["createBackendModule","coreServices","catalogServiceRef","notificationsProcessingExtensionPoint","SlackNotificationProcessor"],"mappings":";;;;;;;AA6BO,MAAM,2BAA2BA,oCAAA,CAAoB;AAAA,EAC1D,QAAA,EAAU,eAAA;AAAA,EACV,QAAA,EAAU,OAAA;AAAA,EACV,SAAS,GAAA,EAAK;AACZ,IAAA,GAAA,CAAI,YAAA,CAAa;AAAA,MACf,IAAA,EAAM;AAAA,QACJ,MAAMC,6BAAA,CAAa,IAAA;AAAA,QACnB,QAAQA,6BAAA,CAAa,UAAA;AAAA,QACrB,QAAQA,6BAAA,CAAa,MAAA;AAAA,QACrB,OAAA,EAASC,mCAAA;AAAA,QACT,aAAA,EAAeC;AAAA,OACjB;AAAA,MACA,MAAM,KAAK,EAAE,IAAA,EAAM,QAAQ,MAAA,EAAQ,OAAA,EAAS,eAAc,EAAG;AAC3D,QAAA,aAAA,CAAc,YAAA;AAAA,UACZC,qDAAA,CAA2B,WAAW,MAAA,EAAQ;AAAA,YAC5C,IAAA;AAAA,YACA,MAAA;AAAA,YACA;AAAA,WACD;AAAA,SACH;AAAA,MACF;AAAA,KACD,CAAA;AAAA,EACH;AACF,CAAC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-notifications-backend-module-slack",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "The slack backend module for the notifications plugin.",
5
5
  "backstage": {
6
6
  "role": "backend-plugin-module",
@@ -37,13 +37,13 @@
37
37
  "test": "backstage-cli package test"
38
38
  },
39
39
  "dependencies": {
40
- "@backstage/backend-plugin-api": "^1.4.1",
40
+ "@backstage/backend-plugin-api": "^1.4.2",
41
41
  "@backstage/catalog-model": "^1.7.5",
42
42
  "@backstage/config": "^1.3.3",
43
43
  "@backstage/errors": "^1.2.7",
44
- "@backstage/plugin-catalog-node": "^1.17.2",
45
- "@backstage/plugin-notifications-common": "^0.0.10",
46
- "@backstage/plugin-notifications-node": "^0.2.17",
44
+ "@backstage/plugin-catalog-node": "^1.18.0",
45
+ "@backstage/plugin-notifications-common": "^0.1.0",
46
+ "@backstage/plugin-notifications-node": "^0.2.18",
47
47
  "@backstage/types": "^1.2.1",
48
48
  "@opentelemetry/api": "^1.9.0",
49
49
  "@slack/bolt": "^3.21.4",
@@ -53,10 +53,10 @@
53
53
  "p-throttle": "^4.1.1"
54
54
  },
55
55
  "devDependencies": {
56
- "@backstage/backend-test-utils": "^1.7.0",
57
- "@backstage/cli": "^0.33.1",
58
- "@backstage/plugin-catalog-node": "^1.17.2",
59
- "@backstage/test-utils": "^1.7.10",
56
+ "@backstage/backend-test-utils": "^1.8.0",
57
+ "@backstage/cli": "^0.34.0",
58
+ "@backstage/plugin-catalog-node": "^1.18.0",
59
+ "@backstage/test-utils": "^1.7.11",
60
60
  "@faker-js/faker": "^8.4.1",
61
61
  "msw": "^2.0.0"
62
62
  },