@backstage/plugin-notifications-node 0.2.18-next.0 → 0.2.19-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
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @backstage/plugin-notifications-node
|
|
2
2
|
|
|
3
|
+
## 0.2.19-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/backend-plugin-api@1.4.3-next.0
|
|
9
|
+
- @backstage/plugin-signals-node@0.1.24-next.0
|
|
10
|
+
|
|
11
|
+
## 0.2.18
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
- @backstage/catalog-client@1.11.0
|
|
17
|
+
- @backstage/plugin-notifications-common@0.1.0
|
|
18
|
+
- @backstage/backend-plugin-api@1.4.2
|
|
19
|
+
- @backstage/plugin-signals-node@0.1.23
|
|
20
|
+
|
|
3
21
|
## 0.2.18-next.0
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions.cjs.js","sources":["../src/extensions.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createExtensionPoint } from '@backstage/backend-plugin-api';\nimport {\n Notification,\n NotificationProcessorFilters as NotificationProcessorFiltersCommon,\n} from '@backstage/plugin-notifications-common';\nimport { NotificationSendOptions } from './service';\n\n/**\n * Notification processors are used to modify the notification parameters or sending the notifications\n * to external systems.\n *\n * Notification modules should utilize the `notificationsProcessingExtensionPoint` to add new processors\n * to the system.\n *\n * Notification processing flow:\n *\n * 1. New notification send request is received\n * 2. For all notification processors registered, processOptions function is called to process the notification options\n * 3. Notification recipients are resolved from the options\n * 4. For each recipient, preProcess function is called to pre-process the notification\n * 5. Notification is saved to the database and sent to the Backstage UI\n * 6. For each recipient, postProcess function is called to post-process the notification\n *\n * @public\n */\nexport interface NotificationProcessor {\n /**\n * Human-readable name of this processor like Email, Slack, etc.\n */\n getName(): string;\n\n /**\n * Process the notification options.\n *\n * Can be used to override the default recipient resolving, sending the notification to an\n * external service or modify other notification options necessary.\n *\n * processOptions functions are called only once for each notification before the recipient resolving,\n * pre-process, sending and post-process of the notification.\n *\n * @param options - The original options to send the notification\n */\n processOptions?(\n options: NotificationSendOptions,\n ): Promise<NotificationSendOptions>;\n\n /**\n * Pre-process notification before sending it to Backstage UI.\n *\n * Can be used to send the notification to external services or to decorate the notification with additional\n * information. The notification is saved to database and sent to Backstage UI after all pre-process functions\n * have run. The notification options passed here are already processed by processOptions functionality.\n *\n * preProcess functions are called for each notification recipient individually or once for broadcast\n * notification BEFORE the notification has been sent to the Backstage UI.\n *\n * @param notification - The notification to send\n * @param options - The options to send the notification\n * @returns The same notification or a modified version of it\n */\n preProcess?(\n notification: Notification,\n options: NotificationSendOptions,\n ): Promise<Notification>;\n\n /**\n * Post process notification after sending it to Backstage UI.\n *\n * Can be used to send the notification to external services.\n *\n * postProcess functions are called for each notification recipient individually or once for\n * broadcast notification AFTER the notification has been sent to the Backstage UI.\n *\n * @param notification - The notification to send\n * @param options - The options to send the notification\n */\n postProcess?(\n notification: Notification,\n options: NotificationSendOptions,\n ): Promise<void>;\n\n /**\n * notification filters are used to call the processor only in certain conditions\n */\n getNotificationFilters?(): NotificationProcessorFilters;\n}\n\n/**\n * @public\n */\nexport interface NotificationsProcessingExtensionPoint {\n addProcessor(\n ...processors: Array<NotificationProcessor | Array<NotificationProcessor>>\n ): void;\n}\n\n/**\n * @public\n */\nexport const notificationsProcessingExtensionPoint =\n createExtensionPoint<NotificationsProcessingExtensionPoint>({\n id: 'notifications.processing',\n });\n\n/**\n * @public\n * @deprecated Please import from `@backstage/plugin-notifications-common` instead\n */\nexport type NotificationProcessorFilters = NotificationProcessorFiltersCommon;\n"],"names":["createExtensionPoint"],"mappings":";;;;AAkHO,MAAM,wCACXA,
|
|
1
|
+
{"version":3,"file":"extensions.cjs.js","sources":["../src/extensions.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createExtensionPoint } from '@backstage/backend-plugin-api';\nimport {\n Notification,\n NotificationProcessorFilters as NotificationProcessorFiltersCommon,\n} from '@backstage/plugin-notifications-common';\nimport { NotificationSendOptions } from './service';\n\n/**\n * Notification processors are used to modify the notification parameters or sending the notifications\n * to external systems.\n *\n * Notification modules should utilize the `notificationsProcessingExtensionPoint` to add new processors\n * to the system.\n *\n * Notification processing flow:\n *\n * 1. New notification send request is received\n * 2. For all notification processors registered, processOptions function is called to process the notification options\n * 3. Notification recipients are resolved from the options\n * 4. For each recipient, preProcess function is called to pre-process the notification\n * 5. Notification is saved to the database and sent to the Backstage UI\n * 6. For each recipient, postProcess function is called to post-process the notification\n *\n * @public\n */\nexport interface NotificationProcessor {\n /**\n * Human-readable name of this processor like Email, Slack, etc.\n */\n getName(): string;\n\n /**\n * Process the notification options.\n *\n * Can be used to override the default recipient resolving, sending the notification to an\n * external service or modify other notification options necessary.\n *\n * processOptions functions are called only once for each notification before the recipient resolving,\n * pre-process, sending and post-process of the notification.\n *\n * @param options - The original options to send the notification\n */\n processOptions?(\n options: NotificationSendOptions,\n ): Promise<NotificationSendOptions>;\n\n /**\n * Pre-process notification before sending it to Backstage UI.\n *\n * Can be used to send the notification to external services or to decorate the notification with additional\n * information. The notification is saved to database and sent to Backstage UI after all pre-process functions\n * have run. The notification options passed here are already processed by processOptions functionality.\n *\n * preProcess functions are called for each notification recipient individually or once for broadcast\n * notification BEFORE the notification has been sent to the Backstage UI.\n *\n * @param notification - The notification to send\n * @param options - The options to send the notification\n * @returns The same notification or a modified version of it\n */\n preProcess?(\n notification: Notification,\n options: NotificationSendOptions,\n ): Promise<Notification>;\n\n /**\n * Post process notification after sending it to Backstage UI.\n *\n * Can be used to send the notification to external services.\n *\n * postProcess functions are called for each notification recipient individually or once for\n * broadcast notification AFTER the notification has been sent to the Backstage UI.\n *\n * @param notification - The notification to send\n * @param options - The options to send the notification\n */\n postProcess?(\n notification: Notification,\n options: NotificationSendOptions,\n ): Promise<void>;\n\n /**\n * notification filters are used to call the processor only in certain conditions\n */\n getNotificationFilters?(): NotificationProcessorFilters;\n}\n\n/**\n * @public\n */\nexport interface NotificationsProcessingExtensionPoint {\n addProcessor(\n ...processors: Array<NotificationProcessor | Array<NotificationProcessor>>\n ): void;\n}\n\n/**\n * @public\n */\nexport const notificationsProcessingExtensionPoint =\n createExtensionPoint<NotificationsProcessingExtensionPoint>({\n id: 'notifications.processing',\n });\n\n/**\n * @public\n * @deprecated Please import from `@backstage/plugin-notifications-common` instead\n */\nexport type NotificationProcessorFilters = NotificationProcessorFiltersCommon;\n"],"names":["createExtensionPoint"],"mappings":";;;;AAkHO,MAAM,wCACXA,qCAAA,CAA4D;AAAA,EAC1D,EAAA,EAAI;AACN,CAAC;;;;"}
|
package/dist/lib.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.cjs.js","sources":["../src/lib.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 coreServices,\n createServiceFactory,\n createServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { DefaultNotificationService } from './service';\nimport { NotificationService } from './service/NotificationService';\n\n/** @public */\nexport const notificationService = createServiceRef<NotificationService>({\n id: 'notifications.service',\n scope: 'plugin',\n defaultFactory: async service =>\n createServiceFactory({\n service,\n deps: {\n auth: coreServices.auth,\n discovery: coreServices.discovery,\n },\n factory({ auth, discovery }) {\n return DefaultNotificationService.create({\n auth,\n discovery,\n });\n },\n }),\n});\n"],"names":["createServiceRef","createServiceFactory","coreServices","DefaultNotificationService"],"mappings":";;;;;AAwBO,MAAM,sBAAsBA,
|
|
1
|
+
{"version":3,"file":"lib.cjs.js","sources":["../src/lib.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 coreServices,\n createServiceFactory,\n createServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { DefaultNotificationService } from './service';\nimport { NotificationService } from './service/NotificationService';\n\n/** @public */\nexport const notificationService = createServiceRef<NotificationService>({\n id: 'notifications.service',\n scope: 'plugin',\n defaultFactory: async service =>\n createServiceFactory({\n service,\n deps: {\n auth: coreServices.auth,\n discovery: coreServices.discovery,\n },\n factory({ auth, discovery }) {\n return DefaultNotificationService.create({\n auth,\n discovery,\n });\n },\n }),\n});\n"],"names":["createServiceRef","createServiceFactory","coreServices","DefaultNotificationService"],"mappings":";;;;;AAwBO,MAAM,sBAAsBA,iCAAA,CAAsC;AAAA,EACvE,EAAA,EAAI,uBAAA;AAAA,EACJ,KAAA,EAAO,QAAA;AAAA,EACP,cAAA,EAAgB,OAAM,OAAA,KACpBC,qCAAA,CAAqB;AAAA,IACnB,OAAA;AAAA,IACA,IAAA,EAAM;AAAA,MACJ,MAAMC,6BAAA,CAAa,IAAA;AAAA,MACnB,WAAWA,6BAAA,CAAa;AAAA,KAC1B;AAAA,IACA,OAAA,CAAQ,EAAE,IAAA,EAAM,SAAA,EAAU,EAAG;AAC3B,MAAA,OAAOC,sDAA2B,MAAA,CAAO;AAAA,QACvC,IAAA;AAAA,QACA;AAAA,OACD,CAAA;AAAA,IACH;AAAA,GACD;AACL,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultNotificationService.cjs.js","sources":["../../src/service/DefaultNotificationService.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 { NotificationService } from './NotificationService';\nimport { AuthService, DiscoveryService } from '@backstage/backend-plugin-api';\nimport { NotificationPayload } from '@backstage/plugin-notifications-common';\n\n/** @public */\nexport type NotificationServiceOptions = {\n auth: AuthService;\n discovery: DiscoveryService;\n};\n\n/** @public */\nexport type NotificationRecipients =\n | {\n type: 'entity';\n /**\n * Entity references to send the notifications to\n */\n entityRef: string | string[];\n /**\n * Optional entity reference(s) to filter out of the resolved recipients.\n * Usually the currently logged-in user for preventing sending notification\n * of user action to him/herself.\n */\n excludeEntityRef?: string | string[];\n }\n | { type: 'broadcast' };\n\n/** @public */\nexport type NotificationSendOptions = {\n recipients: NotificationRecipients;\n payload: NotificationPayload;\n};\n\n/** @public */\nexport class DefaultNotificationService implements NotificationService {\n private constructor(\n private readonly discovery: DiscoveryService,\n private readonly auth: AuthService,\n ) {}\n\n static create(\n options: NotificationServiceOptions,\n ): DefaultNotificationService {\n return new DefaultNotificationService(options.discovery, options.auth);\n }\n\n async send(notification: NotificationSendOptions): Promise<void> {\n try {\n const baseUrl = await this.discovery.getBaseUrl('notifications');\n const { token } = await this.auth.getPluginRequestToken({\n onBehalfOf: await this.auth.getOwnServiceCredentials(),\n targetPluginId: 'notifications',\n });\n\n const response = await fetch(baseUrl, {\n method: 'POST',\n body: JSON.stringify(notification),\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n Authorization: `Bearer ${token}`,\n },\n });\n\n if (!response.ok) {\n throw new Error(`Request failed with status ${response.status}`);\n }\n } catch (error) {\n // TODO: Should not throw in optimal case, see BEP\n throw new Error(`Failed to send notifications: ${error}`);\n }\n }\n}\n"],"names":[],"mappings":";;AAkDO,MAAM,
|
|
1
|
+
{"version":3,"file":"DefaultNotificationService.cjs.js","sources":["../../src/service/DefaultNotificationService.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 { NotificationService } from './NotificationService';\nimport { AuthService, DiscoveryService } from '@backstage/backend-plugin-api';\nimport { NotificationPayload } from '@backstage/plugin-notifications-common';\n\n/** @public */\nexport type NotificationServiceOptions = {\n auth: AuthService;\n discovery: DiscoveryService;\n};\n\n/** @public */\nexport type NotificationRecipients =\n | {\n type: 'entity';\n /**\n * Entity references to send the notifications to\n */\n entityRef: string | string[];\n /**\n * Optional entity reference(s) to filter out of the resolved recipients.\n * Usually the currently logged-in user for preventing sending notification\n * of user action to him/herself.\n */\n excludeEntityRef?: string | string[];\n }\n | { type: 'broadcast' };\n\n/** @public */\nexport type NotificationSendOptions = {\n recipients: NotificationRecipients;\n payload: NotificationPayload;\n};\n\n/** @public */\nexport class DefaultNotificationService implements NotificationService {\n private constructor(\n private readonly discovery: DiscoveryService,\n private readonly auth: AuthService,\n ) {}\n\n static create(\n options: NotificationServiceOptions,\n ): DefaultNotificationService {\n return new DefaultNotificationService(options.discovery, options.auth);\n }\n\n async send(notification: NotificationSendOptions): Promise<void> {\n try {\n const baseUrl = await this.discovery.getBaseUrl('notifications');\n const { token } = await this.auth.getPluginRequestToken({\n onBehalfOf: await this.auth.getOwnServiceCredentials(),\n targetPluginId: 'notifications',\n });\n\n const response = await fetch(baseUrl, {\n method: 'POST',\n body: JSON.stringify(notification),\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n Authorization: `Bearer ${token}`,\n },\n });\n\n if (!response.ok) {\n throw new Error(`Request failed with status ${response.status}`);\n }\n } catch (error) {\n // TODO: Should not throw in optimal case, see BEP\n throw new Error(`Failed to send notifications: ${error}`);\n }\n }\n}\n"],"names":[],"mappings":";;AAkDO,MAAM,0BAAA,CAA0D;AAAA,EAC7D,WAAA,CACW,WACA,IAAA,EACjB;AAFiB,IAAA,IAAA,CAAA,SAAA,GAAA,SAAA;AACA,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAChB;AAAA,EAEH,OAAO,OACL,OAAA,EAC4B;AAC5B,IAAA,OAAO,IAAI,0BAAA,CAA2B,OAAA,CAAQ,SAAA,EAAW,QAAQ,IAAI,CAAA;AAAA,EACvE;AAAA,EAEA,MAAM,KAAK,YAAA,EAAsD;AAC/D,IAAA,IAAI;AACF,MAAA,MAAM,OAAA,GAAU,MAAM,IAAA,CAAK,SAAA,CAAU,WAAW,eAAe,CAAA;AAC/D,MAAA,MAAM,EAAE,KAAA,EAAM,GAAI,MAAM,IAAA,CAAK,KAAK,qBAAA,CAAsB;AAAA,QACtD,UAAA,EAAY,MAAM,IAAA,CAAK,IAAA,CAAK,wBAAA,EAAyB;AAAA,QACrD,cAAA,EAAgB;AAAA,OACjB,CAAA;AAED,MAAA,MAAM,QAAA,GAAW,MAAM,KAAA,CAAM,OAAA,EAAS;AAAA,QACpC,MAAA,EAAQ,MAAA;AAAA,QACR,IAAA,EAAM,IAAA,CAAK,SAAA,CAAU,YAAY,CAAA;AAAA,QACjC,OAAA,EAAS;AAAA,UACP,cAAA,EAAgB,kBAAA;AAAA,UAChB,MAAA,EAAQ,kBAAA;AAAA,UACR,aAAA,EAAe,UAAU,KAAK,CAAA;AAAA;AAChC,OACD,CAAA;AAED,MAAA,IAAI,CAAC,SAAS,EAAA,EAAI;AAChB,QAAA,MAAM,IAAI,KAAA,CAAM,CAAA,2BAAA,EAA8B,QAAA,CAAS,MAAM,CAAA,CAAE,CAAA;AAAA,MACjE;AAAA,IACF,SAAS,KAAA,EAAO;AAEd,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,8BAAA,EAAiC,KAAK,CAAA,CAAE,CAAA;AAAA,IAC1D;AAAA,EACF;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-notifications-node",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.19-next.0",
|
|
4
4
|
"description": "Node.js library for the notifications plugin",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "node-library",
|
|
@@ -37,18 +37,18 @@
|
|
|
37
37
|
"test": "backstage-cli package test"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@backstage/backend-plugin-api": "1.4.
|
|
41
|
-
"@backstage/catalog-client": "1.11.0
|
|
40
|
+
"@backstage/backend-plugin-api": "1.4.3-next.0",
|
|
41
|
+
"@backstage/catalog-client": "1.11.0",
|
|
42
42
|
"@backstage/catalog-model": "1.7.5",
|
|
43
|
-
"@backstage/plugin-notifications-common": "0.0
|
|
44
|
-
"@backstage/plugin-signals-node": "0.1.
|
|
43
|
+
"@backstage/plugin-notifications-common": "0.1.0",
|
|
44
|
+
"@backstage/plugin-signals-node": "0.1.24-next.0",
|
|
45
45
|
"knex": "^3.0.0",
|
|
46
46
|
"uuid": "^11.0.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@backstage/backend-test-utils": "1.
|
|
50
|
-
"@backstage/cli": "0.
|
|
51
|
-
"@backstage/test-utils": "1.7.11
|
|
49
|
+
"@backstage/backend-test-utils": "1.9.0-next.1",
|
|
50
|
+
"@backstage/cli": "0.34.2-next.1",
|
|
51
|
+
"@backstage/test-utils": "1.7.11",
|
|
52
52
|
"msw": "^1.0.0"
|
|
53
53
|
},
|
|
54
54
|
"typesVersions": {
|