From b4e9e7f465e04b14cfb84148465ca144b5e2e564 Mon Sep 17 00:00:00 2001 From: D050513 Date: Thu, 12 Sep 2024 09:34:14 +0200 Subject: [PATCH 1/6] chore: eslint^9 --- .eslintrc | 26 -------------------------- eslint.config.mjs | 2 ++ package.json | 2 +- 3 files changed, 3 insertions(+), 27 deletions(-) delete mode 100644 .eslintrc create mode 100644 eslint.config.mjs diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 74d6149..0000000 --- a/.eslintrc +++ /dev/null @@ -1,26 +0,0 @@ -{ - "extends": "eslint:recommended", - "env": { - "es2022": true, - "node": true, - "jest": true, - "mocha": true - }, - "globals": { - "SELECT": true, - "INSERT": true, - "UPSERT": true, - "UPDATE": true, - "DELETE": true, - "CREATE": true, - "DROP": true, - "CDL": true, - "CQL": true, - "CXL": true, - "cds": true - }, - "rules": { - "no-console": "off", - "require-atomic-updates": "off" - } -} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..0d250b2 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,2 @@ +import cds from '@sap/cds/eslint.config.mjs' +export default [...cds.recommended] diff --git a/package.json b/package.json index 44d6fe0..5650780 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "@cap-js/audit-logging": "file:.", "@cap-js/sqlite": "^1", "axios": "^1", - "eslint": "^8", + "eslint": "^9", "express": "^4", "jest": "^29", "sqlite3": "^5.1.6" From 7278217a44e7d19410365f83d58e71e9d012b6ef Mon Sep 17 00:00:00 2001 From: D050513 Date: Thu, 12 Sep 2024 09:48:24 +0200 Subject: [PATCH 2/6] linting --- lib/utils.js | 2 ++ srv/log2console.js | 1 + test/api/MyAuditLogService.js | 1 + test/api/srv/api-service.js | 2 ++ test/integration/srv/integration-service.js | 2 ++ test/jest.setup.js | 2 +- 6 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/utils.js b/lib/utils.js index 1929982..207dfd2 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,3 +1,5 @@ +const cds = require('@sap/cds') + const WRITE = { CREATE: 1, UPDATE: 1, DELETE: 1 } const $hasPersonalData = Symbol('@cap-js/audit-logging:hasPersonalData') diff --git a/srv/log2console.js b/srv/log2console.js index f024736..c340a9a 100644 --- a/srv/log2console.js +++ b/srv/log2console.js @@ -5,6 +5,7 @@ module.exports = class AuditLog2Console extends AuditLogService { this.on('*', function (req) { const { event, data } = req + // eslint-disable-next-line no-console console.log(`[audit-log] - ${event}:`, data) }) diff --git a/test/api/MyAuditLogService.js b/test/api/MyAuditLogService.js index b16e4f1..fcf1376 100644 --- a/test/api/MyAuditLogService.js +++ b/test/api/MyAuditLogService.js @@ -5,6 +5,7 @@ class MyAuditLogService extends AuditLogService { this.on('*', function (req) { const { event, data } = req + // eslint-disable-next-line no-console console.log(`[my-audit-log] - ${event}:`, data) }) diff --git a/test/api/srv/api-service.js b/test/api/srv/api-service.js index d9a11f7..aa8aaa2 100644 --- a/test/api/srv/api-service.js +++ b/test/api/srv/api-service.js @@ -1,3 +1,5 @@ +const cds = require('@sap/cds') + module.exports = async function () { const audit = await cds.connect.to('audit-log') diff --git a/test/integration/srv/integration-service.js b/test/integration/srv/integration-service.js index 98c799e..ca96d8b 100644 --- a/test/integration/srv/integration-service.js +++ b/test/integration/srv/integration-service.js @@ -1,3 +1,5 @@ +const cds = require('@sap/cds') + module.exports = async function () { const audit = await cds.connect.to('audit-log') diff --git a/test/jest.setup.js b/test/jest.setup.js index 43905f3..7b6066d 100644 --- a/test/jest.setup.js +++ b/test/jest.setup.js @@ -4,7 +4,7 @@ function toContainMatchObject(received, expected) { try { expect(each).toMatchObject(expected) pass = true - } catch (e) { + } catch { // ignore } From 80e382a506000187cb2b3d584d7f8aada4032758 Mon Sep 17 00:00:00 2001 From: D050513 Date: Thu, 12 Sep 2024 13:52:58 +0200 Subject: [PATCH 3/6] fix old db test script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 45c6d7e..5480289 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "lint": "npx eslint .", "test": "npm run test-new-db && npm run test-old-db", "test-new-db": "CDS_ENV='better-sqlite' npx jest --silent", - "test-old-db": "npx jest --silent" + "test-old-db": "CDS_ENV='legacy-sqlite' npx jest --silent" }, "peerDependencies": { "@sap/cds": ">=7" From 43aa5dd1988ed20c6c08d59918bfd374f276d47c Mon Sep 17 00:00:00 2001 From: D050513 Date: Thu, 12 Sep 2024 13:55:00 +0200 Subject: [PATCH 4/6] separate lint job --- .github/workflows/ci.yml | 25 ++++++++++++++++++++++++- README.md | 3 +++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3d21adb..408e21b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,29 @@ on: branches: [ main ] jobs: + lint: + runs-on: ubuntu-latest + #strategy: + # fail-fast: false + # matrix: + # node-version: [22.x, 20.x] + # cds-version: [8, 7] + steps: + - uses: actions/checkout@v2 + #- name: Use Node.js ${{ matrix.node-version }} + # uses: actions/setup-node@v2 + # with: + # node-version: ${{ matrix.node-version }} + #- run: npm i -g @sap/cds-dk@${{ matrix.cds-version }} + - run: npm i + #- run: npm i @sap/cds@${{ matrix.cds-version }} + #- run: cds v + - run: npm run lint + #- run: npm run test + # env: + # ALS_CREDS_OAUTH2: ${{ secrets.ALS_CREDS_OAUTH2 }} + # ALS_CREDS_STANDARD: ${{ secrets.ALS_CREDS_STANDARD }} + # ALS_CREDS_PREMIUM: ${{ secrets.ALS_CREDS_PREMIUM }} test: runs-on: ubuntu-latest strategy: @@ -25,7 +48,7 @@ jobs: - run: npm i - run: npm i @sap/cds@${{ matrix.cds-version }} - run: cds v - - run: npm run lint + #- run: npm run lint - run: npm run test env: ALS_CREDS_OAUTH2: ${{ secrets.ALS_CREDS_OAUTH2 }} diff --git a/README.md b/README.md index 7a10556..c96605a 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ npm i ``` ## Setup + To enable audit logging, simply add this self-configuring plugin package to your project: ```sh @@ -27,6 +28,7 @@ npm add @cap-js/audit-logging ``` ## Annotate Personal Data + Identify entities and elements (potentially) holding personal data using `@PersonalData` annotations. Create a `db/data-privacy.cds` file and add the following: ```cds @@ -69,6 +71,7 @@ Learn more about the annotations in capire: ## Test-Drive Locally + You've prepared everything to log personal data-related events. Let's see that in action. Start the server as usual: From 05de0342c73aad19b79f059daf51901bd34b8048 Mon Sep 17 00:00:00 2001 From: D050513 Date: Thu, 12 Sep 2024 13:56:35 +0200 Subject: [PATCH 5/6] cleanup --- .github/workflows/ci.yml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 408e21b..74d56bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,27 +10,10 @@ on: jobs: lint: runs-on: ubuntu-latest - #strategy: - # fail-fast: false - # matrix: - # node-version: [22.x, 20.x] - # cds-version: [8, 7] steps: - uses: actions/checkout@v2 - #- name: Use Node.js ${{ matrix.node-version }} - # uses: actions/setup-node@v2 - # with: - # node-version: ${{ matrix.node-version }} - #- run: npm i -g @sap/cds-dk@${{ matrix.cds-version }} - run: npm i - #- run: npm i @sap/cds@${{ matrix.cds-version }} - #- run: cds v - run: npm run lint - #- run: npm run test - # env: - # ALS_CREDS_OAUTH2: ${{ secrets.ALS_CREDS_OAUTH2 }} - # ALS_CREDS_STANDARD: ${{ secrets.ALS_CREDS_STANDARD }} - # ALS_CREDS_PREMIUM: ${{ secrets.ALS_CREDS_PREMIUM }} test: runs-on: ubuntu-latest strategy: @@ -48,7 +31,6 @@ jobs: - run: npm i - run: npm i @sap/cds@${{ matrix.cds-version }} - run: cds v - #- run: npm run lint - run: npm run test env: ALS_CREDS_OAUTH2: ${{ secrets.ALS_CREDS_OAUTH2 }} From 8b98fa5bd2917f4439d892b381853dae38779639 Mon Sep 17 00:00:00 2001 From: D050513 Date: Thu, 12 Sep 2024 13:59:39 +0200 Subject: [PATCH 6/6] revert changes to readme --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index c96605a..7a10556 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,6 @@ npm i ``` ## Setup - To enable audit logging, simply add this self-configuring plugin package to your project: ```sh @@ -28,7 +27,6 @@ npm add @cap-js/audit-logging ``` ## Annotate Personal Data - Identify entities and elements (potentially) holding personal data using `@PersonalData` annotations. Create a `db/data-privacy.cds` file and add the following: ```cds @@ -71,7 +69,6 @@ Learn more about the annotations in capire: ## Test-Drive Locally - You've prepared everything to log personal data-related events. Let's see that in action. Start the server as usual: