@keyv/sqlite 4.0.1 → 4.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 CHANGED
@@ -41,7 +41,16 @@ const keyvSqlite = new KeyvSqlite('sqlite://path/to/database.sqlite', {
41
41
  const keyv = new Keyv({ store: keyvSqlite });
42
42
  ```
43
43
 
44
+ You can also use a helper function to create `Keyv` with `KeyvSqlite` store.
45
+
46
+ ```js
47
+ import {createKeyv} from '@keyv/sqlite';
48
+
49
+ const keyv = createKeyv('sqlite://path/to/database.sqlite');
50
+ ```
51
+
52
+
44
53
  ## License
45
54
 
46
- [MIT © Jared Wray](LISCENCE)
55
+ [MIT © Jared Wray](LICENCE)
47
56
 
package/dist/index.cjs CHANGED
@@ -28,14 +28,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
30
  // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
33
  KeyvSqlite: () => KeyvSqlite,
34
- default: () => src_default
34
+ createKeyv: () => createKeyv,
35
+ default: () => index_default
35
36
  });
36
- module.exports = __toCommonJS(src_exports);
37
+ module.exports = __toCommonJS(index_exports);
37
38
  var import_events = __toESM(require("events"), 1);
38
39
  var import_util = require("util");
40
+ var import_keyv = __toESM(require("keyv"), 1);
39
41
  var import_sqlite3 = __toESM(require("sqlite3"), 1);
40
42
  var toString = (input) => String(input).search(/^[a-zA-Z]+$/) < 0 ? "_" + input : input;
41
43
  var KeyvSqlite = class extends import_events.default {
@@ -157,8 +159,10 @@ var KeyvSqlite = class extends import_events.default {
157
159
  await this.close();
158
160
  }
159
161
  };
160
- var src_default = KeyvSqlite;
162
+ var createKeyv = (keyvOptions) => new import_keyv.default({ store: new KeyvSqlite(keyvOptions) });
163
+ var index_default = KeyvSqlite;
161
164
  // Annotate the CommonJS export names for ESM import in node:
162
165
  0 && (module.exports = {
163
- KeyvSqlite
166
+ KeyvSqlite,
167
+ createKeyv
164
168
  });
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import EventEmitter from 'events';
2
- import { KeyvStoreAdapter, StoredData } from 'keyv';
2
+ import Keyv, { KeyvStoreAdapter, StoredData } from 'keyv';
3
3
 
4
4
  type DbQuery = (sqlString: string, ...parameter: unknown[]) => Promise<any>;
5
5
  type DbClose = () => Promise<void>;
@@ -34,5 +34,6 @@ declare class KeyvSqlite extends EventEmitter implements KeyvStoreAdapter {
34
34
  has(key: string): Promise<boolean>;
35
35
  disconnect(): Promise<void>;
36
36
  }
37
+ declare const createKeyv: (keyvOptions?: KeyvSqliteOptions | string) => Keyv<any>;
37
38
 
38
- export { KeyvSqlite, KeyvSqlite as default };
39
+ export { KeyvSqlite, type KeyvSqliteOptions, createKeyv, KeyvSqlite as default };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import EventEmitter from 'events';
2
- import { KeyvStoreAdapter, StoredData } from 'keyv';
2
+ import Keyv, { KeyvStoreAdapter, StoredData } from 'keyv';
3
3
 
4
4
  type DbQuery = (sqlString: string, ...parameter: unknown[]) => Promise<any>;
5
5
  type DbClose = () => Promise<void>;
@@ -34,5 +34,6 @@ declare class KeyvSqlite extends EventEmitter implements KeyvStoreAdapter {
34
34
  has(key: string): Promise<boolean>;
35
35
  disconnect(): Promise<void>;
36
36
  }
37
+ declare const createKeyv: (keyvOptions?: KeyvSqliteOptions | string) => Keyv<any>;
37
38
 
38
- export { KeyvSqlite, KeyvSqlite as default };
39
+ export { KeyvSqlite, type KeyvSqliteOptions, createKeyv, KeyvSqlite as default };
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // src/index.ts
2
2
  import EventEmitter from "events";
3
3
  import { promisify } from "util";
4
+ import Keyv from "keyv";
4
5
  import sqlite3 from "sqlite3";
5
6
  var toString = (input) => String(input).search(/^[a-zA-Z]+$/) < 0 ? "_" + input : input;
6
7
  var KeyvSqlite = class extends EventEmitter {
@@ -122,8 +123,10 @@ var KeyvSqlite = class extends EventEmitter {
122
123
  await this.close();
123
124
  }
124
125
  };
125
- var src_default = KeyvSqlite;
126
+ var createKeyv = (keyvOptions) => new Keyv({ store: new KeyvSqlite(keyvOptions) });
127
+ var index_default = KeyvSqlite;
126
128
  export {
127
129
  KeyvSqlite,
128
- src_default as default
130
+ createKeyv,
131
+ index_default as default
129
132
  };
package/package.json CHANGED
@@ -1,81 +1,81 @@
1
1
  {
2
- "name": "@keyv/sqlite",
3
- "version": "4.0.1",
4
- "description": "SQLite storage adapter for Keyv",
5
- "type": "module",
6
- "main": "dist/index.cjs",
7
- "module": "dist/index.js",
8
- "types": "dist/index.d.ts",
9
- "exports": {
10
- ".": {
11
- "require": "./dist/index.cjs",
12
- "import": "./dist/index.js"
13
- }
14
- },
15
- "scripts": {
16
- "build": "rm -rf dist && tsup src/index.ts --format cjs,esm --dts --clean",
17
- "prepare": "yarn build",
18
- "test": "xo --fix && vitest run --coverage",
19
- "test:ci": "xo && vitest --run --sequence.setupFiles=list",
20
- "clean": "rm -rf node_modules && rm -rf ./coverage && rm -rf ./test/testdb.sqlite"
21
- },
22
- "xo": {
23
- "rules": {
24
- "import/no-named-as-default": "off",
25
- "unicorn/prefer-module": "off",
26
- "n/file-extension-in-import": "off",
27
- "unicorn/prefer-event-target": "off",
28
- "unicorn/prefer-node-protocol": "off",
29
- "promise/prefer-await-to-then": "off",
30
- "@typescript-eslint/use-unknown-in-catch-callback-variable": "off",
31
- "import/extensions": "off",
32
- "@typescript-eslint/no-unsafe-argument": "off",
33
- "@typescript-eslint/no-unsafe-assignment": "off",
34
- "@typescript-eslint/no-unsafe-call": "off",
35
- "@typescript-eslint/no-unsafe-return": "off",
36
- "import/no-extraneous-dependencies": "off",
37
- "unicorn/prevent-abbreviations": "off"
38
- }
39
- },
40
- "repository": {
41
- "type": "git",
42
- "url": "git+https://github.com/jaredwray/keyv.git"
43
- },
44
- "keywords": [
45
- "sqlite",
46
- "sql",
47
- "keyv",
48
- "storage",
49
- "adapter",
50
- "key",
51
- "value",
52
- "store",
53
- "cache",
54
- "ttl"
55
- ],
56
- "author": "Jared Wray <me@jaredwray.com> (http://jaredwray.com)",
57
- "license": "MIT",
58
- "bugs": {
59
- "url": "https://github.com/jaredwray/keyv/issues"
60
- },
61
- "homepage": "https://github.com/jaredwray/keyv",
62
- "dependencies": {
63
- "sqlite3": "^5.1.7"
64
- },
65
- "devDependencies": {
66
- "@keyv/test-suite": "*",
67
- "keyv": "^5.0.0",
68
- "tsd": "^0.31.1",
69
- "xo": "^0.59.3"
70
- },
71
- "tsd": {
72
- "directory": "test"
73
- },
74
- "engines": {
75
- "node": ">= 18"
76
- },
77
- "files": [
78
- "dist",
79
- "LICENSE"
80
- ]
81
- }
2
+ "name": "@keyv/sqlite",
3
+ "version": "4.0.2",
4
+ "description": "SQLite storage adapter for Keyv",
5
+ "type": "module",
6
+ "main": "dist/index.cjs",
7
+ "module": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "require": "./dist/index.cjs",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "xo": {
16
+ "rules": {
17
+ "import/no-named-as-default": "off",
18
+ "unicorn/prefer-module": "off",
19
+ "n/file-extension-in-import": "off",
20
+ "unicorn/prefer-event-target": "off",
21
+ "unicorn/prefer-node-protocol": "off",
22
+ "promise/prefer-await-to-then": "off",
23
+ "@typescript-eslint/use-unknown-in-catch-callback-variable": "off",
24
+ "import/extensions": "off",
25
+ "@typescript-eslint/no-unsafe-argument": "off",
26
+ "@typescript-eslint/no-unsafe-assignment": "off",
27
+ "@typescript-eslint/no-unsafe-call": "off",
28
+ "@typescript-eslint/no-unsafe-return": "off",
29
+ "import/no-extraneous-dependencies": "off",
30
+ "unicorn/prevent-abbreviations": "off"
31
+ }
32
+ },
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/jaredwray/keyv.git"
36
+ },
37
+ "keywords": [
38
+ "sqlite",
39
+ "sql",
40
+ "keyv",
41
+ "storage",
42
+ "adapter",
43
+ "key",
44
+ "value",
45
+ "store",
46
+ "cache",
47
+ "ttl"
48
+ ],
49
+ "author": "Jared Wray <me@jaredwray.com> (http://jaredwray.com)",
50
+ "license": "MIT",
51
+ "bugs": {
52
+ "url": "https://github.com/jaredwray/keyv/issues"
53
+ },
54
+ "homepage": "https://github.com/jaredwray/keyv",
55
+ "dependencies": {
56
+ "sqlite3": "^5.1.7",
57
+ "keyv": "^5.3.2"
58
+ },
59
+ "devDependencies": {
60
+ "rimraf": "^6.0.1",
61
+ "tsd": "^0.31.2",
62
+ "xo": "^0.60.0",
63
+ "@keyv/test-suite": "^2.0.5"
64
+ },
65
+ "tsd": {
66
+ "directory": "test"
67
+ },
68
+ "engines": {
69
+ "node": ">= 18"
70
+ },
71
+ "files": [
72
+ "dist",
73
+ "LICENSE"
74
+ ],
75
+ "scripts": {
76
+ "build": "rimraf ./dist && tsup src/index.ts --format cjs,esm --dts --clean",
77
+ "test": "xo --fix && vitest run --coverage",
78
+ "test:ci": "xo && vitest --run --sequence.setupFiles=list",
79
+ "clean": "rimraf ./node_modules ./coverage ./test/testdb.sqlite ./dist"
80
+ }
81
+ }