@keyv/sqlite 4.0.0 → 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 ADDED
@@ -0,0 +1,168 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ KeyvSqlite: () => KeyvSqlite,
34
+ createKeyv: () => createKeyv,
35
+ default: () => index_default
36
+ });
37
+ module.exports = __toCommonJS(index_exports);
38
+ var import_events = __toESM(require("events"), 1);
39
+ var import_util = require("util");
40
+ var import_keyv = __toESM(require("keyv"), 1);
41
+ var import_sqlite3 = __toESM(require("sqlite3"), 1);
42
+ var toString = (input) => String(input).search(/^[a-zA-Z]+$/) < 0 ? "_" + input : input;
43
+ var KeyvSqlite = class extends import_events.default {
44
+ ttlSupport;
45
+ opts;
46
+ namespace;
47
+ close;
48
+ query;
49
+ constructor(keyvOptions) {
50
+ super();
51
+ this.ttlSupport = false;
52
+ let options = {
53
+ dialect: "sqlite",
54
+ uri: "sqlite://:memory:"
55
+ };
56
+ if (typeof keyvOptions === "string") {
57
+ options.uri = keyvOptions;
58
+ } else {
59
+ options = {
60
+ ...options,
61
+ ...keyvOptions
62
+ };
63
+ }
64
+ options.db = options.uri.replace(/^sqlite:\/\//, "");
65
+ options.connect = async () => new Promise((resolve, reject) => {
66
+ const database = new import_sqlite3.default.Database(options.db, (error) => {
67
+ if (error) {
68
+ reject(error);
69
+ } else {
70
+ if (options.busyTimeout) {
71
+ database.configure("busyTimeout", options.busyTimeout);
72
+ }
73
+ resolve(database);
74
+ }
75
+ });
76
+ }).then((database) => ({ query: (0, import_util.promisify)(database.all).bind(database), close: (0, import_util.promisify)(database.close).bind(database) }));
77
+ this.opts = {
78
+ table: "keyv",
79
+ keySize: 255,
80
+ ...options
81
+ };
82
+ this.opts.table = toString(this.opts.table);
83
+ const createTable = `CREATE TABLE IF NOT EXISTS ${this.opts.table}(key VARCHAR(${Number(this.opts.keySize)}) PRIMARY KEY, value TEXT )`;
84
+ const connected = this.opts.connect().then(async (database) => database.query(createTable).then(() => database)).catch((error) => this.emit("error", error));
85
+ this.query = async (sqlString, ...parameter) => connected.then(async (database) => database.query(sqlString, ...parameter));
86
+ this.close = async () => connected.then((database) => database.close);
87
+ }
88
+ async get(key) {
89
+ const select = `SELECT * FROM ${this.opts.table} WHERE key = ?`;
90
+ const rows = await this.query(select, key);
91
+ const row = rows[0];
92
+ if (row === void 0) {
93
+ return void 0;
94
+ }
95
+ return row.value;
96
+ }
97
+ async getMany(keys) {
98
+ const select = `SELECT * FROM ${this.opts.table} WHERE key IN (SELECT value FROM json_each(?))`;
99
+ const rows = await this.query(select, JSON.stringify(keys));
100
+ return keys.map((key) => {
101
+ const row = rows.find((row2) => row2.key === key);
102
+ return row ? row.value : void 0;
103
+ });
104
+ }
105
+ async set(key, value) {
106
+ const upsert = `INSERT INTO ${this.opts.table} (key, value)
107
+ VALUES(?, ?)
108
+ ON CONFLICT(key)
109
+ DO UPDATE SET value=excluded.value;`;
110
+ return this.query(upsert, key, value);
111
+ }
112
+ async delete(key) {
113
+ const select = `SELECT * FROM ${this.opts.table} WHERE key = ?`;
114
+ const del = `DELETE FROM ${this.opts.table} WHERE key = ?`;
115
+ const rows = await this.query(select, key);
116
+ const row = rows[0];
117
+ if (row === void 0) {
118
+ return false;
119
+ }
120
+ await this.query(del, key);
121
+ return true;
122
+ }
123
+ async deleteMany(keys) {
124
+ const del = `DELETE FROM ${this.opts.table} WHERE key IN (SELECT value FROM json_each(?))`;
125
+ const results = await this.getMany(keys);
126
+ if (results.every((x) => x === void 0)) {
127
+ return false;
128
+ }
129
+ await this.query(del, JSON.stringify(keys));
130
+ return true;
131
+ }
132
+ async clear() {
133
+ const del = `DELETE FROM ${this.opts.table} WHERE key LIKE ?`;
134
+ await this.query(del, this.namespace ? `${this.namespace}:%` : "%");
135
+ }
136
+ async *iterator(namespace) {
137
+ const limit = Number.parseInt(this.opts.iterationLimit, 10) || 10;
138
+ async function* iterate(offset, options, query) {
139
+ const select = `SELECT * FROM ${options.table} WHERE key LIKE ? LIMIT ? OFFSET ?`;
140
+ const iterator = await query(select, [`${namespace ? namespace + ":" : ""}%`, limit, offset]);
141
+ const entries = [...iterator];
142
+ if (entries.length === 0) {
143
+ return;
144
+ }
145
+ for (const entry of entries) {
146
+ offset += 1;
147
+ yield [entry.key, entry.value];
148
+ }
149
+ yield* iterate(offset, options, query);
150
+ }
151
+ yield* iterate(0, this.opts, this.query);
152
+ }
153
+ async has(key) {
154
+ const exists = `SELECT EXISTS ( SELECT * FROM ${this.opts.table} WHERE key = ? )`;
155
+ const result = await this.query(exists, key);
156
+ return Object.values(result[0])[0] === 1;
157
+ }
158
+ async disconnect() {
159
+ await this.close();
160
+ }
161
+ };
162
+ var createKeyv = (keyvOptions) => new import_keyv.default({ store: new KeyvSqlite(keyvOptions) });
163
+ var index_default = KeyvSqlite;
164
+ // Annotate the CommonJS export names for ESM import in node:
165
+ 0 && (module.exports = {
166
+ KeyvSqlite,
167
+ createKeyv
168
+ });
@@ -1,6 +1,22 @@
1
1
  import EventEmitter from 'events';
2
- import { type KeyvStoreAdapter, type StoredData } from 'keyv';
3
- import { type DbClose, type DbQuery, type KeyvSqliteOptions } from './types';
2
+ import Keyv, { KeyvStoreAdapter, StoredData } from 'keyv';
3
+
4
+ type DbQuery = (sqlString: string, ...parameter: unknown[]) => Promise<any>;
5
+ type DbClose = () => Promise<void>;
6
+ type KeyvSqliteOptions = {
7
+ dialect?: string;
8
+ uri?: string;
9
+ busyTimeout?: number;
10
+ table?: string;
11
+ keySize?: number;
12
+ db?: string;
13
+ iterationLimit?: number | string;
14
+ connect?: () => Promise<{
15
+ query: DbQuery;
16
+ close: DbClose;
17
+ }>;
18
+ };
19
+
4
20
  declare class KeyvSqlite extends EventEmitter implements KeyvStoreAdapter {
5
21
  ttlSupport: boolean;
6
22
  opts: KeyvSqliteOptions;
@@ -18,4 +34,6 @@ declare class KeyvSqlite extends EventEmitter implements KeyvStoreAdapter {
18
34
  has(key: string): Promise<boolean>;
19
35
  disconnect(): Promise<void>;
20
36
  }
21
- export default KeyvSqlite;
37
+ declare const createKeyv: (keyvOptions?: KeyvSqliteOptions | string) => Keyv<any>;
38
+
39
+ export { KeyvSqlite, type KeyvSqliteOptions, createKeyv, KeyvSqlite as default };
@@ -1,6 +1,22 @@
1
1
  import EventEmitter from 'events';
2
- import { type KeyvStoreAdapter, type StoredData } from 'keyv';
3
- import { type DbClose, type DbQuery, type KeyvSqliteOptions } from './types';
2
+ import Keyv, { KeyvStoreAdapter, StoredData } from 'keyv';
3
+
4
+ type DbQuery = (sqlString: string, ...parameter: unknown[]) => Promise<any>;
5
+ type DbClose = () => Promise<void>;
6
+ type KeyvSqliteOptions = {
7
+ dialect?: string;
8
+ uri?: string;
9
+ busyTimeout?: number;
10
+ table?: string;
11
+ keySize?: number;
12
+ db?: string;
13
+ iterationLimit?: number | string;
14
+ connect?: () => Promise<{
15
+ query: DbQuery;
16
+ close: DbClose;
17
+ }>;
18
+ };
19
+
4
20
  declare class KeyvSqlite extends EventEmitter implements KeyvStoreAdapter {
5
21
  ttlSupport: boolean;
6
22
  opts: KeyvSqliteOptions;
@@ -18,4 +34,6 @@ declare class KeyvSqlite extends EventEmitter implements KeyvStoreAdapter {
18
34
  has(key: string): Promise<boolean>;
19
35
  disconnect(): Promise<void>;
20
36
  }
21
- export default KeyvSqlite;
37
+ declare const createKeyv: (keyvOptions?: KeyvSqliteOptions | string) => Keyv<any>;
38
+
39
+ export { KeyvSqlite, type KeyvSqliteOptions, createKeyv, KeyvSqlite as default };
package/dist/index.js ADDED
@@ -0,0 +1,132 @@
1
+ // src/index.ts
2
+ import EventEmitter from "events";
3
+ import { promisify } from "util";
4
+ import Keyv from "keyv";
5
+ import sqlite3 from "sqlite3";
6
+ var toString = (input) => String(input).search(/^[a-zA-Z]+$/) < 0 ? "_" + input : input;
7
+ var KeyvSqlite = class extends EventEmitter {
8
+ ttlSupport;
9
+ opts;
10
+ namespace;
11
+ close;
12
+ query;
13
+ constructor(keyvOptions) {
14
+ super();
15
+ this.ttlSupport = false;
16
+ let options = {
17
+ dialect: "sqlite",
18
+ uri: "sqlite://:memory:"
19
+ };
20
+ if (typeof keyvOptions === "string") {
21
+ options.uri = keyvOptions;
22
+ } else {
23
+ options = {
24
+ ...options,
25
+ ...keyvOptions
26
+ };
27
+ }
28
+ options.db = options.uri.replace(/^sqlite:\/\//, "");
29
+ options.connect = async () => new Promise((resolve, reject) => {
30
+ const database = new sqlite3.Database(options.db, (error) => {
31
+ if (error) {
32
+ reject(error);
33
+ } else {
34
+ if (options.busyTimeout) {
35
+ database.configure("busyTimeout", options.busyTimeout);
36
+ }
37
+ resolve(database);
38
+ }
39
+ });
40
+ }).then((database) => ({ query: promisify(database.all).bind(database), close: promisify(database.close).bind(database) }));
41
+ this.opts = {
42
+ table: "keyv",
43
+ keySize: 255,
44
+ ...options
45
+ };
46
+ this.opts.table = toString(this.opts.table);
47
+ const createTable = `CREATE TABLE IF NOT EXISTS ${this.opts.table}(key VARCHAR(${Number(this.opts.keySize)}) PRIMARY KEY, value TEXT )`;
48
+ const connected = this.opts.connect().then(async (database) => database.query(createTable).then(() => database)).catch((error) => this.emit("error", error));
49
+ this.query = async (sqlString, ...parameter) => connected.then(async (database) => database.query(sqlString, ...parameter));
50
+ this.close = async () => connected.then((database) => database.close);
51
+ }
52
+ async get(key) {
53
+ const select = `SELECT * FROM ${this.opts.table} WHERE key = ?`;
54
+ const rows = await this.query(select, key);
55
+ const row = rows[0];
56
+ if (row === void 0) {
57
+ return void 0;
58
+ }
59
+ return row.value;
60
+ }
61
+ async getMany(keys) {
62
+ const select = `SELECT * FROM ${this.opts.table} WHERE key IN (SELECT value FROM json_each(?))`;
63
+ const rows = await this.query(select, JSON.stringify(keys));
64
+ return keys.map((key) => {
65
+ const row = rows.find((row2) => row2.key === key);
66
+ return row ? row.value : void 0;
67
+ });
68
+ }
69
+ async set(key, value) {
70
+ const upsert = `INSERT INTO ${this.opts.table} (key, value)
71
+ VALUES(?, ?)
72
+ ON CONFLICT(key)
73
+ DO UPDATE SET value=excluded.value;`;
74
+ return this.query(upsert, key, value);
75
+ }
76
+ async delete(key) {
77
+ const select = `SELECT * FROM ${this.opts.table} WHERE key = ?`;
78
+ const del = `DELETE FROM ${this.opts.table} WHERE key = ?`;
79
+ const rows = await this.query(select, key);
80
+ const row = rows[0];
81
+ if (row === void 0) {
82
+ return false;
83
+ }
84
+ await this.query(del, key);
85
+ return true;
86
+ }
87
+ async deleteMany(keys) {
88
+ const del = `DELETE FROM ${this.opts.table} WHERE key IN (SELECT value FROM json_each(?))`;
89
+ const results = await this.getMany(keys);
90
+ if (results.every((x) => x === void 0)) {
91
+ return false;
92
+ }
93
+ await this.query(del, JSON.stringify(keys));
94
+ return true;
95
+ }
96
+ async clear() {
97
+ const del = `DELETE FROM ${this.opts.table} WHERE key LIKE ?`;
98
+ await this.query(del, this.namespace ? `${this.namespace}:%` : "%");
99
+ }
100
+ async *iterator(namespace) {
101
+ const limit = Number.parseInt(this.opts.iterationLimit, 10) || 10;
102
+ async function* iterate(offset, options, query) {
103
+ const select = `SELECT * FROM ${options.table} WHERE key LIKE ? LIMIT ? OFFSET ?`;
104
+ const iterator = await query(select, [`${namespace ? namespace + ":" : ""}%`, limit, offset]);
105
+ const entries = [...iterator];
106
+ if (entries.length === 0) {
107
+ return;
108
+ }
109
+ for (const entry of entries) {
110
+ offset += 1;
111
+ yield [entry.key, entry.value];
112
+ }
113
+ yield* iterate(offset, options, query);
114
+ }
115
+ yield* iterate(0, this.opts, this.query);
116
+ }
117
+ async has(key) {
118
+ const exists = `SELECT EXISTS ( SELECT * FROM ${this.opts.table} WHERE key = ? )`;
119
+ const result = await this.query(exists, key);
120
+ return Object.values(result[0])[0] === 1;
121
+ }
122
+ async disconnect() {
123
+ await this.close();
124
+ }
125
+ };
126
+ var createKeyv = (keyvOptions) => new Keyv({ store: new KeyvSqlite(keyvOptions) });
127
+ var index_default = KeyvSqlite;
128
+ export {
129
+ KeyvSqlite,
130
+ createKeyv,
131
+ index_default as default
132
+ };
package/package.json CHANGED
@@ -1,79 +1,81 @@
1
1
  {
2
- "name": "@keyv/sqlite",
3
- "version": "4.0.0",
4
- "description": "SQLite storage adapter for Keyv",
5
- "main": "dist/cjs/index.js",
6
- "module": "dist/esm/index.js",
7
- "types": "dist/esm/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "require": "./dist/cjs/index.js",
11
- "import": "./dist/esm/index.js"
12
- }
13
- },
14
- "scripts": {
15
- "build": "rm -rf dist && tsc --project tsconfig.cjs.json && tsc --project tsconfig.esm.json",
16
- "prepare": "yarn build",
17
- "test": "xo --fix && vitest run --coverage",
18
- "test:ci": "xo && vitest --run --sequence.setupFiles=list",
19
- "clean": "rm -rf node_modules && rm -rf ./coverage && rm -rf ./test/testdb.sqlite"
20
- },
21
- "xo": {
22
- "rules": {
23
- "unicorn/prefer-module": "off",
24
- "n/file-extension-in-import": "off",
25
- "unicorn/prefer-event-target": "off",
26
- "unicorn/prefer-node-protocol": "off",
27
- "promise/prefer-await-to-then": "off",
28
- "@typescript-eslint/use-unknown-in-catch-callback-variable": "off",
29
- "import/extensions": "off",
30
- "@typescript-eslint/no-unsafe-argument": "off",
31
- "@typescript-eslint/no-unsafe-assignment": "off",
32
- "@typescript-eslint/no-unsafe-call": "off",
33
- "@typescript-eslint/no-unsafe-return": "off",
34
- "import/no-extraneous-dependencies": "off",
35
- "unicorn/prevent-abbreviations": "off"
36
- }
37
- },
38
- "repository": {
39
- "type": "git",
40
- "url": "git+https://github.com/jaredwray/keyv.git"
41
- },
42
- "keywords": [
43
- "sqlite",
44
- "sql",
45
- "keyv",
46
- "storage",
47
- "adapter",
48
- "key",
49
- "value",
50
- "store",
51
- "cache",
52
- "ttl"
53
- ],
54
- "author": "Jared Wray <me@jaredwray.com> (http://jaredwray.com)",
55
- "license": "MIT",
56
- "bugs": {
57
- "url": "https://github.com/jaredwray/keyv/issues"
58
- },
59
- "homepage": "https://github.com/jaredwray/keyv",
60
- "dependencies": {
61
- "sqlite3": "^5.1.7"
62
- },
63
- "devDependencies": {
64
- "@keyv/test-suite": "*",
65
- "keyv": "^5.0.0",
66
- "tsd": "^0.31.1",
67
- "xo": "^0.59.3"
68
- },
69
- "tsd": {
70
- "directory": "test"
71
- },
72
- "engines": {
73
- "node": ">= 18"
74
- },
75
- "files": [
76
- "dist",
77
- "LICENSE"
78
- ]
79
- }
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
+ }
package/dist/cjs/index.js DELETED
@@ -1,141 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const events_1 = __importDefault(require("events"));
7
- const util_1 = require("util");
8
- const sqlite3_1 = __importDefault(require("sqlite3"));
9
- const toString = (input) => String(input).search(/^[a-zA-Z]+$/) < 0 ? '_' + input : input;
10
- class KeyvSqlite extends events_1.default {
11
- ttlSupport;
12
- opts;
13
- namespace;
14
- close;
15
- query;
16
- constructor(keyvOptions) {
17
- super();
18
- this.ttlSupport = false;
19
- let options = {
20
- dialect: 'sqlite',
21
- uri: 'sqlite://:memory:',
22
- };
23
- if (typeof keyvOptions === 'string') {
24
- options.uri = keyvOptions;
25
- }
26
- else {
27
- options = {
28
- ...options,
29
- ...keyvOptions,
30
- };
31
- }
32
- options.db = options.uri.replace(/^sqlite:\/\//, '');
33
- options.connect = async () => new Promise((resolve, reject) => {
34
- const database = new sqlite3_1.default.Database(options.db, error => {
35
- /* c8 ignore next 2 */
36
- if (error) {
37
- reject(error);
38
- }
39
- else {
40
- if (options.busyTimeout) {
41
- database.configure('busyTimeout', options.busyTimeout);
42
- }
43
- resolve(database);
44
- }
45
- });
46
- })
47
- // @ts-expect-error - db is unknown
48
- .then(database => ({ query: (0, util_1.promisify)(database.all).bind(database), close: (0, util_1.promisify)(database.close).bind(database) }));
49
- this.opts = {
50
- table: 'keyv',
51
- keySize: 255,
52
- ...options,
53
- };
54
- this.opts.table = toString(this.opts.table);
55
- const createTable = `CREATE TABLE IF NOT EXISTS ${this.opts.table}(key VARCHAR(${Number(this.opts.keySize)}) PRIMARY KEY, value TEXT )`;
56
- // @ts-expect-error - db is
57
- const connected = this.opts.connect()
58
- .then(async (database) => database.query(createTable).then(() => database))
59
- .catch(error => this.emit('error', error));
60
- this.query = async (sqlString, ...parameter) => connected
61
- .then(async (database) => database.query(sqlString, ...parameter));
62
- this.close = async () => connected.then(database => database.close);
63
- }
64
- async get(key) {
65
- const select = `SELECT * FROM ${this.opts.table} WHERE key = ?`;
66
- const rows = await this.query(select, key);
67
- const row = rows[0];
68
- if (row === undefined) {
69
- return undefined;
70
- }
71
- return row.value;
72
- }
73
- async getMany(keys) {
74
- const select = `SELECT * FROM ${this.opts.table} WHERE key IN (SELECT value FROM json_each(?))`;
75
- const rows = await this.query(select, JSON.stringify(keys));
76
- return keys.map(key => {
77
- const row = rows.find((row) => row.key === key);
78
- return (row ? row.value : undefined);
79
- });
80
- }
81
- async set(key, value) {
82
- const upsert = `INSERT INTO ${this.opts.table} (key, value)
83
- VALUES(?, ?)
84
- ON CONFLICT(key)
85
- DO UPDATE SET value=excluded.value;`;
86
- return this.query(upsert, key, value);
87
- }
88
- async delete(key) {
89
- const select = `SELECT * FROM ${this.opts.table} WHERE key = ?`;
90
- const del = `DELETE FROM ${this.opts.table} WHERE key = ?`;
91
- const rows = await this.query(select, key);
92
- const row = rows[0];
93
- if (row === undefined) {
94
- return false;
95
- }
96
- await this.query(del, key);
97
- return true;
98
- }
99
- async deleteMany(keys) {
100
- const del = `DELETE FROM ${this.opts.table} WHERE key IN (SELECT value FROM json_each(?))`;
101
- const results = await this.getMany(keys);
102
- if (results.every(x => x === undefined)) {
103
- return false;
104
- }
105
- await this.query(del, JSON.stringify(keys));
106
- return true;
107
- }
108
- async clear() {
109
- const del = `DELETE FROM ${this.opts.table} WHERE key LIKE ?`;
110
- await this.query(del, this.namespace ? `${this.namespace}:%` : '%');
111
- }
112
- async *iterator(namespace) {
113
- const limit = Number.parseInt(this.opts.iterationLimit, 10) || 10;
114
- // @ts-expect-error - iterate
115
- async function* iterate(offset, options, query) {
116
- const select = `SELECT * FROM ${options.table} WHERE key LIKE ? LIMIT ? OFFSET ?`;
117
- const iterator = await query(select, [`${namespace ? namespace + ':' : ''}%`, limit, offset]);
118
- const entries = [...iterator];
119
- if (entries.length === 0) {
120
- return;
121
- }
122
- for (const entry of entries) {
123
- offset += 1;
124
- yield [entry.key, entry.value];
125
- }
126
- yield* iterate(offset, options, query);
127
- }
128
- yield* iterate(0, this.opts, this.query);
129
- }
130
- async has(key) {
131
- const exists = `SELECT EXISTS ( SELECT * FROM ${this.opts.table} WHERE key = ? )`;
132
- const result = await this.query(exists, key);
133
- return Object.values(result[0])[0] === 1;
134
- }
135
- async disconnect() {
136
- await this.close();
137
- }
138
- }
139
- exports.default = KeyvSqlite;
140
- module.exports = KeyvSqlite;
141
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;AAAA,oDAAkC;AAClC,+BAA+B;AAC/B,sDAA8B;AAM9B,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;AAElG,MAAM,UAAW,SAAQ,gBAAY;IACpC,UAAU,CAAU;IACpB,IAAI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UAAU,CAAC"}
@@ -1,19 +0,0 @@
1
- export type DbQuery = (sqlString: string, ...parameter: unknown[]) => Promise<any>;
2
- export type DbClose = () => Promise<void>;
3
- export type KeyvSqliteOptions = {
4
- dialect?: string;
5
- uri?: string;
6
- busyTimeout?: number;
7
- table?: string;
8
- keySize?: number;
9
- db?: string;
10
- iterationLimit?: number | string;
11
- connect?: () => Promise<{
12
- query: DbQuery;
13
- close: DbClose;
14
- }>;
15
- };
16
- export type Db = {
17
- query: DbQuery;
18
- close: DbClose;
19
- };
package/dist/cjs/types.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
package/dist/esm/index.js DELETED
@@ -1,136 +0,0 @@
1
- import EventEmitter from 'events';
2
- import { promisify } from 'util';
3
- import sqlite3 from 'sqlite3';
4
- const toString = (input) => String(input).search(/^[a-zA-Z]+$/) < 0 ? '_' + input : input;
5
- class KeyvSqlite extends EventEmitter {
6
- ttlSupport;
7
- opts;
8
- namespace;
9
- close;
10
- query;
11
- constructor(keyvOptions) {
12
- super();
13
- this.ttlSupport = false;
14
- let options = {
15
- dialect: 'sqlite',
16
- uri: 'sqlite://:memory:',
17
- };
18
- if (typeof keyvOptions === 'string') {
19
- options.uri = keyvOptions;
20
- }
21
- else {
22
- options = {
23
- ...options,
24
- ...keyvOptions,
25
- };
26
- }
27
- options.db = options.uri.replace(/^sqlite:\/\//, '');
28
- options.connect = async () => new Promise((resolve, reject) => {
29
- const database = new sqlite3.Database(options.db, error => {
30
- /* c8 ignore next 2 */
31
- if (error) {
32
- reject(error);
33
- }
34
- else {
35
- if (options.busyTimeout) {
36
- database.configure('busyTimeout', options.busyTimeout);
37
- }
38
- resolve(database);
39
- }
40
- });
41
- })
42
- // @ts-expect-error - db is unknown
43
- .then(database => ({ query: promisify(database.all).bind(database), close: promisify(database.close).bind(database) }));
44
- this.opts = {
45
- table: 'keyv',
46
- keySize: 255,
47
- ...options,
48
- };
49
- this.opts.table = toString(this.opts.table);
50
- const createTable = `CREATE TABLE IF NOT EXISTS ${this.opts.table}(key VARCHAR(${Number(this.opts.keySize)}) PRIMARY KEY, value TEXT )`;
51
- // @ts-expect-error - db is
52
- const connected = this.opts.connect()
53
- .then(async (database) => database.query(createTable).then(() => database))
54
- .catch(error => this.emit('error', error));
55
- this.query = async (sqlString, ...parameter) => connected
56
- .then(async (database) => database.query(sqlString, ...parameter));
57
- this.close = async () => connected.then(database => database.close);
58
- }
59
- async get(key) {
60
- const select = `SELECT * FROM ${this.opts.table} WHERE key = ?`;
61
- const rows = await this.query(select, key);
62
- const row = rows[0];
63
- if (row === undefined) {
64
- return undefined;
65
- }
66
- return row.value;
67
- }
68
- async getMany(keys) {
69
- const select = `SELECT * FROM ${this.opts.table} WHERE key IN (SELECT value FROM json_each(?))`;
70
- const rows = await this.query(select, JSON.stringify(keys));
71
- return keys.map(key => {
72
- const row = rows.find((row) => row.key === key);
73
- return (row ? row.value : undefined);
74
- });
75
- }
76
- async set(key, value) {
77
- const upsert = `INSERT INTO ${this.opts.table} (key, value)
78
- VALUES(?, ?)
79
- ON CONFLICT(key)
80
- DO UPDATE SET value=excluded.value;`;
81
- return this.query(upsert, key, value);
82
- }
83
- async delete(key) {
84
- const select = `SELECT * FROM ${this.opts.table} WHERE key = ?`;
85
- const del = `DELETE FROM ${this.opts.table} WHERE key = ?`;
86
- const rows = await this.query(select, key);
87
- const row = rows[0];
88
- if (row === undefined) {
89
- return false;
90
- }
91
- await this.query(del, key);
92
- return true;
93
- }
94
- async deleteMany(keys) {
95
- const del = `DELETE FROM ${this.opts.table} WHERE key IN (SELECT value FROM json_each(?))`;
96
- const results = await this.getMany(keys);
97
- if (results.every(x => x === undefined)) {
98
- return false;
99
- }
100
- await this.query(del, JSON.stringify(keys));
101
- return true;
102
- }
103
- async clear() {
104
- const del = `DELETE FROM ${this.opts.table} WHERE key LIKE ?`;
105
- await this.query(del, this.namespace ? `${this.namespace}:%` : '%');
106
- }
107
- async *iterator(namespace) {
108
- const limit = Number.parseInt(this.opts.iterationLimit, 10) || 10;
109
- // @ts-expect-error - iterate
110
- async function* iterate(offset, options, query) {
111
- const select = `SELECT * FROM ${options.table} WHERE key LIKE ? LIMIT ? OFFSET ?`;
112
- const iterator = await query(select, [`${namespace ? namespace + ':' : ''}%`, limit, offset]);
113
- const entries = [...iterator];
114
- if (entries.length === 0) {
115
- return;
116
- }
117
- for (const entry of entries) {
118
- offset += 1;
119
- yield [entry.key, entry.value];
120
- }
121
- yield* iterate(offset, options, query);
122
- }
123
- yield* iterate(0, this.opts, this.query);
124
- }
125
- async has(key) {
126
- const exists = `SELECT EXISTS ( SELECT * FROM ${this.opts.table} WHERE key = ? )`;
127
- const result = await this.query(exists, key);
128
- return Object.values(result[0])[0] === 1;
129
- }
130
- async disconnect() {
131
- await this.close();
132
- }
133
- }
134
- export default KeyvSqlite;
135
- module.exports = KeyvSqlite;
136
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAC,SAAS,EAAC,MAAM,MAAM,CAAC;AAC/B,OAAO,OAAO,MAAM,SAAS,CAAC;AAM9B,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;AAElG,MAAM,UAAW,SAAQ,YAAY;IACpC,UAAU,CAAU;IACpB,IAAI,CAAoB;IACxB,SAAS,CAAU;IACnB,KAAK,CAAU;IACf,KAAK,CAAU;IAEf,YAAY,WAAwC;QACnD,KAAK,E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type KeyvSqliteOptions = {
4
- dialect?: string;
5
- uri?: string;
6
- busyTimeout?: number;
7
- table?: string;
8
- keySize?: number;
9
- db?: string;
10
- iterationLimit?: number | string;
11
- connect?: () => Promise<{
12
- query: DbQuery;
13
- close: DbClose;
14
- }>;
15
- };
16
- export type Db = {
17
- query: DbQuery;
18
- close: DbClose;
19
- };
package/dist/esm/types.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}