From 131e587e04b01f8efdf455cd9a33d8be15efdc9c Mon Sep 17 00:00:00 2001 From: Siddharth VP Date: Sun, 9 Jul 2023 14:39:45 +0530 Subject: [PATCH] add cassandra client --- cassandra.ts | 16 +++++ package-lock.json | 151 +++++++++++++++++++++++++++++++++------------- package.json | 1 + 3 files changed, 127 insertions(+), 41 deletions(-) create mode 100644 cassandra.ts diff --git a/cassandra.ts b/cassandra.ts new file mode 100644 index 0000000..f65fa51 --- /dev/null +++ b/cassandra.ts @@ -0,0 +1,16 @@ +import {Client, DseClientOptions} from 'cassandra-driver'; +import {AuthManager} from "./botbase"; +import {mapPath} from "./utils"; + +export class Cassandra extends Client { + constructor(keyspace: string = 'toolforge', conf: DseClientOptions = {}) { + super({ + cloud: { + secureConnectBundle: mapPath('~/secure-connect-astra-db-1001.zip') + }, + credentials: AuthManager.get('cassandra-astra-db-1001'), + keyspace: keyspace, + ...conf + }); + } +} diff --git a/package-lock.json b/package-lock.json index 3a86f6b..d3dbc6c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "@types/nodemailer": "^6.4.7", "@types/object-hash": "^1.3.4", "async-redis": "^1.1.7", + "cassandra-driver": "^4.6.4", "eventsource": "^1.0.7", "express": "^4.17.1", "jsdom": "^16.2.1", @@ -36,6 +37,9 @@ "ts-mocha": "^8.0.0", "ts-node": "^9.0.0", "typescript": "^4.2.4" + }, + "engines": { + "node": ">= 18.14.2" } }, "node_modules/@babel/helper-validator-identifier": { @@ -224,11 +228,11 @@ } }, "node_modules/@types/async-redis": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@types/async-redis/-/async-redis-1.1.1.tgz", - "integrity": "sha512-NUS/27r3XP+3hXAzsV9dGnk6JXXIQErP5xHHlGVqnC+V0gBqAzQy9MojjcDWmhR9nhZ8xp3p6GvR4X3Yl5U7Kw==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@types/async-redis/-/async-redis-1.1.3.tgz", + "integrity": "sha512-3jMi8dvD2NWutuGi6XzUwvMl4qm8WGdZy+kYEc5Jgc77o/3VhMaP44XDKoz+5nKggDEkyoIiDIas1rp/QschaQ==", "dependencies": { - "@types/redis": "*" + "@types/redis": "^2.8.0" } }, "node_modules/@types/body-parser": { @@ -291,6 +295,11 @@ "dev": true, "optional": true }, + "node_modules/@types/long": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz", + "integrity": "sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA==" + }, "node_modules/@types/mime": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.2.tgz", @@ -331,9 +340,9 @@ "integrity": "sha512-ewFXqrQHlFsgc09MK5jP5iR7vumV/BYayNC6PgJO2LPe8vrnNFyjQjSppfEngITi0qvfKtzFvgKymGheFM9UOA==" }, "node_modules/@types/redis": { - "version": "2.8.28", - "resolved": "https://registry.npmjs.org/@types/redis/-/redis-2.8.28.tgz", - "integrity": "sha512-8l2gr2OQ969ypa7hFOeKqtFoY70XkHxISV0pAwmQ2nm6CSPb1brmTmqJCGGrekCo+pAZyWlNXr+Kvo6L/1wijA==", + "version": "2.8.32", + "resolved": "https://registry.npmjs.org/@types/redis/-/redis-2.8.32.tgz", + "integrity": "sha512-7jkMKxcGq9p242exlbsVzuJb57KqHRhNl4dHoQu2Y5v9bCAbtIXXH0R3HleSQW4CTOqpHIYUW3t6tpUj4BVQ+w==", "dependencies": { "@types/node": "*" } @@ -443,6 +452,14 @@ "node": ">=0.4.0" } }, + "node_modules/adm-zip": { + "version": "0.5.10", + "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.10.tgz", + "integrity": "sha512-x0HvcHqVJNTPk/Bw8JbLWlWoo6Wwnsug0fnYYro1HBrjxZ3G7/AZk7Ahv8JwDe1uIcz8eBqvu86FuF1POiG7vQ==", + "engines": { + "node": ">=6.0" + } + }, "node_modules/ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", @@ -577,6 +594,19 @@ "node": ">=7.6.0" } }, + "node_modules/async-redis/node_modules/redis": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/redis/-/redis-2.8.0.tgz", + "integrity": "sha512-M1OkonEQwtRmZv4tEWF2VgpG0JWJ8Fv1PhlgT5+B+uNq2cA3Rt1Yt/ryoR+vQNOQcIEgdCdfH0jr3bDpihAw1A==", + "dependencies": { + "double-ended-queue": "^2.1.0-0", + "redis-commands": "^1.2.0", + "redis-parser": "^2.6.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -786,6 +816,28 @@ "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" }, + "node_modules/cassandra-driver": { + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/cassandra-driver/-/cassandra-driver-4.6.4.tgz", + "integrity": "sha512-SksbIK0cZ2QZRx8ti7w+PnLqldyY+6kU2gRWFChwXFTtrD/ce8cQICDEHxyPwx+DeILwRnMrPf9cjUGizYw9Vg==", + "dependencies": { + "@types/long": "^4.0.0", + "@types/node": ">=8", + "adm-zip": "^0.5.3", + "long": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cassandra-driver/node_modules/long": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/long/-/long-2.4.0.tgz", + "integrity": "sha512-ijUtjmO/n2A5PaosNG9ZGDsQ3vxJg7ZW8vsY8Kp0f2yIZWhSJvjmegV7t+9RPQKxKrvj8yKGehhS+po14hPLGQ==", + "engines": { + "node": ">=0.6" + } + }, "node_modules/chai": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.4.tgz", @@ -1196,7 +1248,7 @@ "node_modules/double-ended-queue": { "version": "2.1.0-0", "resolved": "https://registry.npmjs.org/double-ended-queue/-/double-ended-queue-2.1.0-0.tgz", - "integrity": "sha1-ED01J/0xUo9AGIEwyEHv3XgmTlw=" + "integrity": "sha512-+BNfZ+deCo8hMNpDqDnvT+c0XpJ5cUa6mqYq89bho2Ifze4URTqRkcwR399hWoTrTkbZ/XJYDgP6rc7pRgffEQ==" }, "node_modules/ecc-jsbn": { "version": "0.1.2", @@ -4026,19 +4078,6 @@ "util-deprecate": "~1.0.1" } }, - "node_modules/redis": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/redis/-/redis-2.8.0.tgz", - "integrity": "sha512-M1OkonEQwtRmZv4tEWF2VgpG0JWJ8Fv1PhlgT5+B+uNq2cA3Rt1Yt/ryoR+vQNOQcIEgdCdfH0jr3bDpihAw1A==", - "dependencies": { - "double-ended-queue": "^2.1.0-0", - "redis-commands": "^1.2.0", - "redis-parser": "^2.6.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/redis-commands": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.7.0.tgz", @@ -4047,7 +4086,7 @@ "node_modules/redis-parser": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-2.6.0.tgz", - "integrity": "sha1-Uu0J2srBCPGmMcB+m2mUHnoZUEs=", + "integrity": "sha512-9Hdw19gwXFBJdN8ENUoNVJFRyMDFrE/ZBClPicKYDPwNPJ4ST1TedAHYNSiGKElwh2vrmRGMoJYbVdJd+WQXIw==", "engines": { "node": ">=0.10.0" } @@ -5511,11 +5550,11 @@ } }, "@types/async-redis": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@types/async-redis/-/async-redis-1.1.1.tgz", - "integrity": "sha512-NUS/27r3XP+3hXAzsV9dGnk6JXXIQErP5xHHlGVqnC+V0gBqAzQy9MojjcDWmhR9nhZ8xp3p6GvR4X3Yl5U7Kw==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@types/async-redis/-/async-redis-1.1.3.tgz", + "integrity": "sha512-3jMi8dvD2NWutuGi6XzUwvMl4qm8WGdZy+kYEc5Jgc77o/3VhMaP44XDKoz+5nKggDEkyoIiDIas1rp/QschaQ==", "requires": { - "@types/redis": "*" + "@types/redis": "^2.8.0" } }, "@types/body-parser": { @@ -5578,6 +5617,11 @@ "dev": true, "optional": true }, + "@types/long": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz", + "integrity": "sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA==" + }, "@types/mime": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.2.tgz", @@ -5618,9 +5662,9 @@ "integrity": "sha512-ewFXqrQHlFsgc09MK5jP5iR7vumV/BYayNC6PgJO2LPe8vrnNFyjQjSppfEngITi0qvfKtzFvgKymGheFM9UOA==" }, "@types/redis": { - "version": "2.8.28", - "resolved": "https://registry.npmjs.org/@types/redis/-/redis-2.8.28.tgz", - "integrity": "sha512-8l2gr2OQ969ypa7hFOeKqtFoY70XkHxISV0pAwmQ2nm6CSPb1brmTmqJCGGrekCo+pAZyWlNXr+Kvo6L/1wijA==", + "version": "2.8.32", + "resolved": "https://registry.npmjs.org/@types/redis/-/redis-2.8.32.tgz", + "integrity": "sha512-7jkMKxcGq9p242exlbsVzuJb57KqHRhNl4dHoQu2Y5v9bCAbtIXXH0R3HleSQW4CTOqpHIYUW3t6tpUj4BVQ+w==", "requires": { "@types/node": "*" } @@ -5715,6 +5759,11 @@ "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz", "integrity": "sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA==" }, + "adm-zip": { + "version": "0.5.10", + "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.10.tgz", + "integrity": "sha512-x0HvcHqVJNTPk/Bw8JbLWlWoo6Wwnsug0fnYYro1HBrjxZ3G7/AZk7Ahv8JwDe1uIcz8eBqvu86FuF1POiG7vQ==" + }, "ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", @@ -5819,6 +5868,18 @@ "requires": { "redis": "^2.8.0", "redis-commands": "^1.3.1" + }, + "dependencies": { + "redis": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/redis/-/redis-2.8.0.tgz", + "integrity": "sha512-M1OkonEQwtRmZv4tEWF2VgpG0JWJ8Fv1PhlgT5+B+uNq2cA3Rt1Yt/ryoR+vQNOQcIEgdCdfH0jr3bDpihAw1A==", + "requires": { + "double-ended-queue": "^2.1.0-0", + "redis-commands": "^1.2.0", + "redis-parser": "^2.6.0" + } + } } }, "asynckit": { @@ -5990,6 +6051,24 @@ "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" }, + "cassandra-driver": { + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/cassandra-driver/-/cassandra-driver-4.6.4.tgz", + "integrity": "sha512-SksbIK0cZ2QZRx8ti7w+PnLqldyY+6kU2gRWFChwXFTtrD/ce8cQICDEHxyPwx+DeILwRnMrPf9cjUGizYw9Vg==", + "requires": { + "@types/long": "^4.0.0", + "@types/node": ">=8", + "adm-zip": "^0.5.3", + "long": "^2.2.0" + }, + "dependencies": { + "long": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/long/-/long-2.4.0.tgz", + "integrity": "sha512-ijUtjmO/n2A5PaosNG9ZGDsQ3vxJg7ZW8vsY8Kp0f2yIZWhSJvjmegV7t+9RPQKxKrvj8yKGehhS+po14hPLGQ==" + } + } + }, "chai": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.4.tgz", @@ -6308,7 +6387,7 @@ "double-ended-queue": { "version": "2.1.0-0", "resolved": "https://registry.npmjs.org/double-ended-queue/-/double-ended-queue-2.1.0-0.tgz", - "integrity": "sha1-ED01J/0xUo9AGIEwyEHv3XgmTlw=" + "integrity": "sha512-+BNfZ+deCo8hMNpDqDnvT+c0XpJ5cUa6mqYq89bho2Ifze4URTqRkcwR399hWoTrTkbZ/XJYDgP6rc7pRgffEQ==" }, "ecc-jsbn": { "version": "0.1.2", @@ -8479,16 +8558,6 @@ "util-deprecate": "~1.0.1" } }, - "redis": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/redis/-/redis-2.8.0.tgz", - "integrity": "sha512-M1OkonEQwtRmZv4tEWF2VgpG0JWJ8Fv1PhlgT5+B+uNq2cA3Rt1Yt/ryoR+vQNOQcIEgdCdfH0jr3bDpihAw1A==", - "requires": { - "double-ended-queue": "^2.1.0-0", - "redis-commands": "^1.2.0", - "redis-parser": "^2.6.0" - } - }, "redis-commands": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.7.0.tgz", @@ -8497,7 +8566,7 @@ "redis-parser": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-2.6.0.tgz", - "integrity": "sha1-Uu0J2srBCPGmMcB+m2mUHnoZUEs=" + "integrity": "sha512-9Hdw19gwXFBJdN8ENUoNVJFRyMDFrE/ZBClPicKYDPwNPJ4ST1TedAHYNSiGKElwh2vrmRGMoJYbVdJd+WQXIw==" }, "regexpp": { "version": "3.1.0", diff --git a/package.json b/package.json index ad81a01..eb41530 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "@types/nodemailer": "^6.4.7", "@types/object-hash": "^1.3.4", "async-redis": "^1.1.7", + "cassandra-driver": "^4.6.4", "eventsource": "^1.0.7", "express": "^4.17.1", "jsdom": "^16.2.1",