@capgo/capacitor-fast-sql 8.0.37 → 8.0.39
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 +57 -0
- package/android/src/main/java/app/capgo/capacitor/fastsql/CapgoCapacitorFastSqlPlugin.java +1 -1
- package/dist/esm/fast-sql.d.ts +15 -0
- package/dist/esm/fast-sql.d.ts.map +1 -1
- package/dist/esm/fast-sql.js +51 -1
- package/dist/esm/helpers.d.ts +2 -0
- package/dist/esm/helpers.d.ts.map +1 -1
- package/dist/esm/helpers.js +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/vector-store.d.ts +128 -0
- package/dist/esm/vector-store.d.ts.map +1 -0
- package/dist/esm/vector-store.js +377 -0
- package/dist/plugin.cjs.js +429 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +429 -1
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CapgoCapacitorFastSqlPlugin/CapgoCapacitorFastSqlPlugin.swift +1 -1
- package/ios/Sources/CapgoCapacitorFastSqlPlugin/SQLDatabase.swift +9 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,6 +52,7 @@ This plugin provides direct native SQLite database access with a custom communic
|
|
|
52
52
|
- **Sync-Friendly**: Designed for local sync systems (CRDTs, operational transforms, etc.)
|
|
53
53
|
- **IndexedDB Replacement**: Provides reliable alternative to broken/limited IndexedDB implementations
|
|
54
54
|
- **Cross-Platform**: iOS, Android, and Web (using sql.js + IndexedDB for persistence)
|
|
55
|
+
- **Optional RAG VectorStore**: Persist many named vector stores for retrieval-augmented generation without adding a native dependency
|
|
55
56
|
|
|
56
57
|
## iOS Configuration
|
|
57
58
|
|
|
@@ -239,6 +240,62 @@ const session = await kv.get('session');
|
|
|
239
240
|
await kv.remove('session');
|
|
240
241
|
```
|
|
241
242
|
|
|
243
|
+
### RAG Vector Stores (Optional)
|
|
244
|
+
|
|
245
|
+
`FastSQLVectorStore` provides a dependency-free VectorStore-compatible helper inspired by `@react-native-rag/op-sqlite`. It stores embeddings in SQLite as binary Float32 vectors and computes cosine similarity in TypeScript, so it works anywhere this plugin works.
|
|
246
|
+
|
|
247
|
+
Each store is namespaced by the `store` option, so one database can hold as many independent vector stores as you need:
|
|
248
|
+
|
|
249
|
+
```typescript
|
|
250
|
+
import { FastSQLVectorStore } from '@capgo/capacitor-fast-sql';
|
|
251
|
+
|
|
252
|
+
const docs = await FastSQLVectorStore.open({
|
|
253
|
+
database: 'rag',
|
|
254
|
+
store: 'docs',
|
|
255
|
+
embeddings,
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
const tickets = await FastSQLVectorStore.open({
|
|
259
|
+
database: 'rag',
|
|
260
|
+
store: 'tickets',
|
|
261
|
+
embeddings,
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
await docs.add({
|
|
265
|
+
document: 'Capgo ships instant updates for Capacitor apps.',
|
|
266
|
+
metadata: { source: 'docs' },
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
const results = await docs.query({
|
|
270
|
+
queryText: 'How do instant updates work?',
|
|
271
|
+
nResults: 3,
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
await docs.close();
|
|
275
|
+
await tickets.close();
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
You can also use precomputed embeddings without an embeddings provider:
|
|
279
|
+
|
|
280
|
+
```typescript
|
|
281
|
+
const store = await FastSQLVectorStore.open({
|
|
282
|
+
database: 'rag',
|
|
283
|
+
store: 'offline-embeddings',
|
|
284
|
+
embeddingDimension: 384,
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
await store.add({
|
|
288
|
+
id: 'intro',
|
|
289
|
+
document: 'Local RAG entry',
|
|
290
|
+
embedding: [0.12, 0.08, 0.31 /* ...384 values */],
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
const matches = await store.query({
|
|
294
|
+
queryEmbedding: [0.11, 0.09, 0.29 /* ...384 values */],
|
|
295
|
+
nResults: 5,
|
|
296
|
+
});
|
|
297
|
+
```
|
|
298
|
+
|
|
242
299
|
> Note: Web support is intended for minimal testing only. The primary focus is iOS/Android.
|
|
243
300
|
|
|
244
301
|
## API
|
|
@@ -19,7 +19,7 @@ import java.util.Map;
|
|
|
19
19
|
@CapacitorPlugin(name = "CapgoCapacitorFastSql")
|
|
20
20
|
public class CapgoCapacitorFastSqlPlugin extends Plugin {
|
|
21
21
|
|
|
22
|
-
private final String pluginVersion = "8.0.
|
|
22
|
+
private final String pluginVersion = "8.0.39";
|
|
23
23
|
|
|
24
24
|
private Map<String, DatabaseConnection> databases = new HashMap<>();
|
|
25
25
|
private SQLHTTPServer server;
|
package/dist/esm/fast-sql.d.ts
CHANGED
|
@@ -8,6 +8,9 @@ import type { SQLConnection } from './sql-connection';
|
|
|
8
8
|
*/
|
|
9
9
|
export declare class FastSQL {
|
|
10
10
|
private static connections;
|
|
11
|
+
private static sharedConnections;
|
|
12
|
+
private static connectionRetainers;
|
|
13
|
+
private static pendingDisconnects;
|
|
11
14
|
/**
|
|
12
15
|
* Open a database connection
|
|
13
16
|
*
|
|
@@ -28,6 +31,18 @@ export declare class FastSQL {
|
|
|
28
31
|
* @returns SQLConnection instance or null if not connected
|
|
29
32
|
*/
|
|
30
33
|
static getConnection(database: string): SQLConnection | null;
|
|
34
|
+
/**
|
|
35
|
+
* Check whether a connection has been handed out more than once.
|
|
36
|
+
*/
|
|
37
|
+
static isConnectionShared(database: string): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Temporarily retain a connection for helpers that share cached connections.
|
|
40
|
+
*/
|
|
41
|
+
static retainConnection(database: string): void;
|
|
42
|
+
/**
|
|
43
|
+
* Release a retained connection. Returns true when a pending disconnect closed it.
|
|
44
|
+
*/
|
|
45
|
+
static releaseConnection(database: string): Promise<boolean>;
|
|
31
46
|
/**
|
|
32
47
|
* Close all open connections
|
|
33
48
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fast-sql.d.ts","sourceRoot":"","sources":["../../src/fast-sql.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAG1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGtD;;;;;GAKG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,MAAM,CAAC,WAAW,CAAyC;
|
|
1
|
+
{"version":3,"file":"fast-sql.d.ts","sourceRoot":"","sources":["../../src/fast-sql.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAG1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGtD;;;;;GAKG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,MAAM,CAAC,WAAW,CAAyC;IACnE,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAA0B;IAC1D,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAAkC;IACpE,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAA0B;IAE3D;;;;;OAKG;WACU,OAAO,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,aAAa,CAAC;IA0B3E;;;;OAIG;WACU,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBxD;;;;;OAKG;IACH,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI;IAI5D;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAIpD;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAO/C;;OAEG;WACU,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAgBlE;;OAEG;WACU,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAW3C;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,IAAI,MAAM,EAAE;CAGpC"}
|
package/dist/esm/fast-sql.js
CHANGED
|
@@ -19,6 +19,7 @@ export class FastSQL {
|
|
|
19
19
|
// Check if already connected
|
|
20
20
|
const existing = this.connections.get(options.database);
|
|
21
21
|
if (existing) {
|
|
22
|
+
this.sharedConnections.add(options.database);
|
|
22
23
|
return existing;
|
|
23
24
|
}
|
|
24
25
|
// Connect via native plugin
|
|
@@ -42,14 +43,22 @@ export class FastSQL {
|
|
|
42
43
|
* @param database - Database name to close
|
|
43
44
|
*/
|
|
44
45
|
static async disconnect(database) {
|
|
46
|
+
var _a;
|
|
45
47
|
const connection = this.connections.get(database);
|
|
46
48
|
if (!connection) {
|
|
47
49
|
throw new Error(`Database '${database}' is not connected`);
|
|
48
50
|
}
|
|
51
|
+
if (((_a = this.connectionRetainers.get(database)) !== null && _a !== void 0 ? _a : 0) > 0) {
|
|
52
|
+
this.pendingDisconnects.add(database);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
49
55
|
// Disconnect via native plugin
|
|
50
56
|
await CapgoCapacitorFastSql.disconnect({ database });
|
|
51
57
|
// Remove connection
|
|
52
58
|
this.connections.delete(database);
|
|
59
|
+
this.sharedConnections.delete(database);
|
|
60
|
+
this.connectionRetainers.delete(database);
|
|
61
|
+
this.pendingDisconnects.delete(database);
|
|
53
62
|
}
|
|
54
63
|
/**
|
|
55
64
|
* Get an existing connection
|
|
@@ -60,12 +69,50 @@ export class FastSQL {
|
|
|
60
69
|
static getConnection(database) {
|
|
61
70
|
return this.connections.get(database) || null;
|
|
62
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Check whether a connection has been handed out more than once.
|
|
74
|
+
*/
|
|
75
|
+
static isConnectionShared(database) {
|
|
76
|
+
return this.sharedConnections.has(database);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Temporarily retain a connection for helpers that share cached connections.
|
|
80
|
+
*/
|
|
81
|
+
static retainConnection(database) {
|
|
82
|
+
var _a;
|
|
83
|
+
if (!this.connections.has(database)) {
|
|
84
|
+
throw new Error(`Database '${database}' is not connected`);
|
|
85
|
+
}
|
|
86
|
+
this.connectionRetainers.set(database, ((_a = this.connectionRetainers.get(database)) !== null && _a !== void 0 ? _a : 0) + 1);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Release a retained connection. Returns true when a pending disconnect closed it.
|
|
90
|
+
*/
|
|
91
|
+
static async releaseConnection(database) {
|
|
92
|
+
var _a;
|
|
93
|
+
const retainers = (_a = this.connectionRetainers.get(database)) !== null && _a !== void 0 ? _a : 0;
|
|
94
|
+
if (retainers > 1) {
|
|
95
|
+
this.connectionRetainers.set(database, retainers - 1);
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
this.connectionRetainers.delete(database);
|
|
99
|
+
if (this.pendingDisconnects.has(database)) {
|
|
100
|
+
this.pendingDisconnects.delete(database);
|
|
101
|
+
await this.disconnect(database);
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
63
106
|
/**
|
|
64
107
|
* Close all open connections
|
|
65
108
|
*/
|
|
66
109
|
static async disconnectAll() {
|
|
67
110
|
const databases = Array.from(this.connections.keys());
|
|
68
|
-
await Promise.all(databases.map((db) =>
|
|
111
|
+
await Promise.all(databases.map((db) => {
|
|
112
|
+
this.connectionRetainers.delete(db);
|
|
113
|
+
this.pendingDisconnects.delete(db);
|
|
114
|
+
return this.disconnect(db);
|
|
115
|
+
}));
|
|
69
116
|
}
|
|
70
117
|
/**
|
|
71
118
|
* Get list of all open database connections
|
|
@@ -77,3 +124,6 @@ export class FastSQL {
|
|
|
77
124
|
}
|
|
78
125
|
}
|
|
79
126
|
FastSQL.connections = new Map();
|
|
127
|
+
FastSQL.sharedConnections = new Set();
|
|
128
|
+
FastSQL.connectionRetainers = new Map();
|
|
129
|
+
FastSQL.pendingDisconnects = new Set();
|
package/dist/esm/helpers.d.ts
CHANGED
|
@@ -4,4 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export { FastSQL } from './fast-sql';
|
|
6
6
|
export { SQLConnection } from './sql-connection';
|
|
7
|
+
export { FastSQLVectorStore } from './vector-store';
|
|
8
|
+
export type { VectorEmbeddings, VectorMetadata, VectorStore, VectorStoreAddOptions, VectorStoreConnectionOptions, VectorStoreDeleteOptions, VectorStoreGetResult, VectorStoreOptions, VectorStoreQueryOptions, VectorStoreQueryResult, VectorStoreUpdateOptions, } from './vector-store';
|
|
7
9
|
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,qBAAqB,EACrB,4BAA4B,EAC5B,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,gBAAgB,CAAC"}
|
package/dist/esm/helpers.js
CHANGED
package/dist/esm/index.d.ts
CHANGED
|
@@ -6,4 +6,6 @@ export { NativeSQLConnection } from './native-sql-connection';
|
|
|
6
6
|
export { WebSQLConnection } from './web-sql-connection';
|
|
7
7
|
export { KeyValueStore } from './key-value';
|
|
8
8
|
export type { KeyValueStoreOptions, KeyValueValue } from './key-value';
|
|
9
|
+
export { FastSQLVectorStore } from './vector-store';
|
|
10
|
+
export type { VectorEmbeddings, VectorMetadata, VectorStore, VectorStoreAddOptions, VectorStoreConnectionOptions, VectorStoreDeleteOptions, VectorStoreGetResult, VectorStoreOptions, VectorStoreQueryOptions, VectorStoreQueryResult, VectorStoreUpdateOptions, } from './vector-store';
|
|
9
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGjD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGjD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,qBAAqB,EACrB,4BAA4B,EAC5B,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,gBAAgB,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { SQLConnectionOptions } from './definitions';
|
|
2
|
+
import type { SQLConnection } from './sql-connection';
|
|
3
|
+
export type VectorMetadata = Record<string, unknown>;
|
|
4
|
+
export interface VectorEmbeddings {
|
|
5
|
+
load?: () => Promise<unknown> | unknown;
|
|
6
|
+
unload?: () => Promise<unknown> | unknown;
|
|
7
|
+
embed: (text: string) => Promise<number[]> | number[];
|
|
8
|
+
}
|
|
9
|
+
export interface VectorStoreGetResult {
|
|
10
|
+
id: string;
|
|
11
|
+
document: string;
|
|
12
|
+
embedding: number[];
|
|
13
|
+
metadata?: VectorMetadata;
|
|
14
|
+
}
|
|
15
|
+
export interface VectorStoreQueryResult extends VectorStoreGetResult {
|
|
16
|
+
similarity: number;
|
|
17
|
+
}
|
|
18
|
+
export interface VectorStoreAddOptions {
|
|
19
|
+
id?: string;
|
|
20
|
+
document?: string;
|
|
21
|
+
embedding?: number[];
|
|
22
|
+
metadata?: VectorMetadata | null;
|
|
23
|
+
}
|
|
24
|
+
export interface VectorStoreUpdateOptions {
|
|
25
|
+
id: string;
|
|
26
|
+
document?: string;
|
|
27
|
+
embedding?: number[];
|
|
28
|
+
metadata?: VectorMetadata | null;
|
|
29
|
+
}
|
|
30
|
+
export interface VectorStoreDeleteOptions {
|
|
31
|
+
predicate: (value: VectorStoreGetResult) => boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface VectorStoreQueryOptions {
|
|
34
|
+
queryText?: string;
|
|
35
|
+
queryEmbedding?: number[];
|
|
36
|
+
nResults?: number;
|
|
37
|
+
predicate?: (value: VectorStoreQueryResult) => boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface VectorStoreConnectionOptions {
|
|
40
|
+
/**
|
|
41
|
+
* Logical vector store name inside the database. Use different names to keep
|
|
42
|
+
* multiple RAG collections in the same SQLite database.
|
|
43
|
+
*/
|
|
44
|
+
store?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Optional embeddings provider. Required when adding or querying by text.
|
|
47
|
+
*/
|
|
48
|
+
embeddings?: VectorEmbeddings;
|
|
49
|
+
/**
|
|
50
|
+
* Optional embedding dimension. Supplying it avoids probing the embeddings
|
|
51
|
+
* model on load and allows precomputed-embedding-only stores.
|
|
52
|
+
*/
|
|
53
|
+
embeddingDimension?: number;
|
|
54
|
+
}
|
|
55
|
+
export interface VectorStoreOptions extends SQLConnectionOptions, VectorStoreConnectionOptions {
|
|
56
|
+
}
|
|
57
|
+
export interface VectorStore {
|
|
58
|
+
load(): Promise<this>;
|
|
59
|
+
unload(): Promise<void>;
|
|
60
|
+
add(params: VectorStoreAddOptions): Promise<string>;
|
|
61
|
+
update(params: VectorStoreUpdateOptions): Promise<void>;
|
|
62
|
+
delete(params: VectorStoreDeleteOptions): Promise<void>;
|
|
63
|
+
query(params: VectorStoreQueryOptions): Promise<VectorStoreQueryResult[]>;
|
|
64
|
+
deleteVectorStore(): Promise<void>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* SQLite-backed VectorStore for local RAG usage.
|
|
68
|
+
*
|
|
69
|
+
* The helper is optional and dependency-free: pass your own embeddings provider,
|
|
70
|
+
* or use precomputed embeddings with `embeddingDimension`. Multiple stores can
|
|
71
|
+
* share one database by choosing different `store` names.
|
|
72
|
+
*/
|
|
73
|
+
export declare class FastSQLVectorStore implements VectorStore {
|
|
74
|
+
private static readonly connectionRefs;
|
|
75
|
+
private static readonly ownedConnections;
|
|
76
|
+
private readonly connection;
|
|
77
|
+
private readonly store;
|
|
78
|
+
private readonly embeddings?;
|
|
79
|
+
private readonly configuredEmbeddingDim?;
|
|
80
|
+
private embeddingDim?;
|
|
81
|
+
private initialized;
|
|
82
|
+
private ownsConnection;
|
|
83
|
+
private shouldDisconnectConnection;
|
|
84
|
+
private closed;
|
|
85
|
+
private constructor();
|
|
86
|
+
private static retainConnection;
|
|
87
|
+
private static releaseConnection;
|
|
88
|
+
/**
|
|
89
|
+
* Open a vector store from database connection options.
|
|
90
|
+
*/
|
|
91
|
+
static open(options: VectorStoreOptions): Promise<FastSQLVectorStore>;
|
|
92
|
+
/**
|
|
93
|
+
* Create a vector store from an existing SQL connection.
|
|
94
|
+
* The caller keeps ownership of the connection.
|
|
95
|
+
*/
|
|
96
|
+
static fromConnection(connection: SQLConnection, options?: VectorStoreConnectionOptions): Promise<FastSQLVectorStore>;
|
|
97
|
+
getStoreName(): string;
|
|
98
|
+
getDatabaseName(): string;
|
|
99
|
+
load(): Promise<this>;
|
|
100
|
+
unload(): Promise<void>;
|
|
101
|
+
close(): Promise<void>;
|
|
102
|
+
add(params: VectorStoreAddOptions): Promise<string>;
|
|
103
|
+
update(params: VectorStoreUpdateOptions): Promise<void>;
|
|
104
|
+
delete(params: VectorStoreDeleteOptions): Promise<void>;
|
|
105
|
+
query(params: VectorStoreQueryOptions): Promise<VectorStoreQueryResult[]>;
|
|
106
|
+
/**
|
|
107
|
+
* Delete only this logical vector store. Other stores in the same database stay intact.
|
|
108
|
+
*/
|
|
109
|
+
deleteVectorStore(): Promise<void>;
|
|
110
|
+
private ensureReady;
|
|
111
|
+
private assertOpen;
|
|
112
|
+
private ensureSchema;
|
|
113
|
+
private ensureStoreDimension;
|
|
114
|
+
private parseStoredDimension;
|
|
115
|
+
private saveEmbeddingDimension;
|
|
116
|
+
private ensureEmbeddingDimension;
|
|
117
|
+
private embedDocument;
|
|
118
|
+
private validateEmbedding;
|
|
119
|
+
private getStoreRows;
|
|
120
|
+
private rowToGetResult;
|
|
121
|
+
private encodeEmbedding;
|
|
122
|
+
private decodeEmbedding;
|
|
123
|
+
private encodeMetadata;
|
|
124
|
+
private decodeMetadata;
|
|
125
|
+
private cosineSimilarity;
|
|
126
|
+
private createId;
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=vector-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector-store.d.ts","sourceRoot":"","sources":["../../src/vector-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAoB,MAAM,eAAe,CAAC;AAE5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAMtD,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAErD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACxC,MAAM,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAC1C,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC;CACvD;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED,MAAM,WAAW,sBAAuB,SAAQ,oBAAoB;IAClE,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CAClC;AAED,MAAM,WA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