@rce-mcp/data-plane 0.1.0

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.
@@ -0,0 +1,18 @@
1
+ export type SqliteBindValue = string | number | bigint | Uint8Array | null;
2
+ export interface SqliteRunResult {
3
+ changes?: number;
4
+ }
5
+ export interface SqliteStatement {
6
+ run(...params: SqliteBindValue[]): SqliteRunResult;
7
+ get(...params: SqliteBindValue[]): unknown;
8
+ all(...params: SqliteBindValue[]): unknown[];
9
+ }
10
+ export interface SqliteDatabase {
11
+ exec(sql: string): void;
12
+ prepare(sql: string): SqliteStatement;
13
+ close(): void;
14
+ }
15
+ type SqliteDriverName = "node:sqlite" | "bun:sqlite";
16
+ export declare function sqliteRuntimeDriverName(): SqliteDriverName;
17
+ export declare function openSqliteDatabase(dbPath: string): SqliteDatabase;
18
+ export {};
@@ -0,0 +1,71 @@
1
+ import { createRequire } from "node:module";
2
+ const require = createRequire(import.meta.url);
3
+ function loadNodeSqliteDriver() {
4
+ const mod = require("node:sqlite");
5
+ return {
6
+ name: "node:sqlite",
7
+ open(dbPath) {
8
+ const db = new mod.DatabaseSync(dbPath);
9
+ return {
10
+ exec(sql) {
11
+ db.exec(sql);
12
+ },
13
+ prepare(sql) {
14
+ return db.prepare(sql);
15
+ },
16
+ close() {
17
+ db.close();
18
+ }
19
+ };
20
+ }
21
+ };
22
+ }
23
+ function loadBunSqliteDriver() {
24
+ const mod = require("bun:sqlite");
25
+ const BunDatabase = mod.Database ?? mod.default?.Database;
26
+ if (!BunDatabase) {
27
+ throw new Error("bun:sqlite Database export is unavailable");
28
+ }
29
+ return {
30
+ name: "bun:sqlite",
31
+ open(dbPath) {
32
+ const db = new BunDatabase(dbPath);
33
+ return {
34
+ exec(sql) {
35
+ db.exec(sql);
36
+ },
37
+ prepare(sql) {
38
+ const statement = db.query(sql);
39
+ return {
40
+ run(...params) {
41
+ return statement.run(...params);
42
+ },
43
+ get(...params) {
44
+ return statement.get(...params);
45
+ },
46
+ all(...params) {
47
+ return statement.all(...params);
48
+ }
49
+ };
50
+ },
51
+ close() {
52
+ db.close();
53
+ }
54
+ };
55
+ }
56
+ };
57
+ }
58
+ function loadSqliteRuntimeDriver() {
59
+ const isBun = typeof process.versions.bun === "string" && process.versions.bun.length > 0;
60
+ if (isBun) {
61
+ return loadBunSqliteDriver();
62
+ }
63
+ return loadNodeSqliteDriver();
64
+ }
65
+ const sqliteRuntimeDriver = loadSqliteRuntimeDriver();
66
+ export function sqliteRuntimeDriverName() {
67
+ return sqliteRuntimeDriver.name;
68
+ }
69
+ export function openSqliteDatabase(dbPath) {
70
+ return sqliteRuntimeDriver.open(dbPath);
71
+ }
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@rce-mcp/data-plane",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ }
12
+ },
13
+ "dependencies": {
14
+ "@rce-mcp/contracts": "0.1.0",
15
+ "ioredis": "^5.6.1",
16
+ "pg": "^8.13.1"
17
+ },
18
+ "devDependencies": {
19
+ "ioredis-mock": "^8.9.0",
20
+ "pg-mem": "^3.0.5"
21
+ }
22
+ }