@backstage/plugin-notifications-backend 0.0.3 → 0.1.0-next.0
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 +18 -17
- package/dist/index.cjs.js +71 -41
- package/dist/index.cjs.js.map +1 -1
- package/package.json +29 -29
package/CHANGELOG.md
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
# @backstage/plugin-notifications-backend
|
|
2
2
|
|
|
3
|
-
## 0.0.
|
|
3
|
+
## 0.1.0-next.0
|
|
4
4
|
|
|
5
|
-
###
|
|
6
|
-
|
|
7
|
-
- Updated dependencies
|
|
8
|
-
- @backstage/backend-common@0.21.2
|
|
9
|
-
- @backstage/plugin-auth-node@0.4.7
|
|
10
|
-
- @backstage/plugin-notifications-node@0.0.3
|
|
11
|
-
- @backstage/plugin-signals-node@0.0.3
|
|
12
|
-
- @backstage/backend-plugin-api@0.6.12
|
|
13
|
-
- @backstage/plugin-events-node@0.2.21
|
|
5
|
+
### Minor Changes
|
|
14
6
|
|
|
15
|
-
|
|
7
|
+
- 758f2a4: The Notifications frontend has been redesigned towards list view with condensed row details. The 'done' attribute has been removed to keep the Notifications aligned with the idea of a messaging system instead of a task manager.
|
|
16
8
|
|
|
17
9
|
### Patch Changes
|
|
18
10
|
|
|
11
|
+
- 5d9c5ba: The Notifications can be newly filtered based on the Created Date.
|
|
12
|
+
- 0fb419b: Updated dependency `uuid` to `^9.0.0`.
|
|
13
|
+
Updated dependency `@types/uuid` to `^9.0.0`.
|
|
14
|
+
- 84af361: Migrated to using the new auth services.
|
|
19
15
|
- Updated dependencies
|
|
20
|
-
- @backstage/
|
|
21
|
-
- @backstage/
|
|
22
|
-
- @backstage/plugin-
|
|
23
|
-
- @backstage/
|
|
24
|
-
- @backstage/backend-plugin-api@0.6.
|
|
25
|
-
- @backstage/plugin-
|
|
16
|
+
- @backstage/plugin-events-node@0.3.0-next.0
|
|
17
|
+
- @backstage/backend-common@0.21.3-next.0
|
|
18
|
+
- @backstage/plugin-auth-node@0.4.8-next.0
|
|
19
|
+
- @backstage/errors@1.2.4-next.0
|
|
20
|
+
- @backstage/backend-plugin-api@0.6.13-next.0
|
|
21
|
+
- @backstage/plugin-notifications-node@0.1.0-next.0
|
|
22
|
+
- @backstage/plugin-signals-node@0.0.4-next.0
|
|
23
|
+
- @backstage/plugin-notifications-common@0.0.2-next.0
|
|
24
|
+
- @backstage/catalog-client@1.6.1-next.0
|
|
25
|
+
- @backstage/catalog-model@1.4.5-next.0
|
|
26
|
+
- @backstage/config@1.1.2-next.0
|
|
26
27
|
|
|
27
28
|
## 0.0.1
|
|
28
29
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -6,7 +6,6 @@ var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
|
6
6
|
var backendCommon = require('@backstage/backend-common');
|
|
7
7
|
var express = require('express');
|
|
8
8
|
var Router = require('express-promise-router');
|
|
9
|
-
var pluginAuthNode = require('@backstage/plugin-auth-node');
|
|
10
9
|
var uuid = require('uuid');
|
|
11
10
|
var catalogClient = require('@backstage/catalog-client');
|
|
12
11
|
var catalogModel = require('@backstage/catalog-model');
|
|
@@ -40,7 +39,6 @@ class DatabaseNotificationsStore {
|
|
|
40
39
|
id: row.id,
|
|
41
40
|
user: row.user,
|
|
42
41
|
created: row.created,
|
|
43
|
-
done: row.done,
|
|
44
42
|
saved: row.saved,
|
|
45
43
|
read: row.read,
|
|
46
44
|
updated: row.updated,
|
|
@@ -56,21 +54,47 @@ class DatabaseNotificationsStore {
|
|
|
56
54
|
}
|
|
57
55
|
}));
|
|
58
56
|
});
|
|
57
|
+
__publicField(this, "mapNotificationToDbRow", (notification) => {
|
|
58
|
+
var _a, _b, _c, _d, _e, _f;
|
|
59
|
+
return {
|
|
60
|
+
id: notification.id,
|
|
61
|
+
user: notification.user,
|
|
62
|
+
origin: notification.origin,
|
|
63
|
+
created: notification.created,
|
|
64
|
+
topic: (_a = notification.payload) == null ? void 0 : _a.topic,
|
|
65
|
+
link: (_b = notification.payload) == null ? void 0 : _b.link,
|
|
66
|
+
title: (_c = notification.payload) == null ? void 0 : _c.title,
|
|
67
|
+
description: (_d = notification.payload) == null ? void 0 : _d.description,
|
|
68
|
+
severity: (_e = notification.payload) == null ? void 0 : _e.severity,
|
|
69
|
+
scope: (_f = notification.payload) == null ? void 0 : _f.scope,
|
|
70
|
+
saved: notification.saved,
|
|
71
|
+
read: notification.read
|
|
72
|
+
};
|
|
73
|
+
});
|
|
59
74
|
__publicField(this, "getNotificationsBaseQuery", (options) => {
|
|
60
75
|
var _a, _b;
|
|
61
|
-
const { user
|
|
76
|
+
const { user } = options;
|
|
77
|
+
const isSQLite = this.db.client.config.client.includes("sqlite3");
|
|
62
78
|
const query = this.db("notification").where("user", user);
|
|
63
79
|
if (options.sort !== void 0 && options.sort !== null) {
|
|
64
80
|
query.orderBy(options.sort, (_a = options.sortOrder) != null ? _a : "desc");
|
|
65
81
|
} else if (options.sort !== null) {
|
|
66
82
|
query.orderBy("created", (_b = options.sortOrder) != null ? _b : "desc");
|
|
67
83
|
}
|
|
68
|
-
if (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
84
|
+
if (options.createdAfter) {
|
|
85
|
+
if (isSQLite) {
|
|
86
|
+
query.where(
|
|
87
|
+
"notification.created",
|
|
88
|
+
">=",
|
|
89
|
+
options.createdAfter.valueOf()
|
|
90
|
+
);
|
|
91
|
+
} else {
|
|
92
|
+
query.where(
|
|
93
|
+
"notification.created",
|
|
94
|
+
">=",
|
|
95
|
+
options.createdAfter.toISOString()
|
|
96
|
+
);
|
|
97
|
+
}
|
|
74
98
|
}
|
|
75
99
|
if (options.limit) {
|
|
76
100
|
query.limit(options.limit);
|
|
@@ -87,6 +111,16 @@ class DatabaseNotificationsStore {
|
|
|
87
111
|
if (options.ids) {
|
|
88
112
|
query.whereIn("notification.id", options.ids);
|
|
89
113
|
}
|
|
114
|
+
if (options.read) {
|
|
115
|
+
query.whereNotNull("notification.read");
|
|
116
|
+
} else if (options.read === false) {
|
|
117
|
+
query.whereNull("notification.read");
|
|
118
|
+
}
|
|
119
|
+
if (options.saved) {
|
|
120
|
+
query.whereNotNull("notification.saved");
|
|
121
|
+
} else if (options.saved === false) {
|
|
122
|
+
query.whereNull("notification.saved");
|
|
123
|
+
}
|
|
90
124
|
return query;
|
|
91
125
|
});
|
|
92
126
|
}
|
|
@@ -109,7 +143,7 @@ class DatabaseNotificationsStore {
|
|
|
109
143
|
return this.mapToNotifications(notifications);
|
|
110
144
|
}
|
|
111
145
|
async saveNotification(notification) {
|
|
112
|
-
await this.db.insert(notification).into("notification");
|
|
146
|
+
await this.db.insert(this.mapNotificationToDbRow(notification)).into("notification");
|
|
113
147
|
}
|
|
114
148
|
async getStatus(options) {
|
|
115
149
|
const notificationQuery = this.getNotificationsBaseQuery({
|
|
@@ -139,10 +173,9 @@ class DatabaseNotificationsStore {
|
|
|
139
173
|
description: options.notification.payload.description,
|
|
140
174
|
link: options.notification.payload.link,
|
|
141
175
|
topic: options.notification.payload.topic,
|
|
142
|
-
updated:
|
|
176
|
+
updated: /* @__PURE__ */ new Date(),
|
|
143
177
|
severity: options.notification.payload.severity,
|
|
144
|
-
read: null
|
|
145
|
-
done: null
|
|
178
|
+
read: null
|
|
146
179
|
});
|
|
147
180
|
return await this.getNotification(options);
|
|
148
181
|
}
|
|
@@ -161,14 +194,6 @@ class DatabaseNotificationsStore {
|
|
|
161
194
|
const notificationQuery = this.getNotificationsBaseQuery(options);
|
|
162
195
|
await notificationQuery.update({ read: null });
|
|
163
196
|
}
|
|
164
|
-
async markDone(options) {
|
|
165
|
-
const notificationQuery = this.getNotificationsBaseQuery(options);
|
|
166
|
-
await notificationQuery.update({ done: /* @__PURE__ */ new Date(), read: /* @__PURE__ */ new Date() });
|
|
167
|
-
}
|
|
168
|
-
async markUndone(options) {
|
|
169
|
-
const notificationQuery = this.getNotificationsBaseQuery(options);
|
|
170
|
-
await notificationQuery.update({ done: null, read: null });
|
|
171
|
-
}
|
|
172
197
|
async markSaved(options) {
|
|
173
198
|
const notificationQuery = this.getNotificationsBaseQuery(options);
|
|
174
199
|
await notificationQuery.update({ saved: /* @__PURE__ */ new Date() });
|
|
@@ -186,12 +211,12 @@ async function createRouter(options) {
|
|
|
186
211
|
identity,
|
|
187
212
|
discovery,
|
|
188
213
|
catalog,
|
|
189
|
-
tokenManager,
|
|
190
214
|
processors,
|
|
191
215
|
signalService
|
|
192
216
|
} = options;
|
|
193
217
|
const catalogClient$1 = catalog != null ? catalog : new catalogClient.CatalogClient({ discoveryApi: discovery });
|
|
194
218
|
const store = await DatabaseNotificationsStore.create({ database });
|
|
219
|
+
const { auth, httpAuth } = backendCommon.createLegacyAuthAdapters(options);
|
|
195
220
|
const getUser = async (req) => {
|
|
196
221
|
const user = await identity.getIdentity({ request: req });
|
|
197
222
|
if (!user) {
|
|
@@ -199,17 +224,11 @@ async function createRouter(options) {
|
|
|
199
224
|
}
|
|
200
225
|
return user.identity.userEntityRef;
|
|
201
226
|
};
|
|
202
|
-
const authenticateService = async (req) => {
|
|
203
|
-
const token = pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
204
|
-
req.header("authorization")
|
|
205
|
-
);
|
|
206
|
-
if (!token) {
|
|
207
|
-
throw new errors.AuthenticationError();
|
|
208
|
-
}
|
|
209
|
-
await tokenManager.authenticate(token);
|
|
210
|
-
};
|
|
211
227
|
const getUsersForEntityRef = async (entityRef) => {
|
|
212
|
-
const { token } = await
|
|
228
|
+
const { token } = await auth.getPluginRequestToken({
|
|
229
|
+
onBehalfOf: await auth.getOwnServiceCredentials(),
|
|
230
|
+
targetPluginId: "catalog"
|
|
231
|
+
});
|
|
213
232
|
if (entityRef === null) {
|
|
214
233
|
return [];
|
|
215
234
|
}
|
|
@@ -286,9 +305,6 @@ async function createRouter(options) {
|
|
|
286
305
|
const opts = {
|
|
287
306
|
user
|
|
288
307
|
};
|
|
289
|
-
if (req.query.type) {
|
|
290
|
-
opts.type = req.query.type.toString();
|
|
291
|
-
}
|
|
292
308
|
if (req.query.offset) {
|
|
293
309
|
opts.offset = Number.parseInt(req.query.offset.toString(), 10);
|
|
294
310
|
}
|
|
@@ -298,6 +314,18 @@ async function createRouter(options) {
|
|
|
298
314
|
if (req.query.search) {
|
|
299
315
|
opts.search = req.query.search.toString();
|
|
300
316
|
}
|
|
317
|
+
if (req.query.read === "true") {
|
|
318
|
+
opts.read = true;
|
|
319
|
+
} else if (req.query.read === "false") {
|
|
320
|
+
opts.read = false;
|
|
321
|
+
}
|
|
322
|
+
if (req.query.created_after) {
|
|
323
|
+
const sinceEpoch = Date.parse(req.query.created_after.toString());
|
|
324
|
+
if (isNaN(sinceEpoch)) {
|
|
325
|
+
throw new errors.InputError("Unexpected date format");
|
|
326
|
+
}
|
|
327
|
+
opts.createdAfter = new Date(sinceEpoch);
|
|
328
|
+
}
|
|
301
329
|
const notifications = await store.getNotifications(opts);
|
|
302
330
|
res.send(notifications);
|
|
303
331
|
});
|
|
@@ -317,7 +345,7 @@ async function createRouter(options) {
|
|
|
317
345
|
});
|
|
318
346
|
router.get("/status", async (req, res) => {
|
|
319
347
|
const user = await getUser(req);
|
|
320
|
-
const status = await store.getStatus({ user
|
|
348
|
+
const status = await store.getStatus({ user });
|
|
321
349
|
res.send(status);
|
|
322
350
|
});
|
|
323
351
|
router.post("/update", async (req, res) => {
|
|
@@ -358,11 +386,7 @@ async function createRouter(options) {
|
|
|
358
386
|
const { recipients, origin, payload } = req.body;
|
|
359
387
|
const notifications = [];
|
|
360
388
|
let users = [];
|
|
361
|
-
|
|
362
|
-
await authenticateService(req);
|
|
363
|
-
} catch (e) {
|
|
364
|
-
throw new errors.AuthenticationError();
|
|
365
|
-
}
|
|
389
|
+
await httpAuth.credentials(req, { allow: ["service"] });
|
|
366
390
|
const { title, link, scope } = payload;
|
|
367
391
|
if (!recipients || !title || !origin || !link) {
|
|
368
392
|
logger.error(`Invalid notification request received`);
|
|
@@ -466,6 +490,8 @@ const notificationsPlugin = backendPluginApi.createBackendPlugin({
|
|
|
466
490
|
);
|
|
467
491
|
env.registerInit({
|
|
468
492
|
deps: {
|
|
493
|
+
auth: backendPluginApi.coreServices.auth,
|
|
494
|
+
httpAuth: backendPluginApi.coreServices.httpAuth,
|
|
469
495
|
httpRouter: backendPluginApi.coreServices.httpRouter,
|
|
470
496
|
logger: backendPluginApi.coreServices.logger,
|
|
471
497
|
identity: backendPluginApi.coreServices.identity,
|
|
@@ -475,6 +501,8 @@ const notificationsPlugin = backendPluginApi.createBackendPlugin({
|
|
|
475
501
|
signals: pluginSignalsNode.signalService
|
|
476
502
|
},
|
|
477
503
|
async init({
|
|
504
|
+
auth,
|
|
505
|
+
httpAuth,
|
|
478
506
|
httpRouter,
|
|
479
507
|
logger,
|
|
480
508
|
identity,
|
|
@@ -485,6 +513,8 @@ const notificationsPlugin = backendPluginApi.createBackendPlugin({
|
|
|
485
513
|
}) {
|
|
486
514
|
httpRouter.use(
|
|
487
515
|
await createRouter({
|
|
516
|
+
auth,
|
|
517
|
+
httpAuth,
|
|
488
518
|
logger,
|
|
489
519
|
identity,
|
|
490
520
|
database,
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/database/DatabaseNotificationsStore.ts","../src/service/router.ts","../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n PluginDatabaseManager,\n resolvePackagePath,\n} from '@backstage/backend-common';\nimport {\n NotificationGetOptions,\n NotificationModifyOptions,\n NotificationsStore,\n} from './NotificationsStore';\nimport { Notification } from '@backstage/plugin-notifications-common';\nimport { Knex } from 'knex';\n\nconst migrationsDir = resolvePackagePath(\n '@backstage/plugin-notifications-backend',\n 'migrations',\n);\n\n/** @internal */\nexport class DatabaseNotificationsStore implements NotificationsStore {\n private constructor(private readonly db: Knex) {}\n\n static async create({\n database,\n skipMigrations,\n }: {\n database: PluginDatabaseManager;\n skipMigrations?: boolean;\n }): Promise<DatabaseNotificationsStore> {\n const client = await database.getClient();\n\n if (!database.migrations?.skip && !skipMigrations) {\n await client.migrate.latest({\n directory: migrationsDir,\n });\n }\n\n return new DatabaseNotificationsStore(client);\n }\n\n private mapToInteger = (val: string | number | undefined): number => {\n return typeof val === 'string' ? Number.parseInt(val, 10) : val ?? 0;\n };\n\n private mapToNotifications = (rows: any[]): Notification[] => {\n return rows.map(row => ({\n id: row.id,\n user: row.user,\n created: row.created,\n done: row.done,\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 getNotificationsBaseQuery = (\n options: NotificationGetOptions | NotificationModifyOptions,\n ) => {\n const { user, type } = options;\n const query = this.db('notification').where('user', user);\n\n if (options.sort !== undefined && options.sort !== null) {\n query.orderBy(options.sort, options.sortOrder ?? 'desc');\n } else if (options.sort !== null) {\n query.orderBy('created', options.sortOrder ?? 'desc');\n }\n\n if (type === 'undone') {\n query.whereNull('done');\n } else if (type === 'done') {\n query.whereNotNull('done');\n } else if (type === 'saved') {\n query.whereNotNull('saved');\n }\n\n if (options.limit) {\n query.limit(options.limit);\n }\n\n if (options.offset) {\n query.offset(options.offset);\n }\n\n if (options.search) {\n query.whereRaw(\n `(LOWER(notification.title) LIKE LOWER(?) OR LOWER(notification.description) LIKE LOWER(?))`,\n [`%${options.search}%`, `%${options.search}%`],\n );\n }\n\n if (options.ids) {\n query.whereIn('notification.id', options.ids);\n }\n\n return query;\n };\n\n async getNotifications(options: NotificationGetOptions) {\n const notificationQuery = this.getNotificationsBaseQuery(options);\n const notifications = await notificationQuery.select();\n return this.mapToNotifications(notifications);\n }\n\n async saveNotification(notification: Notification) {\n await this.db.insert(notification).into('notification');\n }\n\n async getStatus(options: NotificationGetOptions) {\n const notificationQuery = this.getNotificationsBaseQuery({\n ...options,\n sort: null,\n });\n const readSubQuery = notificationQuery\n .clone()\n .count('id')\n .whereNotNull('read')\n .as('READ');\n const unreadSubQuery = notificationQuery\n .clone()\n .count('id')\n .whereNull('read')\n .as('UNREAD');\n\n const query = await notificationQuery\n .select(readSubQuery, unreadSubQuery)\n .first();\n\n return {\n unread: this.mapToInteger((query as any)?.UNREAD),\n read: this.mapToInteger((query as any)?.READ),\n };\n }\n\n async getExistingScopeNotification(options: {\n user: string;\n scope: string;\n origin: string;\n }) {\n const query = this.db('notification')\n .where('user', options.user)\n .where('scope', options.scope)\n .where('origin', options.origin)\n .select()\n .limit(1);\n\n const rows = await query;\n if (!rows || rows.length === 0) {\n return null;\n }\n return rows[0] as Notification;\n }\n\n async restoreExistingNotification(options: {\n id: string;\n notification: Notification;\n }) {\n const query = this.db('notification')\n .where('id', options.id)\n .where('user', options.notification.user);\n\n await query.update({\n title: options.notification.payload.title,\n description: options.notification.payload.description,\n link: options.notification.payload.link,\n topic: options.notification.payload.topic,\n updated: options.notification.created,\n severity: options.notification.payload.severity,\n read: null,\n done: null,\n });\n\n return await this.getNotification(options);\n }\n\n async getNotification(options: { id: string }): Promise<Notification | null> {\n const rows = await this.db('notification')\n .where('id', options.id)\n .select()\n .limit(1);\n if (!rows || rows.length === 0) {\n return null;\n }\n return this.mapToNotifications(rows)[0];\n }\n\n async markRead(options: NotificationModifyOptions): Promise<void> {\n const notificationQuery = this.getNotificationsBaseQuery(options);\n await notificationQuery.update({ read: new Date() });\n }\n\n async markUnread(options: NotificationModifyOptions): Promise<void> {\n const notificationQuery = this.getNotificationsBaseQuery(options);\n await notificationQuery.update({ read: null });\n }\n\n async markDone(options: NotificationModifyOptions): Promise<void> {\n const notificationQuery = this.getNotificationsBaseQuery(options);\n await notificationQuery.update({ done: new Date(), read: new Date() });\n }\n\n async markUndone(options: NotificationModifyOptions): Promise<void> {\n const notificationQuery = this.getNotificationsBaseQuery(options);\n await notificationQuery.update({ done: null, read: null });\n }\n\n async markSaved(options: NotificationModifyOptions): Promise<void> {\n const notificationQuery = this.getNotificationsBaseQuery(options);\n await notificationQuery.update({ saved: new Date() });\n }\n\n async markUnsaved(options: NotificationModifyOptions): Promise<void> {\n const notificationQuery = this.getNotificationsBaseQuery(options);\n await notificationQuery.update({ saved: null });\n }\n}\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n errorHandler,\n PluginDatabaseManager,\n TokenManager,\n} from '@backstage/backend-common';\nimport express, { Request } from 'express';\nimport Router from 'express-promise-router';\nimport {\n getBearerTokenFromAuthorizationHeader,\n IdentityApi,\n} from '@backstage/plugin-auth-node';\nimport {\n DatabaseNotificationsStore,\n NotificationGetOptions,\n} from '../database';\nimport { v4 as uuid } from 'uuid';\nimport { CatalogApi, CatalogClient } from '@backstage/catalog-client';\nimport {\n Entity,\n isGroupEntity,\n isUserEntity,\n RELATION_HAS_MEMBER,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport { NotificationProcessor } from '@backstage/plugin-notifications-node';\nimport { AuthenticationError, InputError } from '@backstage/errors';\nimport { DiscoveryService, LoggerService } from '@backstage/backend-plugin-api';\nimport { SignalService } from '@backstage/plugin-signals-node';\nimport {\n NewNotificationSignal,\n Notification,\n NotificationReadSignal,\n NotificationType,\n} from '@backstage/plugin-notifications-common';\n\n/** @internal */\nexport interface RouterOptions {\n logger: LoggerService;\n identity: IdentityApi;\n database: PluginDatabaseManager;\n tokenManager: TokenManager;\n discovery: DiscoveryService;\n signalService?: SignalService;\n catalog?: CatalogApi;\n processors?: NotificationProcessor[];\n}\n\n/** @internal */\nexport async function createRouter(\n options: RouterOptions,\n): Promise<express.Router> {\n const {\n logger,\n database,\n identity,\n discovery,\n catalog,\n tokenManager,\n processors,\n signalService,\n } = options;\n\n const catalogClient =\n catalog ?? new CatalogClient({ discoveryApi: discovery });\n const store = await DatabaseNotificationsStore.create({ database });\n\n const getUser = async (req: Request<unknown>) => {\n const user = await identity.getIdentity({ request: req });\n if (!user) {\n throw new AuthenticationError();\n }\n return user.identity.userEntityRef;\n };\n\n const authenticateService = async (req: Request<unknown>) => {\n const token = getBearerTokenFromAuthorizationHeader(\n req.header('authorization'),\n );\n if (!token) {\n throw new AuthenticationError();\n }\n await tokenManager.authenticate(token);\n };\n\n const getUsersForEntityRef = async (\n entityRef: string | string[] | null,\n ): Promise<string[]> => {\n const { token } = await tokenManager.getToken();\n\n // TODO: Support for broadcast\n if (entityRef === null) {\n return [];\n }\n\n const refs = Array.isArray(entityRef) ? entityRef : [entityRef];\n const entities = await catalogClient.getEntitiesByRefs(\n {\n entityRefs: refs,\n fields: ['kind', 'metadata.name', 'metadata.namespace'],\n },\n { token },\n );\n const mapEntity = async (entity: Entity | undefined): Promise<string[]> => {\n if (!entity) {\n return [];\n }\n\n if (isUserEntity(entity)) {\n return [stringifyEntityRef(entity)];\n } else if (isGroupEntity(entity) && entity.relations) {\n const users = entity.relations\n .filter(\n relation =>\n relation.type === RELATION_HAS_MEMBER && relation.targetRef,\n )\n .map(r => r.targetRef);\n const childGroups = await catalogClient.getEntitiesByRefs(\n {\n entityRefs: entity.spec.children,\n fields: ['kind', 'metadata.name', 'metadata.namespace'],\n },\n { token },\n );\n const childGroupUsers = await Promise.all(\n childGroups.items.map(mapEntity),\n );\n return [...users, ...childGroupUsers.flat(2)];\n } else if (!isGroupEntity(entity) && entity.spec?.owner) {\n const owner = await catalogClient.getEntityByRef(\n entity.spec.owner as string,\n { token },\n );\n if (owner) {\n return mapEntity(owner);\n }\n }\n\n return [];\n };\n\n const users: string[] = [];\n for (const entity of entities.items) {\n const u = await mapEntity(entity);\n users.push(...u);\n }\n return users;\n };\n\n const decorateNotification = async (notification: Notification) => {\n let ret: Notification = notification;\n for (const processor of processors ?? []) {\n ret = processor.decorate ? await processor.decorate(ret) : ret;\n }\n return ret;\n };\n\n const processorSendNotification = async (notification: Notification) => {\n for (const processor of processors ?? []) {\n if (processor.send) {\n processor.send(notification);\n }\n }\n };\n\n // TODO: Move to use OpenAPI router instead\n const router = Router();\n router.use(express.json());\n\n router.get('/health', (_, response) => {\n logger.info('PONG!');\n response.json({ status: 'ok' });\n });\n\n router.get('/', async (req, res) => {\n const user = await getUser(req);\n const opts: NotificationGetOptions = {\n user: user,\n };\n if (req.query.type) {\n opts.type = req.query.type.toString() as NotificationType;\n }\n if (req.query.offset) {\n opts.offset = Number.parseInt(req.query.offset.toString(), 10);\n }\n if (req.query.limit) {\n opts.limit = Number.parseInt(req.query.limit.toString(), 10);\n }\n if (req.query.search) {\n opts.search = req.query.search.toString();\n }\n\n const notifications = await store.getNotifications(opts);\n res.send(notifications);\n });\n\n router.get('/:id', async (req, res) => {\n const user = await getUser(req);\n const opts: NotificationGetOptions = {\n user: user,\n limit: 1,\n ids: [req.params.id],\n };\n const notifications = await store.getNotifications(opts);\n if (notifications.length !== 1) {\n res.status(404).send({ error: 'Not found' });\n return;\n }\n res.send(notifications[0]);\n });\n\n router.get('/status', async (req, res) => {\n const user = await getUser(req);\n const status = await store.getStatus({ user, type: 'undone' });\n res.send(status);\n });\n\n router.post('/update', async (req, res) => {\n const user = await getUser(req);\n const { ids, read, saved } = req.body;\n if (!ids || !Array.isArray(ids)) {\n throw new InputError();\n }\n\n if (read === true) {\n await store.markRead({ user, ids });\n\n if (signalService) {\n await signalService.publish<NotificationReadSignal>({\n recipients: [user],\n message: { action: 'notification_read', notification_ids: ids },\n channel: 'notifications',\n });\n }\n } else if (read === false) {\n await store.markUnread({ user: user, ids });\n\n if (signalService) {\n await signalService.publish<NotificationReadSignal>({\n recipients: [user],\n message: { action: 'notification_unread', notification_ids: ids },\n channel: 'notifications',\n });\n }\n }\n\n if (saved === true) {\n await store.markSaved({ user: user, ids });\n } else if (saved === false) {\n await store.markUnsaved({ user: user, ids });\n }\n\n const notifications = await store.getNotifications({ ids, user: user });\n res.status(200).send(notifications);\n });\n\n // Add new notification\n // Allowed only for service-to-service authentication, uses `getUsersForEntityRef` to retrieve recipients for\n // specific entity reference\n router.post('/', async (req, res) => {\n const { recipients, origin, payload } = req.body;\n const notifications = [];\n let users = [];\n\n try {\n await authenticateService(req);\n } catch (e) {\n throw new AuthenticationError();\n }\n\n const { title, link, scope } = payload;\n\n if (!recipients || !title || !origin || !link) {\n logger.error(`Invalid notification request received`);\n throw new InputError();\n }\n\n let entityRef = null;\n // TODO: Support for broadcast notifications\n if (recipients.entityRef && recipients.type === 'entity') {\n entityRef = recipients.entityRef;\n }\n\n try {\n users = await getUsersForEntityRef(entityRef);\n } catch (e) {\n throw new InputError();\n }\n\n const baseNotification: Omit<Notification, 'id' | 'user'> = {\n payload: {\n ...payload,\n severity: payload.severity ?? 'normal',\n },\n origin,\n created: new Date(),\n };\n\n const uniqueUsers = [...new Set(users)];\n for (const user of uniqueUsers) {\n const userNotification = {\n ...baseNotification,\n id: uuid(),\n user,\n };\n const notification = await decorateNotification(userNotification);\n\n let existingNotification;\n if (scope) {\n existingNotification = await store.getExistingScopeNotification({\n user,\n scope,\n origin,\n });\n }\n\n let ret = notification;\n if (existingNotification) {\n const restored = await store.restoreExistingNotification({\n id: existingNotification.id,\n notification,\n });\n ret = restored ?? notification;\n } else {\n await store.saveNotification(notification);\n }\n\n processorSendNotification(ret);\n notifications.push(ret);\n\n if (signalService) {\n await signalService.publish<NewNotificationSignal>({\n recipients: user,\n message: {\n action: 'new_notification',\n notification_id: ret.id,\n },\n channel: 'notifications',\n });\n }\n }\n\n res.json(notifications);\n });\n\n router.use(errorHandler());\n return router;\n}\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n coreServices,\n createBackendPlugin,\n} from '@backstage/backend-plugin-api';\nimport { createRouter } from './service/router';\nimport { signalService } from '@backstage/plugin-signals-node';\nimport {\n NotificationProcessor,\n notificationsProcessingExtensionPoint,\n NotificationsProcessingExtensionPoint,\n} from '@backstage/plugin-notifications-node';\n\nclass NotificationsProcessingExtensionPointImpl\n implements NotificationsProcessingExtensionPoint\n{\n #processors = new Array<NotificationProcessor>();\n\n addProcessor(\n ...processors: Array<NotificationProcessor | Array<NotificationProcessor>>\n ): void {\n this.#processors.push(...processors.flat());\n }\n\n get processors() {\n return this.#processors;\n }\n}\n\n/**\n * Notifications backend plugin\n *\n * @public\n */\nexport const notificationsPlugin = createBackendPlugin({\n pluginId: 'notifications',\n register(env) {\n const processingExtensions =\n new NotificationsProcessingExtensionPointImpl();\n env.registerExtensionPoint(\n notificationsProcessingExtensionPoint,\n processingExtensions,\n );\n\n env.registerInit({\n deps: {\n httpRouter: coreServices.httpRouter,\n logger: coreServices.logger,\n identity: coreServices.identity,\n database: coreServices.database,\n tokenManager: coreServices.tokenManager,\n discovery: coreServices.discovery,\n signals: signalService,\n },\n async init({\n httpRouter,\n logger,\n identity,\n database,\n tokenManager,\n discovery,\n signals,\n }) {\n httpRouter.use(\n await createRouter({\n logger,\n identity,\n database,\n tokenManager,\n discovery,\n signalService: signals,\n processors: processingExtensions.processors,\n }),\n );\n },\n });\n },\n});\n"],"names":["resolvePackagePath","catalogClient","CatalogClient","AuthenticationError","getBearerTokenFromAuthorizationHeader","isUserEntity","stringifyEntityRef","isGroupEntity","users","RELATION_HAS_MEMBER","Router","express","InputError","uuid","errorHandler","createBackendPlugin","notificationsProcessingExtensionPoint","coreServices","signalService"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,aAAgB,GAAAA,gCAAA;AAAA,EACpB,yCAAA;AAAA,EACA,YAAA;AACF,CAAA,CAAA;AAGO,MAAM,0BAAyD,CAAA;AAAA,EAC5D,YAA6B,EAAU,EAAA;AAAV,IAAA,IAAA,CAAA,EAAA,GAAA,EAAA,CAAA;AAoBrC,IAAQ,aAAA,CAAA,IAAA,EAAA,cAAA,EAAe,CAAC,GAA6C,KAAA;AACnE,MAAO,OAAA,OAAO,QAAQ,QAAW,GAAA,MAAA,CAAO,SAAS,GAAK,EAAA,EAAE,IAAI,GAAO,IAAA,IAAA,GAAA,GAAA,GAAA,CAAA,CAAA;AAAA,KACrE,CAAA,CAAA;AAEA,IAAQ,aAAA,CAAA,IAAA,EAAA,oBAAA,EAAqB,CAAC,IAAgC,KAAA;AAC5D,MAAO,OAAA,IAAA,CAAK,IAAI,CAAQ,GAAA,MAAA;AAAA,QACtB,IAAI,GAAI,CAAA,EAAA;AAAA,QACR,MAAM,GAAI,CAAA,IAAA;AAAA,QACV,SAAS,GAAI,CAAA,OAAA;AAAA,QACb,MAAM,GAAI,CAAA,IAAA;AAAA,QACV,OAAO,GAAI,CAAA,KAAA;AAAA,QACX,MAAM,GAAI,CAAA,IAAA;AAAA,QACV,SAAS,GAAI,CAAA,OAAA;AAAA,QACb,QAAQ,GAAI,CAAA,MAAA;AAAA,QACZ,OAAS,EAAA;AAAA,UACP,OAAO,GAAI,CAAA,KAAA;AAAA,UACX,aA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AA,GAAA;AAAA,UACT,MAAM,YAAa,CAAA;AAAA,YACjB,MAAA;AAAA,YACA,QAAA;AAAA,YACA,QAAA;AAAA,YACA,YAAA;AAAA,YACA,SAAA;AAAA,YACA,aAAe,EAAA,OAAA;AAAA,YACf,YAAY,oBAAqB,CAAA,UAAA;AAAA,WAClC,CAAA;AAAA,SACH,CAAA;AAAA,OACF;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/database/DatabaseNotificationsStore.ts","../src/service/router.ts","../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n PluginDatabaseManager,\n resolvePackagePath,\n} from '@backstage/backend-common';\nimport {\n NotificationGetOptions,\n NotificationModifyOptions,\n NotificationsStore,\n} from './NotificationsStore';\nimport { Notification } from '@backstage/plugin-notifications-common';\nimport { Knex } from 'knex';\n\nconst migrationsDir = resolvePackagePath(\n '@backstage/plugin-notifications-backend',\n 'migrations',\n);\n\n/** @internal */\nexport class DatabaseNotificationsStore implements NotificationsStore {\n private constructor(private readonly db: Knex) {}\n\n static async create({\n database,\n skipMigrations,\n }: {\n database: PluginDatabaseManager;\n skipMigrations?: boolean;\n }): Promise<DatabaseNotificationsStore> {\n const client = await database.getClient();\n\n if (!database.migrations?.skip && !skipMigrations) {\n await client.migrate.latest({\n directory: migrationsDir,\n });\n }\n\n return new DatabaseNotificationsStore(client);\n }\n\n private mapToInteger = (val: string | number | undefined): number => {\n return typeof val === 'string' ? Number.parseInt(val, 10) : val ?? 0;\n };\n\n private mapToNotifications = (rows: any[]): Notification[] => {\n return rows.map(row => ({\n id: row.id,\n user: row.user,\n created: row.created,\n saved: row.saved,\n read: row.read,\n updated: row.updated,\n origin: row.origin,\n payload: {\n title: row.title,\n description: row.description,\n link: row.link,\n topic: row.topic,\n severity: row.severity,\n scope: row.scope,\n icon: row.icon,\n },\n }));\n };\n\n private mapNotificationToDbRow = (notification: Notification) => {\n return {\n id: notification.id,\n user: notification.user,\n origin: notification.origin,\n created: notification.created,\n topic: notification.payload?.topic,\n link: notification.payload?.link,\n title: notification.payload?.title,\n description: notification.payload?.description,\n severity: notification.payload?.severity,\n scope: notification.payload?.scope,\n saved: notification.saved,\n read: notification.read,\n };\n };\n\n private getNotificationsBaseQuery = (\n options: NotificationGetOptions | NotificationModifyOptions,\n ) => {\n const { user } = options;\n const isSQLite = this.db.client.config.client.includes('sqlite3');\n // const isPsql = this.db.client.config.client.includes('pg');\n\n const query = this.db('notification').where('user', user);\n\n if (options.sort !== undefined && options.sort !== null) {\n query.orderBy(options.sort, options.sortOrder ?? 'desc');\n } else if (options.sort !== null) {\n query.orderBy('created', options.sortOrder ?? 'desc');\n }\n\n if (options.createdAfter) {\n if (isSQLite) {\n query.where(\n 'notification.created',\n '>=',\n options.createdAfter.valueOf(),\n );\n } else {\n query.where(\n 'notification.created',\n '>=',\n options.createdAfter.toISOString(),\n );\n }\n }\n\n if (options.limit) {\n query.limit(options.limit);\n }\n\n if (options.offset) {\n query.offset(options.offset);\n }\n\n if (options.search) {\n query.whereRaw(\n `(LOWER(notification.title) LIKE LOWER(?) OR LOWER(notification.description) LIKE LOWER(?))`,\n [`%${options.search}%`, `%${options.search}%`],\n );\n }\n\n if (options.ids) {\n query.whereIn('notification.id', options.ids);\n }\n\n if (options.read) {\n query.whereNotNull('notification.read');\n } else if (options.read === false) {\n query.whereNull('notification.read');\n } // or match both if undefined\n\n if (options.saved) {\n query.whereNotNull('notification.saved');\n } else if (options.saved === false) {\n query.whereNull('notification.saved');\n } // or match both if undefined\n\n return query;\n };\n\n async getNotifications(options: NotificationGetOptions) {\n const notificationQuery = this.getNotificationsBaseQuery(options);\n const notifications = await notificationQuery.select();\n return this.mapToNotifications(notifications);\n }\n\n async saveNotification(notification: Notification) {\n await this.db\n .insert(this.mapNotificationToDbRow(notification))\n .into('notification');\n }\n\n async getStatus(options: NotificationGetOptions) {\n const notificationQuery = this.getNotificationsBaseQuery({\n ...options,\n sort: null,\n });\n const readSubQuery = notificationQuery\n .clone()\n .count('id')\n .whereNotNull('read')\n .as('READ');\n const unreadSubQuery = notificationQuery\n .clone()\n .count('id')\n .whereNull('read')\n .as('UNREAD');\n\n const query = await notificationQuery\n .select(readSubQuery, unreadSubQuery)\n .first();\n\n return {\n unread: this.mapToInteger((query as any)?.UNREAD),\n read: this.mapToInteger((query as any)?.READ),\n };\n }\n\n async getExistingScopeNotification(options: {\n user: string;\n scope: string;\n origin: string;\n }) {\n const query = this.db('notification')\n .where('user', options.user)\n .where('scope', options.scope)\n .where('origin', options.origin)\n .select()\n .limit(1);\n\n const rows = await query;\n if (!rows || rows.length === 0) {\n return null;\n }\n return rows[0] as Notification;\n }\n\n async restoreExistingNotification(options: {\n id: string;\n notification: Notification;\n }) {\n const query = this.db('notification')\n .where('id', options.id)\n .where('user', options.notification.user);\n\n await query.update({\n title: options.notification.payload.title,\n description: options.notification.payload.description,\n link: options.notification.payload.link,\n topic: options.notification.payload.topic,\n updated: new Date(),\n severity: options.notification.payload.severity,\n read: null,\n });\n\n return await this.getNotification(options);\n }\n\n async getNotification(options: { id: string }): Promise<Notification | null> {\n const rows = await this.db('notification')\n .where('id', options.id)\n .select()\n .limit(1);\n if (!rows || rows.length === 0) {\n return null;\n }\n return this.mapToNotifications(rows)[0];\n }\n\n async markRead(options: NotificationModifyOptions): Promise<void> {\n const notificationQuery = this.getNotificationsBaseQuery(options);\n await notificationQuery.update({ read: new Date() });\n }\n\n async markUnread(options: NotificationModifyOptions): Promise<void> {\n const notificationQuery = this.getNotificationsBaseQuery(options);\n await notificationQuery.update({ read: null });\n }\n\n async markSaved(options: NotificationModifyOptions): Promise<void> {\n const notificationQuery = this.getNotificationsBaseQuery(options);\n await notificationQuery.update({ saved: new Date() });\n }\n\n async markUnsaved(options: NotificationModifyOptions): Promise<void> {\n const notificationQuery = this.getNotificationsBaseQuery(options);\n await notificationQuery.update({ saved: null });\n }\n}\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n createLegacyAuthAdapters,\n errorHandler,\n PluginDatabaseManager,\n TokenManager,\n} from '@backstage/backend-common';\nimport express, { Request } from 'express';\nimport Router from 'express-promise-router';\nimport { IdentityApi } from '@backstage/plugin-auth-node';\nimport {\n DatabaseNotificationsStore,\n NotificationGetOptions,\n} from '../database';\nimport { v4 as uuid } from 'uuid';\nimport { CatalogApi, CatalogClient } from '@backstage/catalog-client';\nimport {\n Entity,\n isGroupEntity,\n isUserEntity,\n RELATION_HAS_MEMBER,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport { NotificationProcessor } from '@backstage/plugin-notifications-node';\nimport { AuthenticationError, InputError } from '@backstage/errors';\nimport {\n AuthService,\n DiscoveryService,\n HttpAuthService,\n LoggerService,\n} from '@backstage/backend-plugin-api';\nimport { SignalService } from '@backstage/plugin-signals-node';\nimport {\n NewNotificationSignal,\n Notification,\n NotificationReadSignal,\n} from '@backstage/plugin-notifications-common';\n\n/** @internal */\nexport interface RouterOptions {\n logger: LoggerService;\n identity: IdentityApi;\n database: PluginDatabaseManager;\n tokenManager: TokenManager;\n discovery: DiscoveryService;\n signalService?: SignalService;\n catalog?: CatalogApi;\n processors?: NotificationProcessor[];\n auth?: AuthService;\n httpAuth?: HttpAuthService;\n}\n\n/** @internal */\nexport async function createRouter(\n options: RouterOptions,\n): Promise<express.Router> {\n const {\n logger,\n database,\n identity,\n discovery,\n catalog,\n processors,\n signalService,\n } = options;\n\n const catalogClient =\n catalog ?? new CatalogClient({ discoveryApi: discovery });\n const store = await DatabaseNotificationsStore.create({ database });\n\n const { auth, httpAuth } = createLegacyAuthAdapters(options);\n\n const getUser = async (req: Request<unknown>) => {\n const user = await identity.getIdentity({ request: req });\n if (!user) {\n throw new AuthenticationError();\n }\n return user.identity.userEntityRef;\n };\n\n const getUsersForEntityRef = async (\n entityRef: string | string[] | null,\n ): Promise<string[]> => {\n const { token } = await auth.getPluginRequestToken({\n onBehalfOf: await auth.getOwnServiceCredentials(),\n targetPluginId: 'catalog',\n });\n\n // TODO: Support for broadcast\n if (entityRef === null) {\n return [];\n }\n\n const refs = Array.isArray(entityRef) ? entityRef : [entityRef];\n const entities = await catalogClient.getEntitiesByRefs(\n {\n entityRefs: refs,\n fields: ['kind', 'metadata.name', 'metadata.namespace'],\n },\n { token },\n );\n const mapEntity = async (entity: Entity | undefined): Promise<string[]> => {\n if (!entity) {\n return [];\n }\n\n if (isUserEntity(entity)) {\n return [stringifyEntityRef(entity)];\n } else if (isGroupEntity(entity) && entity.relations) {\n const users = entity.relations\n .filter(\n relation =>\n relation.type === RELATION_HAS_MEMBER && relation.targetRef,\n )\n .map(r => r.targetRef);\n const childGroups = await catalogClient.getEntitiesByRefs(\n {\n entityRefs: entity.spec.children,\n fields: ['kind', 'metadata.name', 'metadata.namespace'],\n },\n { token },\n );\n const childGroupUsers = await Promise.all(\n childGroups.items.map(mapEntity),\n );\n return [...users, ...childGroupUsers.flat(2)];\n } else if (!isGroupEntity(entity) && entity.spec?.owner) {\n const owner = await catalogClient.getEntityByRef(\n entity.spec.owner as string,\n { token },\n );\n if (owner) {\n return mapEntity(owner);\n }\n }\n\n return [];\n };\n\n const users: string[] = [];\n for (const entity of entities.items) {\n const u = await mapEntity(entity);\n users.push(...u);\n }\n return users;\n };\n\n const decorateNotification = async (notification: Notification) => {\n let ret: Notification = notification;\n for (const processor of processors ?? []) {\n ret = processor.decorate ? await processor.decorate(ret) : ret;\n }\n return ret;\n };\n\n const processorSendNotification = async (notification: Notification) => {\n for (const processor of processors ?? []) {\n if (processor.send) {\n processor.send(notification);\n }\n }\n };\n\n // TODO: Move to use OpenAPI router instead\n const router = Router();\n router.use(express.json());\n\n router.get('/health', (_, response) => {\n logger.info('PONG!');\n response.json({ status: 'ok' });\n });\n\n router.get('/', async (req, res) => {\n const user = await getUser(req);\n const opts: NotificationGetOptions = {\n user: user,\n };\n if (req.query.offset) {\n opts.offset = Number.parseInt(req.query.offset.toString(), 10);\n }\n if (req.query.limit) {\n opts.limit = Number.parseInt(req.query.limit.toString(), 10);\n }\n if (req.query.search) {\n opts.search = req.query.search.toString();\n }\n if (req.query.read === 'true') {\n opts.read = true;\n } else if (req.query.read === 'false') {\n opts.read = false;\n // or keep undefined\n }\n if (req.query.created_after) {\n const sinceEpoch = Date.parse(req.query.created_after.toString());\n if (isNaN(sinceEpoch)) {\n throw new InputError('Unexpected date format');\n }\n opts.createdAfter = new Date(sinceEpoch);\n }\n\n const notifications = await store.getNotifications(opts);\n res.send(notifications);\n });\n\n router.get('/:id', async (req, res) => {\n const user = await getUser(req);\n const opts: NotificationGetOptions = {\n user: user,\n limit: 1,\n ids: [req.params.id],\n };\n const notifications = await store.getNotifications(opts);\n if (notifications.length !== 1) {\n res.status(404).send({ error: 'Not found' });\n return;\n }\n res.send(notifications[0]);\n });\n\n router.get('/status', async (req, res) => {\n const user = await getUser(req);\n const status = await store.getStatus({ user });\n res.send(status);\n });\n\n router.post('/update', async (req, res) => {\n const user = await getUser(req);\n const { ids, read, saved } = req.body;\n if (!ids || !Array.isArray(ids)) {\n throw new InputError();\n }\n\n if (read === true) {\n await store.markRead({ user, ids });\n\n if (signalService) {\n await signalService.publish<NotificationReadSignal>({\n recipients: [user],\n message: { action: 'notification_read', notification_ids: ids },\n channel: 'notifications',\n });\n }\n } else if (read === false) {\n await store.markUnread({ user: user, ids });\n\n if (signalService) {\n await signalService.publish<NotificationReadSignal>({\n recipients: [user],\n message: { action: 'notification_unread', notification_ids: ids },\n channel: 'notifications',\n });\n }\n }\n\n if (saved === true) {\n await store.markSaved({ user: user, ids });\n } else if (saved === false) {\n await store.markUnsaved({ user: user, ids });\n }\n\n const notifications = await store.getNotifications({ ids, user: user });\n res.status(200).send(notifications);\n });\n\n // Add new notification\n // Allowed only for service-to-service authentication, uses `getUsersForEntityRef` to retrieve recipients for\n // specific entity reference\n router.post('/', async (req, res) => {\n const { recipients, origin, payload } = req.body;\n const notifications = [];\n let users = [];\n\n await httpAuth.credentials(req, { allow: ['service'] });\n\n const { title, link, scope } = payload;\n\n if (!recipients || !title || !origin || !link) {\n logger.error(`Invalid notification request received`);\n throw new InputError();\n }\n\n let entityRef = null;\n // TODO: Support for broadcast notifications\n if (recipients.entityRef && recipients.type === 'entity') {\n entityRef = recipients.entityRef;\n }\n\n try {\n users = await getUsersForEntityRef(entityRef);\n } catch (e) {\n throw new InputError();\n }\n\n const baseNotification: Omit<Notification, 'id' | 'user'> = {\n payload: {\n ...payload,\n severity: payload.severity ?? 'normal',\n },\n origin,\n created: new Date(),\n };\n\n const uniqueUsers = [...new Set(users)];\n for (const user of uniqueUsers) {\n const userNotification = {\n ...baseNotification,\n id: uuid(),\n user,\n };\n const notification = await decorateNotification(userNotification);\n\n let existingNotification;\n if (scope) {\n existingNotification = await store.getExistingScopeNotification({\n user,\n scope,\n origin,\n });\n }\n\n let ret = notification;\n if (existingNotification) {\n const restored = await store.restoreExistingNotification({\n id: existingNotification.id,\n notification,\n });\n ret = restored ?? notification;\n } else {\n await store.saveNotification(notification);\n }\n\n processorSendNotification(ret);\n notifications.push(ret);\n\n if (signalService) {\n await signalService.publish<NewNotificationSignal>({\n recipients: user,\n message: {\n action: 'new_notification',\n notification_id: ret.id,\n },\n channel: 'notifications',\n });\n }\n }\n\n res.json(notifications);\n });\n\n router.use(errorHandler());\n return router;\n}\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n coreServices,\n createBackendPlugin,\n} from '@backstage/backend-plugin-api';\nimport { createRouter } from './service/router';\nimport { signalService } from '@backstage/plugin-signals-node';\nimport {\n NotificationProcessor,\n notificationsProcessingExtensionPoint,\n NotificationsProcessingExtensionPoint,\n} from '@backstage/plugin-notifications-node';\n\nclass NotificationsProcessingExtensionPointImpl\n implements NotificationsProcessingExtensionPoint\n{\n #processors = new Array<NotificationProcessor>();\n\n addProcessor(\n ...processors: Array<NotificationProcessor | Array<NotificationProcessor>>\n ): void {\n this.#processors.push(...processors.flat());\n }\n\n get processors() {\n return this.#processors;\n }\n}\n\n/**\n * Notifications backend plugin\n *\n * @public\n */\nexport const notificationsPlugin = createBackendPlugin({\n pluginId: 'notifications',\n register(env) {\n const processingExtensions =\n new NotificationsProcessingExtensionPointImpl();\n env.registerExtensionPoint(\n notificationsProcessingExtensionPoint,\n processingExtensions,\n );\n\n env.registerInit({\n deps: {\n auth: coreServices.auth,\n httpAuth: coreServices.httpAuth,\n httpRouter: coreServices.httpRouter,\n logger: coreServices.logger,\n identity: coreServices.identity,\n database: coreServices.database,\n tokenManager: coreServices.tokenManager,\n discovery: coreServices.discovery,\n signals: signalService,\n },\n async init({\n auth,\n httpAuth,\n httpRouter,\n logger,\n identity,\n database,\n tokenManager,\n discovery,\n signals,\n }) {\n httpRouter.use(\n await createRouter({\n auth,\n httpAuth,\n logger,\n identity,\n database,\n tokenManager,\n discovery,\n signalService: signals,\n processors: processingExtensions.processors,\n }),\n );\n },\n });\n },\n});\n"],"names":["resolvePackagePath","catalogClient","CatalogClient","createLegacyAuthAdapters","AuthenticationError","isUserEntity","stringifyEntityRef","isGroupEntity","users","RELATION_HAS_MEMBER","Router","express","InputError","uuid","errorHandler","createBackendPlugin","notificationsProcessingExtensionPoint","coreServices","signalService"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,aAAgB,GAAAA,gCAAA;AAAA,EACpB,yCAAA;AAAA,EACA,YAAA;AACF,CAAA,CAAA;AAGO,MAAM,0BAAyD,CAAA;AAAA,EAC5D,YAA6B,EAAU,EAAA;AAAV,IAAA,IAAA,CAAA,EAAA,GAAA,EAAA,CAAA;AAoBrC,IAAQ,aAAA,CAAA,IAAA,EAAA,cAAA,EAAe,CAAC,GAA6C,KAAA;AACnE,MAAO,OAAA,OAAO,QAAQ,QAAW,GAAA,MAAA,CAAO,SAAS,GAAK,EAAA,EAAE,IAAI,GAAO,IAAA,IAAA,GAAA,GAAA,GAAA,CAAA,CAAA;AAAA,KACrE,CAAA,CAAA;AAEA,IAAQ,aAAA,CAAA,IAAA,EAAA,oBAAA,EAAqB,CAAC,IAAgC,KAAA;AAC5D,MAAO,OAAA,IAAA,CAAK,IAAI,CAAQ,GAAA,MAAA;AAAA,QACtB,IAAI,GAAI,CAAA,EAAA;AAAA,QACR,MAAM,GAAI,CAAA,IAAA;AAAA,QACV,SAAS,GAAI,CAAA,OAAA;AAAA,QACb,OAAO,GAAI,CAAA,KAAA;AAAA,QACX,MAAM,GAAI,CAAA,IAAA;AAAA,QACV,SAAS,GAAI,CAAA,OAAA;AAAA,QACb,QAAQ,GAAI,CAAA,MAAA;AAAA,QACZ,OAAS,EAAA;AAAA,UACP,OAAO,GAAI,CAAA,KAAA;AAAA,UACX,aAAa,GAAI,CAAA,WAAA;AAAA,UACjB,MAAM,GAAI,CA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6BAAa,CAAA,SAAA;AAAA,QACxB,OAAS,EAAAC,+BAAA;AAAA,OACX;AAAA,MACA,MAAM,IAAK,CAAA;AAAA,QACT,IAAA;AAAA,QACA,QAAA;AAAA,QACA,UAAA;AAAA,QACA,MAAA;AAAA,QACA,QAAA;AAAA,QACA,QAAA;AAAA,QACA,YAAA;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,MAAA;AAAA,YACA,QAAA;AAAA,YACA,QAAA;AAAA,YACA,YAAA;AAAA,YACA,SAAA;AAAA,YACA,aAAe,EAAA,OAAA;AAAA,YACf,YAAY,oBAAqB,CAAA,UAAA;AAAA,WAClC,CAAA;AAAA,SACH,CAAA;AAAA,OACF;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-notifications-backend",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0-next.0",
|
|
4
|
+
"backstage": {
|
|
5
|
+
"role": "backend-plugin"
|
|
6
|
+
},
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public",
|
|
9
9
|
"main": "dist/index.cjs.js",
|
|
@@ -14,47 +14,47 @@
|
|
|
14
14
|
"url": "https://github.com/backstage/backstage",
|
|
15
15
|
"directory": "plugins/notifications-backend"
|
|
16
16
|
},
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
"license": "Apache-2.0",
|
|
18
|
+
"main": "dist/index.cjs.js",
|
|
19
|
+
"types": "dist/index.d.ts",
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
20
23
|
"scripts": {
|
|
21
|
-
"start": "backstage-cli package start",
|
|
22
24
|
"build": "backstage-cli package build",
|
|
23
|
-
"lint": "backstage-cli package lint",
|
|
24
|
-
"test": "backstage-cli package test",
|
|
25
25
|
"clean": "backstage-cli package clean",
|
|
26
|
+
"lint": "backstage-cli package lint",
|
|
26
27
|
"prepack": "backstage-cli package prepack",
|
|
27
|
-
"postpack": "backstage-cli package postpack"
|
|
28
|
+
"postpack": "backstage-cli package postpack",
|
|
29
|
+
"start": "backstage-cli package start",
|
|
30
|
+
"test": "backstage-cli package test"
|
|
28
31
|
},
|
|
29
32
|
"dependencies": {
|
|
30
|
-
"@backstage/backend-common": "^0.21.
|
|
31
|
-
"@backstage/backend-plugin-api": "^0.6.
|
|
32
|
-
"@backstage/catalog-client": "^1.6.0",
|
|
33
|
-
"@backstage/catalog-model": "^1.4.
|
|
34
|
-
"@backstage/config": "^1.1.
|
|
35
|
-
"@backstage/errors": "^1.2.
|
|
36
|
-
"@backstage/plugin-auth-node": "^0.4.
|
|
37
|
-
"@backstage/plugin-events-node": "^0.
|
|
38
|
-
"@backstage/plugin-notifications-common": "^0.0.
|
|
39
|
-
"@backstage/plugin-notifications-node": "^0.0.
|
|
40
|
-
"@backstage/plugin-signals-node": "^0.0.
|
|
33
|
+
"@backstage/backend-common": "^0.21.3-next.0",
|
|
34
|
+
"@backstage/backend-plugin-api": "^0.6.13-next.0",
|
|
35
|
+
"@backstage/catalog-client": "^1.6.1-next.0",
|
|
36
|
+
"@backstage/catalog-model": "^1.4.5-next.0",
|
|
37
|
+
"@backstage/config": "^1.1.2-next.0",
|
|
38
|
+
"@backstage/errors": "^1.2.4-next.0",
|
|
39
|
+
"@backstage/plugin-auth-node": "^0.4.8-next.0",
|
|
40
|
+
"@backstage/plugin-events-node": "^0.3.0-next.0",
|
|
41
|
+
"@backstage/plugin-notifications-common": "^0.0.2-next.0",
|
|
42
|
+
"@backstage/plugin-notifications-node": "^0.1.0-next.0",
|
|
43
|
+
"@backstage/plugin-signals-node": "^0.0.4-next.0",
|
|
41
44
|
"express": "^4.17.1",
|
|
42
45
|
"express-promise-router": "^4.1.0",
|
|
43
46
|
"knex": "^3.0.0",
|
|
44
47
|
"node-fetch": "^2.6.7",
|
|
45
|
-
"uuid": "^
|
|
48
|
+
"uuid": "^9.0.0",
|
|
46
49
|
"winston": "^3.2.1",
|
|
47
50
|
"yn": "^4.0.0"
|
|
48
51
|
},
|
|
49
52
|
"devDependencies": {
|
|
50
|
-
"@backstage/backend-test-utils": "^0.3.
|
|
51
|
-
"@backstage/cli": "^0.25.
|
|
53
|
+
"@backstage/backend-test-utils": "^0.3.3-next.0",
|
|
54
|
+
"@backstage/cli": "^0.25.3-next.0",
|
|
52
55
|
"@types/express": "^4.17.6",
|
|
53
56
|
"@types/supertest": "^2.0.8",
|
|
54
57
|
"msw": "^1.0.0",
|
|
55
58
|
"supertest": "^6.2.4"
|
|
56
|
-
}
|
|
57
|
-
"files": [
|
|
58
|
-
"dist"
|
|
59
|
-
]
|
|
59
|
+
}
|
|
60
60
|
}
|