keyv-registry 2.0.3 → 3.0.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/README.md +54 -22
- package/dist/cjs/constants.d.cts +3 -0
- package/dist/cjs/constants.d.ts +3 -0
- package/dist/cjs/constants.js +37 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/index.d.cts +2 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +8 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/loadAdapter.js +14 -2
- package/dist/cjs/loadAdapter.js.map +1 -1
- package/dist/cjs/migrate-keyv5.d.cts +18 -0
- package/dist/cjs/migrate-keyv5.d.ts +18 -0
- package/dist/cjs/migrate-keyv5.js +554 -0
- package/dist/cjs/migrate-keyv5.js.map +1 -0
- package/dist/cjs/registry.js +2 -2
- package/dist/cjs/registry.js.map +1 -1
- package/dist/cjs/types.d.cts +4 -8
- package/dist/cjs/types.d.ts +4 -8
- package/dist/cjs/utils.d.cts +14 -1
- package/dist/cjs/utils.d.ts +14 -1
- package/dist/cjs/utils.js +24 -12
- package/dist/cjs/utils.js.map +1 -1
- package/dist/cjs/worker.d.cts +7 -0
- package/dist/cjs/worker.d.ts +7 -0
- package/dist/cjs/worker.js +66 -53
- package/dist/cjs/worker.js.map +1 -1
- package/dist/esm/constants.d.ts +3 -0
- package/dist/esm/constants.js +18 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loadAdapter.js +14 -2
- package/dist/esm/loadAdapter.js.map +1 -1
- package/dist/esm/migrate-keyv5.d.ts +18 -0
- package/dist/esm/migrate-keyv5.js +74 -0
- package/dist/esm/migrate-keyv5.js.map +1 -0
- package/dist/esm/registry.js +2 -2
- package/dist/esm/registry.js.map +1 -1
- package/dist/esm/types.d.ts +4 -8
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils.d.ts +14 -1
- package/dist/esm/utils.js +21 -12
- package/dist/esm/utils.js.map +1 -1
- package/dist/esm/worker.d.ts +7 -0
- package/dist/esm/worker.js +25 -21
- package/dist/esm/worker.js.map +1 -1
- package/package.json +7 -5
package/dist/cjs/utils.d.ts
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Parse a store URI, keeping a Windows drive letter written after `//` in the path
|
|
3
|
+
*/
|
|
4
|
+
export declare function parseUri(uri: string): URL;
|
|
5
|
+
export interface ToFilePathOptions {
|
|
6
|
+
windows?: boolean;
|
|
7
|
+
homedir?: string;
|
|
8
|
+
cwd?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Convert a file-backed store URL to a native path, handling ~ and . prefixes (no filesystem access)
|
|
12
|
+
*/
|
|
13
|
+
export declare function toFilePath(url: URL, options?: ToFilePathOptions): string;
|
|
14
|
+
/**
|
|
15
|
+
* Resolve file path from URL and create its parent directory
|
|
3
16
|
*/
|
|
4
17
|
export declare function resolveFilePath(url: URL): string;
|
|
5
18
|
/**
|
package/dist/cjs/utils.js
CHANGED
|
@@ -9,11 +9,17 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
+
get parseUri () {
|
|
13
|
+
return parseUri;
|
|
14
|
+
},
|
|
12
15
|
get parseUriOptions () {
|
|
13
16
|
return parseUriOptions;
|
|
14
17
|
},
|
|
15
18
|
get resolveFilePath () {
|
|
16
19
|
return resolveFilePath;
|
|
20
|
+
},
|
|
21
|
+
get toFilePath () {
|
|
22
|
+
return toFilePath;
|
|
17
23
|
}
|
|
18
24
|
});
|
|
19
25
|
var _nodefs = /*#__PURE__*/ _interop_require_wildcard(require("node:fs"));
|
|
@@ -93,21 +99,27 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
93
99
|
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
94
100
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
95
101
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
96
|
-
if (n === "Map" || n === "Set") return Array.from(
|
|
102
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
97
103
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
98
104
|
}
|
|
105
|
+
// `scheme://C:/x` parses the drive letter as a host and drops the colon, so it is rewritten to `scheme:///C:/x` first.
|
|
106
|
+
var DRIVE_AS_HOST = /^([a-zA-Z][a-zA-Z0-9+.-]*:)\/\/([a-zA-Z]:[/\\])/;
|
|
107
|
+
function parseUri(uri) {
|
|
108
|
+
return new URL(uri.replace(DRIVE_AS_HOST, '$1///$2'));
|
|
109
|
+
}
|
|
110
|
+
function toFilePath(url) {
|
|
111
|
+
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
112
|
+
var _options_windows, _options_homedir, _options_cwd;
|
|
113
|
+
var windows = (_options_windows = options.windows) !== null && _options_windows !== void 0 ? _options_windows : process.platform === 'win32';
|
|
114
|
+
var p = windows ? _nodepath.win32 : _nodepath.posix;
|
|
115
|
+
if (url.host === '~') return p.join((_options_homedir = options.homedir) !== null && _options_homedir !== void 0 ? _options_homedir : _nodeos.homedir(), decodeURIComponent(url.pathname.slice(1)));
|
|
116
|
+
if (url.host === '.') return p.join((_options_cwd = options.cwd) !== null && _options_cwd !== void 0 ? _options_cwd : process.cwd(), decodeURIComponent(url.pathname.slice(1)));
|
|
117
|
+
return (0, _nodeurl.fileURLToPath)(new URL("file://".concat(url.host).concat(url.pathname)), {
|
|
118
|
+
windows: windows
|
|
119
|
+
});
|
|
120
|
+
}
|
|
99
121
|
function resolveFilePath(url) {
|
|
100
|
-
var filePath = url
|
|
101
|
-
// Handle ~ for home directory
|
|
102
|
-
if (url.host === '~') {
|
|
103
|
-
filePath = _nodepath.join(_nodeos.homedir(), decodeURIComponent(filePath.slice(1)));
|
|
104
|
-
} else if (url.host === '.') {
|
|
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)));
|
|
109
|
-
}
|
|
110
|
-
// Ensure directory exists
|
|
122
|
+
var filePath = toFilePath(url);
|
|
111
123
|
_nodefs.mkdirSync(_nodepath.dirname(filePath), {
|
|
112
124
|
recursive: true
|
|
113
125
|
});
|
package/dist/cjs/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/open-source/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 *
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/open-source/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// `scheme://C:/x` parses the drive letter as a host and drops the colon, so it is rewritten to `scheme:///C:/x` first.\nconst DRIVE_AS_HOST = /^([a-zA-Z][a-zA-Z0-9+.-]*:)\\/\\/([a-zA-Z]:[/\\\\])/;\n\n/**\n * Parse a store URI, keeping a Windows drive letter written after `//` in the path\n */\nexport function parseUri(uri: string): URL {\n return new URL(uri.replace(DRIVE_AS_HOST, '$1///$2'));\n}\n\nexport interface ToFilePathOptions {\n windows?: boolean;\n homedir?: string;\n cwd?: string;\n}\n\n/**\n * Convert a file-backed store URL to a native path, handling ~ and . prefixes (no filesystem access)\n */\nexport function toFilePath(url: URL, options: ToFilePathOptions = {}): string {\n const windows = options.windows ?? process.platform === 'win32';\n const p = windows ? path.win32 : path.posix;\n if (url.host === '~') return p.join(options.homedir ?? os.homedir(), decodeURIComponent(url.pathname.slice(1)));\n if (url.host === '.') return p.join(options.cwd ?? process.cwd(), decodeURIComponent(url.pathname.slice(1)));\n return fileURLToPath(new URL(`file://${url.host}${url.pathname}`), { windows });\n}\n\n/**\n * Resolve file path from URL and create its parent directory\n */\nexport function resolveFilePath(url: URL): string {\n const filePath = toFilePath(url);\n fs.mkdirSync(path.dirname(filePath), { recursive: true });\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":["parseUri","parseUriOptions","resolveFilePath","toFilePath","DRIVE_AS_HOST","uri","URL","replace","url","options","windows","process","platform","p","path","win32","posix","host","join","homedir","os","decodeURIComponent","pathname","slice","cwd","fileURLToPath","filePath","fs","mkdirSync","dirname","recursive","searchParams","key","value","test","Number","parseInt","parseFloat"],"mappings":";;;;;;;;;;;QAWgBA;eAAAA;;QAiCAC;eAAAA;;QATAC;eAAAA;;QAXAC;eAAAA;;;8DAxBI;8DACA;gEACE;uBACQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE9B,uHAAuH;AACvH,IAAMC,gBAAgB;AAKf,SAASJ,SAASK,GAAW;IAClC,OAAO,IAAIC,IAAID,IAAIE,OAAO,CAACH,eAAe;AAC5C;AAWO,SAASD,WAAWK,GAAQ;QAAEC,UAAAA,iEAA6B,CAAC;QACjDA,kBAEoBA,kBACAA;IAHpC,IAAMC,WAAUD,mBAAAA,QAAQC,OAAO,cAAfD,8BAAAA,mBAAmBE,QAAQC,QAAQ,KAAK;IACxD,IAAMC,IAAIH,UAAUI,UAAKC,KAAK,GAAGD,UAAKE,KAAK;IAC3C,IAAIR,IAAIS,IAAI,KAAK,KAAK,OAAOJ,EAAEK,IAAI,EAACT,mBAAAA,QAAQU,OAAO,cAAfV,8BAAAA,mBAAmBW,QAAGD,OAAO,IAAIE,mBAAmBb,IAAIc,QAAQ,CAACC,KAAK,CAAC;IAC3G,IAAIf,IAAIS,IAAI,KAAK,KAAK,OAAOJ,EAAEK,IAAI,EAACT,eAAAA,QAAQe,GAAG,cAAXf,0BAAAA,eAAeE,QAAQa,GAAG,IAAIH,mBAAmBb,IAAIc,QAAQ,CAACC,KAAK,CAAC;IACxG,OAAOE,IAAAA,sBAAa,EAAC,IAAInB,IAAI,AAAC,UAAoBE,OAAXA,IAAIS,IAAI,EAAgB,OAAbT,IAAIc,QAAQ,IAAK;QAAEZ,SAAAA;IAAQ;AAC/E;AAKO,SAASR,gBAAgBM,GAAQ;IACtC,IAAMkB,WAAWvB,WAAWK;IAC5BmB,QAAGC,SAAS,CAACd,UAAKe,OAAO,CAACH,WAAW;QAAEI,WAAW;IAAK;IACvD,OAAOJ;AACT;AAKO,SAASzB,gBAAgBO,GAAQ;IACtC,IAAMC,UAAmC,CAAC;QAErC,kCAAA,2BAAA;;QAAL,QAAK,YAAsBD,IAAIuB,YAAY,qBAAtC,SAAA,6BAAA,QAAA,yBAAA,iCAAwC;YAAxC,mCAAA,iBAAOC,sBAAKC;YACf,qBAAqB;YACrB,IAAIA,UAAU,QAAQxB,OAAO,CAACuB,IAAI,GAAG;iBAChC,IAAIC,UAAU,SAASxB,OAAO,CAACuB,IAAI,GAAG;iBACtC,IAAI,QAAQE,IAAI,CAACD,QAAQxB,OAAO,CAACuB,IAAI,GAAGG,OAAOC,QAAQ,CAACH,OAAO;iBAC/D,IAAI,aAAaC,IAAI,CAACD,QAAQxB,OAAO,CAACuB,IAAI,GAAGG,OAAOE,UAAU,CAACJ;iBAC/DxB,OAAO,CAACuB,IAAI,GAAGC;QACtB;;QAPK;QAAA;;;iBAAA,6BAAA;gBAAA;;;gBAAA;sBAAA;;;;IASL,OAAOxB;AACT"}
|
package/dist/cjs/worker.d.cts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import type { CreateStoreCallback, CreateStoreOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Split code options: Keyv's own keys go to `new Keyv`, the rest to the adapter constructor
|
|
4
|
+
*/
|
|
5
|
+
export declare function splitOptions(merged: Record<string, unknown>): {
|
|
6
|
+
keyvOptions: Record<string, unknown>;
|
|
7
|
+
adapterOptions: Record<string, unknown>;
|
|
8
|
+
};
|
|
2
9
|
/**
|
|
3
10
|
* Core worker function that creates a Keyv store
|
|
4
11
|
*/
|
package/dist/cjs/worker.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import type { CreateStoreCallback, CreateStoreOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Split code options: Keyv's own keys go to `new Keyv`, the rest to the adapter constructor
|
|
4
|
+
*/
|
|
5
|
+
export declare function splitOptions(merged: Record<string, unknown>): {
|
|
6
|
+
keyvOptions: Record<string, unknown>;
|
|
7
|
+
adapterOptions: Record<string, unknown>;
|
|
8
|
+
};
|
|
2
9
|
/**
|
|
3
10
|
* Core worker function that creates a Keyv store
|
|
4
11
|
*/
|
package/dist/cjs/worker.js
CHANGED
|
@@ -2,15 +2,24 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get /**
|
|
6
13
|
* Core worker function that creates a Keyv store
|
|
7
|
-
*/
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function() {
|
|
14
|
+
*/ default () {
|
|
10
15
|
return worker;
|
|
16
|
+
},
|
|
17
|
+
get splitOptions () {
|
|
18
|
+
return splitOptions;
|
|
11
19
|
}
|
|
12
20
|
});
|
|
13
21
|
var _keyv = /*#__PURE__*/ _interop_require_default(require("keyv"));
|
|
22
|
+
var _constantsts = require("./constants.js");
|
|
14
23
|
var _loadAdapterts = /*#__PURE__*/ _interop_require_default(require("./loadAdapter.js"));
|
|
15
24
|
var _registryts = require("./registry.js");
|
|
16
25
|
var _utilsts = require("./utils.js");
|
|
@@ -45,42 +54,58 @@ function _object_spread(target) {
|
|
|
45
54
|
}
|
|
46
55
|
return target;
|
|
47
56
|
}
|
|
48
|
-
function
|
|
49
|
-
|
|
50
|
-
var target = {}, sourceKeys, key, i;
|
|
51
|
-
if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
|
|
52
|
-
sourceKeys = Reflect.ownKeys(Object(source));
|
|
53
|
-
for(i = 0; i < sourceKeys.length; i++){
|
|
54
|
-
key = sourceKeys[i];
|
|
55
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
56
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
57
|
-
target[key] = source[key];
|
|
58
|
-
}
|
|
59
|
-
return target;
|
|
60
|
-
}
|
|
61
|
-
target = _object_without_properties_loose(source, excluded);
|
|
57
|
+
function ownKeys(object, enumerableOnly) {
|
|
58
|
+
var keys = Object.keys(object);
|
|
62
59
|
if (Object.getOwnPropertySymbols) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
target[key] = source[key];
|
|
60
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
61
|
+
if (enumerableOnly) {
|
|
62
|
+
symbols = symbols.filter(function(sym) {
|
|
63
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
64
|
+
});
|
|
69
65
|
}
|
|
66
|
+
keys.push.apply(keys, symbols);
|
|
70
67
|
}
|
|
71
|
-
return
|
|
68
|
+
return keys;
|
|
72
69
|
}
|
|
73
|
-
function
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
key
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
target[key] = source[key];
|
|
70
|
+
function _object_spread_props(target, source) {
|
|
71
|
+
source = source != null ? source : {};
|
|
72
|
+
if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
73
|
+
else {
|
|
74
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
75
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
76
|
+
});
|
|
81
77
|
}
|
|
82
78
|
return target;
|
|
83
79
|
}
|
|
80
|
+
function splitOptions(merged) {
|
|
81
|
+
var keyvOptions = {};
|
|
82
|
+
var adapterOptions = {};
|
|
83
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
84
|
+
try {
|
|
85
|
+
for(var _iterator = Object.keys(merged)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
86
|
+
var key = _step.value;
|
|
87
|
+
if (key === 'store') continue;
|
|
88
|
+
(_constantsts.KEYV_OPTION_KEYS.has(key) ? keyvOptions : adapterOptions)[key] = merged[key];
|
|
89
|
+
}
|
|
90
|
+
} catch (err) {
|
|
91
|
+
_didIteratorError = true;
|
|
92
|
+
_iteratorError = err;
|
|
93
|
+
} finally{
|
|
94
|
+
try {
|
|
95
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
96
|
+
_iterator.return();
|
|
97
|
+
}
|
|
98
|
+
} finally{
|
|
99
|
+
if (_didIteratorError) {
|
|
100
|
+
throw _iteratorError;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
keyvOptions: keyvOptions,
|
|
106
|
+
adapterOptions: adapterOptions
|
|
107
|
+
};
|
|
108
|
+
}
|
|
84
109
|
function worker(uri, options, callback) {
|
|
85
110
|
// Passthrough: pre-instantiated adapter provided
|
|
86
111
|
if (options.store) {
|
|
@@ -95,7 +120,7 @@ function worker(uri, options, callback) {
|
|
|
95
120
|
// Parse URI
|
|
96
121
|
var url;
|
|
97
122
|
try {
|
|
98
|
-
url =
|
|
123
|
+
url = (0, _utilsts.parseUri)(uri);
|
|
99
124
|
} catch (_err) {
|
|
100
125
|
callback(new Error("Invalid URI: ".concat(uri)));
|
|
101
126
|
return;
|
|
@@ -121,25 +146,13 @@ function worker(uri, options, callback) {
|
|
|
121
146
|
try {
|
|
122
147
|
var _ref;
|
|
123
148
|
var _config_optionsMapper;
|
|
124
|
-
//
|
|
125
|
-
var
|
|
126
|
-
|
|
127
|
-
var
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
var storeInstance = new AdapterClass(uri, cleanAdapterOptions);
|
|
132
|
-
var keyv = new _keyv.default(_object_spread({
|
|
133
|
-
store: storeInstance
|
|
134
|
-
}, options));
|
|
135
|
-
callback(null, keyv);
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
var storeInstance1 = new AdapterClass(cleanAdapterOptions);
|
|
139
|
-
var keyv1 = new _keyv.default(_object_spread({
|
|
140
|
-
store: storeInstance1
|
|
141
|
-
}, options));
|
|
142
|
-
callback(null, keyv1);
|
|
149
|
+
// Code options split between Keyv and the adapter; query parameters and the URI path mapper go to the adapter only. Code wins.
|
|
150
|
+
var _splitOptions = splitOptions(options), keyvOptions = _splitOptions.keyvOptions, codeAdapterOptions = _splitOptions.adapterOptions;
|
|
151
|
+
var adapterOptions = _object_spread({}, (0, _utilsts.parseUriOptions)(url), (_ref = (_config_optionsMapper = config.optionsMapper) === null || _config_optionsMapper === void 0 ? void 0 : _config_optionsMapper.call(config, url)) !== null && _ref !== void 0 ? _ref : {}, codeAdapterOptions);
|
|
152
|
+
var storeInstance = config.mode === 'string' ? new AdapterClass(uri, adapterOptions) : new AdapterClass(adapterOptions);
|
|
153
|
+
callback(null, new _keyv.default(_object_spread_props(_object_spread({}, keyvOptions), {
|
|
154
|
+
store: storeInstance
|
|
155
|
+
})));
|
|
143
156
|
} catch (createErr) {
|
|
144
157
|
callback(createErr);
|
|
145
158
|
}
|
package/dist/cjs/worker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/open-source/keyv/keyv-registry/src/worker.ts"],"sourcesContent":["import Keyv from 'keyv';\nimport loadAdapter from './loadAdapter.ts';\nimport { getAdapterConfig } from './registry.ts';\nimport type { CreateStoreCallback, CreateStoreOptions } from './types.ts';\nimport { parseUriOptions } from './utils.ts';\n\n/**\n * Core worker function that creates a Keyv store\n */\nexport default function worker<T>(uri: string, options: CreateStoreOptions, callback: CreateStoreCallback<T>): void {\n // Passthrough: pre-instantiated adapter provided\n if (options.store) {\n try {\n const keyv = new Keyv<T>({ ...options });\n callback(null, keyv);\n } catch (err) {\n callback(err as Error);\n }\n return;\n }\n\n // Parse URI\n let url: URL;\n try {\n url =
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/open-source/keyv/keyv-registry/src/worker.ts"],"sourcesContent":["import Keyv from 'keyv';\nimport { KEYV_OPTION_KEYS } from './constants.ts';\nimport loadAdapter from './loadAdapter.ts';\nimport { getAdapterConfig } from './registry.ts';\nimport type { CreateStoreCallback, CreateStoreOptions } from './types.ts';\nimport { parseUri, parseUriOptions } from './utils.ts';\n\n/**\n * Split code options: Keyv's own keys go to `new Keyv`, the rest to the adapter constructor\n */\nexport function splitOptions(merged: Record<string, unknown>): { keyvOptions: Record<string, unknown>; adapterOptions: Record<string, unknown> } {\n const keyvOptions: Record<string, unknown> = {};\n const adapterOptions: Record<string, unknown> = {};\n for (const key of Object.keys(merged)) {\n if (key === 'store') continue;\n (KEYV_OPTION_KEYS.has(key) ? keyvOptions : adapterOptions)[key] = merged[key];\n }\n return { keyvOptions, adapterOptions };\n}\n\n/**\n * Core worker function that creates a Keyv store\n */\nexport default function worker<T>(uri: string, options: CreateStoreOptions, callback: CreateStoreCallback<T>): void {\n // Passthrough: pre-instantiated adapter provided\n if (options.store) {\n try {\n const keyv = new Keyv<T>({ ...options });\n callback(null, keyv);\n } catch (err) {\n callback(err as Error);\n }\n return;\n }\n\n // Parse URI\n let url: URL;\n try {\n url = parseUri(uri);\n } catch (_err) {\n callback(new Error(`Invalid URI: ${uri}`));\n return;\n }\n\n const config = getAdapterConfig(url.protocol);\n\n if (!config) {\n callback(new Error(`Unknown protocol: ${url.protocol}. Use registerAdapter() to add support.`));\n return;\n }\n\n // Memory store - no package needed\n if (config.package === null) {\n try {\n const keyv = new Keyv<T>({ ...parseUriOptions(url), ...options });\n callback(null, keyv);\n } catch (err) {\n callback(err as Error);\n }\n return;\n }\n\n // Load adapter (install if needed)\n loadAdapter(config.package, config.exportName, (err, AdapterClass) => {\n if (err) return callback(err);\n\n try {\n // Code options split between Keyv and the adapter; query parameters and the URI path mapper go to the adapter only. Code wins.\n const { keyvOptions, adapterOptions: codeAdapterOptions } = splitOptions(options);\n const adapterOptions = {\n ...parseUriOptions(url),\n ...(config.optionsMapper?.(url) ?? {}),\n ...codeAdapterOptions,\n };\n\n const storeInstance = config.mode === 'string' ? new (AdapterClass as new (uri: string, options: Record<string, unknown>) => unknown)(uri, adapterOptions) : new (AdapterClass as new (options: Record<string, unknown>) => unknown)(adapterOptions);\n callback(null, new Keyv<T>({ ...keyvOptions, store: storeInstance }));\n } catch (createErr) {\n callback(createErr as Error);\n }\n });\n}\n"],"names":["worker","splitOptions","merged","keyvOptions","adapterOptions","Object","keys","key","KEYV_OPTION_KEYS","has","uri","options","callback","store","keyv","Keyv","err","url","parseUri","_err","Error","config","getAdapterConfig","protocol","package","parseUriOptions","loadAdapter","exportName","AdapterClass","codeAdapterOptions","optionsMapper","storeInstance","mode","createErr"],"mappings":";;;;;;;;;;;QAoBA;;CAEC,GACD;eAAwBA;;QAbRC;eAAAA;;;2DAVC;2BACgB;oEACT;0BACS;uBAES;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKnC,SAASA,aAAaC,MAA+B;IAC1D,IAAMC,cAAuC,CAAC;IAC9C,IAAMC,iBAA0C,CAAC;QAC5C,kCAAA,2BAAA;;QAAL,QAAK,YAAaC,OAAOC,IAAI,CAACJ,4BAAzB,SAAA,6BAAA,QAAA,yBAAA,iCAAkC;YAAlC,IAAMK,MAAN;YACH,IAAIA,QAAQ,SAAS;YACpBC,CAAAA,6BAAgB,CAACC,GAAG,CAACF,OAAOJ,cAAcC,cAAa,CAAE,CAACG,IAAI,GAAGL,MAAM,CAACK,IAAI;QAC/E;;QAHK;QAAA;;;iBAAA,6BAAA;gBAAA;;;gBAAA;sBAAA;;;;IAIL,OAAO;QAAEJ,aAAAA;QAAaC,gBAAAA;IAAe;AACvC;AAKe,SAASJ,OAAUU,GAAW,EAAEC,OAA2B,EAAEC,QAAgC;IAC1G,iDAAiD;IACjD,IAAID,QAAQE,KAAK,EAAE;QACjB,IAAI;YACF,IAAMC,OAAO,IAAIC,aAAI,CAAI,mBAAKJ;YAC9BC,SAAS,MAAME;QACjB,EAAE,OAAOE,KAAK;YACZJ,SAASI;QACX;QACA;IACF;IAEA,YAAY;IACZ,IAAIC;IACJ,IAAI;QACFA,MAAMC,IAAAA,iBAAQ,EAACR;IACjB,EAAE,OAAOS,MAAM;QACbP,SAAS,IAAIQ,MAAM,AAAC,gBAAmB,OAAJV;QACnC;IACF;IAEA,IAAMW,SAASC,IAAAA,4BAAgB,EAACL,IAAIM,QAAQ;IAE5C,IAAI,CAACF,QAAQ;QACXT,SAAS,IAAIQ,MAAM,AAAC,qBAAiC,OAAbH,IAAIM,QAAQ,EAAC;QACrD;IACF;IAEA,mCAAmC;IACnC,IAAIF,OAAOG,OAAO,KAAK,MAAM;QAC3B,IAAI;YACF,IAAMV,QAAO,IAAIC,aAAI,CAAI,mBAAKU,IAAAA,wBAAe,EAACR,MAASN;YACvDC,SAAS,MAAME;QACjB,EAAE,OAAOE,KAAK;YACZJ,SAASI;QACX;QACA;IACF;IAEA,mCAAmC;IACnCU,IAAAA,sBAAW,EAACL,OAAOG,OAAO,EAAEH,OAAOM,UAAU,EAAE,SAACX,KAAKY;QACnD,IAAIZ,KAAK,OAAOJ,SAASI;QAEzB,IAAI;;gBAKIK;YAJN,+HAA+H;YAC/H,IAA4DpB,gBAAAA,aAAaU,UAAjER,cAAoDF,cAApDE,aAAaC,AAAgByB,qBAAuB5B,cAAvCG;YACrB,IAAMA,iBAAiB,mBAClBqB,IAAAA,wBAAe,EAACR,eACfI,wBAAAA,OAAOS,aAAa,cAApBT,4CAAAA,2BAAAA,QAAuBJ,2CAAQ,CAAC,GACjCY;YAGL,IAAME,gBAAgBV,OAAOW,IAAI,KAAK,WAAW,IAAKJ,aAAgFlB,KAAKN,kBAAkB,IAAKwB,aAAmExB;YACrOQ,SAAS,MAAM,IAAIG,aAAI,CAAI,wCAAKZ;gBAAaU,OAAOkB;;QACtD,EAAE,OAAOE,WAAW;YAClBrB,SAASqB;QACX;IACF;AACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Namespace keyv 5 used by default; keyv 6 has none. */ export const KEYV5_NAMESPACE = 'keyv';
|
|
2
|
+
/**
|
|
3
|
+
* Option keys that belong to `new Keyv(...)`; every other option goes to the adapter constructor.
|
|
4
|
+
* One entry per key of `KeyvOptions`: keyv@6.1.0 `dist/index.d.mts:586` namespace, `:593` serialization, `:598` store,
|
|
5
|
+
* `:603` ttl, `:608` compression, `:613` stats, `:620` sanitize, `:628` encryption, `:638` checkExpired.
|
|
6
|
+
* The `Record<keyof KeyvOptions, true>` type makes a key added by a later keyv a compile error here.
|
|
7
|
+
*/ const KEYV_OPTION_FLAGS = {
|
|
8
|
+
namespace: true,
|
|
9
|
+
serialization: true,
|
|
10
|
+
store: true,
|
|
11
|
+
ttl: true,
|
|
12
|
+
compression: true,
|
|
13
|
+
stats: true,
|
|
14
|
+
sanitize: true,
|
|
15
|
+
encryption: true,
|
|
16
|
+
checkExpired: true
|
|
17
|
+
};
|
|
18
|
+
export const KEYV_OPTION_KEYS = new Set(Object.keys(KEYV_OPTION_FLAGS));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/open-source/keyv/keyv-registry/src/constants.ts"],"sourcesContent":["import type { KeyvOptions } from 'keyv';\n\n/** Namespace keyv 5 used by default; keyv 6 has none. */\nexport const KEYV5_NAMESPACE = 'keyv';\n\n/**\n * Option keys that belong to `new Keyv(...)`; every other option goes to the adapter constructor.\n * One entry per key of `KeyvOptions`: keyv@6.1.0 `dist/index.d.mts:586` namespace, `:593` serialization, `:598` store,\n * `:603` ttl, `:608` compression, `:613` stats, `:620` sanitize, `:628` encryption, `:638` checkExpired.\n * The `Record<keyof KeyvOptions, true>` type makes a key added by a later keyv a compile error here.\n */\nconst KEYV_OPTION_FLAGS: Record<keyof KeyvOptions, true> = {\n namespace: true,\n serialization: true,\n store: true,\n ttl: true,\n compression: true,\n stats: true,\n sanitize: true,\n encryption: true,\n checkExpired: true,\n};\n\nexport const KEYV_OPTION_KEYS: ReadonlySet<string> = new Set(Object.keys(KEYV_OPTION_FLAGS));\n"],"names":["KEYV5_NAMESPACE","KEYV_OPTION_FLAGS","namespace","serialization","store","ttl","compression","stats","sanitize","encryption","checkExpired","KEYV_OPTION_KEYS","Set","Object","keys"],"mappings":"AAEA,uDAAuD,GACvD,OAAO,MAAMA,kBAAkB,OAAO;AAEtC;;;;;CAKC,GACD,MAAMC,oBAAqD;IACzDC,WAAW;IACXC,eAAe;IACfC,OAAO;IACPC,KAAK;IACLC,aAAa;IACbC,OAAO;IACPC,UAAU;IACVC,YAAY;IACZC,cAAc;AAChB;AAEA,OAAO,MAAMC,mBAAwC,IAAIC,IAAIC,OAAOC,IAAI,CAACb,oBAAoB"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type Keyv from 'keyv';
|
|
2
2
|
import type { CreateStoreCallback, CreateStoreOptions } from './types.js';
|
|
3
|
+
export { KEYV5_NAMESPACE } from './constants.js';
|
|
3
4
|
export { clearAdapterCache } from './loadAdapter.js';
|
|
5
|
+
export { default as migrateKeyv5Keys } from './migrate-keyv5.js';
|
|
4
6
|
export { getRegistry, registerAdapter } from './registry.js';
|
|
5
7
|
export type { AdapterConfig, CreateStoreCallback, CreateStoreOptions } from './types.js';
|
|
6
8
|
/**
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import worker from './worker.js';
|
|
2
|
+
export { KEYV5_NAMESPACE } from './constants.js';
|
|
2
3
|
export { clearAdapterCache } from './loadAdapter.js';
|
|
4
|
+
export { default as migrateKeyv5Keys } from './migrate-keyv5.js';
|
|
3
5
|
export { getRegistry, registerAdapter } from './registry.js';
|
|
4
6
|
export default function createStore(uri, options, callback) {
|
|
5
7
|
callback = typeof options === 'function' ? options : callback;
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/open-source/keyv/keyv-registry/src/index.ts"],"sourcesContent":["import type Keyv from 'keyv';\nimport type { CreateStoreCallback, CreateStoreOptions } from './types.ts';\nimport worker from './worker.ts';\n\nexport { clearAdapterCache } from './loadAdapter.ts';\nexport { getRegistry, registerAdapter } from './registry.ts';\nexport type { AdapterConfig, CreateStoreCallback, CreateStoreOptions } from './types.ts';\n\n/**\n * Create a Keyv store from a URI string\n *\n * Supports dual-boot API (callback or Promise):\n *\n * @example\n * // Promise API\n * const store = await createStore('redis://localhost:6379');\n * const file = await createStore('file://~/.cache/app/data.json');\n * const memory = await createStore('memory://');\n *\n * @example\n * // Callback API\n * createStore('redis://localhost:6379', (err, store) => {\n * if (err) throw err;\n * // use store\n * });\n *\n * @example\n * // With options\n * const store = await createStore('redis://localhost:6379', {\n * namespace: 'myapp',\n * ttl: 60000\n * });\n *\n * @example\n * // Pre-instantiated adapter passthrough\n * import KeyvRedis from '@keyv/redis';\n * const redis = new KeyvRedis('redis://localhost:6379');\n * const store = await createStore('redis://ignored', { store: redis });\n */\nexport default function createStore<T>(uri: string, callback: CreateStoreCallback<T>): void;\nexport default function createStore<T>(uri: string, options: CreateStoreOptions, callback: CreateStoreCallback<T>): void;\nexport default function createStore<T>(uri: string, options?: CreateStoreOptions): Promise<Keyv<T>>;\nexport default function createStore<T>(uri: string, options?: CreateStoreOptions | CreateStoreCallback<T>, callback?: CreateStoreCallback<T>): void | Promise<Keyv<T>> {\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as CreateStoreOptions);\n\n if (typeof callback === 'function') return worker(uri, options, callback);\n return new Promise((resolve, reject) => worker(uri, options, (err, store) => (err ? reject(err) : resolve(store as Keyv<T>))));\n}\n"],"names":["worker","clearAdapterCache","getRegistry","registerAdapter","createStore","uri","options","callback","Promise","resolve","reject","err","store"],"mappings":"AAEA,OAAOA,YAAY,cAAc;AAEjC,SAASC,iBAAiB,QAAQ,mBAAmB;AACrD,SAASC,WAAW,EAAEC,eAAe,QAAQ,gBAAgB;AAqC7D,eAAe,SAASC,YAAeC,GAAW,EAAEC,OAAqD,EAAEC,QAAiC;IAC1IA,WAAW,OAAOD,YAAY,aAAaA,UAAUC;IACrDD,UAAU,OAAOA,YAAY,aAAa,CAAC,IAAMA,WAAW,CAAC;IAE7D,IAAI,OAAOC,aAAa,YAAY,
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/open-source/keyv/keyv-registry/src/index.ts"],"sourcesContent":["import type Keyv from 'keyv';\nimport type { CreateStoreCallback, CreateStoreOptions } from './types.ts';\nimport worker from './worker.ts';\n\nexport { KEYV5_NAMESPACE } from './constants.ts';\nexport { clearAdapterCache } from './loadAdapter.ts';\nexport { default as migrateKeyv5Keys } from './migrate-keyv5.ts';\nexport { getRegistry, registerAdapter } from './registry.ts';\nexport type { AdapterConfig, CreateStoreCallback, CreateStoreOptions } from './types.ts';\n\n/**\n * Create a Keyv store from a URI string\n *\n * Supports dual-boot API (callback or Promise):\n *\n * @example\n * // Promise API\n * const store = await createStore('redis://localhost:6379');\n * const file = await createStore('file://~/.cache/app/data.json');\n * const memory = await createStore('memory://');\n *\n * @example\n * // Callback API\n * createStore('redis://localhost:6379', (err, store) => {\n * if (err) throw err;\n * // use store\n * });\n *\n * @example\n * // With options\n * const store = await createStore('redis://localhost:6379', {\n * namespace: 'myapp',\n * ttl: 60000\n * });\n *\n * @example\n * // Pre-instantiated adapter passthrough\n * import KeyvRedis from '@keyv/redis';\n * const redis = new KeyvRedis('redis://localhost:6379');\n * const store = await createStore('redis://ignored', { store: redis });\n */\nexport default function createStore<T>(uri: string, callback: CreateStoreCallback<T>): void;\nexport default function createStore<T>(uri: string, options: CreateStoreOptions, callback: CreateStoreCallback<T>): void;\nexport default function createStore<T>(uri: string, options?: CreateStoreOptions): Promise<Keyv<T>>;\nexport default function createStore<T>(uri: string, options?: CreateStoreOptions | CreateStoreCallback<T>, callback?: CreateStoreCallback<T>): void | Promise<Keyv<T>> {\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as CreateStoreOptions);\n\n if (typeof callback === 'function') return worker(uri, options, callback);\n return new Promise((resolve, reject) => worker(uri, options, (err, store) => (err ? reject(err) : resolve(store as Keyv<T>))));\n}\n"],"names":["worker","KEYV5_NAMESPACE","clearAdapterCache","default","migrateKeyv5Keys","getRegistry","registerAdapter","createStore","uri","options","callback","Promise","resolve","reject","err","store"],"mappings":"AAEA,OAAOA,YAAY,cAAc;AAEjC,SAASC,eAAe,QAAQ,iBAAiB;AACjD,SAASC,iBAAiB,QAAQ,mBAAmB;AACrD,SAASC,WAAWC,gBAAgB,QAAQ,qBAAqB;AACjE,SAASC,WAAW,EAAEC,eAAe,QAAQ,gBAAgB;AAqC7D,eAAe,SAASC,YAAeC,GAAW,EAAEC,OAAqD,EAAEC,QAAiC;IAC1IA,WAAW,OAAOD,YAAY,aAAaA,UAAUC;IACrDD,UAAU,OAAOA,YAAY,aAAa,CAAC,IAAMA,WAAW,CAAC;IAE7D,IAAI,OAAOC,aAAa,YAAY,OAAOV,OAAOQ,KAAKC,SAASC;IAChE,OAAO,IAAIC,QAAQ,CAACC,SAASC,SAAWb,OAAOQ,KAAKC,SAAS,CAACK,KAAKC,QAAWD,MAAMD,OAAOC,OAAOF,QAAQG;AAC5G"}
|
package/dist/esm/loadAdapter.js
CHANGED
|
@@ -3,6 +3,18 @@ import Module from 'node:module';
|
|
|
3
3
|
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
4
4
|
// Cache loaded adapters
|
|
5
5
|
const adapterCache = new Map();
|
|
6
|
+
// Module-not-found for the adapter itself; a missing dependency of the adapter names another module
|
|
7
|
+
function isMissingModule(err, packageName) {
|
|
8
|
+
const e = err;
|
|
9
|
+
return ((e === null || e === void 0 ? void 0 : e.code) === 'MODULE_NOT_FOUND' || (e === null || e === void 0 ? void 0 : e.code) === 'ERR_MODULE_NOT_FOUND') && typeof e.message === 'string' && e.message.includes(`'${packageName}'`);
|
|
10
|
+
}
|
|
11
|
+
// Keep the original error as `cause` (the `ErrorOptions` argument is not in this project's lib target)
|
|
12
|
+
function loadError(err, packageName) {
|
|
13
|
+
const message = isMissingModule(err, packageName) ? `Adapter "${packageName}" is not installed. Install it alongside this package: npm install ${packageName}` : `Adapter "${packageName}" failed to load: ${err === null || err === void 0 ? void 0 : err.message}`;
|
|
14
|
+
const error = new Error(message);
|
|
15
|
+
error.cause = err;
|
|
16
|
+
return error;
|
|
17
|
+
}
|
|
6
18
|
/**
|
|
7
19
|
* Load an adapter from the modules installed alongside the consumer
|
|
8
20
|
*/ export default function loadAdapter(packageName, exportName, callback) {
|
|
@@ -17,8 +29,8 @@ const adapterCache = new Map();
|
|
|
17
29
|
var _mod_default;
|
|
18
30
|
const mod = _require(packageName);
|
|
19
31
|
Adapter = exportName ? mod[exportName] : (_mod_default = mod.default) !== null && _mod_default !== void 0 ? _mod_default : mod;
|
|
20
|
-
} catch
|
|
21
|
-
callback(
|
|
32
|
+
} catch (err) {
|
|
33
|
+
callback(loadError(err, packageName));
|
|
22
34
|
return;
|
|
23
35
|
}
|
|
24
36
|
adapterCache.set(cacheKey, Adapter);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/open-source/keyv/keyv-registry/src/loadAdapter.ts"],"sourcesContent":["import Module from 'node:module';\nimport type { LoadAdapterCallback } from './types.ts';\n\n// Create require function for ESM compatibility\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\n// Cache loaded adapters\nconst adapterCache = new Map<string, unknown>();\n\n/**\n * Load an adapter from the modules installed alongside the consumer\n */\nexport default function loadAdapter(packageName: string, exportName: string | undefined, callback: LoadAdapterCallback): void {\n const cacheKey = `${packageName}:${exportName ?? 'default'}`;\n\n // Return cached adapter if available\n if (adapterCache.has(cacheKey)) {\n callback(null, adapterCache.get(cacheKey));\n return;\n }\n\n let Adapter: unknown;\n try {\n const mod = _require(packageName);\n Adapter = exportName ? mod[exportName] : (mod.default ?? mod);\n } catch {\n callback(
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/open-source/keyv/keyv-registry/src/loadAdapter.ts"],"sourcesContent":["import Module from 'node:module';\nimport type { LoadAdapterCallback } from './types.ts';\n\n// Create require function for ESM compatibility\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\n// Cache loaded adapters\nconst adapterCache = new Map<string, unknown>();\n\n// Module-not-found for the adapter itself; a missing dependency of the adapter names another module\nfunction isMissingModule(err: unknown, packageName: string): boolean {\n const e = err as { code?: string; message?: string };\n return (e?.code === 'MODULE_NOT_FOUND' || e?.code === 'ERR_MODULE_NOT_FOUND') && typeof e.message === 'string' && e.message.includes(`'${packageName}'`);\n}\n\n// Keep the original error as `cause` (the `ErrorOptions` argument is not in this project's lib target)\nfunction loadError(err: unknown, packageName: string): Error {\n const message = isMissingModule(err, packageName) ? `Adapter \"${packageName}\" is not installed. Install it alongside this package: npm install ${packageName}` : `Adapter \"${packageName}\" failed to load: ${(err as Error)?.message}`;\n const error = new Error(message);\n (error as Error & { cause?: unknown }).cause = err;\n return error;\n}\n\n/**\n * Load an adapter from the modules installed alongside the consumer\n */\nexport default function loadAdapter(packageName: string, exportName: string | undefined, callback: LoadAdapterCallback): void {\n const cacheKey = `${packageName}:${exportName ?? 'default'}`;\n\n // Return cached adapter if available\n if (adapterCache.has(cacheKey)) {\n callback(null, adapterCache.get(cacheKey));\n return;\n }\n\n let Adapter: unknown;\n try {\n const mod = _require(packageName);\n Adapter = exportName ? mod[exportName] : (mod.default ?? mod);\n } catch (err) {\n callback(loadError(err, packageName));\n return;\n }\n\n adapterCache.set(cacheKey, Adapter);\n callback(null, Adapter);\n}\n\n/**\n * Clear the adapter cache (useful for testing)\n */\nexport function clearAdapterCache(): void {\n adapterCache.clear();\n}\n"],"names":["Module","_require","require","createRequire","url","adapterCache","Map","isMissingModule","err","packageName","e","code","message","includes","loadError","error","Error","cause","loadAdapter","exportName","callback","cacheKey","has","get","Adapter","mod","default","set","clearAdapterCache","clear"],"mappings":"AAAA,OAAOA,YAAY,cAAc;AAGjC,gDAAgD;AAChD,MAAMC,WAAW,OAAOC,YAAY,cAAcF,OAAOG,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAE1F,wBAAwB;AACxB,MAAMG,eAAe,IAAIC;AAEzB,oGAAoG;AACpG,SAASC,gBAAgBC,GAAY,EAAEC,WAAmB;IACxD,MAAMC,IAAIF;IACV,OAAO,AAACE,CAAAA,CAAAA,cAAAA,wBAAAA,EAAGC,IAAI,MAAK,sBAAsBD,CAAAA,cAAAA,wBAAAA,EAAGC,IAAI,MAAK,sBAAqB,KAAM,OAAOD,EAAEE,OAAO,KAAK,YAAYF,EAAEE,OAAO,CAACC,QAAQ,CAAC,CAAC,CAAC,EAAEJ,YAAY,CAAC,CAAC;AACzJ;AAEA,uGAAuG;AACvG,SAASK,UAAUN,GAAY,EAAEC,WAAmB;IAClD,MAAMG,UAAUL,gBAAgBC,KAAKC,eAAe,CAAC,SAAS,EAAEA,YAAY,mEAAmE,EAAEA,aAAa,GAAG,CAAC,SAAS,EAAEA,YAAY,kBAAkB,EAAGD,gBAAAA,0BAAD,AAACA,IAAeI,OAAO,EAAE;IACtO,MAAMG,QAAQ,IAAIC,MAAMJ;IACvBG,MAAsCE,KAAK,GAAGT;IAC/C,OAAOO;AACT;AAEA;;CAEC,GACD,eAAe,SAASG,YAAYT,WAAmB,EAAEU,UAA8B,EAAEC,QAA6B;IACpH,MAAMC,WAAW,GAAGZ,YAAY,CAAC,EAAEU,uBAAAA,wBAAAA,aAAc,WAAW;IAE5D,qCAAqC;IACrC,IAAId,aAAaiB,GAAG,CAACD,WAAW;QAC9BD,SAAS,MAAMf,aAAakB,GAAG,CAACF;QAChC;IACF;IAEA,IAAIG;IACJ,IAAI;YAEwCC;QAD1C,MAAMA,MAAMxB,SAASQ;QACrBe,UAAUL,aAAaM,GAAG,CAACN,WAAW,IAAIM,eAAAA,IAAIC,OAAO,cAAXD,0BAAAA,eAAeA;IAC3D,EAAE,OAAOjB,KAAK;QACZY,SAASN,UAAUN,KAAKC;QACxB;IACF;IAEAJ,aAAasB,GAAG,CAACN,UAAUG;IAC3BJ,SAAS,MAAMI;AACjB;AAEA;;CAEC,GACD,OAAO,SAASI;IACdvB,aAAawB,KAAK;AACpB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Keyv } from 'keyv';
|
|
2
|
+
/**
|
|
3
|
+
* One-time move of entries keyv 5 wrote under its default `keyv` namespace to the plain keys keyv 6 reads.
|
|
4
|
+
*
|
|
5
|
+
* Works through the Keyv API only, on the instance the caller passes, so it covers every adapter that can iterate.
|
|
6
|
+
* Finds both old layouts: `keyv:<key>` with no namespace (keyv-file) and namespace `keyv` (sqlite `<key>`, redis `keyv:<key>`).
|
|
7
|
+
* Keeps the absolute expiry, skips expired entries, lets an existing plain key win, and is safe to run again.
|
|
8
|
+
*
|
|
9
|
+
* Call it at startup, before the store serves other traffic: it renames keys and switches `store.namespace` while it runs.
|
|
10
|
+
* A plain key that itself starts with `keyv:` is taken for a keyv 5 key.
|
|
11
|
+
* A store that cannot iterate (for example memcache) has nothing to find: it returns 0.
|
|
12
|
+
*
|
|
13
|
+
* Store errors: keyv hides them from the caller once any `error` listener is attached, so a temporary listener watches every read and write.
|
|
14
|
+
* If one is emitted, the old key is not deleted and the call rejects with the error as `cause`; entries already moved stay moved and a rerun repairs the rest.
|
|
15
|
+
*
|
|
16
|
+
* @returns the number of entries moved
|
|
17
|
+
*/
|
|
18
|
+
export default function migrateKeyv5Keys(store: Keyv): Promise<number>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { KEYV5_NAMESPACE } from './constants.js';
|
|
2
|
+
const PREFIX = `${KEYV5_NAMESPACE}:`;
|
|
3
|
+
function fail(message, cause) {
|
|
4
|
+
const error = new Error(message);
|
|
5
|
+
error.cause = cause;
|
|
6
|
+
return error;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* One-time move of entries keyv 5 wrote under its default `keyv` namespace to the plain keys keyv 6 reads.
|
|
10
|
+
*
|
|
11
|
+
* Works through the Keyv API only, on the instance the caller passes, so it covers every adapter that can iterate.
|
|
12
|
+
* Finds both old layouts: `keyv:<key>` with no namespace (keyv-file) and namespace `keyv` (sqlite `<key>`, redis `keyv:<key>`).
|
|
13
|
+
* Keeps the absolute expiry, skips expired entries, lets an existing plain key win, and is safe to run again.
|
|
14
|
+
*
|
|
15
|
+
* Call it at startup, before the store serves other traffic: it renames keys and switches `store.namespace` while it runs.
|
|
16
|
+
* A plain key that itself starts with `keyv:` is taken for a keyv 5 key.
|
|
17
|
+
* A store that cannot iterate (for example memcache) has nothing to find: it returns 0.
|
|
18
|
+
*
|
|
19
|
+
* Store errors: keyv hides them from the caller once any `error` listener is attached, so a temporary listener watches every read and write.
|
|
20
|
+
* If one is emitted, the old key is not deleted and the call rejects with the error as `cause`; entries already moved stay moved and a rerun repairs the rest.
|
|
21
|
+
*
|
|
22
|
+
* @returns the number of entries moved
|
|
23
|
+
*/ export default async function migrateKeyv5Keys(store) {
|
|
24
|
+
const original = store.namespace;
|
|
25
|
+
const errors = [];
|
|
26
|
+
const onError = (err)=>errors.push(err);
|
|
27
|
+
const check = (what)=>{
|
|
28
|
+
var _ref;
|
|
29
|
+
var _errors_;
|
|
30
|
+
if (errors.length > 0) throw fail(`migrateKeyv5Keys: ${what}: ${(_ref = (_errors_ = errors[0]) === null || _errors_ === void 0 ? void 0 : _errors_.message) !== null && _ref !== void 0 ? _ref : errors[0]}`, errors[0]);
|
|
31
|
+
};
|
|
32
|
+
store.on('error', onError);
|
|
33
|
+
try {
|
|
34
|
+
const legacy = [];
|
|
35
|
+
// Collect first, then change anything, so the iterators never see our own writes.
|
|
36
|
+
store.namespace = undefined;
|
|
37
|
+
for await (const [key] of store.iterator())if (typeof key === 'string' && key.startsWith(PREFIX)) legacy.push({
|
|
38
|
+
namespace: undefined,
|
|
39
|
+
oldKey: key,
|
|
40
|
+
newKey: key.slice(PREFIX.length)
|
|
41
|
+
});
|
|
42
|
+
check('listing keys failed');
|
|
43
|
+
store.namespace = KEYV5_NAMESPACE;
|
|
44
|
+
for await (const [key] of store.iterator())if (typeof key === 'string') legacy.push({
|
|
45
|
+
namespace: KEYV5_NAMESPACE,
|
|
46
|
+
oldKey: key,
|
|
47
|
+
newKey: key.startsWith(PREFIX) ? key.slice(PREFIX.length) : key
|
|
48
|
+
});
|
|
49
|
+
check('listing keys failed');
|
|
50
|
+
let moved = 0;
|
|
51
|
+
for (const { namespace, oldKey, newKey } of legacy){
|
|
52
|
+
store.namespace = namespace;
|
|
53
|
+
const raw = await store.getRaw(oldKey); // undefined when expired, and when the store failed (then an error was emitted)
|
|
54
|
+
check(`reading "${oldKey}" failed, kept it`);
|
|
55
|
+
store.namespace = undefined;
|
|
56
|
+
if (raw !== undefined) {
|
|
57
|
+
const exists = await store.has(newKey);
|
|
58
|
+
check(`checking "${newKey}" failed, kept "${oldKey}"`);
|
|
59
|
+
if (!exists) {
|
|
60
|
+
if (!await store.setRaw(newKey, raw)) throw fail(`migrateKeyv5Keys: could not write migrated key "${newKey}", kept "${oldKey}"`, errors[0]);
|
|
61
|
+
check(`writing "${newKey}" failed, kept "${oldKey}"`);
|
|
62
|
+
moved++;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
store.namespace = namespace;
|
|
66
|
+
await store.delete(oldKey); // after the write: a crash in between leaves both, and a rerun keeps the plain key
|
|
67
|
+
check(`deleting "${oldKey}" failed`);
|
|
68
|
+
}
|
|
69
|
+
return moved;
|
|
70
|
+
} finally{
|
|
71
|
+
store.off('error', onError);
|
|
72
|
+
store.namespace = original;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/open-source/keyv/keyv-registry/src/migrate-keyv5.ts"],"sourcesContent":["import type { Keyv, KeyvValue } from 'keyv';\nimport { KEYV5_NAMESPACE } from './constants.ts';\n\nconst PREFIX = `${KEYV5_NAMESPACE}:`;\n\ninterface LegacyKey {\n /** Namespace the old key is read and deleted under */\n namespace: string | undefined;\n oldKey: string;\n newKey: string;\n}\n\nfunction fail(message: string, cause: unknown): Error {\n const error = new Error(message);\n (error as Error & { cause?: unknown }).cause = cause;\n return error;\n}\n\n/**\n * One-time move of entries keyv 5 wrote under its default `keyv` namespace to the plain keys keyv 6 reads.\n *\n * Works through the Keyv API only, on the instance the caller passes, so it covers every adapter that can iterate.\n * Finds both old layouts: `keyv:<key>` with no namespace (keyv-file) and namespace `keyv` (sqlite `<key>`, redis `keyv:<key>`).\n * Keeps the absolute expiry, skips expired entries, lets an existing plain key win, and is safe to run again.\n *\n * Call it at startup, before the store serves other traffic: it renames keys and switches `store.namespace` while it runs.\n * A plain key that itself starts with `keyv:` is taken for a keyv 5 key.\n * A store that cannot iterate (for example memcache) has nothing to find: it returns 0.\n *\n * Store errors: keyv hides them from the caller once any `error` listener is attached, so a temporary listener watches every read and write.\n * If one is emitted, the old key is not deleted and the call rejects with the error as `cause`; entries already moved stay moved and a rerun repairs the rest.\n *\n * @returns the number of entries moved\n */\nexport default async function migrateKeyv5Keys(store: Keyv): Promise<number> {\n const original = store.namespace;\n const errors: unknown[] = [];\n const onError = (err: unknown) => errors.push(err);\n const check = (what: string) => {\n if (errors.length > 0) throw fail(`migrateKeyv5Keys: ${what}: ${(errors[0] as Error)?.message ?? errors[0]}`, errors[0]);\n };\n store.on('error', onError);\n try {\n const legacy: LegacyKey[] = [];\n\n // Collect first, then change anything, so the iterators never see our own writes.\n store.namespace = undefined;\n for await (const [key] of store.iterator()) if (typeof key === 'string' && key.startsWith(PREFIX)) legacy.push({ namespace: undefined, oldKey: key, newKey: key.slice(PREFIX.length) });\n check('listing keys failed');\n store.namespace = KEYV5_NAMESPACE;\n for await (const [key] of store.iterator()) if (typeof key === 'string') legacy.push({ namespace: KEYV5_NAMESPACE, oldKey: key, newKey: key.startsWith(PREFIX) ? key.slice(PREFIX.length) : key });\n check('listing keys failed');\n\n let moved = 0;\n for (const { namespace, oldKey, newKey } of legacy) {\n store.namespace = namespace;\n const raw = await store.getRaw(oldKey); // undefined when expired, and when the store failed (then an error was emitted)\n check(`reading \"${oldKey}\" failed, kept it`);\n store.namespace = undefined;\n if (raw !== undefined) {\n const exists = await store.has(newKey);\n check(`checking \"${newKey}\" failed, kept \"${oldKey}\"`);\n if (!exists) {\n if (!(await store.setRaw(newKey, raw as KeyvValue<unknown>))) throw fail(`migrateKeyv5Keys: could not write migrated key \"${newKey}\", kept \"${oldKey}\"`, errors[0]);\n check(`writing \"${newKey}\" failed, kept \"${oldKey}\"`);\n moved++;\n }\n }\n store.namespace = namespace;\n await store.delete(oldKey); // after the write: a crash in between leaves both, and a rerun keeps the plain key\n check(`deleting \"${oldKey}\" failed`);\n }\n return moved;\n } finally {\n store.off('error', onError);\n store.namespace = original;\n }\n}\n"],"names":["KEYV5_NAMESPACE","PREFIX","fail","message","cause","error","Error","migrateKeyv5Keys","store","original","namespace","errors","onError","err","push","check","what","length","on","legacy","undefined","key","iterator","startsWith","oldKey","newKey","slice","moved","raw","getRaw","exists","has","setRaw","delete","off"],"mappings":"AACA,SAASA,eAAe,QAAQ,iBAAiB;AAEjD,MAAMC,SAAS,GAAGD,gBAAgB,CAAC,CAAC;AASpC,SAASE,KAAKC,OAAe,EAAEC,KAAc;IAC3C,MAAMC,QAAQ,IAAIC,MAAMH;IACvBE,MAAsCD,KAAK,GAAGA;IAC/C,OAAOC;AACT;AAEA;;;;;;;;;;;;;;;CAeC,GACD,eAAe,eAAeE,iBAAiBC,KAAW;IACxD,MAAMC,WAAWD,MAAME,SAAS;IAChC,MAAMC,SAAoB,EAAE;IAC5B,MAAMC,UAAU,CAACC,MAAiBF,OAAOG,IAAI,CAACD;IAC9C,MAAME,QAAQ,CAACC;;YACoDL;QAAjE,IAAIA,OAAOM,MAAM,GAAG,GAAG,MAAMf,KAAK,CAAC,kBAAkB,EAAEc,KAAK,EAAE,WAAGL,WAAAA,MAAM,CAAC,EAAE,cAATA,+BAAD,AAACA,SAAqBR,OAAO,uCAAIQ,MAAM,CAAC,EAAE,EAAE,EAAEA,MAAM,CAAC,EAAE;IACzH;IACAH,MAAMU,EAAE,CAAC,SAASN;IAClB,IAAI;QACF,MAAMO,SAAsB,EAAE;QAE9B,kFAAkF;QAClFX,MAAME,SAAS,GAAGU;QAClB,WAAW,MAAM,CAACC,IAAI,IAAIb,MAAMc,QAAQ,GAAI,IAAI,OAAOD,QAAQ,YAAYA,IAAIE,UAAU,CAACtB,SAASkB,OAAOL,IAAI,CAAC;YAAEJ,WAAWU;YAAWI,QAAQH;YAAKI,QAAQJ,IAAIK,KAAK,CAACzB,OAAOgB,MAAM;QAAE;QACrLF,MAAM;QACNP,MAAME,SAAS,GAAGV;QAClB,WAAW,MAAM,CAACqB,IAAI,IAAIb,MAAMc,QAAQ,GAAI,IAAI,OAAOD,QAAQ,UAAUF,OAAOL,IAAI,CAAC;YAAEJ,WAAWV;YAAiBwB,QAAQH;YAAKI,QAAQJ,IAAIE,UAAU,CAACtB,UAAUoB,IAAIK,KAAK,CAACzB,OAAOgB,MAAM,IAAII;QAAI;QAChMN,MAAM;QAEN,IAAIY,QAAQ;QACZ,KAAK,MAAM,EAAEjB,SAAS,EAAEc,MAAM,EAAEC,MAAM,EAAE,IAAIN,OAAQ;YAClDX,MAAME,SAAS,GAAGA;YAClB,MAAMkB,MAAM,MAAMpB,MAAMqB,MAAM,CAACL,SAAS,gFAAgF;YACxHT,MAAM,CAAC,SAAS,EAAES,OAAO,iBAAiB,CAAC;YAC3ChB,MAAME,SAAS,GAAGU;YAClB,IAAIQ,QAAQR,WAAW;gBACrB,MAAMU,SAAS,MAAMtB,MAAMuB,GAAG,CAACN;gBAC/BV,MAAM,CAAC,UAAU,EAAEU,OAAO,gBAAgB,EAAED,OAAO,CAAC,CAAC;gBACrD,IAAI,CAACM,QAAQ;oBACX,IAAI,CAAE,MAAMtB,MAAMwB,MAAM,CAACP,QAAQG,MAA6B,MAAM1B,KAAK,CAAC,gDAAgD,EAAEuB,OAAO,SAAS,EAAED,OAAO,CAAC,CAAC,EAAEb,MAAM,CAAC,EAAE;oBAClKI,MAAM,CAAC,SAAS,EAAEU,OAAO,gBAAgB,EAAED,OAAO,CAAC,CAAC;oBACpDG;gBACF;YACF;YACAnB,MAAME,SAAS,GAAGA;YAClB,MAAMF,MAAMyB,MAAM,CAACT,SAAS,mFAAmF;YAC/GT,MAAM,CAAC,UAAU,EAAES,OAAO,QAAQ,CAAC;QACrC;QACA,OAAOG;IACT,SAAU;QACRnB,MAAM0B,GAAG,CAAC,SAAStB;QACnBJ,MAAME,SAAS,GAAGD;IACpB;AACF"}
|
package/dist/esm/registry.js
CHANGED
|
@@ -36,7 +36,7 @@ import { resolveFilePath } from './utils.js';
|
|
|
36
36
|
package: '@keyv/sqlite',
|
|
37
37
|
mode: 'options',
|
|
38
38
|
optionsMapper: (url)=>({
|
|
39
|
-
uri: url
|
|
39
|
+
uri: `sqlite://${resolveFilePath(url)}`
|
|
40
40
|
})
|
|
41
41
|
},
|
|
42
42
|
'mongodb:': {
|
|
@@ -80,7 +80,7 @@ import { resolveFilePath } from './utils.js';
|
|
|
80
80
|
'duckdb:': {
|
|
81
81
|
package: 'keyv-duckdb',
|
|
82
82
|
optionsMapper: (url)=>({
|
|
83
|
-
|
|
83
|
+
path: resolveFilePath(url)
|
|
84
84
|
})
|
|
85
85
|
}
|
|
86
86
|
};
|
package/dist/esm/registry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/open-source/keyv/keyv-registry/src/registry.ts"],"sourcesContent":["import type { AdapterConfig } from './types.ts';\nimport { resolveFilePath } from './utils.ts';\n\n/**\n * Protocol registry mapping URI protocols to adapter configurations\n */\nconst PROTOCOL_REGISTRY: Record<string, AdapterConfig> = {\n // Official @keyv adapters\n 'redis:': { package: '@keyv/redis', mode: 'string' },\n 'rediss:': { package: '@keyv/redis', mode: 'string' },\n 'postgresql:': { package: '@keyv/postgres', mode: 'options', optionsMapper: (url) => ({ uri: url.toString() }) },\n 'postgres:': { package: '@keyv/postgres', mode: 'options', optionsMapper: (url) => ({ uri: url.toString() }) },\n 'mysql:': { package: '@keyv/mysql', mode: 'options', optionsMapper: (url) => ({ uri: url.toString() }) },\n 'sqlite:': { package: '@keyv/sqlite', mode: 'options', optionsMapper: (url) => ({ uri: url
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/open-source/keyv/keyv-registry/src/registry.ts"],"sourcesContent":["import type { AdapterConfig } from './types.ts';\nimport { resolveFilePath } from './utils.ts';\n\n/**\n * Protocol registry mapping URI protocols to adapter configurations\n */\nconst PROTOCOL_REGISTRY: Record<string, AdapterConfig> = {\n // Official @keyv adapters\n 'redis:': { package: '@keyv/redis', mode: 'string' },\n 'rediss:': { package: '@keyv/redis', mode: 'string' },\n 'postgresql:': { package: '@keyv/postgres', mode: 'options', optionsMapper: (url) => ({ uri: url.toString() }) },\n 'postgres:': { package: '@keyv/postgres', mode: 'options', optionsMapper: (url) => ({ uri: url.toString() }) },\n 'mysql:': { package: '@keyv/mysql', mode: 'options', optionsMapper: (url) => ({ uri: url.toString() }) },\n 'sqlite:': { package: '@keyv/sqlite', mode: 'options', optionsMapper: (url) => ({ uri: `sqlite://${resolveFilePath(url)}` }) },\n 'mongodb:': { package: '@keyv/mongo', mode: 'options', optionsMapper: (url) => ({ url: url.toString() }) },\n 'mongodb+srv:': { package: '@keyv/mongo', mode: 'options', optionsMapper: (url) => ({ url: url.toString() }) },\n 'memcache:': { package: '@keyv/memcache', mode: 'string' },\n 'etcd:': { package: '@keyv/etcd', mode: 'options', optionsMapper: (url) => ({ url: url.toString() }) },\n\n // Third-party adapters\n 'file:': {\n package: 'keyv-file',\n exportName: 'KeyvFile',\n optionsMapper: (url: URL) => ({ filename: resolveFilePath(url) }),\n },\n\n // Built-in (no package needed)\n 'memory:': { package: null },\n\n // Future/custom adapters\n 'duckdb:': {\n package: 'keyv-duckdb',\n optionsMapper: (url: URL) => ({ path: resolveFilePath(url) }),\n },\n};\n\n/**\n * Register or override a protocol adapter\n */\nexport function registerAdapter(protocol: string, config: AdapterConfig): void {\n const normalizedProtocol = protocol.endsWith(':') ? protocol : `${protocol}:`;\n PROTOCOL_REGISTRY[normalizedProtocol] = config;\n}\n\n/**\n * Get the current registry (read-only copy)\n */\nexport function getRegistry(): Readonly<Record<string, AdapterConfig>> {\n return { ...PROTOCOL_REGISTRY };\n}\n\n/**\n * Get adapter config for a protocol\n */\nexport function getAdapterConfig(protocol: string): AdapterConfig | undefined {\n return PROTOCOL_REGISTRY[protocol];\n}\n"],"names":["resolveFilePath","PROTOCOL_REGISTRY","package","mode","optionsMapper","url","uri","toString","exportName","filename","path","registerAdapter","protocol","config","normalizedProtocol","endsWith","getRegistry","getAdapterConfig"],"mappings":"AACA,SAASA,eAAe,QAAQ,aAAa;AAE7C;;CAEC,GACD,MAAMC,oBAAmD;IACvD,0BAA0B;IAC1B,UAAU;QAAEC,SAAS;QAAeC,MAAM;IAAS;IACnD,WAAW;QAAED,SAAS;QAAeC,MAAM;IAAS;IACpD,eAAe;QAAED,SAAS;QAAkBC,MAAM;QAAWC,eAAe,CAACC,MAAS,CAAA;gBAAEC,KAAKD,IAAIE,QAAQ;YAAG,CAAA;IAAG;IAC/G,aAAa;QAAEL,SAAS;QAAkBC,MAAM;QAAWC,eAAe,CAACC,MAAS,CAAA;gBAAEC,KAAKD,IAAIE,QAAQ;YAAG,CAAA;IAAG;IAC7G,UAAU;QAAEL,SAAS;QAAeC,MAAM;QAAWC,eAAe,CAACC,MAAS,CAAA;gBAAEC,KAAKD,IAAIE,QAAQ;YAAG,CAAA;IAAG;IACvG,WAAW;QAAEL,SAAS;QAAgBC,MAAM;QAAWC,eAAe,CAACC,MAAS,CAAA;gBAAEC,KAAK,CAAC,SAAS,EAAEN,gBAAgBK,MAAM;YAAC,CAAA;IAAG;IAC7H,YAAY;QAAEH,SAAS;QAAeC,MAAM;QAAWC,eAAe,CAACC,MAAS,CAAA;gBAAEA,KAAKA,IAAIE,QAAQ;YAAG,CAAA;IAAG;IACzG,gBAAgB;QAAEL,SAAS;QAAeC,MAAM;QAAWC,eAAe,CAACC,MAAS,CAAA;gBAAEA,KAAKA,IAAIE,QAAQ;YAAG,CAAA;IAAG;IAC7G,aAAa;QAAEL,SAAS;QAAkBC,MAAM;IAAS;IACzD,SAAS;QAAED,SAAS;QAAcC,MAAM;QAAWC,eAAe,CAACC,MAAS,CAAA;gBAAEA,KAAKA,IAAIE,QAAQ;YAAG,CAAA;IAAG;IAErG,uBAAuB;IACvB,SAAS;QACPL,SAAS;QACTM,YAAY;QACZJ,eAAe,CAACC,MAAc,CAAA;gBAAEI,UAAUT,gBAAgBK;YAAK,CAAA;IACjE;IAEA,+BAA+B;IAC/B,WAAW;QAAEH,SAAS;IAAK;IAE3B,yBAAyB;IACzB,WAAW;QACTA,SAAS;QACTE,eAAe,CAACC,MAAc,CAAA;gBAAEK,MAAMV,gBAAgBK;YAAK,CAAA;IAC7D;AACF;AAEA;;CAEC,GACD,OAAO,SAASM,gBAAgBC,QAAgB,EAAEC,MAAqB;IACrE,MAAMC,qBAAqBF,SAASG,QAAQ,CAAC,OAAOH,WAAW,GAAGA,SAAS,CAAC,CAAC;IAC7EX,iBAAiB,CAACa,mBAAmB,GAAGD;AAC1C;AAEA;;CAEC,GACD,OAAO,SAASG;IACd,OAAO;QAAE,GAAGf,iBAAiB;IAAC;AAChC;AAEA;;CAEC,GACD,OAAO,SAASgB,iBAAiBL,QAAgB;IAC/C,OAAOX,iBAAiB,CAACW,SAAS;AACpC"}
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type Keyv from 'keyv';
|
|
1
|
+
import type { Keyv, KeyvOptions } from 'keyv';
|
|
2
2
|
/**
|
|
3
3
|
* Configuration for a protocol adapter
|
|
4
4
|
*/
|
|
@@ -15,14 +15,10 @@ export interface AdapterConfig {
|
|
|
15
15
|
/**
|
|
16
16
|
* Options for createStore
|
|
17
17
|
*/
|
|
18
|
-
export interface CreateStoreOptions {
|
|
18
|
+
export interface CreateStoreOptions extends Partial<KeyvOptions> {
|
|
19
19
|
/** Pre-instantiated adapter (bypasses URI loading) */
|
|
20
|
-
store?:
|
|
21
|
-
/**
|
|
22
|
-
namespace?: string;
|
|
23
|
-
/** Default TTL in milliseconds */
|
|
24
|
-
ttl?: number;
|
|
25
|
-
/** Additional Keyv options */
|
|
20
|
+
store?: KeyvOptions['store'];
|
|
21
|
+
/** Options passed through to the adapter constructor */
|
|
26
22
|
[key: string]: unknown;
|
|
27
23
|
}
|
|
28
24
|
/**
|