@cap-js-community/common 0.1.0
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/LICENSE +201 -0
- package/README.md +265 -0
- package/bin/cdsmc.js +51 -0
- package/cds-plugin.js +48 -0
- package/index.js +3 -0
- package/package.json +131 -0
- package/src/common/promise.js +24 -0
- package/src/index.js +8 -0
- package/src/migration-check/MigrationCheck.js +588 -0
- package/src/migration-check/index.js +5 -0
- package/src/rate-limiting/RateLimiting.js +213 -0
- package/src/rate-limiting/index.js +5 -0
- package/src/rate-limiting/redis/common.js +33 -0
- package/src/rate-limiting/redis/counter.js +63 -0
- package/src/rate-limiting/redis/resetTime.js +44 -0
- package/src/redis-client/RedisClient.js +238 -0
- package/src/redis-client/index.js +5 -0
- package/src/replication-cache/ReplicationCache.js +961 -0
- package/src/replication-cache/index.js +5 -0
package/package.json
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cap-js-community/common",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CAP Node.js Community Common",
|
|
5
|
+
"homepage": "https://cap.cloud.sap/",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=22"
|
|
8
|
+
},
|
|
9
|
+
"author": "Oliver Klemenz <oliver.klemenz@sap.com>, Gruenfelder, Maximilian <maximilian.gruenfelder@sap.com>, Richard Lindner <richard.lindner@sap.com>",
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/cap-js-community/common.git"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"CAP",
|
|
17
|
+
"CDS"
|
|
18
|
+
],
|
|
19
|
+
"files": [
|
|
20
|
+
"bin",
|
|
21
|
+
"src",
|
|
22
|
+
"LICENSE",
|
|
23
|
+
"cds-plugin.js"
|
|
24
|
+
],
|
|
25
|
+
"main": "index.js",
|
|
26
|
+
"types": "index.d.ts",
|
|
27
|
+
"bin": {
|
|
28
|
+
"cdsmc": "./bin/cdsmc.js"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"start": "cds-serve",
|
|
32
|
+
"test": "jest --runInBand",
|
|
33
|
+
"test:update": "npm test -- -u",
|
|
34
|
+
"lint": "npm run lint:eslint && npm run lint:prettier",
|
|
35
|
+
"lint:prettier": "prettier \"**/*.{js,json,md,yml,yaml,html}\" --write --log-level error",
|
|
36
|
+
"lint:eslint": "eslint . --fix",
|
|
37
|
+
"lint:ci": "npm run eslint:ci && npm run prettier:ci",
|
|
38
|
+
"eslint": "eslint --fix .",
|
|
39
|
+
"eslint:ci": "eslint .",
|
|
40
|
+
"prettier": "prettier \"**/*.{js,json,md,yml,yaml}\" --write --log-level error",
|
|
41
|
+
"prettier:ci": "prettier \"**/*.{js,json,md,yml,yaml}\" --check",
|
|
42
|
+
"upgrade-lock": "rm -rf package-lock.json node_modules && npm i",
|
|
43
|
+
"prepareRelease": "npm prune --production",
|
|
44
|
+
"audit": "npm audit --only=prod"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@cap-js/sqlite": "^1.10.0",
|
|
48
|
+
"redis": "^4.7.0",
|
|
49
|
+
"verror": "^1.10.1"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@cap-js-community/common": "./",
|
|
53
|
+
"@cap-js/cds-test": "^0.3.0",
|
|
54
|
+
"@sap/cds": "^8.9.1",
|
|
55
|
+
"@sap/cds-common-content": "^2.1.0",
|
|
56
|
+
"@sap/cds-dk": "^8.9.1",
|
|
57
|
+
"commander": "^13.1.0",
|
|
58
|
+
"eslint": "9.24.0",
|
|
59
|
+
"eslint-config-prettier": "10.1.1",
|
|
60
|
+
"eslint-plugin-jest": "28.11.0",
|
|
61
|
+
"eslint-plugin-n": "^17.17.0",
|
|
62
|
+
"jest": "29.7.0",
|
|
63
|
+
"jest-html-reporters": "3.1.7",
|
|
64
|
+
"jest-junit": "16.0.0",
|
|
65
|
+
"prettier": "3.5.3",
|
|
66
|
+
"shelljs": "^0.9.2"
|
|
67
|
+
},
|
|
68
|
+
"cds": {
|
|
69
|
+
"requires": {
|
|
70
|
+
"redis-ratelimit": {
|
|
71
|
+
"vcap": {
|
|
72
|
+
"label": "redis-cache"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"migrationCheck": {
|
|
77
|
+
"baseDir": "migration-check",
|
|
78
|
+
"whitelist": true,
|
|
79
|
+
"checkMtx": true,
|
|
80
|
+
"keep": false,
|
|
81
|
+
"freeze": false,
|
|
82
|
+
"label": null,
|
|
83
|
+
"buildPath": null,
|
|
84
|
+
"adminHash": null
|
|
85
|
+
},
|
|
86
|
+
"rateLimiting": {
|
|
87
|
+
"plugin": true,
|
|
88
|
+
"[test]": {
|
|
89
|
+
"plugin": false
|
|
90
|
+
},
|
|
91
|
+
"maxConcurrent": 3,
|
|
92
|
+
"maxInWindow": 10000,
|
|
93
|
+
"window": 3600000,
|
|
94
|
+
"retry": 5,
|
|
95
|
+
"redis": true
|
|
96
|
+
},
|
|
97
|
+
"replicationCache": {
|
|
98
|
+
"plugin": true,
|
|
99
|
+
"[test]": {
|
|
100
|
+
"plugin": false
|
|
101
|
+
},
|
|
102
|
+
"name": "db",
|
|
103
|
+
"group": "default",
|
|
104
|
+
"credentials": {
|
|
105
|
+
"database": ":memory:",
|
|
106
|
+
"[production]": {
|
|
107
|
+
"database": "data.sqlite"
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
"ttl": 1800000,
|
|
111
|
+
"check": 60000,
|
|
112
|
+
"stats": 300000,
|
|
113
|
+
"size": 10485760,
|
|
114
|
+
"[production]": {
|
|
115
|
+
"size": 104857600
|
|
116
|
+
},
|
|
117
|
+
"chunks": 1000,
|
|
118
|
+
"retries": 3,
|
|
119
|
+
"auto": true,
|
|
120
|
+
"prune": true,
|
|
121
|
+
"validate": true,
|
|
122
|
+
"deploy": true,
|
|
123
|
+
"preload": false,
|
|
124
|
+
"wait": false,
|
|
125
|
+
"search": true,
|
|
126
|
+
"measure": false,
|
|
127
|
+
"tmpDir": false,
|
|
128
|
+
"baseDir": "temp"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const VError = require("verror");
|
|
4
|
+
|
|
5
|
+
async function allDone(iterable) {
|
|
6
|
+
const results = await Promise.allSettled(iterable);
|
|
7
|
+
const rejects = results.filter((entry) => {
|
|
8
|
+
return entry.status === "rejected";
|
|
9
|
+
});
|
|
10
|
+
if (rejects.length === 1) {
|
|
11
|
+
return Promise.reject(rejects[0].reason);
|
|
12
|
+
} else if (rejects.length > 1) {
|
|
13
|
+
return Promise.reject(new VError.MultiError(rejects.map((reject) => reject.reason)));
|
|
14
|
+
}
|
|
15
|
+
return results.map((entry) => {
|
|
16
|
+
return entry.value;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
Promise.allDone = allDone;
|
|
21
|
+
|
|
22
|
+
module.exports = {
|
|
23
|
+
allDone,
|
|
24
|
+
};
|
package/src/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
MigrationCheck: require("./migration-check").MigrationCheck,
|
|
5
|
+
RateLimiting: require("./rate-limiting").RateLimiting,
|
|
6
|
+
RedisClient: require("./redis-client").RedisClient,
|
|
7
|
+
ReplicationCache: require("./replication-cache").ReplicationCache,
|
|
8
|
+
};
|