@storecraft/database-turso 1.0.22 → 1.2.5
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/README.md +10 -12
- package/index.js +2 -2
- package/kysely.turso.dialect.js +0 -2
- package/package.json +2 -3
- package/vector-store/index.js +11 -5
package/README.md
CHANGED
@@ -44,16 +44,15 @@ const app = new App(
|
|
44
44
|
url: 'file:local-vector.db'
|
45
45
|
}
|
46
46
|
)
|
47
|
-
)
|
47
|
+
).init();
|
48
48
|
|
49
|
-
await app.
|
50
|
-
await
|
51
|
-
await app.vectorstore.createVectorIndex();
|
49
|
+
await migrateToLatest(app.__show_me_everything.db, false);
|
50
|
+
await app.__show_me_everything.vector_store.createVectorIndex();
|
52
51
|
|
53
|
-
|
52
|
+
http.createServer(app.handler).listen(
|
54
53
|
8000,
|
55
54
|
() => {
|
56
|
-
|
55
|
+
app.print_banner('http://localhost:8000');
|
57
56
|
}
|
58
57
|
);
|
59
58
|
|
@@ -127,16 +126,15 @@ const app = new App(
|
|
127
126
|
authToken: process.env.LIBSQL_API_TOKEN,
|
128
127
|
}
|
129
128
|
)
|
130
|
-
)
|
129
|
+
).init();
|
131
130
|
|
132
|
-
await app.
|
133
|
-
await
|
134
|
-
await app.vectorstore.createVectorIndex();
|
131
|
+
await migrateToLatest(app.__show_me_everything.db, false);
|
132
|
+
await app.__show_me_everything.vector_store.createVectorIndex();
|
135
133
|
|
136
|
-
|
134
|
+
http.createServer(app.handler).listen(
|
137
135
|
8000,
|
138
136
|
() => {
|
139
|
-
|
137
|
+
app.print_banner('http://localhost:8000');
|
140
138
|
}
|
141
139
|
);
|
142
140
|
|
package/index.js
CHANGED
@@ -44,9 +44,9 @@ export class Turso extends SQL {
|
|
44
44
|
const dconfig = dialect.config;
|
45
45
|
|
46
46
|
// optional
|
47
|
-
dconfig.authToken ??= app.
|
47
|
+
dconfig.authToken ??= app.env[Turso.EnvConfig.authToken];
|
48
48
|
// mandatory
|
49
|
-
dconfig.url ??= (app.
|
49
|
+
dconfig.url ??= (app.env[Turso.EnvConfig.url] ?? 'file:data.db');
|
50
50
|
|
51
51
|
if (!dconfig.url) {
|
52
52
|
console.warn(
|
package/kysely.turso.dialect.js
CHANGED
@@ -170,8 +170,6 @@ export class LibsqlConnection {
|
|
170
170
|
insertId: last_result?.lastInsertRowid,
|
171
171
|
rows: last_result?.rows ?? [],
|
172
172
|
numAffectedRows: BigInt(last_result?.rowsAffected ?? 0),
|
173
|
-
// @ts-ignore deprecated in kysely >= 0.23, keep for backward compatibility.
|
174
|
-
numUpdatedOrDeletedRows: last_result?.rowsAffected,
|
175
173
|
};
|
176
174
|
|
177
175
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@storecraft/database-turso",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.2.5",
|
4
4
|
"description": "`Storecraft` database driver for `Turso` (cloud sqlite)",
|
5
5
|
"license": "MIT",
|
6
6
|
"author": "Tomer Shalev (https://github.com/store-craft)",
|
@@ -35,8 +35,7 @@
|
|
35
35
|
"scripts": {
|
36
36
|
"database-turso:test": "node ./tests/runner.test.js",
|
37
37
|
"test": "npm run database-turso:test",
|
38
|
-
"
|
39
|
-
"sc-publish": "npm publish --access public"
|
38
|
+
"sc-publish": "npm test && npm publish --access public"
|
40
39
|
},
|
41
40
|
"dependencies": {
|
42
41
|
"@libsql/client": "^0.15.4",
|
package/vector-store/index.js
CHANGED
@@ -102,11 +102,13 @@ export class LibSQLVectorStore {
|
|
102
102
|
|
103
103
|
/** @type {VectorStore["onInit"]} */
|
104
104
|
onInit = (app) => {
|
105
|
-
this.config.authToken ??=
|
106
|
-
|
105
|
+
this.config.authToken ??=
|
106
|
+
app.env[LibSQLVectorStore.EnvConfig.authToken]
|
107
|
+
?? app.env['LIBSQL_AUTH_TOKEN'];
|
107
108
|
|
108
|
-
this.config.url ??=
|
109
|
-
|
109
|
+
this.config.url ??=
|
110
|
+
app.env[LibSQLVectorStore.EnvConfig.url]
|
111
|
+
?? app.env['LIBSQL_URL'] ?? 'file:data.db';
|
110
112
|
}
|
111
113
|
|
112
114
|
/** @type {VectorStore["embedder"]} */
|
@@ -281,10 +283,11 @@ export class LibSQLVectorStore {
|
|
281
283
|
|
282
284
|
/**
|
283
285
|
*
|
286
|
+
* @param {Record<string, any>} [params={}]
|
284
287
|
* @param {boolean} [delete_index_if_exists_before=false]
|
285
288
|
* @returns {Promise<boolean>}
|
286
289
|
*/
|
287
|
-
createVectorIndex = async (delete_index_if_exists_before=false) => {
|
290
|
+
createVectorIndex = async (params={}, delete_index_if_exists_before=false) => {
|
288
291
|
|
289
292
|
/** @type {string[]} */
|
290
293
|
const batch = [];
|
@@ -299,6 +302,9 @@ export class LibSQLVectorStore {
|
|
299
302
|
);
|
300
303
|
|
301
304
|
const result = await this.client.batch(batch);
|
305
|
+
|
306
|
+
// console.log({result});
|
307
|
+
|
302
308
|
return true;
|
303
309
|
}
|
304
310
|
|