taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 6bb967f159cc968befb7452310b4201c0ffa5348
parent 8e11ead343d7707d3a050f926f9301c01119560b
Author: Florian Dold <florian@dold.me>
Date:   Thu, 19 Dec 2024 21:03:03 +0100

get rid of better-sqlite3 dependency

Diffstat:
Mpackages/idb-bridge/package.json | 6+++---
Mpackages/idb-bridge/src/SqliteBackend.test.ts | 6+++---
Mpackages/idb-bridge/src/bench.ts | 4++--
Mpackages/idb-bridge/src/index.ts | 3---
Dpackages/idb-bridge/src/node-better-sqlite3-impl.ts | 85-------------------------------------------------------------------------------
Mpackages/taler-wallet-cli/build-qtart.mjs | 2+-
Mpackages/taler-wallet-core/src/host-impl.node.ts | 4+++-
Mpackages/taler-wallet-embedded/build.mjs | 2+-
Mpackages/web-util/build.mjs | 4++--
Mpnpm-lock.yaml | 121-------------------------------------------------------------------------------
10 files changed, 15 insertions(+), 222 deletions(-)

diff --git a/packages/idb-bridge/package.json b/packages/idb-bridge/package.json @@ -19,6 +19,9 @@ "exports": { ".": { "default": "./lib/index.js" + }, + "./node-helper-sqlite3-impl": { + "default": "./lib/node-helper-sqlite3-impl.js" } }, "devDependencies": { @@ -33,8 +36,5 @@ }, "ava": { "failFast": true - }, - "optionalDependencies": { - "better-sqlite3": "11.7.0" } } diff --git a/packages/idb-bridge/src/SqliteBackend.test.ts b/packages/idb-bridge/src/SqliteBackend.test.ts @@ -15,11 +15,11 @@ */ import test from "ava"; +import * as fs from "node:fs"; import { createSqliteBackend } from "./SqliteBackend.js"; import { ResultLevel, StoreLevel } from "./backend-interface.js"; import { BridgeIDBKeyRange } from "./bridge-idb.js"; -import * as fs from "node:fs"; -import { createNodeBetterSqlite3Impl } from "./node-better-sqlite3-impl.js"; +import { createNodeHelperSqlite3Impl } from "./node-helper-sqlite3-impl.js"; test("sqlite3 backend", async (t) => { const filename = "mytestdb.sqlite3"; @@ -29,7 +29,7 @@ test("sqlite3 backend", async (t) => { // Do nothing. } try { - const sqlite3Impl = await createNodeBetterSqlite3Impl(); + const sqlite3Impl = await createNodeHelperSqlite3Impl(); const backend = await createSqliteBackend(sqlite3Impl, { filename, }); diff --git a/packages/idb-bridge/src/bench.ts b/packages/idb-bridge/src/bench.ts @@ -22,7 +22,7 @@ import { BridgeIDBTransaction, createSqliteBackend, } from "./index.js"; -import { createNodeBetterSqlite3Impl } from "./node-better-sqlite3-impl.js"; +import { createNodeHelperSqlite3Impl } from "./node-helper-sqlite3-impl.js"; function openDb(idbFactory: BridgeIDBFactory): Promise<BridgeIDBDatabase> { return new Promise((resolve, reject) => { @@ -82,7 +82,7 @@ async function main() { console.log(`doing ${nTx} iterations of ${nInsert} items`); - const sqlite3Impl = await createNodeBetterSqlite3Impl(); + const sqlite3Impl = await createNodeHelperSqlite3Impl(); const backend = await createSqliteBackend(sqlite3Impl, { filename, }); diff --git a/packages/idb-bridge/src/index.ts b/packages/idb-bridge/src/index.ts @@ -119,6 +119,3 @@ export function shimIndexedDB(factory: BridgeIDBFactory): void { g.IDBTransaction = BridgeIDBTransaction; g.IDBVersionChangeEvent = BridgeIDBVersionChangeEvent; } - -export { createNodeBetterSqlite3Impl } from "./node-better-sqlite3-impl.js"; -export { createNodeHelperSqlite3Impl } from "./node-helper-sqlite3-impl.js"; diff --git a/packages/idb-bridge/src/node-better-sqlite3-impl.ts b/packages/idb-bridge/src/node-better-sqlite3-impl.ts @@ -1,85 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2023 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -// @ts-ignore: optional dependency -import type Database from "better-sqlite3"; -import { - ResultRow, - Sqlite3Database, - Sqlite3Interface, - Sqlite3Statement, -} from "./sqlite3-interface.js"; - -export async function createNodeBetterSqlite3Impl(): Promise<Sqlite3Interface> { - // @ts-ignore: optional dependency - const bsq = (await import("better-sqlite3")).default; - - return { - async open(filename: string): Promise<Sqlite3Database> { - const internalDbHandle = bsq(filename); - return { - internalDbHandle, - async close() { - internalDbHandle.close(); - }, - async prepare(stmtStr): Promise<Sqlite3Statement> { - const stmtHandle = internalDbHandle.prepare(stmtStr); - return { - internalStatement: stmtHandle, - async getAll(params): Promise<ResultRow[]> { - let res: ResultRow[]; - if (params === undefined) { - res = stmtHandle.all() as ResultRow[]; - } else { - res = stmtHandle.all(params) as ResultRow[]; - } - return res; - }, - async getFirst(params): Promise<ResultRow | undefined> { - let res: ResultRow | undefined; - if (params === undefined) { - res = stmtHandle.get() as ResultRow | undefined; - } else { - res = stmtHandle.get(params) as ResultRow | undefined; - } - return res; - }, - async run(params) { - const myParams = []; - if (params !== undefined) { - myParams.push(params); - } - // The better-sqlite3 library doesn't like it we pass - // undefined directly. - let res: Database.RunResult; - if (params !== undefined) { - res = stmtHandle.run(params); - } else { - res = stmtHandle.run(); - } - return { - lastInsertRowid: res.lastInsertRowid, - }; - }, - }; - }, - async exec(sqlStr: string): Promise<void> { - internalDbHandle.exec(sqlStr); - }, - }; - }, - }; -} diff --git a/packages/taler-wallet-cli/build-qtart.mjs b/packages/taler-wallet-cli/build-qtart.mjs @@ -62,7 +62,7 @@ export const buildConfig = { conditions: ["qtart"], sourcemap: true, // quickjs standard library - external: ["std", "os", "better-sqlite3"], + external: ["std", "os", "node:child_process"], define: { __VERSION__: `"${_package.version}"`, __GIT_HASH__: `"${GIT_HASH}"`, diff --git a/packages/taler-wallet-core/src/host-impl.node.ts b/packages/taler-wallet-core/src/host-impl.node.ts @@ -26,11 +26,13 @@ import { BridgeIDBFactory, MemoryBackend, - createNodeHelperSqlite3Impl, createSqliteBackend, shimIndexedDB, } from "@gnu-taler/idb-bridge"; import { + createNodeHelperSqlite3Impl, +} from "@gnu-taler/idb-bridge/node-helper-sqlite3-impl"; +import { Logger, SetTimeoutTimerAPI, WalletRunConfig, diff --git a/packages/taler-wallet-embedded/build.mjs b/packages/taler-wallet-embedded/build.mjs @@ -56,7 +56,7 @@ export const buildConfig = { bundle: true, minify: false, target: ["es2020"], - external: ["os", "std", "better-sqlite3"], + external: ["os", "std", "node:child_process", "node:fs"], format: "esm", platform: "neutral", mainFields: ["module", "main"], diff --git a/packages/web-util/build.mjs b/packages/web-util/build.mjs @@ -126,7 +126,7 @@ const buildConfigBuild = { }, format: "esm", platform: "node", - external: ["esbuild"], + external: ["esbuild", "node:child_process"], // https://github.com/evanw/esbuild/issues/1921 // How to fix "Dynamic require of "os" is not supported" // esbuild cannot convert external "static" commonjs require statements to static esm imports @@ -152,7 +152,7 @@ const buildConfigTesting = { }, format: "esm", platform: "browser", - external: ["preact", "@gnu-taler/taler-util", "jed", "swr", "axios"], + external: ["preact", "@gnu-taler/taler-util", "jed", "swr", "axios", "node:child_process"], jsxFactory: "h", jsxFragment: "Fragment", }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml @@ -510,10 +510,6 @@ importers: tslib: specifier: ^2.6.2 version: 2.6.2 - optionalDependencies: - better-sqlite3: - specifier: 11.7.0 - version: 11.7.0 devDependencies: '@types/better-sqlite3': specifier: ^7.6.8 @@ -3878,9 +3874,6 @@ packages: bcrypt-pbkdf@1.0.2: resolution: {integrity: sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w==} - better-sqlite3@11.7.0: - resolution: {integrity: sha512-mXpa5jnIKKHeoGzBrUJrc65cXFKcILGZpU3FXR0pradUEm9MA7UZz02qfEejaMcm9iXrSOCenwwYMJ/tZ1y5Ig==} - big-integer@1.6.52: resolution: {integrity: sha512-QxD8cf2eVqJOOz63z6JIN9BzvVs/dlySa5HGSBH5xtR8dPteIRQnBxxKqkNTiT6jbDTF6jAfrd4oMcND9RGbQg==} engines: {node: '>=0.6'} @@ -4856,10 +4849,6 @@ packages: resolution: {integrity: sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw==} engines: {node: '>=8'} - detect-libc@2.0.3: - resolution: {integrity: sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==} - engines: {node: '>=8'} - detect-node@2.1.0: resolution: {integrity: sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g==} @@ -5390,10 +5379,6 @@ packages: resolution: {integrity: sha512-w/ozOKR9Obk3qoWeY/WDi6MFta9AoMR+zud60mdnbniMcBxRuFJyDt2LdX/14A1UABeqk+Uk+LDfUpvoGKppZA==} engines: {node: '>=0.10.0'} - expand-template@2.0.3: - resolution: {integrity: sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==} - engines: {node: '>=6'} - express@4.18.2: resolution: {integrity: sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==} engines: {node: '>= 0.10.0'} @@ -5623,9 +5608,6 @@ packages: fromentries@1.3.2: resolution: {integrity: sha512-cHEpEQHUg0f8XdtZCc2ZAhrHzKzT0MrFUTcvx+hfxYu7rGMDc5SKoXFh+n4YigxsHXRzc6OrCshdR1bWH6HHyg==} - fs-constants@1.0.0: - resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==} - fs-extra@11.1.0: resolution: {integrity: sha512-0rcTq621PD5jM/e0a3EJoGC/1TC5ZBCERW82LQuwfGnCa1V8w7dpYH1yNu+SLb6E5dkeCBzKEyLGlFrnr+dUyw==} engines: {node: '>=14.14'} @@ -5755,9 +5737,6 @@ packages: gettext-parser@1.1.0: resolution: {integrity: sha512-zL3eayB0jF+cr6vogH/VJKoKcj7uQj2TPByaaj6a4k/3elk9iq7fiwCM2FqdzS/umo021RetSanVisarzeb9Wg==} - github-from-package@0.0.0: - resolution: {integrity: sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==} - gittar@0.1.1: resolution: {integrity: sha512-p+XuqWJpW9ahUuNTptqeFjudFq31o6Jd+maMBarkMAR5U3K9c7zJB4sQ4BV8mIqrTOV29TtqikDhnZfCD4XNfQ==} engines: {node: '>=4'} @@ -7175,9 +7154,6 @@ packages: resolution: {integrity: sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==} engines: {node: '>=0.10.0'} - mkdirp-classic@0.5.3: - resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==} - mkdirp@0.5.6: resolution: {integrity: sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==} hasBin: true @@ -7273,9 +7249,6 @@ packages: resolution: {integrity: sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==} engines: {node: '>=0.10.0'} - napi-build-utils@1.0.2: - resolution: {integrity: sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==} - native-url@0.3.4: resolution: {integrity: sha512-6iM8R99ze45ivyH8vybJ7X0yekIcPf5GgLV5K0ENCbmRcaRIDoj37BC8iLEmaaBfqqb8enuZ5p0uhY+lVAbAcA==} @@ -7299,10 +7272,6 @@ packages: no-case@3.0.4: resolution: {integrity: sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==} - node-abi@3.62.0: - resolution: {integrity: sha512-CPMcGa+y33xuL1E0TcNIu4YyaZCxnnvkVaEXrsosR3FxN+fV8xvb7Mzpb7IgKler10qeMkE6+Dp8qJhpzdq35g==} - engines: {node: '>=10'} - node-domexception@1.0.0: resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} engines: {node: '>=10.5.0'} @@ -8214,11 +8183,6 @@ packages: preact@10.11.3: resolution: {integrity: sha512-eY93IVpod/zG3uMF22Unl8h9KkrcKIRs2EGar8hwLZZDU1lkjph303V9HZBwufh2s736U6VXuhD109LYqPoffg==} - prebuild-install@7.1.2: - resolution: {integrity: sha512-UnNke3IQb6sgarcZIDU3gbMeTp/9SSU1DAIkil7PrqG1vZlBtY5msYccSKSHDqa3hNg436IXK+SNImReuA1wEQ==} - engines: {node: '>=10'} - hasBin: true - prelude-ls@1.1.2: resolution: {integrity: sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==} engines: {node: '>= 0.8.0'} @@ -8901,12 +8865,6 @@ packages: resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} engines: {node: '>=14'} - simple-concat@1.0.1: - resolution: {integrity: sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==} - - simple-get@4.0.1: - resolution: {integrity: sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==} - simple-swizzle@0.2.2: resolution: {integrity: sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==} @@ -9283,13 +9241,6 @@ packages: resolution: {integrity: sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==} engines: {node: '>=6'} - tar-fs@2.1.1: - resolution: {integrity: sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==} - - tar-stream@2.2.0: - resolution: {integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==} - engines: {node: '>=6'} - tar@4.4.19: resolution: {integrity: sha512-a20gEsvHnWe0ygBY8JbxoM4w3SJdhc7ZAuxkLqh+nvNQN2IOt0B5lLgM490X5Hl8FF0dl0tOf2ewFYAlIFgzVA==} engines: {node: '>=4.5'} @@ -14301,12 +14252,6 @@ snapshots: dependencies: tweetnacl: 0.14.5 - better-sqlite3@11.7.0: - dependencies: - bindings: 1.5.0 - prebuild-install: 7.1.2 - optional: true - big-integer@1.6.52: {} big.js@3.2.0: {} @@ -15539,9 +15484,6 @@ snapshots: detect-libc@2.0.2: {} - detect-libc@2.0.3: - optional: true - detect-node@2.1.0: {} didyoumean@1.2.2: {} @@ -16366,9 +16308,6 @@ snapshots: transitivePeerDependencies: - supports-color - expand-template@2.0.3: - optional: true - express@4.18.2: dependencies: accepts: 1.3.8 @@ -16646,9 +16585,6 @@ snapshots: fromentries@1.3.2: {} - fs-constants@1.0.0: - optional: true - fs-extra@11.1.0: dependencies: graceful-fs: 4.2.11 @@ -16787,9 +16723,6 @@ snapshots: dependencies: encoding: 0.1.13 - github-from-package@0.0.0: - optional: true - gittar@0.1.1: dependencies: mkdirp: 0.5.6 @@ -18224,9 +18157,6 @@ snapshots: for-in: 1.0.2 is-extendable: 1.0.1 - mkdirp-classic@0.5.3: - optional: true - mkdirp@0.5.6: dependencies: minimist: 1.2.8 @@ -18368,9 +18298,6 @@ snapshots: transitivePeerDependencies: - supports-color - napi-build-utils@1.0.2: - optional: true - native-url@0.3.4: dependencies: querystring: 0.2.1 @@ -18393,11 +18320,6 @@ snapshots: lower-case: 2.0.2 tslib: 2.6.2 - node-abi@3.62.0: - dependencies: - semver: 7.6.2 - optional: true - node-domexception@1.0.0: {} node-fetch@2.7.0(encoding@0.1.13): @@ -19515,22 +19437,6 @@ snapshots: preact@10.11.3: {} - prebuild-install@7.1.2: - dependencies: - detect-libc: 2.0.3 - expand-template: 2.0.3 - github-from-package: 0.0.0 - minimist: 1.2.8 - mkdirp-classic: 0.5.3 - napi-build-utils: 1.0.2 - node-abi: 3.62.0 - pump: 3.0.0 - rc: 1.2.8 - simple-get: 4.0.1 - tar-fs: 2.1.1 - tunnel-agent: 0.6.0 - optional: true - prelude-ls@1.1.2: {} prelude-ls@1.2.1: {} @@ -20263,16 +20169,6 @@ snapshots: signal-exit@4.1.0: {} - simple-concat@1.0.1: - optional: true - - simple-get@4.0.1: - dependencies: - decompress-response: 6.0.0 - once: 1.4.0 - simple-concat: 1.0.1 - optional: true - simple-swizzle@0.2.2: dependencies: is-arrayish: 0.3.2 @@ -20774,23 +20670,6 @@ snapshots: tapable@2.2.1: {} - tar-fs@2.1.1: - dependencies: - chownr: 1.1.4 - mkdirp-classic: 0.5.3 - pump: 3.0.0 - tar-stream: 2.2.0 - optional: true - - tar-stream@2.2.0: - dependencies: - bl: 4.1.0 - end-of-stream: 1.4.4 - fs-constants: 1.0.0 - inherits: 2.0.4 - readable-stream: 3.6.2 - optional: true - tar@4.4.19: dependencies: chownr: 1.1.4