@storecraft/database-turso 1.0.11 → 1.0.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storecraft/database-turso",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
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,7 +35,8 @@
35
35
  "scripts": {
36
36
  "database-turso:test": "node ./tests/runner.test.js",
37
37
  "test": "npm run database-turso:test",
38
- "prepublishOnly": "npm version patch --force"
38
+ "prepublishOnly": "npm version patch --force",
39
+ "sc-publish": "npm publish --access public"
39
40
  },
40
41
  "peerDependencies": {
41
42
  "kysely": "*"
@@ -92,12 +92,11 @@ export class LibSQLVectorStore {
92
92
 
93
93
  /** @type {VectorStore["onInit"]} */
94
94
  onInit = (app) => {
95
- this.config.authToken ??= app.platform.env[
96
- LibSQLVectorStore.EnvConfig.authToken ?? 'LIBSQL_AUTH_TOKEN'
97
- ];
98
- this.config.url ??= app.platform.env[
99
- LibSQLVectorStore.EnvConfig.url ?? 'LIBSQL_URL'
100
- ];
95
+ this.config.authToken ??= app.platform.env[LibSQLVectorStore.EnvConfig.authToken]
96
+ ?? app.platform.env['LIBSQL_AUTH_TOKEN'];
97
+
98
+ this.config.url ??= app.platform.env[LibSQLVectorStore.EnvConfig.url]
99
+ ?? app.platform.env['LIBSQL_URL'];
101
100
  }
102
101
 
103
102
  /** @type {VectorStore["embedder"]} */
@@ -193,7 +192,8 @@ export class LibSQLVectorStore {
193
192
 
194
193
  /** @type {VectorStore["similaritySearch"]} */
195
194
  similaritySearch = async (query, k, namespaces) => {
196
-
195
+ // console.log({query,k,namespaces})
196
+
197
197
  const embedding_result = await this.embedder.generateEmbeddings(
198
198
  {
199
199
  content: [
@@ -218,10 +218,12 @@ export class LibSQLVectorStore {
218
218
  /** @type {InArgs} */
219
219
  let args = [];
220
220
  let sql = `
221
- SELECT id, metadata, pageContent, updated_at, namespace, ${distance_fn}(embedding, vector(?)) AS score
222
- FROM vector_top_k('${index_name}', vector(?), ?) as top_k_view
223
- JOIN ${table} ON ${table}.rowid = top_k_view.id
221
+ SELECT ${table}.id, metadata, pageContent, updated_at, namespace, ${distance_fn}(embedding, vector(?)) AS score
222
+ FROM vector_top_k('${index_name}', vector(?), CAST(? AS INTEGER)) as top_k_view
223
+ JOIN ${table} ON ${table}.rowid = top_k_view.rowid
224
224
  `;
225
+
226
+ // console.log(typeof k)
225
227
  args.push(vector_sql_value, vector_sql_value, k);
226
228
 
227
229
  if(Array.isArray(namespaces) && namespaces.length) {
@@ -236,9 +238,10 @@ export class LibSQLVectorStore {
236
238
  `
237
239
  args.push(vector_sql_value);
238
240
 
239
-
240
241
  const result = await this.client.execute({ sql, args });
241
242
 
243
+ // console.log({result})
244
+
242
245
  return result.rows.map(
243
246
  (row) => (
244
247
  {