@backstage/plugin-notifications-backend 0.3.4-next.1 → 0.3.4-next.3
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 +36 -0
- package/README.md +3 -59
- package/dist/index.cjs.js +95 -64
- package/dist/index.cjs.js.map +1 -1
- package/package.json +17 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @backstage/plugin-notifications-backend
|
|
2
2
|
|
|
3
|
+
## 0.3.4-next.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7a05f50: Allow using notifications without users in the catalog
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/backend-plugin-api@0.8.0-next.3
|
|
10
|
+
- @backstage/backend-common@0.23.4-next.3
|
|
11
|
+
- @backstage/catalog-model@1.6.0-next.0
|
|
12
|
+
- @backstage/catalog-client@1.6.6-next.0
|
|
13
|
+
- @backstage/config@1.2.0
|
|
14
|
+
- @backstage/errors@1.2.4
|
|
15
|
+
- @backstage/plugin-auth-node@0.5.0-next.3
|
|
16
|
+
- @backstage/plugin-events-node@0.3.9-next.3
|
|
17
|
+
- @backstage/plugin-notifications-common@0.0.5
|
|
18
|
+
- @backstage/plugin-notifications-node@0.2.4-next.3
|
|
19
|
+
- @backstage/plugin-signals-node@0.1.9-next.3
|
|
20
|
+
|
|
21
|
+
## 0.3.4-next.2
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- 93095ee: Make sure node-fetch is version 2.7.0 or greater
|
|
26
|
+
- Updated dependencies
|
|
27
|
+
- @backstage/backend-plugin-api@0.8.0-next.2
|
|
28
|
+
- @backstage/plugin-notifications-node@0.2.4-next.2
|
|
29
|
+
- @backstage/backend-common@0.23.4-next.2
|
|
30
|
+
- @backstage/plugin-auth-node@0.5.0-next.2
|
|
31
|
+
- @backstage/plugin-events-node@0.3.9-next.2
|
|
32
|
+
- @backstage/plugin-signals-node@0.1.9-next.2
|
|
33
|
+
- @backstage/catalog-client@1.6.5
|
|
34
|
+
- @backstage/catalog-model@1.5.0
|
|
35
|
+
- @backstage/config@1.2.0
|
|
36
|
+
- @backstage/errors@1.2.4
|
|
37
|
+
- @backstage/plugin-notifications-common@0.0.5
|
|
38
|
+
|
|
3
39
|
## 0.3.4-next.1
|
|
4
40
|
|
|
5
41
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -4,13 +4,7 @@ Welcome to the notifications backend plugin!
|
|
|
4
4
|
|
|
5
5
|
## Getting started
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
```ts
|
|
10
|
-
const backend = createBackend();
|
|
11
|
-
// ...
|
|
12
|
-
backend.add(import('@backstage/plugin-notifications-backend'));
|
|
13
|
-
```
|
|
7
|
+
To install, please refer the [Getting Started](https://backstage.io/docs/notifications) Backstage Notifications and Signals documentation section.
|
|
14
8
|
|
|
15
9
|
For users to be able to see notifications in real-time, you have to install also
|
|
16
10
|
the signals plugin (`@backstage/plugin-signals-node`, `@backstage/plugin-signals-backend`, and
|
|
@@ -18,58 +12,8 @@ the signals plugin (`@backstage/plugin-signals-node`, `@backstage/plugin-signals
|
|
|
18
12
|
|
|
19
13
|
## Extending Notifications
|
|
20
14
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
Start off by creating a notification processor:
|
|
25
|
-
|
|
26
|
-
```ts
|
|
27
|
-
import { Notification } from '@backstage/plugin-notifications-common';
|
|
28
|
-
import { NotificationProcessor } from '@backstage/plugin-notifications-node';
|
|
29
|
-
|
|
30
|
-
class MyNotificationProcessor implements NotificationProcessor {
|
|
31
|
-
async decorate(notification: Notification): Promise<Notification> {
|
|
32
|
-
if (notification.origin === 'plugin-my-plugin') {
|
|
33
|
-
notification.payload.icon = 'my-icon';
|
|
34
|
-
}
|
|
35
|
-
return notification;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async send(notification: Notification): Promise<void> {
|
|
39
|
-
nodemailer.sendEmail({
|
|
40
|
-
from: 'backstage',
|
|
41
|
-
to: 'user',
|
|
42
|
-
subject: notification.payload.title,
|
|
43
|
-
text: notification.payload.description,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
Both of the processing functions are optional, and you can implement only one of them.
|
|
50
|
-
|
|
51
|
-
Add the notification processor to the notification system by:
|
|
52
|
-
|
|
53
|
-
```ts
|
|
54
|
-
import { notificationsProcessingExtensionPoint } from '@backstage/plugin-notifications-node';
|
|
55
|
-
import { Notification } from '@backstage/plugin-notifications-common';
|
|
56
|
-
|
|
57
|
-
export const myPlugin = createBackendPlugin({
|
|
58
|
-
pluginId: 'myPlugin',
|
|
59
|
-
register(env) {
|
|
60
|
-
env.registerInit({
|
|
61
|
-
deps: {
|
|
62
|
-
notifications: notificationsProcessingExtensionPoint,
|
|
63
|
-
// ...
|
|
64
|
-
},
|
|
65
|
-
async init({ notifications }) {
|
|
66
|
-
// ...
|
|
67
|
-
notifications.addProcessor(new MyNotificationProcessor());
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
```
|
|
15
|
+
When a notification is created, it's processing can be customized via `processors`.
|
|
16
|
+
Please refer [Backstage documentation](https://backstage.io/docs/notifications) for further details.
|
|
73
17
|
|
|
74
18
|
## Sending Notifications By Backend Plugins
|
|
75
19
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -9,8 +9,8 @@ var Router = require('express-promise-router');
|
|
|
9
9
|
var pluginNotificationsCommon = require('@backstage/plugin-notifications-common');
|
|
10
10
|
var uuid = require('uuid');
|
|
11
11
|
var catalogClient = require('@backstage/catalog-client');
|
|
12
|
-
var catalogModel = require('@backstage/catalog-model');
|
|
13
12
|
var errors = require('@backstage/errors');
|
|
13
|
+
var catalogModel = require('@backstage/catalog-model');
|
|
14
14
|
var pluginSignalsNode = require('@backstage/plugin-signals-node');
|
|
15
15
|
var pluginNotificationsNode = require('@backstage/plugin-notifications-node');
|
|
16
16
|
|
|
@@ -333,6 +333,98 @@ function isOrder(order) {
|
|
|
333
333
|
return ["asc", "desc"].includes(order);
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
+
const isUserEntityRef = (ref) => catalogModel.parseEntityRef(ref).kind.toLocaleLowerCase() === "user";
|
|
337
|
+
const partitionEntityRefs = (refs) => refs.reduce(
|
|
338
|
+
([userEntityRefs, otherEntityRefs], ref) => {
|
|
339
|
+
return isUserEntityRef(ref) ? [[...userEntityRefs, ref], otherEntityRefs] : [userEntityRefs, [...otherEntityRefs, ref]];
|
|
340
|
+
},
|
|
341
|
+
[[], []]
|
|
342
|
+
);
|
|
343
|
+
const getUsersForEntityRef = async (entityRef, excludeEntityRefs, options) => {
|
|
344
|
+
const { auth, catalogClient } = options;
|
|
345
|
+
if (entityRef === null) {
|
|
346
|
+
return [];
|
|
347
|
+
}
|
|
348
|
+
const { token } = await auth.getPluginRequestToken({
|
|
349
|
+
onBehalfOf: await auth.getOwnServiceCredentials(),
|
|
350
|
+
targetPluginId: "catalog"
|
|
351
|
+
});
|
|
352
|
+
const excluded = Array.isArray(excludeEntityRefs) ? excludeEntityRefs : [excludeEntityRefs];
|
|
353
|
+
const refsArr = Array.isArray(entityRef) ? entityRef : [entityRef];
|
|
354
|
+
const [userEntityRefs, otherEntityRefs] = partitionEntityRefs(refsArr);
|
|
355
|
+
const users = userEntityRefs.filter((ref) => !excluded.includes(ref));
|
|
356
|
+
const entityRefs = otherEntityRefs.filter((ref) => !excluded.includes(ref));
|
|
357
|
+
const fields = ["kind", "metadata.name", "metadata.namespace", "relations"];
|
|
358
|
+
let entities = [];
|
|
359
|
+
if (entityRefs.length > 0) {
|
|
360
|
+
const fetchedEntities = await catalogClient.getEntitiesByRefs(
|
|
361
|
+
{
|
|
362
|
+
entityRefs,
|
|
363
|
+
fields
|
|
364
|
+
},
|
|
365
|
+
{ token }
|
|
366
|
+
);
|
|
367
|
+
entities = fetchedEntities.items;
|
|
368
|
+
}
|
|
369
|
+
const mapEntity = async (entity) => {
|
|
370
|
+
if (!entity) {
|
|
371
|
+
return [];
|
|
372
|
+
}
|
|
373
|
+
const currentEntityRef = catalogModel.stringifyEntityRef(entity);
|
|
374
|
+
if (excluded.includes(currentEntityRef)) {
|
|
375
|
+
return [];
|
|
376
|
+
}
|
|
377
|
+
if (catalogModel.isUserEntity(entity)) {
|
|
378
|
+
return [currentEntityRef];
|
|
379
|
+
}
|
|
380
|
+
if (catalogModel.isGroupEntity(entity)) {
|
|
381
|
+
if (!entity.relations?.length) {
|
|
382
|
+
return [];
|
|
383
|
+
}
|
|
384
|
+
const groupUsers = entity.relations.filter(
|
|
385
|
+
(relation) => relation.type === catalogModel.RELATION_HAS_MEMBER && isUserEntityRef(relation.targetRef)
|
|
386
|
+
).map((r) => r.targetRef);
|
|
387
|
+
const childGroupRefs = entity.relations.filter((relation) => relation.type === catalogModel.RELATION_PARENT_OF).map((r) => r.targetRef);
|
|
388
|
+
let childGroupUsers = [];
|
|
389
|
+
if (childGroupRefs.length > 0) {
|
|
390
|
+
const childGroups = await catalogClient.getEntitiesByRefs(
|
|
391
|
+
{
|
|
392
|
+
entityRefs: childGroupRefs,
|
|
393
|
+
fields
|
|
394
|
+
},
|
|
395
|
+
{ token }
|
|
396
|
+
);
|
|
397
|
+
childGroupUsers = await Promise.all(childGroups.items.map(mapEntity));
|
|
398
|
+
}
|
|
399
|
+
return [...groupUsers, ...childGroupUsers.flat(2)].filter(
|
|
400
|
+
(ref) => !excluded.includes(ref)
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
if (entity.relations?.length) {
|
|
404
|
+
const ownerRef = entity.relations.find(
|
|
405
|
+
(relation) => relation.type === catalogModel.RELATION_OWNED_BY
|
|
406
|
+
)?.targetRef;
|
|
407
|
+
if (!ownerRef) {
|
|
408
|
+
return [];
|
|
409
|
+
}
|
|
410
|
+
if (isUserEntityRef(ownerRef)) {
|
|
411
|
+
if (excluded.includes(ownerRef)) {
|
|
412
|
+
return [];
|
|
413
|
+
}
|
|
414
|
+
return [ownerRef];
|
|
415
|
+
}
|
|
416
|
+
const owner = await catalogClient.getEntityByRef(ownerRef, { token });
|
|
417
|
+
return mapEntity(owner);
|
|
418
|
+
}
|
|
419
|
+
return [];
|
|
420
|
+
};
|
|
421
|
+
for (const entity of entities) {
|
|
422
|
+
const u = await mapEntity(entity);
|
|
423
|
+
users.push(...u);
|
|
424
|
+
}
|
|
425
|
+
return [...new Set(users)];
|
|
426
|
+
};
|
|
427
|
+
|
|
336
428
|
async function createRouter(options) {
|
|
337
429
|
const {
|
|
338
430
|
logger,
|
|
@@ -352,68 +444,6 @@ async function createRouter(options) {
|
|
|
352
444
|
const info = await userInfo.getUserInfo(credentials);
|
|
353
445
|
return info.userEntityRef;
|
|
354
446
|
};
|
|
355
|
-
const getUsersForEntityRef = async (entityRef, excludeEntityRefs) => {
|
|
356
|
-
const { token } = await auth.getPluginRequestToken({
|
|
357
|
-
onBehalfOf: await auth.getOwnServiceCredentials(),
|
|
358
|
-
targetPluginId: "catalog"
|
|
359
|
-
});
|
|
360
|
-
if (entityRef === null) {
|
|
361
|
-
return [];
|
|
362
|
-
}
|
|
363
|
-
const fields = ["kind", "metadata.name", "metadata.namespace", "relations"];
|
|
364
|
-
const refs = Array.isArray(entityRef) ? entityRef : [entityRef];
|
|
365
|
-
const entities = await catalogClient$1.getEntitiesByRefs(
|
|
366
|
-
{
|
|
367
|
-
entityRefs: refs,
|
|
368
|
-
fields
|
|
369
|
-
},
|
|
370
|
-
{ token }
|
|
371
|
-
);
|
|
372
|
-
const excluded = Array.isArray(excludeEntityRefs) ? excludeEntityRefs : [excludeEntityRefs];
|
|
373
|
-
const mapEntity = async (entity) => {
|
|
374
|
-
if (!entity) {
|
|
375
|
-
return [];
|
|
376
|
-
}
|
|
377
|
-
const currentEntityRef = catalogModel.stringifyEntityRef(entity);
|
|
378
|
-
if (excluded.includes(currentEntityRef)) {
|
|
379
|
-
return [];
|
|
380
|
-
}
|
|
381
|
-
if (catalogModel.isUserEntity(entity)) {
|
|
382
|
-
return [currentEntityRef];
|
|
383
|
-
} else if (catalogModel.isGroupEntity(entity) && entity.relations) {
|
|
384
|
-
const users2 = entity.relations.filter((relation) => relation.type === catalogModel.RELATION_HAS_MEMBER).map((r) => r.targetRef);
|
|
385
|
-
const childGroupRefs = entity.relations.filter((relation) => relation.type === catalogModel.RELATION_PARENT_OF).map((r) => r.targetRef);
|
|
386
|
-
const childGroups = await catalogClient$1.getEntitiesByRefs(
|
|
387
|
-
{
|
|
388
|
-
entityRefs: childGroupRefs,
|
|
389
|
-
fields
|
|
390
|
-
},
|
|
391
|
-
{ token }
|
|
392
|
-
);
|
|
393
|
-
const childGroupUsers = await Promise.all(
|
|
394
|
-
childGroups.items.map(mapEntity)
|
|
395
|
-
);
|
|
396
|
-
return [...users2, ...childGroupUsers.flat(2)];
|
|
397
|
-
} else if (entity.relations) {
|
|
398
|
-
const ownerRef = entity.relations.find(
|
|
399
|
-
(relation) => relation.type === catalogModel.RELATION_OWNED_BY
|
|
400
|
-
)?.targetRef;
|
|
401
|
-
if (ownerRef) {
|
|
402
|
-
const owner = await catalogClient$1.getEntityByRef(ownerRef, { token });
|
|
403
|
-
if (owner) {
|
|
404
|
-
return mapEntity(owner);
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
return [];
|
|
409
|
-
};
|
|
410
|
-
const users = [];
|
|
411
|
-
for (const entity of entities.items) {
|
|
412
|
-
const u = await mapEntity(entity);
|
|
413
|
-
users.push(...u);
|
|
414
|
-
}
|
|
415
|
-
return users;
|
|
416
|
-
};
|
|
417
447
|
const filterProcessors = (payload) => {
|
|
418
448
|
const result = [];
|
|
419
449
|
for (const processor of processors) {
|
|
@@ -711,7 +741,8 @@ async function createRouter(options) {
|
|
|
711
741
|
try {
|
|
712
742
|
users = await getUsersForEntityRef(
|
|
713
743
|
entityRef,
|
|
714
|
-
recipients.excludeEntityRef ?? []
|
|
744
|
+
recipients.excludeEntityRef ?? [],
|
|
745
|
+
{ auth, catalogClient: catalogClient$1 }
|
|
715
746
|
);
|
|
716
747
|
} catch (e) {
|
|
717
748
|
logger.error(`Failed to resolve notification receivers: ${e}`);
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/database/DatabaseNotificationsStore.ts","../src/service/parseEntityOrderFieldParams.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 { PluginDatabaseManager } from '@backstage/backend-common';\nimport { resolvePackagePath } from '@backstage/backend-plugin-api';\nimport {\n NotificationGetOptions,\n NotificationModifyOptions,\n NotificationsStore,\n} from './NotificationsStore';\nimport {\n Notification,\n NotificationSeverity,\n notificationSeverities,\n} from '@backstage/plugin-notifications-common';\nimport { Knex } from 'knex';\n\nconst migrationsDir = resolvePackagePath(\n '@backstage/plugin-notifications-backend',\n 'migrations',\n);\n\nconst NOTIFICATION_COLUMNS = [\n 'id',\n 'title',\n 'description',\n 'severity',\n 'link',\n 'origin',\n 'scope',\n 'topic',\n 'created',\n 'updated',\n 'user',\n 'read',\n 'saved',\n];\n\nexport const normalizeSeverity = (input?: string): NotificationSeverity => {\n let lower = (input ?? 'normal').toLowerCase() as NotificationSeverity;\n if (notificationSeverities.indexOf(lower) < 0) {\n lower = 'normal';\n }\n return lower;\n};\n\n/** @internal */\nexport class DatabaseNotificationsStore implements NotificationsStore {\n private readonly isSQLite = false;\n\n private constructor(private readonly db: Knex) {\n this.isSQLite = this.db.client.config.client.includes('sqlite3');\n }\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: new Date(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: normalizeSeverity(notification.payload?.severity),\n scope: notification.payload?.scope,\n saved: notification.saved,\n read: notification.read,\n };\n };\n\n private mapBroadcastToDbRow = (notification: Notification) => {\n return {\n id: notification.id,\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: normalizeSeverity(notification.payload?.severity),\n scope: notification.payload?.scope,\n };\n };\n\n private getBroadcastUnion = () => {\n return this.db('broadcast')\n .leftJoin(\n 'broadcast_user_status',\n 'id',\n '=',\n 'broadcast_user_status.broadcast_id',\n )\n .select(NOTIFICATION_COLUMNS);\n };\n\n private getNotificationsBaseQuery = (\n options: NotificationGetOptions | NotificationModifyOptions,\n ) => {\n const { user, orderField } = options;\n\n const subQuery = this.db('notification')\n .select(NOTIFICATION_COLUMNS)\n .unionAll([this.getBroadcastUnion()])\n .as('notifications');\n\n const query = this.db.from(subQuery).where(q => {\n q.where('user', user).orWhereNull('user');\n });\n\n if (orderField && orderField.length > 0) {\n orderField.forEach(orderBy => {\n query.orderBy(orderBy.field, orderBy.order);\n });\n } else if (!orderField) {\n query.orderBy('created', 'desc');\n }\n\n if (options.createdAfter) {\n if (this.isSQLite) {\n query.where('created', '>=', options.createdAfter.valueOf());\n } else {\n query.where('created', '>=', options.createdAfter.toISOString());\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(title) LIKE LOWER(?) OR LOWER(description) LIKE LOWER(?))`,\n [`%${options.search}%`, `%${options.search}%`],\n );\n }\n\n if (options.ids) {\n query.whereIn('id', options.ids);\n }\n\n if (options.read) {\n query.whereNotNull('read');\n } else if (options.read === false) {\n query.whereNull('read');\n } // or match both if undefined\n\n if (options.topic) {\n query.where('topic', '=', options.topic);\n }\n\n if (options.saved) {\n query.whereNotNull('saved');\n } else if (options.saved === false) {\n query.whereNull('saved');\n } // or match both if undefined\n\n if (options.minimumSeverity !== undefined) {\n const idx = notificationSeverities.indexOf(options.minimumSeverity);\n const equalOrHigher = notificationSeverities.slice(0, idx + 1);\n query.whereIn('severity', equalOrHigher);\n }\n\n return query;\n };\n\n async getNotifications(options: NotificationGetOptions) {\n const notificationQuery = this.getNotificationsBaseQuery(options);\n const notifications = await notificationQuery.select(NOTIFICATION_COLUMNS);\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.orderField = [];\n const notificationQuery = this.getNotificationsBaseQuery(countOptions);\n const response = await notificationQuery.count('id 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 saveBroadcast(notification: Notification) {\n await this.db\n .insert(this.mapBroadcastToDbRow(notification))\n .into('broadcast');\n if (notification.saved || notification.read) {\n await this.db\n .insert({\n user: notification.user,\n broadcast_id: notification.id,\n saved: notification.saved,\n read: notification.read,\n })\n .into('broadcast_user_status');\n }\n }\n\n async getStatus(options: NotificationGetOptions) {\n const notificationQuery = this.getNotificationsBaseQuery({\n ...options,\n orderField: [],\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 .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 getExistingScopeBroadcast(options: { scope: string; origin: string }) {\n const query = this.db('broadcast')\n .where('scope', options.scope)\n .where('origin', options.origin)\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({\n id,\n notification,\n }: {\n id: string;\n notification: Notification;\n }) {\n const updateColumns = {\n title: notification.payload.title,\n description: notification.payload.description,\n link: notification.payload.link,\n topic: notification.payload.topic,\n updated: new Date(),\n severity: normalizeSeverity(notification.payload?.severity),\n read: null,\n };\n\n const notificationQuery = this.db('notification')\n .where('id', id)\n .where('user', notification.user);\n const broadcastQuery = this.db('broadcast').where('id', id);\n\n await Promise.all([\n notificationQuery.update(updateColumns),\n broadcastQuery.update({ ...updateColumns, read: undefined }),\n ]);\n\n return await this.getNotification({ id });\n }\n\n async getNotification(options: { id: string }): Promise<Notification | null> {\n const rows = await this.db\n .select('*')\n .from(\n this.db('notification')\n .select(NOTIFICATION_COLUMNS)\n .unionAll([this.getBroadcastUnion()])\n .as('notifications'),\n )\n .where('id', options.id)\n .limit(1);\n if (!rows || rows.length === 0) {\n return null;\n }\n return this.mapToNotifications(rows)[0];\n }\n\n private markReadSaved = async (\n ids: string[],\n user: string,\n read?: Date | null,\n saved?: Date | null,\n ) => {\n await this.db('notification')\n .whereIn('id', ids)\n .where('user', user)\n .update({ read, saved });\n\n const broadcasts = this.mapToNotifications(\n await this.db('broadcast').whereIn('id', ids).select(),\n );\n\n if (broadcasts.length > 0)\n if (!this.isSQLite) {\n await this.db('broadcast_user_status')\n .insert(\n broadcasts.map(b => ({\n broadcast_id: b.id,\n user,\n read,\n saved,\n })),\n )\n .onConflict(['broadcast_id', 'user'])\n .merge(['read', 'saved']);\n } else {\n // SQLite does not support upsert so fall back to this (mostly for tests and local dev)\n for (const b of broadcasts) {\n const baseQuery = this.db('broadcast_user_status')\n .where('broadcast_id', b.id)\n .where('user', user);\n const exists = await baseQuery.clone().limit(1).select().first();\n if (exists) {\n await baseQuery.clone().update({ read, saved });\n } else {\n await baseQuery\n .clone()\n .insert({ broadcast_id: b.id, user, read, saved });\n }\n }\n }\n };\n\n async markRead(options: NotificationModifyOptions): Promise<void> {\n await this.markReadSaved(options.ids, options.user, new Date(), undefined);\n }\n\n async markUnread(options: NotificationModifyOptions): Promise<void> {\n await this.markReadSaved(options.ids, options.user, null, undefined);\n }\n\n async markSaved(options: NotificationModifyOptions): Promise<void> {\n await this.markReadSaved(options.ids, options.user, undefined, new Date());\n }\n\n async markUnsaved(options: NotificationModifyOptions): Promise<void> {\n await this.markReadSaved(options.ids, options.user, undefined, null);\n }\n}\n","/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// This file is based on the plugins/catalog-backend\n\nimport { InputError } from '@backstage/errors';\nimport { EntityOrder } from '../database';\n\n/**\n * Takes a single unknown parameter and makes sure that it's a single string or\n * an array of strings, and returns as an array.\n */\nexport function parseStringsParam(\n param: unknown,\n ctx: string,\n): string[] | undefined {\n if (param === undefined) {\n return undefined;\n }\n\n const array = [param].flat();\n if (array.some(p => typeof p !== 'string')) {\n throw new InputError(`Invalid ${ctx}, not a string`);\n }\n\n return array as string[];\n}\n\nexport function parseEntityOrderFieldParams(\n params: Record<string, unknown>,\n): EntityOrder[] | undefined {\n const orderFieldStrings = parseStringsParam(params.orderField, 'orderField');\n if (!orderFieldStrings) {\n return undefined;\n }\n\n return orderFieldStrings.map(orderFieldString => {\n const [field, order] = orderFieldString.split(',');\n\n if (order !== undefined && !isOrder(order)) {\n throw new InputError('Invalid order field order, must be asc or desc');\n }\n return { field, order };\n });\n}\n\nexport function isOrder(order: string): order is 'asc' | 'desc' {\n return ['asc', 'desc'].includes(order);\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 normalizeSeverity,\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 RELATION_OWNED_BY,\n RELATION_PARENT_OF,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport {\n NotificationProcessor,\n NotificationSendOptions,\n} 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 { SignalsService } from '@backstage/plugin-signals-node';\nimport {\n NewNotificationSignal,\n Notification,\n NotificationPayload,\n NotificationReadSignal,\n notificationSeverities,\n NotificationStatus,\n} from '@backstage/plugin-notifications-common';\nimport { parseEntityOrderFieldParams } from './parseEntityOrderFieldParams';\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 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 logger,\n database,\n auth,\n httpAuth,\n userInfo,\n discovery,\n catalog,\n processors = [],\n signals,\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 excludeEntityRefs: string | string[],\n ): Promise<string[]> => {\n const { token } = await auth.getPluginRequestToken({\n onBehalfOf: await auth.getOwnServiceCredentials(),\n targetPluginId: 'catalog',\n });\n\n if (entityRef === null) {\n return [];\n }\n\n const fields = ['kind', 'metadata.name', 'metadata.namespace', 'relations'];\n\n const refs = Array.isArray(entityRef) ? entityRef : [entityRef];\n const entities = await catalogClient.getEntitiesByRefs(\n {\n entityRefs: refs,\n fields,\n },\n { token },\n );\n\n const excluded = Array.isArray(excludeEntityRefs)\n ? excludeEntityRefs\n : [excludeEntityRefs];\n\n const mapEntity = async (entity: Entity | undefined): Promise<string[]> => {\n if (!entity) {\n return [];\n }\n\n const currentEntityRef = stringifyEntityRef(entity);\n if (excluded.includes(currentEntityRef)) {\n return [];\n }\n\n if (isUserEntity(entity)) {\n return [currentEntityRef];\n } else if (isGroupEntity(entity) && entity.relations) {\n const users = entity.relations\n .filter(relation => relation.type === RELATION_HAS_MEMBER)\n .map(r => r.targetRef);\n\n const childGroupRefs = entity.relations\n .filter(relation => relation.type === RELATION_PARENT_OF)\n .map(r => r.targetRef);\n\n const childGroups = await catalogClient.getEntitiesByRefs(\n {\n entityRefs: childGroupRefs,\n fields,\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 (entity.relations) {\n const ownerRef = entity.relations.find(\n relation => relation.type === RELATION_OWNED_BY,\n )?.targetRef;\n\n if (ownerRef) {\n const owner = await catalogClient.getEntityByRef(ownerRef, { token });\n if (owner) {\n return mapEntity(owner);\n }\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\n return users;\n };\n\n const filterProcessors = (payload: NotificationPayload) => {\n const result: NotificationProcessor[] = [];\n\n for (const processor of processors) {\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 (opts: NotificationSendOptions) => {\n const filtered = filterProcessors(opts.payload);\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 = filterProcessors(notification.payload);\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 = filterProcessors(notification.payload);\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 // 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.send({\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.send(status);\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 res.status(404).send({ error: 'Not found' });\n return;\n }\n res.send(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.status(200).send(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 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 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 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 opts = await processOptions(req.body);\n const { recipients, payload } = opts;\n const notifications: Notification[] = [];\n let users = [];\n\n const credentials = await httpAuth.credentials(req, {\n allow: ['service'],\n });\n\n const { title } = payload;\n\n if (!recipients || !title) {\n logger.error(`Invalid notification request received`);\n throw new InputError(`Invalid notification request received`);\n }\n\n const origin = credentials.principal.subject;\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 );\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","/*\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 { signalsServiceRef } 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: signalsServiceRef,\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 signals,\n processors: processingExtensions.processors,\n }),\n );\n httpRouter.addAuthPolicy({\n path: '/health',\n allow: 'unauthenticated',\n });\n },\n });\n },\n});\n"],"names":["resolvePackagePath","notificationSeverities","InputError","catalogClient","CatalogClient","stringifyEntityRef","isUserEntity","isGroupEntity","users","RELATION_HAS_MEMBER","RELATION_PARENT_OF","RELATION_OWNED_BY","Router","express","uuid","errorHandler","createBackendPlugin","notificationsProcessingExtensionPoint","coreServices","signalsServiceRef"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6BA,MAAM,aAAgB,GAAAA,mCAAA;AAAA,EACpB,yCAAA;AAAA,EACA,YAAA;AACF,CAAA,CAAA;AAEA,MAAM,oBAAuB,GAAA;AAAA,EAC3B,IAAA;AAAA,EACA,OAAA;AAAA,EACA,aAAA;AAAA,EACA,UAAA;AAAA,EACA,MAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AACF,CAAA,CAAA;AAEa,MAAA,iBAAA,GAAoB,CAAC,KAAyC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C,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,mCAAA;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,OAAA;AAAA,YACA,YAAY,oBAAqB,CAAA,UAAA;AAAA,WAClC,CAAA;AAAA,SACH,CAAA;AACA,QAAA,UAAA,CAAW,aAAc,CAAA;AAAA,UACvB,IAAM,EAAA,SAAA;AAAA,UACN,KAAO,EAAA,iBAAA;AAAA,SACR,CAAA,CAAA;AAAA,OACH;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/database/DatabaseNotificationsStore.ts","../src/service/parseEntityOrderFieldParams.ts","../src/service/getUsersForEntityRef.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 { PluginDatabaseManager } from '@backstage/backend-common';\nimport { resolvePackagePath } from '@backstage/backend-plugin-api';\nimport {\n NotificationGetOptions,\n NotificationModifyOptions,\n NotificationsStore,\n} from './NotificationsStore';\nimport {\n Notification,\n NotificationSeverity,\n notificationSeverities,\n} from '@backstage/plugin-notifications-common';\nimport { Knex } from 'knex';\n\nconst migrationsDir = resolvePackagePath(\n '@backstage/plugin-notifications-backend',\n 'migrations',\n);\n\nconst NOTIFICATION_COLUMNS = [\n 'id',\n 'title',\n 'description',\n 'severity',\n 'link',\n 'origin',\n 'scope',\n 'topic',\n 'created',\n 'updated',\n 'user',\n 'read',\n 'saved',\n];\n\nexport const normalizeSeverity = (input?: string): NotificationSeverity => {\n let lower = (input ?? 'normal').toLowerCase() as NotificationSeverity;\n if (notificationSeverities.indexOf(lower) < 0) {\n lower = 'normal';\n }\n return lower;\n};\n\n/** @internal */\nexport class DatabaseNotificationsStore implements NotificationsStore {\n private readonly isSQLite = false;\n\n private constructor(private readonly db: Knex) {\n this.isSQLite = this.db.client.config.client.includes('sqlite3');\n }\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: new Date(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: normalizeSeverity(notification.payload?.severity),\n scope: notification.payload?.scope,\n saved: notification.saved,\n read: notification.read,\n };\n };\n\n private mapBroadcastToDbRow = (notification: Notification) => {\n return {\n id: notification.id,\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: normalizeSeverity(notification.payload?.severity),\n scope: notification.payload?.scope,\n };\n };\n\n private getBroadcastUnion = () => {\n return this.db('broadcast')\n .leftJoin(\n 'broadcast_user_status',\n 'id',\n '=',\n 'broadcast_user_status.broadcast_id',\n )\n .select(NOTIFICATION_COLUMNS);\n };\n\n private getNotificationsBaseQuery = (\n options: NotificationGetOptions | NotificationModifyOptions,\n ) => {\n const { user, orderField } = options;\n\n const subQuery = this.db('notification')\n .select(NOTIFICATION_COLUMNS)\n .unionAll([this.getBroadcastUnion()])\n .as('notifications');\n\n const query = this.db.from(subQuery).where(q => {\n q.where('user', user).orWhereNull('user');\n });\n\n if (orderField && orderField.length > 0) {\n orderField.forEach(orderBy => {\n query.orderBy(orderBy.field, orderBy.order);\n });\n } else if (!orderField) {\n query.orderBy('created', 'desc');\n }\n\n if (options.createdAfter) {\n if (this.isSQLite) {\n query.where('created', '>=', options.createdAfter.valueOf());\n } else {\n query.where('created', '>=', options.createdAfter.toISOString());\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(title) LIKE LOWER(?) OR LOWER(description) LIKE LOWER(?))`,\n [`%${options.search}%`, `%${options.search}%`],\n );\n }\n\n if (options.ids) {\n query.whereIn('id', options.ids);\n }\n\n if (options.read) {\n query.whereNotNull('read');\n } else if (options.read === false) {\n query.whereNull('read');\n } // or match both if undefined\n\n if (options.topic) {\n query.where('topic', '=', options.topic);\n }\n\n if (options.saved) {\n query.whereNotNull('saved');\n } else if (options.saved === false) {\n query.whereNull('saved');\n } // or match both if undefined\n\n if (options.minimumSeverity !== undefined) {\n const idx = notificationSeverities.indexOf(options.minimumSeverity);\n const equalOrHigher = notificationSeverities.slice(0, idx + 1);\n query.whereIn('severity', equalOrHigher);\n }\n\n return query;\n };\n\n async getNotifications(options: NotificationGetOptions) {\n const notificationQuery = this.getNotificationsBaseQuery(options);\n const notifications = await notificationQuery.select(NOTIFICATION_COLUMNS);\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.orderField = [];\n const notificationQuery = this.getNotificationsBaseQuery(countOptions);\n const response = await notificationQuery.count('id 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 saveBroadcast(notification: Notification) {\n await this.db\n .insert(this.mapBroadcastToDbRow(notification))\n .into('broadcast');\n if (notification.saved || notification.read) {\n await this.db\n .insert({\n user: notification.user,\n broadcast_id: notification.id,\n saved: notification.saved,\n read: notification.read,\n })\n .into('broadcast_user_status');\n }\n }\n\n async getStatus(options: NotificationGetOptions) {\n const notificationQuery = this.getNotificationsBaseQuery({\n ...options,\n orderField: [],\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 .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 getExistingScopeBroadcast(options: { scope: string; origin: string }) {\n const query = this.db('broadcast')\n .where('scope', options.scope)\n .where('origin', options.origin)\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({\n id,\n notification,\n }: {\n id: string;\n notification: Notification;\n }) {\n const updateColumns = {\n title: notification.payload.title,\n description: notification.payload.description,\n link: notification.payload.link,\n topic: notification.payload.topic,\n updated: new Date(),\n severity: normalizeSeverity(notification.payload?.severity),\n read: null,\n };\n\n const notificationQuery = this.db('notification')\n .where('id', id)\n .where('user', notification.user);\n const broadcastQuery = this.db('broadcast').where('id', id);\n\n await Promise.all([\n notificationQuery.update(updateColumns),\n broadcastQuery.update({ ...updateColumns, read: undefined }),\n ]);\n\n return await this.getNotification({ id });\n }\n\n async getNotification(options: { id: string }): Promise<Notification | null> {\n const rows = await this.db\n .select('*')\n .from(\n this.db('notification')\n .select(NOTIFICATION_COLUMNS)\n .unionAll([this.getBroadcastUnion()])\n .as('notifications'),\n )\n .where('id', options.id)\n .limit(1);\n if (!rows || rows.length === 0) {\n return null;\n }\n return this.mapToNotifications(rows)[0];\n }\n\n private markReadSaved = async (\n ids: string[],\n user: string,\n read?: Date | null,\n saved?: Date | null,\n ) => {\n await this.db('notification')\n .whereIn('id', ids)\n .where('user', user)\n .update({ read, saved });\n\n const broadcasts = this.mapToNotifications(\n await this.db('broadcast').whereIn('id', ids).select(),\n );\n\n if (broadcasts.length > 0)\n if (!this.isSQLite) {\n await this.db('broadcast_user_status')\n .insert(\n broadcasts.map(b => ({\n broadcast_id: b.id,\n user,\n read,\n saved,\n })),\n )\n .onConflict(['broadcast_id', 'user'])\n .merge(['read', 'saved']);\n } else {\n // SQLite does not support upsert so fall back to this (mostly for tests and local dev)\n for (const b of broadcasts) {\n const baseQuery = this.db('broadcast_user_status')\n .where('broadcast_id', b.id)\n .where('user', user);\n const exists = await baseQuery.clone().limit(1).select().first();\n if (exists) {\n await baseQuery.clone().update({ read, saved });\n } else {\n await baseQuery\n .clone()\n .insert({ broadcast_id: b.id, user, read, saved });\n }\n }\n }\n };\n\n async markRead(options: NotificationModifyOptions): Promise<void> {\n await this.markReadSaved(options.ids, options.user, new Date(), undefined);\n }\n\n async markUnread(options: NotificationModifyOptions): Promise<void> {\n await this.markReadSaved(options.ids, options.user, null, undefined);\n }\n\n async markSaved(options: NotificationModifyOptions): Promise<void> {\n await this.markReadSaved(options.ids, options.user, undefined, new Date());\n }\n\n async markUnsaved(options: NotificationModifyOptions): Promise<void> {\n await this.markReadSaved(options.ids, options.user, undefined, null);\n }\n}\n","/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// This file is based on the plugins/catalog-backend\n\nimport { InputError } from '@backstage/errors';\nimport { EntityOrder } from '../database';\n\n/**\n * Takes a single unknown parameter and makes sure that it's a single string or\n * an array of strings, and returns as an array.\n */\nexport function parseStringsParam(\n param: unknown,\n ctx: string,\n): string[] | undefined {\n if (param === undefined) {\n return undefined;\n }\n\n const array = [param].flat();\n if (array.some(p => typeof p !== 'string')) {\n throw new InputError(`Invalid ${ctx}, not a string`);\n }\n\n return array as string[];\n}\n\nexport function parseEntityOrderFieldParams(\n params: Record<string, unknown>,\n): EntityOrder[] | undefined {\n const orderFieldStrings = parseStringsParam(params.orderField, 'orderField');\n if (!orderFieldStrings) {\n return undefined;\n }\n\n return orderFieldStrings.map(orderFieldString => {\n const [field, order] = orderFieldString.split(',');\n\n if (order !== undefined && !isOrder(order)) {\n throw new InputError('Invalid order field order, must be asc or desc');\n }\n return { field, order };\n });\n}\n\nexport function isOrder(order: string): order is 'asc' | 'desc' {\n return ['asc', 'desc'].includes(order);\n}\n","/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n Entity,\n isGroupEntity,\n isUserEntity,\n parseEntityRef,\n RELATION_HAS_MEMBER,\n RELATION_OWNED_BY,\n RELATION_PARENT_OF,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport { AuthService } from '@backstage/backend-plugin-api';\nimport { CatalogApi } from '@backstage/catalog-client';\n\nconst isUserEntityRef = (ref: string) =>\n parseEntityRef(ref).kind.toLocaleLowerCase() === 'user';\n\n// Partitions array of entity references to two arrays; user entity refs and other entity refs\nconst partitionEntityRefs = (refs: string[]): string[][] =>\n refs.reduce(\n ([userEntityRefs, otherEntityRefs]: string[][], ref: string) => {\n return isUserEntityRef(ref)\n ? [[...userEntityRefs, ref], otherEntityRefs]\n : [userEntityRefs, [...otherEntityRefs, ref]];\n },\n [[], []],\n );\n\nexport const getUsersForEntityRef = async (\n entityRef: string | string[] | null,\n excludeEntityRefs: string | string[],\n options: {\n auth: AuthService;\n catalogClient: CatalogApi;\n },\n): Promise<string[]> => {\n const { auth, catalogClient } = options;\n\n if (entityRef === null) {\n return [];\n }\n\n const { token } = await auth.getPluginRequestToken({\n onBehalfOf: await auth.getOwnServiceCredentials(),\n targetPluginId: 'catalog',\n });\n\n const excluded = Array.isArray(excludeEntityRefs)\n ? excludeEntityRefs\n : [excludeEntityRefs];\n\n const refsArr = Array.isArray(entityRef) ? entityRef : [entityRef];\n const [userEntityRefs, otherEntityRefs] = partitionEntityRefs(refsArr);\n const users: string[] = userEntityRefs.filter(ref => !excluded.includes(ref));\n const entityRefs = otherEntityRefs.filter(ref => !excluded.includes(ref));\n\n const fields = ['kind', 'metadata.name', 'metadata.namespace', 'relations'];\n let entities: Array<Entity | undefined> = [];\n if (entityRefs.length > 0) {\n const fetchedEntities = await catalogClient.getEntitiesByRefs(\n {\n entityRefs,\n fields,\n },\n { token },\n );\n entities = fetchedEntities.items;\n }\n\n const mapEntity = async (entity: Entity | undefined): Promise<string[]> => {\n if (!entity) {\n return [];\n }\n\n const currentEntityRef = stringifyEntityRef(entity);\n if (excluded.includes(currentEntityRef)) {\n return [];\n }\n\n if (isUserEntity(entity)) {\n return [currentEntityRef];\n }\n\n if (isGroupEntity(entity)) {\n if (!entity.relations?.length) {\n return [];\n }\n\n const groupUsers = entity.relations\n .filter(\n relation =>\n relation.type === RELATION_HAS_MEMBER &&\n isUserEntityRef(relation.targetRef),\n )\n .map(r => r.targetRef);\n\n const childGroupRefs = entity.relations\n .filter(relation => relation.type === RELATION_PARENT_OF)\n .map(r => r.targetRef);\n\n let childGroupUsers: string[][] = [];\n if (childGroupRefs.length > 0) {\n const childGroups = await catalogClient.getEntitiesByRefs(\n {\n entityRefs: childGroupRefs,\n fields,\n },\n { token },\n );\n childGroupUsers = await Promise.all(childGroups.items.map(mapEntity));\n }\n\n return [...groupUsers, ...childGroupUsers.flat(2)].filter(\n ref => !excluded.includes(ref),\n );\n }\n\n if (entity.relations?.length) {\n const ownerRef = entity.relations.find(\n relation => relation.type === RELATION_OWNED_BY,\n )?.targetRef;\n\n if (!ownerRef) {\n return [];\n }\n\n if (isUserEntityRef(ownerRef)) {\n if (excluded.includes(ownerRef)) {\n return [];\n }\n return [ownerRef];\n }\n\n const owner = await catalogClient.getEntityByRef(ownerRef, { token });\n return mapEntity(owner);\n }\n\n return [];\n };\n\n for (const entity of entities) {\n const u = await mapEntity(entity);\n users.push(...u);\n }\n\n return [...new Set(users)];\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 normalizeSeverity,\n NotificationGetOptions,\n} from '../database';\nimport { v4 as uuid } from 'uuid';\nimport { CatalogApi, CatalogClient } from '@backstage/catalog-client';\nimport {\n NotificationProcessor,\n NotificationSendOptions,\n} 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 { SignalsService } from '@backstage/plugin-signals-node';\nimport {\n NewNotificationSignal,\n Notification,\n NotificationPayload,\n NotificationReadSignal,\n notificationSeverities,\n NotificationStatus,\n} from '@backstage/plugin-notifications-common';\nimport { parseEntityOrderFieldParams } from './parseEntityOrderFieldParams';\nimport { getUsersForEntityRef } from './getUsersForEntityRef';\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 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 logger,\n database,\n auth,\n httpAuth,\n userInfo,\n discovery,\n catalog,\n processors = [],\n signals,\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 filterProcessors = (payload: NotificationPayload) => {\n const result: NotificationProcessor[] = [];\n\n for (const processor of processors) {\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 (opts: NotificationSendOptions) => {\n const filtered = filterProcessors(opts.payload);\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 = filterProcessors(notification.payload);\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 = filterProcessors(notification.payload);\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 // 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.send({\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.send(status);\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 res.status(404).send({ error: 'Not found' });\n return;\n }\n res.send(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.status(200).send(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 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 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 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 opts = await processOptions(req.body);\n const { recipients, payload } = opts;\n const notifications: Notification[] = [];\n let users = [];\n\n const credentials = await httpAuth.credentials(req, {\n allow: ['service'],\n });\n\n const { title } = payload;\n\n if (!recipients || !title) {\n logger.error(`Invalid notification request received`);\n throw new InputError(`Invalid notification request received`);\n }\n\n const origin = credentials.principal.subject;\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 },\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","/*\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 { signalsServiceRef } 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: signalsServiceRef,\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 signals,\n processors: processingExtensions.processors,\n }),\n );\n httpRouter.addAuthPolicy({\n path: '/health',\n allow: 'unauthenticated',\n });\n },\n });\n },\n});\n"],"names":["resolvePackagePath","notificationSeverities","InputError","parseEntityRef","stringifyEntityRef","isUserEntity","isGroupEntity","RELATION_HAS_MEMBER","RELATION_PARENT_OF","RELATION_OWNED_BY","catalogClient","CatalogClient","Router","express","uuid","errorHandler","createBackendPlugin","notificationsProcessingExtensionPoint","coreServices","signalsServiceRef"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6BA,MAAM,aAAgB,GAAAA,mCAAA;AAAA,EACpB,yCAAA;AAAA,EACA,YAAA;AACF,CAAA,CAAA;AAEA,MAAM,oBAAuB,GAAA;AAAA,EAC3B,IAAA;AAAA,EACA,OAAA;AAAA,EACA,aAAA;AAAA,EACA,UAAA;AAAA,EACA,MAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AACF,CAAA,CAAA;AAEa,MAAA,iBAAA,GAAoB,CAAC,KAAyC,KAAA;AACzE,EAAI,IAAA,KAAA,GAAA,CAAS,KAAS,IAAA,QAAA,EAAU,WAAY,EAAA,CAAA;AAC5C,EAAA,IAAIC,gDAAuB,CAAA,OAAA,CAAQ,KAAK,CAAA,GAAI,CAAG,EAAA;AAC7C,IAAQ,KAAA,GAAA,QAAA,CAAA;AAAA,GACV;AACA,EAAO,OAAA,KAAA,CAAA;AACT,CAAA,CAAA;AAGO,MAAM,0BAAyD,CAAA;AAAA,EAG5D,YAA6B,EAAU,EAAA;AAAV,IAAA,IAAA,CAAA,EAAA,GAAA,EAAA,CAAA;AACnC,IAAA,IAAA,CAAK,WAAW,IAAK,CAAA,EAAA,CAAG,OAAO,MAAO,CAAA,MAAA,CAAO,SAAS,SAAS,CAAA,CAAA;AAAA,GACjE;AAAA,EAJiB,QAAW,GAAA,KAAA,CAAA;AAAA,EAM5B,aAAa,MAAO,CAAA;AAAA,IAClB,QAAA;AAAA,IACA,cAAA;AAAA,GAIsC,EAA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CAAA;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,OAAA;AAAA,YACA,YAAY,oBAAqB,CAAA,UAAA;AAAA,WAClC,CAAA;AAAA,SACH,CAAA;AACA,QAAA,UAAA,CAAW,aAAc,CAAA;AAAA,UACvB,IAAM,EAAA,SAAA;AAAA,UACN,KAAO,EAAA,iBAAA;AAAA,SACR,CAAA,CAAA;AAAA,OACH;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.3.4-next.
|
|
3
|
+
"version": "0.3.4-next.3",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "backend-plugin",
|
|
6
6
|
"pluginId": "notifications",
|
|
@@ -38,33 +38,33 @@
|
|
|
38
38
|
"test": "backstage-cli package test"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@backstage/backend-common": "^0.23.4-next.
|
|
42
|
-
"@backstage/backend-plugin-api": "^0.
|
|
43
|
-
"@backstage/catalog-client": "^1.6.
|
|
44
|
-
"@backstage/catalog-model": "^1.
|
|
41
|
+
"@backstage/backend-common": "^0.23.4-next.3",
|
|
42
|
+
"@backstage/backend-plugin-api": "^0.8.0-next.3",
|
|
43
|
+
"@backstage/catalog-client": "^1.6.6-next.0",
|
|
44
|
+
"@backstage/catalog-model": "^1.6.0-next.0",
|
|
45
45
|
"@backstage/config": "^1.2.0",
|
|
46
46
|
"@backstage/errors": "^1.2.4",
|
|
47
|
-
"@backstage/plugin-auth-node": "^0.
|
|
48
|
-
"@backstage/plugin-events-node": "^0.3.9-next.
|
|
47
|
+
"@backstage/plugin-auth-node": "^0.5.0-next.3",
|
|
48
|
+
"@backstage/plugin-events-node": "^0.3.9-next.3",
|
|
49
49
|
"@backstage/plugin-notifications-common": "^0.0.5",
|
|
50
|
-
"@backstage/plugin-notifications-node": "^0.2.4-next.
|
|
51
|
-
"@backstage/plugin-signals-node": "^0.1.9-next.
|
|
50
|
+
"@backstage/plugin-notifications-node": "^0.2.4-next.3",
|
|
51
|
+
"@backstage/plugin-signals-node": "^0.1.9-next.3",
|
|
52
52
|
"express": "^4.17.1",
|
|
53
53
|
"express-promise-router": "^4.1.0",
|
|
54
54
|
"knex": "^3.0.0",
|
|
55
|
-
"node-fetch": "^2.
|
|
55
|
+
"node-fetch": "^2.7.0",
|
|
56
56
|
"uuid": "^9.0.0",
|
|
57
57
|
"winston": "^3.2.1",
|
|
58
58
|
"yn": "^4.0.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@backstage/backend-defaults": "^0.4.2-next.
|
|
62
|
-
"@backstage/backend-test-utils": "^0.4.5-next.
|
|
63
|
-
"@backstage/cli": "^0.27.0-next.
|
|
64
|
-
"@backstage/plugin-auth-backend": "^0.22.10-next.
|
|
65
|
-
"@backstage/plugin-auth-backend-module-guest-provider": "^0.1.9-next.
|
|
66
|
-
"@backstage/plugin-events-backend": "^0.3.10-next.
|
|
67
|
-
"@backstage/plugin-signals-backend": "^0.1.9-next.
|
|
61
|
+
"@backstage/backend-defaults": "^0.4.2-next.3",
|
|
62
|
+
"@backstage/backend-test-utils": "^0.4.5-next.3",
|
|
63
|
+
"@backstage/cli": "^0.27.0-next.4",
|
|
64
|
+
"@backstage/plugin-auth-backend": "^0.22.10-next.3",
|
|
65
|
+
"@backstage/plugin-auth-backend-module-guest-provider": "^0.1.9-next.3",
|
|
66
|
+
"@backstage/plugin-events-backend": "^0.3.10-next.3",
|
|
67
|
+
"@backstage/plugin-signals-backend": "^0.1.9-next.3",
|
|
68
68
|
"@types/express": "^4.17.6",
|
|
69
69
|
"@types/supertest": "^2.0.8",
|
|
70
70
|
"msw": "^1.0.0",
|