@backstage/plugin-scaffolder-backend-module-notifications 0.1.1-next.1 → 0.1.1-next.2

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,15 @@
1
1
  # @backstage/plugin-scaffolder-backend-module-notifications
2
2
 
3
+ ## 0.1.1-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/plugin-scaffolder-node@0.5.0-next.2
9
+ - @backstage/backend-plugin-api@1.0.1-next.1
10
+ - @backstage/plugin-notifications-common@0.0.5
11
+ - @backstage/plugin-notifications-node@0.2.7-next.1
12
+
3
13
  ## 0.1.1-next.1
4
14
 
5
15
  ### Patch Changes
@@ -0,0 +1,107 @@
1
+ 'use strict';
2
+
3
+ var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
4
+ var sendNotification_examples = require('./sendNotification.examples.cjs.js');
5
+
6
+ function createSendNotificationAction(options) {
7
+ const { notifications } = options;
8
+ return pluginScaffolderNode.createTemplateAction({
9
+ id: "notification:send",
10
+ description: "Sends a notification using NotificationService",
11
+ examples: sendNotification_examples.examples,
12
+ schema: {
13
+ input: {
14
+ type: "object",
15
+ required: ["recipients", "title"],
16
+ properties: {
17
+ recipients: {
18
+ title: "Recipient",
19
+ enum: ["broadcast", "entity"],
20
+ description: "The recipient of the notification, either broadcast or entity. If using entity, also entityRef must be provided",
21
+ type: "string"
22
+ },
23
+ entityRefs: {
24
+ title: "Entity references",
25
+ description: "The entity references to send the notification to, required if using recipient of entity",
26
+ type: "array",
27
+ items: {
28
+ type: "string"
29
+ }
30
+ },
31
+ title: {
32
+ title: "Title",
33
+ description: "Notification title",
34
+ type: "string"
35
+ },
36
+ info: {
37
+ title: "Description",
38
+ description: "Notification description",
39
+ type: "string"
40
+ },
41
+ link: {
42
+ title: "Link",
43
+ description: "Notification link",
44
+ type: "string"
45
+ },
46
+ severity: {
47
+ title: "Severity",
48
+ type: "string",
49
+ description: `Notification severity`,
50
+ enum: ["low", "normal", "high", "critical"]
51
+ },
52
+ scope: {
53
+ title: "Scope",
54
+ description: "Notification scope",
55
+ type: "string"
56
+ },
57
+ optional: {
58
+ title: "Optional",
59
+ description: "Do not fail the action if the notification sending fails",
60
+ type: "boolean"
61
+ }
62
+ }
63
+ }
64
+ },
65
+ async handler(ctx) {
66
+ const {
67
+ recipients,
68
+ entityRefs,
69
+ title,
70
+ info,
71
+ link,
72
+ severity,
73
+ scope,
74
+ optional
75
+ } = ctx.input;
76
+ ctx.logger.info(`Sending notification to ${recipients}`);
77
+ if (recipients === "entity" && !entityRefs) {
78
+ if (optional !== true) {
79
+ throw new Error("Entity references must be provided");
80
+ }
81
+ return;
82
+ }
83
+ const notificationRecipients = recipients === "broadcast" ? { type: "broadcast" } : { type: "entity", entityRef: entityRefs };
84
+ const payload = {
85
+ title,
86
+ description: info,
87
+ link,
88
+ severity,
89
+ scope
90
+ };
91
+ try {
92
+ await notifications.send({
93
+ recipients: notificationRecipients,
94
+ payload
95
+ });
96
+ } catch (e) {
97
+ ctx.logger.error(`Failed to send notification: ${e}`);
98
+ if (optional !== true) {
99
+ throw e;
100
+ }
101
+ }
102
+ }
103
+ });
104
+ }
105
+
106
+ exports.createSendNotificationAction = createSendNotificationAction;
107
+ //# sourceMappingURL=sendNotification.cjs.js.map
@@ -0,0 +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 recipients: notificationRecipients,\n payload,\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,CAAA;AAC1B,EAAA,OAAOA,yCASJ,CAAA;AAAA,IACD,EAAI,EAAA,mBAAA;AAAA,IACJ,WAAa,EAAA,gDAAA;AAAA,cACbC,kCAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAA,EAAU,CAAC,YAAA,EAAc,OAAO,CAAA;AAAA,QAChC,UAAY,EAAA;AAAA,UACV,UAAY,EAAA;AAAA,YACV,KAAO,EAAA,WAAA;AAAA,YACP,IAAA,EAAM,CAAC,WAAA,EAAa,QAAQ,CAAA;AAAA,YAC5B,WACE,EAAA,iHAAA;AAAA,YACF,IAAM,EAAA,QAAA;AAAA,WACR;AAAA,UACA,UAAY,EAAA;AAAA,YACV,KAAO,EAAA,mBAAA;AAAA,YACP,WACE,EAAA,0FAAA;AAAA,YACF,IAAM,EAAA,OAAA;AAAA,YACN,KAAO,EAAA;AAAA,cACL,IAAM,EAAA,QAAA;AAAA,aACR;AAAA,WACF;AAAA,UACA,KAAO,EAAA;AAAA,YACL,KAAO,EAAA,OAAA;AAAA,YACP,WAAa,EAAA,oBAAA;AAAA,YACb,IAAM,EAAA,QAAA;AAAA,WACR;AAAA,UACA,IAAM,EAAA;AAAA,YACJ,KAAO,EAAA,aAAA;AAAA,YACP,WAAa,EAAA,0BAAA;AAAA,YACb,IAAM,EAAA,QAAA;AAAA,WACR;AAAA,UACA,IAAM,EAAA;AAAA,YACJ,KAAO,EAAA,MAAA;AAAA,YACP,WAAa,EAAA,mB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KAAA;AAAA,QACA,WAAa,EAAA,IAAA;AAAA,QACb,IAAA;AAAA,QACA,QAAA;AAAA,QACA,KAAA;AAAA,OACF,CAAA;AAEA,MAAI,IAAA;AACF,QAAA,MAAM,cAAc,IAAK,CAAA;AAAA,UACvB,UAAY,EAAA,sBAAA;AAAA,UACZ,OAAA;AAAA,SACD,CAAA,CAAA;AAAA,eACM,CAAG,EAAA;AACV,QAAA,GAAA,CAAI,MAAO,CAAA,KAAA,CAAM,CAAgC,6BAAA,EAAA,CAAC,CAAE,CAAA,CAAA,CAAA;AACpD,QAAA,IAAI,aAAa,IAAM,EAAA;AACrB,UAAM,MAAA,CAAA,CAAA;AAAA,SACR;AAAA,OACF;AAAA,KACF;AAAA,GACD,CAAA,CAAA;AACH;;;;"}
@@ -0,0 +1,240 @@
1
+ 'use strict';
2
+
3
+ var yaml = require('yaml');
4
+
5
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
6
+
7
+ var yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml);
8
+
9
+ const examples = [
10
+ {
11
+ description: "Sends a notification with minimal options",
12
+ example: yaml__default.default.stringify({
13
+ steps: [
14
+ {
15
+ id: "sendNotification",
16
+ action: "notification:send",
17
+ name: "Send Notification",
18
+ input: {
19
+ recipients: "broadcast",
20
+ title: "Test notification"
21
+ }
22
+ }
23
+ ]
24
+ })
25
+ },
26
+ {
27
+ description: "Sends a notification with entity recipients and link",
28
+ example: yaml__default.default.stringify({
29
+ steps: [
30
+ {
31
+ id: "sendNotification",
32
+ action: "notification:send",
33
+ name: "Send Notification",
34
+ input: {
35
+ recipients: "entity",
36
+ entityRefs: ["entity:component:1"],
37
+ title: "Security Update",
38
+ info: "A security update has been applied. Please review.",
39
+ link: "https://example.com/security/update",
40
+ severity: "high",
41
+ scope: "internal"
42
+ }
43
+ }
44
+ ]
45
+ })
46
+ },
47
+ {
48
+ description: "Sends a notification with entity recipients and optional flag",
49
+ example: yaml__default.default.stringify({
50
+ steps: [
51
+ {
52
+ id: "sendNotification",
53
+ action: "notification:send",
54
+ name: "Send Notification",
55
+ input: {
56
+ recipients: "entity",
57
+ entityRefs: ["entity:component:1"],
58
+ title: "Weekly Update",
59
+ info: "Here is your weekly update.",
60
+ severity: "low",
61
+ optional: true
62
+ }
63
+ }
64
+ ]
65
+ })
66
+ },
67
+ {
68
+ description: "Sends a notification with broadcast recipients and custom scope",
69
+ example: yaml__default.default.stringify({
70
+ steps: [
71
+ {
72
+ id: "sendNotification",
73
+ action: "notification:send",
74
+ name: "Send Notification",
75
+ input: {
76
+ recipients: "broadcast",
77
+ title: "New Release Available",
78
+ info: "Version 2.0.0 is now available. Upgrade now!",
79
+ severity: "normal",
80
+ scope: "public"
81
+ }
82
+ }
83
+ ]
84
+ })
85
+ },
86
+ {
87
+ description: "Sends a notification with entity recipients and custom severity",
88
+ example: yaml__default.default.stringify({
89
+ steps: [
90
+ {
91
+ id: "sendNotification",
92
+ action: "notification:send",
93
+ name: "Send Notification",
94
+ input: {
95
+ recipients: "entity",
96
+ entityRefs: ["entity:component:1"],
97
+ title: "Critical Bug Found",
98
+ info: "A critical bug has been identified. Immediate action required.",
99
+ severity: "critical",
100
+ scope: "internal"
101
+ }
102
+ }
103
+ ]
104
+ })
105
+ },
106
+ {
107
+ description: "Sends a notification with broadcast recipients and no link",
108
+ example: yaml__default.default.stringify({
109
+ steps: [
110
+ {
111
+ id: "sendNotification",
112
+ action: "notification:send",
113
+ name: "Send Notification",
114
+ input: {
115
+ recipients: "broadcast",
116
+ title: "Server Maintenance Scheduled",
117
+ info: "Server maintenance will occur tonight at 11 PM.",
118
+ severity: "normal",
119
+ scope: "internal"
120
+ }
121
+ }
122
+ ]
123
+ })
124
+ },
125
+ {
126
+ description: "Sends a notification with broadcast recipients and optional flag",
127
+ example: yaml__default.default.stringify({
128
+ steps: [
129
+ {
130
+ id: "sendNotification",
131
+ action: "notification:send",
132
+ name: "Send Notification",
133
+ input: {
134
+ recipients: "broadcast",
135
+ title: "New Feature Deployment",
136
+ info: "New features have been deployed. Explore them now!",
137
+ severity: "normal",
138
+ optional: true
139
+ }
140
+ }
141
+ ]
142
+ })
143
+ },
144
+ {
145
+ description: "Sends a notification with broadcast recipients and no description",
146
+ example: yaml__default.default.stringify({
147
+ steps: [
148
+ {
149
+ id: "sendNotification",
150
+ action: "notification:send",
151
+ name: "Send Notification",
152
+ input: {
153
+ recipients: "broadcast",
154
+ title: "Holiday Office Closure",
155
+ severity: "low",
156
+ scope: "internal"
157
+ }
158
+ }
159
+ ]
160
+ })
161
+ },
162
+ {
163
+ description: "Sends a notification with broadcast recipients and no severity",
164
+ example: yaml__default.default.stringify({
165
+ steps: [
166
+ {
167
+ id: "sendNotification",
168
+ action: "notification:send",
169
+ name: "Send Notification",
170
+ input: {
171
+ recipients: "broadcast",
172
+ title: "Reminder: Weekly Meeting Tomorrow",
173
+ info: "Don't forget, the weekly meeting is scheduled for tomorrow.",
174
+ scope: "internal"
175
+ }
176
+ }
177
+ ]
178
+ })
179
+ },
180
+ {
181
+ description: "Sends a notification with broadcast recipients and no scope",
182
+ example: yaml__default.default.stringify({
183
+ steps: [
184
+ {
185
+ id: "sendNotification",
186
+ action: "notification:send",
187
+ name: "Send Notification",
188
+ input: {
189
+ recipients: "broadcast",
190
+ title: "Important Announcement",
191
+ info: "Please read the latest announcement regarding the upcoming changes.",
192
+ severity: "high"
193
+ }
194
+ }
195
+ ]
196
+ })
197
+ },
198
+ {
199
+ description: "Sends a notification with optional parameters",
200
+ example: yaml__default.default.stringify({
201
+ steps: [
202
+ {
203
+ id: "sendNotification",
204
+ action: "notification:send",
205
+ name: "Send Notification",
206
+ input: {
207
+ recipients: "broadcast",
208
+ title: "Broadcast Notification",
209
+ info: "This is a broadcast notification",
210
+ severity: "low",
211
+ optional: true
212
+ }
213
+ }
214
+ ]
215
+ })
216
+ },
217
+ {
218
+ description: "Sends a notification with entity recipients and optional set to false",
219
+ example: yaml__default.default.stringify({
220
+ steps: [
221
+ {
222
+ id: "sendNotification",
223
+ action: "notification:send",
224
+ name: "Send Notification to Entity",
225
+ input: {
226
+ recipients: "entity",
227
+ entityRefs: ["entity:service1"],
228
+ title: "Entity Notification",
229
+ info: "This is a notification for entity service1",
230
+ severity: "normal",
231
+ optional: false
232
+ }
233
+ }
234
+ ]
235
+ })
236
+ }
237
+ ];
238
+
239
+ exports.examples = examples;
240
+ //# sourceMappingURL=sendNotification.examples.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sendNotification.examples.cjs.js","sources":["../../src/actions/sendNotification.examples.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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Sends a notification with minimal options',\n example: yaml.stringify({\n steps: [\n {\n id: 'sendNotification',\n action: 'notification:send',\n name: 'Send Notification',\n input: {\n recipients: 'broadcast',\n title: 'Test notification',\n },\n },\n ],\n }),\n },\n {\n description: 'Sends a notification with entity recipients and link',\n example: yaml.stringify({\n steps: [\n {\n id: 'sendNotification',\n action: 'notification:send',\n name: 'Send Notification',\n input: {\n recipients: 'entity',\n entityRefs: ['entity:component:1'],\n title: 'Security Update',\n info: 'A security update has been applied. Please review.',\n link: 'https://example.com/security/update',\n severity: 'high',\n scope: 'internal',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Sends a notification with entity recipients and optional flag',\n example: yaml.stringify({\n steps: [\n {\n id: 'sendNotification',\n action: 'notification:send',\n name: 'Send Notification',\n input: {\n recipients: 'entity',\n entityRefs: ['entity:component:1'],\n title: 'Weekly Update',\n info: 'Here is your weekly update.',\n severity: 'low',\n optional: true,\n },\n },\n ],\n }),\n },\n {\n description:\n 'Sends a notification with broadcast recipients and custom scope',\n example: yaml.stringify({\n steps: [\n {\n id: 'sendNotification',\n action: 'notification:send',\n name: 'Send Notification',\n input: {\n recipients: 'broadcast',\n title: 'New Release Available',\n info: 'Version 2.0.0 is now available. Upgrade now!',\n severity: 'normal',\n scope: 'public',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Sends a notification with entity recipients and custom severity',\n example: yaml.stringify({\n steps: [\n {\n id: 'sendNotification',\n action: 'notification:send',\n name: 'Send Notification',\n input: {\n recipients: 'entity',\n entityRefs: ['entity:component:1'],\n title: 'Critical Bug Found',\n info: 'A critical bug has been identified. Immediate action required.',\n severity: 'critical',\n scope: 'internal',\n },\n },\n ],\n }),\n },\n {\n description: 'Sends a notification with broadcast recipients and no link',\n example: yaml.stringify({\n steps: [\n {\n id: 'sendNotification',\n action: 'notification:send',\n name: 'Send Notification',\n input: {\n recipients: 'broadcast',\n title: 'Server Maintenance Scheduled',\n info: 'Server maintenance will occur tonight at 11 PM.',\n severity: 'normal',\n scope: 'internal',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Sends a notification with broadcast recipients and optional flag',\n example: yaml.stringify({\n steps: [\n {\n id: 'sendNotification',\n action: 'notification:send',\n name: 'Send Notification',\n input: {\n recipients: 'broadcast',\n title: 'New Feature Deployment',\n info: 'New features have been deployed. Explore them now!',\n severity: 'normal',\n optional: true,\n },\n },\n ],\n }),\n },\n {\n description:\n 'Sends a notification with broadcast recipients and no description',\n example: yaml.stringify({\n steps: [\n {\n id: 'sendNotification',\n action: 'notification:send',\n name: 'Send Notification',\n input: {\n recipients: 'broadcast',\n title: 'Holiday Office Closure',\n severity: 'low',\n scope: 'internal',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Sends a notification with broadcast recipients and no severity',\n example: yaml.stringify({\n steps: [\n {\n id: 'sendNotification',\n action: 'notification:send',\n name: 'Send Notification',\n input: {\n recipients: 'broadcast',\n title: 'Reminder: Weekly Meeting Tomorrow',\n info: \"Don't forget, the weekly meeting is scheduled for tomorrow.\",\n scope: 'internal',\n },\n },\n ],\n }),\n },\n {\n description: 'Sends a notification with broadcast recipients and no scope',\n example: yaml.stringify({\n steps: [\n {\n id: 'sendNotification',\n action: 'notification:send',\n name: 'Send Notification',\n input: {\n recipients: 'broadcast',\n title: 'Important Announcement',\n info: 'Please read the latest announcement regarding the upcoming changes.',\n severity: 'high',\n },\n },\n ],\n }),\n },\n {\n description: 'Sends a notification with optional parameters',\n example: yaml.stringify({\n steps: [\n {\n id: 'sendNotification',\n action: 'notification:send',\n name: 'Send Notification',\n input: {\n recipients: 'broadcast',\n title: 'Broadcast Notification',\n info: 'This is a broadcast notification',\n severity: 'low',\n optional: true,\n },\n },\n ],\n }),\n },\n {\n description:\n 'Sends a notification with entity recipients and optional set to false',\n example: yaml.stringify({\n steps: [\n {\n id: 'sendNotification',\n action: 'notification:send',\n name: 'Send Notification to Entity',\n input: {\n recipients: 'entity',\n entityRefs: ['entity:service1'],\n title: 'Entity Notification',\n info: 'This is a notification for entity service1',\n severity: 'normal',\n optional: false,\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,2CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,kBAAA;AAAA,UACJ,MAAQ,EAAA,mBAAA;AAAA,UACR,IAAM,EAAA,mBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,UAAY,EAAA,WAAA;AAAA,YACZ,KAAO,EAAA,mBAAA;AAAA,WACT;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAA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KACD,CAAA;AAAA,GACH;AACF;;;;"}
package/dist/index.cjs.js CHANGED
@@ -2,362 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
6
- var yaml = require('yaml');
7
- var backendPluginApi = require('@backstage/backend-plugin-api');
8
- var pluginNotificationsNode = require('@backstage/plugin-notifications-node');
9
- var alpha = require('@backstage/plugin-scaffolder-node/alpha');
5
+ var sendNotification = require('./actions/sendNotification.cjs.js');
6
+ var module$1 = require('./module.cjs.js');
10
7
 
