@neoimpulse/cap-js-notifications 1.0.6 → 1.0.8

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
@@ -4,6 +4,8 @@
4
4
 
5
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
6
 
7
+ **Note:** This project is a copy of the [cap-js/notifications](https://github.com/cap-js/notifications) repository. Please refer to the original repository for more details.
8
+
7
9
  ## Features
8
10
 
9
11
  - Send notifications to REST endpoints or console based on the environment.
package/cds-plugin.js CHANGED
@@ -1,25 +1,24 @@
1
1
  const cds = require("@sap/cds");
2
2
 
3
3
  if (cds.cli.command === "build") {
4
- // register build plugin
5
- cds.build?.register?.('notifications', require("./lib/build"));
6
- }
4
+ // register build plugin
5
+ cds.build?.register?.("notifications", require("./lib/build"));
6
+ } else
7
+ cds.once("served", async () => {
8
+ const { validateNotificationTypes, readFile } = require("./lib/utils");
9
+ const { createNotificationTypesMap } = require("./lib/notificationTypes");
10
+ const { deployNotificationTypes } = require("./lib/content-deployment");
11
+ const production = cds.env.profiles?.includes("production");
7
12
 
8
- else cds.once("served", async () => {
9
- const { validateNotificationTypes, readFile } = require("./lib/utils");
10
- const { createNotificationTypesMap } = require("./lib/notificationTypes");
11
- const { deployNotificationTypes } = require("./lib/content-deployment");
12
- const production = cds.env.profiles?.includes("production");
13
+ // read notification types
14
+ const notificationTypes = readFile(cds.env.requires?.notifications?.types);
15
+ if (validateNotificationTypes(notificationTypes)) {
16
+ if (!production) {
17
+ const notificationTypesMap = createNotificationTypesMap(notificationTypes, true);
18
+ cds.notifications = { local: { types: notificationTypesMap } };
19
+ }
20
+ deployNotificationTypes();
21
+ }
13
22
 
14
- // read notification types
15
- const notificationTypes = readFile(cds.env.requires?.notifications?.types);
16
- if (validateNotificationTypes(notificationTypes)) {
17
- if (!production) {
18
- const notificationTypesMap = createNotificationTypesMap(notificationTypes, true);
19
- cds.notifications = { local: { types: notificationTypesMap } };
20
- }
21
- deployNotificationTypes();
22
- }
23
-
24
- require("@sap-cloud-sdk/util").setGlobalLogLevel("error")
25
- })
23
+ require("@sap-cloud-sdk/util").setGlobalLogLevel("error");
24
+ });
package/lib/build.js CHANGED
@@ -1,19 +1,19 @@
1
- const cds = require('@sap/cds')
1
+ const cds = require("@sap/cds");
2
2
 
3
- const { copy, exists, path } = cds.utils
3
+ const { copy, exists, path } = cds.utils;
4
4
 
5
5
  module.exports = class NotificationsBuildPlugin extends cds.build.Plugin {
6
- static taskDefaults = { src: cds.env.folders.srv }
7
-
8
- static hasTask() {
9
- const notificationTypesFile = cds.env.requires?.notifications?.types;
10
- return notificationTypesFile === undefined ? false : exists(notificationTypesFile);
11
- }
6
+ static taskDefaults = { src: cds.env.folders.srv };
12
7
 
13
- async build() {
14
- if (exists(cds.env.requires.notifications?.types)) {
15
- const fileName = path.basename(cds.env.requires.notifications.types);
16
- await copy(cds.env.requires.notifications.types).to(path.join(this.task.dest, fileName));
8
+ static hasTask() {
9
+ const notificationTypesFile = cds.env.requires?.notifications?.types;
10
+ return notificationTypesFile === undefined ? false : exists(notificationTypesFile);
17
11
  }
18
- }
19
- }
12
+
13
+ async build() {
14
+ if (exists(cds.env.requires.notifications?.types)) {
15
+ const fileName = path.basename(cds.env.requires.notifications.types);
16
+ await copy(cds.env.requires.notifications.types).to(path.join(this.task.dest, fileName));
17
+ }
18
+ }
19
+ };
@@ -4,19 +4,19 @@ const { processNotificationTypes } = require("./notificationTypes");
4
4
  const { setGlobalLogLevel } = require("@sap-cloud-sdk/util");
5
5
 
6
6
  async function deployNotificationTypes() {
7
- setGlobalLogLevel("error");
7
+ setGlobalLogLevel("error");
8
8
 
9
- // read notification types
10
- const filePath = cds.env.requires?.notifications?.types ?? '';
11
- const notificationTypes = readFile(filePath);
9
+ // read notification types
10
+ const filePath = cds.env.requires?.notifications?.types ?? "";
11
+ const notificationTypes = readFile(filePath);
12
12
 
13
- if (validateNotificationTypes(notificationTypes)) {
14
- await processNotificationTypes(notificationTypes);
15
- }
13
+ if (validateNotificationTypes(notificationTypes)) {
14
+ await processNotificationTypes(notificationTypes);
15
+ }
16
16
  }
17
17
 
18
18
  deployNotificationTypes();
19
19
 
20
20
  module.exports = {
21
- deployNotificationTypes
22
- }
21
+ deployNotificationTypes
22
+ };