@backstage/plugin-notifications-backend 0.1.0-next.0 → 0.1.0-next.1

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,28 @@
1
1
  # @backstage/plugin-notifications-backend
2
2
 
3
+ ## 0.1.0-next.1
4
+
5
+ ### Minor Changes
6
+
7
+ - 07abfe1: The NotificationsPage newly uses pagination implemented on the backend layer to avoid large dataset transfers
8
+ - daf85dc: BREAKING CHANGE: Migrates signals to use the `EventsService` and makes it mandatory
9
+
10
+ ### Patch Changes
11
+
12
+ - a790a3d: Move notification origin resolving to backend with new auth
13
+ - Updated dependencies
14
+ - @backstage/config@1.2.0-next.1
15
+ - @backstage/plugin-notifications-common@0.0.2-next.1
16
+ - @backstage/plugin-notifications-node@0.1.0-next.1
17
+ - @backstage/plugin-signals-node@0.1.0-next.1
18
+ - @backstage/backend-common@0.21.4-next.1
19
+ - @backstage/backend-plugin-api@0.6.14-next.1
20
+ - @backstage/plugin-auth-node@0.4.9-next.1
21
+ - @backstage/catalog-client@1.6.1-next.0
22
+ - @backstage/catalog-model@1.4.5-next.0
23
+ - @backstage/errors@1.2.4-next.0
24
+ - @backstage/plugin-events-node@0.3.0-next.1
25
+
3
26
  ## 0.1.0-next.0
4
27
 
5
28
  ### Minor Changes
package/dist/index.cjs.js CHANGED
@@ -142,6 +142,15 @@ class DatabaseNotificationsStore {
142
142
  const notifications = await notificationQuery.select();
143
143
  return this.mapToNotifications(notifications);
144
144
  }
145
+ async getNotificationsCount(options) {
146
+ const countOptions = { ...options };
147
+ countOptions.limit = void 0;
148
+ countOptions.offset = void 0;
149
+ countOptions.sort = null;
150
+ const notificationQuery = this.getNotificationsBaseQuery(countOptions);
151
+ const response = await notificationQuery.count("* as CNT");
152
+ return Number(response[0].CNT);
153
+ }
145
154
  async saveNotification(notification) {
146
155
  await this.db.insert(this.mapNotificationToDbRow(notification)).into("notification");
147
156
  }
