@backstage/plugin-scaffolder-backend-module-notifications 0.1.10-next.1 → 0.1.10-next.3
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 +21 -0
- package/dist/actions/sendNotification.cjs.js +14 -49
- package/dist/actions/sendNotification.cjs.js.map +1 -1
- package/dist/index.d.ts +10 -10
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend-module-notifications
|
|
2
2
|
|
|
3
|
+
## 0.1.10-next.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/plugin-scaffolder-node@0.8.2-next.3
|
|
9
|
+
- @backstage/backend-plugin-api@1.3.1-next.2
|
|
10
|
+
- @backstage/plugin-notifications-common@0.0.8
|
|
11
|
+
- @backstage/plugin-notifications-node@0.2.15-next.2
|
|
12
|
+
|
|
13
|
+
## 0.1.10-next.2
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- b60253d: Change notification send scaffolder action to use native zod schemas
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
- @backstage/plugin-notifications-node@0.2.15-next.1
|
|
20
|
+
- @backstage/plugin-scaffolder-node@0.8.2-next.2
|
|
21
|
+
- @backstage/backend-plugin-api@1.3.1-next.1
|
|
22
|
+
- @backstage/plugin-notifications-common@0.0.8
|
|
23
|
+
|
|
3
24
|
## 0.1.10-next.1
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
|
@@ -11,55 +11,20 @@ function createSendNotificationAction(options) {
|
|
|
11
11
|
examples: sendNotification_examples.examples,
|
|
12
12
|
schema: {
|
|
13
13
|
input: {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
}
|
|
14
|
+
recipients: (z) => z.enum(["broadcast", "entity"]).describe(
|
|
15
|
+
"The recipient of the notification, either broadcast or entity. If using entity, also entityRef must be provided"
|
|
16
|
+
),
|
|
17
|
+
entityRefs: (z) => z.array(z.string()).optional().describe(
|
|
18
|
+
"The entity references to send the notification to, required if using recipient of entity"
|
|
19
|
+
),
|
|
20
|
+
title: (z) => z.string().describe("Notification title"),
|
|
21
|
+
info: (z) => z.string().optional().describe("Notification description"),
|
|
22
|
+
link: (z) => z.string().optional().describe("Notification link"),
|
|
23
|
+
severity: (z) => z.enum(["low", "normal", "high", "critical"]).optional().describe("Notification severity"),
|
|
24
|
+
scope: (z) => z.string().optional().describe("Notification scope"),
|
|
25
|
+
optional: (z) => z.boolean().optional().describe(
|
|
26
|
+
"Do not fail the action if the notification sending fails"
|
|
27
|
+
)
|
|
63
28
|
}
|
|
64
29
|
},
|
|
65
30
|
async handler(ctx) {
|
|
@@ -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 {
|
|
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 { NotificationPayload } 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 id: 'notification:send',\n description: 'Sends a notification using NotificationService',\n examples,\n schema: {\n input: {\n recipients: z =>\n z\n .enum(['broadcast', 'entity'])\n .describe(\n 'The recipient of the notification, either broadcast or entity. If using entity, also entityRef must be provided',\n ),\n entityRefs: z =>\n z\n .array(z.string())\n .optional()\n .describe(\n 'The entity references to send the notification to, required if using recipient of entity',\n ),\n title: z => z.string().describe('Notification title'),\n info: z => z.string().optional().describe('Notification description'),\n link: z => z.string().optional().describe('Notification link'),\n severity: z =>\n z\n .enum(['low', 'normal', 'high', 'critical'])\n .optional()\n .describe('Notification severity'),\n scope: z => z.string().optional().describe('Notification scope'),\n optional: z =>\n z\n .boolean()\n .optional()\n .describe(\n 'Do not fail the action if the notification sending fails',\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":";;;;;AA0BO,SAAS,6BAA6B,OAE1C,EAAA;AACD,EAAM,MAAA,EAAE,eAAkB,GAAA,OAAA;AAC1B,EAAA,OAAOA,yCAAqB,CAAA;AAAA,IAC1B,EAAI,EAAA,mBAAA;AAAA,IACJ,WAAa,EAAA,gDAAA;AAAA,cACbC,kCAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,UAAA,EAAY,OACV,CACG,CAAA,IAAA,CAAK,CAAC,WAAa,EAAA,QAAQ,CAAC,CAC5B,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I,MAAM,oCAAoC,CAAA;AAAA;AAEtD,QAAA;AAAA;AAGF,MAAM,MAAA,sBAAA,GACJ,UAAe,KAAA,WAAA,GACX,EAAE,IAAA,EAAM,WAAY,EAAA,GACpB,EAAE,IAAA,EAAM,QAAU,EAAA,SAAA,EAAW,UAAY,EAAA;AAC/C,MAAA,MAAM,OAA+B,GAAA;AAAA,QACnC,KAAA;AAAA,QACA,WAAa,EAAA,IAAA;AAAA,QACb,IAAA;AAAA,QACA,QAAA;AAAA,QACA;AAAA,OACF;AAEA,MAAI,IAAA;AACF,QAAA,MAAM,IAAI,UAAW,CAAA;AAAA,UACnB,GAAA,EAAK,CAAqB,kBAAA,EAAA,OAAA,CAAQ,KAAK,CAAA,CAAA;AAAA,UACvC,IAAI,YAAY;AACd,YAAA,MAAM,cAAc,IAAK,CAAA;AAAA,cACvB,UAAY,EAAA,sBAAA;AAAA,cACZ;AAAA,aACD,CAAA;AAAA;AACH,SACD,CAAA;AAAA,eACM,CAAG,EAAA;AACV,QAAA,GAAA,CAAI,MAAO,CAAA,KAAA,CAAM,CAAgC,6BAAA,EAAA,CAAC,CAAE,CAAA,CAAA;AACpD,QAAA,IAAI,aAAa,IAAM,EAAA;AACrB,UAAM,MAAA,CAAA;AAAA;AACR;AACF;AACF,GACD,CAAA;AACH;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as _backstage_plugin_scaffolder_node from '@backstage/plugin-scaffolder-node';
|
|
2
|
-
import * as _backstage_types from '@backstage/types';
|
|
3
2
|
import { NotificationService } from '@backstage/plugin-notifications-node';
|
|
4
|
-
import { NotificationSeverity } from '@backstage/plugin-notifications-common';
|
|
5
3
|
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
6
4
|
|
|
7
5
|
/**
|
|
@@ -10,15 +8,17 @@ import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
|
10
8
|
declare function createSendNotificationAction(options: {
|
|
11
9
|
notifications: NotificationService;
|
|
12
10
|
}): _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
13
|
-
recipients:
|
|
14
|
-
entityRefs?: string[];
|
|
11
|
+
recipients: "entity" | "broadcast";
|
|
15
12
|
title: string;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
entityRefs?: string[] | undefined;
|
|
14
|
+
info?: string | undefined;
|
|
15
|
+
link?: string | undefined;
|
|
16
|
+
severity?: "normal" | "high" | "low" | "critical" | undefined;
|
|
17
|
+
scope?: string | undefined;
|
|
18
|
+
optional?: boolean | undefined;
|
|
19
|
+
}, {
|
|
20
|
+
[x: string]: any;
|
|
21
|
+
}, "v2">;
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* @public
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-scaffolder-backend-module-notifications",
|
|
3
|
-
"version": "0.1.10-next.
|
|
3
|
+
"version": "0.1.10-next.3",
|
|
4
4
|
"description": "The notifications backend module for the scaffolder plugin.",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin-module",
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
"test": "backstage-cli package test"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@backstage/backend-plugin-api": "1.3.1-next.
|
|
39
|
+
"@backstage/backend-plugin-api": "1.3.1-next.2",
|
|
40
40
|
"@backstage/plugin-notifications-common": "0.0.8",
|
|
41
|
-
"@backstage/plugin-notifications-node": "0.2.15-next.
|
|
42
|
-
"@backstage/plugin-scaffolder-node": "0.8.2-next.
|
|
41
|
+
"@backstage/plugin-notifications-node": "0.2.15-next.2",
|
|
42
|
+
"@backstage/plugin-scaffolder-node": "0.8.2-next.3",
|
|
43
43
|
"octokit": "^3.0.0",
|
|
44
44
|
"yaml": "^2.0.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@backstage/cli": "0.32.1-next.
|
|
48
|
-
"@backstage/plugin-scaffolder-node-test-utils": "0.2.2-next.
|
|
47
|
+
"@backstage/cli": "0.32.1-next.3",
|
|
48
|
+
"@backstage/plugin-scaffolder-node-test-utils": "0.2.2-next.3"
|
|
49
49
|
},
|
|
50
50
|
"typesVersions": {
|
|
51
51
|
"*": {
|