opencode-gateway 0.2.7 → 0.2.8
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 +72 -33
- package/dist/store/database.d.ts +1 -8
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -14931,38 +14931,74 @@ var require_out4 = __commonJS((exports, module) => {
|
|
|
14931
14931
|
// src/store/database.ts
|
|
14932
14932
|
var exports_database = {};
|
|
14933
14933
|
__export(exports_database, {
|
|
14934
|
-
|
|
14934
|
+
openRuntimeSqliteDatabase: () => openRuntimeSqliteDatabase
|
|
14935
14935
|
});
|
|
14936
|
-
|
|
14937
|
-
|
|
14938
|
-
|
|
14939
|
-
db;
|
|
14940
|
-
constructor(path) {
|
|
14941
|
-
this.db = new BetterSqlite3(path);
|
|
14942
|
-
}
|
|
14943
|
-
exec(source) {
|
|
14944
|
-
this.db.exec(source);
|
|
14945
|
-
}
|
|
14946
|
-
query(source) {
|
|
14947
|
-
const statement = this.db.prepare(source);
|
|
14948
|
-
return {
|
|
14949
|
-
get: (...params) => statement.get(...toSqliteParams(params)),
|
|
14950
|
-
all: (...params) => statement.all(...toSqliteParams(params)),
|
|
14951
|
-
run: (...params) => {
|
|
14952
|
-
const result = statement.run(...toSqliteParams(params));
|
|
14953
|
-
return {
|
|
14954
|
-
changes: result.changes,
|
|
14955
|
-
lastInsertRowid: result.lastInsertRowid
|
|
14956
|
-
};
|
|
14957
|
-
}
|
|
14958
|
-
};
|
|
14959
|
-
}
|
|
14960
|
-
transaction(handler) {
|
|
14961
|
-
return this.db.transaction((...args) => handler(...args));
|
|
14962
|
-
}
|
|
14963
|
-
close() {
|
|
14964
|
-
this.db.close();
|
|
14936
|
+
async function openRuntimeSqliteDatabase(path) {
|
|
14937
|
+
if (isBunRuntime()) {
|
|
14938
|
+
return await openBunSqliteDatabase(path);
|
|
14965
14939
|
}
|
|
14940
|
+
return await openNodeSqliteDatabase(path);
|
|
14941
|
+
}
|
|
14942
|
+
async function openNodeSqliteDatabase(path) {
|
|
14943
|
+
const module = await dynamicImport("better-sqlite3");
|
|
14944
|
+
const db2 = new module.default(path);
|
|
14945
|
+
return {
|
|
14946
|
+
exec(source) {
|
|
14947
|
+
db2.exec(source);
|
|
14948
|
+
},
|
|
14949
|
+
query(source) {
|
|
14950
|
+
const statement = db2.prepare(source);
|
|
14951
|
+
return {
|
|
14952
|
+
get: (...params) => statement.get(...toSqliteParams(params)),
|
|
14953
|
+
all: (...params) => statement.all(...toSqliteParams(params)),
|
|
14954
|
+
run: (...params) => {
|
|
14955
|
+
const result = statement.run(...toSqliteParams(params));
|
|
14956
|
+
return {
|
|
14957
|
+
changes: result.changes,
|
|
14958
|
+
lastInsertRowid: result.lastInsertRowid
|
|
14959
|
+
};
|
|
14960
|
+
}
|
|
14961
|
+
};
|
|
14962
|
+
},
|
|
14963
|
+
transaction(handler) {
|
|
14964
|
+
return db2.transaction((...args) => handler(...args));
|
|
14965
|
+
},
|
|
14966
|
+
close() {
|
|
14967
|
+
db2.close();
|
|
14968
|
+
}
|
|
14969
|
+
};
|
|
14970
|
+
}
|
|
14971
|
+
async function openBunSqliteDatabase(path) {
|
|
14972
|
+
const module = await dynamicImport("bun:sqlite");
|
|
14973
|
+
const db2 = new module.Database(path);
|
|
14974
|
+
return {
|
|
14975
|
+
exec(source) {
|
|
14976
|
+
db2.exec(source);
|
|
14977
|
+
},
|
|
14978
|
+
query(source) {
|
|
14979
|
+
const statement = db2.query(source);
|
|
14980
|
+
return {
|
|
14981
|
+
get(...params) {
|
|
14982
|
+
return statement.get(...params);
|
|
14983
|
+
},
|
|
14984
|
+
all(...params) {
|
|
14985
|
+
return statement.all(...params);
|
|
14986
|
+
},
|
|
14987
|
+
run(...params) {
|
|
14988
|
+
return statement.run(...params);
|
|
14989
|
+
}
|
|
14990
|
+
};
|
|
14991
|
+
},
|
|
14992
|
+
transaction(handler) {
|
|
14993
|
+
return db2.transaction((...args) => handler(...args));
|
|
14994
|
+
},
|
|
14995
|
+
close() {
|
|
14996
|
+
db2.close();
|
|
14997
|
+
}
|
|
14998
|
+
};
|
|
14999
|
+
}
|
|
15000
|
+
function isBunRuntime() {
|
|
15001
|
+
return typeof globalThis === "object" && globalThis !== null && "Bun" in globalThis;
|
|
14966
15002
|
}
|
|
14967
15003
|
function toSqliteParams(params) {
|
|
14968
15004
|
return params.map((param) => {
|
|
@@ -14972,7 +15008,10 @@ function toSqliteParams(params) {
|
|
|
14972
15008
|
throw new Error(`unsupported SQLite parameter type: ${typeof param}`);
|
|
14973
15009
|
});
|
|
14974
15010
|
}
|
|
14975
|
-
var
|
|
15011
|
+
var dynamicImport;
|
|
15012
|
+
var init_database = __esm(() => {
|
|
15013
|
+
dynamicImport = new Function("specifier", "return import(specifier)");
|
|
15014
|
+
});
|
|
14976
15015
|
|
|
14977
15016
|
// src/binding/index.ts
|
|
14978
15017
|
import { access, readFile } from "node:fs/promises";
|
|
@@ -23339,8 +23378,8 @@ function readBooleanField(value, field, fallback) {
|
|
|
23339
23378
|
}
|
|
23340
23379
|
async function openSqliteStore(path) {
|
|
23341
23380
|
await mkdir2(dirname3(path), { recursive: true });
|
|
23342
|
-
const {
|
|
23343
|
-
const db2 =
|
|
23381
|
+
const { openRuntimeSqliteDatabase: openRuntimeSqliteDatabase2 } = await Promise.resolve().then(() => (init_database(), exports_database));
|
|
23382
|
+
const db2 = await openRuntimeSqliteDatabase2(path);
|
|
23344
23383
|
migrateGatewayDatabase(db2);
|
|
23345
23384
|
return new SqliteStore(db2);
|
|
23346
23385
|
}
|
package/dist/store/database.d.ts
CHANGED
|
@@ -12,11 +12,4 @@ export type SqliteDatabaseLike = {
|
|
|
12
12
|
transaction<Args extends unknown[], Result>(handler: (...args: Args) => Result): (...args: Args) => Result;
|
|
13
13
|
close(): void;
|
|
14
14
|
};
|
|
15
|
-
export declare
|
|
16
|
-
private readonly db;
|
|
17
|
-
constructor(path: string);
|
|
18
|
-
exec(source: string): void;
|
|
19
|
-
query<Row, Params extends unknown[]>(source: string): SqliteQueryStatementLike<Row, Params>;
|
|
20
|
-
transaction<Args extends unknown[], Result>(handler: (...args: Args) => Result): (...args: Args) => Result;
|
|
21
|
-
close(): void;
|
|
22
|
-
}
|
|
15
|
+
export declare function openRuntimeSqliteDatabase(path: string): Promise<SqliteDatabaseLike>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-gateway",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"description": "Gateway plugin for OpenCode",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "node ./scripts/build.mjs",
|
|
27
27
|
"build:wasm": "node ../../scripts/build-binding.mjs",
|
|
28
|
-
"check": "tsc --noEmit --project tsconfig.json && bun test src && node ./scripts/build.mjs && node ./scripts/smoke-node-import.mjs",
|
|
28
|
+
"check": "tsc --noEmit --project tsconfig.json && bun test src && node ./scripts/build.mjs && node ./scripts/smoke-node-import.mjs && bun ./scripts/smoke-bun-import.mjs",
|
|
29
29
|
"prepack": "npm run build:wasm && npm run build",
|
|
30
30
|
"test": "bun test src"
|
|
31
31
|
},
|