ruvector 0.1.34 → 0.1.35
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"startTime":
|
|
3
|
-
"sessionId": "session-
|
|
4
|
-
"lastActivity":
|
|
2
|
+
"startTime": 1765639811138,
|
|
3
|
+
"sessionId": "session-1765639811138",
|
|
4
|
+
"lastActivity": 1765639811138,
|
|
5
5
|
"sessionDuration": 0,
|
|
6
6
|
"totalTasks": 1,
|
|
7
7
|
"successfulTasks": 1,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
|
-
"id": "cmd-hooks-
|
|
3
|
+
"id": "cmd-hooks-1765639811246",
|
|
4
4
|
"type": "hooks",
|
|
5
5
|
"success": true,
|
|
6
|
-
"duration": 7.
|
|
7
|
-
"timestamp":
|
|
6
|
+
"duration": 7.567385000000002,
|
|
7
|
+
"timestamp": 1765639811254,
|
|
8
8
|
"metadata": {}
|
|
9
9
|
}
|
|
10
10
|
]
|
package/dist/index.d.ts
CHANGED
|
@@ -31,7 +31,70 @@ export declare function getVersion(): {
|
|
|
31
31
|
version: string;
|
|
32
32
|
implementation: string;
|
|
33
33
|
};
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Wrapper class that automatically handles metadata JSON conversion
|
|
36
|
+
*/
|
|
37
|
+
declare class VectorDBWrapper {
|
|
38
|
+
private db;
|
|
39
|
+
constructor(options: {
|
|
40
|
+
dimensions: number;
|
|
41
|
+
storagePath?: string;
|
|
42
|
+
distanceMetric?: string;
|
|
43
|
+
hnswConfig?: any;
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* Insert a vector with optional metadata (objects are auto-converted to JSON)
|
|
47
|
+
*/
|
|
48
|
+
insert(entry: {
|
|
49
|
+
id?: string;
|
|
50
|
+
vector: Float32Array | number[];
|
|
51
|
+
metadata?: Record<string, any>;
|
|
52
|
+
}): Promise<string>;
|
|
53
|
+
/**
|
|
54
|
+
* Insert multiple vectors in batch
|
|
55
|
+
*/
|
|
56
|
+
insertBatch(entries: Array<{
|
|
57
|
+
id?: string;
|
|
58
|
+
vector: Float32Array | number[];
|
|
59
|
+
metadata?: Record<string, any>;
|
|
60
|
+
}>): Promise<string[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Search for similar vectors (metadata is auto-parsed from JSON)
|
|
63
|
+
*/
|
|
64
|
+
search(query: {
|
|
65
|
+
vector: Float32Array | number[];
|
|
66
|
+
k: number;
|
|
67
|
+
filter?: Record<string, any>;
|
|
68
|
+
efSearch?: number;
|
|
69
|
+
}): Promise<Array<{
|
|
70
|
+
id: string;
|
|
71
|
+
score: number;
|
|
72
|
+
vector?: Float32Array;
|
|
73
|
+
metadata?: Record<string, any>;
|
|
74
|
+
}>>;
|
|
75
|
+
/**
|
|
76
|
+
* Get a vector by ID (metadata is auto-parsed from JSON)
|
|
77
|
+
*/
|
|
78
|
+
get(id: string): Promise<{
|
|
79
|
+
id?: string;
|
|
80
|
+
vector: Float32Array;
|
|
81
|
+
metadata?: Record<string, any>;
|
|
82
|
+
} | null>;
|
|
83
|
+
/**
|
|
84
|
+
* Delete a vector by ID
|
|
85
|
+
*/
|
|
86
|
+
delete(id: string): Promise<boolean>;
|
|
87
|
+
/**
|
|
88
|
+
* Get the number of vectors in the database
|
|
89
|
+
*/
|
|
90
|
+
len(): Promise<number>;
|
|
91
|
+
/**
|
|
92
|
+
* Check if the database is empty
|
|
93
|
+
*/
|
|
94
|
+
isEmpty(): Promise<boolean>;
|
|
95
|
+
}
|
|
96
|
+
export declare const VectorDb: typeof VectorDBWrapper;
|
|
97
|
+
export declare const VectorDB: typeof VectorDBWrapper;
|
|
98
|
+
export declare const NativeVectorDb: any;
|
|
36
99
|
export default implementation;
|
|
37
100
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,cAAc,SAAS,CAAC;AAGxB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAE3B,QAAA,IAAI,cAAc,EAAE,GAAG,CAAC;AA0BxB;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,QAAQ,GAAG,MAAM,CAEzD;AAED;;GAEG;AACH,wBAAgB,QAAQ,IAAI,OAAO,CAElC;AAED;;GAEG;AACH,wBAAgB,MAAM,IAAI,OAAO,CAEhC;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,CAMxE;AAGD,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,cAAc,SAAS,CAAC;AAGxB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAE3B,QAAA,IAAI,cAAc,EAAE,GAAG,CAAC;AA0BxB;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,QAAQ,GAAG,MAAM,CAEzD;AAED;;GAEG;AACH,wBAAgB,QAAQ,IAAI,OAAO,CAElC;AAED;;GAEG;AACH,wBAAgB,MAAM,IAAI,OAAO,CAEhC;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,CAMxE;AAED;;GAEG;AACH,cAAM,eAAe;IACnB,OAAO,CAAC,EAAE,CAAM;gBAEJ,OAAO,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,GAAG,C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AAO,CAAC;IAI1C;;OAEG;IACG,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;IAI5B;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;CAGlC;AAGD,eAAO,MAAM,QAAQ,wBAAkB,CAAC;AACxC,eAAO,MAAM,QAAQ,wBAAkB,CAAC;AAGxC,eAAO,MAAM,cAAc,KAA0B,CAAC;AAGtD,eAAe,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -24,7 +24,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
24
24
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.VectorDB = exports.VectorDb = void 0;
|
|
27
|
+
exports.NativeVectorDb = exports.VectorDB = exports.VectorDb = void 0;
|
|
28
28
|
exports.getImplementationType = getImplementationType;
|
|
29
29
|
exports.isNative = isNative;
|
|
30
30
|
exports.isWasm = isWasm;
|
|
@@ -83,8 +83,96 @@ function getVersion() {
|
|
|
83
83
|
implementation: implementationType
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Wrapper class that automatically handles metadata JSON conversion
|
|
88
|
+
*/
|
|
89
|
+
class VectorDBWrapper {
|
|
90
|
+
constructor(options) {
|
|
91
|
+
this.db = new implementation.VectorDb(options);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Insert a vector with optional metadata (objects are auto-converted to JSON)
|
|
95
|
+
*/
|
|
96
|
+
async insert(entry) {
|
|
97
|
+
const nativeEntry = {
|
|
98
|
+
id: entry.id,
|
|
99
|
+
vector: entry.vector instanceof Float32Array ? entry.vector : new Float32Array(entry.vector),
|
|
100
|
+
};
|
|
101
|
+
// Auto-convert metadata object to JSON string
|
|
102
|
+
if (entry.metadata) {
|
|
103
|
+
nativeEntry.metadata = JSON.stringify(entry.metadata);
|
|
104
|
+
}
|
|
105
|
+
return this.db.insert(nativeEntry);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Insert multiple vectors in batch
|
|
109
|
+
*/
|
|
110
|
+
async insertBatch(entries) {
|
|
111
|
+
const nativeEntries = entries.map(entry => ({
|
|
112
|
+
id: entry.id,
|
|
113
|
+
vector: entry.vector instanceof Float32Array ? entry.vector : new Float32Array(entry.vector),
|
|
114
|
+
metadata: entry.metadata ? JSON.stringify(entry.metadata) : undefined,
|
|
115
|
+
}));
|
|
116
|
+
return this.db.insertBatch(nativeEntries);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Search for similar vectors (metadata is auto-parsed from JSON)
|
|
120
|
+
*/
|
|
121
|
+
async search(query) {
|
|
122
|
+
const nativeQuery = {
|
|
123
|
+
vector: query.vector instanceof Float32Array ? query.vector : new Float32Array(query.vector),
|
|
124
|
+
k: query.k,
|
|
125
|
+
efSearch: query.efSearch,
|
|
126
|
+
};
|
|
127
|
+
// Auto-convert filter object to JSON string
|
|
128
|
+
if (query.filter) {
|
|
129
|
+
nativeQuery.filter = JSON.stringify(query.filter);
|
|
130
|
+
}
|
|
131
|
+
const results = await this.db.search(nativeQuery);
|
|
132
|
+
// Auto-parse metadata JSON strings back to objects
|
|
133
|
+
return results.map((r) => ({
|
|
134
|
+
id: r.id,
|
|
135
|
+
score: r.score,
|
|
136
|
+
vector: r.vector,
|
|
137
|
+
metadata: r.metadata ? JSON.parse(r.metadata) : undefined,
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Get a vector by ID (metadata is auto-parsed from JSON)
|
|
142
|
+
*/
|
|
143
|
+
async get(id) {
|
|
144
|
+
const entry = await this.db.get(id);
|
|
145
|
+
if (!entry)
|
|
146
|
+
return null;
|
|
147
|
+
return {
|
|
148
|
+
id: entry.id,
|
|
149
|
+
vector: entry.vector,
|
|
150
|
+
metadata: entry.metadata ? JSON.parse(entry.metadata) : undefined,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Delete a vector by ID
|
|
155
|
+
*/
|
|
156
|
+
async delete(id) {
|
|
157
|
+
return this.db.delete(id);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Get the number of vectors in the database
|
|
161
|
+
*/
|
|
162
|
+
async len() {
|
|
163
|
+
return this.db.len();
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Check if the database is empty
|
|
167
|
+
*/
|
|
168
|
+
async isEmpty() {
|
|
169
|
+
return this.db.isEmpty();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
// Export the wrapper class (aliased as VectorDB for backwards compatibility)
|
|
173
|
+
exports.VectorDb = VectorDBWrapper;
|
|
174
|
+
exports.VectorDB = VectorDBWrapper;
|
|
175
|
+
// Also export the raw native implementation for advanced users
|
|
176
|
+
exports.NativeVectorDb = implementation.VectorDb;
|
|
89
177
|
// Export everything from the implementation
|
|
90
178
|
exports.default = implementation;
|