From 70f3c7313203bac685695b12c375a3570b1cab62 Mon Sep 17 00:00:00 2001 From: Steven Roebert Date: Mon, 7 Oct 2024 10:58:12 +0200 Subject: [PATCH] Added keyv version 5 support to KeyvAdapter --- .changeset/afraid-badgers-glow.md | 5 + package-lock.json | 288 +++++++++++------- packages/keyvAdapter/package.json | 2 +- .../src/__tests__/KeyvAdapter.test.ts | 91 +++--- packages/keyvAdapter/src/index.ts | 12 +- 5 files changed, 234 insertions(+), 164 deletions(-) create mode 100644 .changeset/afraid-badgers-glow.md diff --git a/.changeset/afraid-badgers-glow.md b/.changeset/afraid-badgers-glow.md new file mode 100644 index 00000000..1c0e4d82 --- /dev/null +++ b/.changeset/afraid-badgers-glow.md @@ -0,0 +1,5 @@ +--- +"@apollo/utils.keyvadapter": major +--- + +Added keyv 5 support diff --git a/package-lock.json b/package-lock.json index c56a0306..d9ee3977 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3948,6 +3948,37 @@ "integrity": "sha512-gbkePEBupNydxCelHCESvFSFM8XPh1Zs/OAVRW/rKpEqPAl5PbOM90Si8mv9bvnR53uPD2s/FiRxdvSejpRJew==", "dev": true }, + "node_modules/@keyv/serialize": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@keyv/serialize/-/serialize-1.0.1.tgz", + "integrity": "sha512-kKXeynfORDGPUEEl2PvTExM2zs+IldC6ZD8jPcfvI351MDNtfMlw9V9s4XZXuJNDK2qR5gbEKxRyoYx3quHUVQ==", + "dependencies": { + "buffer": "^6.0.3" + } + }, + "node_modules/@keyv/serialize/node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, "node_modules/@manypkg/find-root": { "version": "1.1.0", "dev": true, @@ -4338,10 +4369,6 @@ "integrity": "sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg==", "dev": true }, - "node_modules/@types/json-buffer": { - "version": "3.0.0", - "license": "MIT" - }, "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", @@ -5237,7 +5264,6 @@ "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", - "dev": true, "funding": [ { "type": "github", @@ -5286,10 +5312,11 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "license": "MIT", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -5879,17 +5906,6 @@ "node": ">=4.0.0" } }, - "node_modules/compress-brotli": { - "version": "1.3.8", - "license": "MIT", - "dependencies": { - "@types/json-buffer": "~3.0.0", - "json-buffer": "~3.0.1" - }, - "engines": { - "node": ">= 12" - } - }, "node_modules/concat-map": { "version": "0.0.1", "dev": true, @@ -6359,9 +6375,9 @@ } }, "node_modules/dset": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/dset/-/dset-3.1.3.tgz", - "integrity": "sha512-20TuZZHCEZ2O71q9/+8BwKwZ0QtD9D8ObhrihJPr+vLLYlSuAU3/zL4cSlgbfeoGHTjCSJBa7NGcrF9/Bx/WJQ==", + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/dset/-/dset-3.1.4.tgz", + "integrity": "sha512-2QF/g9/zTaPDc3BjNcVTGoBbXBgYfMTTceLaYcFJ/W9kggFUkhxD/hMEeuLKbugyef9SqAx8cpgwlIP/jinUTA==", "engines": { "node": ">=4" } @@ -7116,8 +7132,9 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "license": "MIT", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dependencies": { "to-regex-range": "^5.0.1" }, @@ -7728,7 +7745,6 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", - "dev": true, "funding": [ { "type": "github", @@ -7978,10 +7994,23 @@ "loose-envify": "^1.0.0" } }, - "node_modules/ip": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.1.tgz", - "integrity": "sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ==", + "node_modules/ip-address": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-9.0.5.tgz", + "integrity": "sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g==", + "dev": true, + "dependencies": { + "jsbn": "1.1.0", + "sprintf-js": "^1.1.3" + }, + "engines": { + "node": ">= 12" + } + }, + "node_modules/ip-address/node_modules/sprintf-js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz", + "integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==", "dev": true }, "node_modules/is-absolute": { @@ -8160,7 +8189,8 @@ }, "node_modules/is-number": { "version": "7.0.0", - "license": "MIT", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "engines": { "node": ">=0.12.0" } @@ -10137,6 +10167,12 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/jsbn": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-1.1.0.tgz", + "integrity": "sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==", + "dev": true + }, "node_modules/jsesc": { "version": "2.5.2", "license": "MIT", @@ -10147,10 +10183,6 @@ "node": ">=4" } }, - "node_modules/json-buffer": { - "version": "3.0.1", - "license": "MIT" - }, "node_modules/json-parse-even-better-errors": { "version": "2.3.1", "license": "MIT" @@ -10233,12 +10265,11 @@ "dev": true }, "node_modules/keyv": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.4.1.tgz", - "integrity": "sha512-PzByhNxfBLnSBW2MZi1DF+W5+qB/7BMpOokewqIvqS8GFtP7xHm2oeGU72Y1fhtfOv/FiEnI4+nyViYDmUChnw==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-5.1.0.tgz", + "integrity": "sha512-FUr1fbKVsj9IZkPkY9reJ80Lp2B3ldtFXH+xK0wvZYzOpwgHV1er3xP4JUhu2cgkV2X3BJQw+hzAbIGqa+hNIA==", "dependencies": { - "compress-brotli": "^1.3.8", - "json-buffer": "3.0.1" + "@keyv/serialize": "*" } }, "node_modules/kind-of": { @@ -10810,10 +10841,11 @@ } }, "node_modules/micromatch": { - "version": "4.0.5", - "license": "MIT", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dependencies": { - "braces": "^3.0.2", + "braces": "^3.0.3", "picomatch": "^2.3.1" }, "engines": { @@ -12609,16 +12641,16 @@ } }, "node_modules/socks": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz", - "integrity": "sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ==", + "version": "2.8.3", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.3.tgz", + "integrity": "sha512-l5x7VUUWbjVFbafGLxPWkYsHIhEvmF85tbIeFZWc8ZPtoMyybuEhL7Jye/ooC4/d48FgOjSJXgsF/AJPYCW8Zw==", "dev": true, "dependencies": { - "ip": "^2.0.0", + "ip-address": "^9.0.5", "smart-buffer": "^4.2.0" }, "engines": { - "node": ">= 10.13.0", + "node": ">= 10.0.0", "npm": ">= 3.0.0" } }, @@ -13026,19 +13058,29 @@ } }, "node_modules/tar": { - "version": "6.1.11", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", "dev": true, - "license": "ISC", "dependencies": { "chownr": "^2.0.0", "fs-minipass": "^2.0.0", - "minipass": "^3.0.0", + "minipass": "^5.0.0", "minizlib": "^2.1.1", "mkdirp": "^1.0.3", "yallist": "^4.0.0" }, "engines": { - "node": ">= 10" + "node": ">=10" + } + }, + "node_modules/tar/node_modules/minipass": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", + "dev": true, + "engines": { + "node": ">=8" } }, "node_modules/tar/node_modules/mkdirp": { @@ -13133,7 +13175,8 @@ }, "node_modules/to-regex-range": { "version": "5.0.1", - "license": "MIT", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "dependencies": { "is-number": "^7.0.0" }, @@ -14053,9 +14096,9 @@ } }, "node_modules/ws": { - "version": "8.16.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.16.0.tgz", - "integrity": "sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==", + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", "dev": true, "engines": { "node": ">=10.0.0" @@ -14210,7 +14253,7 @@ }, "packages/generate-persisted-query-manifest": { "name": "@apollo/generate-persisted-query-manifest", - "version": "1.2.1", + "version": "1.2.2", "license": "MIT", "dependencies": { "@apollo/persisted-query-lists": "^1.0.0", @@ -14346,7 +14389,7 @@ "dependencies": { "@apollo/utils.keyvaluecache": "^3.1.0", "dataloader": "^2.1.0", - "keyv": "^4.4.0" + "keyv": "^5.1.0" }, "engines": { "node": ">=16" @@ -14665,7 +14708,7 @@ "requires": { "@apollo/utils.keyvaluecache": "^3.1.0", "dataloader": "^2.1.0", - "keyv": "^4.4.0" + "keyv": "^5.1.0" }, "dependencies": { "dataloader": { @@ -17468,6 +17511,25 @@ "integrity": "sha512-gbkePEBupNydxCelHCESvFSFM8XPh1Zs/OAVRW/rKpEqPAl5PbOM90Si8mv9bvnR53uPD2s/FiRxdvSejpRJew==", "dev": true }, + "@keyv/serialize": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@keyv/serialize/-/serialize-1.0.1.tgz", + "integrity": "sha512-kKXeynfORDGPUEEl2PvTExM2zs+IldC6ZD8jPcfvI351MDNtfMlw9V9s4XZXuJNDK2qR5gbEKxRyoYx3quHUVQ==", + "requires": { + "buffer": "^6.0.3" + }, + "dependencies": { + "buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + } + } + }, "@manypkg/find-root": { "version": "1.1.0", "dev": true, @@ -17802,9 +17864,6 @@ "integrity": "sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg==", "dev": true }, - "@types/json-buffer": { - "version": "3.0.0" - }, "@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", @@ -18443,8 +18502,7 @@ "base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", - "dev": true + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" }, "better-path-resolve": { "version": "1.0.0", @@ -18475,9 +18533,11 @@ } }, "braces": { - "version": "3.0.2", + "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" } }, "breakword": { @@ -18882,13 +18942,6 @@ "integrity": "sha512-gk/Z852D2Wtb//0I+kRFNKKE9dIIVirjoqPoA1wJU+XePVXZfGeBpk45+A1rKO4Q43prqWBNY/MiIeRLbPWUaA==", "dev": true }, - "compress-brotli": { - "version": "1.3.8", - "requires": { - "@types/json-buffer": "~3.0.0", - "json-buffer": "~3.0.1" - } - }, "concat-map": { "version": "0.0.1", "dev": true @@ -19219,9 +19272,9 @@ "dev": true }, "dset": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/dset/-/dset-3.1.3.tgz", - "integrity": "sha512-20TuZZHCEZ2O71q9/+8BwKwZ0QtD9D8ObhrihJPr+vLLYlSuAU3/zL4cSlgbfeoGHTjCSJBa7NGcrF9/Bx/WJQ==" + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/dset/-/dset-3.1.4.tgz", + "integrity": "sha512-2QF/g9/zTaPDc3BjNcVTGoBbXBgYfMTTceLaYcFJ/W9kggFUkhxD/hMEeuLKbugyef9SqAx8cpgwlIP/jinUTA==" }, "dtrace-provider": { "version": "0.8.8", @@ -19772,7 +19825,9 @@ } }, "fill-range": { - "version": "7.0.1", + "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" } @@ -20190,8 +20245,7 @@ "ieee754": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", - "dev": true + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==" }, "ignore": { "version": "5.2.4", @@ -20358,11 +20412,23 @@ "loose-envify": "^1.0.0" } }, - "ip": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.1.tgz", - "integrity": "sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ==", - "dev": true + "ip-address": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-9.0.5.tgz", + "integrity": "sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g==", + "dev": true, + "requires": { + "jsbn": "1.1.0", + "sprintf-js": "^1.1.3" + }, + "dependencies": { + "sprintf-js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz", + "integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==", + "dev": true + } + } }, "is-absolute": { "version": "1.0.0", @@ -20467,7 +20533,9 @@ "dev": true }, "is-number": { - "version": "7.0.0" + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" }, "is-number-object": { "version": "1.0.7", @@ -21899,12 +21967,15 @@ "esprima": "^4.0.0" } }, + "jsbn": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-1.1.0.tgz", + "integrity": "sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==", + "dev": true + }, "jsesc": { "version": "2.5.2" }, - "json-buffer": { - "version": "3.0.1" - }, "json-parse-even-better-errors": { "version": "2.3.1" }, @@ -21967,12 +22038,11 @@ "dev": true }, "keyv": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.4.1.tgz", - "integrity": "sha512-PzByhNxfBLnSBW2MZi1DF+W5+qB/7BMpOokewqIvqS8GFtP7xHm2oeGU72Y1fhtfOv/FiEnI4+nyViYDmUChnw==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-5.1.0.tgz", + "integrity": "sha512-FUr1fbKVsj9IZkPkY9reJ80Lp2B3ldtFXH+xK0wvZYzOpwgHV1er3xP4JUhu2cgkV2X3BJQw+hzAbIGqa+hNIA==", "requires": { - "compress-brotli": "^1.3.8", - "json-buffer": "3.0.1" + "@keyv/serialize": "*" } }, "kind-of": { @@ -22386,9 +22456,11 @@ "requires": {} }, "micromatch": { - "version": "4.0.5", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "requires": { - "braces": "^3.0.2", + "braces": "^3.0.3", "picomatch": "^2.3.1" } }, @@ -23635,12 +23707,12 @@ } }, "socks": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz", - "integrity": "sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ==", + "version": "2.8.3", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.3.tgz", + "integrity": "sha512-l5x7VUUWbjVFbafGLxPWkYsHIhEvmF85tbIeFZWc8ZPtoMyybuEhL7Jye/ooC4/d48FgOjSJXgsF/AJPYCW8Zw==", "dev": true, "requires": { - "ip": "^2.0.0", + "ip-address": "^9.0.5", "smart-buffer": "^4.2.0" } }, @@ -23949,17 +24021,25 @@ "integrity": "sha512-b19dMThMV4HVFynSAM1++gBHAbk2Tc/osgLIBZMKsyqh34jb2e8Os7T6ZW/Bt3pJFdBTd2JwAnAAEQV7rSNvcQ==" }, "tar": { - "version": "6.1.11", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", "dev": true, "requires": { "chownr": "^2.0.0", "fs-minipass": "^2.0.0", - "minipass": "^3.0.0", + "minipass": "^5.0.0", "minizlib": "^2.1.1", "mkdirp": "^1.0.3", "yallist": "^4.0.0" }, "dependencies": { + "minipass": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", + "dev": true + }, "mkdirp": { "version": "1.0.4", "dev": true @@ -24026,6 +24106,8 @@ }, "to-regex-range": { "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==", "requires": { "is-number": "^7.0.0" } @@ -24666,9 +24748,9 @@ } }, "ws": { - "version": "8.16.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.16.0.tgz", - "integrity": "sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==", + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", "dev": true, "requires": {} }, diff --git a/packages/keyvAdapter/package.json b/packages/keyvAdapter/package.json index 61eb2c7a..e5cd4c8a 100644 --- a/packages/keyvAdapter/package.json +++ b/packages/keyvAdapter/package.json @@ -23,6 +23,6 @@ "dependencies": { "@apollo/utils.keyvaluecache": "^3.1.0", "dataloader": "^2.1.0", - "keyv": "^4.4.0" + "keyv": "^5.1.0" } } diff --git a/packages/keyvAdapter/src/__tests__/KeyvAdapter.test.ts b/packages/keyvAdapter/src/__tests__/KeyvAdapter.test.ts index b89fe015..53d6069e 100644 --- a/packages/keyvAdapter/src/__tests__/KeyvAdapter.test.ts +++ b/packages/keyvAdapter/src/__tests__/KeyvAdapter.test.ts @@ -1,5 +1,5 @@ import type { KeyValueCache } from "@apollo/utils.keyvaluecache"; -import Keyv, { type Store } from "keyv"; +import Keyv, { type KeyvStoreAdapter } from "keyv"; import { expectType } from "ts-expect"; import { KeyvAdapter } from ".."; @@ -26,44 +26,6 @@ describe("KeyvAdapter", () => { expectType>(new KeyvAdapter(numberKeyv)); }); - it("Keyv class generics `Option`", () => { - interface RedisOption { - sentinels: { - port?: number; - host?: string; - family?: number; - }[]; - } - const keyv = new Keyv({ - sentinels: [], - }); - const keyvAdapter = new KeyvAdapter(keyv); - expectType>(keyvAdapter); - }); - - it("Keyv class generics `Option` default", () => { - const keyv = new Keyv({ - sentinels: [], - }); - const keyvAdapter = new KeyvAdapter(keyv); - expectType>>(keyvAdapter); - }); - - it("Keyv class generics with incompatible `Option`", () => { - interface Option { - sentinels: { - port?: number; - host?: string; - family?: number; - }[]; - } - const keyv = new Keyv({ - sentinels: [], - }); - // @ts-expect-error - new KeyvAdapter(keyv); - }); - describe("Keyv methods", () => { let keyv: Keyv; let keyvAdapter: KeyvAdapter; @@ -124,12 +86,32 @@ describe("KeyvAdapter", () => { }); it("multiple `get`s are batched", async () => { - const storeWithGetMany: Store = new (class extends Map< - string, - string - > { - getMany = jest.fn((keys: string[]) => keys.map((key) => this.get(key))); - })(); + class MapStore implements KeyvStoreAdapter { + private map = new Map(); + opts: any = {}; + namespace?: string; + getMany = jest.fn((keys: string[]) => + Promise.resolve(keys.map((key) => this.map.get(key))), + ); + get(key: string) { + return Promise.resolve(this.map.get(key) as Value); + } + set(key: string, value: any) { + this.map.set(key, value); + } + delete(key: string) { + return Promise.resolve(this.map.delete(key)); + } + clear() { + this.map.clear(); + return Promise.resolve(); + } + on(): this { + return this; + } + } + + const storeWithGetMany = new MapStore(); const keyv = new Keyv({ store: storeWithGetMany }); const keyvAdapter = new KeyvAdapter(keyv); @@ -160,23 +142,26 @@ describe("KeyvAdapter", () => { describe("Dataloader implementation details", () => { it("enforces the Dataloader contract (1:1 key to value)", async () => { - class GetManyReturnsSingularUndefinedStore implements Store { - getMany(_keys: string[]) { - // really we would prefer an array of undefined of the length of - // _keys, but that isn't a contract that `Keyv` enforces - return undefined; + class GetManyReturnsSingularUndefinedStore implements KeyvStoreAdapter { + opts: any = {}; + namespace?: string; + getMany(keys: string[]) { + return Promise.resolve(Array(keys.length).fill(undefined)); } get() { - return "hello"; + return Promise.resolve(undefined); } set() { return; } delete() { - return true; + return Promise.resolve(true); } clear() { - return; + return Promise.resolve(); + } + on(): this { + return this; } } diff --git a/packages/keyvAdapter/src/index.ts b/packages/keyvAdapter/src/index.ts index 7381d44b..3e7149dc 100644 --- a/packages/keyvAdapter/src/index.ts +++ b/packages/keyvAdapter/src/index.ts @@ -9,16 +9,14 @@ interface KeyvAdapterOptions { disableBatchReads?: boolean; } -export class KeyvAdapter< - V = string, - O extends Record = Record, -> implements KeyValueCache +export class KeyvAdapter + implements KeyValueCache { - private readonly keyv: Keyv; + private readonly keyv: Keyv; private readonly dataLoader: DataLoader | undefined; - constructor(keyv?: Keyv, options?: KeyvAdapterOptions) { - this.keyv = keyv ?? new Keyv(); + constructor(keyv?: Keyv, options?: KeyvAdapterOptions) { + this.keyv = keyv ?? new Keyv(); this.dataLoader = options?.disableBatchReads ? undefined : new DataLoader(