@backstage/plugin-scaffolder-backend-module-notifications 0.1.8 → 0.1.9-next.1
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,26 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend-module-notifications
|
|
2
2
|
|
|
3
|
+
## 0.1.9-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/plugin-scaffolder-node@0.8.1-next.1
|
|
9
|
+
- @backstage/backend-plugin-api@1.2.1
|
|
10
|
+
- @backstage/plugin-notifications-common@0.0.8
|
|
11
|
+
- @backstage/plugin-notifications-node@0.2.13
|
|
12
|
+
|
|
13
|
+
## 0.1.9-next.0
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 25a7675: Made "notification:send" action idempotent
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
- @backstage/plugin-scaffolder-node@0.8.1-next.0
|
|
20
|
+
- @backstage/backend-plugin-api@1.2.1
|
|
21
|
+
- @backstage/plugin-notifications-common@0.0.8
|
|
22
|
+
- @backstage/plugin-notifications-node@0.2.13
|
|
23
|
+
|
|
3
24
|
## 0.1.8
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
|
@@ -89,9 +89,14 @@ function createSendNotificationAction(options) {
|
|
|
89
89
|
scope
|
|
90
90
|
};
|
|
91
91
|
try {
|
|
92
|
-
await
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
await ctx.checkpoint({
|
|
93
|
+
key: `send.notification.${payload.title}`,
|
|
94
|
+
fn: async () => {
|
|
95
|
+
await notifications.send({
|
|
96
|
+
recipients: notificationRecipients,
|
|
97
|
+
payload
|
|
98
|
+
});
|
|
99
|
+
}
|
|
95
100
|
});
|
|
96
101
|
} catch (e) {
|
|
97
102
|
ctx.logger.error(`Failed to send notification: ${e}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendNotification.cjs.js","sources":["../../src/actions/sendNotification.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 {\n NotificationRecipients,\n NotificationService,\n} from '@backstage/plugin-notifications-node';\nimport {\n NotificationPayload,\n NotificationSeverity,\n} from '@backstage/plugin-notifications-common';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { examples } from './sendNotification.examples';\n\n/**\n * @public\n */\nexport function createSendNotificationAction(options: {\n notifications: NotificationService;\n}) {\n const { notifications } = options;\n return createTemplateAction<{\n recipients: string;\n entityRefs?: string[];\n title: string;\n info?: string;\n link?: string;\n severity?: NotificationSeverity;\n scope?: string;\n optional?: boolean;\n }>({\n id: 'notification:send',\n description: 'Sends a notification using NotificationService',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['recipients', 'title'],\n properties: {\n recipients: {\n title: 'Recipient',\n enum: ['broadcast', 'entity'],\n description:\n 'The recipient of the notification, either broadcast or entity. If using entity, also entityRef must be provided',\n type: 'string',\n },\n entityRefs: {\n title: 'Entity references',\n description:\n 'The entity references to send the notification to, required if using recipient of entity',\n type: 'array',\n items: {\n type: 'string',\n },\n },\n title: {\n title: 'Title',\n description: 'Notification title',\n type: 'string',\n },\n info: {\n title: 'Description',\n description: 'Notification description',\n type: 'string',\n },\n link: {\n title: 'Link',\n description: 'Notification link',\n type: 'string',\n },\n severity: {\n title: 'Severity',\n type: 'string',\n description: `Notification severity`,\n enum: ['low', 'normal', 'high', 'critical'],\n },\n scope: {\n title: 'Scope',\n description: 'Notification scope',\n type: 'string',\n },\n optional: {\n title: 'Optional',\n description:\n 'Do not fail the action if the notification sending fails',\n type: 'boolean',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n recipients,\n entityRefs,\n title,\n info,\n link,\n severity,\n scope,\n optional,\n } = ctx.input;\n\n ctx.logger.info(`Sending notification to ${recipients}`);\n if (recipients === 'entity' && !entityRefs) {\n if (optional !== true) {\n throw new Error('Entity references must be provided');\n }\n return;\n }\n\n const notificationRecipients: NotificationRecipients =\n recipients === 'broadcast'\n ? { type: 'broadcast' }\n : { type: 'entity', entityRef: entityRefs! };\n const payload: NotificationPayload = {\n title,\n description: info,\n link,\n severity,\n scope,\n };\n\n try {\n await notifications.send({\n
|
|
1
|
+
{"version":3,"file":"sendNotification.cjs.js","sources":["../../src/actions/sendNotification.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 {\n NotificationRecipients,\n NotificationService,\n} from '@backstage/plugin-notifications-node';\nimport {\n NotificationPayload,\n NotificationSeverity,\n} from '@backstage/plugin-notifications-common';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { examples } from './sendNotification.examples';\n\n/**\n * @public\n */\nexport function createSendNotificationAction(options: {\n notifications: NotificationService;\n}) {\n const { notifications } = options;\n return createTemplateAction<{\n recipients: string;\n entityRefs?: string[];\n title: string;\n info?: string;\n link?: string;\n severity?: NotificationSeverity;\n scope?: string;\n optional?: boolean;\n }>({\n id: 'notification:send',\n description: 'Sends a notification using NotificationService',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['recipients', 'title'],\n properties: {\n recipients: {\n title: 'Recipient',\n enum: ['broadcast', 'entity'],\n description:\n 'The recipient of the notification, either broadcast or entity. If using entity, also entityRef must be provided',\n type: 'string',\n },\n entityRefs: {\n title: 'Entity references',\n description:\n 'The entity references to send the notification to, required if using recipient of entity',\n type: 'array',\n items: {\n type: 'string',\n },\n },\n title: {\n title: 'Title',\n description: 'Notification title',\n type: 'string',\n },\n info: {\n title: 'Description',\n description: 'Notification description',\n type: 'string',\n },\n link: {\n title: 'Link',\n description: 'Notification link',\n type: 'string',\n },\n severity: {\n title: 'Severity',\n type: 'string',\n description: `Notification severity`,\n enum: ['low', 'normal', 'high', 'critical'],\n },\n scope: {\n title: 'Scope',\n description: 'Notification scope',\n type: 'string',\n },\n optional: {\n title: 'Optional',\n description:\n 'Do not fail the action if the notification sending fails',\n type: 'boolean',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n recipients,\n entityRefs,\n title,\n info,\n link,\n severity,\n scope,\n optional,\n } = ctx.input;\n\n ctx.logger.info(`Sending notification to ${recipients}`);\n if (recipients === 'entity' && !entityRefs) {\n if (optional !== true) {\n throw new Error('Entity references must be provided');\n }\n return;\n }\n\n const notificationRecipients: NotificationRecipients =\n recipients === 'broadcast'\n ? { type: 'broadcast' }\n : { type: 'entity', entityRef: entityRefs! };\n const payload: NotificationPayload = {\n title,\n description: info,\n link,\n severity,\n scope,\n };\n\n try {\n await ctx.checkpoint({\n key: `send.notification.${payload.title}`,\n fn: async () => {\n await notifications.send({\n recipients: notificationRecipients,\n payload,\n });\n },\n });\n } catch (e) {\n ctx.logger.error(`Failed to send notification: ${e}`);\n if (optional !== true) {\n throw e;\n }\n }\n },\n });\n}\n"],"names":["createTemplateAction","examples"],"mappings":";;;;;AA6BO,SAAS,6BAA6B,OAE1C,EAAA;AACD,EAAM,MAAA,EAAE,eAAkB,GAAA,OAAA;AAC1B,EAAA,OAAOA,yCASJ,CAAA;AAAA,IACD,EAAI,EAAA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C,CAAE,CAAA,CAAA;AACpD,QAAA,IAAI,aAAa,IAAM,EAAA;AACrB,UAAM,MAAA,CAAA;AAAA;AACR;AACF;AACF,GACD,CAAA;AACH;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-scaffolder-backend-module-notifications",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9-next.1",
|
|
4
4
|
"description": "The notifications backend module for the scaffolder plugin.",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin-module",
|
|
@@ -36,15 +36,15 @@
|
|
|
36
36
|
"test": "backstage-cli package test"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@backstage/backend-plugin-api": "
|
|
40
|
-
"@backstage/plugin-notifications-common": "
|
|
41
|
-
"@backstage/plugin-notifications-node": "
|
|
42
|
-
"@backstage/plugin-scaffolder-node": "
|
|
39
|
+
"@backstage/backend-plugin-api": "1.2.1",
|
|
40
|
+
"@backstage/plugin-notifications-common": "0.0.8",
|
|
41
|
+
"@backstage/plugin-notifications-node": "0.2.13",
|
|
42
|
+
"@backstage/plugin-scaffolder-node": "0.8.1-next.1",
|
|
43
43
|
"octokit": "^3.0.0",
|
|
44
44
|
"yaml": "^2.0.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@backstage/cli": "
|
|
48
|
-
"@backstage/plugin-scaffolder-node-test-utils": "
|
|
47
|
+
"@backstage/cli": "0.32.0-next.1",
|
|
48
|
+
"@backstage/plugin-scaffolder-node-test-utils": "0.2.1-next.1"
|
|
49
49
|
}
|
|
50
50
|
}
|