@wiscale/tauri-plugin-velesdb 0.5.1
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.d.mts +273 -0
- package/dist/index.d.ts +273 -0
- package/dist/index.js +73 -0
- package/dist/index.mjs +40 -0
- package/package.json +54 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module tauri-plugin-velesdb
|
|
3
|
+
*
|
|
4
|
+
* TypeScript bindings for the VelesDB Tauri plugin.
|
|
5
|
+
* Provides type-safe access to vector database operations in desktop apps.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { createCollection, search, upsert } from 'tauri-plugin-velesdb';
|
|
10
|
+
*
|
|
11
|
+
* // Create a collection
|
|
12
|
+
* await createCollection({ name: 'docs', dimension: 768, metric: 'cosine' });
|
|
13
|
+
*
|
|
14
|
+
* // Insert vectors
|
|
15
|
+
* await upsert({
|
|
16
|
+
* collection: 'docs',
|
|
17
|
+
* points: [{ id: 1, vector: [...], payload: { title: 'Doc' } }]
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* // Search
|
|
21
|
+
* const results = await search({ collection: 'docs', vector: [...], topK: 10 });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
/** Distance metric for vector similarity. */
|
|
25
|
+
type DistanceMetric = 'cosine' | 'euclidean' | 'dot' | 'hamming' | 'jaccard';
|
|
26
|
+
/** Request to create a new collection. */
|
|
27
|
+
interface CreateCollectionRequest {
|
|
28
|
+
/** Collection name (unique identifier). */
|
|
29
|
+
name: string;
|
|
30
|
+
/** Vector dimension (e.g., 768 for BERT, 1536 for GPT). */
|
|
31
|
+
dimension: number;
|
|
32
|
+
/** Distance metric for similarity calculations. Default: 'cosine'. */
|
|
33
|
+
metric?: DistanceMetric;
|
|
34
|
+
}
|
|
35
|
+
/** Collection information. */
|
|
36
|
+
interface CollectionInfo {
|
|
37
|
+
/** Collection name. */
|
|
38
|
+
name: string;
|
|
39
|
+
/** Vector dimension. */
|
|
40
|
+
dimension: number;
|
|
41
|
+
/** Distance metric. */
|
|
42
|
+
metric: string;
|
|
43
|
+
/** Number of vectors in the collection. */
|
|
44
|
+
count: number;
|
|
45
|
+
}
|
|
46
|
+
/** A point (vector with metadata) to insert. */
|
|
47
|
+
interface PointInput {
|
|
48
|
+
/** Unique point identifier. */
|
|
49
|
+
id: number;
|
|
50
|
+
/** Vector data (must match collection dimension). */
|
|
51
|
+
vector: number[];
|
|
52
|
+
/** Optional JSON payload with metadata. */
|
|
53
|
+
payload?: Record<string, unknown>;
|
|
54
|
+
}
|
|
55
|
+
/** Request to upsert points. */
|
|
56
|
+
interface UpsertRequest {
|
|
57
|
+
/** Target collection name. */
|
|
58
|
+
collection: string;
|
|
59
|
+
/** Points to insert or update. */
|
|
60
|
+
points: PointInput[];
|
|
61
|
+
}
|
|
62
|
+
/** Request for vector similarity search. */
|
|
63
|
+
interface SearchRequest {
|
|
64
|
+
/** Target collection name. */
|
|
65
|
+
collection: string;
|
|
66
|
+
/** Query vector. */
|
|
67
|
+
vector: number[];
|
|
68
|
+
/** Number of results to return. Default: 10. */
|
|
69
|
+
topK?: number;
|
|
70
|
+
}
|
|
71
|
+
/** Request for BM25 text search. */
|
|
72
|
+
interface TextSearchRequest {
|
|
73
|
+
/** Target collection name. */
|
|
74
|
+
collection: string;
|
|
75
|
+
/** Text query for BM25 search. */
|
|
76
|
+
query: string;
|
|
77
|
+
/** Number of results to return. Default: 10. */
|
|
78
|
+
topK?: number;
|
|
79
|
+
}
|
|
80
|
+
/** Request for hybrid (vector + text) search. */
|
|
81
|
+
interface HybridSearchRequest {
|
|
82
|
+
/** Target collection name. */
|
|
83
|
+
collection: string;
|
|
84
|
+
/** Query vector for similarity search. */
|
|
85
|
+
vector: number[];
|
|
86
|
+
/** Text query for BM25 search. */
|
|
87
|
+
query: string;
|
|
88
|
+
/** Number of results to return. Default: 10. */
|
|
89
|
+
topK?: number;
|
|
90
|
+
/** Weight for vector results (0.0-1.0). Default: 0.5. */
|
|
91
|
+
vectorWeight?: number;
|
|
92
|
+
}
|
|
93
|
+
/** Request for VelesQL query. */
|
|
94
|
+
interface QueryRequest {
|
|
95
|
+
/** VelesQL query string. */
|
|
96
|
+
query: string;
|
|
97
|
+
/** Query parameters (for parameterized queries). */
|
|
98
|
+
params?: Record<string, unknown>;
|
|
99
|
+
}
|
|
100
|
+
/** Search result item. */
|
|
101
|
+
interface SearchResult {
|
|
102
|
+
/** Point ID. */
|
|
103
|
+
id: number;
|
|
104
|
+
/** Similarity/distance score. */
|
|
105
|
+
score: number;
|
|
106
|
+
/** Point payload (if any). */
|
|
107
|
+
payload?: Record<string, unknown>;
|
|
108
|
+
}
|
|
109
|
+
/** Response from search operations. */
|
|
110
|
+
interface SearchResponse {
|
|
111
|
+
/** Search results ordered by relevance. */
|
|
112
|
+
results: SearchResult[];
|
|
113
|
+
/** Query execution time in milliseconds. */
|
|
114
|
+
timingMs: number;
|
|
115
|
+
}
|
|
116
|
+
/** Error returned by plugin commands. */
|
|
117
|
+
interface CommandError {
|
|
118
|
+
/** Human-readable error message. */
|
|
119
|
+
message: string;
|
|
120
|
+
/** Error code for programmatic handling. */
|
|
121
|
+
code: string;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Creates a new vector collection.
|
|
125
|
+
*
|
|
126
|
+
* @param request - Collection configuration
|
|
127
|
+
* @returns Collection info
|
|
128
|
+
* @throws {CommandError} If collection already exists or parameters are invalid
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* const info = await createCollection({
|
|
133
|
+
* name: 'documents',
|
|
134
|
+
* dimension: 768,
|
|
135
|
+
* metric: 'cosine'
|
|
136
|
+
* });
|
|
137
|
+
* console.log(`Created collection with ${info.count} vectors`);
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
declare function createCollection(request: CreateCollectionRequest): Promise<CollectionInfo>;
|
|
141
|
+
/**
|
|
142
|
+
* Deletes a collection and all its data.
|
|
143
|
+
*
|
|
144
|
+
* @param name - Collection name to delete
|
|
145
|
+
* @throws {CommandError} If collection doesn't exist
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* await deleteCollection('documents');
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
declare function deleteCollection(name: string): Promise<void>;
|
|
153
|
+
/**
|
|
154
|
+
* Lists all collections in the database.
|
|
155
|
+
*
|
|
156
|
+
* @returns Array of collection info objects
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```typescript
|
|
160
|
+
* const collections = await listCollections();
|
|
161
|
+
* collections.forEach(c => console.log(`${c.name}: ${c.count} vectors`));
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
declare function listCollections(): Promise<CollectionInfo[]>;
|
|
165
|
+
/**
|
|
166
|
+
* Gets information about a specific collection.
|
|
167
|
+
*
|
|
168
|
+
* @param name - Collection name
|
|
169
|
+
* @returns Collection info
|
|
170
|
+
* @throws {CommandError} If collection doesn't exist
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```typescript
|
|
174
|
+
* const info = await getCollection('documents');
|
|
175
|
+
* console.log(`Dimension: ${info.dimension}, Count: ${info.count}`);
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
declare function getCollection(name: string): Promise<CollectionInfo>;
|
|
179
|
+
/**
|
|
180
|
+
* Inserts or updates vectors in a collection.
|
|
181
|
+
*
|
|
182
|
+
* @param request - Upsert request with collection name and points
|
|
183
|
+
* @returns Number of points upserted
|
|
184
|
+
* @throws {CommandError} If collection doesn't exist or vectors are invalid
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```typescript
|
|
188
|
+
* const count = await upsert({
|
|
189
|
+
* collection: 'documents',
|
|
190
|
+
* points: [
|
|
191
|
+
* { id: 1, vector: [0.1, 0.2, ...], payload: { title: 'Doc 1' } },
|
|
192
|
+
* { id: 2, vector: [0.3, 0.4, ...], payload: { title: 'Doc 2' } }
|
|
193
|
+
* ]
|
|
194
|
+
* });
|
|
195
|
+
* console.log(`Upserted ${count} points`);
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
declare function upsert(request: UpsertRequest): Promise<number>;
|
|
199
|
+
/**
|
|
200
|
+
* Performs vector similarity search.
|
|
201
|
+
*
|
|
202
|
+
* @param request - Search request with query vector
|
|
203
|
+
* @returns Search response with results and timing
|
|
204
|
+
* @throws {CommandError} If collection doesn't exist or vector dimension mismatches
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```typescript
|
|
208
|
+
* const response = await search({
|
|
209
|
+
* collection: 'documents',
|
|
210
|
+
* vector: queryEmbedding,
|
|
211
|
+
* topK: 5
|
|
212
|
+
* });
|
|
213
|
+
* response.results.forEach(r => {
|
|
214
|
+
* console.log(`ID: ${r.id}, Score: ${r.score}, Title: ${r.payload?.title}`);
|
|
215
|
+
* });
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
declare function search(request: SearchRequest): Promise<SearchResponse>;
|
|
219
|
+
/**
|
|
220
|
+
* Performs BM25 full-text search across payloads.
|
|
221
|
+
*
|
|
222
|
+
* @param request - Text search request
|
|
223
|
+
* @returns Search response with results and timing
|
|
224
|
+
* @throws {CommandError} If collection doesn't exist
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* const response = await textSearch({
|
|
229
|
+
* collection: 'documents',
|
|
230
|
+
* query: 'machine learning tutorial',
|
|
231
|
+
* topK: 10
|
|
232
|
+
* });
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
declare function textSearch(request: TextSearchRequest): Promise<SearchResponse>;
|
|
236
|
+
/**
|
|
237
|
+
* Performs hybrid search combining vector similarity and BM25 text relevance.
|
|
238
|
+
* Uses Reciprocal Rank Fusion (RRF) to merge results.
|
|
239
|
+
*
|
|
240
|
+
* @param request - Hybrid search request
|
|
241
|
+
* @returns Search response with fused results and timing
|
|
242
|
+
* @throws {CommandError} If collection doesn't exist or parameters are invalid
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* ```typescript
|
|
246
|
+
* const response = await hybridSearch({
|
|
247
|
+
* collection: 'documents',
|
|
248
|
+
* vector: queryEmbedding,
|
|
249
|
+
* query: 'neural networks',
|
|
250
|
+
* topK: 10,
|
|
251
|
+
* vectorWeight: 0.7 // 70% vector, 30% text
|
|
252
|
+
* });
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
declare function hybridSearch(request: HybridSearchRequest): Promise<SearchResponse>;
|
|
256
|
+
/**
|
|
257
|
+
* Executes a VelesQL query.
|
|
258
|
+
*
|
|
259
|
+
* @param request - Query request with VelesQL string
|
|
260
|
+
* @returns Search response with results and timing
|
|
261
|
+
* @throws {CommandError} If query syntax is invalid or collection doesn't exist
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```typescript
|
|
265
|
+
* const response = await query({
|
|
266
|
+
* query: "SELECT * FROM documents WHERE content MATCH 'rust programming' LIMIT 10",
|
|
267
|
+
* params: {}
|
|
268
|
+
* });
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
declare function query(request: QueryRequest): Promise<SearchResponse>;
|
|
272
|
+
|
|
273
|
+
export { type CollectionInfo, type CommandError, type CreateCollectionRequest, type DistanceMetric, type HybridSearchRequest, type PointInput, type QueryRequest, type SearchRequest, type SearchResponse, type SearchResult, type TextSearchRequest, type UpsertRequest, createCollection, deleteCollection, getCollection, hybridSearch, listCollections, query, search, textSearch, upsert };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module tauri-plugin-velesdb
|
|
3
|
+
*
|
|
4
|
+
* TypeScript bindings for the VelesDB Tauri plugin.
|
|
5
|
+
* Provides type-safe access to vector database operations in desktop apps.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { createCollection, search, upsert } from 'tauri-plugin-velesdb';
|
|
10
|
+
*
|
|
11
|
+
* // Create a collection
|
|
12
|
+
* await createCollection({ name: 'docs', dimension: 768, metric: 'cosine' });
|
|
13
|
+
*
|
|
14
|
+
* // Insert vectors
|
|
15
|
+
* await upsert({
|
|
16
|
+
* collection: 'docs',
|
|
17
|
+
* points: [{ id: 1, vector: [...], payload: { title: 'Doc' } }]
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* // Search
|
|
21
|
+
* const results = await search({ collection: 'docs', vector: [...], topK: 10 });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
/** Distance metric for vector similarity. */
|
|
25
|
+
type DistanceMetric = 'cosine' | 'euclidean' | 'dot' | 'hamming' | 'jaccard';
|
|
26
|
+
/** Request to create a new collection. */
|
|
27
|
+
interface CreateCollectionRequest {
|
|
28
|
+
/** Collection name (unique identifier). */
|
|
29
|
+
name: string;
|
|
30
|
+
/** Vector dimension (e.g., 768 for BERT, 1536 for GPT). */
|
|
31
|
+
dimension: number;
|
|
32
|
+
/** Distance metric for similarity calculations. Default: 'cosine'. */
|
|
33
|
+
metric?: DistanceMetric;
|
|
34
|
+
}
|
|
35
|
+
/** Collection information. */
|
|
36
|
+
interface CollectionInfo {
|
|
37
|
+
/** Collection name. */
|
|
38
|
+
name: string;
|
|
39
|
+
/** Vector dimension. */
|
|
40
|
+
dimension: number;
|
|
41
|
+
/** Distance metric. */
|
|
42
|
+
metric: string;
|
|
43
|
+
/** Number of vectors in the collection. */
|
|
44
|
+
count: number;
|
|
45
|
+
}
|
|
46
|
+
/** A point (vector with metadata) to insert. */
|
|
47
|
+
interface PointInput {
|
|
48
|
+
/** Unique point identifier. */
|
|
49
|
+
id: number;
|
|
50
|
+
/** Vector data (must match collection dimension). */
|
|
51
|
+
vector: number[];
|
|
52
|
+
/** Optional JSON payload with metadata. */
|
|
53
|
+
payload?: Record<string, unknown>;
|
|
54
|
+
}
|
|
55
|
+
/** Request to upsert points. */
|
|
56
|
+
interface UpsertRequest {
|
|
57
|
+
/** Target collection name. */
|
|
58
|
+
collection: string;
|
|
59
|
+
/** Points to insert or update. */
|
|
60
|
+
points: PointInput[];
|
|
61
|
+
}
|
|
62
|
+
/** Request for vector similarity search. */
|
|
63
|
+
interface SearchRequest {
|
|
64
|
+
/** Target collection name. */
|
|
65
|
+
collection: string;
|
|
66
|
+
/** Query vector. */
|
|
67
|
+
vector: number[];
|
|
68
|
+
/** Number of results to return. Default: 10. */
|
|
69
|
+
topK?: number;
|
|
70
|
+
}
|
|
71
|
+
/** Request for BM25 text search. */
|
|
72
|
+
interface TextSearchRequest {
|
|
73
|
+
/** Target collection name. */
|
|
74
|
+
collection: string;
|
|
75
|
+
/** Text query for BM25 search. */
|
|
76
|
+
query: string;
|
|
77
|
+
/** Number of results to return. Default: 10. */
|
|
78
|
+
topK?: number;
|
|
79
|
+
}
|
|
80
|
+
/** Request for hybrid (vector + text) search. */
|
|
81
|
+
interface HybridSearchRequest {
|
|
82
|
+
/** Target collection name. */
|
|
83
|
+
collection: string;
|
|
84
|
+
/** Query vector for similarity search. */
|
|
85
|
+
vector: number[];
|
|
86
|
+
/** Text query for BM25 search. */
|
|
87
|
+
query: string;
|
|
88
|
+
/** Number of results to return. Default: 10. */
|
|
89
|
+
topK?: number;
|
|
90
|
+
/** Weight for vector results (0.0-1.0). Default: 0.5. */
|
|
91
|
+
vectorWeight?: number;
|
|
92
|
+
}
|
|
93
|
+
/** Request for VelesQL query. */
|
|
94
|
+
interface QueryRequest {
|
|
95
|
+
/** VelesQL query string. */
|
|
96
|
+
query: string;
|
|
97
|
+
/** Query parameters (for parameterized queries). */
|
|
98
|
+
params?: Record<string, unknown>;
|
|
99
|
+
}
|
|
100
|
+
/** Search result item. */
|
|
101
|
+
interface SearchResult {
|
|
102
|
+
/** Point ID. */
|
|
103
|
+
id: number;
|
|
104
|
+
/** Similarity/distance score. */
|
|
105
|
+
score: number;
|
|
106
|
+
/** Point payload (if any). */
|
|
107
|
+
payload?: Record<string, unknown>;
|
|
108
|
+
}
|
|
109
|
+
/** Response from search operations. */
|
|
110
|
+
interface SearchResponse {
|
|
111
|
+
/** Search results ordered by relevance. */
|
|
112
|
+
results: SearchResult[];
|
|
113
|
+
/** Query execution time in milliseconds. */
|
|
114
|
+
timingMs: number;
|
|
115
|
+
}
|
|
116
|
+
/** Error returned by plugin commands. */
|
|
117
|
+
interface CommandError {
|
|
118
|
+
/** Human-readable error message. */
|
|
119
|
+
message: string;
|
|
120
|
+
/** Error code for programmatic handling. */
|
|
121
|
+
code: string;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Creates a new vector collection.
|
|
125
|
+
*
|
|
126
|
+
* @param request - Collection configuration
|
|
127
|
+
* @returns Collection info
|
|
128
|
+
* @throws {CommandError} If collection already exists or parameters are invalid
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* const info = await createCollection({
|
|
133
|
+
* name: 'documents',
|
|
134
|
+
* dimension: 768,
|
|
135
|
+
* metric: 'cosine'
|
|
136
|
+
* });
|
|
137
|
+
* console.log(`Created collection with ${info.count} vectors`);
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
declare function createCollection(request: CreateCollectionRequest): Promise<CollectionInfo>;
|
|
141
|
+
/**
|
|
142
|
+
* Deletes a collection and all its data.
|
|
143
|
+
*
|
|
144
|
+
* @param name - Collection name to delete
|
|
145
|
+
* @throws {CommandError} If collection doesn't exist
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* await deleteCollection('documents');
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
declare function deleteCollection(name: string): Promise<void>;
|
|
153
|
+
/**
|
|
154
|
+
* Lists all collections in the database.
|
|
155
|
+
*
|
|
156
|
+
* @returns Array of collection info objects
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```typescript
|
|
160
|
+
* const collections = await listCollections();
|
|
161
|
+
* collections.forEach(c => console.log(`${c.name}: ${c.count} vectors`));
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
declare function listCollections(): Promise<CollectionInfo[]>;
|
|
165
|
+
/**
|
|
166
|
+
* Gets information about a specific collection.
|
|
167
|
+
*
|
|
168
|
+
* @param name - Collection name
|
|
169
|
+
* @returns Collection info
|
|
170
|
+
* @throws {CommandError} If collection doesn't exist
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```typescript
|
|
174
|
+
* const info = await getCollection('documents');
|
|
175
|
+
* console.log(`Dimension: ${info.dimension}, Count: ${info.count}`);
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
declare function getCollection(name: string): Promise<CollectionInfo>;
|
|
179
|
+
/**
|
|
180
|
+
* Inserts or updates vectors in a collection.
|
|
181
|
+
*
|
|
182
|
+
* @param request - Upsert request with collection name and points
|
|
183
|
+
* @returns Number of points upserted
|
|
184
|
+
* @throws {CommandError} If collection doesn't exist or vectors are invalid
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```typescript
|
|
188
|
+
* const count = await upsert({
|
|
189
|
+
* collection: 'documents',
|
|
190
|
+
* points: [
|
|
191
|
+
* { id: 1, vector: [0.1, 0.2, ...], payload: { title: 'Doc 1' } },
|
|
192
|
+
* { id: 2, vector: [0.3, 0.4, ...], payload: { title: 'Doc 2' } }
|
|
193
|
+
* ]
|
|
194
|
+
* });
|
|
195
|
+
* console.log(`Upserted ${count} points`);
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
declare function upsert(request: UpsertRequest): Promise<number>;
|
|
199
|
+
/**
|
|
200
|
+
* Performs vector similarity search.
|
|
201
|
+
*
|
|
202
|
+
* @param request - Search request with query vector
|
|
203
|
+
* @returns Search response with results and timing
|
|
204
|
+
* @throws {CommandError} If collection doesn't exist or vector dimension mismatches
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```typescript
|
|
208
|
+
* const response = await search({
|
|
209
|
+
* collection: 'documents',
|
|
210
|
+
* vector: queryEmbedding,
|
|
211
|
+
* topK: 5
|
|
212
|
+
* });
|
|
213
|
+
* response.results.forEach(r => {
|
|
214
|
+
* console.log(`ID: ${r.id}, Score: ${r.score}, Title: ${r.payload?.title}`);
|
|
215
|
+
* });
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
declare function search(request: SearchRequest): Promise<SearchResponse>;
|
|
219
|
+
/**
|
|
220
|
+
* Performs BM25 full-text search across payloads.
|
|
221
|
+
*
|
|
222
|
+
* @param request - Text search request
|
|
223
|
+
* @returns Search response with results and timing
|
|
224
|
+
* @throws {CommandError} If collection doesn't exist
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* const response = await textSearch({
|
|
229
|
+
* collection: 'documents',
|
|
230
|
+
* query: 'machine learning tutorial',
|
|
231
|
+
* topK: 10
|
|
232
|
+
* });
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
declare function textSearch(request: TextSearchRequest): Promise<SearchResponse>;
|
|
236
|
+
/**
|
|
237
|
+
* Performs hybrid search combining vector similarity and BM25 text relevance.
|
|
238
|
+
* Uses Reciprocal Rank Fusion (RRF) to merge results.
|
|
239
|
+
*
|
|
240
|
+
* @param request - Hybrid search request
|
|
241
|
+
* @returns Search response with fused results and timing
|
|
242
|
+
* @throws {CommandError} If collection doesn't exist or parameters are invalid
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* ```typescript
|
|
246
|
+
* const response = await hybridSearch({
|
|
247
|
+
* collection: 'documents',
|
|
248
|
+
* vector: queryEmbedding,
|
|
249
|
+
* query: 'neural networks',
|
|
250
|
+
* topK: 10,
|
|
251
|
+
* vectorWeight: 0.7 // 70% vector, 30% text
|
|
252
|
+
* });
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
declare function hybridSearch(request: HybridSearchRequest): Promise<SearchResponse>;
|
|
256
|
+
/**
|
|
257
|
+
* Executes a VelesQL query.
|
|
258
|
+
*
|
|
259
|
+
* @param request - Query request with VelesQL string
|
|
260
|
+
* @returns Search response with results and timing
|
|
261
|
+
* @throws {CommandError} If query syntax is invalid or collection doesn't exist
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```typescript
|
|
265
|
+
* const response = await query({
|
|
266
|
+
* query: "SELECT * FROM documents WHERE content MATCH 'rust programming' LIMIT 10",
|
|
267
|
+
* params: {}
|
|
268
|
+
* });
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
declare function query(request: QueryRequest): Promise<SearchResponse>;
|
|
272
|
+
|
|
273
|
+
export { type CollectionInfo, type CommandError, type CreateCollectionRequest, type DistanceMetric, type HybridSearchRequest, type PointInput, type QueryRequest, type SearchRequest, type SearchResponse, type SearchResult, type TextSearchRequest, type UpsertRequest, createCollection, deleteCollection, getCollection, hybridSearch, listCollections, query, search, textSearch, upsert };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
createCollection: () => createCollection,
|
|
24
|
+
deleteCollection: () => deleteCollection,
|
|
25
|
+
getCollection: () => getCollection,
|
|
26
|
+
hybridSearch: () => hybridSearch,
|
|
27
|
+
listCollections: () => listCollections,
|
|
28
|
+
query: () => query,
|
|
29
|
+
search: () => search,
|
|
30
|
+
textSearch: () => textSearch,
|
|
31
|
+
upsert: () => upsert
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(index_exports);
|
|
34
|
+
var import_core = require("@tauri-apps/api/core");
|
|
35
|
+
async function createCollection(request) {
|
|
36
|
+
return (0, import_core.invoke)("plugin:velesdb|create_collection", { request });
|
|
37
|
+
}
|
|
38
|
+
async function deleteCollection(name) {
|
|
39
|
+
return (0, import_core.invoke)("plugin:velesdb|delete_collection", { name });
|
|
40
|
+
}
|
|
41
|
+
async function listCollections() {
|
|
42
|
+
return (0, import_core.invoke)("plugin:velesdb|list_collections");
|
|
43
|
+
}
|
|
44
|
+
async function getCollection(name) {
|
|
45
|
+
return (0, import_core.invoke)("plugin:velesdb|get_collection", { name });
|
|
46
|
+
}
|
|
47
|
+
async function upsert(request) {
|
|
48
|
+
return (0, import_core.invoke)("plugin:velesdb|upsert", { request });
|
|
49
|
+
}
|
|
50
|
+
async function search(request) {
|
|
51
|
+
return (0, import_core.invoke)("plugin:velesdb|search", { request });
|
|
52
|
+
}
|
|
53
|
+
async function textSearch(request) {
|
|
54
|
+
return (0, import_core.invoke)("plugin:velesdb|text_search", { request });
|
|
55
|
+
}
|
|
56
|
+
async function hybridSearch(request) {
|
|
57
|
+
return (0, import_core.invoke)("plugin:velesdb|hybrid_search", { request });
|
|
58
|
+
}
|
|
59
|
+
async function query(request) {
|
|
60
|
+
return (0, import_core.invoke)("plugin:velesdb|query", { request });
|
|
61
|
+
}
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 && (module.exports = {
|
|
64
|
+
createCollection,
|
|
65
|
+
deleteCollection,
|
|
66
|
+
getCollection,
|
|
67
|
+
hybridSearch,
|
|
68
|
+
listCollections,
|
|
69
|
+
query,
|
|
70
|
+
search,
|
|
71
|
+
textSearch,
|
|
72
|
+
upsert
|
|
73
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// index.ts
|
|
2
|
+
import { invoke } from "@tauri-apps/api/core";
|
|
3
|
+
async function createCollection(request) {
|
|
4
|
+
return invoke("plugin:velesdb|create_collection", { request });
|
|
5
|
+
}
|
|
6
|
+
async function deleteCollection(name) {
|
|
7
|
+
return invoke("plugin:velesdb|delete_collection", { name });
|
|
8
|
+
}
|
|
9
|
+
async function listCollections() {
|
|
10
|
+
return invoke("plugin:velesdb|list_collections");
|
|
11
|
+
}
|
|
12
|
+
async function getCollection(name) {
|
|
13
|
+
return invoke("plugin:velesdb|get_collection", { name });
|
|
14
|
+
}
|
|
15
|
+
async function upsert(request) {
|
|
16
|
+
return invoke("plugin:velesdb|upsert", { request });
|
|
17
|
+
}
|
|
18
|
+
async function search(request) {
|
|
19
|
+
return invoke("plugin:velesdb|search", { request });
|
|
20
|
+
}
|
|
21
|
+
async function textSearch(request) {
|
|
22
|
+
return invoke("plugin:velesdb|text_search", { request });
|
|
23
|
+
}
|
|
24
|
+
async function hybridSearch(request) {
|
|
25
|
+
return invoke("plugin:velesdb|hybrid_search", { request });
|
|
26
|
+
}
|
|
27
|
+
async function query(request) {
|
|
28
|
+
return invoke("plugin:velesdb|query", { request });
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
createCollection,
|
|
32
|
+
deleteCollection,
|
|
33
|
+
getCollection,
|
|
34
|
+
hybridSearch,
|
|
35
|
+
listCollections,
|
|
36
|
+
query,
|
|
37
|
+
search,
|
|
38
|
+
textSearch,
|
|
39
|
+
upsert
|
|
40
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wiscale/tauri-plugin-velesdb",
|
|
3
|
+
"version": "0.5.1",
|
|
4
|
+
"description": "TypeScript bindings for the VelesDB Tauri plugin - Vector search in desktop apps",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsup index.ts --format cjs,esm --dts",
|
|
21
|
+
"lint": "eslint index.ts",
|
|
22
|
+
"typecheck": "tsc --noEmit"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"tauri",
|
|
26
|
+
"plugin",
|
|
27
|
+
"velesdb",
|
|
28
|
+
"vector",
|
|
29
|
+
"database",
|
|
30
|
+
"search",
|
|
31
|
+
"embeddings",
|
|
32
|
+
"ai",
|
|
33
|
+
"desktop"
|
|
34
|
+
],
|
|
35
|
+
"author": "Cyberlife Coder",
|
|
36
|
+
"license": "Elastic-2.0",
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://github.com/cyberlife-coder/VelesDB.git",
|
|
40
|
+
"directory": "integrations/tauri-plugin-velesdb/guest-js"
|
|
41
|
+
},
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/cyberlife-coder/VelesDB/issues"
|
|
44
|
+
},
|
|
45
|
+
"homepage": "https://velesdb.com",
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"@tauri-apps/api": ">=2.0.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@tauri-apps/api": "^2.0.0",
|
|
51
|
+
"tsup": "^8.0.0",
|
|
52
|
+
"typescript": "^5.3.0"
|
|
53
|
+
}
|
|
54
|
+
}
|