@backstage/plugin-notifications-backend 0.4.4-next.1 → 0.5.0-next.2
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 +22 -0
- package/README.md +1 -1
- package/dist/service/router.cjs.js +68 -69
- package/dist/service/router.cjs.js.map +1 -1
- package/package.json +19 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @backstage/plugin-notifications-backend
|
|
2
2
|
|
|
3
|
+
## 0.5.0-next.2
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- fc15b77: **BREAKING**: Removed redundant `/health` endpoint, switch to using [the built-in endpoint instead](https://backstage.io/docs/backend-system/core-services/root-health).
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- fc15b77: Deprecated root '/' endpoints, moving them under `/notifications` instead.
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
- @backstage/backend-plugin-api@1.1.0-next.2
|
|
14
|
+
- @backstage/errors@1.2.6-next.0
|
|
15
|
+
- @backstage/plugin-auth-node@0.5.5-next.2
|
|
16
|
+
- @backstage/plugin-catalog-node@1.15.0-next.2
|
|
17
|
+
- @backstage/plugin-events-node@0.4.6-next.2
|
|
18
|
+
- @backstage/plugin-notifications-node@0.2.10-next.2
|
|
19
|
+
- @backstage/plugin-signals-node@0.1.15-next.2
|
|
20
|
+
- @backstage/catalog-client@1.9.0-next.2
|
|
21
|
+
- @backstage/catalog-model@1.7.2-next.0
|
|
22
|
+
- @backstage/config@1.3.1-next.0
|
|
23
|
+
- @backstage/plugin-notifications-common@0.0.7-next.0
|
|
24
|
+
|
|
3
25
|
## 0.4.4-next.1
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -29,5 +29,5 @@ To be able to do so, `external access` needs to be enabled as described in the [
|
|
|
29
29
|
Once the API can be accessed, the request can look like:
|
|
30
30
|
|
|
31
31
|
```
|
|
32
|
-
curl -X POST [YOUR_SERVER_URL]/api/notifications -H "Content-Type: application/json" -H "Authorization: Bearer [BASE64_ENCODED_ACCESS_TOKEN]" -d '{"recipients":{"type":"entity","entityRef":"user:development/guest"},"payload": {"title": "Title of user-targeted external message","description": "The description","link": "http://foo.com/bar","severity": "high","topic": "The topic"}}'
|
|
32
|
+
curl -X POST [YOUR_SERVER_URL]/api/notifications/notifications -H "Content-Type: application/json" -H "Authorization: Bearer [BASE64_ENCODED_ACCESS_TOKEN]" -d '{"recipients":{"type":"entity","entityRef":"user:development/guest"},"payload": {"title": "Title of user-targeted external message","description": "The description","link": "http://foo.com/bar","severity": "high","topic": "The topic"}}'
|
|
33
33
|
```
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var backendCommon = require('@backstage/backend-common');
|
|
4
3
|
var express = require('express');
|
|
5
4
|
var Router = require('express-promise-router');
|
|
6
5
|
var DatabaseNotificationsStore = require('../database/DatabaseNotificationsStore.cjs.js');
|
|
@@ -154,11 +153,7 @@ async function createRouter(options) {
|
|
|
154
153
|
};
|
|
155
154
|
const router = Router__default.default();
|
|
156
155
|
router.use(express__default.default.json());
|
|
157
|
-
|
|
158
|
-
logger.info("PONG!");
|
|
159
|
-
response.json({ status: "ok" });
|
|
160
|
-
});
|
|
161
|
-
router.get("/", async (req, res) => {
|
|
156
|
+
const listNotificationsHandler = async (req, res) => {
|
|
162
157
|
const user = await getUser(req);
|
|
163
158
|
const opts = {
|
|
164
159
|
user
|
|
@@ -208,7 +203,9 @@ async function createRouter(options) {
|
|
|
208
203
|
totalCount,
|
|
209
204
|
notifications
|
|
210
205
|
});
|
|
211
|
-
}
|
|
206
|
+
};
|
|
207
|
+
router.get("/", listNotificationsHandler);
|
|
208
|
+
router.get("/notifications", listNotificationsHandler);
|
|
212
209
|
router.get("/status", async (req, res) => {
|
|
213
210
|
const user = await getUser(req);
|
|
214
211
|
const status = await store.getStatus({ user });
|
|
@@ -236,7 +233,7 @@ async function createRouter(options) {
|
|
|
236
233
|
res.json(response);
|
|
237
234
|
}
|
|
238
235
|
);
|
|
239
|
-
|
|
236
|
+
const getNotificationHandler = async (req, res) => {
|
|
240
237
|
const user = await getUser(req);
|
|
241
238
|
const opts = {
|
|
242
239
|
user,
|
|
@@ -248,8 +245,10 @@ async function createRouter(options) {
|
|
|
248
245
|
throw new errors.NotFoundError("Not found");
|
|
249
246
|
}
|
|
250
247
|
res.json(notifications[0]);
|
|
251
|
-
}
|
|
252
|
-
router.
|
|
248
|
+
};
|
|
249
|
+
router.get("/:id", getNotificationHandler);
|
|
250
|
+
router.get("/notifications/:id", getNotificationHandler);
|
|
251
|
+
const updateNotificationsHandler = async (req, res) => {
|
|
253
252
|
const user = await getUser(req);
|
|
254
253
|
const { ids, read, saved } = req.body;
|
|
255
254
|
if (!ids || !Array.isArray(ids)) {
|
|
@@ -281,7 +280,9 @@ async function createRouter(options) {
|
|
|
281
280
|
}
|
|
282
281
|
const notifications = await store.getNotifications({ ids, user });
|
|
283
282
|
res.json(notifications);
|
|
284
|
-
}
|
|
283
|
+
};
|
|
284
|
+
router.post("/update", updateNotificationsHandler);
|
|
285
|
+
router.post("/notifications/update", updateNotificationsHandler);
|
|
285
286
|
const sendBroadcastNotification = async (baseNotification, opts, origin) => {
|
|
286
287
|
const { scope } = opts.payload;
|
|
287
288
|
const broadcastNotification = {
|
|
@@ -374,68 +375,66 @@ async function createRouter(options) {
|
|
|
374
375
|
}
|
|
375
376
|
return notifications;
|
|
376
377
|
};
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
} catch (e) {
|
|
397
|
-
throw new errors.InputError("Invalid link provided", e);
|
|
398
|
-
}
|
|
378
|
+
const createNotificationHandler = async (req, res) => {
|
|
379
|
+
const credentials = await httpAuth.credentials(req, {
|
|
380
|
+
allow: ["service"]
|
|
381
|
+
});
|
|
382
|
+
const origin = credentials.principal.subject;
|
|
383
|
+
const opts = await processOptions(req.body, origin);
|
|
384
|
+
const { recipients, payload } = opts;
|
|
385
|
+
const { title, link } = payload;
|
|
386
|
+
const notifications = [];
|
|
387
|
+
let users = [];
|
|
388
|
+
if (!recipients || !title) {
|
|
389
|
+
logger.error(`Invalid notification request received`);
|
|
390
|
+
throw new errors.InputError(`Invalid notification request received`);
|
|
391
|
+
}
|
|
392
|
+
if (link) {
|
|
393
|
+
try {
|
|
394
|
+
validateLink(link);
|
|
395
|
+
} catch (e) {
|
|
396
|
+
throw new errors.InputError("Invalid link provided", e);
|
|
399
397
|
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
} catch (e) {
|
|
424
|
-
logger.error(`Failed to resolve notification receivers: ${e}`);
|
|
425
|
-
throw new errors.InputError("Failed to resolve notification receivers", e);
|
|
426
|
-
}
|
|
427
|
-
const userNotifications = await sendUserNotifications(
|
|
428
|
-
baseNotification,
|
|
429
|
-
users,
|
|
430
|
-
opts,
|
|
431
|
-
origin
|
|
398
|
+
}
|
|
399
|
+
const baseNotification = {
|
|
400
|
+
payload: {
|
|
401
|
+
...payload,
|
|
402
|
+
severity: payload.severity ?? "normal"
|
|
403
|
+
},
|
|
404
|
+
origin,
|
|
405
|
+
created: /* @__PURE__ */ new Date()
|
|
406
|
+
};
|
|
407
|
+
if (recipients.type === "broadcast") {
|
|
408
|
+
const broadcast = await sendBroadcastNotification(
|
|
409
|
+
baseNotification,
|
|
410
|
+
opts,
|
|
411
|
+
origin
|
|
412
|
+
);
|
|
413
|
+
notifications.push(broadcast);
|
|
414
|
+
} else {
|
|
415
|
+
const entityRef = recipients.entityRef;
|
|
416
|
+
try {
|
|
417
|
+
users = await getUsersForEntityRef.getUsersForEntityRef(
|
|
418
|
+
entityRef,
|
|
419
|
+
recipients.excludeEntityRef ?? [],
|
|
420
|
+
{ auth, catalogClient: catalog }
|
|
432
421
|
);
|
|
433
|
-
|
|
422
|
+
} catch (e) {
|
|
423
|
+
logger.error(`Failed to resolve notification receivers: ${e}`);
|
|
424
|
+
throw new errors.InputError("Failed to resolve notification receivers", e);
|
|
434
425
|
}
|
|
435
|
-
|
|
426
|
+
const userNotifications = await sendUserNotifications(
|
|
427
|
+
baseNotification,
|
|
428
|
+
users,
|
|
429
|
+
opts,
|
|
430
|
+
origin
|
|
431
|
+
);
|
|
432
|
+
notifications.push(...userNotifications);
|
|
436
433
|
}
|
|
437
|
-
|
|
438
|
-
|
|
434
|
+
res.json(notifications);
|
|
435
|
+
};
|
|
436
|
+
router.post("/", createNotificationHandler);
|
|
437
|
+
router.post("/notifications", createNotificationHandler);
|
|
439
438
|
return router;
|
|
440
439
|
}
|
|
441
440
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.cjs.js","sources":["../../src/service/router.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 */\n\nimport { errorHandler, PluginDatabaseManager } from '@backstage/backend-common';\nimport express, { Request } from 'express';\nimport Router from 'express-promise-router';\nimport {\n DatabaseNotificationsStore,\n normalizeSeverity,\n NotificationGetOptions,\n} from '../database';\nimport { v4 as uuid } from 'uuid';\nimport { CatalogApi } from '@backstage/catalog-client';\nimport {\n NotificationProcessor,\n NotificationSendOptions,\n} from '@backstage/plugin-notifications-node';\nimport { InputError, NotFoundError } from '@backstage/errors';\nimport {\n AuthService,\n HttpAuthService,\n LoggerService,\n UserInfoService,\n} from '@backstage/backend-plugin-api';\nimport { SignalsService } from '@backstage/plugin-signals-node';\nimport {\n isNotificationsEnabledFor,\n NewNotificationSignal,\n Notification,\n NotificationReadSignal,\n NotificationSettings,\n notificationSeverities,\n NotificationStatus,\n} from '@backstage/plugin-notifications-common';\nimport { parseEntityOrderFieldParams } from './parseEntityOrderFieldParams';\nimport { getUsersForEntityRef } from './getUsersForEntityRef';\nimport { Config } from '@backstage/config';\n\n/** @internal */\nexport interface RouterOptions {\n logger: LoggerService;\n config: Config;\n database: PluginDatabaseManager;\n auth: AuthService;\n httpAuth: HttpAuthService;\n userInfo: UserInfoService;\n signals?: SignalsService;\n catalog: CatalogApi;\n processors?: NotificationProcessor[];\n}\n\n/** @internal */\nexport async function createRouter(\n options: RouterOptions,\n): Promise<express.Router> {\n const {\n config,\n logger,\n database,\n auth,\n httpAuth,\n userInfo,\n catalog,\n processors = [],\n signals,\n } = options;\n\n const WEB_NOTIFICATION_CHANNEL = 'Web';\n const store = await DatabaseNotificationsStore.create({ database });\n const frontendBaseUrl = config.getString('app.baseUrl');\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 getNotificationChannels = () => {\n return [WEB_NOTIFICATION_CHANNEL, ...processors.map(p => p.getName())];\n };\n\n const getNotificationSettings = async (user: string) => {\n const { origins } = await store.getUserNotificationOrigins({ user });\n const settings = await store.getNotificationSettings({ user });\n const channels = getNotificationChannels();\n\n const response: NotificationSettings = {\n channels: channels.map(channel => {\n const channelSettings = settings.channels.find(c => c.id === channel);\n if (channelSettings) {\n return channelSettings;\n }\n return {\n id: channel,\n origins: origins.map(origin => ({\n id: origin,\n enabled: true,\n })),\n };\n }),\n };\n return response;\n };\n\n const isNotificationsEnabled = async (opts: {\n user: string;\n channel: string;\n origin: string;\n }) => {\n const settings = await getNotificationSettings(opts.user);\n return isNotificationsEnabledFor(settings, opts.channel, opts.origin);\n };\n\n const filterProcessors = async (\n notification:\n | Notification\n | ({ origin: string; user: null } & NotificationSendOptions),\n ) => {\n const result: NotificationProcessor[] = [];\n const { payload, user, origin } = notification;\n\n for (const processor of processors) {\n if (user) {\n const enabled = await isNotificationsEnabled({\n user,\n origin,\n channel: processor.getName(),\n });\n if (!enabled) {\n continue;\n }\n }\n\n if (processor.getNotificationFilters) {\n const filters = processor.getNotificationFilters();\n if (filters.minSeverity) {\n if (\n notificationSeverities.indexOf(payload.severity ?? 'normal') >\n notificationSeverities.indexOf(filters.minSeverity)\n ) {\n continue;\n }\n }\n\n if (filters.maxSeverity) {\n if (\n notificationSeverities.indexOf(payload.severity ?? 'normal') <\n notificationSeverities.indexOf(filters.maxSeverity)\n ) {\n continue;\n }\n }\n\n if (filters.excludedTopics && payload.topic) {\n if (filters.excludedTopics.includes(payload.topic)) {\n continue;\n }\n }\n }\n result.push(processor);\n }\n\n return result;\n };\n\n const processOptions = async (\n opts: NotificationSendOptions,\n origin: string,\n ) => {\n const filtered = await filterProcessors({ ...opts, origin, user: null });\n let ret = opts;\n for (const processor of filtered) {\n try {\n ret = processor.processOptions\n ? await processor.processOptions(ret)\n : ret;\n } catch (e) {\n logger.error(\n `Error while processing notification options with ${processor.getName()}: ${e}`,\n );\n }\n }\n return ret;\n };\n\n const preProcessNotification = async (\n notification: Notification,\n opts: NotificationSendOptions,\n ) => {\n const filtered = await filterProcessors(notification);\n let ret = notification;\n for (const processor of filtered) {\n try {\n ret = processor.preProcess\n ? await processor.preProcess(ret, opts)\n : ret;\n } catch (e) {\n logger.error(\n `Error while pre processing notification with ${processor.getName()}: ${e}`,\n );\n }\n }\n return ret;\n };\n\n const postProcessNotification = async (\n notification: Notification,\n opts: NotificationSendOptions,\n ) => {\n const filtered = await filterProcessors(notification);\n for (const processor of filtered) {\n if (processor.postProcess) {\n try {\n await processor.postProcess(notification, opts);\n } catch (e) {\n logger.error(\n `Error while post processing notification with ${processor.getName()}: ${e}`,\n );\n }\n }\n }\n };\n\n const validateLink = (link: string) => {\n const stripLeadingSlash = (s: string) => s.replace(/^\\//, '');\n const ensureTrailingSlash = (s: string) => s.replace(/\\/?$/, '/');\n const url = new URL(\n stripLeadingSlash(link),\n ensureTrailingSlash(frontendBaseUrl),\n );\n if (url.protocol !== 'https:' && url.protocol !== 'http:') {\n throw new Error('Only HTTP/HTTPS links are allowed');\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.orderField) {\n opts.orderField = parseEntityOrderFieldParams(req.query);\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\n if (req.query.topic) {\n opts.topic = req.query.topic.toString();\n }\n\n if (req.query.saved === 'true') {\n opts.saved = true;\n } else if (req.query.saved === 'false') {\n opts.saved = false;\n // or keep undefined\n }\n if (req.query.createdAfter) {\n const sinceEpoch = Date.parse(String(req.query.createdAfter));\n if (isNaN(sinceEpoch)) {\n throw new InputError('Unexpected date format');\n }\n opts.createdAfter = new Date(sinceEpoch);\n }\n if (req.query.minimumSeverity) {\n opts.minimumSeverity = normalizeSeverity(\n req.query.minimumSeverity.toString(),\n );\n }\n\n const [notifications, totalCount] = await Promise.all([\n store.getNotifications(opts),\n store.getNotificationsCount(opts),\n ]);\n res.json({\n totalCount,\n notifications,\n });\n });\n\n router.get('/status', async (req: Request<any, NotificationStatus>, res) => {\n const user = await getUser(req);\n const status = await store.getStatus({ user });\n res.json(status);\n });\n\n router.get(\n '/settings',\n async (req: Request<any, NotificationSettings>, res) => {\n const user = await getUser(req);\n const response = await getNotificationSettings(user);\n res.json(response);\n },\n );\n\n router.post(\n '/settings',\n async (\n req: Request<any, NotificationSettings, NotificationSettings>,\n res,\n ) => {\n const user = await getUser(req);\n const channels = getNotificationChannels();\n const settings: NotificationSettings = req.body;\n if (settings.channels.some(c => !channels.includes(c.id))) {\n throw new InputError('Invalid channel');\n }\n await store.saveNotificationSettings({ user, settings });\n const response = await getNotificationSettings(user);\n res.json(response);\n },\n );\n\n // Make sure this is the last \"GET\" handler\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 throw new NotFoundError('Not found');\n }\n res.json(notifications[0]);\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 (signals) {\n await signals.publish<NotificationReadSignal>({\n recipients: { type: 'user', entityRef: [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 (signals) {\n await signals.publish<NotificationReadSignal>({\n recipients: { type: 'user', entityRef: [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.json(notifications);\n });\n\n const sendBroadcastNotification = async (\n baseNotification: Omit<Notification, 'user' | 'id'>,\n opts: NotificationSendOptions,\n origin: string,\n ) => {\n const { scope } = opts.payload;\n const broadcastNotification = {\n ...baseNotification,\n user: null,\n id: uuid(),\n };\n const notification = await preProcessNotification(\n broadcastNotification,\n opts,\n );\n let existingNotification;\n if (scope) {\n existingNotification = await store.getExistingScopeBroadcast({\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: { ...notification, user: '' },\n });\n ret = restored ?? notification;\n } else {\n await store.saveBroadcast(notification);\n }\n\n if (signals) {\n await signals.publish<NewNotificationSignal>({\n recipients: { type: 'broadcast' },\n message: {\n action: 'new_notification',\n notification_id: ret.id,\n },\n channel: 'notifications',\n });\n postProcessNotification(ret, opts);\n }\n return notification;\n };\n\n const sendUserNotifications = async (\n baseNotification: Omit<Notification, 'user' | 'id'>,\n users: string[],\n opts: NotificationSendOptions,\n origin: string,\n ) => {\n const notifications = [];\n const { scope } = opts.payload;\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 preProcessNotification(userNotification, opts);\n\n const enabled = await isNotificationsEnabled({\n user,\n channel: WEB_NOTIFICATION_CHANNEL,\n origin: userNotification.origin,\n });\n\n let ret = notification;\n if (enabled) {\n let existingNotification;\n if (scope) {\n existingNotification = await store.getExistingScopeNotification({\n user,\n scope,\n origin,\n });\n }\n\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 notifications.push(ret);\n\n if (signals) {\n await signals.publish<NewNotificationSignal>({\n recipients: { type: 'user', entityRef: [user] },\n message: {\n action: 'new_notification',\n notification_id: ret.id,\n },\n channel: 'notifications',\n });\n }\n }\n postProcessNotification(ret, opts);\n }\n return notifications;\n };\n\n // Add new notification\n router.post(\n '/',\n async (req: Request<any, Notification[], NotificationSendOptions>, res) => {\n const credentials = await httpAuth.credentials(req, {\n allow: ['service'],\n });\n\n const origin = credentials.principal.subject;\n const opts = await processOptions(req.body, origin);\n const { recipients, payload } = opts;\n const { title, link } = payload;\n const notifications: Notification[] = [];\n let users = [];\n\n if (!recipients || !title) {\n logger.error(`Invalid notification request received`);\n throw new InputError(`Invalid notification request received`);\n }\n\n if (link) {\n try {\n validateLink(link);\n } catch (e) {\n throw new InputError('Invalid link provided', e);\n }\n }\n\n const baseNotification = {\n payload: {\n ...payload,\n severity: payload.severity ?? 'normal',\n },\n origin,\n created: new Date(),\n };\n\n if (recipients.type === 'broadcast') {\n const broadcast = await sendBroadcastNotification(\n baseNotification,\n opts,\n origin,\n );\n notifications.push(broadcast);\n } else {\n const entityRef = recipients.entityRef;\n\n try {\n users = await getUsersForEntityRef(\n entityRef,\n recipients.excludeEntityRef ?? [],\n { auth, catalogClient: catalog },\n );\n } catch (e) {\n logger.error(`Failed to resolve notification receivers: ${e}`);\n throw new InputError('Failed to resolve notification receivers', e);\n }\n\n const userNotifications = await sendUserNotifications(\n baseNotification,\n users,\n opts,\n origin,\n );\n notifications.push(...userNotifications);\n }\n\n res.json(notifications);\n },\n );\n\n router.use(errorHandler());\n return router;\n}\n"],"names":["DatabaseNotificationsStore","isNotificationsEnabledFor","notificationSeverities","Router","express","parseEntityOrderFieldParams","InputError","normalizeSeverity","NotFoundError","uuid","getUsersForEntityRef","errorHandler"],"mappings":";;;;;;;;;;;;;;;;;AAiEA,eAAsB,aACpB,OACyB,EAAA;AACzB,EAAM,MAAA;AAAA,IACJ,MAAA;AAAA,IACA,MAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;A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AA,aAAA,EAAe,OAAQ;AAAA,WACjC;AAAA,iBACO,CAAG,EAAA;AACV,UAAO,MAAA,CAAA,KAAA,CAAM,CAA6C,0CAAA,EAAA,CAAC,CAAE,CAAA,CAAA;AAC7D,UAAM,MAAA,IAAIJ,iBAAW,CAAA,0CAAA,EAA4C,CAAC,CAAA;AAAA;AAGpE,QAAA,MAAM,oBAAoB,MAAM,qBAAA;AAAA,UAC9B,gBAAA;AAAA,UACA,KAAA;AAAA,UACA,IAAA;AAAA,UACA;AAAA,SACF;AACA,QAAc,aAAA,CAAA,IAAA,CAAK,GAAG,iBAAiB,CAAA;AAAA;AAGzC,MAAA,GAAA,CAAI,KAAK,aAAa,CAAA;AAAA;AACxB,GACF;AAEA,EAAO,MAAA,CAAA,GAAA,CAAIK,4BAAc,CAAA;AACzB,EAAO,OAAA,MAAA;AACT;;;;"}
|
|
1
|
+
{"version":3,"file":"router.cjs.js","sources":["../../src/service/router.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 */\n\nimport express, { Request, Response } from 'express';\nimport Router from 'express-promise-router';\nimport {\n DatabaseNotificationsStore,\n normalizeSeverity,\n NotificationGetOptions,\n} from '../database';\nimport { v4 as uuid } from 'uuid';\nimport { CatalogApi } from '@backstage/catalog-client';\nimport {\n NotificationProcessor,\n NotificationSendOptions,\n} from '@backstage/plugin-notifications-node';\nimport { InputError, NotFoundError } from '@backstage/errors';\nimport {\n AuthService,\n DatabaseService,\n HttpAuthService,\n LoggerService,\n UserInfoService,\n} from '@backstage/backend-plugin-api';\nimport { SignalsService } from '@backstage/plugin-signals-node';\nimport {\n isNotificationsEnabledFor,\n NewNotificationSignal,\n Notification,\n NotificationReadSignal,\n NotificationSettings,\n notificationSeverities,\n NotificationStatus,\n} from '@backstage/plugin-notifications-common';\nimport { parseEntityOrderFieldParams } from './parseEntityOrderFieldParams';\nimport { getUsersForEntityRef } from './getUsersForEntityRef';\nimport { Config } from '@backstage/config';\n\n/** @internal */\nexport interface RouterOptions {\n logger: LoggerService;\n config: Config;\n database: DatabaseService;\n auth: AuthService;\n httpAuth: HttpAuthService;\n userInfo: UserInfoService;\n signals?: SignalsService;\n catalog: CatalogApi;\n processors?: NotificationProcessor[];\n}\n\n/** @internal */\nexport async function createRouter(\n options: RouterOptions,\n): Promise<express.Router> {\n const {\n config,\n logger,\n database,\n auth,\n httpAuth,\n userInfo,\n catalog,\n processors = [],\n signals,\n } = options;\n\n const WEB_NOTIFICATION_CHANNEL = 'Web';\n const store = await DatabaseNotificationsStore.create({ database });\n const frontendBaseUrl = config.getString('app.baseUrl');\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 getNotificationChannels = () => {\n return [WEB_NOTIFICATION_CHANNEL, ...processors.map(p => p.getName())];\n };\n\n const getNotificationSettings = async (user: string) => {\n const { origins } = await store.getUserNotificationOrigins({ user });\n const settings = await store.getNotificationSettings({ user });\n const channels = getNotificationChannels();\n\n const response: NotificationSettings = {\n channels: channels.map(channel => {\n const channelSettings = settings.channels.find(c => c.id === channel);\n if (channelSettings) {\n return channelSettings;\n }\n return {\n id: channel,\n origins: origins.map(origin => ({\n id: origin,\n enabled: true,\n })),\n };\n }),\n };\n return response;\n };\n\n const isNotificationsEnabled = async (opts: {\n user: string;\n channel: string;\n origin: string;\n }) => {\n const settings = await getNotificationSettings(opts.user);\n return isNotificationsEnabledFor(settings, opts.channel, opts.origin);\n };\n\n const filterProcessors = async (\n notification:\n | Notification\n | ({ origin: string; user: null } & NotificationSendOptions),\n ) => {\n const result: NotificationProcessor[] = [];\n const { payload, user, origin } = notification;\n\n for (const processor of processors) {\n if (user) {\n const enabled = await isNotificationsEnabled({\n user,\n origin,\n channel: processor.getName(),\n });\n if (!enabled) {\n continue;\n }\n }\n\n if (processor.getNotificationFilters) {\n const filters = processor.getNotificationFilters();\n if (filters.minSeverity) {\n if (\n notificationSeverities.indexOf(payload.severity ?? 'normal') >\n notificationSeverities.indexOf(filters.minSeverity)\n ) {\n continue;\n }\n }\n\n if (filters.maxSeverity) {\n if (\n notificationSeverities.indexOf(payload.severity ?? 'normal') <\n notificationSeverities.indexOf(filters.maxSeverity)\n ) {\n continue;\n }\n }\n\n if (filters.excludedTopics && payload.topic) {\n if (filters.excludedTopics.includes(payload.topic)) {\n continue;\n }\n }\n }\n result.push(processor);\n }\n\n return result;\n };\n\n const processOptions = async (\n opts: NotificationSendOptions,\n origin: string,\n ) => {\n const filtered = await filterProcessors({ ...opts, origin, user: null });\n let ret = opts;\n for (const processor of filtered) {\n try {\n ret = processor.processOptions\n ? await processor.processOptions(ret)\n : ret;\n } catch (e) {\n logger.error(\n `Error while processing notification options with ${processor.getName()}: ${e}`,\n );\n }\n }\n return ret;\n };\n\n const preProcessNotification = async (\n notification: Notification,\n opts: NotificationSendOptions,\n ) => {\n const filtered = await filterProcessors(notification);\n let ret = notification;\n for (const processor of filtered) {\n try {\n ret = processor.preProcess\n ? await processor.preProcess(ret, opts)\n : ret;\n } catch (e) {\n logger.error(\n `Error while pre processing notification with ${processor.getName()}: ${e}`,\n );\n }\n }\n return ret;\n };\n\n const postProcessNotification = async (\n notification: Notification,\n opts: NotificationSendOptions,\n ) => {\n const filtered = await filterProcessors(notification);\n for (const processor of filtered) {\n if (processor.postProcess) {\n try {\n await processor.postProcess(notification, opts);\n } catch (e) {\n logger.error(\n `Error while post processing notification with ${processor.getName()}: ${e}`,\n );\n }\n }\n }\n };\n\n const validateLink = (link: string) => {\n const stripLeadingSlash = (s: string) => s.replace(/^\\//, '');\n const ensureTrailingSlash = (s: string) => s.replace(/\\/?$/, '/');\n const url = new URL(\n stripLeadingSlash(link),\n ensureTrailingSlash(frontendBaseUrl),\n );\n if (url.protocol !== 'https:' && url.protocol !== 'http:') {\n throw new Error('Only HTTP/HTTPS links are allowed');\n }\n };\n\n // TODO: Move to use OpenAPI router instead\n const router = Router();\n router.use(express.json());\n\n const listNotificationsHandler = async (req: Request, res: Response) => {\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.orderField) {\n opts.orderField = parseEntityOrderFieldParams(req.query);\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\n if (req.query.topic) {\n opts.topic = req.query.topic.toString();\n }\n\n if (req.query.saved === 'true') {\n opts.saved = true;\n } else if (req.query.saved === 'false') {\n opts.saved = false;\n // or keep undefined\n }\n if (req.query.createdAfter) {\n const sinceEpoch = Date.parse(String(req.query.createdAfter));\n if (isNaN(sinceEpoch)) {\n throw new InputError('Unexpected date format');\n }\n opts.createdAfter = new Date(sinceEpoch);\n }\n if (req.query.minimumSeverity) {\n opts.minimumSeverity = normalizeSeverity(\n req.query.minimumSeverity.toString(),\n );\n }\n\n const [notifications, totalCount] = await Promise.all([\n store.getNotifications(opts),\n store.getNotificationsCount(opts),\n ]);\n res.json({\n totalCount,\n notifications,\n });\n };\n\n router.get('/', listNotificationsHandler); // Deprecated endpoint\n router.get('/notifications', listNotificationsHandler);\n\n router.get('/status', async (req: Request<any, NotificationStatus>, res) => {\n const user = await getUser(req);\n const status = await store.getStatus({ user });\n res.json(status);\n });\n\n router.get(\n '/settings',\n async (req: Request<any, NotificationSettings>, res) => {\n const user = await getUser(req);\n const response = await getNotificationSettings(user);\n res.json(response);\n },\n );\n\n router.post(\n '/settings',\n async (\n req: Request<any, NotificationSettings, NotificationSettings>,\n res,\n ) => {\n const user = await getUser(req);\n const channels = getNotificationChannels();\n const settings: NotificationSettings = req.body;\n if (settings.channels.some(c => !channels.includes(c.id))) {\n throw new InputError('Invalid channel');\n }\n await store.saveNotificationSettings({ user, settings });\n const response = await getNotificationSettings(user);\n res.json(response);\n },\n );\n\n const getNotificationHandler = async (req: Request, res: Response) => {\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 throw new NotFoundError('Not found');\n }\n res.json(notifications[0]);\n };\n\n // Make sure this is the last \"GET\" handler\n router.get('/:id', getNotificationHandler); // Deprecated endpoint\n router.get('/notifications/:id', getNotificationHandler);\n\n const updateNotificationsHandler = async (req: Request, res: Response) => {\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 (signals) {\n await signals.publish<NotificationReadSignal>({\n recipients: { type: 'user', entityRef: [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 (signals) {\n await signals.publish<NotificationReadSignal>({\n recipients: { type: 'user', entityRef: [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.json(notifications);\n };\n\n router.post('/update', updateNotificationsHandler); // Deprecated endpoint\n router.post('/notifications/update', updateNotificationsHandler);\n\n const sendBroadcastNotification = async (\n baseNotification: Omit<Notification, 'user' | 'id'>,\n opts: NotificationSendOptions,\n origin: string,\n ) => {\n const { scope } = opts.payload;\n const broadcastNotification = {\n ...baseNotification,\n user: null,\n id: uuid(),\n };\n const notification = await preProcessNotification(\n broadcastNotification,\n opts,\n );\n let existingNotification;\n if (scope) {\n existingNotification = await store.getExistingScopeBroadcast({\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: { ...notification, user: '' },\n });\n ret = restored ?? notification;\n } else {\n await store.saveBroadcast(notification);\n }\n\n if (signals) {\n await signals.publish<NewNotificationSignal>({\n recipients: { type: 'broadcast' },\n message: {\n action: 'new_notification',\n notification_id: ret.id,\n },\n channel: 'notifications',\n });\n postProcessNotification(ret, opts);\n }\n return notification;\n };\n\n const sendUserNotifications = async (\n baseNotification: Omit<Notification, 'user' | 'id'>,\n users: string[],\n opts: NotificationSendOptions,\n origin: string,\n ) => {\n const notifications = [];\n const { scope } = opts.payload;\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 preProcessNotification(userNotification, opts);\n\n const enabled = await isNotificationsEnabled({\n user,\n channel: WEB_NOTIFICATION_CHANNEL,\n origin: userNotification.origin,\n });\n\n let ret = notification;\n if (enabled) {\n let existingNotification;\n if (scope) {\n existingNotification = await store.getExistingScopeNotification({\n user,\n scope,\n origin,\n });\n }\n\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 notifications.push(ret);\n\n if (signals) {\n await signals.publish<NewNotificationSignal>({\n recipients: { type: 'user', entityRef: [user] },\n message: {\n action: 'new_notification',\n notification_id: ret.id,\n },\n channel: 'notifications',\n });\n }\n }\n postProcessNotification(ret, opts);\n }\n return notifications;\n };\n\n const createNotificationHandler = async (\n req: Request<any, Notification[], NotificationSendOptions>,\n res: Response,\n ) => {\n const credentials = await httpAuth.credentials(req, {\n allow: ['service'],\n });\n\n const origin = credentials.principal.subject;\n const opts = await processOptions(req.body, origin);\n const { recipients, payload } = opts;\n const { title, link } = payload;\n const notifications: Notification[] = [];\n let users = [];\n\n if (!recipients || !title) {\n logger.error(`Invalid notification request received`);\n throw new InputError(`Invalid notification request received`);\n }\n\n if (link) {\n try {\n validateLink(link);\n } catch (e) {\n throw new InputError('Invalid link provided', e);\n }\n }\n\n const baseNotification = {\n payload: {\n ...payload,\n severity: payload.severity ?? 'normal',\n },\n origin,\n created: new Date(),\n };\n\n if (recipients.type === 'broadcast') {\n const broadcast = await sendBroadcastNotification(\n baseNotification,\n opts,\n origin,\n );\n notifications.push(broadcast);\n } else {\n const entityRef = recipients.entityRef;\n\n try {\n users = await getUsersForEntityRef(\n entityRef,\n recipients.excludeEntityRef ?? [],\n { auth, catalogClient: catalog },\n );\n } catch (e) {\n logger.error(`Failed to resolve notification receivers: ${e}`);\n throw new InputError('Failed to resolve notification receivers', e);\n }\n\n const userNotifications = await sendUserNotifications(\n baseNotification,\n users,\n opts,\n origin,\n );\n notifications.push(...userNotifications);\n }\n\n res.json(notifications);\n };\n\n // Add new notification\n router.post('/', createNotificationHandler);\n router.post('/notifications', createNotificationHandler);\n\n return router;\n}\n"],"names":["DatabaseNotificationsStore","isNotificationsEnabledFor","notificationSeverities","Router","express","parseEntityOrderFieldParams","InputError","normalizeSeverity","NotFoundError","uuid","getUsersForEntityRef"],"mappings":";;;;;;;;;;;;;;;;AAiEA,eAAsB,aACpB,OACyB,EAAA;AACzB,EAAM,MAAA;AAAA,IACJ,MAAA;AAAA,IACA,MAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,IACA,OAAA;AAAA,IACA,aAAa,EAAC;AAAA,IACd;AAAA,GACE,GAAA,OAAA;AAEJ,EAAA,MAAM,wBAA2B,GAAA,KAAA;AACjC,EAAA,MAAM,QAAQ,MAAMA,qDAAA,CAA2B,MAAO,CAAA,E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E,CAAA,CAAA;AAC7D,QAAM,MAAA,IAAIJ,iBAAW,CAAA,0CAAA,EAA4C,CAAC,CAAA;AAAA;AAGpE,MAAA,MAAM,oBAAoB,MAAM,qBAAA;AAAA,QAC9B,gBAAA;AAAA,QACA,KAAA;AAAA,QACA,IAAA;AAAA,QACA;AAAA,OACF;AACA,MAAc,aAAA,CAAA,IAAA,CAAK,GAAG,iBAAiB,CAAA;AAAA;AAGzC,IAAA,GAAA,CAAI,KAAK,aAAa,CAAA;AAAA,GACxB;AAGA,EAAO,MAAA,CAAA,IAAA,CAAK,KAAK,yBAAyB,CAAA;AAC1C,EAAO,MAAA,CAAA,IAAA,CAAK,kBAAkB,yBAAyB,CAAA;AAEvD,EAAO,OAAA,MAAA;AACT;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-notifications-backend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0-next.2",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "backend-plugin",
|
|
6
6
|
"pluginId": "notifications",
|
|
@@ -39,17 +39,17 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@backstage/backend-common": "^0.25.0",
|
|
42
|
-
"@backstage/backend-plugin-api": "1.1.0-next.
|
|
43
|
-
"@backstage/catalog-client": "1.9.0-next.
|
|
44
|
-
"@backstage/catalog-model": "1.7.
|
|
45
|
-
"@backstage/config": "1.3.0",
|
|
46
|
-
"@backstage/errors": "1.2.
|
|
47
|
-
"@backstage/plugin-auth-node": "0.5.5-next.
|
|
48
|
-
"@backstage/plugin-catalog-node": "1.15.0-next.
|
|
49
|
-
"@backstage/plugin-events-node": "0.4.6-next.
|
|
50
|
-
"@backstage/plugin-notifications-common": "0.0.
|
|
51
|
-
"@backstage/plugin-notifications-node": "0.2.10-next.
|
|
52
|
-
"@backstage/plugin-signals-node": "0.1.15-next.
|
|
42
|
+
"@backstage/backend-plugin-api": "1.1.0-next.2",
|
|
43
|
+
"@backstage/catalog-client": "1.9.0-next.2",
|
|
44
|
+
"@backstage/catalog-model": "1.7.2-next.0",
|
|
45
|
+
"@backstage/config": "1.3.1-next.0",
|
|
46
|
+
"@backstage/errors": "1.2.6-next.0",
|
|
47
|
+
"@backstage/plugin-auth-node": "0.5.5-next.2",
|
|
48
|
+
"@backstage/plugin-catalog-node": "1.15.0-next.2",
|
|
49
|
+
"@backstage/plugin-events-node": "0.4.6-next.2",
|
|
50
|
+
"@backstage/plugin-notifications-common": "0.0.7-next.0",
|
|
51
|
+
"@backstage/plugin-notifications-node": "0.2.10-next.2",
|
|
52
|
+
"@backstage/plugin-signals-node": "0.1.15-next.2",
|
|
53
53
|
"express": "^4.17.1",
|
|
54
54
|
"express-promise-router": "^4.1.0",
|
|
55
55
|
"knex": "^3.0.0",
|
|
@@ -58,13 +58,13 @@
|
|
|
58
58
|
"yn": "^4.0.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@backstage/backend-defaults": "0.6.0-next.
|
|
62
|
-
"@backstage/backend-test-utils": "1.2.0-next.
|
|
63
|
-
"@backstage/cli": "0.29.3-next.
|
|
64
|
-
"@backstage/plugin-auth-backend": "0.24.1-next.
|
|
65
|
-
"@backstage/plugin-auth-backend-module-guest-provider": "0.2.3-next.
|
|
66
|
-
"@backstage/plugin-events-backend": "0.4.0-next.
|
|
67
|
-
"@backstage/plugin-signals-backend": "0.2.4-next.
|
|
61
|
+
"@backstage/backend-defaults": "0.6.0-next.2",
|
|
62
|
+
"@backstage/backend-test-utils": "1.2.0-next.2",
|
|
63
|
+
"@backstage/cli": "0.29.3-next.2",
|
|
64
|
+
"@backstage/plugin-auth-backend": "0.24.1-next.2",
|
|
65
|
+
"@backstage/plugin-auth-backend-module-guest-provider": "0.2.3-next.2",
|
|
66
|
+
"@backstage/plugin-events-backend": "0.4.0-next.2",
|
|
67
|
+
"@backstage/plugin-signals-backend": "0.2.4-next.2",
|
|
68
68
|
"@types/express": "^4.17.6",
|
|
69
69
|
"@types/supertest": "^2.0.8",
|
|
70
70
|
"msw": "^1.0.0",
|