From 754834a4ab1a23643dc771f726fb3de569775aaf Mon Sep 17 00:00:00 2001 From: i332371 Date: Thu, 13 Jun 2024 12:06:24 +0530 Subject: [PATCH 01/18] setup and checkout --- checkout | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup.sh | 17 +++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100755 checkout create mode 100644 setup.sh diff --git a/checkout b/checkout new file mode 100755 index 0000000..090c9f9 --- /dev/null +++ b/checkout @@ -0,0 +1,58 @@ +#!/usr/bin/env node +/* eslint-disable no-console */ + +const [,,$1,$2] = process.argv + +async function remoteService () { + const TARGET_DIR = "xmpls/remote-service" + const EXCLUDES = "--exclude='*.md' --exclude='package.json'" + const cmd = `eval rsync -av ${EXCLUDES} ${TARGET_DIR}/ .` + await run(cmd) + + const { readFile, writeFile } = require("fs").promises; + const { join } = require("path"); + const packageJson = JSON.parse(await readFile(join(__dirname, "package.json"), "utf-8")); + const delta = JSON.parse(await readFile(join(__dirname, `${TARGET_DIR}/package.json`), "utf-8")); + packageJson.cds.requires["API_BUSINESS_PARTNER"] = delta.cds.requires["API_BUSINESS_PARTNER"] + await writeFile(join(__dirname, "package.json"), JSON.stringify(packageJson, null, 2), "utf-8"); +} + +async function messaging () { + const TARGET_DIR = "xmpls/messaging" + const EXCLUDES = "--exclude='*.md' --exclude='package.json'" + const cmd = `eval rsync -av ${EXCLUDES} ${TARGET_DIR}/ .` + await run(cmd) + + const { readFile, writeFile } = require("fs").promises; + const { join } = require("path"); + const packageJson = JSON.parse(await readFile(join(__dirname, "package.json"), "utf-8")); + const delta = JSON.parse(await readFile(join(__dirname, `${TARGET_DIR}/package.json`), "utf-8")); + packageJson.cds.requires["API_BUSINESS_PARTNER"] = delta.cds.requires["API_BUSINESS_PARTNER"] + packageJson.cds.requires["messaging"] = delta.cds.requires["messaging"] + await writeFile(join(__dirname, "package.json"), JSON.stringify(packageJson, null, 2), "utf-8"); +} + +function run (cmd, silent) { + if (cmd.raw) return run (String.raw(...arguments)) + if (cmd.endsWith('--silent')) silent = cmd = cmd.slice(0,-9) + if (typeof cmd === 'string') cmd = new Promise ((done,failed) => { + const cp = exec (cmd, (e,stdout) => e ? failed(e) : done(stdout)) + if (!silent) { + cp.stdout.on ('data', d => process.stdout.write(d)) + cp.stderr.on ('data', d => process.stderr.write(d)) + } + }) + return cmd +} + +switch ($1) { + + case 'remote-service': + remoteService(); + break; + case 'messaging': + messaging(); + break; + default: + console.log('Usage: ./checkout [args]'); +} \ No newline at end of file diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..d8a4c3d --- /dev/null +++ b/setup.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +echo "Adding Remote Service" +cp -r xmpls/remote-service/* . + +echo "Adding Messaging" +cp -r xmpls/messaging/* . + +echo "Adding Change Tracking" +npm add @cap-js/change-tracking +cp xmpls/change-tracking.cds ./srv +cp xmpls/change-tracking.test.js ./test + +echo "Adding Audit Log" +npm add @cap-js/audit-logging +cp xmpls/data-privacy.cds ./srv +cp xmpls/audit-log.test.js ./test \ No newline at end of file From 3972ee99cdcc37d010348a0a857b7915cfc120da Mon Sep 17 00:00:00 2001 From: i332371 Date: Thu, 13 Jun 2024 13:08:33 +0530 Subject: [PATCH 02/18] script commands --- checkout | 28 ++++++++++++++++++++++------ package.json | 7 ++++++- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/checkout b/checkout index 090c9f9..eba4dd6 100755 --- a/checkout +++ b/checkout @@ -2,12 +2,14 @@ /* eslint-disable no-console */ const [,,$1,$2] = process.argv +const { exec } = require('child_process') async function remoteService () { const TARGET_DIR = "xmpls/remote-service" - const EXCLUDES = "--exclude='*.md' --exclude='package.json'" - const cmd = `eval rsync -av ${EXCLUDES} ${TARGET_DIR}/ .` - await run(cmd) + const INCLUDES = ["srv", "test"] + const paths = INCLUDES.map(pattern => TARGET_DIR + '/' + pattern) + const cmd = `cp -r ${paths.join(' ')} .` + await run(cmd); const { readFile, writeFile } = require("fs").promises; const { join } = require("path"); @@ -19,9 +21,10 @@ async function remoteService () { async function messaging () { const TARGET_DIR = "xmpls/messaging" - const EXCLUDES = "--exclude='*.md' --exclude='package.json'" - const cmd = `eval rsync -av ${EXCLUDES} ${TARGET_DIR}/ .` - await run(cmd) + const INCLUDES = ["app", "srv", "test"] + const paths = INCLUDES.map(pattern => TARGET_DIR + '/' + pattern) + const cmd = `cp -r ${paths.join(' ')} .` + await run(cmd); const { readFile, writeFile } = require("fs").promises; const { join } = require("path"); @@ -32,6 +35,16 @@ async function messaging () { await writeFile(join(__dirname, "package.json"), JSON.stringify(packageJson, null, 2), "utf-8"); } +async function changeTracking () { + const TARGET_DIR = "xmpls" + const deps = ["@cap-js/change-tracking"] + await run(`npm add ${deps.join(" ")}`) + + await run (`cp -r ${TARGET_DIR}/change-*.cds srv/`) + await run (`cp -r ${TARGET_DIR}/change-*.test.js test/`) + +} + function run (cmd, silent) { if (cmd.raw) return run (String.raw(...arguments)) if (cmd.endsWith('--silent')) silent = cmd = cmd.slice(0,-9) @@ -53,6 +66,9 @@ switch ($1) { case 'messaging': messaging(); break; + case 'change-tracking': + changeTracking(); + break; default: console.log('Usage: ./checkout [args]'); } \ No newline at end of file diff --git a/package.json b/package.json index cbe99d2..b4e487a 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,12 @@ "add-remote-service": "cp -r xmpls/remote-service/* .", "add-messaging": "cp -r xmpls/messaging/* .", "add-all-xmpls": "npm run add-remote-service && npm run add-messaging && npm run add-change-tracking && npm run add-audit-log", - "reset": "read -p 'This will irreversibly reset your working directory including ALL files in this git repo. Continue?' -n 1 -r && echo && if [[ $REPLY =~ ^[Yy]$ ]]; then git clean -fd && git reset --hard && npm i; fi" + "reset": "read -p 'This will irreversibly reset your working directory including ALL files in this git repo. Continue?' -n 1 -r && echo && if [[ $REPLY =~ ^[Yy]$ ]]; then git clean -fd && git reset --hard && npm i; fi", + + "add-remote-service-new": "./checkout remote-service", + "add-messaging-new": "./checkout messaging", + "add-change-tracking-new": "./checkout change-tracking" + }, "jest": { "modulePathIgnorePatterns": ["/xmpls/"] From 9a4b38e81eb4094b14214ebafa3257556822f4c4 Mon Sep 17 00:00:00 2001 From: i332371 Date: Thu, 13 Jun 2024 13:24:23 +0530 Subject: [PATCH 03/18] adding dependencies --- checkout | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/checkout b/checkout index eba4dd6..e26bce1 100755 --- a/checkout +++ b/checkout @@ -17,6 +17,16 @@ async function remoteService () { const delta = JSON.parse(await readFile(join(__dirname, `${TARGET_DIR}/package.json`), "utf-8")); packageJson.cds.requires["API_BUSINESS_PARTNER"] = delta.cds.requires["API_BUSINESS_PARTNER"] await writeFile(join(__dirname, "package.json"), JSON.stringify(packageJson, null, 2), "utf-8"); + + // dependencies + const deps = [ + "@sap-cloud-sdk/connectivity", + "@sap-cloud-sdk/http-client", + "@sap-cloud-sdk/resilience", + "@sap-cloud-sdk/util" + ] + console.log("Adding npm dependencies") + await run(`npm add ${deps.join(" ")}`) } async function messaging () { @@ -33,6 +43,17 @@ async function messaging () { packageJson.cds.requires["API_BUSINESS_PARTNER"] = delta.cds.requires["API_BUSINESS_PARTNER"] packageJson.cds.requires["messaging"] = delta.cds.requires["messaging"] await writeFile(join(__dirname, "package.json"), JSON.stringify(packageJson, null, 2), "utf-8"); + + // dependencies + const deps = [ + "@sap-cloud-sdk/connectivity", + "@sap-cloud-sdk/http-client", + "@sap-cloud-sdk/resilience", + "@sap-cloud-sdk/util", + "@sap/xb-msg-amqp-v100" + ] + console.log("Adding npm dependencies") + await run(`npm add ${deps.join(" ")}`) } async function changeTracking () { From b4bf57da1a23d8977e205f835381cdd879446d6c Mon Sep 17 00:00:00 2001 From: i332371 Date: Thu, 13 Jun 2024 16:41:38 +0530 Subject: [PATCH 04/18] cleanup --- checkout | 19 ++++--------------- package.json | 11 +++-------- setup.sh | 17 ----------------- 3 files changed, 7 insertions(+), 40 deletions(-) delete mode 100644 setup.sh diff --git a/checkout b/checkout index e26bce1..18c26fe 100755 --- a/checkout +++ b/checkout @@ -1,7 +1,7 @@ #!/usr/bin/env node /* eslint-disable no-console */ -const [,,$1,$2] = process.argv +const [,,$1] = process.argv const { exec } = require('child_process') async function remoteService () { @@ -27,6 +27,7 @@ async function remoteService () { ] console.log("Adding npm dependencies") await run(`npm add ${deps.join(" ")}`) + console.log("Added Remote Service") } async function messaging () { @@ -54,16 +55,7 @@ async function messaging () { ] console.log("Adding npm dependencies") await run(`npm add ${deps.join(" ")}`) -} - -async function changeTracking () { - const TARGET_DIR = "xmpls" - const deps = ["@cap-js/change-tracking"] - await run(`npm add ${deps.join(" ")}`) - - await run (`cp -r ${TARGET_DIR}/change-*.cds srv/`) - await run (`cp -r ${TARGET_DIR}/change-*.test.js test/`) - + console.log("Added Messaging") } function run (cmd, silent) { @@ -87,9 +79,6 @@ switch ($1) { case 'messaging': messaging(); break; - case 'change-tracking': - changeTracking(); - break; default: - console.log('Usage: ./checkout [args]'); + console.log('Usage: ./checkout '); } \ No newline at end of file diff --git a/package.json b/package.json index b4e487a..ae4fd4d 100644 --- a/package.json +++ b/package.json @@ -32,15 +32,10 @@ "add-attachments": "npm add @cap-js/attachments && cp -r xmpls/attachments.cds ./db", "add-notifications": "npm add @cap-js/notifications && cp xmpls/alert-notifications.js ./srv && cp xmpls/notification-types.json ./srv", "add-audit-log": "npm add @cap-js/audit-logging && cp xmpls/data-privacy.cds ./srv && cp xmpls/audit-log.test.js ./test", - "add-remote-service": "cp -r xmpls/remote-service/* .", - "add-messaging": "cp -r xmpls/messaging/* .", + "add-remote-service": "./checkout remote-service", + "add-messaging": "./checkout messaging", "add-all-xmpls": "npm run add-remote-service && npm run add-messaging && npm run add-change-tracking && npm run add-audit-log", - "reset": "read -p 'This will irreversibly reset your working directory including ALL files in this git repo. Continue?' -n 1 -r && echo && if [[ $REPLY =~ ^[Yy]$ ]]; then git clean -fd && git reset --hard && npm i; fi", - - "add-remote-service-new": "./checkout remote-service", - "add-messaging-new": "./checkout messaging", - "add-change-tracking-new": "./checkout change-tracking" - + "reset": "read -p 'This will irreversibly reset your working directory including ALL files in this git repo. Continue?' -n 1 -r && echo && if [[ $REPLY =~ ^[Yy]$ ]]; then git clean -fd && git reset --hard && npm i; fi" }, "jest": { "modulePathIgnorePatterns": ["/xmpls/"] diff --git a/setup.sh b/setup.sh deleted file mode 100644 index d8a4c3d..0000000 --- a/setup.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -echo "Adding Remote Service" -cp -r xmpls/remote-service/* . - -echo "Adding Messaging" -cp -r xmpls/messaging/* . - -echo "Adding Change Tracking" -npm add @cap-js/change-tracking -cp xmpls/change-tracking.cds ./srv -cp xmpls/change-tracking.test.js ./test - -echo "Adding Audit Log" -npm add @cap-js/audit-logging -cp xmpls/data-privacy.cds ./srv -cp xmpls/audit-log.test.js ./test \ No newline at end of file From 7f46ba55be13a691b99fa77ad6afcd0e2a0d5020 Mon Sep 17 00:00:00 2001 From: i332371 Date: Thu, 13 Jun 2024 16:49:39 +0530 Subject: [PATCH 05/18] extensible fields.cds --- xmpls/messaging/app/fields.cds | 1 + xmpls/messaging/app/services.cds | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) create mode 100644 xmpls/messaging/app/fields.cds delete mode 100644 xmpls/messaging/app/services.cds diff --git a/xmpls/messaging/app/fields.cds b/xmpls/messaging/app/fields.cds new file mode 100644 index 0000000..cdc5648 --- /dev/null +++ b/xmpls/messaging/app/fields.cds @@ -0,0 +1 @@ +using from './incidents/field'; \ No newline at end of file diff --git a/xmpls/messaging/app/services.cds b/xmpls/messaging/app/services.cds deleted file mode 100644 index 64d334f..0000000 --- a/xmpls/messaging/app/services.cds +++ /dev/null @@ -1,3 +0,0 @@ - -using from './incidents/annotations'; -using from './incidents/field'; \ No newline at end of file From f17b2fb3718b0563f6d8b349a6a1c7351cc50028 Mon Sep 17 00:00:00 2001 From: i332371 Date: Thu, 13 Jun 2024 17:52:43 +0530 Subject: [PATCH 06/18] add permission for checkout file --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index ae4fd4d..bb98f5a 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,8 @@ "add-remote-service": "./checkout remote-service", "add-messaging": "./checkout messaging", "add-all-xmpls": "npm run add-remote-service && npm run add-messaging && npm run add-change-tracking && npm run add-audit-log", - "reset": "read -p 'This will irreversibly reset your working directory including ALL files in this git repo. Continue?' -n 1 -r && echo && if [[ $REPLY =~ ^[Yy]$ ]]; then git clean -fd && git reset --hard && npm i; fi" + "reset": "read -p 'This will irreversibly reset your working directory including ALL files in this git repo. Continue?' -n 1 -r && echo && if [[ $REPLY =~ ^[Yy]$ ]]; then git clean -fd && git reset --hard && npm i; fi", + "make-exec": "chmod +x ./checkout" }, "jest": { "modulePathIgnorePatterns": ["/xmpls/"] From 259abc1e41142f2d2f27d3c8cb09af0ee1e9aed1 Mon Sep 17 00:00:00 2001 From: sjvans <30337871+sjvans@users.noreply.github.com> Date: Thu, 20 Jun 2024 09:58:24 +0200 Subject: [PATCH 07/18] fix: adjust test/audit-logging.http to changing the customer's id to a string (#63) --- test/audit-logging.http | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/audit-logging.http b/test/audit-logging.http index e60b661..a21cab2 100644 --- a/test/audit-logging.http +++ b/test/audit-logging.http @@ -25,7 +25,7 @@ Authorization: Basic alice:wonderland Content-Type: application/json { - "ID": "{{$guid}}", + "ID": "{{$randomInt 9000000 9999999}}", "firstName": "Bob", "lastName": "Builder", "email": "bob.builder@example.com" @@ -33,7 +33,7 @@ Content-Type: application/json ### Updating a customer with personal data details @customer = {{create_customer.response.body.ID}} -PATCH {{host}}/odata/v4/admin/Customers({{customer}}) +PATCH {{host}}/odata/v4/admin/Customers('{{customer}}') Authorization: Basic alice:wonderland Content-Type: application/json From 5384bc8353e6f32dc12d573f3347a916054009dc Mon Sep 17 00:00:00 2001 From: Navin Krishnan Date: Mon, 1 Jul 2024 21:38:13 +0530 Subject: [PATCH 08/18] Fix for change tracking delete test --- xmpls/change-tracking.test.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xmpls/change-tracking.test.js b/xmpls/change-tracking.test.js index 89bf809..54522c4 100644 --- a/xmpls/change-tracking.test.js +++ b/xmpls/change-tracking.test.js @@ -126,8 +126,10 @@ describe("Integration Test for ChangeTracking", () => { const incidentChanges = await SELECT.from(ChangeView).where({ entity: "sap.capire.incidents.Incidents", attribute: "status", + keys: `ID=${draftId}`, + modification: "delete" }) - expect(incidentChanges.length).to.equal(0); + expect(incidentChanges.length).to.equal(1); }); }); }); From adbb29036eb8c34c84dd0d7c7b9fb7e7e5a34f2d Mon Sep 17 00:00:00 2001 From: i332371 Date: Mon, 1 Jul 2024 22:27:56 +0530 Subject: [PATCH 09/18] checkout script for samples --- checkout | 10 ++++------ package.json | 3 +-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/checkout b/checkout index 18c26fe..dfbff8d 100755 --- a/checkout +++ b/checkout @@ -25,9 +25,8 @@ async function remoteService () { "@sap-cloud-sdk/resilience", "@sap-cloud-sdk/util" ] - console.log("Adding npm dependencies") - await run(`npm add ${deps.join(" ")}`) - console.log("Added Remote Service") + console.info("Preparing Incidents-app with Remote Service") + return await run(`npm add ${deps.join(" ")}`) } async function messaging () { @@ -53,9 +52,8 @@ async function messaging () { "@sap-cloud-sdk/util", "@sap/xb-msg-amqp-v100" ] - console.log("Adding npm dependencies") - await run(`npm add ${deps.join(" ")}`) - console.log("Added Messaging") + console.info("Preparing Incidents-app with Messaging") + return await run(`npm add ${deps.join(" ")}`) } function run (cmd, silent) { diff --git a/package.json b/package.json index bb98f5a..ae4fd4d 100644 --- a/package.json +++ b/package.json @@ -35,8 +35,7 @@ "add-remote-service": "./checkout remote-service", "add-messaging": "./checkout messaging", "add-all-xmpls": "npm run add-remote-service && npm run add-messaging && npm run add-change-tracking && npm run add-audit-log", - "reset": "read -p 'This will irreversibly reset your working directory including ALL files in this git repo. Continue?' -n 1 -r && echo && if [[ $REPLY =~ ^[Yy]$ ]]; then git clean -fd && git reset --hard && npm i; fi", - "make-exec": "chmod +x ./checkout" + "reset": "read -p 'This will irreversibly reset your working directory including ALL files in this git repo. Continue?' -n 1 -r && echo && if [[ $REPLY =~ ^[Yy]$ ]]; then git clean -fd && git reset --hard && npm i; fi" }, "jest": { "modulePathIgnorePatterns": ["/xmpls/"] From 9b5b278a3c6bdc6caf9732a925bc285e937985ed Mon Sep 17 00:00:00 2001 From: Christian Georgi Date: Tue, 2 Jul 2024 17:30:42 +0200 Subject: [PATCH 10/18] Update UI5 version to 1.125.1 --- app/incidents/webapp/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/incidents/webapp/index.html b/app/incidents/webapp/index.html index 5f1256d..75c5c1f 100644 --- a/app/incidents/webapp/index.html +++ b/app/incidents/webapp/index.html @@ -12,7 +12,7 @@