keyv-registry 2.0.0 → 2.0.2
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/README.md +8 -4
- package/dist/cjs/utils.js +6 -2
- package/dist/cjs/utils.js.map +1 -1
- package/dist/esm/utils.js +6 -2
- package/dist/esm/utils.js.map +1 -1
- package/package.json +1 -9
package/README.md
CHANGED
|
@@ -19,6 +19,8 @@ Create Keyv stores from URI strings, resolving each adapter from the modules ins
|
|
|
19
19
|
npm install keyv-registry
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
Requires Node.js >=16.
|
|
23
|
+
|
|
22
24
|
Adapters are not bundled. Install the one your protocol needs alongside it:
|
|
23
25
|
|
|
24
26
|
```bash
|
|
@@ -37,7 +39,12 @@ Adapters are resolved with `require()`, so an adapter only has to be installed s
|
|
|
37
39
|
```typescript
|
|
38
40
|
import createStore from 'keyv-registry';
|
|
39
41
|
|
|
40
|
-
//
|
|
42
|
+
// In-memory storage is built in and needs no adapter package.
|
|
43
|
+
const memory = await createStore('memory://');
|
|
44
|
+
await memory.set('greeting', 'hello');
|
|
45
|
+
console.log(await memory.get('greeting')); // hello
|
|
46
|
+
|
|
47
|
+
// Redis requires @keyv/redis and a running Redis server.
|
|
41
48
|
const redis = await createStore('redis://localhost:6379');
|
|
42
49
|
|
|
43
50
|
// PostgreSQL
|
|
@@ -46,9 +53,6 @@ const postgres = await createStore('postgresql://user:pass@localhost/db');
|
|
|
46
53
|
// File-based storage
|
|
47
54
|
const file = await createStore('file://~/.cache/myapp/data.json');
|
|
48
55
|
|
|
49
|
-
// In-memory (built-in, no package needed)
|
|
50
|
-
const memory = await createStore('memory://');
|
|
51
|
-
|
|
52
56
|
// SQLite
|
|
53
57
|
const sqlite = await createStore('sqlite:///path/to/db.sqlite');
|
|
54
58
|
|
package/dist/cjs/utils.js
CHANGED
|
@@ -19,6 +19,7 @@ _export(exports, {
|
|
|
19
19
|
var _nodefs = /*#__PURE__*/ _interop_require_wildcard(require("node:fs"));
|
|
20
20
|
var _nodeos = /*#__PURE__*/ _interop_require_wildcard(require("node:os"));
|
|
21
21
|
var _nodepath = /*#__PURE__*/ _interop_require_wildcard(require("node:path"));
|
|
22
|
+
var _nodeurl = require("node:url");
|
|
22
23
|
function _array_like_to_array(arr, len) {
|
|
23
24
|
if (len == null || len > arr.length) len = arr.length;
|
|
24
25
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
@@ -99,9 +100,12 @@ function resolveFilePath(url) {
|
|
|
99
100
|
var filePath = url.pathname;
|
|
100
101
|
// Handle ~ for home directory
|
|
101
102
|
if (url.host === '~') {
|
|
102
|
-
filePath = _nodepath.join(_nodeos.homedir(), filePath.slice(1));
|
|
103
|
+
filePath = _nodepath.join(_nodeos.homedir(), decodeURIComponent(filePath.slice(1)));
|
|
103
104
|
} else if (url.host === '.') {
|
|
104
|
-
filePath = _nodepath.join(process.cwd(), filePath.slice(1));
|
|
105
|
+
filePath = _nodepath.join(process.cwd(), decodeURIComponent(filePath.slice(1)));
|
|
106
|
+
} else {
|
|
107
|
+
// File-backed adapters such as duckdb use the same native path conversion.
|
|
108
|
+
filePath = (0, _nodeurl.fileURLToPath)(new URL("file://".concat(url.host).concat(url.pathname)));
|
|
105
109
|
}
|
|
106
110
|
// Ensure directory exists
|
|
107
111
|
_nodefs.mkdirSync(_nodepath.dirname(filePath), {
|
package/dist/cjs/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/keyv/keyv-registry/src/utils.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport * as os from 'node:os';\nimport * as path from 'node:path';\n\n/**\n * Resolve file path from URL, handling ~ and . prefixes\n */\nexport function resolveFilePath(url: URL): string {\n let filePath = url.pathname;\n\n // Handle ~ for home directory\n if (url.host === '~') {\n filePath = path.join(os.homedir(), filePath.slice(1));\n }\n // Handle . for current directory\n else if (url.host === '.') {\n filePath = path.join(process.cwd(), filePath.slice(1));\n }\n\n // Ensure directory exists\n fs.mkdirSync(path.dirname(filePath), { recursive: true });\n\n return filePath;\n}\n\n/**\n * Parse URL search params into options object with type conversion\n */\nexport function parseUriOptions(url: URL): Record<string, unknown> {\n const options: Record<string, unknown> = {};\n\n for (const [key, value] of url.searchParams) {\n // Auto-convert types\n if (value === 'true') options[key] = true;\n else if (value === 'false') options[key] = false;\n else if (/^\\d+$/.test(value)) options[key] = Number.parseInt(value, 10);\n else if (/^\\d+\\.\\d+$/.test(value)) options[key] = Number.parseFloat(value);\n else options[key] = value;\n }\n\n return options;\n}\n"],"names":["parseUriOptions","resolveFilePath","url","filePath","pathname","host","path","join","os","homedir","slice","process","cwd","fs","mkdirSync","dirname","recursive","options","searchParams","key","value","test","Number","parseInt","parseFloat"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/keyv/keyv-registry/src/utils.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport * as os from 'node:os';\nimport * as path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\n/**\n * Resolve file path from URL, handling ~ and . prefixes\n */\nexport function resolveFilePath(url: URL): string {\n let filePath = url.pathname;\n\n // Handle ~ for home directory\n if (url.host === '~') {\n filePath = path.join(os.homedir(), decodeURIComponent(filePath.slice(1)));\n }\n // Handle . for current directory\n else if (url.host === '.') {\n filePath = path.join(process.cwd(), decodeURIComponent(filePath.slice(1)));\n } else {\n // File-backed adapters such as duckdb use the same native path conversion.\n filePath = fileURLToPath(new URL(`file://${url.host}${url.pathname}`));\n }\n\n // Ensure directory exists\n fs.mkdirSync(path.dirname(filePath), { recursive: true });\n\n return filePath;\n}\n\n/**\n * Parse URL search params into options object with type conversion\n */\nexport function parseUriOptions(url: URL): Record<string, unknown> {\n const options: Record<string, unknown> = {};\n\n for (const [key, value] of url.searchParams) {\n // Auto-convert types\n if (value === 'true') options[key] = true;\n else if (value === 'false') options[key] = false;\n else if (/^\\d+$/.test(value)) options[key] = Number.parseInt(value, 10);\n else if (/^\\d+\\.\\d+$/.test(value)) options[key] = Number.parseFloat(value);\n else options[key] = value;\n }\n\n return options;\n}\n"],"names":["parseUriOptions","resolveFilePath","url","filePath","pathname","host","path","join","os","homedir","decodeURIComponent","slice","process","cwd","fileURLToPath","URL","fs","mkdirSync","dirname","recursive","options","searchParams","key","value","test","Number","parseInt","parseFloat"],"mappings":";;;;;;;;;;;QAgCgBA;eAAAA;;QAxBAC;eAAAA;;;8DARI;8DACA;gEACE;uBACQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKvB,SAASA,gBAAgBC,GAAQ;IACtC,IAAIC,WAAWD,IAAIE,QAAQ;IAE3B,8BAA8B;IAC9B,IAAIF,IAAIG,IAAI,KAAK,KAAK;QACpBF,WAAWG,UAAKC,IAAI,CAACC,QAAGC,OAAO,IAAIC,mBAAmBP,SAASQ,KAAK,CAAC;IACvE,OAEK,IAAIT,IAAIG,IAAI,KAAK,KAAK;QACzBF,WAAWG,UAAKC,IAAI,CAACK,QAAQC,GAAG,IAAIH,mBAAmBP,SAASQ,KAAK,CAAC;IACxE,OAAO;QACL,2EAA2E;QAC3ER,WAAWW,IAAAA,sBAAa,EAAC,IAAIC,IAAI,AAAC,UAAoBb,OAAXA,IAAIG,IAAI,EAAgB,OAAbH,IAAIE,QAAQ;IACpE;IAEA,0BAA0B;IAC1BY,QAAGC,SAAS,CAACX,UAAKY,OAAO,CAACf,WAAW;QAAEgB,WAAW;IAAK;IAEvD,OAAOhB;AACT;AAKO,SAASH,gBAAgBE,GAAQ;IACtC,IAAMkB,UAAmC,CAAC;QAErC,kCAAA,2BAAA;;QAAL,QAAK,YAAsBlB,IAAImB,YAAY,qBAAtC,SAAA,6BAAA,QAAA,yBAAA,iCAAwC;YAAxC,mCAAA,iBAAOC,sBAAKC;YACf,qBAAqB;YACrB,IAAIA,UAAU,QAAQH,OAAO,CAACE,IAAI,GAAG;iBAChC,IAAIC,UAAU,SAASH,OAAO,CAACE,IAAI,GAAG;iBACtC,IAAI,QAAQE,IAAI,CAACD,QAAQH,OAAO,CAACE,IAAI,GAAGG,OAAOC,QAAQ,CAACH,OAAO;iBAC/D,IAAI,aAAaC,IAAI,CAACD,QAAQH,OAAO,CAACE,IAAI,GAAGG,OAAOE,UAAU,CAACJ;iBAC/DH,OAAO,CAACE,IAAI,GAAGC;QACtB;;QAPK;QAAA;;;iBAAA,6BAAA;gBAAA;;;gBAAA;sBAAA;;;;IASL,OAAOH;AACT"}
|
package/dist/esm/utils.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import * as fs from 'node:fs';
|
|
2
2
|
import * as os from 'node:os';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
4
5
|
/**
|
|
5
6
|
* Resolve file path from URL, handling ~ and . prefixes
|
|
6
7
|
*/ export function resolveFilePath(url) {
|
|
7
8
|
let filePath = url.pathname;
|
|
8
9
|
// Handle ~ for home directory
|
|
9
10
|
if (url.host === '~') {
|
|
10
|
-
filePath = path.join(os.homedir(), filePath.slice(1));
|
|
11
|
+
filePath = path.join(os.homedir(), decodeURIComponent(filePath.slice(1)));
|
|
11
12
|
} else if (url.host === '.') {
|
|
12
|
-
filePath = path.join(process.cwd(), filePath.slice(1));
|
|
13
|
+
filePath = path.join(process.cwd(), decodeURIComponent(filePath.slice(1)));
|
|
14
|
+
} else {
|
|
15
|
+
// File-backed adapters such as duckdb use the same native path conversion.
|
|
16
|
+
filePath = fileURLToPath(new URL(`file://${url.host}${url.pathname}`));
|
|
13
17
|
}
|
|
14
18
|
// Ensure directory exists
|
|
15
19
|
fs.mkdirSync(path.dirname(filePath), {
|
package/dist/esm/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/keyv/keyv-registry/src/utils.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport * as os from 'node:os';\nimport * as path from 'node:path';\n\n/**\n * Resolve file path from URL, handling ~ and . prefixes\n */\nexport function resolveFilePath(url: URL): string {\n let filePath = url.pathname;\n\n // Handle ~ for home directory\n if (url.host === '~') {\n filePath = path.join(os.homedir(), filePath.slice(1));\n }\n // Handle . for current directory\n else if (url.host === '.') {\n filePath = path.join(process.cwd(), filePath.slice(1));\n }\n\n // Ensure directory exists\n fs.mkdirSync(path.dirname(filePath), { recursive: true });\n\n return filePath;\n}\n\n/**\n * Parse URL search params into options object with type conversion\n */\nexport function parseUriOptions(url: URL): Record<string, unknown> {\n const options: Record<string, unknown> = {};\n\n for (const [key, value] of url.searchParams) {\n // Auto-convert types\n if (value === 'true') options[key] = true;\n else if (value === 'false') options[key] = false;\n else if (/^\\d+$/.test(value)) options[key] = Number.parseInt(value, 10);\n else if (/^\\d+\\.\\d+$/.test(value)) options[key] = Number.parseFloat(value);\n else options[key] = value;\n }\n\n return options;\n}\n"],"names":["fs","os","path","resolveFilePath","url","filePath","pathname","host","join","homedir","slice","process","cwd","mkdirSync","dirname","recursive","parseUriOptions","options","key","value","searchParams","test","Number","parseInt","parseFloat"],"mappings":"AAAA,YAAYA,QAAQ,UAAU;AAC9B,YAAYC,QAAQ,UAAU;AAC9B,YAAYC,UAAU,YAAY;
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/keyv/keyv-registry/src/utils.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport * as os from 'node:os';\nimport * as path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\n/**\n * Resolve file path from URL, handling ~ and . prefixes\n */\nexport function resolveFilePath(url: URL): string {\n let filePath = url.pathname;\n\n // Handle ~ for home directory\n if (url.host === '~') {\n filePath = path.join(os.homedir(), decodeURIComponent(filePath.slice(1)));\n }\n // Handle . for current directory\n else if (url.host === '.') {\n filePath = path.join(process.cwd(), decodeURIComponent(filePath.slice(1)));\n } else {\n // File-backed adapters such as duckdb use the same native path conversion.\n filePath = fileURLToPath(new URL(`file://${url.host}${url.pathname}`));\n }\n\n // Ensure directory exists\n fs.mkdirSync(path.dirname(filePath), { recursive: true });\n\n return filePath;\n}\n\n/**\n * Parse URL search params into options object with type conversion\n */\nexport function parseUriOptions(url: URL): Record<string, unknown> {\n const options: Record<string, unknown> = {};\n\n for (const [key, value] of url.searchParams) {\n // Auto-convert types\n if (value === 'true') options[key] = true;\n else if (value === 'false') options[key] = false;\n else if (/^\\d+$/.test(value)) options[key] = Number.parseInt(value, 10);\n else if (/^\\d+\\.\\d+$/.test(value)) options[key] = Number.parseFloat(value);\n else options[key] = value;\n }\n\n return options;\n}\n"],"names":["fs","os","path","fileURLToPath","resolveFilePath","url","filePath","pathname","host","join","homedir","decodeURIComponent","slice","process","cwd","URL","mkdirSync","dirname","recursive","parseUriOptions","options","key","value","searchParams","test","Number","parseInt","parseFloat"],"mappings":"AAAA,YAAYA,QAAQ,UAAU;AAC9B,YAAYC,QAAQ,UAAU;AAC9B,YAAYC,UAAU,YAAY;AAClC,SAASC,aAAa,QAAQ,WAAW;AAEzC;;CAEC,GACD,OAAO,SAASC,gBAAgBC,GAAQ;IACtC,IAAIC,WAAWD,IAAIE,QAAQ;IAE3B,8BAA8B;IAC9B,IAAIF,IAAIG,IAAI,KAAK,KAAK;QACpBF,WAAWJ,KAAKO,IAAI,CAACR,GAAGS,OAAO,IAAIC,mBAAmBL,SAASM,KAAK,CAAC;IACvE,OAEK,IAAIP,IAAIG,IAAI,KAAK,KAAK;QACzBF,WAAWJ,KAAKO,IAAI,CAACI,QAAQC,GAAG,IAAIH,mBAAmBL,SAASM,KAAK,CAAC;IACxE,OAAO;QACL,2EAA2E;QAC3EN,WAAWH,cAAc,IAAIY,IAAI,CAAC,OAAO,EAAEV,IAAIG,IAAI,GAAGH,IAAIE,QAAQ,EAAE;IACtE;IAEA,0BAA0B;IAC1BP,GAAGgB,SAAS,CAACd,KAAKe,OAAO,CAACX,WAAW;QAAEY,WAAW;IAAK;IAEvD,OAAOZ;AACT;AAEA;;CAEC,GACD,OAAO,SAASa,gBAAgBd,GAAQ;IACtC,MAAMe,UAAmC,CAAC;IAE1C,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAIjB,IAAIkB,YAAY,CAAE;QAC3C,qBAAqB;QACrB,IAAID,UAAU,QAAQF,OAAO,CAACC,IAAI,GAAG;aAChC,IAAIC,UAAU,SAASF,OAAO,CAACC,IAAI,GAAG;aACtC,IAAI,QAAQG,IAAI,CAACF,QAAQF,OAAO,CAACC,IAAI,GAAGI,OAAOC,QAAQ,CAACJ,OAAO;aAC/D,IAAI,aAAaE,IAAI,CAACF,QAAQF,OAAO,CAACC,IAAI,GAAGI,OAAOE,UAAU,CAACL;aAC/DF,OAAO,CAACC,IAAI,GAAGC;IACtB;IAEA,OAAOF;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keyv-registry",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Protocol-based Keyv adapter registry",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"keyv",
|
|
@@ -47,9 +47,7 @@
|
|
|
47
47
|
"keyv": "^5.0.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@keyv/etcd": "*",
|
|
51
50
|
"@keyv/redis": "*",
|
|
52
|
-
"@keyv/sqlite": "*",
|
|
53
51
|
"@types/mocha": "*",
|
|
54
52
|
"@types/node": "*",
|
|
55
53
|
"fs-remove-compat": "^1.0.4",
|
|
@@ -60,11 +58,5 @@
|
|
|
60
58
|
},
|
|
61
59
|
"engines": {
|
|
62
60
|
"node": ">=16"
|
|
63
|
-
},
|
|
64
|
-
"allowScripts": {
|
|
65
|
-
"node-filename-to-dist-paths": true,
|
|
66
|
-
"node-semvers": true,
|
|
67
|
-
"node-version-use": true,
|
|
68
|
-
"thread-sleep-compat": true
|
|
69
61
|
}
|
|
70
62
|
}
|