11
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
12
8
 
13
- var yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml);
14
9
 
15
- const examples = [
16
- {
17
- description: "Sends a notification with minimal options",
18
- example: yaml__default.default.stringify({
19
- steps: [
20
- {
21
- id: "sendNotification",
22
- action: "notification:send",
23
- name: "Send Notification",
24
- input: {
25
- recipients: "broadcast",
26
- title: "Test notification"
27
- }
28
- }
29
- ]
30
- })
31
- },
32
- {
33
- description: "Sends a notification with entity recipients and link",
34
- example: yaml__default.default.stringify({
35
- steps: [
36
- {
37
- id: "sendNotification",
38
- action: "notification:send",
39
- name: "Send Notification",
40
- input: {
41
- recipients: "entity",
42
- entityRefs: ["entity:component:1"],
43
- title: "Security Update",
44
- info: "A security update has been applied. Please review.",
45
- link: "https://example.com/security/update",
46
- severity: "high",
47
- scope: "internal"
48
- }
49
- }
50
- ]
51
- })
52
- },
53
- {
54
- description: "Sends a notification with entity recipients and optional flag",
55
- example: yaml__default.default.stringify({
56
- steps: [
57
- {
58
- id: "sendNotification",
59
- action: "notification:send",
60
- name: "Send Notification",
61
- input: {
62
- recipients: "entity",
63
- entityRefs: ["entity:component:1"],
64
- title: "Weekly Update",
65
- info: "Here is your weekly update.",
66
- severity: "low",
67
- optional: true
68
- }
69
- }
70
- ]
71
- })
72
- },
73
- {
74
- description: "Sends a notification with broadcast recipients and custom scope",
75
- example: yaml__default.default.stringify({
76
- steps: [
77
- {
78
- id: "sendNotification",
79
- action: "notification:send",
80
- name: "Send Notification",
81
- input: {
82
- recipients: "broadcast",
83
- title: "New Release Available",
84
- info: "Version 2.0.0 is now available. Upgrade now!",
85
- severity: "normal",
86
- scope: "public"
87
- }
88
- }
89
- ]
90
- })
91
- },
92
- {
93
- description: "Sends a notification with entity recipients and custom severity",
94
- example: yaml__default.default.stringify({
95
- steps: [
96
- {
97
- id: "sendNotification",
98
- action: "notification:send",
99
- name: "Send Notification",
100
- input: {
101
- recipients: "entity",
102
- entityRefs: ["entity:component:1"],
103
- title: "Critical Bug Found",
104
- info: "A critical bug has been identified. Immediate action required.",
105
- severity: "critical",
106
- scope: "internal"
107
- }
108
- }
109
- ]
110
- })
111
- },
112
- {
113
- description: "Sends a notification with broadcast recipients and no link",
114
- example: yaml__default.default.stringify({
115
- steps: [
116
- {
117
- id: "sendNotification",
118
- action: "notification:send",
119
- name: "Send Notification",
120
- input: {
121
- recipients: "broadcast",
122
- title: "Server Maintenance Scheduled",
123
- info: "Server maintenance will occur tonight at 11 PM.",
124
- severity: "normal",
125
- scope: "internal"
126
- }
127
- }
128
- ]
129
- })
130
- },
131
- {
132
- description: "Sends a notification with broadcast recipients and optional flag",
133
- example: yaml__default.default.stringify({
134
- steps: [
135
- {
136
- id: "sendNotification",
137
- action: "notification:send",
138
- name: "Send Notification",
139
- input: {
140
- recipients: "broadcast",
141
- title: "New Feature Deployment",
142
- info: "New features have been deployed. Explore them now!",
143
- severity: "normal",
144
- optional: true
145
- }
146
- }
147
- ]
148
- })
149
- },
150
- {
151
- description: "Sends a notification with broadcast recipients and no description",
152
- example: yaml__default.default.stringify({
153
- steps: [
154
- {
155
- id: "sendNotification",
156
- action: "notification:send",
157
- name: "Send Notification",
158
- input: {
159
- recipients: "broadcast",
160
- title: "Holiday Office Closure",
161
- severity: "low",
162
- scope: "internal"
163
- }
164
- }
165
- ]
166
- })
167
- },
168
- {
169
- description: "Sends a notification with broadcast recipients and no severity",
170
- example: yaml__default.default.stringify({
171
- steps: [
172
- {
173
- id: "sendNotification",
174
- action: "notification:send",
175
- name: "Send Notification",
176
- input: {
177
- recipients: "broadcast",
178
- title: "Reminder: Weekly Meeting Tomorrow",
179
- info: "Don't forget, the weekly meeting is scheduled for tomorrow.",
180
- scope: "internal"
181
- }
182
- }
183
- ]
184
- })
185
- },
186
- {
187
- description: "Sends a notification with broadcast recipients and no scope",
188
- example: yaml__default.default.stringify({
189
- steps: [
190
- {
191
- id: "sendNotification",
192
- action: "notification:send",
193
- name: "Send Notification",
194
- input: {
195
- recipients: "broadcast",
196
- title: "Important Announcement",
197
- info: "Please read the latest announcement regarding the upcoming changes.",
198
- severity: "high"
199
- }
200
- }
201
- ]
202
- })
203
- },
204
- {
205
- description: "Sends a notification with optional parameters",
206
- example: yaml__default.default.stringify({
207
- steps: [
208
- {
209
- id: "sendNotification",
210
- action: "notification:send",
211
- name: "Send Notification",
212
- input: {
213
- recipients: "broadcast",
214
- title: "Broadcast Notification",
215
- info: "This is a broadcast notification",
216
- severity: "low",
217
- optional: true
218
- }
219
- }
220
- ]
221
- })
222
- },
223
- {
224
- description: "Sends a notification with entity recipients and optional set to false",
225
- example: yaml__default.default.stringify({
226
- steps: [
227
- {
228
- id: "sendNotification",
229
- action: "notification:send",
230
- name: "Send Notification to Entity",
231
- input: {
232
- recipients: "entity",
233
- entityRefs: ["entity:service1"],
234
- title: "Entity Notification",
235
- info: "This is a notification for entity service1",
236
- severity: "normal",
237
- optional: false
238
- }
239
- }
240
- ]
241
- })
242
- }
243
- ];
244
-
245
- function createSendNotificationAction(options) {
246
- const { notifications } = options;
247
- return pluginScaffolderNode.createTemplateAction({
248
- id: "notification:send",
249
- description: "Sends a notification using NotificationService",
250
- examples,
251
- schema: {
252
- input: {
253
- type: "object",
254
- required: ["recipients", "title"],
255
- properties: {
256
- recipients: {
257
- title: "Recipient",
258
- enum: ["broadcast", "entity"],
259
- description: "The recipient of the notification, either broadcast or entity. If using entity, also entityRef must be provided",
260
- type: "string"
261
- },
262
- entityRefs: {
263
- title: "Entity references",
264
- description: "The entity references to send the notification to, required if using recipient of entity",
265
- type: "array",
266
- items: {
267
- type: "string"
268
- }
269
- },
270
- title: {
271
- title: "Title",
272
- description: "Notification title",
273
- type: "string"
274
- },
275
- info: {
276
- title: "Description",
277
- description: "Notification description",
278
- type: "string"
279
- },
280
- link: {
281
- title: "Link",
282
- description: "Notification link",
283
- type: "string"
284
- },
285
- severity: {
286
- title: "Severity",
287
- type: "string",
288
- description: `Notification severity`,
289
- enum: ["low", "normal", "high", "critical"]
290
- },
291
- scope: {
292
- title: "Scope",
293
- description: "Notification scope",
294
- type: "string"
295
- },
296
- optional: {
297
- title: "Optional",
298
- description: "Do not fail the action if the notification sending fails",
299
- type: "boolean"
300
- }
301
- }
302
- }
303
- },
304
- async handler(ctx) {
305
- const {
306
- recipients,
307
- entityRefs,
308
- title,
309
- info,
310
- link,
311
- severity,
312
- scope,
313
- optional
314
- } = ctx.input;
315
- ctx.logger.info(`Sending notification to ${recipients}`);
316
- if (recipients === "entity" && !entityRefs) {
317
- if (optional !== true) {
318
- throw new Error("Entity references must be provided");
319
- }
320
- return;
321
- }
322
- const notificationRecipients = recipients === "broadcast" ? { type: "broadcast" } : { type: "entity", entityRef: entityRefs };
323
- const payload = {
324
- title,
325
- description: info,
326
- link,
327
- severity,
328
- scope
329
- };
330
- try {
331
- await notifications.send({
332
- recipients: notificationRecipients,
333
- payload
334
- });
335
- } catch (e) {
336
- ctx.logger.error(`Failed to send notification: ${e}`);
337
- if (optional !== true) {
338
- throw e;
339
- }
340
- }
341
- }
342
- });
343
- }
344
-
345
- const scaffolderModuleNotifications = backendPluginApi.createBackendModule({
346
- pluginId: "scaffolder",
347
- moduleId: "notifications",
348
- register(reg) {
349
- reg.registerInit({
350
- deps: {
351
- notifications: pluginNotificationsNode.notificationService,
352
- scaffolder: alpha.scaffolderActionsExtensionPoint
353
- },
354
- async init({ notifications, scaffolder }) {
355
- scaffolder.addActions(createSendNotificationAction({ notifications }));
356
- }
357
- });
358
- }
359
- });
360
-
361
- exports.createSendNotificationAction = createSendNotificationAction;
362
- exports.default = scaffolderModuleNotifications;
10
+ exports.createSendNotificationAction = sendNotification.createSendNotificationAction;
11
+ exports.default = module$1.scaffolderModuleNotifications;
363
12
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/actions/sendNotification.examples.ts","../src/actions/sendNotification.ts","../src/module.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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Sends a notification with minimal options',\n example: yaml.stringify({\n steps: [\n {\n id: 'sendNotification',\n action: 'notification:send',\n name: 'Send Notification',\n input: {\n recipients: 'broadcast',\n title: 'Test notification',\n },\n },\n ],\n }),\n },\n {\n description: 'Sends a notification with entity recipients and link',\n example: yaml.stringify({\n steps: [\n {\n id: 'sendNotification',\n action: 'notification:send',\n name: 'Send Notification',\n input: {\n recipients: 'entity',\n entityRefs: ['entity:component:1'],\n title: 'Security Update',\n info: 'A security update has been applied. Please review.',\n link: 'https://example.com/security/update',\n severity: 'high',\n scope: 'internal',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Sends a notification with entity recipients and optional flag',\n example: yaml.stringify({\n steps: [\n {\n id: 'sendNotification',\n action: 'notification:send',\n name: 'Send Notification',\n input: {\n recipients: 'entity',\n entityRefs: ['entity:component:1'],\n title: 'Weekly Update',\n info: 'Here is your weekly update.',\n severity: 'low',\n optional: true,\n },\n },\n ],\n }),\n },\n {\n description:\n 'Sends a notification with broadcast recipients and custom scope',\n example: yaml.stringify({\n steps: [\n {\n id: 'sendNotification',\n action: 'notification:send',\n name: 'Send Notification',\n input: {\n recipients: 'broadcast',\n title: 'New Release Available',\n info: 'Version 2.0.0 is now available. Upgrade now!',\n severity: 'normal',\n scope: 'public',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Sends a notification with entity recipients and custom severity',\n example: yaml.stringify({\n steps: [\n {\n id: 'sendNotification',\n action: 'notification:send',\n name: 'Send Notification',\n input: {\n recipients: 'entity',\n entityRefs: ['entity:component:1'],\n title: 'Critical Bug Found',\n info: 'A critical bug has been identified. Immediate action required.',\n severity: 'critical',\n scope: 'internal',\n },\n },\n ],\n }),\n },\n {\n description: 'Sends a notification with broadcast recipients and no link',\n example: yaml.stringify({\n steps: [\n {\n id: 'sendNotification',\n action: 'notification:send',\n name: 'Send Notification',\n input: {\n recipients: 'broadcast',\n title: 'Server Maintenance Scheduled',\n info: 'Server maintenance will occur tonight at 11 PM.',\n severity: 'normal',\n scope: 'internal',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Sends a notification with broadcast recipients and optional flag',\n example: yaml.stringify({\n steps: [\n {\n id: 'sendNotification',\n action: 'notification:send',\n name: 'Send Notification',\n input: {\n recipients: 'broadcast',\n title: 'New Feature Deployment',\n info: 'New features have been deployed. Explore them now!',\n severity: 'normal',\n optional: true,\n },\n },\n ],\n }),\n },\n {\n description:\n 'Sends a notification with broadcast recipients and no description',\n example: yaml.stringify({\n steps: [\n {\n id: 'sendNotification',\n action: 'notification:send',\n name: 'Send Notification',\n input: {\n recipients: 'broadcast',\n title: 'Holiday Office Closure',\n severity: 'low',\n scope: 'internal',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Sends a notification with broadcast recipients and no severity',\n example: yaml.stringify({\n steps: [\n {\n id: 'sendNotification',\n action: 'notification:send',\n name: 'Send Notification',\n input: {\n recipients: 'broadcast',\n title: 'Reminder: Weekly Meeting Tomorrow',\n info: \"Don't forget, the weekly meeting is scheduled for tomorrow.\",\n scope: 'internal',\n },\n },\n ],\n }),\n },\n {\n description: 'Sends a notification with broadcast recipients and no scope',\n example: yaml.stringify({\n steps: [\n {\n id: 'sendNotification',\n action: 'notification:send',\n name: 'Send Notification',\n input: {\n recipients: 'broadcast',\n title: 'Important Announcement',\n info: 'Please read the latest announcement regarding the upcoming changes.',\n severity: 'high',\n },\n },\n ],\n }),\n },\n {\n description: 'Sends a notification with optional parameters',\n example: yaml.stringify({\n steps: [\n {\n id: 'sendNotification',\n action: 'notification:send',\n name: 'Send Notification',\n input: {\n recipients: 'broadcast',\n title: 'Broadcast Notification',\n info: 'This is a broadcast notification',\n severity: 'low',\n optional: true,\n },\n },\n ],\n }),\n },\n {\n description:\n 'Sends a notification with entity recipients and optional set to false',\n example: yaml.stringify({\n steps: [\n {\n id: 'sendNotification',\n action: 'notification:send',\n name: 'Send Notification to Entity',\n input: {\n recipients: 'entity',\n entityRefs: ['entity:service1'],\n title: 'Entity Notification',\n info: 'This is a notification for entity service1',\n severity: 'normal',\n optional: false,\n },\n },\n ],\n }),\n },\n];\n","/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\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 recipients: notificationRecipients,\n payload,\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","/*\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 { createBackendModule } from '@backstage/backend-plugin-api';\nimport { notificationService } from '@backstage/plugin-notifications-node';\nimport { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';\nimport { createSendNotificationAction } from './actions';\n\n/**\n * @public\n * The Notifications module for the Scaffolder Backend\n */\nexport const scaffolderModuleNotifications = createBackendModule({\n pluginId: 'scaffolder',\n moduleId: 'notifications',\n register(reg) {\n reg.registerInit({\n deps: {\n notifications: notificationService,\n scaffolder: scaffolderActionsExtensionPoint,\n },\n async init({ notifications, scaffolder }) {\n scaffolder.addActions(createSendNotificationAction({ notifications }));\n },\n });\n },\n});\n"],"names":["yaml","createTemplateAction","createBackendModule","notificationService","scaffolderActionsExtensionPoint"],"mappings":";;;;;;;;;;;;;;AAmBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,2CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,kBAAA;AAAA,UACJ,MAAQ,EAAA,mBAAA;AAAA,UACR,IAAM,EAAA,mBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,UAAY,EAAA,WAAA;AAAA,YACZ,KAAO,EAAA,mBAAA;AAAA,WACT;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,sDAAA;AAAA,IACb,OAAA,EAASA,sBAAK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ACD,CAAA,CAAA;AAAA,eACM,CAAG,EAAA;AACV,QAAA,GAAA,CAAI,MAAO,CAAA,KAAA,CAAM,CAAgC,6BAAA,EAAA,CAAC,CAAE,CAAA,CAAA,CAAA;AACpD,QAAA,IAAI,aAAa,IAAM,EAAA;AACrB,UAAM,MAAA,CAAA,CAAA;AAAA,SACR;AAAA,OACF;AAAA,KACF;AAAA,GACD,CAAA,CAAA;AACH;;AC3HO,MAAM,gCAAgCC,oCAAoB,CAAA;AAAA,EAC/D,QAAU,EAAA,YAAA;AAAA,EACV,QAAU,EAAA,eAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,aAAe,EAAAC,2CAAA;AAAA,QACf,UAAY,EAAAC,qCAAA;AAAA,OACd;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,aAAA,EAAe,YAAc,EAAA;AACxC,QAAA,UAAA,CAAW,UAAW,CAAA,4BAAA,CAA6B,EAAE,aAAA,EAAe,CAAC,CAAA,CAAA;AAAA,OACvE;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ var backendPluginApi = require('@backstage/backend-plugin-api');
4
+ var pluginNotificationsNode = require('@backstage/plugin-notifications-node');
5
+ var alpha = require('@backstage/plugin-scaffolder-node/alpha');
6
+ var sendNotification = require('./actions/sendNotification.cjs.js');
7
+
8
+ const scaffolderModuleNotifications = backendPluginApi.createBackendModule({
9
+ pluginId: "scaffolder",
10
+ moduleId: "notifications",
11
+ register(reg) {
12
+ reg.registerInit({
13
+ deps: {
14
+ notifications: pluginNotificationsNode.notificationService,
15
+ scaffolder: alpha.scaffolderActionsExtensionPoint
16
+ },
17
+ async init({ notifications, scaffolder }) {
18
+ scaffolder.addActions(sendNotification.createSendNotificationAction({ notifications }));
19
+ }
20
+ });
21
+ }
22
+ });
23
+
24
+ exports.scaffolderModuleNotifications = scaffolderModuleNotifications;
25
+ //# sourceMappingURL=module.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.cjs.js","sources":["../src/module.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 { createBackendModule } from '@backstage/backend-plugin-api';\nimport { notificationService } from '@backstage/plugin-notifications-node';\nimport { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';\nimport { createSendNotificationAction } from './actions';\n\n/**\n * @public\n * The Notifications module for the Scaffolder Backend\n */\nexport const scaffolderModuleNotifications = createBackendModule({\n pluginId: 'scaffolder',\n moduleId: 'notifications',\n register(reg) {\n reg.registerInit({\n deps: {\n notifications: notificationService,\n scaffolder: scaffolderActionsExtensionPoint,\n },\n async init({ notifications, scaffolder }) {\n scaffolder.addActions(createSendNotificationAction({ notifications }));\n },\n });\n },\n});\n"],"names":["createBackendModule","notificationService","scaffolderActionsExtensionPoint","createSendNotificationAction"],"mappings":";;;;;;;AAwBO,MAAM,gCAAgCA,oCAAoB,CAAA;AAAA,EAC/D,QAAU,EAAA,YAAA;AAAA,EACV,QAAU,EAAA,eAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,aAAe,EAAAC,2CAAA;AAAA,QACf,UAAY,EAAAC,qCAAA;AAAA,OACd;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,aAAA,EAAe,YAAc,EAAA;AACxC,QAAA,UAAA,CAAW,UAAW,CAAAC,6CAAA,CAA6B,EAAE,aAAA,EAAe,CAAC,CAAA,CAAA;AAAA,OACvE;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend-module-notifications",
3
- "version": "0.1.1-next.1",
3
+ "version": "0.1.1-next.2",
4
4
  "description": "The notifications backend module for the scaffolder plugin.",
5
5
  "backstage": {
6
6
  "role": "backend-plugin-module",
@@ -34,15 +34,15 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@backstage/backend-common": "^0.25.0",
37
- "@backstage/backend-plugin-api": "1.0.1-next.0",
37
+ "@backstage/backend-plugin-api": "1.0.1-next.1",
38
38
  "@backstage/plugin-notifications-common": "0.0.5",
39
- "@backstage/plugin-notifications-node": "0.2.7-next.0",
40
- "@backstage/plugin-scaffolder-node": "0.5.0-next.1",
39
+ "@backstage/plugin-notifications-node": "0.2.7-next.1",
40
+ "@backstage/plugin-scaffolder-node": "0.5.0-next.2",
41
41
  "octokit": "^3.0.0",
42
42
  "yaml": "^2.0.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@backstage/cli": "0.28.0-next.1",
46
- "@backstage/plugin-scaffolder-node-test-utils": "0.1.13-next.1"
45
+ "@backstage/cli": "0.28.0-next.2",
46
+ "@backstage/plugin-scaffolder-node-test-utils": "0.1.13-next.2"
47
47
  }
48
48
  }