@neoimpulse/cap-js-notifications 1.0.0 → 1.0.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/README.md CHANGED
@@ -0,0 +1,62 @@
1
+ # CAP JS Notifications
2
+
3
+ ## Overview
4
+
5
+ CAP JS Notifications is a CDS plugin designed to provide an easy action for the notification service. It supports sending notifications to different destinations based on the environment configuration.
6
+
7
+ ## Features
8
+
9
+ - Send notifications to REST endpoints or console based on the environment.
10
+ - Validate and process notification types.
11
+ - Deploy notification types to the notification service.
12
+ - Customizable notification templates.
13
+
14
+ ## Installation
15
+
16
+ To install the dependencies, run:
17
+
18
+ ```bash
19
+ npm install
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ ### Configuration
25
+
26
+ The plugin configuration is defined in the `package.json` file under the `cds.requires.notifications` section. It includes settings for different environments, notification types, and destinations.
27
+
28
+ ### Notification Types
29
+
30
+ Notification types are defined in the `srv/notification-types.json` file. Each notification type includes templates for different languages and versions.
31
+
32
+ ### Running the Plugin
33
+
34
+ To run the plugin, use the following command:
35
+
36
+ ```bash
37
+ cds run
38
+ ```
39
+
40
+ ### Building the Project
41
+
42
+ To build the project, use the following command:
43
+
44
+ ```bash
45
+ cds build
46
+ ```
47
+
48
+ ### Releasing the Project
49
+
50
+ The release process is automated using GitHub Actions. The configuration is defined in the `.github/workflows/release.yml` file.
51
+
52
+ ## License
53
+
54
+ This project is licensed under the Apache License 2.0. See the [LICENSE](./LICENSE) file for more details.
55
+
56
+ ## Contributing
57
+
58
+ Contributions are welcome! Please read the [CONTRIBUTING](./CONTRIBUTING.md) guidelines before submitting a pull request.
59
+
60
+ ## Contact
61
+
62
+ For any questions or issues, please contact the author at Neoimpulse GmbH.
package/cds-plugin.js CHANGED
@@ -1,4 +1,4 @@
1
- const cds = require("@sap/cds/lib");
1
+ const cds = require("@sap/cds");
2
2
 
3
3
  if (cds.cli.command === "build") {
4
4
  // register build plugin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neoimpulse/cap-js-notifications",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "A CDS plugin to provide an easy action for the notification service",
5
5
  "main": "cds-plugin.js",
6
6
  "scripts": {
@@ -13,7 +13,7 @@
13
13
  "keywords": [
14
14
  "cds",
15
15
  "cap",
16
- "trim",
16
+ "notifications",
17
17
  "plugin"
18
18
  ],
19
19
  "author": "Neoimpulse GmbH",
@@ -30,10 +30,13 @@
30
30
  "README.md"
31
31
  ],
32
32
  "dependencies": {
33
- "@sap/cds": "^7",
34
- "express": "^4.17.1"
33
+ "@sap-cloud-sdk/connectivity": "^3.13.0",
34
+ "@sap-cloud-sdk/http-client": "^3.13.0",
35
+ "@sap-cloud-sdk/util": "^3.13.0"
35
36
  },
36
37
  "devDependencies": {
38
+ "@sap/cds": ">=7.3",
39
+ "@sap/cds-dk": ">=7.3",
37
40
  "prettier": "^3.3.3",
38
41
  "semantic-release": "^24.2.1"
39
42
  },
@@ -49,8 +52,7 @@
49
52
  "kind": "notify-to-rest"
50
53
  },
51
54
  "prefix": "$app-name",
52
- "types": "srv/notification-types.json",
53
- "outbox": true
55
+ "types": "srv/notification-types.json"
54
56
  },
55
57
  "kinds": {
56
58
  "notify-to-console": {
@@ -1,6 +1,6 @@
1
1
  const cds = require("@sap/cds");
2
2
  const LOG = cds.log('notifications');
3
- const { readFile } = require("../lib/utils");
3
+ const { readFile, buildNotification } = require("../lib/utils");
4
4
 
5
5
  module.exports = class NotifyToConsole extends cds.Service {
6
6
  async init() {
@@ -15,7 +15,7 @@ module.exports = class NotifyToConsole extends cds.Service {
15
15
  console.log (
16
16
  '\n---------------------------------------------------------------\n' +
17
17
  'Notification:', req.event,
18
- notification,
18
+ buildNotification(notification),
19
19
  '\n---------------------------------------------------------------\n',
20
20
  )
21
21
 
@@ -1,6 +1,6 @@
1
1
  const { buildHeadersForDestination } = require("@sap-cloud-sdk/connectivity");
2
2
  const { executeHttpRequest } = require("@sap-cloud-sdk/http-client");
3
- const { getNotificationDestination, readFile } = require("../lib/utils");
3
+ const { getNotificationDestination, readFile, buildNotification } = require("../lib/utils");
4
4
  const cds = require("@sap/cds");
5
5
  const LOG = cds.log('notifications');
6
6
  const NOTIFICATIONS_API_ENDPOINT = "v2/Notification.svc";
@@ -28,7 +28,7 @@ module.exports = exports = class NotifyToRest extends cds.Service {
28
28
  await executeHttpRequest(notificationDestination, {
29
29
  url: `${NOTIFICATIONS_API_ENDPOINT}/Notifications`,
30
30
  method: "post",
31
- data: notificationData,
31
+ data: buildNotification(notificationData),
32
32
  headers: csrfHeaders,
33
33
  });
34
34
  } catch (err) {