@ruvector/node 0.1.18 → 0.1.23
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 +34 -52
- package/README.md +0 -1085
- package/index.d.ts +0 -345
- package/index.js +0 -321
package/index.d.ts
DELETED
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
|
|
4
|
-
/* auto-generated by NAPI-RS */
|
|
5
|
-
|
|
6
|
-
/** Distance metric for similarity calculation */
|
|
7
|
-
export const enum JsDistanceMetric {
|
|
8
|
-
/** Euclidean (L2) distance */
|
|
9
|
-
Euclidean = 'Euclidean',
|
|
10
|
-
/** Cosine similarity (converted to distance) */
|
|
11
|
-
Cosine = 'Cosine',
|
|
12
|
-
/** Dot product (converted to distance for maximization) */
|
|
13
|
-
DotProduct = 'DotProduct',
|
|
14
|
-
/** Manhattan (L1) distance */
|
|
15
|
-
Manhattan = 'Manhattan'
|
|
16
|
-
}
|
|
17
|
-
/** Quantization configuration */
|
|
18
|
-
export interface JsQuantizationConfig {
|
|
19
|
-
/** Quantization type: "none", "scalar", "product", "binary" */
|
|
20
|
-
type: string
|
|
21
|
-
/** Number of subspaces (for product quantization) */
|
|
22
|
-
subspaces?: number
|
|
23
|
-
/** Codebook size (for product quantization) */
|
|
24
|
-
k?: number
|
|
25
|
-
}
|
|
26
|
-
/** HNSW index configuration */
|
|
27
|
-
export interface JsHnswConfig {
|
|
28
|
-
/** Number of connections per layer (M) */
|
|
29
|
-
m?: number
|
|
30
|
-
/** Size of dynamic candidate list during construction */
|
|
31
|
-
efConstruction?: number
|
|
32
|
-
/** Size of dynamic candidate list during search */
|
|
33
|
-
efSearch?: number
|
|
34
|
-
/** Maximum number of elements */
|
|
35
|
-
maxElements?: number
|
|
36
|
-
}
|
|
37
|
-
/** Database configuration options */
|
|
38
|
-
export interface JsDbOptions {
|
|
39
|
-
/** Vector dimensions */
|
|
40
|
-
dimensions: number
|
|
41
|
-
/** Distance metric */
|
|
42
|
-
distanceMetric?: JsDistanceMetric
|
|
43
|
-
/** Storage path */
|
|
44
|
-
storagePath?: string
|
|
45
|
-
/** HNSW configuration */
|
|
46
|
-
hnswConfig?: JsHnswConfig
|
|
47
|
-
/** Quantization configuration */
|
|
48
|
-
quantization?: JsQuantizationConfig
|
|
49
|
-
}
|
|
50
|
-
/** Vector entry */
|
|
51
|
-
export interface JsVectorEntry {
|
|
52
|
-
/** Optional ID (auto-generated if not provided) */
|
|
53
|
-
id?: string
|
|
54
|
-
/** Vector data as Float32Array or array of numbers */
|
|
55
|
-
vector: Float32Array
|
|
56
|
-
}
|
|
57
|
-
/** Search query parameters */
|
|
58
|
-
export interface JsSearchQuery {
|
|
59
|
-
/** Query vector as Float32Array or array of numbers */
|
|
60
|
-
vector: Float32Array
|
|
61
|
-
/** Number of results to return (top-k) */
|
|
62
|
-
k: number
|
|
63
|
-
/** Optional ef_search parameter for HNSW */
|
|
64
|
-
efSearch?: number
|
|
65
|
-
}
|
|
66
|
-
/** Search result with similarity score */
|
|
67
|
-
export interface JsSearchResult {
|
|
68
|
-
/** Vector ID */
|
|
69
|
-
id: string
|
|
70
|
-
/** Distance/similarity score (lower is better for distance metrics) */
|
|
71
|
-
score: number
|
|
72
|
-
}
|
|
73
|
-
/** Get the version of the Ruvector library */
|
|
74
|
-
export declare function version(): string
|
|
75
|
-
/** Test function to verify the bindings are working */
|
|
76
|
-
export declare function hello(): string
|
|
77
|
-
/** Filter for metadata-based search */
|
|
78
|
-
export interface JsFilter {
|
|
79
|
-
/** Field name to filter on */
|
|
80
|
-
field: string
|
|
81
|
-
/** Operator: "eq", "ne", "gt", "gte", "lt", "lte", "in", "match" */
|
|
82
|
-
operator: string
|
|
83
|
-
/** Value to compare against (JSON string) */
|
|
84
|
-
value: string
|
|
85
|
-
}
|
|
86
|
-
/** Collection configuration */
|
|
87
|
-
export interface JsCollectionConfig {
|
|
88
|
-
/** Vector dimensions */
|
|
89
|
-
dimensions: number
|
|
90
|
-
/** Distance metric */
|
|
91
|
-
distanceMetric?: JsDistanceMetric
|
|
92
|
-
/** HNSW configuration */
|
|
93
|
-
hnswConfig?: JsHnswConfig
|
|
94
|
-
/** Quantization configuration */
|
|
95
|
-
quantization?: JsQuantizationConfig
|
|
96
|
-
}
|
|
97
|
-
/** Collection statistics */
|
|
98
|
-
export interface JsCollectionStats {
|
|
99
|
-
/** Number of vectors in the collection */
|
|
100
|
-
vectorsCount: number
|
|
101
|
-
/** Disk space used in bytes */
|
|
102
|
-
diskSizeBytes: number
|
|
103
|
-
/** RAM space used in bytes */
|
|
104
|
-
ramSizeBytes: number
|
|
105
|
-
}
|
|
106
|
-
/** Collection alias */
|
|
107
|
-
export interface JsAlias {
|
|
108
|
-
/** Alias name */
|
|
109
|
-
alias: string
|
|
110
|
-
/** Collection name */
|
|
111
|
-
collection: string
|
|
112
|
-
}
|
|
113
|
-
/** Health response */
|
|
114
|
-
export interface JsHealthResponse {
|
|
115
|
-
/** Status: "healthy", "degraded", or "unhealthy" */
|
|
116
|
-
status: string
|
|
117
|
-
/** Version string */
|
|
118
|
-
version: string
|
|
119
|
-
/** Uptime in seconds */
|
|
120
|
-
uptimeSeconds: number
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Get Prometheus metrics
|
|
124
|
-
*
|
|
125
|
-
* # Example
|
|
126
|
-
* ```javascript
|
|
127
|
-
* const metrics = getMetrics();
|
|
128
|
-
* console.log(metrics);
|
|
129
|
-
* ```
|
|
130
|
-
*/
|
|
131
|
-
export declare function getMetrics(): string
|
|
132
|
-
/**
|
|
133
|
-
* Get health status
|
|
134
|
-
*
|
|
135
|
-
* # Example
|
|
136
|
-
* ```javascript
|
|
137
|
-
* const health = getHealth();
|
|
138
|
-
* console.log(`Status: ${health.status}`);
|
|
139
|
-
* console.log(`Uptime: ${health.uptimeSeconds}s`);
|
|
140
|
-
* ```
|
|
141
|
-
*/
|
|
142
|
-
export declare function getHealth(): JsHealthResponse
|
|
143
|
-
export type VectorDB = VectorDb
|
|
144
|
-
/** High-performance vector database with HNSW indexing */
|
|
145
|
-
export declare class VectorDb {
|
|
146
|
-
/**
|
|
147
|
-
* Create a new vector database with the given options
|
|
148
|
-
*
|
|
149
|
-
* # Example
|
|
150
|
-
* ```javascript
|
|
151
|
-
* const db = new VectorDB({
|
|
152
|
-
* dimensions: 384,
|
|
153
|
-
* distanceMetric: 'Cosine',
|
|
154
|
-
* storagePath: './vectors.db',
|
|
155
|
-
* hnswConfig: {
|
|
156
|
-
* m: 32,
|
|
157
|
-
* efConstruction: 200,
|
|
158
|
-
* efSearch: 100
|
|
159
|
-
* }
|
|
160
|
-
* });
|
|
161
|
-
* ```
|
|
162
|
-
*/
|
|
163
|
-
constructor(options: JsDbOptions)
|
|
164
|
-
/**
|
|
165
|
-
* Create a vector database with default options
|
|
166
|
-
*
|
|
167
|
-
* # Example
|
|
168
|
-
* ```javascript
|
|
169
|
-
* const db = VectorDB.withDimensions(384);
|
|
170
|
-
* ```
|
|
171
|
-
*/
|
|
172
|
-
static withDimensions(dimensions: number): VectorDb
|
|
173
|
-
/**
|
|
174
|
-
* Insert a vector entry into the database
|
|
175
|
-
*
|
|
176
|
-
* Returns the ID of the inserted vector (auto-generated if not provided)
|
|
177
|
-
*
|
|
178
|
-
* # Example
|
|
179
|
-
* ```javascript
|
|
180
|
-
* const id = await db.insert({
|
|
181
|
-
* vector: new Float32Array([1.0, 2.0, 3.0]),
|
|
182
|
-
* metadata: { text: 'example' }
|
|
183
|
-
* });
|
|
184
|
-
* ```
|
|
185
|
-
*/
|
|
186
|
-
insert(entry: JsVectorEntry): Promise<string>
|
|
187
|
-
/**
|
|
188
|
-
* Insert multiple vectors in a batch
|
|
189
|
-
*
|
|
190
|
-
* Returns an array of IDs for the inserted vectors
|
|
191
|
-
*
|
|
192
|
-
* # Example
|
|
193
|
-
* ```javascript
|
|
194
|
-
* const ids = await db.insertBatch([
|
|
195
|
-
* { vector: new Float32Array([1, 2, 3]) },
|
|
196
|
-
* { vector: new Float32Array([4, 5, 6]) }
|
|
197
|
-
* ]);
|
|
198
|
-
* ```
|
|
199
|
-
*/
|
|
200
|
-
insertBatch(entries: Array<JsVectorEntry>): Promise<Array<string>>
|
|
201
|
-
/**
|
|
202
|
-
* Search for similar vectors
|
|
203
|
-
*
|
|
204
|
-
* Returns an array of search results sorted by similarity
|
|
205
|
-
*
|
|
206
|
-
* # Example
|
|
207
|
-
* ```javascript
|
|
208
|
-
* const results = await db.search({
|
|
209
|
-
* vector: new Float32Array([1, 2, 3]),
|
|
210
|
-
* k: 10,
|
|
211
|
-
* filter: { category: 'example' }
|
|
212
|
-
* });
|
|
213
|
-
* ```
|
|
214
|
-
*/
|
|
215
|
-
search(query: JsSearchQuery): Promise<Array<JsSearchResult>>
|
|
216
|
-
/**
|
|
217
|
-
* Delete a vector by ID
|
|
218
|
-
*
|
|
219
|
-
* Returns true if the vector was deleted, false if not found
|
|
220
|
-
*
|
|
221
|
-
* # Example
|
|
222
|
-
* ```javascript
|
|
223
|
-
* const deleted = await db.delete('vector-id');
|
|
224
|
-
* ```
|
|
225
|
-
*/
|
|
226
|
-
delete(id: string): Promise<boolean>
|
|
227
|
-
/**
|
|
228
|
-
* Get a vector by ID
|
|
229
|
-
*
|
|
230
|
-
* Returns the vector entry if found, null otherwise
|
|
231
|
-
*
|
|
232
|
-
* # Example
|
|
233
|
-
* ```javascript
|
|
234
|
-
* const entry = await db.get('vector-id');
|
|
235
|
-
* if (entry) {
|
|
236
|
-
* console.log('Found:', entry.metadata);
|
|
237
|
-
* }
|
|
238
|
-
* ```
|
|
239
|
-
*/
|
|
240
|
-
get(id: string): Promise<JsVectorEntry | null>
|
|
241
|
-
/**
|
|
242
|
-
* Get the number of vectors in the database
|
|
243
|
-
*
|
|
244
|
-
* # Example
|
|
245
|
-
* ```javascript
|
|
246
|
-
* const count = await db.len();
|
|
247
|
-
* console.log(`Database contains ${count} vectors`);
|
|
248
|
-
* ```
|
|
249
|
-
*/
|
|
250
|
-
len(): Promise<number>
|
|
251
|
-
/**
|
|
252
|
-
* Check if the database is empty
|
|
253
|
-
*
|
|
254
|
-
* # Example
|
|
255
|
-
* ```javascript
|
|
256
|
-
* if (await db.isEmpty()) {
|
|
257
|
-
* console.log('Database is empty');
|
|
258
|
-
* }
|
|
259
|
-
* ```
|
|
260
|
-
*/
|
|
261
|
-
isEmpty(): Promise<boolean>
|
|
262
|
-
}
|
|
263
|
-
/** Collection manager for multi-collection support */
|
|
264
|
-
export declare class CollectionManager {
|
|
265
|
-
/**
|
|
266
|
-
* Create a new collection manager
|
|
267
|
-
*
|
|
268
|
-
* # Example
|
|
269
|
-
* ```javascript
|
|
270
|
-
* const manager = new CollectionManager('./collections');
|
|
271
|
-
* ```
|
|
272
|
-
*/
|
|
273
|
-
constructor(basePath?: string | undefined | null)
|
|
274
|
-
/**
|
|
275
|
-
* Create a new collection
|
|
276
|
-
*
|
|
277
|
-
* # Example
|
|
278
|
-
* ```javascript
|
|
279
|
-
* await manager.createCollection('my_vectors', {
|
|
280
|
-
* dimensions: 384,
|
|
281
|
-
* distanceMetric: 'Cosine'
|
|
282
|
-
* });
|
|
283
|
-
* ```
|
|
284
|
-
*/
|
|
285
|
-
createCollection(name: string, config: JsCollectionConfig): Promise<void>
|
|
286
|
-
/**
|
|
287
|
-
* List all collections
|
|
288
|
-
*
|
|
289
|
-
* # Example
|
|
290
|
-
* ```javascript
|
|
291
|
-
* const collections = await manager.listCollections();
|
|
292
|
-
* console.log('Collections:', collections);
|
|
293
|
-
* ```
|
|
294
|
-
*/
|
|
295
|
-
listCollections(): Promise<Array<string>>
|
|
296
|
-
/**
|
|
297
|
-
* Delete a collection
|
|
298
|
-
*
|
|
299
|
-
* # Example
|
|
300
|
-
* ```javascript
|
|
301
|
-
* await manager.deleteCollection('my_vectors');
|
|
302
|
-
* ```
|
|
303
|
-
*/
|
|
304
|
-
deleteCollection(name: string): Promise<void>
|
|
305
|
-
/**
|
|
306
|
-
* Get collection statistics
|
|
307
|
-
*
|
|
308
|
-
* # Example
|
|
309
|
-
* ```javascript
|
|
310
|
-
* const stats = await manager.getStats('my_vectors');
|
|
311
|
-
* console.log(`Vectors: ${stats.vectorsCount}`);
|
|
312
|
-
* ```
|
|
313
|
-
*/
|
|
314
|
-
getStats(name: string): Promise<JsCollectionStats>
|
|
315
|
-
/**
|
|
316
|
-
* Create an alias for a collection
|
|
317
|
-
*
|
|
318
|
-
* # Example
|
|
319
|
-
* ```javascript
|
|
320
|
-
* await manager.createAlias('latest', 'my_vectors_v2');
|
|
321
|
-
* ```
|
|
322
|
-
*/
|
|
323
|
-
createAlias(alias: string, collection: string): Promise<void>
|
|
324
|
-
/**
|
|
325
|
-
* Delete an alias
|
|
326
|
-
*
|
|
327
|
-
* # Example
|
|
328
|
-
* ```javascript
|
|
329
|
-
* await manager.deleteAlias('latest');
|
|
330
|
-
* ```
|
|
331
|
-
*/
|
|
332
|
-
deleteAlias(alias: string): Promise<void>
|
|
333
|
-
/**
|
|
334
|
-
* List all aliases
|
|
335
|
-
*
|
|
336
|
-
* # Example
|
|
337
|
-
* ```javascript
|
|
338
|
-
* const aliases = await manager.listAliases();
|
|
339
|
-
* for (const alias of aliases) {
|
|
340
|
-
* console.log(`${alias.alias} -> ${alias.collection}`);
|
|
341
|
-
* }
|
|
342
|
-
* ```
|
|
343
|
-
*/
|
|
344
|
-
listAliases(): Promise<Array<JsAlias>>
|
|
345
|
-
}
|
package/index.js
DELETED
|
@@ -1,321 +0,0 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
/* prettier-ignore */
|
|
4
|
-
|
|
5
|
-
/* auto-generated by NAPI-RS */
|
|
6
|
-
|
|
7
|
-
const { existsSync, readFileSync } = require('fs')
|
|
8
|
-
const { join } = require('path')
|
|
9
|
-
|
|
10
|
-
const { platform, arch } = process
|
|
11
|
-
|
|
12
|
-
let nativeBinding = null
|
|
13
|
-
let localFileExisted = false
|
|
14
|
-
let loadError = null
|
|
15
|
-
|
|
16
|
-
function isMusl() {
|
|
17
|
-
// For Node 10
|
|
18
|
-
if (!process.report || typeof process.report.getReport !== 'function') {
|
|
19
|
-
try {
|
|
20
|
-
const lddPath = require('child_process').execSync('which ldd').toString().trim()
|
|
21
|
-
return readFileSync(lddPath, 'utf8').includes('musl')
|
|
22
|
-
} catch (e) {
|
|
23
|
-
return true
|
|
24
|
-
}
|
|
25
|
-
} else {
|
|
26
|
-
const { glibcVersionRuntime } = process.report.getReport().header
|
|
27
|
-
return !glibcVersionRuntime
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
switch (platform) {
|
|
32
|
-
case 'android':
|
|
33
|
-
switch (arch) {
|
|
34
|
-
case 'arm64':
|
|
35
|
-
localFileExisted = existsSync(join(__dirname, 'ruvector.android-arm64.node'))
|
|
36
|
-
try {
|
|
37
|
-
if (localFileExisted) {
|
|
38
|
-
nativeBinding = require('./ruvector.android-arm64.node')
|
|
39
|
-
} else {
|
|
40
|
-
nativeBinding = require('@ruvector/node-android-arm64')
|
|
41
|
-
}
|
|
42
|
-
} catch (e) {
|
|
43
|
-
loadError = e
|
|
44
|
-
}
|
|
45
|
-
break
|
|
46
|
-
case 'arm':
|
|
47
|
-
localFileExisted = existsSync(join(__dirname, 'ruvector.android-arm-eabi.node'))
|
|
48
|
-
try {
|
|
49
|
-
if (localFileExisted) {
|
|
50
|
-
nativeBinding = require('./ruvector.android-arm-eabi.node')
|
|
51
|
-
} else {
|
|
52
|
-
nativeBinding = require('@ruvector/node-android-arm-eabi')
|
|
53
|
-
}
|
|
54
|
-
} catch (e) {
|
|
55
|
-
loadError = e
|
|
56
|
-
}
|
|
57
|
-
break
|
|
58
|
-
default:
|
|
59
|
-
throw new Error(`Unsupported architecture on Android ${arch}`)
|
|
60
|
-
}
|
|
61
|
-
break
|
|
62
|
-
case 'win32':
|
|
63
|
-
switch (arch) {
|
|
64
|
-
case 'x64':
|
|
65
|
-
localFileExisted = existsSync(
|
|
66
|
-
join(__dirname, 'ruvector.win32-x64-msvc.node')
|
|
67
|
-
)
|
|
68
|
-
try {
|
|
69
|
-
if (localFileExisted) {
|
|
70
|
-
nativeBinding = require('./ruvector.win32-x64-msvc.node')
|
|
71
|
-
} else {
|
|
72
|
-
nativeBinding = require('@ruvector/node-win32-x64-msvc')
|
|
73
|
-
}
|
|
74
|
-
} catch (e) {
|
|
75
|
-
loadError = e
|
|
76
|
-
}
|
|
77
|
-
break
|
|
78
|
-
case 'ia32':
|
|
79
|
-
localFileExisted = existsSync(
|
|
80
|
-
join(__dirname, 'ruvector.win32-ia32-msvc.node')
|
|
81
|
-
)
|
|
82
|
-
try {
|
|
83
|
-
if (localFileExisted) {
|
|
84
|
-
nativeBinding = require('./ruvector.win32-ia32-msvc.node')
|
|
85
|
-
} else {
|
|
86
|
-
nativeBinding = require('@ruvector/node-win32-ia32-msvc')
|
|
87
|
-
}
|
|
88
|
-
} catch (e) {
|
|
89
|
-
loadError = e
|
|
90
|
-
}
|
|
91
|
-
break
|
|
92
|
-
case 'arm64':
|
|
93
|
-
localFileExisted = existsSync(
|
|
94
|
-
join(__dirname, 'ruvector.win32-arm64-msvc.node')
|
|
95
|
-
)
|
|
96
|
-
try {
|
|
97
|
-
if (localFileExisted) {
|
|
98
|
-
nativeBinding = require('./ruvector.win32-arm64-msvc.node')
|
|
99
|
-
} else {
|
|
100
|
-
nativeBinding = require('@ruvector/node-win32-arm64-msvc')
|
|
101
|
-
}
|
|
102
|
-
} catch (e) {
|
|
103
|
-
loadError = e
|
|
104
|
-
}
|
|
105
|
-
break
|
|
106
|
-
default:
|
|
107
|
-
throw new Error(`Unsupported architecture on Windows: ${arch}`)
|
|
108
|
-
}
|
|
109
|
-
break
|
|
110
|
-
case 'darwin':
|
|
111
|
-
localFileExisted = existsSync(join(__dirname, 'ruvector.darwin-universal.node'))
|
|
112
|
-
try {
|
|
113
|
-
if (localFileExisted) {
|
|
114
|
-
nativeBinding = require('./ruvector.darwin-universal.node')
|
|
115
|
-
} else {
|
|
116
|
-
nativeBinding = require('@ruvector/node-darwin-universal')
|
|
117
|
-
}
|
|
118
|
-
break
|
|
119
|
-
} catch {}
|
|
120
|
-
switch (arch) {
|
|
121
|
-
case 'x64':
|
|
122
|
-
localFileExisted = existsSync(join(__dirname, 'ruvector.darwin-x64.node'))
|
|
123
|
-
try {
|
|
124
|
-
if (localFileExisted) {
|
|
125
|
-
nativeBinding = require('./ruvector.darwin-x64.node')
|
|
126
|
-
} else {
|
|
127
|
-
nativeBinding = require('@ruvector/node-darwin-x64')
|
|
128
|
-
}
|
|
129
|
-
} catch (e) {
|
|
130
|
-
loadError = e
|
|
131
|
-
}
|
|
132
|
-
break
|
|
133
|
-
case 'arm64':
|
|
134
|
-
localFileExisted = existsSync(
|
|
135
|
-
join(__dirname, 'ruvector.darwin-arm64.node')
|
|
136
|
-
)
|
|
137
|
-
try {
|
|
138
|
-
if (localFileExisted) {
|
|
139
|
-
nativeBinding = require('./ruvector.darwin-arm64.node')
|
|
140
|
-
} else {
|
|
141
|
-
nativeBinding = require('@ruvector/node-darwin-arm64')
|
|
142
|
-
}
|
|
143
|
-
} catch (e) {
|
|
144
|
-
loadError = e
|
|
145
|
-
}
|
|
146
|
-
break
|
|
147
|
-
default:
|
|
148
|
-
throw new Error(`Unsupported architecture on macOS: ${arch}`)
|
|
149
|
-
}
|
|
150
|
-
break
|
|
151
|
-
case 'freebsd':
|
|
152
|
-
if (arch !== 'x64') {
|
|
153
|
-
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
|
|
154
|
-
}
|
|
155
|
-
localFileExisted = existsSync(join(__dirname, 'ruvector.freebsd-x64.node'))
|
|
156
|
-
try {
|
|
157
|
-
if (localFileExisted) {
|
|
158
|
-
nativeBinding = require('./ruvector.freebsd-x64.node')
|
|
159
|
-
} else {
|
|
160
|
-
nativeBinding = require('@ruvector/node-freebsd-x64')
|
|
161
|
-
}
|
|
162
|
-
} catch (e) {
|
|
163
|
-
loadError = e
|
|
164
|
-
}
|
|
165
|
-
break
|
|
166
|
-
case 'linux':
|
|
167
|
-
switch (arch) {
|
|
168
|
-
case 'x64':
|
|
169
|
-
if (isMusl()) {
|
|
170
|
-
localFileExisted = existsSync(
|
|
171
|
-
join(__dirname, 'ruvector.linux-x64-musl.node')
|
|
172
|
-
)
|
|
173
|
-
try {
|
|
174
|
-
if (localFileExisted) {
|
|
175
|
-
nativeBinding = require('./ruvector.linux-x64-musl.node')
|
|
176
|
-
} else {
|
|
177
|
-
nativeBinding = require('@ruvector/node-linux-x64-musl')
|
|
178
|
-
}
|
|
179
|
-
} catch (e) {
|
|
180
|
-
loadError = e
|
|
181
|
-
}
|
|
182
|
-
} else {
|
|
183
|
-
localFileExisted = existsSync(
|
|
184
|
-
join(__dirname, 'ruvector.linux-x64-gnu.node')
|
|
185
|
-
)
|
|
186
|
-
try {
|
|
187
|
-
if (localFileExisted) {
|
|
188
|
-
nativeBinding = require('./ruvector.linux-x64-gnu.node')
|
|
189
|
-
} else {
|
|
190
|
-
nativeBinding = require('@ruvector/node-linux-x64-gnu')
|
|
191
|
-
}
|
|
192
|
-
} catch (e) {
|
|
193
|
-
loadError = e
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
break
|
|
197
|
-
case 'arm64':
|
|
198
|
-
if (isMusl()) {
|
|
199
|
-
localFileExisted = existsSync(
|
|
200
|
-
join(__dirname, 'ruvector.linux-arm64-musl.node')
|
|
201
|
-
)
|
|
202
|
-
try {
|
|
203
|
-
if (localFileExisted) {
|
|
204
|
-
nativeBinding = require('./ruvector.linux-arm64-musl.node')
|
|
205
|
-
} else {
|
|
206
|
-
nativeBinding = require('@ruvector/node-linux-arm64-musl')
|
|
207
|
-
}
|
|
208
|
-
} catch (e) {
|
|
209
|
-
loadError = e
|
|
210
|
-
}
|
|
211
|
-
} else {
|
|
212
|
-
localFileExisted = existsSync(
|
|
213
|
-
join(__dirname, 'ruvector.linux-arm64-gnu.node')
|
|
214
|
-
)
|
|
215
|
-
try {
|
|
216
|
-
if (localFileExisted) {
|
|
217
|
-
nativeBinding = require('./ruvector.linux-arm64-gnu.node')
|
|
218
|
-
} else {
|
|
219
|
-
nativeBinding = require('@ruvector/node-linux-arm64-gnu')
|
|
220
|
-
}
|
|
221
|
-
} catch (e) {
|
|
222
|
-
loadError = e
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
break
|
|
226
|
-
case 'arm':
|
|
227
|
-
if (isMusl()) {
|
|
228
|
-
localFileExisted = existsSync(
|
|
229
|
-
join(__dirname, 'ruvector.linux-arm-musleabihf.node')
|
|
230
|
-
)
|
|
231
|
-
try {
|
|
232
|
-
if (localFileExisted) {
|
|
233
|
-
nativeBinding = require('./ruvector.linux-arm-musleabihf.node')
|
|
234
|
-
} else {
|
|
235
|
-
nativeBinding = require('@ruvector/node-linux-arm-musleabihf')
|
|
236
|
-
}
|
|
237
|
-
} catch (e) {
|
|
238
|
-
loadError = e
|
|
239
|
-
}
|
|
240
|
-
} else {
|
|
241
|
-
localFileExisted = existsSync(
|
|
242
|
-
join(__dirname, 'ruvector.linux-arm-gnueabihf.node')
|
|
243
|
-
)
|
|
244
|
-
try {
|
|
245
|
-
if (localFileExisted) {
|
|
246
|
-
nativeBinding = require('./ruvector.linux-arm-gnueabihf.node')
|
|
247
|
-
} else {
|
|
248
|
-
nativeBinding = require('@ruvector/node-linux-arm-gnueabihf')
|
|
249
|
-
}
|
|
250
|
-
} catch (e) {
|
|
251
|
-
loadError = e
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
break
|
|
255
|
-
case 'riscv64':
|
|
256
|
-
if (isMusl()) {
|
|
257
|
-
localFileExisted = existsSync(
|
|
258
|
-
join(__dirname, 'ruvector.linux-riscv64-musl.node')
|
|
259
|
-
)
|
|
260
|
-
try {
|
|
261
|
-
if (localFileExisted) {
|
|
262
|
-
nativeBinding = require('./ruvector.linux-riscv64-musl.node')
|
|
263
|
-
} else {
|
|
264
|
-
nativeBinding = require('@ruvector/node-linux-riscv64-musl')
|
|
265
|
-
}
|
|
266
|
-
} catch (e) {
|
|
267
|
-
loadError = e
|
|
268
|
-
}
|
|
269
|
-
} else {
|
|
270
|
-
localFileExisted = existsSync(
|
|
271
|
-
join(__dirname, 'ruvector.linux-riscv64-gnu.node')
|
|
272
|
-
)
|
|
273
|
-
try {
|
|
274
|
-
if (localFileExisted) {
|
|
275
|
-
nativeBinding = require('./ruvector.linux-riscv64-gnu.node')
|
|
276
|
-
} else {
|
|
277
|
-
nativeBinding = require('@ruvector/node-linux-riscv64-gnu')
|
|
278
|
-
}
|
|
279
|
-
} catch (e) {
|
|
280
|
-
loadError = e
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
break
|
|
284
|
-
case 's390x':
|
|
285
|
-
localFileExisted = existsSync(
|
|
286
|
-
join(__dirname, 'ruvector.linux-s390x-gnu.node')
|
|
287
|
-
)
|
|
288
|
-
try {
|
|
289
|
-
if (localFileExisted) {
|
|
290
|
-
nativeBinding = require('./ruvector.linux-s390x-gnu.node')
|
|
291
|
-
} else {
|
|
292
|
-
nativeBinding = require('@ruvector/node-linux-s390x-gnu')
|
|
293
|
-
}
|
|
294
|
-
} catch (e) {
|
|
295
|
-
loadError = e
|
|
296
|
-
}
|
|
297
|
-
break
|
|
298
|
-
default:
|
|
299
|
-
throw new Error(`Unsupported architecture on Linux: ${arch}`)
|
|
300
|
-
}
|
|
301
|
-
break
|
|
302
|
-
default:
|
|
303
|
-
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
if (!nativeBinding) {
|
|
307
|
-
if (loadError) {
|
|
308
|
-
throw loadError
|
|
309
|
-
}
|
|
310
|
-
throw new Error(`Failed to load native binding`)
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
const { JsDistanceMetric, VectorDb, version, hello, CollectionManager, getMetrics, getHealth } = nativeBinding
|
|
314
|
-
|
|
315
|
-
module.exports.JsDistanceMetric = JsDistanceMetric
|
|
316
|
-
module.exports.VectorDb = VectorDb
|
|
317
|
-
module.exports.version = version
|
|
318
|
-
module.exports.hello = hello
|
|
319
|
-
module.exports.CollectionManager = CollectionManager
|
|
320
|
-
module.exports.getMetrics = getMetrics
|
|
321
|
-
module.exports.getHealth = getHealth
|