recappi 0.1.65 → 0.1.66

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/dist/index.js CHANGED
@@ -18657,7 +18657,7 @@ import os3 from "os";
18657
18657
  import path3 from "path";
18658
18658
  import { createRequire } from "module";
18659
18659
  var require2 = createRequire(import.meta.url);
18660
- var Database = require2("better-sqlite3");
18660
+ var sqliteModule = null;
18661
18661
  var CLI_STORE_SCHEMA_VERSION = 2;
18662
18662
  function defaultStorePath(homeDir = os3.homedir(), env = process.env) {
18663
18663
  const explicit = env.RECAPPI_CLI_STORE_PATH?.trim();
@@ -18689,7 +18689,7 @@ var CliLocalStore = class {
18689
18689
  if (!opts.readonly && dbPath !== ":memory:") {
18690
18690
  mkdirSync(path3.dirname(dbPath), { recursive: true, mode: 448 });
18691
18691
  }
18692
- this.db = new Database(dbPath, opts.readonly === true ? { readonly: true } : void 0);
18692
+ this.db = openSqliteDatabase(dbPath, { readonly: opts.readonly === true });
18693
18693
  this.now = opts.now ?? Date.now;
18694
18694
  if (!opts.readonly) this.migrate();
18695
18695
  }
@@ -18950,6 +18950,44 @@ function parseAccountPartition(input, mode) {
18950
18950
  return null;
18951
18951
  }
18952
18952
  }
18953
+ function openSqliteDatabase(filename, opts) {
18954
+ const { DatabaseSync } = loadNodeSqlite();
18955
+ const db = new DatabaseSync(filename, opts.readonly ? { readOnly: true } : {});
18956
+ return {
18957
+ exec: (source) => db.exec(source),
18958
+ prepare: (source) => db.prepare(source),
18959
+ pragma: (source) => db.prepare(`PRAGMA ${source.trim().replace(/;$/, "")}`).all(),
18960
+ close: () => db.close()
18961
+ };
18962
+ }
18963
+ function loadNodeSqlite() {
18964
+ if (sqliteModule) return sqliteModule;
18965
+ sqliteModule = suppressNodeSqliteWarning(() => require2("node:sqlite"));
18966
+ return sqliteModule;
18967
+ }
18968
+ function suppressNodeSqliteWarning(run) {
18969
+ const emitWarning = process.emitWarning;
18970
+ process.emitWarning = function emitWarningWithoutNodeSqliteNoise(warning, ...args) {
18971
+ const message = typeof warning === "string" ? warning : warning.message;
18972
+ if (message.includes("SQLite is an experimental feature")) return;
18973
+ return emitWarning.call(process, warning, ...args);
18974
+ };
18975
+ try {
18976
+ return run();
18977
+ } catch (error51) {
18978
+ if (isMissingNodeSqlite(error51)) {
18979
+ throw cliError("internal.unexpected", "Local SQLite store requires Node.js 22 or newer.", {
18980
+ hint: "Upgrade Node.js, then retry. Cloud-only commands that do not touch local state can still run."
18981
+ });
18982
+ }
18983
+ throw error51;
18984
+ } finally {
18985
+ process.emitWarning = emitWarning;
18986
+ }
18987
+ }
18988
+ function isMissingNodeSqlite(error51) {
18989
+ return error51 instanceof Error && ("code" in error51 ? error51.code === "ERR_UNKNOWN_BUILTIN_MODULE" : false);
18990
+ }
18953
18991
  function cleanString(value) {
18954
18992
  const trimmed = value?.trim();
18955
18993
  return trimmed ? trimmed : null;