Skip to content

Commit e349e57

Browse files
authored
Merge branch 'MVP' into unit-tests-post-notification
2 parents 707ade8 + 867e9d4 commit e349e57

File tree

5 files changed

+33
-11
lines changed

5 files changed

+33
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ yarn-debug.log*
66
yarn-error.log*
77
lerna-debug.log*
88
.pnpm-debug.log*
9+
package-lock.json
910

1011
# Diagnostic reports (https://nodejs.org/api/report.html)
1112
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"tabWidth": 2,
3+
"useTabs": false,
4+
"printWidth": 150
5+
}

cds-plugin.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
const cds = require("@sap/cds");
22
const { validateNotificationTypes, readFile } = require("./lib/utils");
3-
const { createNotificationTypesMap, processNotificationTypes} = require("./lib/notificationTypes");
3+
const { createNotificationTypesMap } = require("./lib/notificationTypes");
44
const { setGlobalLogLevel } = require("@sap-cloud-sdk/util");
55

66
cds.once("served", async () => {
77
setGlobalLogLevel("error");
88
const profiles = cds.env.profiles ?? [];
9-
const production = profiles.includes('production');
9+
const production = profiles.includes("production");
1010

1111
// read notification types
1212
const notificationTypes = readFile(cds.env.requires?.notifications?.types);
1313

14-
if(validateNotificationTypes(notificationTypes)) {
15-
if (production) {
16-
await processNotificationTypes(notificationTypes);
17-
} else {
14+
if (validateNotificationTypes(notificationTypes)) {
15+
if (!production) {
1816
const notificationTypesMap = createNotificationTypesMap(notificationTypes, true);
19-
cds.notifications = { local: { types: notificationTypesMap }};
17+
cds.notifications = { local: { types: notificationTypesMap } };
2018
}
2119
}
2220
});

lib/content-deployment.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const cds = require("@sap/cds");
2+
const { validateNotificationTypes, readFile } = require("./utils");
3+
const { createNotificationTypesMap, processNotificationTypes } = require("./notificationTypes");
4+
const { setGlobalLogLevel } = require("@sap-cloud-sdk/util");
5+
6+
async function deployNotificationTypes() {
7+
setGlobalLogLevel("error");
8+
9+
// read notification types
10+
const notificationTypes = readFile(cds.env.requires?.notifications?.types);
11+
12+
if (validateNotificationTypes(notificationTypes)) {
13+
await processNotificationTypes(notificationTypes);
14+
}
15+
}
16+
17+
deployNotificationTypes();

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"name": "@cap-js/alert-notification",
2+
"name": "@cap-js/notifications",
33
"version": "0.0.1",
44
"description": "CDS plugin providing integration to the SAP BTP Alert Notification Service.",
5-
"repository": "cap-js/alert-notification",
5+
"repository": "cap-js/notifications",
66
"author": "SAP SE (https://www.sap.com)",
77
"homepage": "https://cap.cloud.sap/",
88
"license": "SEE LICENSE IN LICENSE",
@@ -15,6 +15,7 @@
1515
"@sap-cloud-sdk/connectivity": "3.5.0",
1616
"@sap-cloud-sdk/http-client": "3.5.0",
1717
"@sap-cloud-sdk/util": "3.5.0",
18+
"@sap/cds": ">=7",
1819
"lodash": "4.17.21"
1920
},
2021
"devDependencies": {
@@ -36,11 +37,11 @@
3637
}
3738
},
3839
"notify-to-console": {
39-
"impl": "@cap-js/alert-notification/srv/notifyToConsole",
40+
"impl": "@cap-js/notifications/srv/notifyToConsole",
4041
"outbox": false
4142
},
4243
"notify-to-rest": {
43-
"impl": "@cap-js/alert-notification/srv/notifyToRest",
44+
"impl": "@cap-js/notifications/srv/notifyToRest",
4445
"outbox": true
4546
}
4647
}

0 commit comments

Comments
 (0)