@backstage/plugin-notifications-backend 0.6.5 → 0.6.6-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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.cjs.js","sources":["../../../../src/schema/openapi/generated/router.ts"],"sourcesContent":["/*\n * Copyright 2026 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// ******************************************************************\n// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *\n// ******************************************************************\nimport { createValidatedOpenApiRouterFromGeneratedEndpointMap } from '@backstage/backend-openapi-utils';\nimport { EndpointMap } from './apis';\n\nexport const spec = {\n openapi: '3.1.0',\n info: {\n title: 'notifications',\n version: '1',\n description: 'The Backstage backend plugin that powers user notifications.',\n license: {\n name: 'Apache-2.0',\n url: 'http://www.apache.org/licenses/LICENSE-2.0.html',\n },\n contact: {},\n },\n servers: [\n {\n url: '/',\n },\n ],\n components: {\n examples: {},\n headers: {},\n parameters: {\n notificationId: {\n name: 'id',\n in: 'path',\n required: true,\n schema: {\n type: 'string',\n },\n },\n offset: {\n name: 'offset',\n in: 'query',\n required: false,\n allowReserved: true,\n schema: {\n type: 'integer',\n minimum: 0,\n },\n },\n limit: {\n name: 'limit',\n in: 'query',\n required: false,\n allowReserved: true,\n schema: {\n type: 'integer',\n minimum: 0,\n },\n },\n orderField: {\n name: 'orderField',\n in: 'query',\n required: false,\n allowReserved: true,\n description:\n 'One or more \"field,direction\" pairs. Direction is \"asc\" or \"desc\". Pass multiple to express compound sorts.',\n schema: {\n $ref: '#/components/schemas/OrderField',\n },\n },\n topic: {\n name: 'topic',\n in: 'query',\n required: false,\n allowReserved: true,\n schema: {\n type: 'string',\n },\n },\n search: {\n name: 'search',\n in: 'query',\n required: false,\n allowReserved: true,\n schema: {\n type: 'string',\n },\n },\n read: {\n name: 'read',\n in: 'query',\n required: false,\n allowReserved: true,\n schema: {\n type: 'string',\n enum: ['true', 'false'],\n },\n },\n saved: {\n name: 'saved',\n in: 'query',\n required: false,\n allowReserved: true,\n schema: {\n type: 'string',\n enum: ['true', 'false'],\n },\n },\n createdAfter: {\n name: 'createdAfter',\n in: 'query',\n required: false,\n allowReserved: true,\n description: 'ISO 8601 date-time string. Validated by the handler.',\n schema: {\n type: 'string',\n },\n },\n minimumSeverity: {\n name: 'minimumSeverity',\n in: 'query',\n required: false,\n allowReserved: true,\n schema: {\n $ref: '#/components/schemas/NotificationSeverity',\n },\n },\n },\n requestBodies: {},\n responses: {\n ErrorResponse: {\n description: 'An error response from the backend.',\n content: {\n 'application/json; charset=utf-8': {\n schema: {\n $ref: '#/components/schemas/Error',\n },\n },\n },\n },\n },\n schemas: {\n NotificationSeverity: {\n type: 'string',\n enum: ['critical', 'high', 'normal', 'low'],\n },\n NotificationPayload: {\n type: 'object',\n required: ['title'],\n properties: {\n title: {\n type: 'string',\n description: 'Notification title',\n },\n description: {\n type: 'string',\n description: 'Optional longer description for the notification',\n },\n link: {\n type: 'string',\n description: 'Optional link where the notification is pointing to',\n },\n severity: {\n $ref: '#/components/schemas/NotificationSeverity',\n },\n topic: {\n type: 'string',\n description: 'Optional notification topic',\n },\n scope: {\n type: 'string',\n description:\n 'Notification scope, can be used to re-send same notifications in case the scope and origin matches.',\n },\n icon: {\n type: 'string',\n description: 'Optional notification icon',\n },\n metadata: {\n type: 'object',\n description: 'Optional additional customizable metadata.',\n additionalProperties: true,\n },\n },\n },\n NotificationResponsePayload: {\n description:\n 'Response variant of NotificationPayload. Optional string fields may be returned as null when unset.',\n type: 'object',\n required: ['title'],\n properties: {\n title: {\n type: 'string',\n },\n description: {\n type: ['string', 'null'],\n },\n link: {\n type: ['string', 'null'],\n },\n severity: {\n $ref: '#/components/schemas/NotificationSeverity',\n },\n topic: {\n type: ['string', 'null'],\n },\n scope: {\n type: ['string', 'null'],\n },\n icon: {\n type: ['string', 'null'],\n },\n metadata: {\n type: 'object',\n additionalProperties: true,\n },\n },\n },\n Notification: {\n type: 'object',\n required: ['id', 'user', 'created', 'origin', 'payload'],\n properties: {\n id: {\n type: 'string',\n description: 'Unique identifier for the notification.',\n },\n user: {\n type: ['string', 'null'],\n description:\n 'User entity reference, or null for broadcast notifications.',\n },\n created: {\n type: 'string',\n format: 'date-time',\n },\n saved: {\n type: ['string', 'null'],\n format: 'date-time',\n },\n read: {\n type: ['string', 'null'],\n format: 'date-time',\n },\n updated: {\n type: ['string', 'null'],\n format: 'date-time',\n },\n origin: {\n type: 'string',\n description: \"Origin of the notification (the sender's reference).\",\n },\n payload: {\n $ref: '#/components/schemas/NotificationResponsePayload',\n },\n },\n },\n NotificationStatus: {\n type: 'object',\n required: ['unread', 'read'],\n properties: {\n unread: {\n type: 'integer',\n },\n read: {\n type: 'integer',\n },\n },\n },\n TopicSetting: {\n type: 'object',\n required: ['id', 'enabled'],\n properties: {\n id: {\n type: 'string',\n },\n enabled: {\n type: 'boolean',\n },\n },\n },\n OriginSetting: {\n type: 'object',\n required: ['id', 'enabled'],\n properties: {\n id: {\n type: 'string',\n },\n enabled: {\n type: 'boolean',\n },\n topics: {\n type: 'array',\n items: {\n $ref: '#/components/schemas/TopicSetting',\n },\n },\n },\n },\n ChannelSetting: {\n type: 'object',\n required: ['id', 'origins'],\n properties: {\n id: {\n type: 'string',\n },\n enabled: {\n type: 'boolean',\n },\n origins: {\n type: 'array',\n items: {\n $ref: '#/components/schemas/OriginSetting',\n },\n },\n },\n },\n NotificationSettings: {\n type: 'object',\n required: ['channels'],\n properties: {\n channels: {\n type: 'array',\n items: {\n $ref: '#/components/schemas/ChannelSetting',\n },\n },\n },\n },\n EntityRef: {\n description: 'A single entity ref, or a list of entity refs.',\n oneOf: [\n {\n type: 'string',\n },\n {\n type: 'array',\n items: {\n type: 'string',\n },\n },\n ],\n },\n OrderField: {\n description:\n 'One or more \"field,direction\" pairs, given as a single string or an array of strings.',\n oneOf: [\n {\n type: 'string',\n },\n {\n type: 'array',\n items: {\n type: 'string',\n },\n },\n ],\n },\n NotificationRecipients: {\n oneOf: [\n {\n type: 'object',\n required: ['type', 'entityRef'],\n properties: {\n type: {\n type: 'string',\n enum: ['entity'],\n },\n entityRef: {\n $ref: '#/components/schemas/EntityRef',\n },\n excludeEntityRef: {\n $ref: '#/components/schemas/EntityRef',\n },\n },\n },\n {\n type: 'object',\n required: ['type'],\n properties: {\n type: {\n type: 'string',\n enum: ['broadcast'],\n },\n },\n },\n ],\n },\n NotificationSendOptions: {\n type: 'object',\n required: ['recipients', 'payload'],\n properties: {\n recipients: {\n $ref: '#/components/schemas/NotificationRecipients',\n },\n payload: {\n $ref: '#/components/schemas/NotificationPayload',\n },\n },\n },\n UpdateNotificationsRequest: {\n type: 'object',\n required: ['ids'],\n properties: {\n ids: {\n type: 'array',\n items: {\n type: 'string',\n },\n },\n read: {\n type: 'boolean',\n },\n saved: {\n type: 'boolean',\n },\n },\n },\n ListNotificationsResponse: {\n type: 'object',\n required: ['totalCount', 'notifications'],\n properties: {\n totalCount: {\n type: 'integer',\n },\n notifications: {\n type: 'array',\n items: {\n $ref: '#/components/schemas/Notification',\n },\n },\n },\n },\n GetTopicsResponse: {\n type: 'object',\n required: ['topics'],\n properties: {\n topics: {\n type: 'array',\n items: {\n type: 'string',\n },\n },\n },\n },\n Error: {\n type: 'object',\n properties: {\n error: {\n type: 'object',\n properties: {\n name: {\n type: 'string',\n },\n message: {\n type: 'string',\n },\n },\n required: ['name', 'message'],\n },\n request: {\n type: 'object',\n properties: {\n method: {\n type: 'string',\n },\n url: {\n type: 'string',\n },\n },\n required: ['method', 'url'],\n },\n response: {\n type: 'object',\n properties: {\n statusCode: {\n type: 'number',\n },\n },\n required: ['statusCode'],\n },\n },\n required: ['error', 'request', 'response'],\n },\n },\n securitySchemes: {\n JWT: {\n type: 'http',\n scheme: 'bearer',\n bearerFormat: 'JWT',\n },\n },\n },\n paths: {\n '/': {\n get: {\n operationId: 'ListNotificationsLegacy',\n deprecated: true,\n description: 'Deprecated alias for `GET /notifications`.',\n parameters: [\n {\n $ref: '#/components/parameters/offset',\n },\n {\n $ref: '#/components/parameters/limit',\n },\n {\n $ref: '#/components/parameters/orderField',\n },\n {\n $ref: '#/components/parameters/topic',\n },\n {\n $ref: '#/components/parameters/search',\n },\n {\n $ref: '#/components/parameters/read',\n },\n {\n $ref: '#/components/parameters/saved',\n },\n {\n $ref: '#/components/parameters/createdAfter',\n },\n {\n $ref: '#/components/parameters/minimumSeverity',\n },\n ],\n responses: {\n '200': {\n description: 'A page of notifications for the current user.',\n content: {\n 'application/json': {\n schema: {\n $ref: '#/components/schemas/ListNotificationsResponse',\n },\n },\n },\n },\n default: {\n $ref: '#/components/responses/ErrorResponse',\n },\n },\n security: [\n {},\n {\n JWT: [],\n },\n ],\n },\n post: {\n operationId: 'CreateNotificationsLegacy',\n deprecated: true,\n description: 'Deprecated alias for `POST /notifications`.',\n requestBody: {\n required: true,\n content: {\n 'application/json': {\n schema: {\n $ref: '#/components/schemas/NotificationSendOptions',\n },\n },\n },\n },\n responses: {\n '200': {\n description: 'The notifications that were created.',\n content: {\n 'application/json': {\n schema: {\n type: 'array',\n items: {\n $ref: '#/components/schemas/Notification',\n },\n },\n },\n },\n },\n default: {\n $ref: '#/components/responses/ErrorResponse',\n },\n },\n security: [\n {},\n {\n JWT: [],\n },\n ],\n },\n },\n '/notifications': {\n get: {\n operationId: 'ListNotifications',\n description: 'List notifications for the current user.',\n parameters: [\n {\n $ref: '#/components/parameters/offset',\n },\n {\n $ref: '#/components/parameters/limit',\n },\n {\n $ref: '#/components/parameters/orderField',\n },\n {\n $ref: '#/components/parameters/topic',\n },\n {\n $ref: '#/components/parameters/search',\n },\n {\n $ref: '#/components/parameters/read',\n },\n {\n $ref: '#/components/parameters/saved',\n },\n {\n $ref: '#/components/parameters/createdAfter',\n },\n {\n $ref: '#/components/parameters/minimumSeverity',\n },\n ],\n responses: {\n '200': {\n description: 'A page of notifications for the current user.',\n content: {\n 'application/json': {\n schema: {\n $ref: '#/components/schemas/ListNotificationsResponse',\n },\n },\n },\n },\n default: {\n $ref: '#/components/responses/ErrorResponse',\n },\n },\n security: [\n {},\n {\n JWT: [],\n },\n ],\n },\n post: {\n operationId: 'CreateNotifications',\n description:\n 'Send a notification to one or more recipients (service credentials required).',\n requestBody: {\n required: true,\n content: {\n 'application/json': {\n schema: {\n $ref: '#/components/schemas/NotificationSendOptions',\n },\n },\n },\n },\n responses: {\n '200': {\n description: 'The notifications that were created.',\n content: {\n 'application/json': {\n schema: {\n type: 'array',\n items: {\n $ref: '#/components/schemas/Notification',\n },\n },\n },\n },\n },\n default: {\n $ref: '#/components/responses/ErrorResponse',\n },\n },\n security: [\n {},\n {\n JWT: [],\n },\n ],\n },\n },\n '/update': {\n post: {\n operationId: 'UpdateNotificationsLegacy',\n deprecated: true,\n description: 'Deprecated alias for `POST /notifications/update`.',\n requestBody: {\n required: true,\n content: {\n 'application/json': {\n schema: {\n $ref: '#/components/schemas/UpdateNotificationsRequest',\n },\n },\n },\n },\n responses: {\n '200': {\n description: 'The notifications that were updated.',\n content: {\n 'application/json': {\n schema: {\n type: 'array',\n items: {\n $ref: '#/components/schemas/Notification',\n },\n },\n },\n },\n },\n default: {\n $ref: '#/components/responses/ErrorResponse',\n },\n },\n security: [\n {},\n {\n JWT: [],\n },\n ],\n },\n },\n '/notifications/update': {\n post: {\n operationId: 'UpdateNotifications',\n description: 'Mark notifications as read/unread or saved/unsaved.',\n requestBody: {\n required: true,\n content: {\n 'application/json': {\n schema: {\n $ref: '#/components/schemas/UpdateNotificationsRequest',\n },\n },\n },\n },\n responses: {\n '200': {\n description: 'The notifications that were updated.',\n content: {\n 'application/json': {\n schema: {\n type: 'array',\n items: {\n $ref: '#/components/schemas/Notification',\n },\n },\n },\n },\n },\n default: {\n $ref: '#/components/responses/ErrorResponse',\n },\n },\n security: [\n {},\n {\n JWT: [],\n },\n ],\n },\n },\n '/status': {\n get: {\n operationId: 'GetStatus',\n description: 'Get the unread/read counts for the current user.',\n responses: {\n '200': {\n description: \"The current user's notification status.\",\n content: {\n 'application/json': {\n schema: {\n $ref: '#/components/schemas/NotificationStatus',\n },\n },\n },\n },\n default: {\n $ref: '#/components/responses/ErrorResponse',\n },\n },\n security: [\n {},\n {\n JWT: [],\n },\n ],\n },\n },\n '/settings': {\n get: {\n operationId: 'GetSettings',\n description:\n \"Get the current user's notification settings, merged with defaults.\",\n responses: {\n '200': {\n description: 'Effective notification settings for the user.',\n content: {\n 'application/json': {\n schema: {\n $ref: '#/components/schemas/NotificationSettings',\n },\n },\n },\n },\n default: {\n $ref: '#/components/responses/ErrorResponse',\n },\n },\n security: [\n {},\n {\n JWT: [],\n },\n ],\n },\n post: {\n operationId: 'UpdateSettings',\n description: \"Update the current user's notification settings.\",\n requestBody: {\n required: true,\n content: {\n 'application/json': {\n schema: {\n $ref: '#/components/schemas/NotificationSettings',\n },\n },\n },\n },\n responses: {\n '200': {\n description: 'Effective notification settings for the user.',\n content: {\n 'application/json': {\n schema: {\n $ref: '#/components/schemas/NotificationSettings',\n },\n },\n },\n },\n default: {\n $ref: '#/components/responses/ErrorResponse',\n },\n },\n security: [\n {},\n {\n JWT: [],\n },\n ],\n },\n },\n '/topics': {\n get: {\n operationId: 'GetTopics',\n description:\n 'List notification topics that the user has received notifications on.',\n parameters: [\n {\n $ref: '#/components/parameters/search',\n },\n {\n $ref: '#/components/parameters/read',\n },\n {\n $ref: '#/components/parameters/saved',\n },\n {\n $ref: '#/components/parameters/createdAfter',\n },\n {\n $ref: '#/components/parameters/minimumSeverity',\n },\n ],\n responses: {\n '200': {\n description: 'The list of topics.',\n content: {\n 'application/json': {\n schema: {\n $ref: '#/components/schemas/GetTopicsResponse',\n },\n },\n },\n },\n default: {\n $ref: '#/components/responses/ErrorResponse',\n },\n },\n security: [\n {},\n {\n JWT: [],\n },\n ],\n },\n },\n '/{id}': {\n get: {\n operationId: 'GetNotificationLegacy',\n deprecated: true,\n description: 'Deprecated alias for `GET /notifications/{id}`.',\n parameters: [\n {\n $ref: '#/components/parameters/notificationId',\n },\n ],\n responses: {\n '200': {\n description: 'The requested notification.',\n content: {\n 'application/json': {\n schema: {\n $ref: '#/components/schemas/Notification',\n },\n },\n },\n },\n default: {\n $ref: '#/components/responses/ErrorResponse',\n },\n },\n security: [\n {},\n {\n JWT: [],\n },\n ],\n },\n },\n '/notifications/{id}': {\n get: {\n operationId: 'GetNotification',\n description: 'Get a single notification by id for the current user.',\n parameters: [\n {\n $ref: '#/components/parameters/notificationId',\n },\n ],\n responses: {\n '200': {\n description: 'The requested notification.',\n content: {\n 'application/json': {\n schema: {\n $ref: '#/components/schemas/Notification',\n },\n },\n },\n },\n default: {\n $ref: '#/components/responses/ErrorResponse',\n },\n },\n security: [\n {},\n {\n JWT: [],\n },\n ],\n },\n },\n },\n} as const;\nexport const createOpenApiRouter = async (\n options?: Parameters<\n typeof createValidatedOpenApiRouterFromGeneratedEndpointMap\n >['1'],\n) =>\n createValidatedOpenApiRouterFromGeneratedEndpointMap<EndpointMap>(\n spec,\n options,\n );\n"],"names":["createValidatedOpenApiRouterFromGeneratedEndpointMap"],"mappings":";;;;AAsBO,MAAM,IAAA,GAAO;AAAA,EAClB,OAAA,EAAS,OAAA;AAAA,EACT,IAAA,EAAM;AAAA,IACJ,KAAA,EAAO,eAAA;AAAA,IACP,OAAA,EAAS,GAAA;AAAA,IACT,WAAA,EAAa,8DAAA;AAAA,IACb,OAAA,EAAS;AAAA,MACP,IAAA,EAAM,YAAA;AAAA,MACN,GAAA,EAAK;AAAA,KACP;AAAA,IACA,SAAS;AAAC,GACZ;AAAA,EACA,OAAA,EAAS;AAAA,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A,EAAM;AAAA;AACR;AACF;AACF,WACF;AAAA,UACA,OAAA,EAAS;AAAA,YACP,IAAA,EAAM;AAAA;AACR,SACF;AAAA,QACA,QAAA,EAAU;AAAA,UACR,EAAC;AAAA,UACD;AAAA,YACE,KAAK;AAAC;AACR;AACF;AACF,KACF;AAAA,IACA,qBAAA,EAAuB;AAAA,MACrB,GAAA,EAAK;AAAA,QACH,WAAA,EAAa,iBAAA;AAAA,QACb,WAAA,EAAa,uDAAA;AAAA,QACb,UAAA,EAAY;AAAA,UACV;AAAA,YACE,IAAA,EAAM;AAAA;AACR,SACF;AAAA,QACA,SAAA,EAAW;AAAA,UACT,KAAA,EAAO;AAAA,YACL,WAAA,EAAa,6BAAA;AAAA,YACb,OAAA,EAAS;AAAA,cACP,kBAAA,EAAoB;AAAA,gBAClB,MAAA,EAAQ;AAAA,kBACN,IAAA,EAAM;AAAA;AACR;AACF;AACF,WACF;AAAA,UACA,OAAA,EAAS;AAAA,YACP,IAAA,EAAM;AAAA;AACR,SACF;AAAA,QACA,QAAA,EAAU;AAAA,UACR,EAAC;AAAA,UACD;AAAA,YACE,KAAK;AAAC;AACR;AACF;AACF;AACF;AAEJ;AACO,MAAM,mBAAA,GAAsB,OACjC,OAAA,KAIAA,wEAAA;AAAA,EACE,IAAA;AAAA,EACA;AACF;;;;;"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var Router = require('express-promise-router');
|
|
3
|
+
var router = require('../schema/openapi/generated/router.cjs.js');
|
|
5
4
|
var DatabaseNotificationsStore = require('../database/DatabaseNotificationsStore.cjs.js');
|
|
6
5
|
var crypto = require('node:crypto');
|
|
7
6
|
var errors = require('@backstage/errors');
|
|
@@ -15,8 +14,6 @@ var DefaultNotificationRecipientResolver = require('./DefaultNotificationRecipie
|
|
|
15
14
|
|
|
16
15
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
17
16
|
|
|
18
|
-
var express__default = /*#__PURE__*/_interopDefaultCompat(express);
|
|
19
|
-
var Router__default = /*#__PURE__*/_interopDefaultCompat(Router);
|
|
20
17
|
var pThrottle__default = /*#__PURE__*/_interopDefaultCompat(pThrottle);
|
|
21
18
|
|
|
22
19
|
async function createRouter(options) {
|
|
@@ -280,7 +277,7 @@ async function createRouter(options) {
|
|
|
280
277
|
};
|
|
281
278
|
const appendCommonOptions = (req, opts) => {
|
|
282
279
|
if (req.query.search) {
|
|
283
|
-
opts.search = req.query.search
|
|
280
|
+
opts.search = req.query.search;
|
|
284
281
|
}
|
|
285
282
|
if (req.query.read === "true") {
|
|
286
283
|
opts.read = true;
|
|
@@ -293,76 +290,71 @@ async function createRouter(options) {
|
|
|
293
290
|
opts.saved = false;
|
|
294
291
|
}
|
|
295
292
|
if (req.query.createdAfter) {
|
|
296
|
-
const sinceEpoch = Date.parse(
|
|
293
|
+
const sinceEpoch = Date.parse(req.query.createdAfter);
|
|
297
294
|
if (isNaN(sinceEpoch)) {
|
|
298
295
|
throw new errors.InputError("Unexpected date format");
|
|
299
296
|
}
|
|
300
297
|
opts.createdAfter = new Date(sinceEpoch);
|
|
301
298
|
}
|
|
302
299
|
if (req.query.minimumSeverity) {
|
|
303
|
-
opts.minimumSeverity = DatabaseNotificationsStore.normalizeSeverity(
|
|
304
|
-
req.query.minimumSeverity.toString()
|
|
305
|
-
);
|
|
300
|
+
opts.minimumSeverity = DatabaseNotificationsStore.normalizeSeverity(req.query.minimumSeverity);
|
|
306
301
|
}
|
|
307
302
|
};
|
|
308
|
-
const router =
|
|
309
|
-
router.use(express__default.default.json());
|
|
303
|
+
const router$1 = await router.createOpenApiRouter();
|
|
310
304
|
const listNotificationsHandler = async (req, res) => {
|
|
311
305
|
const user = await getUser(req);
|
|
312
|
-
const opts = {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
if (req.query.offset) {
|
|
316
|
-
opts.offset = Number.parseInt(req.query.offset.toString(), 10);
|
|
306
|
+
const opts = { user };
|
|
307
|
+
if (req.query.offset !== void 0) {
|
|
308
|
+
opts.offset = req.query.offset;
|
|
317
309
|
}
|
|
318
|
-
if (req.query.limit) {
|
|
319
|
-
opts.limit =
|
|
310
|
+
if (req.query.limit !== void 0) {
|
|
311
|
+
opts.limit = req.query.limit;
|
|
320
312
|
}
|
|
321
|
-
if (req.query.orderField) {
|
|
322
|
-
opts.orderField = parseEntityOrderFieldParams.parseEntityOrderFieldParams(
|
|
313
|
+
if (req.query.orderField !== void 0) {
|
|
314
|
+
opts.orderField = parseEntityOrderFieldParams.parseEntityOrderFieldParams({
|
|
315
|
+
orderField: req.query.orderField
|
|
316
|
+
});
|
|
323
317
|
}
|
|
324
318
|
if (req.query.topic) {
|
|
325
|
-
opts.topic = req.query.topic
|
|
319
|
+
opts.topic = req.query.topic;
|
|
326
320
|
}
|
|
327
321
|
appendCommonOptions(req, opts);
|
|
328
322
|
const [notifications, totalCount] = await Promise.all([
|
|
329
323
|
store.getNotifications(opts),
|
|
330
324
|
store.getNotificationsCount(opts)
|
|
331
325
|
]);
|
|
332
|
-
res.json({
|
|
333
|
-
totalCount,
|
|
334
|
-
notifications
|
|
335
|
-
});
|
|
326
|
+
res.json({ totalCount, notifications });
|
|
336
327
|
};
|
|
337
|
-
router.get("/", listNotificationsHandler);
|
|
338
|
-
router.get("/notifications", listNotificationsHandler);
|
|
339
|
-
router.get("/status", async (req, res) => {
|
|
328
|
+
router$1.get("/", listNotificationsHandler);
|
|
329
|
+
router$1.get("/notifications", listNotificationsHandler);
|
|
330
|
+
router$1.get("/status", async (req, res) => {
|
|
340
331
|
const user = await getUser(req);
|
|
341
332
|
const status = await store.getStatus({ user });
|
|
342
333
|
res.json(status);
|
|
343
334
|
});
|
|
344
|
-
router.get(
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
const user = await getUser(req);
|
|
356
|
-
const channels = getNotificationChannels();
|
|
357
|
-
const settings = req.body;
|
|
358
|
-
if (settings.channels.some((c) => !channels.includes(c.id))) {
|
|
359
|
-
throw new errors.InputError("Invalid channel");
|
|
360
|
-
}
|
|
361
|
-
await store.saveNotificationSettings({ user, settings });
|
|
362
|
-
const response = await getNotificationSettings(user);
|
|
363
|
-
res.json(response);
|
|
335
|
+
router$1.get("/settings", async (req, res) => {
|
|
336
|
+
const user = await getUser(req);
|
|
337
|
+
const response = await getNotificationSettings(user);
|
|
338
|
+
res.json(response);
|
|
339
|
+
});
|
|
340
|
+
router$1.post("/settings", async (req, res) => {
|
|
341
|
+
const user = await getUser(req);
|
|
342
|
+
const channels = getNotificationChannels();
|
|
343
|
+
const settings = req.body;
|
|
344
|
+
if (settings.channels.some((c) => !channels.includes(c.id))) {
|
|
345
|
+
throw new errors.InputError("Invalid channel");
|
|
364
346
|
}
|
|
365
|
-
|
|
347
|
+
await store.saveNotificationSettings({ user, settings });
|
|
348
|
+
const response = await getNotificationSettings(user);
|
|
349
|
+
res.json(response);
|
|
350
|
+
});
|
|
351
|
+
router$1.get("/topics", async (req, res) => {
|
|
352
|
+
const user = await getUser(req);
|
|
353
|
+
const opts = { user };
|
|
354
|
+
appendCommonOptions(req, opts);
|
|
355
|
+
const topics = await store.getTopics(opts);
|
|
356
|
+
res.json(topics);
|
|
357
|
+
});
|
|
366
358
|
const getNotificationHandler = async (req, res) => {
|
|
367
359
|
const user = await getUser(req);
|
|
368
360
|
const opts = {
|
|
@@ -376,24 +368,11 @@ async function createRouter(options) {
|
|
|
376
368
|
}
|
|
377
369
|
res.json(notifications[0]);
|
|
378
370
|
};
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
const opts = {
|
|
382
|
-
user
|
|
383
|
-
};
|
|
384
|
-
appendCommonOptions(req, opts);
|
|
385
|
-
const topics = await store.getTopics(opts);
|
|
386
|
-
res.json(topics);
|
|
387
|
-
};
|
|
388
|
-
router.get("/topics", listTopicsHandler);
|
|
389
|
-
router.get("/:id", getNotificationHandler);
|
|
390
|
-
router.get("/notifications/:id", getNotificationHandler);
|
|
371
|
+
router$1.get("/:id", getNotificationHandler);
|
|
372
|
+
router$1.get("/notifications/:id", getNotificationHandler);
|
|
391
373
|
const updateNotificationsHandler = async (req, res) => {
|
|
392
374
|
const user = await getUser(req);
|
|
393
375
|
const { ids, read, saved } = req.body;
|
|
394
|
-
if (!ids || !Array.isArray(ids)) {
|
|
395
|
-
throw new errors.InputError();
|
|
396
|
-
}
|
|
397
376
|
if (read === true) {
|
|
398
377
|
await store.markRead({ user, ids });
|
|
399
378
|
if (signals) {
|
|
@@ -421,8 +400,8 @@ async function createRouter(options) {
|
|
|
421
400
|
const notifications = await store.getNotifications({ ids, user });
|
|
422
401
|
res.json(notifications);
|
|
423
402
|
};
|
|
424
|
-
router.post("/update", updateNotificationsHandler);
|
|
425
|
-
router.post("/notifications/update", updateNotificationsHandler);
|
|
403
|
+
router$1.post("/update", updateNotificationsHandler);
|
|
404
|
+
router$1.post("/notifications/update", updateNotificationsHandler);
|
|
426
405
|
const sendBroadcastNotification = async (baseNotification, opts, origin) => {
|
|
427
406
|
const { scope } = opts.payload;
|
|
428
407
|
const broadcastNotification = {
|
|
@@ -531,7 +510,7 @@ async function createRouter(options) {
|
|
|
531
510
|
const sent = await Promise.all(uniqueUsers.map((user) => throttled(user)));
|
|
532
511
|
return sent.filter((n) => n !== void 0);
|
|
533
512
|
};
|
|
534
|
-
const
|
|
513
|
+
const createNotificationsHandler = async (req, res) => {
|
|
535
514
|
const credentials = await httpAuth.credentials(req, {
|
|
536
515
|
allow: ["service"]
|
|
537
516
|
});
|
|
@@ -597,9 +576,9 @@ async function createRouter(options) {
|
|
|
597
576
|
}
|
|
598
577
|
res.json(notifications);
|
|
599
578
|
};
|
|
600
|
-
router.post("/",
|
|
601
|
-
router.post("/notifications",
|
|
602
|
-
return router;
|
|
579
|
+
router$1.post("/", createNotificationsHandler);
|
|
580
|
+
router$1.post("/notifications", createNotificationsHandler);
|
|
581
|
+
return router$1;
|
|
603
582
|
}
|
|
604
583
|
|
|
605
584
|
exports.createRouter = createRouter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.cjs.js","sources":["../../src/service/router.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport express, { Request, Response } from 'express';\nimport Router from 'express-promise-router';\nimport {\n normalizeSeverity,\n NotificationGetOptions,\n NotificationsStore,\n TopicGetOptions,\n} from '../database';\nimport { randomUUID as uuid } from 'node:crypto';\nimport { CatalogService } from '@backstage/plugin-catalog-node';\nimport {\n NotificationProcessor,\n NotificationRecipientResolver,\n NotificationSendOptions,\n} from '@backstage/plugin-notifications-node';\nimport { InputError, NotFoundError } from '@backstage/errors';\nimport {\n AuthService,\n HttpAuthService,\n LoggerService,\n UserInfoService,\n} from '@backstage/backend-plugin-api';\nimport { SignalsService } from '@backstage/plugin-signals-node';\nimport {\n ChannelSetting,\n isNotificationsEnabledFor,\n NewNotificationSignal,\n Notification,\n NotificationReadSignal,\n NotificationSettings,\n notificationSeverities,\n NotificationStatus,\n OriginSetting,\n} from '@backstage/plugin-notifications-common';\nimport { parseEntityOrderFieldParams } from './parseEntityOrderFieldParams';\nimport { Config, readDurationFromConfig } from '@backstage/config';\nimport { durationToMilliseconds } from '@backstage/types';\nimport pThrottle from 'p-throttle';\nimport { parseEntityRef } from '@backstage/catalog-model';\nimport { DefaultNotificationRecipientResolver } from './DefaultNotificationRecipientResolver.ts';\n\n/** @internal */\nexport interface RouterOptions {\n logger: LoggerService;\n config: Config;\n store: NotificationsStore;\n auth: AuthService;\n httpAuth: HttpAuthService;\n userInfo: UserInfoService;\n signals?: SignalsService;\n catalog: CatalogService;\n processors?: NotificationProcessor[];\n recipientResolver?: NotificationRecipientResolver;\n}\n\n/** @internal */\nexport async function createRouter(\n options: RouterOptions,\n): Promise<express.Router> {\n const {\n config,\n logger,\n store,\n auth,\n httpAuth,\n userInfo,\n catalog,\n processors = [],\n signals,\n recipientResolver,\n } = options;\n\n const WEB_NOTIFICATION_CHANNEL = 'Web';\n const frontendBaseUrl = config.getString('app.baseUrl');\n const concurrencyLimit =\n config.getOptionalNumber('notifications.concurrencyLimit') ?? 10;\n const throttleInterval = config.has('notifications.throttleInterval')\n ? durationToMilliseconds(\n readDurationFromConfig(config, {\n key: 'notifications.throttleInterval',\n }),\n )\n : 50;\n const throttle = pThrottle({\n limit: concurrencyLimit,\n interval: throttleInterval,\n });\n const defaultNotificationSettings: NotificationSettings | undefined =\n config.getOptional<NotificationSettings>('notifications.defaultSettings');\n\n const usedRecipientResolver =\n recipientResolver ??\n new DefaultNotificationRecipientResolver(auth, catalog);\n\n const getUser = async (req: Request<unknown>) => {\n const credentials = await httpAuth.credentials(req, { allow: ['user'] });\n const info = await userInfo.getUserInfo(credentials);\n return info.userEntityRef;\n };\n\n const getNotificationChannels = () => {\n return [WEB_NOTIFICATION_CHANNEL, ...processors.map(p => p.getName())];\n };\n\n const getTopicSettings = (\n topic: any,\n existingOrigin: OriginSetting | undefined,\n defaultOriginSettings: OriginSetting | undefined,\n channelDefaultEnabled: boolean,\n ) => {\n const existingTopic = existingOrigin?.topics?.find(\n t => t.id.toLowerCase() === topic.topic.toLowerCase(),\n );\n const defaultTopicSettings = defaultOriginSettings?.topics?.find(\n t => t.id.toLowerCase() === topic.topic.toLowerCase(),\n );\n\n // If topic has explicit setting, use it\n // Otherwise check default topic settings from config\n // Otherwise use channel default (not origin enabled state)\n return {\n id: topic.topic,\n enabled: existingTopic\n ? existingTopic.enabled\n : defaultTopicSettings?.enabled ?? channelDefaultEnabled,\n };\n };\n\n const getOriginSettings = (\n originId: string,\n existingChannel: ChannelSetting | undefined,\n defaultChannelSettings: ChannelSetting | undefined,\n topics: { origin: string; topic: string }[],\n channelDefaultEnabled: boolean,\n channelHasExplicitEnabled: boolean,\n ) => {\n const existingOrigin = existingChannel?.origins?.find(\n o => o.id.toLowerCase() === originId.toLowerCase(),\n );\n\n const defaultOriginSettings = defaultChannelSettings?.origins?.find(\n c => c.id.toLowerCase() === originId.toLowerCase(),\n );\n\n const defaultEnabled = existingOrigin\n ? existingOrigin.enabled\n : defaultOriginSettings?.enabled ?? channelDefaultEnabled;\n\n return {\n id: originId,\n enabled: defaultEnabled,\n topics: topics\n .filter(t => t.origin === originId)\n .map(t =>\n getTopicSettings(\n t,\n existingOrigin,\n defaultOriginSettings,\n channelHasExplicitEnabled ? channelDefaultEnabled : defaultEnabled,\n ),\n ),\n };\n };\n\n const getChannelSettings = (\n channelId: string,\n settings: NotificationSettings,\n origins: string[],\n topics: { origin: string; topic: string }[],\n ) => {\n const existingChannel = settings.channels.find(\n c => c.id.toLowerCase() === channelId.toLowerCase(),\n );\n const defaultChannelSettings = defaultNotificationSettings?.channels?.find(\n c => c.id.toLowerCase() === channelId.toLowerCase(),\n );\n\n // Determine channel enabled state\n const channelEnabled =\n existingChannel?.enabled ?? defaultChannelSettings?.enabled;\n\n // Use channel's enabled flag as the default for origins if not explicitly set\n const defaultEnabledForOrigins = channelEnabled ?? true;\n\n // Check if channel has explicit enabled flag (either from user settings or config)\n const channelHasExplicitEnabled =\n existingChannel?.enabled !== undefined ||\n defaultChannelSettings?.enabled !== undefined;\n\n return {\n id: channelId,\n enabled: channelEnabled,\n origins: origins.map(originId =>\n getOriginSettings(\n originId,\n existingChannel,\n defaultChannelSettings,\n topics,\n defaultEnabledForOrigins,\n channelHasExplicitEnabled,\n ),\n ),\n };\n };\n\n const getNotificationSettings = async (\n user: string,\n ): Promise<NotificationSettings> => {\n const { origins } = await store.getUserNotificationOrigins({ user });\n const { topics } = await store.getUserNotificationTopics({ user });\n const settings = await store.getNotificationSettings({ user });\n const channels = getNotificationChannels();\n\n // Merge existing channels/origins/topics with configured settings\n for (const channel of defaultNotificationSettings?.channels ?? []) {\n if (!channels.includes(channel.id)) {\n channels.push(channel.id);\n }\n\n for (const origin of channel.origins ?? []) {\n if (!origins.includes(origin.id)) {\n origins.push(origin.id);\n }\n\n for (const topic of origin.topics ?? []) {\n if (\n !topics.some(t => t.origin === origin.id && t.topic === topic.id)\n ) {\n topics.push({ origin: origin.id, topic: topic.id });\n }\n }\n }\n }\n\n return {\n channels: channels.map(channelId =>\n getChannelSettings(channelId, settings, origins, topics),\n ),\n };\n };\n\n const isNotificationsEnabled = async (opts: {\n user: string;\n channel: string;\n origin: string;\n topic: string | null;\n }) => {\n // Get user's explicit settings from database\n const userSettings = await store.getNotificationSettings({\n user: opts.user,\n });\n\n // Build a minimal settings object with user settings and config defaults\n const settings: NotificationSettings = {\n channels: [\n {\n id: opts.channel,\n enabled: defaultNotificationSettings?.channels?.find(\n c => c.id.toLowerCase() === opts.channel.toLowerCase(),\n )?.enabled,\n origins: [],\n },\n ],\n };\n\n // Add user's channel if it exists\n const userChannel = userSettings.channels.find(\n c => c.id.toLowerCase() === opts.channel.toLowerCase(),\n );\n if (userChannel) {\n settings.channels[0] = {\n ...settings.channels[0],\n enabled: userChannel.enabled ?? settings.channels[0].enabled,\n origins: userChannel.origins ?? [],\n };\n }\n\n // Add config default origins if not in user settings\n // Only add origins if the channel is enabled (not explicitly disabled)\n const defaultChannelSettings = defaultNotificationSettings?.channels?.find(\n c => c.id.toLowerCase() === opts.channel.toLowerCase(),\n );\n if (\n defaultChannelSettings?.origins &&\n settings.channels[0].enabled !== false\n ) {\n for (const defaultOrigin of defaultChannelSettings.origins) {\n if (\n !settings.channels[0].origins.some(\n o => o.id.toLowerCase() === defaultOrigin.id.toLowerCase(),\n )\n ) {\n settings.channels[0].origins.push(defaultOrigin);\n }\n }\n }\n\n return isNotificationsEnabledFor(\n settings,\n opts.channel,\n opts.origin,\n opts.topic,\n );\n };\n\n const filterProcessors = async (\n notification:\n | Notification\n | ({ origin: string; user: null } & NotificationSendOptions),\n ) => {\n const result: NotificationProcessor[] = [];\n const { payload, user, origin } = notification;\n\n for (const processor of processors) {\n if (user) {\n const enabled = await isNotificationsEnabled({\n user,\n origin,\n channel: processor.getName(),\n topic: payload.topic ?? null,\n });\n if (!enabled) {\n continue;\n }\n }\n\n if (processor.getNotificationFilters) {\n const filters = processor.getNotificationFilters();\n if (filters.minSeverity) {\n if (\n notificationSeverities.indexOf(payload.severity ?? 'normal') >\n notificationSeverities.indexOf(filters.minSeverity)\n ) {\n continue;\n }\n }\n\n if (filters.maxSeverity) {\n if (\n notificationSeverities.indexOf(payload.severity ?? 'normal') <\n notificationSeverities.indexOf(filters.maxSeverity)\n ) {\n continue;\n }\n }\n\n if (filters.excludedTopics && payload.topic) {\n if (filters.excludedTopics.includes(payload.topic)) {\n continue;\n }\n }\n\n if (filters.includedTopics) {\n if (\n !payload.topic ||\n !filters.includedTopics.includes(payload.topic)\n ) {\n continue;\n }\n }\n }\n result.push(processor);\n }\n\n return result;\n };\n\n const processOptions = async (\n opts: NotificationSendOptions,\n origin: string,\n ): Promise<NotificationSendOptions> => {\n const filtered = await filterProcessors({ ...opts, origin, user: null });\n let ret = opts;\n for (const processor of filtered) {\n try {\n ret = processor.processOptions\n ? await processor.processOptions(ret)\n : ret;\n } catch (e) {\n logger.error(\n `Error while processing notification options with ${processor.getName()}: ${e}`,\n );\n }\n }\n return ret;\n };\n\n const preProcessNotification = async (\n notification: Notification,\n opts: NotificationSendOptions,\n ) => {\n const filtered = await filterProcessors(notification);\n let ret = notification;\n for (const processor of filtered) {\n try {\n ret = processor.preProcess\n ? await processor.preProcess(ret, opts)\n : ret;\n } catch (e) {\n logger.error(\n `Error while pre processing notification with ${processor.getName()}: ${e}`,\n );\n }\n }\n return ret;\n };\n\n const postProcessNotification = async (\n notification: Notification,\n opts: NotificationSendOptions,\n ) => {\n const filtered = await filterProcessors(notification);\n for (const processor of filtered) {\n if (!processor.postProcess) {\n continue;\n }\n\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 const validateLink = (link: string) => {\n const stripLeadingSlash = (s: string) => s.replace(/^\\//, '');\n const ensureTrailingSlash = (s: string) => s.replace(/\\/?$/, '/');\n const url = new URL(\n stripLeadingSlash(link),\n ensureTrailingSlash(frontendBaseUrl),\n );\n if (url.protocol !== 'https:' && url.protocol !== 'http:') {\n throw new Error('Only HTTP/HTTPS links are allowed');\n }\n };\n\n const appendCommonOptions = (\n req: Request,\n opts: NotificationGetOptions | TopicGetOptions,\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.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\n // TODO: Move to use OpenAPI router instead\n const router = Router();\n router.use(express.json());\n\n const listNotificationsHandler = async (req: Request, res: Response) => {\n const user = await getUser(req);\n const opts: NotificationGetOptions = {\n user: user,\n };\n if (req.query.offset) {\n opts.offset = Number.parseInt(req.query.offset.toString(), 10);\n }\n if (req.query.limit) {\n opts.limit = Number.parseInt(req.query.limit.toString(), 10);\n }\n if (req.query.orderField) {\n opts.orderField = parseEntityOrderFieldParams(req.query);\n }\n\n if (req.query.topic) {\n opts.topic = req.query.topic.toString();\n }\n\n appendCommonOptions(req, opts);\n\n const [notifications, totalCount] = await Promise.all([\n store.getNotifications(opts),\n store.getNotificationsCount(opts),\n ]);\n res.json({\n totalCount,\n notifications,\n });\n };\n\n router.get('/', listNotificationsHandler); // Deprecated endpoint\n router.get('/notifications', listNotificationsHandler);\n\n router.get('/status', async (req: Request<any, NotificationStatus>, res) => {\n const user = await getUser(req);\n const status = await store.getStatus({ user });\n res.json(status);\n });\n\n router.get(\n '/settings',\n async (req: Request<any, NotificationSettings>, res) => {\n const user = await getUser(req);\n const response = await getNotificationSettings(user);\n res.json(response);\n },\n );\n\n router.post(\n '/settings',\n async (\n req: Request<any, NotificationSettings, NotificationSettings>,\n res,\n ) => {\n const user = await getUser(req);\n const channels = getNotificationChannels();\n const settings: NotificationSettings = req.body;\n if (settings.channels.some(c => !channels.includes(c.id))) {\n throw new InputError('Invalid channel');\n }\n await store.saveNotificationSettings({ user, settings });\n const response = await getNotificationSettings(user);\n res.json(response);\n },\n );\n\n const getNotificationHandler = async (req: Request, res: Response) => {\n const user = await getUser(req);\n const opts: NotificationGetOptions = {\n user: user,\n limit: 1,\n ids: [req.params.id],\n };\n const notifications = await store.getNotifications(opts);\n if (notifications.length !== 1) {\n throw new NotFoundError('Not found');\n }\n res.json(notifications[0]);\n };\n\n // Get topics\n const listTopicsHandler = async (req: Request, res: Response) => {\n const user = await getUser(req);\n const opts: TopicGetOptions = {\n user: user,\n };\n\n appendCommonOptions(req, opts);\n\n const topics = await store.getTopics(opts);\n res.json(topics);\n };\n\n router.get('/topics', listTopicsHandler);\n\n // Make sure this is the last \"GET\" handler\n router.get('/:id', getNotificationHandler); // Deprecated endpoint\n router.get('/notifications/:id', getNotificationHandler);\n\n const updateNotificationsHandler = async (req: Request, res: Response) => {\n const user = await getUser(req);\n const { ids, read, saved } = req.body;\n if (!ids || !Array.isArray(ids)) {\n throw new InputError();\n }\n\n if (read === true) {\n await store.markRead({ user, ids });\n\n if (signals) {\n await signals.publish<NotificationReadSignal>({\n recipients: { type: 'user', entityRef: [user] },\n message: { action: 'notification_read', notification_ids: ids },\n channel: 'notifications',\n });\n }\n } else if (read === false) {\n await store.markUnread({ user: user, ids });\n\n if (signals) {\n await signals.publish<NotificationReadSignal>({\n recipients: { type: 'user', entityRef: [user] },\n message: { action: 'notification_unread', notification_ids: ids },\n channel: 'notifications',\n });\n }\n }\n\n if (saved === true) {\n await store.markSaved({ user: user, ids });\n } else if (saved === false) {\n await store.markUnsaved({ user: user, ids });\n }\n\n const notifications = await store.getNotifications({ ids, user: user });\n res.json(notifications);\n };\n\n router.post('/update', updateNotificationsHandler); // Deprecated endpoint\n router.post('/notifications/update', updateNotificationsHandler);\n\n const sendBroadcastNotification = async (\n baseNotification: Omit<Notification, 'user' | 'id'>,\n opts: NotificationSendOptions,\n origin: string,\n ) => {\n const { scope } = opts.payload;\n const broadcastNotification = {\n ...baseNotification,\n user: null,\n id: uuid(),\n };\n const notification = await preProcessNotification(\n broadcastNotification,\n opts,\n );\n let existingNotification;\n if (scope) {\n existingNotification = await store.getExistingScopeBroadcast({\n scope,\n origin,\n });\n }\n\n let ret = notification;\n if (existingNotification) {\n const restored = await store.restoreExistingNotification({\n id: existingNotification.id,\n notification: { ...notification, user: '' },\n });\n ret = restored ?? notification;\n } else {\n await store.saveBroadcast(notification);\n }\n\n if (signals) {\n await signals.publish<NewNotificationSignal>({\n recipients: { type: 'broadcast' },\n message: {\n action: 'new_notification',\n notification_id: ret.id,\n },\n channel: 'notifications',\n });\n }\n postProcessNotification(ret, opts);\n return notification;\n };\n\n const sendUserNotification = async (\n baseNotification: Omit<Notification, 'user' | 'id'>,\n user: string,\n opts: NotificationSendOptions,\n origin: string,\n scope?: string,\n ): Promise<Notification | undefined> => {\n const userNotification = {\n ...baseNotification,\n id: uuid(),\n user,\n };\n const notification = await preProcessNotification(userNotification, opts);\n\n const enabled = await isNotificationsEnabled({\n user,\n channel: WEB_NOTIFICATION_CHANNEL,\n origin: userNotification.origin,\n topic: userNotification.payload.topic ?? null,\n });\n\n let ret = notification;\n\n if (!enabled) {\n postProcessNotification(ret, opts);\n return undefined;\n }\n\n let existingNotification;\n if (scope) {\n existingNotification = await store.getExistingScopeNotification({\n user,\n scope,\n origin,\n });\n }\n\n if (existingNotification) {\n const restored = await store.restoreExistingNotification({\n id: existingNotification.id,\n notification,\n });\n ret = restored ?? notification;\n } else {\n await store.saveNotification(notification);\n }\n\n 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 return ret;\n };\n\n const filterNonUserEntityRefs = (refs: string[]): string[] => {\n return refs.filter(ref => {\n try {\n const parsed = parseEntityRef(ref);\n return parsed.kind.toLowerCase() === 'user';\n } catch {\n return false;\n }\n });\n };\n\n const sendUserNotifications = async (\n baseNotification: Omit<Notification, 'user' | 'id'>,\n users: string[],\n opts: NotificationSendOptions,\n origin: string,\n ): Promise<Notification[]> => {\n const { scope } = opts.payload;\n const uniqueUsers = [...new Set(filterNonUserEntityRefs(users))];\n const throttled = throttle((user: string) =>\n sendUserNotification(baseNotification, user, opts, origin, scope),\n );\n const sent = await Promise.all(uniqueUsers.map(user => throttled(user)));\n return sent.filter(n => n !== undefined);\n };\n\n const createNotificationHandler = async (\n req: Request<any, Notification[], NotificationSendOptions>,\n res: Response,\n ) => {\n const credentials = await httpAuth.credentials(req, {\n allow: ['service'],\n });\n\n const origin = credentials.principal.subject;\n const opts = await processOptions(req.body, origin);\n const { recipients, payload } = opts;\n const { title, link } = payload;\n const notifications: Notification[] = [];\n\n if (!recipients || !title) {\n const missing = [\n !title ? 'title' : null,\n !recipients ? 'recipients' : null,\n ].filter(Boolean);\n const err = `Invalid notification request received: missing ${missing.join(\n ', ',\n )}`;\n throw new InputError(err);\n }\n\n if (link) {\n try {\n validateLink(link);\n } catch (e) {\n throw new InputError('Invalid link provided', e);\n }\n }\n\n const baseNotification = {\n payload: {\n ...payload,\n severity: payload.severity ?? 'normal',\n },\n origin,\n created: new Date(),\n };\n\n if (recipients.type === 'broadcast') {\n const broadcast = await sendBroadcastNotification(\n baseNotification,\n opts,\n origin,\n );\n notifications.push(broadcast);\n } else if (recipients.type === 'entity') {\n const entityRefs = [recipients.entityRef].flat();\n const excludedEntityRefs = recipients.excludeEntityRef\n ? [recipients.excludeEntityRef].flat()\n : undefined;\n try {\n const { userEntityRefs } =\n await usedRecipientResolver.resolveNotificationRecipients({\n entityRefs,\n excludedEntityRefs,\n });\n const userNotifications = await sendUserNotifications(\n baseNotification,\n userEntityRefs,\n opts,\n origin,\n );\n notifications.push(...userNotifications);\n } catch (e) {\n throw new InputError('Failed to send user notifications', e);\n }\n } else {\n throw new InputError(\n `Invalid recipients type, please use either 'broadcast' or 'entity'`,\n );\n }\n\n res.json(notifications);\n };\n\n // Add new notification\n router.post('/', createNotificationHandler);\n router.post('/notifications', createNotificationHandler);\n\n return router;\n}\n"],"names":["config","durationToMilliseconds","readDurationFromConfig","pThrottle","DefaultNotificationRecipientResolver","isNotificationsEnabledFor","notificationSeverities","InputError","normalizeSeverity","Router","express","parseEntityOrderFieldParams","NotFoundError","uuid","parseEntityRef"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAwEA,eAAsB,aACpB,OAAA,EACyB;AACzB,EAAA,MAAM;AAAA,YACJA,QAAA;AAAA,IACA,MAAA;AAAA,IACA,KAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,IACA,OAAA;AAAA,IACA,aAAa,EAAC;AAAA,IACd,OAAA;AAAA,IACA;AAAA,GACF,GAAI,OAAA;AAEJ,EAAA,MAAM,wBAAA,GAA2B,KAAA;AACjC,EAAA,MAAM,eAAA,GAAkBA,QAAA,CAAO,SAAA,CAAU,aAAa,CAAA;AACtD,EAAA,MAAM,gBAAA,GACJA,QAAA,CAAO,iBAAA,CAAkB,gCAAgC,CAAA,IAAK,EAAA;AAChE,E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../../src/service/router.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport express, { Request } from 'express';\nimport { createOpenApiRouter, EndpointMap } from '../schema/openapi';\nimport { internal as openapi } from '@backstage/backend-openapi-utils';\nimport {\n normalizeSeverity,\n NotificationGetOptions,\n NotificationsStore,\n TopicGetOptions,\n} from '../database';\nimport { randomUUID as uuid } from 'node:crypto';\nimport { CatalogService } from '@backstage/plugin-catalog-node';\nimport {\n NotificationProcessor,\n NotificationRecipientResolver,\n NotificationSendOptions,\n} from '@backstage/plugin-notifications-node';\nimport { InputError, NotFoundError } from '@backstage/errors';\nimport {\n AuthService,\n HttpAuthService,\n LoggerService,\n UserInfoService,\n} from '@backstage/backend-plugin-api';\nimport { SignalsService } from '@backstage/plugin-signals-node';\nimport {\n ChannelSetting,\n isNotificationsEnabledFor,\n NewNotificationSignal,\n Notification,\n NotificationReadSignal,\n NotificationSettings,\n notificationSeverities,\n OriginSetting,\n} from '@backstage/plugin-notifications-common';\nimport { parseEntityOrderFieldParams } from './parseEntityOrderFieldParams';\nimport { Config, readDurationFromConfig } from '@backstage/config';\nimport { durationToMilliseconds } from '@backstage/types';\nimport pThrottle from 'p-throttle';\nimport { parseEntityRef } from '@backstage/catalog-model';\nimport { DefaultNotificationRecipientResolver } from './DefaultNotificationRecipientResolver.ts';\n\n/** @internal */\nexport interface RouterOptions {\n logger: LoggerService;\n config: Config;\n store: NotificationsStore;\n auth: AuthService;\n httpAuth: HttpAuthService;\n userInfo: UserInfoService;\n signals?: SignalsService;\n catalog: CatalogService;\n processors?: NotificationProcessor[];\n recipientResolver?: NotificationRecipientResolver;\n}\n\n/** @internal */\nexport async function createRouter(\n options: RouterOptions,\n): Promise<express.Router> {\n const {\n config,\n logger,\n store,\n auth,\n httpAuth,\n userInfo,\n catalog,\n processors = [],\n signals,\n recipientResolver,\n } = options;\n\n const WEB_NOTIFICATION_CHANNEL = 'Web';\n const frontendBaseUrl = config.getString('app.baseUrl');\n const concurrencyLimit =\n config.getOptionalNumber('notifications.concurrencyLimit') ?? 10;\n const throttleInterval = config.has('notifications.throttleInterval')\n ? durationToMilliseconds(\n readDurationFromConfig(config, {\n key: 'notifications.throttleInterval',\n }),\n )\n : 50;\n const throttle = pThrottle({\n limit: concurrencyLimit,\n interval: throttleInterval,\n });\n const defaultNotificationSettings: NotificationSettings | undefined =\n config.getOptional<NotificationSettings>('notifications.defaultSettings');\n\n const usedRecipientResolver =\n recipientResolver ??\n new DefaultNotificationRecipientResolver(auth, catalog);\n\n const getUser = async (req: Request<any, any, any, any, any>) => {\n const credentials = await httpAuth.credentials(req, { allow: ['user'] });\n const info = await userInfo.getUserInfo(credentials);\n return info.userEntityRef;\n };\n\n const getNotificationChannels = () => {\n return [WEB_NOTIFICATION_CHANNEL, ...processors.map(p => p.getName())];\n };\n\n const getTopicSettings = (\n topic: any,\n existingOrigin: OriginSetting | undefined,\n defaultOriginSettings: OriginSetting | undefined,\n channelDefaultEnabled: boolean,\n ) => {\n const existingTopic = existingOrigin?.topics?.find(\n t => t.id.toLowerCase() === topic.topic.toLowerCase(),\n );\n const defaultTopicSettings = defaultOriginSettings?.topics?.find(\n t => t.id.toLowerCase() === topic.topic.toLowerCase(),\n );\n\n // If topic has explicit setting, use it\n // Otherwise check default topic settings from config\n // Otherwise use channel default (not origin enabled state)\n return {\n id: topic.topic,\n enabled: existingTopic\n ? existingTopic.enabled\n : defaultTopicSettings?.enabled ?? channelDefaultEnabled,\n };\n };\n\n const getOriginSettings = (\n originId: string,\n existingChannel: ChannelSetting | undefined,\n defaultChannelSettings: ChannelSetting | undefined,\n topics: { origin: string; topic: string }[],\n channelDefaultEnabled: boolean,\n channelHasExplicitEnabled: boolean,\n ) => {\n const existingOrigin = existingChannel?.origins?.find(\n o => o.id.toLowerCase() === originId.toLowerCase(),\n );\n\n const defaultOriginSettings = defaultChannelSettings?.origins?.find(\n c => c.id.toLowerCase() === originId.toLowerCase(),\n );\n\n const defaultEnabled = existingOrigin\n ? existingOrigin.enabled\n : defaultOriginSettings?.enabled ?? channelDefaultEnabled;\n\n return {\n id: originId,\n enabled: defaultEnabled,\n topics: topics\n .filter(t => t.origin === originId)\n .map(t =>\n getTopicSettings(\n t,\n existingOrigin,\n defaultOriginSettings,\n channelHasExplicitEnabled ? channelDefaultEnabled : defaultEnabled,\n ),\n ),\n };\n };\n\n const getChannelSettings = (\n channelId: string,\n settings: NotificationSettings,\n origins: string[],\n topics: { origin: string; topic: string }[],\n ) => {\n const existingChannel = settings.channels.find(\n c => c.id.toLowerCase() === channelId.toLowerCase(),\n );\n const defaultChannelSettings = defaultNotificationSettings?.channels?.find(\n c => c.id.toLowerCase() === channelId.toLowerCase(),\n );\n\n // Determine channel enabled state\n const channelEnabled =\n existingChannel?.enabled ?? defaultChannelSettings?.enabled;\n\n // Use channel's enabled flag as the default for origins if not explicitly set\n const defaultEnabledForOrigins = channelEnabled ?? true;\n\n // Check if channel has explicit enabled flag (either from user settings or config)\n const channelHasExplicitEnabled =\n existingChannel?.enabled !== undefined ||\n defaultChannelSettings?.enabled !== undefined;\n\n return {\n id: channelId,\n enabled: channelEnabled,\n origins: origins.map(originId =>\n getOriginSettings(\n originId,\n existingChannel,\n defaultChannelSettings,\n topics,\n defaultEnabledForOrigins,\n channelHasExplicitEnabled,\n ),\n ),\n };\n };\n\n const getNotificationSettings = async (\n user: string,\n ): Promise<NotificationSettings> => {\n const { origins } = await store.getUserNotificationOrigins({ user });\n const { topics } = await store.getUserNotificationTopics({ user });\n const settings = await store.getNotificationSettings({ user });\n const channels = getNotificationChannels();\n\n // Merge existing channels/origins/topics with configured settings\n for (const channel of defaultNotificationSettings?.channels ?? []) {\n if (!channels.includes(channel.id)) {\n channels.push(channel.id);\n }\n\n for (const origin of channel.origins ?? []) {\n if (!origins.includes(origin.id)) {\n origins.push(origin.id);\n }\n\n for (const topic of origin.topics ?? []) {\n if (\n !topics.some(t => t.origin === origin.id && t.topic === topic.id)\n ) {\n topics.push({ origin: origin.id, topic: topic.id });\n }\n }\n }\n }\n\n return {\n channels: channels.map(channelId =>\n getChannelSettings(channelId, settings, origins, topics),\n ),\n };\n };\n\n const isNotificationsEnabled = async (opts: {\n user: string;\n channel: string;\n origin: string;\n topic: string | null;\n }) => {\n // Get user's explicit settings from database\n const userSettings = await store.getNotificationSettings({\n user: opts.user,\n });\n\n // Build a minimal settings object with user settings and config defaults\n const settings: NotificationSettings = {\n channels: [\n {\n id: opts.channel,\n enabled: defaultNotificationSettings?.channels?.find(\n c => c.id.toLowerCase() === opts.channel.toLowerCase(),\n )?.enabled,\n origins: [],\n },\n ],\n };\n\n // Add user's channel if it exists\n const userChannel = userSettings.channels.find(\n c => c.id.toLowerCase() === opts.channel.toLowerCase(),\n );\n if (userChannel) {\n settings.channels[0] = {\n ...settings.channels[0],\n enabled: userChannel.enabled ?? settings.channels[0].enabled,\n origins: userChannel.origins ?? [],\n };\n }\n\n // Add config default origins if not in user settings\n // Only add origins if the channel is enabled (not explicitly disabled)\n const defaultChannelSettings = defaultNotificationSettings?.channels?.find(\n c => c.id.toLowerCase() === opts.channel.toLowerCase(),\n );\n if (\n defaultChannelSettings?.origins &&\n settings.channels[0].enabled !== false\n ) {\n for (const defaultOrigin of defaultChannelSettings.origins) {\n if (\n !settings.channels[0].origins.some(\n o => o.id.toLowerCase() === defaultOrigin.id.toLowerCase(),\n )\n ) {\n settings.channels[0].origins.push(defaultOrigin);\n }\n }\n }\n\n return isNotificationsEnabledFor(\n settings,\n opts.channel,\n opts.origin,\n opts.topic,\n );\n };\n\n const filterProcessors = async (\n notification:\n | Notification\n | ({ origin: string; user: null } & NotificationSendOptions),\n ) => {\n const result: NotificationProcessor[] = [];\n const { payload, user, origin } = notification;\n\n for (const processor of processors) {\n if (user) {\n const enabled = await isNotificationsEnabled({\n user,\n origin,\n channel: processor.getName(),\n topic: payload.topic ?? null,\n });\n if (!enabled) {\n continue;\n }\n }\n\n if (processor.getNotificationFilters) {\n const filters = processor.getNotificationFilters();\n if (filters.minSeverity) {\n if (\n notificationSeverities.indexOf(payload.severity ?? 'normal') >\n notificationSeverities.indexOf(filters.minSeverity)\n ) {\n continue;\n }\n }\n\n if (filters.maxSeverity) {\n if (\n notificationSeverities.indexOf(payload.severity ?? 'normal') <\n notificationSeverities.indexOf(filters.maxSeverity)\n ) {\n continue;\n }\n }\n\n if (filters.excludedTopics && payload.topic) {\n if (filters.excludedTopics.includes(payload.topic)) {\n continue;\n }\n }\n\n if (filters.includedTopics) {\n if (\n !payload.topic ||\n !filters.includedTopics.includes(payload.topic)\n ) {\n continue;\n }\n }\n }\n result.push(processor);\n }\n\n return result;\n };\n\n const processOptions = async (\n opts: NotificationSendOptions,\n origin: string,\n ): Promise<NotificationSendOptions> => {\n const filtered = await filterProcessors({ ...opts, origin, user: null });\n let ret = opts;\n for (const processor of filtered) {\n try {\n ret = processor.processOptions\n ? await processor.processOptions(ret)\n : ret;\n } catch (e) {\n logger.error(\n `Error while processing notification options with ${processor.getName()}: ${e}`,\n );\n }\n }\n return ret;\n };\n\n const preProcessNotification = async (\n notification: Notification,\n opts: NotificationSendOptions,\n ) => {\n const filtered = await filterProcessors(notification);\n let ret = notification;\n for (const processor of filtered) {\n try {\n ret = processor.preProcess\n ? await processor.preProcess(ret, opts)\n : ret;\n } catch (e) {\n logger.error(\n `Error while pre processing notification with ${processor.getName()}: ${e}`,\n );\n }\n }\n return ret;\n };\n\n const postProcessNotification = async (\n notification: Notification,\n opts: NotificationSendOptions,\n ) => {\n const filtered = await filterProcessors(notification);\n for (const processor of filtered) {\n if (!processor.postProcess) {\n continue;\n }\n\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 const validateLink = (link: string) => {\n const stripLeadingSlash = (s: string) => s.replace(/^\\//, '');\n const ensureTrailingSlash = (s: string) => s.replace(/\\/?$/, '/');\n const url = new URL(\n stripLeadingSlash(link),\n ensureTrailingSlash(frontendBaseUrl),\n );\n if (url.protocol !== 'https:' && url.protocol !== 'http:') {\n throw new Error('Only HTTP/HTTPS links are allowed');\n }\n };\n\n const appendCommonOptions = (\n req: {\n query: openapi.StaticQueryParamsSchema<EndpointMap, '/topics', 'get'>;\n },\n opts: NotificationGetOptions | TopicGetOptions,\n ) => {\n if (req.query.search) {\n opts.search = req.query.search;\n }\n if (req.query.read === 'true') {\n opts.read = true;\n } else if (req.query.read === 'false') {\n opts.read = false;\n }\n\n if (req.query.saved === 'true') {\n opts.saved = true;\n } else if (req.query.saved === 'false') {\n opts.saved = false;\n }\n if (req.query.createdAfter) {\n const sinceEpoch = Date.parse(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(req.query.minimumSeverity);\n }\n };\n\n const router = await createOpenApiRouter();\n\n const listNotificationsHandler: openapi.EndpointMapRequestHandler<\n EndpointMap,\n '/notifications',\n 'get'\n > = async (req, res) => {\n const user = await getUser(req);\n const opts: NotificationGetOptions = { user };\n if (req.query.offset !== undefined) {\n opts.offset = req.query.offset;\n }\n if (req.query.limit !== undefined) {\n opts.limit = req.query.limit;\n }\n if (req.query.orderField !== undefined) {\n opts.orderField = parseEntityOrderFieldParams({\n orderField: req.query.orderField,\n });\n }\n if (req.query.topic) {\n opts.topic = req.query.topic;\n }\n appendCommonOptions(req, opts);\n\n const [notifications, totalCount] = await Promise.all([\n store.getNotifications(opts),\n store.getNotificationsCount(opts),\n ]);\n res.json({ totalCount, notifications });\n };\n\n router.get('/', listNotificationsHandler); // Deprecated alias of /notifications\n router.get('/notifications', listNotificationsHandler);\n\n router.get('/status', async (req, res) => {\n const user = await getUser(req);\n const status = await store.getStatus({ user });\n res.json(status);\n });\n\n router.get('/settings', async (req, res) => {\n const user = await getUser(req);\n const response = await getNotificationSettings(user);\n res.json(response);\n });\n\n router.post('/settings', async (req, res) => {\n const user = await getUser(req);\n const channels = getNotificationChannels();\n const settings: NotificationSettings = req.body;\n if (settings.channels.some(c => !channels.includes(c.id))) {\n throw new InputError('Invalid channel');\n }\n await store.saveNotificationSettings({ user, settings });\n const response = await getNotificationSettings(user);\n res.json(response);\n });\n\n router.get('/topics', async (req, res) => {\n const user = await getUser(req);\n const opts: TopicGetOptions = { user };\n appendCommonOptions(req, opts);\n const topics = await store.getTopics(opts);\n res.json(topics);\n });\n\n const getNotificationHandler: openapi.EndpointMapRequestHandler<\n EndpointMap,\n '/notifications/{id}',\n 'get'\n > = async (req, res) => {\n const user = await getUser(req);\n const opts: NotificationGetOptions = {\n user,\n limit: 1,\n ids: [req.params.id],\n };\n const notifications = await store.getNotifications(opts);\n if (notifications.length !== 1) {\n throw new NotFoundError('Not found');\n }\n res.json(notifications[0]);\n };\n\n // Make sure this is the last \"GET\" handler.\n router.get('/:id', getNotificationHandler); // Deprecated alias of /notifications/:id\n router.get('/notifications/:id', getNotificationHandler);\n\n const updateNotificationsHandler: openapi.EndpointMapRequestHandler<\n EndpointMap,\n '/notifications/update',\n 'post'\n > = async (req, res) => {\n const user = await getUser(req);\n const { ids, read, saved } = req.body;\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, 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, ids });\n } else if (saved === false) {\n await store.markUnsaved({ user, ids });\n }\n\n const notifications = await store.getNotifications({ ids, user });\n res.json(notifications);\n };\n\n router.post('/update', updateNotificationsHandler); // Deprecated alias of /notifications/update\n router.post('/notifications/update', updateNotificationsHandler);\n\n const sendBroadcastNotification = async (\n baseNotification: Omit<Notification, 'user' | 'id'>,\n opts: NotificationSendOptions,\n origin: string,\n ) => {\n const { scope } = opts.payload;\n const broadcastNotification = {\n ...baseNotification,\n user: null,\n id: uuid(),\n };\n const notification = await preProcessNotification(\n broadcastNotification,\n opts,\n );\n let existingNotification;\n if (scope) {\n existingNotification = await store.getExistingScopeBroadcast({\n scope,\n origin,\n });\n }\n\n let ret = notification;\n if (existingNotification) {\n const restored = await store.restoreExistingNotification({\n id: existingNotification.id,\n notification: { ...notification, user: '' },\n });\n ret = restored ?? notification;\n } else {\n await store.saveBroadcast(notification);\n }\n\n if (signals) {\n await signals.publish<NewNotificationSignal>({\n recipients: { type: 'broadcast' },\n message: {\n action: 'new_notification',\n notification_id: ret.id,\n },\n channel: 'notifications',\n });\n }\n postProcessNotification(ret, opts);\n return notification;\n };\n\n const sendUserNotification = async (\n baseNotification: Omit<Notification, 'user' | 'id'>,\n user: string,\n opts: NotificationSendOptions,\n origin: string,\n scope?: string,\n ): Promise<Notification | undefined> => {\n const userNotification = {\n ...baseNotification,\n id: uuid(),\n user,\n };\n const notification = await preProcessNotification(userNotification, opts);\n\n const enabled = await isNotificationsEnabled({\n user,\n channel: WEB_NOTIFICATION_CHANNEL,\n origin: userNotification.origin,\n topic: userNotification.payload.topic ?? null,\n });\n\n let ret = notification;\n\n if (!enabled) {\n postProcessNotification(ret, opts);\n return undefined;\n }\n\n let existingNotification;\n if (scope) {\n existingNotification = await store.getExistingScopeNotification({\n user,\n scope,\n origin,\n });\n }\n\n if (existingNotification) {\n const restored = await store.restoreExistingNotification({\n id: existingNotification.id,\n notification,\n });\n ret = restored ?? notification;\n } else {\n await store.saveNotification(notification);\n }\n\n 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 return ret;\n };\n\n const filterNonUserEntityRefs = (refs: string[]): string[] => {\n return refs.filter(ref => {\n try {\n const parsed = parseEntityRef(ref);\n return parsed.kind.toLowerCase() === 'user';\n } catch {\n return false;\n }\n });\n };\n\n const sendUserNotifications = async (\n baseNotification: Omit<Notification, 'user' | 'id'>,\n users: string[],\n opts: NotificationSendOptions,\n origin: string,\n ): Promise<Notification[]> => {\n const { scope } = opts.payload;\n const uniqueUsers = [...new Set(filterNonUserEntityRefs(users))];\n const throttled = throttle((user: string) =>\n sendUserNotification(baseNotification, user, opts, origin, scope),\n );\n const sent = await Promise.all(uniqueUsers.map(user => throttled(user)));\n return sent.filter(n => n !== undefined);\n };\n\n const createNotificationsHandler: openapi.EndpointMapRequestHandler<\n EndpointMap,\n '/notifications',\n 'post'\n > = async (req, res) => {\n const credentials = await httpAuth.credentials(req, {\n allow: ['service'],\n });\n\n const origin = credentials.principal.subject;\n const opts = await processOptions(req.body, origin);\n const { recipients, payload } = opts;\n const { title, link } = payload;\n const notifications: Notification[] = [];\n\n if (!recipients || !title) {\n const missing = [\n !title ? 'title' : null,\n !recipients ? 'recipients' : null,\n ].filter(Boolean);\n const err = `Invalid notification request received: missing ${missing.join(\n ', ',\n )}`;\n throw new InputError(err);\n }\n\n if (link) {\n try {\n validateLink(link);\n } catch (e) {\n throw new InputError('Invalid link provided', e);\n }\n }\n\n const baseNotification = {\n payload: {\n ...payload,\n severity: payload.severity ?? 'normal',\n },\n origin,\n created: new Date(),\n };\n\n if (recipients.type === 'broadcast') {\n const broadcast = await sendBroadcastNotification(\n baseNotification,\n opts,\n origin,\n );\n notifications.push(broadcast);\n } else if (recipients.type === 'entity') {\n const entityRefs = [recipients.entityRef].flat();\n const excludedEntityRefs = recipients.excludeEntityRef\n ? [recipients.excludeEntityRef].flat()\n : undefined;\n try {\n const { userEntityRefs } =\n await usedRecipientResolver.resolveNotificationRecipients({\n entityRefs,\n excludedEntityRefs,\n });\n const userNotifications = await sendUserNotifications(\n baseNotification,\n userEntityRefs,\n opts,\n origin,\n );\n notifications.push(...userNotifications);\n } catch (e) {\n throw new InputError('Failed to send user notifications', e);\n }\n } else {\n throw new InputError(\n `Invalid recipients type, please use either 'broadcast' or 'entity'`,\n );\n }\n\n res.json(notifications);\n };\n\n // Add new notification\n router.post('/', createNotificationsHandler); // Deprecated alias of /notifications\n router.post('/notifications', createNotificationsHandler);\n\n return router;\n}\n"],"names":["config","durationToMilliseconds","readDurationFromConfig","pThrottle","DefaultNotificationRecipientResolver","isNotificationsEnabledFor","notificationSeverities","InputError","normalizeSeverity","router","createOpenApiRouter","parseEntityOrderFieldParams","NotFoundError","uuid","parseEntityRef"],"mappings":";;;;;;;;;;;;;;;;;;AAwEA,eAAsB,aACpB,OAAA,EACyB;AACzB,EAAA,MAAM;AAAA,YACJA,QAAA;AAAA,IACA,MAAA;AAAA,IACA,KAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,IACA,OAAA;AAAA,IACA,aAAa,EAAC;AAAA,IACd,OAAA;AAAA,IACA;AAAA,GACF,GAAI,OAAA;AAEJ,EAAA,MAAM,wBAAA,GAA2B,KAAA;AACjC,EAAA,MAAM,eAAA,GAAkBA,QAAA,CAAO,SAAA,CAAU,aAAa,CAAA;AACtD,EAAA,MAAM,gBAAA,GACJA,QAAA,CAAO,iBAAA,CAAkB,gCAAgC,CAAA,IAAK,EAAA;AAChE,EAAA,MAAM,gBAAA,GAAmBA,QAAA,CAAO,GAAA,CAAI,gCAAgC,CAAA,GAChEC,4BAAA;AAAA,IACEC,8BAAuBF,QAAA,EAAQ;AAAA,MAC7B,GAAA,EAAK;AAAA,KACN;AAAA,GACH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M,EAAE,cAAA,EAAe,GACrB,MAAM,sBAAsB,6BAAA,CAA8B;AAAA,UACxD,UAAA;AAAA,UACA;AAAA,SACD,CAAA;AACH,QAAA,MAAM,oBAAoB,MAAM,qBAAA;AAAA,UAC9B,gBAAA;AAAA,UACA,cAAA;AAAA,UACA,IAAA;AAAA,UACA;AAAA,SACF;AACA,QAAA,aAAA,CAAc,IAAA,CAAK,GAAG,iBAAiB,CAAA;AAAA,MACzC,SAAS,CAAA,EAAG;AACV,QAAA,MAAM,IAAIA,iBAAA,CAAW,mCAAA,EAAqC,CAAC,CAAA;AAAA,MAC7D;AAAA,IACF,CAAA,MAAO;AACL,MAAA,MAAM,IAAIA,iBAAA;AAAA,QACR,CAAA,kEAAA;AAAA,OACF;AAAA,IACF;AAEA,IAAA,GAAA,CAAI,KAAK,aAAa,CAAA;AAAA,EACxB,CAAA;AAGA,EAAAE,QAAA,CAAO,IAAA,CAAK,KAAK,0BAA0B,CAAA;AAC3C,EAAAA,QAAA,CAAO,IAAA,CAAK,kBAAkB,0BAA0B,CAAA;AAExD,EAAA,OAAOA,QAAA;AACT;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-notifications-backend",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.6-next.0",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "backend-plugin",
|
|
6
6
|
"pluginId": "notifications",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "backstage-cli package build",
|
|
40
40
|
"clean": "backstage-cli package clean",
|
|
41
|
+
"generate": "backstage-repo-tools package schema openapi generate --server",
|
|
41
42
|
"lint": "backstage-cli package lint",
|
|
42
43
|
"prepack": "backstage-cli package prepack",
|
|
43
44
|
"postpack": "backstage-cli package postpack",
|
|
@@ -45,28 +46,30 @@
|
|
|
45
46
|
"test": "backstage-cli package test"
|
|
46
47
|
},
|
|
47
48
|
"dependencies": {
|
|
48
|
-
"@backstage/backend-
|
|
49
|
-
"@backstage/
|
|
50
|
-
"@backstage/
|
|
51
|
-
"@backstage/
|
|
52
|
-
"@backstage/
|
|
53
|
-
"@backstage/plugin-
|
|
54
|
-
"@backstage/plugin-notifications-
|
|
55
|
-
"@backstage/plugin-
|
|
56
|
-
"@backstage/
|
|
49
|
+
"@backstage/backend-openapi-utils": "0.6.10-next.0",
|
|
50
|
+
"@backstage/backend-plugin-api": "1.9.2-next.0",
|
|
51
|
+
"@backstage/catalog-model": "1.9.0",
|
|
52
|
+
"@backstage/config": "1.3.8",
|
|
53
|
+
"@backstage/errors": "1.3.1",
|
|
54
|
+
"@backstage/plugin-catalog-node": "2.2.2-next.0",
|
|
55
|
+
"@backstage/plugin-notifications-common": "0.2.3",
|
|
56
|
+
"@backstage/plugin-notifications-node": "0.2.27-next.0",
|
|
57
|
+
"@backstage/plugin-signals-node": "0.2.2-next.0",
|
|
58
|
+
"@backstage/types": "1.2.2",
|
|
57
59
|
"express": "^4.22.0",
|
|
58
60
|
"express-promise-router": "^4.1.0",
|
|
59
61
|
"knex": "^3.0.0",
|
|
60
62
|
"p-throttle": "^4.1.1"
|
|
61
63
|
},
|
|
62
64
|
"devDependencies": {
|
|
63
|
-
"@backstage/backend-defaults": "
|
|
64
|
-
"@backstage/backend-test-utils": "
|
|
65
|
-
"@backstage/cli": "
|
|
66
|
-
"@backstage/plugin-auth-backend": "
|
|
67
|
-
"@backstage/plugin-auth-backend-module-guest-provider": "
|
|
68
|
-
"@backstage/plugin-events-backend": "
|
|
69
|
-
"@backstage/plugin-signals-backend": "
|
|
65
|
+
"@backstage/backend-defaults": "0.17.2-next.0",
|
|
66
|
+
"@backstage/backend-test-utils": "1.11.4-next.0",
|
|
67
|
+
"@backstage/cli": "0.36.3-next.0",
|
|
68
|
+
"@backstage/plugin-auth-backend": "0.29.1-next.0",
|
|
69
|
+
"@backstage/plugin-auth-backend-module-guest-provider": "0.2.20-next.0",
|
|
70
|
+
"@backstage/plugin-events-backend": "0.6.3-next.0",
|
|
71
|
+
"@backstage/plugin-signals-backend": "0.3.16-next.0",
|
|
72
|
+
"@backstage/repo-tools": "0.17.3-next.0",
|
|
70
73
|
"@types/express": "^4.17.6",
|
|
71
74
|
"@types/supertest": "^2.0.8",
|
|
72
75
|
"supertest": "^7.0.0"
|