From 68d912eb5a2d1869d4260658586ab6782b149942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20H=C3=B6ij?= Date: Mon, 1 Apr 2024 10:13:01 +0200 Subject: [PATCH 01/10] Use default import with latest Axios --- lib/axiosInstance.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/axiosInstance.js b/lib/axiosInstance.js index 05ea1270..2057b581 100644 --- a/lib/axiosInstance.js +++ b/lib/axiosInstance.js @@ -1,4 +1,4 @@ -const axios = require('axios'); +const axios = require('axios').default; const axiosInstance = axios.create(); From 4c7a73d971d5c6b850953dd73ad8c5798b5e5c76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20H=C3=B6ij?= Date: Fri, 19 Jul 2024 06:02:00 +0200 Subject: [PATCH 02/10] update dependencies to secure versions: follow-redirects, braces --- package-lock.json | 272 ++++++++++++++++++++++------------------------ 1 file changed, 128 insertions(+), 144 deletions(-) diff --git a/package-lock.json b/package-lock.json index d10ac49b..2c8ce527 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@terminusdb/terminusdb-client", - "version": "10.0.32", + "version": "10.0.33", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@terminusdb/terminusdb-client", - "version": "10.0.32", + "version": "10.0.33", "license": "Apache-2.0", "dependencies": { "axios": "1.6", @@ -3839,13 +3839,14 @@ "dev": true }, "node_modules/body-parser": { - "version": "1.20.1", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", - "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", + "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==", "dev": true, + "license": "MIT", "dependencies": { "bytes": "3.1.2", - "content-type": "~1.0.4", + "content-type": "~1.0.5", "debug": "2.6.9", "depd": "2.0.0", "destroy": "1.2.0", @@ -3853,7 +3854,7 @@ "iconv-lite": "0.4.24", "on-finished": "2.4.1", "qs": "6.11.0", - "raw-body": "2.5.1", + "raw-body": "2.5.2", "type-is": "~1.6.18", "unpipe": "1.0.0" }, @@ -3867,6 +3868,7 @@ "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.8" } @@ -3876,6 +3878,7 @@ "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, + "license": "MIT", "dependencies": { "ms": "2.0.0" } @@ -3884,22 +3887,8 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", - "dev": true - }, - "node_modules/body-parser/node_modules/qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", "dev": true, - "dependencies": { - "side-channel": "^1.0.4" - }, - "engines": { - "node": ">=0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } + "license": "MIT" }, "node_modules/bonjour-service": { "version": "1.0.14", @@ -3929,11 +3918,12 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "license": "MIT", "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -4688,10 +4678,11 @@ ] }, "node_modules/content-type": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", - "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.6" } @@ -4705,10 +4696,11 @@ } }, "node_modules/cookie": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", - "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.6" } @@ -5823,17 +5815,18 @@ } }, "node_modules/express": { - "version": "4.18.2", - "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", - "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", + "version": "4.19.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", + "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", "dev": true, + "license": "MIT", "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.20.1", + "body-parser": "1.20.2", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.5.0", + "cookie": "0.6.0", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", @@ -5891,21 +5884,6 @@ "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==", "dev": true }, - "node_modules/express/node_modules/qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", - "dev": true, - "dependencies": { - "side-channel": "^1.0.4" - }, - "engines": { - "node": ">=0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/express/node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -6050,9 +6028,10 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "license": "MIT", "dependencies": { "to-regex-range": "^5.0.1" }, @@ -6173,15 +6152,16 @@ "dev": true }, "node_modules/follow-redirects": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", "funding": [ { "type": "individual", "url": "https://github.com/sponsors/RubenVerborgh" } ], + "license": "MIT", "engines": { "node": ">=4.0" }, @@ -6826,6 +6806,7 @@ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", "dev": true, + "license": "MIT", "dependencies": { "safer-buffer": ">= 2.1.2 < 3" }, @@ -7149,6 +7130,7 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "license": "MIT", "engines": { "node": ">=0.12.0" } @@ -8994,16 +8976,16 @@ } }, "node_modules/jsdoc-parse": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsdoc-parse/-/jsdoc-parse-6.1.0.tgz", - "integrity": "sha512-n/hDGQJa69IBun1yZAjqzV4gVR41+flZ3bIlm9fKvNe2Xjsd1/+zCo2+R9ls8LxtePgIWbpA1jU7xkB2lRdLLg==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/jsdoc-parse/-/jsdoc-parse-6.2.1.tgz", + "integrity": "sha512-9viGRUUtWOk/G4V0+nQ6rfLucz5plxh5I74WbNSNm9h9NWugCDVX4jbG8hZP9QqKGpdTPDE+qJXzaYNos3wqTA==", "dev": true, + "license": "MIT", "dependencies": { "array-back": "^6.2.2", "lodash.omit": "^4.5.0", - "lodash.pick": "^4.4.0", "reduce-extract": "^1.0.0", - "sort-array": "^4.1.4", + "sort-array": "^4.1.5", "test-value": "^3.0.0" }, "engines": { @@ -9238,12 +9220,6 @@ "integrity": "sha512-sOQs2aqGpbl27tmCS1QNZA09Uqp01ZzWfDUoD+xzTii0E7dSQfRKcRetFwa+uXaxaqL+TKm7CgD2JdKP7aZBSw==", "dev": true }, - "node_modules/lodash.pick": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.pick/-/lodash.pick-4.4.0.tgz", - "integrity": "sha512-hXt6Ul/5yWjfklSGvLQl8vM//l3FtyHZeuelpzK6mm99pNvN9yTDruNZPEJZD1oWrqo+izBmB7oUfWgcCX7s4Q==", - "dev": true - }, "node_modules/log-symbols": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", @@ -9449,6 +9425,7 @@ "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.6" } @@ -10778,6 +10755,22 @@ "node": ">=6" } }, + "node_modules/qs": { + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.0.4" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", @@ -10817,10 +10810,11 @@ } }, "node_modules/raw-body": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", - "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", + "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", "dev": true, + "license": "MIT", "dependencies": { "bytes": "3.1.2", "http-errors": "2.0.0", @@ -10836,6 +10830,7 @@ "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.8" } @@ -11294,7 +11289,8 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/schema-utils": { "version": "2.7.1", @@ -12222,6 +12218,7 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "license": "MIT", "dependencies": { "is-number": "^7.0.0" }, @@ -12439,6 +12436,7 @@ "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", "dev": true, + "license": "MIT", "dependencies": { "media-typer": "0.3.0", "mime-types": "~2.1.24" @@ -12796,10 +12794,11 @@ } }, "node_modules/webpack-dev-middleware": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/webpack-dev-middleware/-/webpack-dev-middleware-5.3.3.tgz", - "integrity": "sha512-hj5CYrY0bZLB+eTO+x/j67Pkrquiy7kWepMHmUMoPsmcUaeEnQJqFzHJOyxgWlq746/wUuA64p9ta34Kyb01pA==", + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/webpack-dev-middleware/-/webpack-dev-middleware-5.3.4.tgz", + "integrity": "sha512-BVdTqhhs+0IfoeAf7EoH5WE+exCmqGerHfDM0IL096Px60Tq2Mn9MAbnaGUe6HiMa41KMCYF19gyzZmBcq/o4Q==", "dev": true, + "license": "MIT", "dependencies": { "colorette": "^2.0.10", "memfs": "^3.4.3", @@ -13213,16 +13212,17 @@ } }, "node_modules/ws": { - "version": "8.9.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.9.0.tgz", - "integrity": "sha512-Ja7nszREasGaYUYCI2k4lCKIRTt+y7XuqVoHR44YpI49TtryyqbqvDMn5eqfW7e6HzTukDRIsXqzVHScqRcafg==", + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", "dev": true, + "license": "MIT", "engines": { "node": ">=10.0.0" }, "peerDependencies": { "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" + "utf-8-validate": ">=5.0.2" }, "peerDependenciesMeta": { "bufferutil": { @@ -16215,13 +16215,13 @@ "dev": true }, "body-parser": { - "version": "1.20.1", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", - "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", + "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==", "dev": true, "requires": { "bytes": "3.1.2", - "content-type": "~1.0.4", + "content-type": "~1.0.5", "debug": "2.6.9", "depd": "2.0.0", "destroy": "1.2.0", @@ -16229,7 +16229,7 @@ "iconv-lite": "0.4.24", "on-finished": "2.4.1", "qs": "6.11.0", - "raw-body": "2.5.1", + "raw-body": "2.5.2", "type-is": "~1.6.18", "unpipe": "1.0.0" }, @@ -16254,15 +16254,6 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true - }, - "qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", - "dev": true, - "requires": { - "side-channel": "^1.0.4" - } } } }, @@ -16294,11 +16285,11 @@ } }, "braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "requires": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" } }, "browser-stdout": { @@ -16869,9 +16860,9 @@ } }, "content-type": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", - "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", "dev": true }, "convert-source-map": { @@ -16883,9 +16874,9 @@ } }, "cookie": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", - "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", "dev": true }, "cookie-signature": { @@ -17707,17 +17698,17 @@ } }, "express": { - "version": "4.18.2", - "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", - "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", + "version": "4.19.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", + "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", "dev": true, "requires": { "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.20.1", + "body-parser": "1.20.2", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.5.0", + "cookie": "0.6.0", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", @@ -17772,15 +17763,6 @@ "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==", "dev": true }, - "qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", - "dev": true, - "requires": { - "side-channel": "^1.0.4" - } - }, "safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -17896,9 +17878,9 @@ } }, "fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "requires": { "to-regex-range": "^5.0.1" } @@ -17996,9 +17978,9 @@ "dev": true }, "follow-redirects": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==" + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==" }, "foreground-child": { "version": "2.0.0", @@ -20005,16 +19987,15 @@ } }, "jsdoc-parse": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsdoc-parse/-/jsdoc-parse-6.1.0.tgz", - "integrity": "sha512-n/hDGQJa69IBun1yZAjqzV4gVR41+flZ3bIlm9fKvNe2Xjsd1/+zCo2+R9ls8LxtePgIWbpA1jU7xkB2lRdLLg==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/jsdoc-parse/-/jsdoc-parse-6.2.1.tgz", + "integrity": "sha512-9viGRUUtWOk/G4V0+nQ6rfLucz5plxh5I74WbNSNm9h9NWugCDVX4jbG8hZP9QqKGpdTPDE+qJXzaYNos3wqTA==", "dev": true, "requires": { "array-back": "^6.2.2", "lodash.omit": "^4.5.0", - "lodash.pick": "^4.4.0", "reduce-extract": "^1.0.0", - "sort-array": "^4.1.4", + "sort-array": "^4.1.5", "test-value": "^3.0.0" } }, @@ -20195,12 +20176,6 @@ "integrity": "sha512-sOQs2aqGpbl27tmCS1QNZA09Uqp01ZzWfDUoD+xzTii0E7dSQfRKcRetFwa+uXaxaqL+TKm7CgD2JdKP7aZBSw==", "dev": true }, - "lodash.pick": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.pick/-/lodash.pick-4.4.0.tgz", - "integrity": "sha512-hXt6Ul/5yWjfklSGvLQl8vM//l3FtyHZeuelpzK6mm99pNvN9yTDruNZPEJZD1oWrqo+izBmB7oUfWgcCX7s4Q==", - "dev": true - }, "log-symbols": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", @@ -21364,6 +21339,15 @@ "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", "dev": true }, + "qs": { + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "dev": true, + "requires": { + "side-channel": "^1.0.4" + } + }, "queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", @@ -21386,9 +21370,9 @@ "dev": true }, "raw-body": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", - "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", + "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", "dev": true, "requires": { "bytes": "3.1.2", @@ -22886,9 +22870,9 @@ } }, "webpack-dev-middleware": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/webpack-dev-middleware/-/webpack-dev-middleware-5.3.3.tgz", - "integrity": "sha512-hj5CYrY0bZLB+eTO+x/j67Pkrquiy7kWepMHmUMoPsmcUaeEnQJqFzHJOyxgWlq746/wUuA64p9ta34Kyb01pA==", + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/webpack-dev-middleware/-/webpack-dev-middleware-5.3.4.tgz", + "integrity": "sha512-BVdTqhhs+0IfoeAf7EoH5WE+exCmqGerHfDM0IL096Px60Tq2Mn9MAbnaGUe6HiMa41KMCYF19gyzZmBcq/o4Q==", "dev": true, "requires": { "colorette": "^2.0.10", @@ -23167,9 +23151,9 @@ } }, "ws": { - "version": "8.9.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.9.0.tgz", - "integrity": "sha512-Ja7nszREasGaYUYCI2k4lCKIRTt+y7XuqVoHR44YpI49TtryyqbqvDMn5eqfW7e6HzTukDRIsXqzVHScqRcafg==", + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", "dev": true, "requires": {} }, From 2379089b25cbaa4f0bf39015c92816ddb745cc7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20H=C3=B6ij?= Date: Sat, 20 Jul 2024 14:44:01 +0200 Subject: [PATCH 03/10] fixes terminusdb/terminusdb-client-js#304 --- lib/axiosInstance.js | 8 +++++++- package-lock.json | 19 ++++++++++--------- package.json | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/axiosInstance.js b/lib/axiosInstance.js index 2057b581..bf2c8370 100644 --- a/lib/axiosInstance.js +++ b/lib/axiosInstance.js @@ -1,5 +1,11 @@ const axios = require('axios').default; -const axiosInstance = axios.create(); +// Add workaround for axios formdata issue +// Added transformRequest based on on issue resolution suggestion here: +// https://github.com/axios/axios/issues/5986#issuecomment-2029933275 +const axiosInstance = axios.create({ + transformRequest: [(data) => data, + ] +}); module.exports = axiosInstance; diff --git a/package-lock.json b/package-lock.json index 2c8ce527..afe06c73 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "10.0.33", "license": "Apache-2.0", "dependencies": { - "axios": "1.6", + "axios": "^1.7.2", "follow-redirects": "^1.14.8", "form-data": "^4.0.0", "jest": "^29.1.2", @@ -3481,11 +3481,12 @@ "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, "node_modules/axios": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz", - "integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==", + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.2.tgz", + "integrity": "sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==", + "license": "MIT", "dependencies": { - "follow-redirects": "^1.15.0", + "follow-redirects": "^1.15.6", "form-data": "^4.0.0", "proxy-from-env": "^1.1.0" } @@ -15947,11 +15948,11 @@ "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, "axios": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz", - "integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==", + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.2.tgz", + "integrity": "sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==", "requires": { - "follow-redirects": "^1.15.0", + "follow-redirects": "^1.15.6", "form-data": "^4.0.0", "proxy-from-env": "^1.1.0" } diff --git a/package.json b/package.json index d24c00f0..2822a577 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "author": "kevin@terminusdb.com", "license": "Apache-2.0", "dependencies": { - "axios": "1.6", + "axios": "^1.7.2", "follow-redirects": "^1.14.8", "form-data": "^4.0.0", "jest": "^29.1.2", From cbf5a4a3d9a21417a6b8de6abdba4d4f99598160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20H=C3=B6ij?= Date: Sat, 20 Jul 2024 14:49:01 +0200 Subject: [PATCH 04/10] lint god appeasal --- lib/axiosInstance.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/axiosInstance.js b/lib/axiosInstance.js index bf2c8370..06ff3d94 100644 --- a/lib/axiosInstance.js +++ b/lib/axiosInstance.js @@ -5,7 +5,7 @@ const axios = require('axios').default; // https://github.com/axios/axios/issues/5986#issuecomment-2029933275 const axiosInstance = axios.create({ transformRequest: [(data) => data, - ] + ], }); module.exports = axiosInstance; From d0a70f4cde36430ac981c0e6e15de27e6890108f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20H=C3=B6ij?= Date: Sat, 20 Jul 2024 19:41:42 +0200 Subject: [PATCH 05/10] fixes terminusdb/terminusdb-client-js#304 --- lib/axiosInstance.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/axiosInstance.js b/lib/axiosInstance.js index 06ff3d94..b652a3cd 100644 --- a/lib/axiosInstance.js +++ b/lib/axiosInstance.js @@ -4,8 +4,9 @@ const axios = require('axios').default; // Added transformRequest based on on issue resolution suggestion here: // https://github.com/axios/axios/issues/5986#issuecomment-2029933275 const axiosInstance = axios.create({ - transformRequest: [(data) => data, - ], + transformRequest: axios.defaults.transformRequest, + transformResponse: axios.defaults.transformResponse, + ...axios.config, }); module.exports = axiosInstance; From a96313598b62b8ca9de914f4faea94b74f7e6024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20H=C3=B6ij?= Date: Sat, 20 Jul 2024 23:49:51 +0200 Subject: [PATCH 06/10] content-type casing error and axios upgrade regression --- lib/axiosInstance.js | 9 +-------- lib/dispatchRequest.js | 4 +++- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/axiosInstance.js b/lib/axiosInstance.js index b652a3cd..fc1e9dc1 100644 --- a/lib/axiosInstance.js +++ b/lib/axiosInstance.js @@ -1,12 +1,5 @@ const axios = require('axios').default; -// Add workaround for axios formdata issue -// Added transformRequest based on on issue resolution suggestion here: -// https://github.com/axios/axios/issues/5986#issuecomment-2029933275 -const axiosInstance = axios.create({ - transformRequest: axios.defaults.transformRequest, - transformResponse: axios.defaults.transformResponse, - ...axios.config, -}); +const axiosInstance = axios.create({}); module.exports = axiosInstance; diff --git a/lib/dispatchRequest.js b/lib/dispatchRequest.js index 4c8fcf28..19800188 100644 --- a/lib/dispatchRequest.js +++ b/lib/dispatchRequest.js @@ -215,7 +215,9 @@ function DispatchRequest(url, action, payload, local_auth, remote_auth = null, c } default: { options.headers = options.headers ? options.headers : {}; - options.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(!options.headers['content-type'] && !options.headers['Content-Type']) { + options.headers['Content-Type'] = 'application/json; charset=utf-8'; + } const compressedContentPost = checkPayload(payload, options, compress); return axiosInstance .post(url, compressedContentPost || payload || {}, options) From 35ce8e28a753fdb623007df630e2f812839c7f4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20H=C3=B6ij?= Date: Sat, 20 Jul 2024 23:50:50 +0200 Subject: [PATCH 07/10] Remediate typescript warning --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 8007a438..21ab9ee2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,10 +1,10 @@ { "include": ["lib/**/*","./index.js"], - "esModuleInterop" : true, "compilerOptions": { "allowJs": true, "declaration": true, "emitDeclarationOnly": true, + "esModuleInterop": true, "outDir": "dist/typescript/" } } \ No newline at end of file From 5f0f88e4f461e7ecf56ed742641c1fb3cd6cbb41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20H=C3=B6ij?= Date: Sat, 20 Jul 2024 23:52:15 +0200 Subject: [PATCH 08/10] Add tests for CSV functionality + axios --- integration_tests/create_database.test.ts | 7 +- integration_tests/data/employees.csv | 5 ++ integration_tests/data/employees_limit1.ts | 16 ++++ integration_tests/woql_client.test.ts | 87 ++++++++++++++++++++++ 4 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 integration_tests/data/employees.csv create mode 100644 integration_tests/data/employees_limit1.ts create mode 100644 integration_tests/woql_client.test.ts diff --git a/integration_tests/create_database.test.ts b/integration_tests/create_database.test.ts index 3db17402..d1fe3bb3 100644 --- a/integration_tests/create_database.test.ts +++ b/integration_tests/create_database.test.ts @@ -30,7 +30,7 @@ describe('Create a database, schema and insert data', () => { }) test('Insert Document Child Tom', async () => { - const person = {"age":"10","name":"Tom","@type":"Child"} + const person = {"age":"10","name":"Tom","@type":"Child" } const result = await client.addDocument(person); expect(result).toStrictEqual(["terminusdb:///data/Child/Tom" ]); }) @@ -47,6 +47,11 @@ describe('Create a database, schema and insert data', () => { expect(result).toStrictEqual(["terminusdb:///data/Parent/Tom%20Senior" ]); }) + test('Get document history on an object', async () => { + const result = await client.getDocumentHistory("Child/Tom"); + expect(result[0].message).toStrictEqual("add a new document"); + }) + test('Query Person by name', async () => { const queryTemplate = {"name":"Tom", "@type":"Person" } const result = await client.getDocument({query:queryTemplate}); diff --git a/integration_tests/data/employees.csv b/integration_tests/data/employees.csv new file mode 100644 index 00000000..71b38f25 --- /dev/null +++ b/integration_tests/data/employees.csv @@ -0,0 +1,5 @@ +EmployeeId,Name,Title,Team,Manager +001,Destiny Norris,Marketing Manager,Marketing, +002,Darci Prosser,Creative Writer,Marketing,001 +003,Alanah Bloggs,Frontend Developer,IT,004 +004,Fabian Dalby,Web Service Manager,IT, \ No newline at end of file diff --git a/integration_tests/data/employees_limit1.ts b/integration_tests/data/employees_limit1.ts new file mode 100644 index 00000000..df5f8776 --- /dev/null +++ b/integration_tests/data/employees_limit1.ts @@ -0,0 +1,16 @@ +export const mock_employees_limit_1 = [ + { + "Manager": { + "@type": "xsd:string", + "@value": "", + }, + "Name": { + "@type": "xsd:string", + "@value": "Destiny Norris", + }, + "Title": { + "@type": "xsd:string", + "@value": "Marketing Manager", + }, + }, + ] \ No newline at end of file diff --git a/integration_tests/woql_client.test.ts b/integration_tests/woql_client.test.ts new file mode 100644 index 00000000..ae357ec2 --- /dev/null +++ b/integration_tests/woql_client.test.ts @@ -0,0 +1,87 @@ +//@ts-check +import { describe, expect, test, beforeAll } from '@jest/globals'; +import { WOQLClient, WOQL } from '../index.js'; +import { DbDetails, DocParamsGet } from '../dist/typescript/lib/typedef.js'; +import schemaJson from './persons_schema' +import { mock_employees_limit_1 } from './data/employees_limit1'; +import fs from 'fs'; + +let client: WOQLClient //= new WOQLClient('http://localhost:6363'); + +beforeAll(() => { + client = new WOQLClient("http://localhost:6363", { user: 'admin', organization: 'admin', key: 'root' }) +}); + +const db01 = 'db__test_woql'; + +describe('Create a database, schema and insert data', () => { + test('Create a database', async () => { + const dbObj: DbDetails = { label: db01, comment: 'add db', schema: true } + const result = await client.createDatabase(db01, dbObj); + //woqlClient return only the data no status + expect(result["@type"]).toEqual("api:DbCreateResponse"); + expect(result["api:status"]).toEqual("api:success"); + }); + + test('Create a schema', async () => { + const result = await client.addDocument(schemaJson, { graph_type: "schema", full_replace: true }); + expect(result).toStrictEqual(["Child", "Person", "Parent"]); + }) + + test('Query with CSV upload from file', async () => { + const query = WOQL.limit(1).and( + WOQL.get( + WOQL.as('Name', 'v:Name') + .as('Manager', 'v:Manager') + .as('Title', 'v:Title'), + WOQL.post("./integration_tests/data/employees.csv") + ), + ); + const result = await client.query(query, undefined, undefined, undefined, undefined,); + expect(result?.bindings).toStrictEqual(mock_employees_limit_1); + }); + + test('Query with CSV upload as resource attachment', async () => { + const query = WOQL.limit(1).and( + WOQL.get( + WOQL.as('Name', 'v:Name') + .as('Manager', 'v:Manager') + .as('Title', 'v:Title'), + WOQL.post("employees.csv") + ), + ); + const data = fs.readFileSync('./integration_tests/data/employees.csv'); + const result = await client.query(query, undefined, undefined, undefined, undefined, [{ + filename: "employees.csv", + data: data, + }]); + expect(result?.bindings).toStrictEqual(mock_employees_limit_1); + }); + + test('Get branches from the server (only main)', async () => { + const result = await client.getBranches(); + expect(result.main["@id"]).toStrictEqual("Branch/main"); + expect(Object.keys(result)).toStrictEqual(["main"]); + }); + + test('Get commits log from the server', async () => { + const result = await client.getCommitsLog(); + expect(result.length).toStrictEqual(1); + expect(result[0]["@type"]).toStrictEqual("ValidCommit"); + }); + + test('Get prefixes from the server', async () => { + const result = await client.getPrefixes(); + expect(result).toStrictEqual({"@base": "terminusdb:///data/", "@schema": "terminusdb:///schema#", "@type": "Context"}); + }); + + test('Get userOrganisations from the server', async () => { + const result = (await client.getUserOrganizations()).filter(org => org["@id"] === "Organization/admin"); + expect(result[0]["@id"]).toStrictEqual("Organization/admin"); + }); + + test('Delete a database', async () => { + const result = await client.deleteDatabase(db01); + expect(result).toStrictEqual({ '@type': 'api:DbDeleteResponse', 'api:status': 'api:success' }); + }); +}); From a96a606af42a93d3dfb28cb0fec70ff0c9416afc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20H=C3=B6ij?= Date: Sat, 20 Jul 2024 23:54:11 +0200 Subject: [PATCH 09/10] Linting fix --- lib/dispatchRequest.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dispatchRequest.js b/lib/dispatchRequest.js index 19800188..0b4b5e85 100644 --- a/lib/dispatchRequest.js +++ b/lib/dispatchRequest.js @@ -215,7 +215,7 @@ function DispatchRequest(url, action, payload, local_auth, remote_auth = null, c } default: { options.headers = options.headers ? options.headers : {}; - if(!options.headers['content-type'] && !options.headers['Content-Type']) { + if (!options.headers['content-type'] && !options.headers['Content-Type']) { options.headers['Content-Type'] = 'application/json; charset=utf-8'; } const compressedContentPost = checkPayload(payload, options, compress); From bf6aedae105a1ad3ab7b54ad0462da6a15f22c1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20H=C3=B6ij?= Date: Sat, 20 Jul 2024 23:56:58 +0200 Subject: [PATCH 10/10] Enable string CSV resources --- lib/typedef.js | 6 ++++++ lib/woqlClient.js | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/typedef.js b/lib/typedef.js index 87364aab..46227f4a 100644 --- a/lib/typedef.js +++ b/lib/typedef.js @@ -184,4 +184,10 @@ const { ACTIONS } = Utils.ACTIONS; * @property {number} [start] - Amount of commits to show, 10 is the default */ +/** + * @typedef {Object} NamedResourceData - { filename: "data.csv", data: "col1;col2\nval1;val2" } + * @property {string} filename - Filename referenced in the WOQL query + * @property {string|Blob} data - Attached data, such as CSV contents + */ + module.exports = {}; diff --git a/lib/woqlClient.js b/lib/woqlClient.js index 5c379929..adf7033a 100644 --- a/lib/woqlClient.js +++ b/lib/woqlClient.js @@ -635,14 +635,19 @@ function getResourceObjects(queryObject, result_array) { * @param {string} [lastDataVersion] the last data version tracking id. * @param {boolean} [getDataVersion] If true the function will return object having result * and dataVersion. + * @param {Array} [resources] csv resources supplied as strings * @returns {Promise} A promise that returns the call response object or object having *result* * and *dataVersion* object if ***getDataVersion*** parameter is true, or an Error if rejected. * @example * const result = await client.query(WOQL.star()) */ -WOQLClient.prototype.query = function (woql, commitMsg, allWitnesses, lastDataVersion = '', getDataVersion = false) { +WOQLClient.prototype.query = function (woql, commitMsg, allWitnesses, lastDataVersion = '', getDataVersion = false, resources = []) { allWitnesses = allWitnesses || false; commitMsg = commitMsg || 'Commit generated with javascript client without message'; + + const providedResourcesLookupMap = (resources ?? []) + .reduce((map, res) => ({ ...map, [(res.filename).split('/').pop()]: res.data }), {}); + if (woql && woql.json && (!woql.containsUpdate() || commitMsg)) { const doql = woql.containsUpdate() ? this.generateCommitInfo(commitMsg) : {}; doql.query = woql.json(); @@ -655,9 +660,17 @@ WOQLClient.prototype.query = function (woql, commitMsg, allWitnesses, lastDataVe const formData = new FormData(); resourceObjects.forEach((resourceObject) => { + const providedResourceInsteadOfFile = typeof resourceObject.source.post === 'string' + ? providedResourcesLookupMap?.[resourceObject.source.post.split('/').pop()] + : undefined; + const fileName = resourceObject.source.post.split('/').pop(); - formData.append('file', fs.createReadStream(resourceObject.source.post)); + if (providedResourceInsteadOfFile) { + formData.append('file', providedResourceInsteadOfFile, { filename: fileName, contentType: 'application/csv' }); + } else { + formData.append('file', fs.createReadStream(resourceObject.source.post)); + } resourceObject.source.post = fileName; });