@wiscale/velesdb-sdk 0.8.10 → 0.8.12

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/LICENSE ADDED
@@ -0,0 +1,27 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-2026 Wiscale France
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ ---
24
+
25
+ Note: This MIT license applies to the TypeScript SDK code only.
26
+ VelesDB Core itself is licensed under the Elastic License 2.0 (ELv2).
27
+ See https://github.com/cyberlife-coder/VelesDB for VelesDB Core licensing.
package/README.md CHANGED
@@ -188,6 +188,25 @@ const results = await db.query(
188
188
  );
189
189
  ```
190
190
 
191
+ ### `db.isEmpty(collection)` (v0.8.11+)
192
+
193
+ Check if a collection is empty.
194
+
195
+ ```typescript
196
+ const empty = await db.isEmpty('documents');
197
+ if (empty) {
198
+ console.log('No vectors in collection');
199
+ }
200
+ ```
201
+
202
+ ### `db.flush(collection)` (v0.8.11+)
203
+
204
+ Flush pending changes to disk.
205
+
206
+ ```typescript
207
+ await db.flush('documents');
208
+ ```
209
+
191
210
  ### `db.close()`
192
211
 
193
212
  Close the client and release resources.
@@ -219,4 +238,6 @@ try {
219
238
 
220
239
  ## License
221
240
 
222
- Elastic License 2.0 (ELv2) - See [LICENSE](../../LICENSE) for details.
241
+ MIT License - See [LICENSE](./LICENSE) for details.
242
+
243
+ VelesDB Core is licensed under ELv2 (source available).
package/dist/index.d.mts CHANGED
@@ -121,6 +121,10 @@ interface IVelesDBBackend {
121
121
  }): Promise<SearchResult[]>;
122
122
  /** Execute VelesQL query */
123
123
  query(queryString: string, params?: Record<string, unknown>): Promise<SearchResult[]>;
124
+ /** Check if collection is empty */
125
+ isEmpty(collection: string): Promise<boolean>;
126
+ /** Flush pending changes to disk */
127
+ flush(collection: string): Promise<void>;
124
128
  /** Close/cleanup the backend */
125
129
  close(): Promise<void>;
126
130
  }
@@ -296,6 +300,19 @@ declare class VelesDB {
296
300
  * @returns Query results
297
301
  */
298
302
  query(queryString: string, params?: Record<string, unknown>): Promise<SearchResult[]>;
303
+ /**
304
+ * Check if a collection is empty
305
+ *
306
+ * @param collection - Collection name
307
+ * @returns true if empty, false otherwise
308
+ */
309
+ isEmpty(collection: string): Promise<boolean>;
310
+ /**
311
+ * Flush pending changes to disk
312
+ *
313
+ * @param collection - Collection name
314
+ */
315
+ flush(collection: string): Promise<void>;
299
316
  /**
300
317
  * Close the client and release resources
301
318
  */
@@ -349,6 +366,8 @@ declare class WasmBackend implements IVelesDBBackend {
349
366
  filter?: Record<string, unknown>;
350
367
  }): Promise<SearchResult[]>;
351
368
  query(_queryString: string, _params?: Record<string, unknown>): Promise<SearchResult[]>;
369
+ isEmpty(collectionName: string): Promise<boolean>;
370
+ flush(collectionName: string): Promise<void>;
352
371
  close(): Promise<void>;
353
372
  private toNumericId;
354
373
  }
@@ -398,6 +417,8 @@ declare class RestBackend implements IVelesDBBackend {
398
417
  filter?: Record<string, unknown>;
399
418
  }): Promise<SearchResult[]>;
400
419
  query(queryString: string, params?: Record<string, unknown>): Promise<SearchResult[]>;
420
+ isEmpty(collection: string): Promise<boolean>;
421
+ flush(collection: string): Promise<void>;
401
422
  close(): Promise<void>;
402
423
  }
403
424
 
package/dist/index.d.ts CHANGED
@@ -121,6 +121,10 @@ interface IVelesDBBackend {
121
121
  }): Promise<SearchResult[]>;
122
122
  /** Execute VelesQL query */
123
123
  query(queryString: string, params?: Record<string, unknown>): Promise<SearchResult[]>;
124
+ /** Check if collection is empty */
125
+ isEmpty(collection: string): Promise<boolean>;
126
+ /** Flush pending changes to disk */
127
+ flush(collection: string): Promise<void>;
124
128
  /** Close/cleanup the backend */
125
129
  close(): Promise<void>;
126
130
  }
@@ -296,6 +300,19 @@ declare class VelesDB {
296
300
  * @returns Query results
297
301
  */
298
302
  query(queryString: string, params?: Record<string, unknown>): Promise<SearchResult[]>;
303
+ /**
304
+ * Check if a collection is empty
305
+ *
306
+ * @param collection - Collection name
307
+ * @returns true if empty, false otherwise
308
+ */
309
+ isEmpty(collection: string): Promise<boolean>;
310
+ /**
311
+ * Flush pending changes to disk
312
+ *
313
+ * @param collection - Collection name
314
+ */
315
+ flush(collection: string): Promise<void>;
299
316
  /**
300
317
  * Close the client and release resources
301
318
  */
@@ -349,6 +366,8 @@ declare class WasmBackend implements IVelesDBBackend {
349
366
  filter?: Record<string, unknown>;
350
367
  }): Promise<SearchResult[]>;
351
368
  query(_queryString: string, _params?: Record<string, unknown>): Promise<SearchResult[]>;
369
+ isEmpty(collectionName: string): Promise<boolean>;
370
+ flush(collectionName: string): Promise<void>;
352
371
  close(): Promise<void>;
353
372
  private toNumericId;
354
373
  }
@@ -398,6 +417,8 @@ declare class RestBackend implements IVelesDBBackend {
398
417
  filter?: Record<string, unknown>;
399
418
  }): Promise<SearchResult[]>;
400
419
  query(queryString: string, params?: Record<string, unknown>): Promise<SearchResult[]>;
420
+ isEmpty(collection: string): Promise<boolean>;
421
+ flush(collection: string): Promise<void>;
401
422
  close(): Promise<void>;
402
423
  }
403
424
 
package/dist/index.js CHANGED
@@ -287,6 +287,21 @@ var WasmBackend = class {
287
287
  "NOT_SUPPORTED"
288
288
  );
289
289
  }
290
+ async isEmpty(collectionName) {
291
+ this.ensureInitialized();
292
+ const collection = this.collections.get(collectionName);
293
+ if (!collection) {
294
+ throw new NotFoundError(`Collection '${collectionName}'`);
295
+ }
296
+ return collection.store.is_empty();
297
+ }
298
+ async flush(collectionName) {
299
+ this.ensureInitialized();
300
+ const collection = this.collections.get(collectionName);
301
+ if (!collection) {
302
+ throw new NotFoundError(`Collection '${collectionName}'`);
303
+ }
304
+ }
290
305
  async close() {
291
306
  for (const [, data] of this.collections) {
292
307
  data.store.free();
@@ -591,6 +606,33 @@ var RestBackend = class {
591
606
  }
592
607
  return response.data?.results ?? [];
593
608
  }
609
+ async isEmpty(collection) {
610
+ this.ensureInitialized();
611
+ const response = await this.request(
612
+ "GET",
613
+ `/collections/${encodeURIComponent(collection)}/empty`
614
+ );
615
+ if (response.error) {
616
+ if (response.error.code === "NOT_FOUND") {
617
+ throw new NotFoundError(`Collection '${collection}'`);
618
+ }
619
+ throw new VelesDBError(response.error.message, response.error.code);
620
+ }
621
+ return response.data?.is_empty ?? true;
622
+ }
623
+ async flush(collection) {
624
+ this.ensureInitialized();
625
+ const response = await this.request(
626
+ "POST",
627
+ `/collections/${encodeURIComponent(collection)}/flush`
628
+ );
629
+ if (response.error) {
630
+ if (response.error.code === "NOT_FOUND") {
631
+ throw new NotFoundError(`Collection '${collection}'`);
632
+ }
633
+ throw new VelesDBError(response.error.message, response.error.code);
634
+ }
635
+ }
594
636
  async close() {
595
637
  this._initialized = false;
596
638
  }
@@ -839,6 +881,25 @@ var VelesDB = class {
839
881
  }
840
882
  return this.backend.query(queryString, params);
841
883
  }
884
+ /**
885
+ * Check if a collection is empty
886
+ *
887
+ * @param collection - Collection name
888
+ * @returns true if empty, false otherwise
889
+ */
890
+ async isEmpty(collection) {
891
+ this.ensureInitialized();
892
+ return this.backend.isEmpty(collection);
893
+ }
894
+ /**
895
+ * Flush pending changes to disk
896
+ *
897
+ * @param collection - Collection name
898
+ */
899
+ async flush(collection) {
900
+ this.ensureInitialized();
901
+ await this.backend.flush(collection);
902
+ }
842
903
  /**
843
904
  * Close the client and release resources
844
905
  */
package/dist/index.mjs CHANGED
@@ -245,6 +245,21 @@ var WasmBackend = class {
245
245
  "NOT_SUPPORTED"
246
246
  );
247
247
  }
248
+ async isEmpty(collectionName) {
249
+ this.ensureInitialized();
250
+ const collection = this.collections.get(collectionName);
251
+ if (!collection) {
252
+ throw new NotFoundError(`Collection '${collectionName}'`);
253
+ }
254
+ return collection.store.is_empty();
255
+ }
256
+ async flush(collectionName) {
257
+ this.ensureInitialized();
258
+ const collection = this.collections.get(collectionName);
259
+ if (!collection) {
260
+ throw new NotFoundError(`Collection '${collectionName}'`);
261
+ }
262
+ }
248
263
  async close() {
249
264
  for (const [, data] of this.collections) {
250
265
  data.store.free();
@@ -549,6 +564,33 @@ var RestBackend = class {
549
564
  }
550
565
  return response.data?.results ?? [];
551
566
  }
567
+ async isEmpty(collection) {
568
+ this.ensureInitialized();
569
+ const response = await this.request(
570
+ "GET",
571
+ `/collections/${encodeURIComponent(collection)}/empty`
572
+ );
573
+ if (response.error) {
574
+ if (response.error.code === "NOT_FOUND") {
575
+ throw new NotFoundError(`Collection '${collection}'`);
576
+ }
577
+ throw new VelesDBError(response.error.message, response.error.code);
578
+ }
579
+ return response.data?.is_empty ?? true;
580
+ }
581
+ async flush(collection) {
582
+ this.ensureInitialized();
583
+ const response = await this.request(
584
+ "POST",
585
+ `/collections/${encodeURIComponent(collection)}/flush`
586
+ );
587
+ if (response.error) {
588
+ if (response.error.code === "NOT_FOUND") {
589
+ throw new NotFoundError(`Collection '${collection}'`);
590
+ }
591
+ throw new VelesDBError(response.error.message, response.error.code);
592
+ }
593
+ }
552
594
  async close() {
553
595
  this._initialized = false;
554
596
  }
@@ -797,6 +839,25 @@ var VelesDB = class {
797
839
  }
798
840
  return this.backend.query(queryString, params);
799
841
  }
842
+ /**
843
+ * Check if a collection is empty
844
+ *
845
+ * @param collection - Collection name
846
+ * @returns true if empty, false otherwise
847
+ */
848
+ async isEmpty(collection) {
849
+ this.ensureInitialized();
850
+ return this.backend.isEmpty(collection);
851
+ }
852
+ /**
853
+ * Flush pending changes to disk
854
+ *
855
+ * @param collection - Collection name
856
+ */
857
+ async flush(collection) {
858
+ this.ensureInitialized();
859
+ await this.backend.flush(collection);
860
+ }
800
861
  /**
801
862
  * Close the client and release resources
802
863
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wiscale/velesdb-sdk",
3
- "version": "0.8.10",
3
+ "version": "0.8.12",
4
4
  "description": "Official TypeScript SDK for VelesDB - Vector Search in Microseconds",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -40,7 +40,7 @@
40
40
  "typescript"
41
41
  ],
42
42
  "author": "Wiscale France",
43
- "license": "Elastic-2.0",
43
+ "license": "MIT",
44
44
  "repository": {
45
45
  "type": "git",
46
46
  "url": "https://github.com/cyberlife-coder/VelesDB.git",
@@ -63,7 +63,7 @@
63
63
  "vitest": "^4.0.16"
64
64
  },
65
65
  "dependencies": {
66
- "@wiscale/velesdb-wasm": "^0.8.10"
66
+ "@wiscale/velesdb-wasm": "^0.8.11"
67
67
  },
68
68
  "engines": {
69
69
  "node": ">=18.0.0"