@@ -208,7 +217,9 @@ async function createRouter(options) {
208
217
  const {
209
218
  logger,
210
219
  database,
211
- identity,
220
+ auth,
221
+ httpAuth,
222
+ userInfo,
212
223
  discovery,
213
224
  catalog,
214
225
  processors,
@@ -216,13 +227,10 @@ async function createRouter(options) {
216
227
  } = options;
217
228
  const catalogClient$1 = catalog != null ? catalog : new catalogClient.CatalogClient({ discoveryApi: discovery });
218
229
  const store = await DatabaseNotificationsStore.create({ database });
219
- const { auth, httpAuth } = backendCommon.createLegacyAuthAdapters(options);
220
230
  const getUser = async (req) => {
221
- const user = await identity.getIdentity({ request: req });
222
- if (!user) {
223
- throw new errors.AuthenticationError();
224
- }
225
- return user.identity.userEntityRef;
231
+ const credentials = await httpAuth.credentials(req, { allow: ["user"] });
232
+ const info = await userInfo.getUserInfo(credentials);
233
+ return info.userEntityRef;
226
234
  };
227
235
  const getUsersForEntityRef = async (entityRef) => {
228
236
  const { token } = await auth.getPluginRequestToken({
@@ -320,14 +328,20 @@ async function createRouter(options) {
320
328
  opts.read = false;
321
329
  }
322
330
  if (req.query.created_after) {
323
- const sinceEpoch = Date.parse(req.query.created_after.toString());
331
+ const sinceEpoch = Date.parse(String(req.query.created_after));
324
332
  if (isNaN(sinceEpoch)) {
325
333
  throw new errors.InputError("Unexpected date format");
326
334
  }
327
335
  opts.createdAfter = new Date(sinceEpoch);
328
336
  }
329
- const notifications = await store.getNotifications(opts);
330
- res.send(notifications);
337
+ const [notifications, totalCount] = await Promise.all([
338
+ store.getNotifications(opts),
339
+ store.getNotificationsCount(opts)
340
+ ]);
341
+ res.send({
342
+ totalCount,
343
+ notifications
344
+ });
331
345
  });
332
346
  router.get("/:id", async (req, res) => {
333
347
  const user = await getUser(req);
@@ -383,12 +397,12 @@ async function createRouter(options) {
383
397
  });
384
398
  router.post("/", async (req, res) => {
385
399
  var _a;
386
- const { recipients, origin, payload } = req.body;
400
+ const { recipients, payload } = req.body;
387
401
  const notifications = [];
388
402
  let users = [];
389
- await httpAuth.credentials(req, { allow: ["service"] });
390
- const { title, link, scope } = payload;
391
- if (!recipients || !title || !origin || !link) {
403
+ const credentials = await httpAuth.credentials(req, { allow: ["service"] });
404
+ const { title, scope } = payload;
405
+ if (!recipients || !title) {
392
406
  logger.error(`Invalid notification request received`);
393
407
  throw new errors.InputError();
394
408
  }
@@ -401,6 +415,7 @@ async function createRouter(options) {
401
415
  } catch (e) {
402
416
  throw new errors.InputError();
403
417
  }
418
+ const origin = credentials.principal.subject;
404
419
  const baseNotification = {
405
420
  payload: {
406
421
  ...payload,
@@ -492,22 +507,20 @@ const notificationsPlugin = backendPluginApi.createBackendPlugin({
492
507
  deps: {
493
508
  auth: backendPluginApi.coreServices.auth,
494
509
  httpAuth: backendPluginApi.coreServices.httpAuth,
510
+ userInfo: backendPluginApi.coreServices.userInfo,
495
511
  httpRouter: backendPluginApi.coreServices.httpRouter,
496
512
  logger: backendPluginApi.coreServices.logger,
497
- identity: backendPluginApi.coreServices.identity,
498
513
  database: backendPluginApi.coreServices.database,
499
- tokenManager: backendPluginApi.coreServices.tokenManager,
500
514
  discovery: backendPluginApi.coreServices.discovery,
501
515
  signals: pluginSignalsNode.signalService
502
516
  },
503
517
  async init({
504
518
  auth,
505
519
  httpAuth,
520
+ userInfo,
506
521
  httpRouter,
507
522
  logger,
508
- identity,
509
523
  database,
510
- tokenManager,
511
524
  discovery,
512
525
  signals
513
526
  }) {
@@ -515,10 +528,9 @@ const notificationsPlugin = backendPluginApi.createBackendPlugin({
515
528
  await createRouter({
516
529
  auth,
517
530
  httpAuth,
531
+ userInfo,
518
532
  logger,
519
- identity,
520
533
  database,
521
- tokenManager,
522
534
  discovery,
523
535
  signalService: signals,
524
536
  processors: processingExtensions.processors
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/database/DatabaseNotificationsStore.ts","../src/service/router.ts","../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2023 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 PluginDatabaseManager,\n resolvePackagePath,\n} from '@backstage/backend-common';\nimport {\n NotificationGetOptions,\n NotificationModifyOptions,\n NotificationsStore,\n} from './NotificationsStore';\nimport { Notification } from '@backstage/plugin-notifications-common';\nimport { Knex } from 'knex';\n\nconst migrationsDir = resolvePackagePath(\n '@backstage/plugin-notifications-backend',\n 'migrations',\n);\n\n/** @internal */\nexport class DatabaseNotificationsStore implements NotificationsStore {\n private constructor(private readonly db: Knex) {}\n\n static async create({\n database,\n skipMigrations,\n }: {\n database: PluginDatabaseManager;\n skipMigrations?: boolean;\n }): Promise<DatabaseNotificationsStore> {\n const client = await database.getClient();\n\n if (!database.migrations?.skip && !skipMigrations) {\n await client.migrate.latest({\n directory: migrationsDir,\n });\n }\n\n return new DatabaseNotificationsStore(client);\n }\n\n private mapToInteger = (val: string | number | undefined): number => {\n return typeof val === 'string' ? Number.parseInt(val, 10) : val ?? 0;\n };\n\n private mapToNotifications = (rows: any[]): Notification[] => {\n return rows.map(row => ({\n id: row.id,\n user: row.user,\n created: row.created,\n saved: row.saved,\n read: row.read,\n updated: row.updated,\n origin: row.origin,\n payload: {\n title: row.title,\n description: row.description,\n link: row.link,\n topic: row.topic,\n severity: row.severity,\n scope: row.scope,\n icon: row.icon,\n },\n }));\n };\n\n private mapNotificationToDbRow = (notification: Notification) => {\n return {\n id: notification.id,\n user: notification.user,\n origin: notification.origin,\n created: notification.created,\n topic: notification.payload?.topic,\n link: notification.payload?.link,\n title: notification.payload?.title,\n description: notification.payload?.description,\n severity: notification.payload?.severity,\n scope: notification.payload?.scope,\n saved: notification.saved,\n read: notification.read,\n };\n };\n\n private getNotificationsBaseQuery = (\n options: NotificationGetOptions | NotificationModifyOptions,\n ) => {\n const { user } = options;\n const isSQLite = this.db.client.config.client.includes('sqlite3');\n // const isPsql = this.db.client.config.client.includes('pg');\n\n const query = this.db('notification').where('user', user);\n\n if (options.sort !== undefined && options.sort !== null) {\n query.orderBy(options.sort, options.sortOrder ?? 'desc');\n } else if (options.sort !== null) {\n query.orderBy('created', options.sortOrder ?? 'desc');\n }\n\n if (options.createdAfter) {\n if (isSQLite) {\n query.where(\n 'notification.created',\n '>=',\n options.createdAfter.valueOf(),\n );\n } else {\n query.where(\n 'notification.created',\n '>=',\n options.createdAfter.toISOString(),\n );\n }\n }\n\n if (options.limit) {\n query.limit(options.limit);\n }\n\n if (options.offset) {\n query.offset(options.offset);\n }\n\n if (options.search) {\n query.whereRaw(\n `(LOWER(notification.title) LIKE LOWER(?) OR LOWER(notification.description) LIKE LOWER(?))`,\n [`%${options.search}%`, `%${options.search}%`],\n );\n }\n\n if (options.ids) {\n query.whereIn('notification.id', options.ids);\n }\n\n if (options.read) {\n query.whereNotNull('notification.read');\n } else if (options.read === false) {\n query.whereNull('notification.read');\n } // or match both if undefined\n\n if (options.saved) {\n query.whereNotNull('notification.saved');\n } else if (options.saved === false) {\n query.whereNull('notification.saved');\n } // or match both if undefined\n\n return query;\n };\n\n async getNotifications(options: NotificationGetOptions) {\n const notificationQuery = this.getNotificationsBaseQuery(options);\n const notifications = await notificationQuery.select();\n return this.mapToNotifications(notifications);\n }\n\n async saveNotification(notification: Notification) {\n await this.db\n .insert(this.mapNotificationToDbRow(notification))\n .into('notification');\n }\n\n async getStatus(options: NotificationGetOptions) {\n const notificationQuery = this.getNotificationsBaseQuery({\n ...options,\n sort: null,\n });\n const readSubQuery = notificationQuery\n .clone()\n .count('id')\n .whereNotNull('read')\n .as('READ');\n const unreadSubQuery = notificationQuery\n .clone()\n .count('id')\n .whereNull('read')\n .as('UNREAD');\n\n const query = await notificationQuery\n .select(readSubQuery, unreadSubQuery)\n .first();\n\n return {\n unread: this.mapToInteger((query as any)?.UNREAD),\n read: this.mapToInteger((query as any)?.READ),\n };\n }\n\n async getExistingScopeNotification(options: {\n user: string;\n scope: string;\n origin: string;\n }) {\n const query = this.db('notification')\n .where('user', options.user)\n .where('scope', options.scope)\n .where('origin', options.origin)\n .select()\n .limit(1);\n\n const rows = await query;\n if (!rows || rows.length === 0) {\n return null;\n }\n return rows[0] as Notification;\n }\n\n async restoreExistingNotification(options: {\n id: string;\n notification: Notification;\n }) {\n const query = this.db('notification')\n .where('id', options.id)\n .where('user', options.notification.user);\n\n await query.update({\n title: options.notification.payload.title,\n description: options.notification.payload.description,\n link: options.notification.payload.link,\n topic: options.notification.payload.topic,\n updated: new Date(),\n severity: options.notification.payload.severity,\n read: null,\n });\n\n return await this.getNotification(options);\n }\n\n async getNotification(options: { id: string }): Promise<Notification | null> {\n const rows = await this.db('notification')\n .where('id', options.id)\n .select()\n .limit(1);\n if (!rows || rows.length === 0) {\n return null;\n }\n return this.mapToNotifications(rows)[0];\n }\n\n async markRead(options: NotificationModifyOptions): Promise<void> {\n const notificationQuery = this.getNotificationsBaseQuery(options);\n await notificationQuery.update({ read: new Date() });\n }\n\n async markUnread(options: NotificationModifyOptions): Promise<void> {\n const notificationQuery = this.getNotificationsBaseQuery(options);\n await notificationQuery.update({ read: null });\n }\n\n async markSaved(options: NotificationModifyOptions): Promise<void> {\n const notificationQuery = this.getNotificationsBaseQuery(options);\n await notificationQuery.update({ saved: new Date() });\n }\n\n async markUnsaved(options: NotificationModifyOptions): Promise<void> {\n const notificationQuery = this.getNotificationsBaseQuery(options);\n await notificationQuery.update({ saved: null });\n }\n}\n","/*\n * Copyright 2023 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 createLegacyAuthAdapters,\n errorHandler,\n PluginDatabaseManager,\n TokenManager,\n} from '@backstage/backend-common';\nimport express, { Request } from 'express';\nimport Router from 'express-promise-router';\nimport { IdentityApi } from '@backstage/plugin-auth-node';\nimport {\n DatabaseNotificationsStore,\n NotificationGetOptions,\n} from '../database';\nimport { v4 as uuid } from 'uuid';\nimport { CatalogApi, CatalogClient } from '@backstage/catalog-client';\nimport {\n Entity,\n isGroupEntity,\n isUserEntity,\n RELATION_HAS_MEMBER,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport { NotificationProcessor } from '@backstage/plugin-notifications-node';\nimport { AuthenticationError, InputError } from '@backstage/errors';\nimport {\n AuthService,\n DiscoveryService,\n HttpAuthService,\n LoggerService,\n} from '@backstage/backend-plugin-api';\nimport { SignalService } from '@backstage/plugin-signals-node';\nimport {\n NewNotificationSignal,\n Notification,\n NotificationReadSignal,\n} from '@backstage/plugin-notifications-common';\n\n/** @internal */\nexport interface RouterOptions {\n logger: LoggerService;\n identity: IdentityApi;\n database: PluginDatabaseManager;\n tokenManager: TokenManager;\n discovery: DiscoveryService;\n signalService?: SignalService;\n catalog?: CatalogApi;\n processors?: NotificationProcessor[];\n auth?: AuthService;\n httpAuth?: HttpAuthService;\n}\n\n/** @internal */\nexport async function createRouter(\n options: RouterOptions,\n): Promise<express.Router> {\n const {\n logger,\n database,\n identity,\n discovery,\n catalog,\n processors,\n signalService,\n } = options;\n\n const catalogClient =\n catalog ?? new CatalogClient({ discoveryApi: discovery });\n const store = await DatabaseNotificationsStore.create({ database });\n\n const { auth, httpAuth } = createLegacyAuthAdapters(options);\n\n const getUser = async (req: Request<unknown>) => {\n const user = await identity.getIdentity({ request: req });\n if (!user) {\n throw new AuthenticationError();\n }\n return user.identity.userEntityRef;\n };\n\n const getUsersForEntityRef = async (\n entityRef: string | string[] | null,\n ): Promise<string[]> => {\n const { token } = await auth.getPluginRequestToken({\n onBehalfOf: await auth.getOwnServiceCredentials(),\n targetPluginId: 'catalog',\n });\n\n // TODO: Support for broadcast\n if (entityRef === null) {\n return [];\n }\n\n const refs = Array.isArray(entityRef) ? entityRef : [entityRef];\n const entities = await catalogClient.getEntitiesByRefs(\n {\n entityRefs: refs,\n fields: ['kind', 'metadata.name', 'metadata.namespace'],\n },\n { token },\n );\n const mapEntity = async (entity: Entity | undefined): Promise<string[]> => {\n if (!entity) {\n return [];\n }\n\n if (isUserEntity(entity)) {\n return [stringifyEntityRef(entity)];\n } else if (isGroupEntity(entity) && entity.relations) {\n const users = entity.relations\n .filter(\n relation =>\n relation.type === RELATION_HAS_MEMBER && relation.targetRef,\n )\n .map(r => r.targetRef);\n const childGroups = await catalogClient.getEntitiesByRefs(\n {\n entityRefs: entity.spec.children,\n fields: ['kind', 'metadata.name', 'metadata.namespace'],\n },\n { token },\n );\n const childGroupUsers = await Promise.all(\n childGroups.items.map(mapEntity),\n );\n return [...users, ...childGroupUsers.flat(2)];\n } else if (!isGroupEntity(entity) && entity.spec?.owner) {\n const owner = await catalogClient.getEntityByRef(\n entity.spec.owner as string,\n { token },\n );\n if (owner) {\n return mapEntity(owner);\n }\n }\n\n return [];\n };\n\n const users: string[] = [];\n for (const entity of entities.items) {\n const u = await mapEntity(entity);\n users.push(...u);\n }\n return users;\n };\n\n const decorateNotification = async (notification: Notification) => {\n let ret: Notification = notification;\n for (const processor of processors ?? []) {\n ret = processor.decorate ? await processor.decorate(ret) : ret;\n }\n return ret;\n };\n\n const processorSendNotification = async (notification: Notification) => {\n for (const processor of processors ?? []) {\n if (processor.send) {\n processor.send(notification);\n }\n }\n };\n\n // TODO: Move to use OpenAPI router instead\n const router = Router();\n router.use(express.json());\n\n router.get('/health', (_, response) => {\n logger.info('PONG!');\n response.json({ status: 'ok' });\n });\n\n router.get('/', async (req, res) => {\n const user = await getUser(req);\n const opts: NotificationGetOptions = {\n user: user,\n };\n if (req.query.offset) {\n opts.offset = Number.parseInt(req.query.offset.toString(), 10);\n }\n if (req.query.limit) {\n opts.limit = Number.parseInt(req.query.limit.toString(), 10);\n }\n if (req.query.search) {\n opts.search = req.query.search.toString();\n }\n if (req.query.read === 'true') {\n opts.read = true;\n } else if (req.query.read === 'false') {\n opts.read = false;\n // or keep undefined\n }\n if (req.query.created_after) {\n const sinceEpoch = Date.parse(req.query.created_after.toString());\n if (isNaN(sinceEpoch)) {\n throw new InputError('Unexpected date format');\n }\n opts.createdAfter = new Date(sinceEpoch);\n }\n\n const notifications = await store.getNotifications(opts);\n res.send(notifications);\n });\n\n router.get('/:id', async (req, res) => {\n const user = await getUser(req);\n const opts: NotificationGetOptions = {\n user: user,\n limit: 1,\n ids: [req.params.id],\n };\n const notifications = await store.getNotifications(opts);\n if (notifications.length !== 1) {\n res.status(404).send({ error: 'Not found' });\n return;\n }\n res.send(notifications[0]);\n });\n\n router.get('/status', async (req, res) => {\n const user = await getUser(req);\n const status = await store.getStatus({ user });\n res.send(status);\n });\n\n router.post('/update', async (req, res) => {\n const user = await getUser(req);\n const { ids, read, saved } = req.body;\n if (!ids || !Array.isArray(ids)) {\n throw new InputError();\n }\n\n if (read === true) {\n await store.markRead({ user, ids });\n\n if (signalService) {\n await signalService.publish<NotificationReadSignal>({\n recipients: [user],\n message: { action: 'notification_read', notification_ids: ids },\n channel: 'notifications',\n });\n }\n } else if (read === false) {\n await store.markUnread({ user: user, ids });\n\n if (signalService) {\n await signalService.publish<NotificationReadSignal>({\n recipients: [user],\n message: { action: 'notification_unread', notification_ids: ids },\n channel: 'notifications',\n });\n }\n }\n\n if (saved === true) {\n await store.markSaved({ user: user, ids });\n } else if (saved === false) {\n await store.markUnsaved({ user: user, ids });\n }\n\n const notifications = await store.getNotifications({ ids, user: user });\n res.status(200).send(notifications);\n });\n\n // Add new notification\n // Allowed only for service-to-service authentication, uses `getUsersForEntityRef` to retrieve recipients for\n // specific entity reference\n router.post('/', async (req, res) => {\n const { recipients, origin, payload } = req.body;\n const notifications = [];\n let users = [];\n\n await httpAuth.credentials(req, { allow: ['service'] });\n\n const { title, link, scope } = payload;\n\n if (!recipients || !title || !origin || !link) {\n logger.error(`Invalid notification request received`);\n throw new InputError();\n }\n\n let entityRef = null;\n // TODO: Support for broadcast notifications\n if (recipients.entityRef && recipients.type === 'entity') {\n entityRef = recipients.entityRef;\n }\n\n try {\n users = await getUsersForEntityRef(entityRef);\n } catch (e) {\n throw new InputError();\n }\n\n const baseNotification: Omit<Notification, 'id' | 'user'> = {\n payload: {\n ...payload,\n severity: payload.severity ?? 'normal',\n },\n origin,\n created: new Date(),\n };\n\n const uniqueUsers = [...new Set(users)];\n for (const user of uniqueUsers) {\n const userNotification = {\n ...baseNotification,\n id: uuid(),\n user,\n };\n const notification = await decorateNotification(userNotification);\n\n let existingNotification;\n if (scope) {\n existingNotification = await store.getExistingScopeNotification({\n user,\n scope,\n origin,\n });\n }\n\n let ret = notification;\n if (existingNotification) {\n const restored = await store.restoreExistingNotification({\n id: existingNotification.id,\n notification,\n });\n ret = restored ?? notification;\n } else {\n await store.saveNotification(notification);\n }\n\n processorSendNotification(ret);\n notifications.push(ret);\n\n if (signalService) {\n await signalService.publish<NewNotificationSignal>({\n recipients: user,\n message: {\n action: 'new_notification',\n notification_id: ret.id,\n },\n channel: 'notifications',\n });\n }\n }\n\n res.json(notifications);\n });\n\n router.use(errorHandler());\n return router;\n}\n","/*\n * Copyright 2023 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 createBackendPlugin,\n} from '@backstage/backend-plugin-api';\nimport { createRouter } from './service/router';\nimport { signalService } from '@backstage/plugin-signals-node';\nimport {\n NotificationProcessor,\n notificationsProcessingExtensionPoint,\n NotificationsProcessingExtensionPoint,\n} from '@backstage/plugin-notifications-node';\n\nclass NotificationsProcessingExtensionPointImpl\n implements NotificationsProcessingExtensionPoint\n{\n #processors = new Array<NotificationProcessor>();\n\n addProcessor(\n ...processors: Array<NotificationProcessor | Array<NotificationProcessor>>\n ): void {\n this.#processors.push(...processors.flat());\n }\n\n get processors() {\n return this.#processors;\n }\n}\n\n/**\n * Notifications backend plugin\n *\n * @public\n */\nexport const notificationsPlugin = createBackendPlugin({\n pluginId: 'notifications',\n register(env) {\n const processingExtensions =\n new NotificationsProcessingExtensionPointImpl();\n env.registerExtensionPoint(\n notificationsProcessingExtensionPoint,\n processingExtensions,\n );\n\n env.registerInit({\n deps: {\n auth: coreServices.auth,\n httpAuth: coreServices.httpAuth,\n httpRouter: coreServices.httpRouter,\n logger: coreServices.logger,\n identity: coreServices.identity,\n database: coreServices.database,\n tokenManager: coreServices.tokenManager,\n discovery: coreServices.discovery,\n signals: signalService,\n },\n async init({\n auth,\n httpAuth,\n httpRouter,\n logger,\n identity,\n database,\n tokenManager,\n discovery,\n signals,\n }) {\n httpRouter.use(\n await createRouter({\n auth,\n httpAuth,\n logger,\n identity,\n database,\n tokenManager,\n discovery,\n signalService: signals,\n processors: processingExtensions.processors,\n }),\n );\n },\n });\n },\n});\n"],"names":["resolvePackagePath","catalogClient","CatalogClient","createLegacyAuthAdapters","AuthenticationError","isUserEntity","stringifyEntityRef","isGroupEntity","users","RELATION_HAS_MEMBER","Router","express","InputError","uuid","errorHandler","createBackendPlugin","notificationsProcessingExtensionPoint","coreServices","signalService"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,aAAgB,GAAAA,gCAAA;AAAA,EACpB,yCAAA;AAAA,EACA,YAAA;AACF,CAAA,CAAA;AAGO,MAAM,0BAAyD,CAAA;AAAA,EAC5D,YAA6B,EAAU,E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AA,OAAA;AAAA,YACf,YAAY,oBAAqB,CAAA,UAAA;AAAA,WAClC,CAAA;AAAA,SACH,CAAA;AAAA,OACF;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/database/DatabaseNotificationsStore.ts","../src/service/router.ts","../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2023 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 PluginDatabaseManager,\n resolvePackagePath,\n} from '@backstage/backend-common';\nimport {\n NotificationGetOptions,\n NotificationModifyOptions,\n NotificationsStore,\n} from './NotificationsStore';\nimport { Notification } from '@backstage/plugin-notifications-common';\nimport { Knex } from 'knex';\n\nconst migrationsDir = resolvePackagePath(\n '@backstage/plugin-notifications-backend',\n 'migrations',\n);\n\n/** @internal */\nexport class DatabaseNotificationsStore implements NotificationsStore {\n private constructor(private readonly db: Knex) {}\n\n static async create({\n database,\n skipMigrations,\n }: {\n database: PluginDatabaseManager;\n skipMigrations?: boolean;\n }): Promise<DatabaseNotificationsStore> {\n const client = await database.getClient();\n\n if (!database.migrations?.skip && !skipMigrations) {\n await client.migrate.latest({\n directory: migrationsDir,\n });\n }\n\n return new DatabaseNotificationsStore(client);\n }\n\n private mapToInteger = (val: string | number | undefined): number => {\n return typeof val === 'string' ? Number.parseInt(val, 10) : val ?? 0;\n };\n\n private mapToNotifications = (rows: any[]): Notification[] => {\n return rows.map(row => ({\n id: row.id,\n user: row.user,\n created: row.created,\n saved: row.saved,\n read: row.read,\n updated: row.updated,\n origin: row.origin,\n payload: {\n title: row.title,\n description: row.description,\n link: row.link,\n topic: row.topic,\n severity: row.severity,\n scope: row.scope,\n icon: row.icon,\n },\n }));\n };\n\n private mapNotificationToDbRow = (notification: Notification) => {\n return {\n id: notification.id,\n user: notification.user,\n origin: notification.origin,\n created: notification.created,\n topic: notification.payload?.topic,\n link: notification.payload?.link,\n title: notification.payload?.title,\n description: notification.payload?.description,\n severity: notification.payload?.severity,\n scope: notification.payload?.scope,\n saved: notification.saved,\n read: notification.read,\n };\n };\n\n private getNotificationsBaseQuery = (\n options: NotificationGetOptions | NotificationModifyOptions,\n ) => {\n const { user } = options;\n const isSQLite = this.db.client.config.client.includes('sqlite3');\n\n const query = this.db('notification').where('user', user);\n\n if (options.sort !== undefined && options.sort !== null) {\n query.orderBy(options.sort, options.sortOrder ?? 'desc');\n } else if (options.sort !== null) {\n query.orderBy('created', options.sortOrder ?? 'desc');\n }\n\n if (options.createdAfter) {\n if (isSQLite) {\n query.where(\n 'notification.created',\n '>=',\n options.createdAfter.valueOf(),\n );\n } else {\n query.where(\n 'notification.created',\n '>=',\n options.createdAfter.toISOString(),\n );\n }\n }\n\n if (options.limit) {\n query.limit(options.limit);\n }\n\n if (options.offset) {\n query.offset(options.offset);\n }\n\n if (options.search) {\n query.whereRaw(\n `(LOWER(notification.title) LIKE LOWER(?) OR LOWER(notification.description) LIKE LOWER(?))`,\n [`%${options.search}%`, `%${options.search}%`],\n );\n }\n\n if (options.ids) {\n query.whereIn('notification.id', options.ids);\n }\n\n if (options.read) {\n query.whereNotNull('notification.read');\n } else if (options.read === false) {\n query.whereNull('notification.read');\n } // or match both if undefined\n\n if (options.saved) {\n query.whereNotNull('notification.saved');\n } else if (options.saved === false) {\n query.whereNull('notification.saved');\n } // or match both if undefined\n\n return query;\n };\n\n async getNotifications(options: NotificationGetOptions) {\n const notificationQuery = this.getNotificationsBaseQuery(options);\n const notifications = await notificationQuery.select();\n return this.mapToNotifications(notifications);\n }\n\n async getNotificationsCount(options: NotificationGetOptions) {\n const countOptions: NotificationGetOptions = { ...options };\n countOptions.limit = undefined;\n countOptions.offset = undefined;\n countOptions.sort = null;\n const notificationQuery = this.getNotificationsBaseQuery(countOptions);\n const response = await notificationQuery.count('* as CNT');\n return Number(response[0].CNT);\n }\n\n async saveNotification(notification: Notification) {\n await this.db\n .insert(this.mapNotificationToDbRow(notification))\n .into('notification');\n }\n\n async getStatus(options: NotificationGetOptions) {\n const notificationQuery = this.getNotificationsBaseQuery({\n ...options,\n sort: null,\n });\n const readSubQuery = notificationQuery\n .clone()\n .count('id')\n .whereNotNull('read')\n .as('READ');\n const unreadSubQuery = notificationQuery\n .clone()\n .count('id')\n .whereNull('read')\n .as('UNREAD');\n\n const query = await notificationQuery\n .select(readSubQuery, unreadSubQuery)\n .first();\n\n return {\n unread: this.mapToInteger((query as any)?.UNREAD),\n read: this.mapToInteger((query as any)?.READ),\n };\n }\n\n async getExistingScopeNotification(options: {\n user: string;\n scope: string;\n origin: string;\n }) {\n const query = this.db('notification')\n .where('user', options.user)\n .where('scope', options.scope)\n .where('origin', options.origin)\n .select()\n .limit(1);\n\n const rows = await query;\n if (!rows || rows.length === 0) {\n return null;\n }\n return rows[0] as Notification;\n }\n\n async restoreExistingNotification(options: {\n id: string;\n notification: Notification;\n }) {\n const query = this.db('notification')\n .where('id', options.id)\n .where('user', options.notification.user);\n\n await query.update({\n title: options.notification.payload.title,\n description: options.notification.payload.description,\n link: options.notification.payload.link,\n topic: options.notification.payload.topic,\n updated: new Date(),\n severity: options.notification.payload.severity,\n read: null,\n });\n\n return await this.getNotification(options);\n }\n\n async getNotification(options: { id: string }): Promise<Notification | null> {\n const rows = await this.db('notification')\n .where('id', options.id)\n .select()\n .limit(1);\n if (!rows || rows.length === 0) {\n return null;\n }\n return this.mapToNotifications(rows)[0];\n }\n\n async markRead(options: NotificationModifyOptions): Promise<void> {\n const notificationQuery = this.getNotificationsBaseQuery(options);\n await notificationQuery.update({ read: new Date() });\n }\n\n async markUnread(options: NotificationModifyOptions): Promise<void> {\n const notificationQuery = this.getNotificationsBaseQuery(options);\n await notificationQuery.update({ read: null });\n }\n\n async markSaved(options: NotificationModifyOptions): Promise<void> {\n const notificationQuery = this.getNotificationsBaseQuery(options);\n await notificationQuery.update({ saved: new Date() });\n }\n\n async markUnsaved(options: NotificationModifyOptions): Promise<void> {\n const notificationQuery = this.getNotificationsBaseQuery(options);\n await notificationQuery.update({ saved: null });\n }\n}\n","/*\n * Copyright 2023 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 { errorHandler, PluginDatabaseManager } from '@backstage/backend-common';\nimport express, { Request } from 'express';\nimport Router from 'express-promise-router';\nimport {\n DatabaseNotificationsStore,\n NotificationGetOptions,\n} from '../database';\nimport { v4 as uuid } from 'uuid';\nimport { CatalogApi, CatalogClient } from '@backstage/catalog-client';\nimport {\n Entity,\n isGroupEntity,\n isUserEntity,\n RELATION_HAS_MEMBER,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport { NotificationProcessor } from '@backstage/plugin-notifications-node';\nimport { InputError } from '@backstage/errors';\nimport {\n AuthService,\n DiscoveryService,\n HttpAuthService,\n LoggerService,\n UserInfoService,\n} from '@backstage/backend-plugin-api';\nimport { SignalService } from '@backstage/plugin-signals-node';\nimport {\n NewNotificationSignal,\n Notification,\n NotificationReadSignal,\n} from '@backstage/plugin-notifications-common';\n\n/** @internal */\nexport interface RouterOptions {\n logger: LoggerService;\n database: PluginDatabaseManager;\n discovery: DiscoveryService;\n auth: AuthService;\n httpAuth: HttpAuthService;\n userInfo: UserInfoService;\n signalService?: SignalService;\n catalog?: CatalogApi;\n processors?: NotificationProcessor[];\n}\n\n/** @internal */\nexport async function createRouter(\n options: RouterOptions,\n): Promise<express.Router> {\n const {\n logger,\n database,\n auth,\n httpAuth,\n userInfo,\n discovery,\n catalog,\n processors,\n signalService,\n } = options;\n\n const catalogClient =\n catalog ?? new CatalogClient({ discoveryApi: discovery });\n const store = await DatabaseNotificationsStore.create({ database });\n\n const getUser = async (req: Request<unknown>) => {\n const credentials = await httpAuth.credentials(req, { allow: ['user'] });\n const info = await userInfo.getUserInfo(credentials);\n return info.userEntityRef;\n };\n\n const getUsersForEntityRef = async (\n entityRef: string | string[] | null,\n ): Promise<string[]> => {\n const { token } = await auth.getPluginRequestToken({\n onBehalfOf: await auth.getOwnServiceCredentials(),\n targetPluginId: 'catalog',\n });\n\n // TODO: Support for broadcast\n if (entityRef === null) {\n return [];\n }\n\n const refs = Array.isArray(entityRef) ? entityRef : [entityRef];\n const entities = await catalogClient.getEntitiesByRefs(\n {\n entityRefs: refs,\n fields: ['kind', 'metadata.name', 'metadata.namespace'],\n },\n { token },\n );\n const mapEntity = async (entity: Entity | undefined): Promise<string[]> => {\n if (!entity) {\n return [];\n }\n\n if (isUserEntity(entity)) {\n return [stringifyEntityRef(entity)];\n } else if (isGroupEntity(entity) && entity.relations) {\n const users = entity.relations\n .filter(\n relation =>\n relation.type === RELATION_HAS_MEMBER && relation.targetRef,\n )\n .map(r => r.targetRef);\n const childGroups = await catalogClient.getEntitiesByRefs(\n {\n entityRefs: entity.spec.children,\n fields: ['kind', 'metadata.name', 'metadata.namespace'],\n },\n { token },\n );\n const childGroupUsers = await Promise.all(\n childGroups.items.map(mapEntity),\n );\n return [...users, ...childGroupUsers.flat(2)];\n } else if (!isGroupEntity(entity) && entity.spec?.owner) {\n const owner = await catalogClient.getEntityByRef(\n entity.spec.owner as string,\n { token },\n );\n if (owner) {\n return mapEntity(owner);\n }\n }\n\n return [];\n };\n\n const users: string[] = [];\n for (const entity of entities.items) {\n const u = await mapEntity(entity);\n users.push(...u);\n }\n return users;\n };\n\n const decorateNotification = async (notification: Notification) => {\n let ret: Notification = notification;\n for (const processor of processors ?? []) {\n ret = processor.decorate ? await processor.decorate(ret) : ret;\n }\n return ret;\n };\n\n const processorSendNotification = async (notification: Notification) => {\n for (const processor of processors ?? []) {\n if (processor.send) {\n processor.send(notification);\n }\n }\n };\n\n // TODO: Move to use OpenAPI router instead\n const router = Router();\n router.use(express.json());\n\n router.get('/health', (_, response) => {\n logger.info('PONG!');\n response.json({ status: 'ok' });\n });\n\n router.get('/', async (req, res) => {\n const user = await getUser(req);\n const opts: NotificationGetOptions = {\n user: user,\n };\n if (req.query.offset) {\n opts.offset = Number.parseInt(req.query.offset.toString(), 10);\n }\n if (req.query.limit) {\n opts.limit = Number.parseInt(req.query.limit.toString(), 10);\n }\n if (req.query.search) {\n opts.search = req.query.search.toString();\n }\n if (req.query.read === 'true') {\n opts.read = true;\n } else if (req.query.read === 'false') {\n opts.read = false;\n // or keep undefined\n }\n if (req.query.created_after) {\n const sinceEpoch = Date.parse(String(req.query.created_after));\n if (isNaN(sinceEpoch)) {\n throw new InputError('Unexpected date format');\n }\n opts.createdAfter = new Date(sinceEpoch);\n }\n\n const [notifications, totalCount] = await Promise.all([\n store.getNotifications(opts),\n store.getNotificationsCount(opts),\n ]);\n res.send({\n totalCount,\n notifications,\n });\n });\n\n router.get('/:id', async (req, res) => {\n const user = await getUser(req);\n const opts: NotificationGetOptions = {\n user: user,\n limit: 1,\n ids: [req.params.id],\n };\n const notifications = await store.getNotifications(opts);\n if (notifications.length !== 1) {\n res.status(404).send({ error: 'Not found' });\n return;\n }\n res.send(notifications[0]);\n });\n\n router.get('/status', async (req, res) => {\n const user = await getUser(req);\n const status = await store.getStatus({ user });\n res.send(status);\n });\n\n router.post('/update', async (req, res) => {\n const user = await getUser(req);\n const { ids, read, saved } = req.body;\n if (!ids || !Array.isArray(ids)) {\n throw new InputError();\n }\n\n if (read === true) {\n await store.markRead({ user, ids });\n\n if (signalService) {\n await signalService.publish<NotificationReadSignal>({\n recipients: [user],\n message: { action: 'notification_read', notification_ids: ids },\n channel: 'notifications',\n });\n }\n } else if (read === false) {\n await store.markUnread({ user: user, ids });\n\n if (signalService) {\n await signalService.publish<NotificationReadSignal>({\n recipients: [user],\n message: { action: 'notification_unread', notification_ids: ids },\n channel: 'notifications',\n });\n }\n }\n\n if (saved === true) {\n await store.markSaved({ user: user, ids });\n } else if (saved === false) {\n await store.markUnsaved({ user: user, ids });\n }\n\n const notifications = await store.getNotifications({ ids, user: user });\n res.status(200).send(notifications);\n });\n\n // Add new notification\n router.post('/', async (req, res) => {\n const { recipients, payload } = req.body;\n const notifications = [];\n let users = [];\n\n const credentials = await httpAuth.credentials(req, { allow: ['service'] });\n\n const { title, scope } = payload;\n\n if (!recipients || !title) {\n logger.error(`Invalid notification request received`);\n throw new InputError();\n }\n\n let entityRef = null;\n // TODO: Support for broadcast notifications\n if (recipients.entityRef && recipients.type === 'entity') {\n entityRef = recipients.entityRef;\n }\n\n try {\n users = await getUsersForEntityRef(entityRef);\n } catch (e) {\n throw new InputError();\n }\n\n const origin = credentials.principal.subject;\n const baseNotification: Omit<Notification, 'id' | 'user'> = {\n payload: {\n ...payload,\n severity: payload.severity ?? 'normal',\n },\n origin,\n created: new Date(),\n };\n\n const uniqueUsers = [...new Set(users)];\n for (const user of uniqueUsers) {\n const userNotification = {\n ...baseNotification,\n id: uuid(),\n user,\n };\n const notification = await decorateNotification(userNotification);\n\n let existingNotification;\n if (scope) {\n existingNotification = await store.getExistingScopeNotification({\n user,\n scope,\n origin,\n });\n }\n\n let ret = notification;\n if (existingNotification) {\n const restored = await store.restoreExistingNotification({\n id: existingNotification.id,\n notification,\n });\n ret = restored ?? notification;\n } else {\n await store.saveNotification(notification);\n }\n\n processorSendNotification(ret);\n notifications.push(ret);\n\n if (signalService) {\n await signalService.publish<NewNotificationSignal>({\n recipients: user,\n message: {\n action: 'new_notification',\n notification_id: ret.id,\n },\n channel: 'notifications',\n });\n }\n }\n\n res.json(notifications);\n });\n\n router.use(errorHandler());\n return router;\n}\n","/*\n * Copyright 2023 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 createBackendPlugin,\n} from '@backstage/backend-plugin-api';\nimport { createRouter } from './service/router';\nimport { signalService } from '@backstage/plugin-signals-node';\nimport {\n NotificationProcessor,\n notificationsProcessingExtensionPoint,\n NotificationsProcessingExtensionPoint,\n} from '@backstage/plugin-notifications-node';\n\nclass NotificationsProcessingExtensionPointImpl\n implements NotificationsProcessingExtensionPoint\n{\n #processors = new Array<NotificationProcessor>();\n\n addProcessor(\n ...processors: Array<NotificationProcessor | Array<NotificationProcessor>>\n ): void {\n this.#processors.push(...processors.flat());\n }\n\n get processors() {\n return this.#processors;\n }\n}\n\n/**\n * Notifications backend plugin\n *\n * @public\n */\nexport const notificationsPlugin = createBackendPlugin({\n pluginId: 'notifications',\n register(env) {\n const processingExtensions =\n new NotificationsProcessingExtensionPointImpl();\n env.registerExtensionPoint(\n notificationsProcessingExtensionPoint,\n processingExtensions,\n );\n\n env.registerInit({\n deps: {\n auth: coreServices.auth,\n httpAuth: coreServices.httpAuth,\n userInfo: coreServices.userInfo,\n httpRouter: coreServices.httpRouter,\n logger: coreServices.logger,\n database: coreServices.database,\n discovery: coreServices.discovery,\n signals: signalService,\n },\n async init({\n auth,\n httpAuth,\n userInfo,\n httpRouter,\n logger,\n database,\n discovery,\n signals,\n }) {\n httpRouter.use(\n await createRouter({\n auth,\n httpAuth,\n userInfo,\n logger,\n database,\n discovery,\n signalService: signals,\n processors: processingExtensions.processors,\n }),\n );\n },\n });\n },\n});\n"],"names":["resolvePackagePath","catalogClient","CatalogClient","isUserEntity","stringifyEntityRef","isGroupEntity","users","RELATION_HAS_MEMBER","Router","express","InputError","uuid","errorHandler","createBackendPlugin","notificationsProcessingExtensionPoint","coreServices","signalService"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,aAAgB,GAAAA,gCAAA;AAAA,EACpB,yCAAA;AAAA,EACA,YAAA;AACF,CAAA,CAAA;AAGO,MAAM,0BAAyD,CAAA;AAAA,EAC5D,YAA6B,EAAU,EAAA;AAAV,IAAA,IAAA,CAAA,EAAA,GAAA,EAAA,CAAA;AAoBrC,IAAQ,aAAA,CAAA,IAAA,EAAA,cAAA,EAAe,CAAC,GAA6C,KAAA;AACnE,MAAO,OAAA,OAAO,QAAQ,QAAW,GAAA,MAAA,CAAO,SAAS,GAAK,EAAA,EAAE,IAAI,GAAO,IAAA,IAAA,GAAA,GAAA,GAAA,CAAA,CAAA;AAAA,KACrE,CAAA,CAAA;AAEA,IAAQ,aAAA,CAAA,IAAA,EAAA,oBAAA,EAAqB,CAAC,IAAgC,KAAA;AAC5D,MAAO,OAAA,IAAA,CAAK,IAAI,CAAQ,GAAA,MAAA;AAAA,QACtB,IAAI,GAAI,CAAA,EAAA;AAAA,QACR,MAAM,GAAI,CAAA,IAAA;AAAA,QACV,SAAS,GAAI,CAAA,OAAA;AAAA,QACb,OAAO,GAAI,CAAA,KAAA;AAAA,QACX,MAAM,GAAI,CAAA,IAAA;AAAA,QACV,SAAS,GAAI,CAAA,OAAA;AAAA,QACb,QAAQ,GAAI,CAAA,MAAA;AAAA,QACZ,OAAS,EAAA;AAAA,UACP,OAAO,GAAI,CAAA,KAAA;AAAA,UACX,aAAa,GAAI,CAAA,WAAA;AAAA,UACjB,MAAM,GAAI,CAAA,IAAA;AAAA,UACV,OAAO,GAAI,CAAA,KAAA;AAAA,UACX,UAAU,GAAI,CAAA,QAAA;AAAA,UACd,OAAO,GAAI,CAAA,KAAA;AAAA,UACX,MAAM,GAAI,CA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AAAA,EACrD,QAAU,EAAA,eAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAM,MAAA,oBAAA,GACJ,IAAI,yCAA0C,EAAA,CAAA;AAChD,IAAI,GAAA,CAAA,sBAAA;AAAA,MACFC,6DAAA;AAAA,MACA,oBAAA;AAAA,KACF,CAAA;AAEA,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,MAAMC,6BAAa,CAAA,IAAA;AAAA,QACnB,UAAUA,6BAAa,CAAA,QAAA;AAAA,QACvB,UAAUA,6BAAa,CAAA,QAAA;AAAA,QACvB,YAAYA,6BAAa,CAAA,UAAA;AAAA,QACzB,QAAQA,6BAAa,CAAA,MAAA;AAAA,QACrB,UAAUA,6BAAa,CAAA,QAAA;AAAA,QACvB,WAAWA,6BAAa,CAAA,SAAA;AAAA,QACxB,OAAS,EAAAC,+BAAA;AAAA,OACX;AAAA,MACA,MAAM,IAAK,CAAA;AAAA,QACT,IAAA;AAAA,QACA,QAAA;AAAA,QACA,QAAA;AAAA,QACA,UAAA;AAAA,QACA,MAAA;AAAA,QACA,QAAA;AAAA,QACA,SAAA;AAAA,QACA,OAAA;AAAA,OACC,EAAA;AACD,QAAW,UAAA,CAAA,GAAA;AAAA,UACT,MAAM,YAAa,CAAA;AAAA,YACjB,IAAA;AAAA,YACA,QAAA;AAAA,YACA,QAAA;AAAA,YACA,MAAA;AAAA,YACA,QAAA;AAAA,YACA,SAAA;AAAA,YACA,aAAe,EAAA,OAAA;AAAA,YACf,YAAY,oBAAqB,CAAA,UAAA;AAAA,WAClC,CAAA;AAAA,SACH,CAAA;AAAA,OACF;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-notifications-backend",
3
- "version": "0.1.0-next.0",
3
+ "version": "0.1.0-next.1",
4
4
  "backstage": {
5
5
  "role": "backend-plugin"
6
6
  },
@@ -30,17 +30,17 @@
30
30
  "test": "backstage-cli package test"
31
31
  },
32
32
  "dependencies": {
33
- "@backstage/backend-common": "^0.21.3-next.0",
34
- "@backstage/backend-plugin-api": "^0.6.13-next.0",
33
+ "@backstage/backend-common": "^0.21.4-next.1",
34
+ "@backstage/backend-plugin-api": "^0.6.14-next.1",
35
35
  "@backstage/catalog-client": "^1.6.1-next.0",
36
36
  "@backstage/catalog-model": "^1.4.5-next.0",
37
- "@backstage/config": "^1.1.2-next.0",
37
+ "@backstage/config": "^1.2.0-next.1",
38
38
  "@backstage/errors": "^1.2.4-next.0",
39
- "@backstage/plugin-auth-node": "^0.4.8-next.0",
40
- "@backstage/plugin-events-node": "^0.3.0-next.0",
41
- "@backstage/plugin-notifications-common": "^0.0.2-next.0",
42
- "@backstage/plugin-notifications-node": "^0.1.0-next.0",
43
- "@backstage/plugin-signals-node": "^0.0.4-next.0",
39
+ "@backstage/plugin-auth-node": "^0.4.9-next.1",
40
+ "@backstage/plugin-events-node": "^0.3.0-next.1",
41
+ "@backstage/plugin-notifications-common": "^0.0.2-next.1",
42
+ "@backstage/plugin-notifications-node": "^0.1.0-next.1",
43
+ "@backstage/plugin-signals-node": "^0.1.0-next.1",
44
44
  "express": "^4.17.1",
45
45
  "express-promise-router": "^4.1.0",
46
46
  "knex": "^3.0.0",
@@ -50,8 +50,8 @@
50
50
  "yn": "^4.0.0"
51
51
  },
52
52
  "devDependencies": {
53
- "@backstage/backend-test-utils": "^0.3.3-next.0",
54
- "@backstage/cli": "^0.25.3-next.0",
53
+ "@backstage/backend-test-utils": "^0.3.4-next.1",
54
+ "@backstage/cli": "^0.25.3-next.1",
55
55
  "@types/express": "^4.17.6",
56
56
  "@types/supertest": "^2.0.8",
57
57
  "msw": "^1.0.0",