@ocap/statedb-sqlite 1.31.8 → 1.31.9

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/esm/kysely.mjs CHANGED
@@ -1,7 +1,11 @@
1
1
  import { __require } from "./_virtual/rolldown_runtime.mjs";
2
2
  import { Kysely, SqliteAdapter, SqliteDialect, SqliteIntrospector, SqliteQueryCompiler } from "kysely";
3
+ import { instrumentSqlTiming } from "@ocap/util/lib/sql-timing";
3
4
 
4
5
  //#region src/kysely.ts
6
+ const timeConnection = async (connection) => {
7
+ instrumentSqlTiming(connection);
8
+ };
5
9
  var ConnectionMutex = class {
6
10
  async lock() {
7
11
  while (this.promise) await this.promise;
@@ -1576,9 +1580,15 @@ function createKysely(config) {
1576
1580
  sqlite.exec("PRAGMA foreign_keys = ON");
1577
1581
  sqlite.exec("PRAGMA busy_timeout = 5000");
1578
1582
  sqlite.exec(`PRAGMA mmap_size = ${resolveMmapSize(config)}`);
1579
- return new Kysely({ dialect: new BunSqliteDialect({ database: sqlite }) });
1580
- }
1581
- return new Kysely({ dialect: new SqliteDialect({ database: openBetterSqlite3(__require("better-sqlite3"), filename, config) }) });
1583
+ return new Kysely({ dialect: new BunSqliteDialect({
1584
+ database: sqlite,
1585
+ onCreateConnection: timeConnection
1586
+ }) });
1587
+ }
1588
+ return new Kysely({ dialect: new SqliteDialect({
1589
+ database: openBetterSqlite3(__require("better-sqlite3"), filename, config),
1590
+ onCreateConnection: timeConnection
1591
+ }) });
1582
1592
  }
1583
1593
  /**
1584
1594
  * Open a better-sqlite3 connection and apply connection pragmas (Node.js runtime path).
package/lib/kysely.cjs CHANGED
@@ -1,7 +1,11 @@
1
1
  const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
2
  let kysely = require("kysely");
3
+ let _ocap_util_lib_sql_timing = require("@ocap/util/lib/sql-timing");
3
4
 
4
5
  //#region src/kysely.ts
6
+ const timeConnection = async (connection) => {
7
+ (0, _ocap_util_lib_sql_timing.instrumentSqlTiming)(connection);
8
+ };
5
9
  var ConnectionMutex = class {
6
10
  async lock() {
7
11
  while (this.promise) await this.promise;
@@ -1576,9 +1580,15 @@ function createKysely(config) {
1576
1580
  sqlite.exec("PRAGMA foreign_keys = ON");
1577
1581
  sqlite.exec("PRAGMA busy_timeout = 5000");
1578
1582
  sqlite.exec(`PRAGMA mmap_size = ${resolveMmapSize(config)}`);
1579
- return new kysely.Kysely({ dialect: new BunSqliteDialect({ database: sqlite }) });
1580
- }
1581
- return new kysely.Kysely({ dialect: new kysely.SqliteDialect({ database: openBetterSqlite3(require("better-sqlite3"), filename, config) }) });
1583
+ return new kysely.Kysely({ dialect: new BunSqliteDialect({
1584
+ database: sqlite,
1585
+ onCreateConnection: timeConnection
1586
+ }) });
1587
+ }
1588
+ return new kysely.Kysely({ dialect: new kysely.SqliteDialect({
1589
+ database: openBetterSqlite3(require("better-sqlite3"), filename, config),
1590
+ onCreateConnection: timeConnection
1591
+ }) });
1582
1592
  }
1583
1593
  /**
1584
1594
  * Open a better-sqlite3 connection and apply connection pragmas (Node.js runtime path).
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ocap/statedb-sqlite",
3
3
  "description": "OCAP statedb adapter that uses SQLite as backend",
4
- "version": "1.31.8",
4
+ "version": "1.31.9",
5
5
  "author": "wangshijun <shijun@arcblock.io> (https://www.arcblock.io)",
6
6
  "bugs": {
7
7
  "url": "https://github.com/ArcBlock/blockchain/issues",
@@ -14,7 +14,7 @@
14
14
  "wangshijun <shijun@arcblock.io> (https://www.arcblock.io)"
15
15
  ],
16
16
  "devDependencies": {
17
- "@ocap/statedb-test": "1.31.8"
17
+ "@ocap/statedb-test": "1.31.9"
18
18
  },
19
19
  "homepage": "https://github.com/ArcBlock/blockchain/tree/master/statedb/sqlite",
20
20
  "keywords": [
@@ -63,12 +63,12 @@
63
63
  "clean": "rm -rf lib esm"
64
64
  },
65
65
  "dependencies": {
66
- "@arcblock/did": "1.31.8",
67
- "@arcblock/did-util": "1.31.8",
68
- "@ocap/state": "1.31.8",
69
- "@ocap/statedb": "1.31.8",
70
- "@ocap/types": "1.31.8",
71
- "@ocap/util": "1.31.8",
66
+ "@arcblock/did": "1.31.9",
67
+ "@arcblock/did-util": "1.31.9",
68
+ "@ocap/state": "1.31.9",
69
+ "@ocap/statedb": "1.31.9",
70
+ "@ocap/types": "1.31.9",
71
+ "@ocap/util": "1.31.9",
72
72
  "better-sqlite3": "^11.8.1",
73
73
  "kysely": "^0.28.14",
74
74
  "kysely-bun-sqlite": "^0.4.0",