hyperspace-sdk-ts 3.0.9 → 3.0.10

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 CHANGED
@@ -69,6 +69,19 @@ Create a new collection.
69
69
 
70
70
  Delete collection and all its data.
71
71
 
72
+ ### `listCollections()`
73
+
74
+ Retrieve all active collections for the current tenant.
75
+ Returns `Promise<CollectionInfo[]>`.
76
+
77
+ ```ts
78
+ const collections = await client.listCollections();
79
+ for (const col of collections) {
80
+ console.log(`${col.name}: dim=${col.dimension}, metric=${col.metric}, count=${col.count}`);
81
+ }
82
+ ```
83
+
84
+
72
85
  ### `insert(id, vector, meta?, collection?, durability?)`
73
86
 
74
87
  Insert one vector. Accepts `number[]`, `Float32Array`, `Float64Array`.
package/dist/client.d.ts CHANGED
@@ -26,6 +26,12 @@ export interface SearchResult {
26
26
  [key: string]: TypedMetadataValue;
27
27
  };
28
28
  }
29
+ export interface CollectionInfo {
30
+ name: string;
31
+ count: number;
32
+ dimension: number;
33
+ metric: string;
34
+ }
29
35
  export interface GraphNode {
30
36
  id: number;
31
37
  layer: number;
@@ -69,7 +75,7 @@ export declare class HyperspaceClient {
69
75
  constructor(host?: string, apiKey?: string, userId?: string);
70
76
  createCollection(name: string, dimension: number, metric: string): Promise<boolean>;
71
77
  deleteCollection(name: string): Promise<boolean>;
72
- listCollections(): Promise<string[]>;
78
+ listCollections(): Promise<CollectionInfo[]>;
73
79
  delete(id: number, collection?: string): Promise<boolean>;
74
80
  insert(vector: number[] | Float32Array | Float64Array, id: number, meta?: {
75
81
  [key: string]: string;
package/dist/client.js CHANGED
@@ -274,7 +274,13 @@ class HyperspaceClient {
274
274
  this.client.listCollections(req, this.metadata, (err, resp) => {
275
275
  if (err)
276
276
  return reject(err);
277
- resolve(resp.getCollectionsList());
277
+ const list = resp.getCollectionsList().map(c => ({
278
+ name: c.getName(),
279
+ count: c.getCount(),
280
+ dimension: c.getDimension(),
281
+ metric: c.getMetric()
282
+ }));
283
+ resolve(list);
278
284
  });
279
285
  });
280
286
  }
@@ -26,6 +26,7 @@ goog.exportSymbol('proto.hyperspace.BatchSearchRequest', null, global);
26
26
  goog.exportSymbol('proto.hyperspace.BatchSearchResponse', null, global);
27
27
  goog.exportSymbol('proto.hyperspace.CollectionStatsRequest', null, global);
28
28
  goog.exportSymbol('proto.hyperspace.CollectionStatsResponse', null, global);
29
+ goog.exportSymbol('proto.hyperspace.CollectionSummary', null, global);
29
30
  goog.exportSymbol('proto.hyperspace.ConfigUpdate', null, global);
30
31
  goog.exportSymbol('proto.hyperspace.CreateCollectionOp', null, global);
31
32
  goog.exportSymbol('proto.hyperspace.CreateCollectionRequest', null, global);
@@ -284,6 +285,27 @@ if (goog.DEBUG && !COMPILED) {
284
285
  */
285
286
  proto.hyperspace.DeleteCollectionRequest.displayName = 'proto.hyperspace.DeleteCollectionRequest';
286
287
  }
288
+ /**
289
+ * Generated by JsPbCodeGenerator.
290
+ * @param {Array=} opt_data Optional initial data array, typically from a
291
+ * server response, or constructed directly in Javascript. The array is used
292
+ * in place and becomes part of the constructed object. It is not cloned.
293
+ * If no data is provided, the constructed object will be empty, but still
294
+ * valid.
295
+ * @extends {jspb.Message}
296
+ * @constructor
297
+ */
298
+ proto.hyperspace.CollectionSummary = function(opt_data) {
299
+ jspb.Message.initialize(this, opt_data, 0, -1, null, null);
300
+ };
301
+ goog.inherits(proto.hyperspace.CollectionSummary, jspb.Message);
302
+ if (goog.DEBUG && !COMPILED) {
303
+ /**
304
+ * @public
305
+ * @override
306
+ */
307
+ proto.hyperspace.CollectionSummary.displayName = 'proto.hyperspace.CollectionSummary';
308
+ }
287
309
  /**
288
310
  * Generated by JsPbCodeGenerator.
289
311
  * @param {Array=} opt_data Optional initial data array, typically from a
@@ -3150,6 +3172,226 @@ proto.hyperspace.DeleteCollectionRequest.prototype.setName = function(value) {
3150
3172
 
3151
3173
 
3152
3174
 
3175
+
3176
+
3177
+ if (jspb.Message.GENERATE_TO_OBJECT) {
3178
+ /**
3179
+ * Creates an object representation of this proto.
3180
+ * Field names that are reserved in JavaScript and will be renamed to pb_name.
3181
+ * Optional fields that are not set will be set to undefined.
3182
+ * To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
3183
+ * For the list of reserved names please see:
3184
+ * net/proto2/compiler/js/internal/generator.cc#kKeyword.
3185
+ * @param {boolean=} opt_includeInstance Deprecated. whether to include the
3186
+ * JSPB instance for transitional soy proto support:
3187
+ * http://goto/soy-param-migration
3188
+ * @return {!Object}
3189
+ */
3190
+ proto.hyperspace.CollectionSummary.prototype.toObject = function(opt_includeInstance) {
3191
+ return proto.hyperspace.CollectionSummary.toObject(opt_includeInstance, this);
3192
+ };
3193
+
3194
+
3195
+ /**
3196
+ * Static version of the {@see toObject} method.
3197
+ * @param {boolean|undefined} includeInstance Deprecated. Whether to include
3198
+ * the JSPB instance for transitional soy proto support:
3199
+ * http://goto/soy-param-migration
3200
+ * @param {!proto.hyperspace.CollectionSummary} msg The msg instance to transform.
3201
+ * @return {!Object}
3202
+ * @suppress {unusedLocalVariables} f is only used for nested messages
3203
+ */
3204
+ proto.hyperspace.CollectionSummary.toObject = function(includeInstance, msg) {
3205
+ var f, obj = {
3206
+ name: jspb.Message.getFieldWithDefault(msg, 1, ""),
3207
+ count: jspb.Message.getFieldWithDefault(msg, 2, 0),
3208
+ dimension: jspb.Message.getFieldWithDefault(msg, 3, 0),
3209
+ metric: jspb.Message.getFieldWithDefault(msg, 4, "")
3210
+ };
3211
+
3212
+ if (includeInstance) {
3213
+ obj.$jspbMessageInstance = msg;
3214
+ }
3215
+ return obj;
3216
+ };
3217
+ }
3218
+
3219
+
3220
+ /**
3221
+ * Deserializes binary data (in protobuf wire format).
3222
+ * @param {jspb.ByteSource} bytes The bytes to deserialize.
3223
+ * @return {!proto.hyperspace.CollectionSummary}
3224
+ */
3225
+ proto.hyperspace.CollectionSummary.deserializeBinary = function(bytes) {
3226
+ var reader = new jspb.BinaryReader(bytes);
3227
+ var msg = new proto.hyperspace.CollectionSummary;
3228
+ return proto.hyperspace.CollectionSummary.deserializeBinaryFromReader(msg, reader);
3229
+ };
3230
+
3231
+
3232
+ /**
3233
+ * Deserializes binary data (in protobuf wire format) from the
3234
+ * given reader into the given message object.
3235
+ * @param {!proto.hyperspace.CollectionSummary} msg The message object to deserialize into.
3236
+ * @param {!jspb.BinaryReader} reader The BinaryReader to use.
3237
+ * @return {!proto.hyperspace.CollectionSummary}
3238
+ */
3239
+ proto.hyperspace.CollectionSummary.deserializeBinaryFromReader = function(msg, reader) {
3240
+ while (reader.nextField()) {
3241
+ if (reader.isEndGroup()) {
3242
+ break;
3243
+ }
3244
+ var field = reader.getFieldNumber();
3245
+ switch (field) {
3246
+ case 1:
3247
+ var value = /** @type {string} */ (reader.readString());
3248
+ msg.setName(value);
3249
+ break;
3250
+ case 2:
3251
+ var value = /** @type {number} */ (reader.readUint64());
3252
+ msg.setCount(value);
3253
+ break;
3254
+ case 3:
3255
+ var value = /** @type {number} */ (reader.readUint32());
3256
+ msg.setDimension(value);
3257
+ break;
3258
+ case 4:
3259
+ var value = /** @type {string} */ (reader.readString());
3260
+ msg.setMetric(value);
3261
+ break;
3262
+ default:
3263
+ reader.skipField();
3264
+ break;
3265
+ }
3266
+ }
3267
+ return msg;
3268
+ };
3269
+
3270
+
3271
+ /**
3272
+ * Serializes the message to binary data (in protobuf wire format).
3273
+ * @return {!Uint8Array}
3274
+ */
3275
+ proto.hyperspace.CollectionSummary.prototype.serializeBinary = function() {
3276
+ var writer = new jspb.BinaryWriter();
3277
+ proto.hyperspace.CollectionSummary.serializeBinaryToWriter(this, writer);
3278
+ return writer.getResultBuffer();
3279
+ };
3280
+
3281
+
3282
+ /**
3283
+ * Serializes the given message to binary data (in protobuf wire
3284
+ * format), writing to the given BinaryWriter.
3285
+ * @param {!proto.hyperspace.CollectionSummary} message
3286
+ * @param {!jspb.BinaryWriter} writer
3287
+ * @suppress {unusedLocalVariables} f is only used for nested messages
3288
+ */
3289
+ proto.hyperspace.CollectionSummary.serializeBinaryToWriter = function(message, writer) {
3290
+ var f = undefined;
3291
+ f = message.getName();
3292
+ if (f.length > 0) {
3293
+ writer.writeString(
3294
+ 1,
3295
+ f
3296
+ );
3297
+ }
3298
+ f = message.getCount();
3299
+ if (f !== 0) {
3300
+ writer.writeUint64(
3301
+ 2,
3302
+ f
3303
+ );
3304
+ }
3305
+ f = message.getDimension();
3306
+ if (f !== 0) {
3307
+ writer.writeUint32(
3308
+ 3,
3309
+ f
3310
+ );
3311
+ }
3312
+ f = message.getMetric();
3313
+ if (f.length > 0) {
3314
+ writer.writeString(
3315
+ 4,
3316
+ f
3317
+ );
3318
+ }
3319
+ };
3320
+
3321
+
3322
+ /**
3323
+ * optional string name = 1;
3324
+ * @return {string}
3325
+ */
3326
+ proto.hyperspace.CollectionSummary.prototype.getName = function() {
3327
+ return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
3328
+ };
3329
+
3330
+
3331
+ /**
3332
+ * @param {string} value
3333
+ * @return {!proto.hyperspace.CollectionSummary} returns this
3334
+ */
3335
+ proto.hyperspace.CollectionSummary.prototype.setName = function(value) {
3336
+ return jspb.Message.setProto3StringField(this, 1, value);
3337
+ };
3338
+
3339
+
3340
+ /**
3341
+ * optional uint64 count = 2;
3342
+ * @return {number}
3343
+ */
3344
+ proto.hyperspace.CollectionSummary.prototype.getCount = function() {
3345
+ return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0));
3346
+ };
3347
+
3348
+
3349
+ /**
3350
+ * @param {number} value
3351
+ * @return {!proto.hyperspace.CollectionSummary} returns this
3352
+ */
3353
+ proto.hyperspace.CollectionSummary.prototype.setCount = function(value) {
3354
+ return jspb.Message.setProto3IntField(this, 2, value);
3355
+ };
3356
+
3357
+
3358
+ /**
3359
+ * optional uint32 dimension = 3;
3360
+ * @return {number}
3361
+ */
3362
+ proto.hyperspace.CollectionSummary.prototype.getDimension = function() {
3363
+ return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0));
3364
+ };
3365
+
3366
+
3367
+ /**
3368
+ * @param {number} value
3369
+ * @return {!proto.hyperspace.CollectionSummary} returns this
3370
+ */
3371
+ proto.hyperspace.CollectionSummary.prototype.setDimension = function(value) {
3372
+ return jspb.Message.setProto3IntField(this, 3, value);
3373
+ };
3374
+
3375
+
3376
+ /**
3377
+ * optional string metric = 4;
3378
+ * @return {string}
3379
+ */
3380
+ proto.hyperspace.CollectionSummary.prototype.getMetric = function() {
3381
+ return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, ""));
3382
+ };
3383
+
3384
+
3385
+ /**
3386
+ * @param {string} value
3387
+ * @return {!proto.hyperspace.CollectionSummary} returns this
3388
+ */
3389
+ proto.hyperspace.CollectionSummary.prototype.setMetric = function(value) {
3390
+ return jspb.Message.setProto3StringField(this, 4, value);
3391
+ };
3392
+
3393
+
3394
+
3153
3395
  /**
3154
3396
  * List of repeated fields within this message type.
3155
3397
  * @private {!Array<number>}
@@ -3188,7 +3430,8 @@ proto.hyperspace.ListCollectionsResponse.prototype.toObject = function(opt_inclu
3188
3430
  */
3189
3431
  proto.hyperspace.ListCollectionsResponse.toObject = function(includeInstance, msg) {
3190
3432
  var f, obj = {
3191
- collectionsList: (f = jspb.Message.getRepeatedField(msg, 1)) == null ? undefined : f
3433
+ collectionsList: jspb.Message.toObjectList(msg.getCollectionsList(),
3434
+ proto.hyperspace.CollectionSummary.toObject, includeInstance)
3192
3435
  };
3193
3436
 
3194
3437
  if (includeInstance) {
@@ -3226,7 +3469,8 @@ proto.hyperspace.ListCollectionsResponse.deserializeBinaryFromReader = function(
3226
3469
  var field = reader.getFieldNumber();
3227
3470
  switch (field) {
3228
3471
  case 1:
3229
- var value = /** @type {string} */ (reader.readString());
3472
+ var value = new proto.hyperspace.CollectionSummary;
3473
+ reader.readMessage(value,proto.hyperspace.CollectionSummary.deserializeBinaryFromReader);
3230
3474
  msg.addCollections(value);
3231
3475
  break;
3232
3476
  default:
@@ -3260,39 +3504,41 @@ proto.hyperspace.ListCollectionsResponse.serializeBinaryToWriter = function(mess
3260
3504
  var f = undefined;
3261
3505
  f = message.getCollectionsList();
3262
3506
  if (f.length > 0) {
3263
- writer.writeRepeatedString(
3507
+ writer.writeRepeatedMessage(
3264
3508
  1,
3265
- f
3509
+ f,
3510
+ proto.hyperspace.CollectionSummary.serializeBinaryToWriter
3266
3511
  );
3267
3512
  }
3268
3513
  };
3269
3514
 
3270
3515
 
3271
3516
  /**
3272
- * repeated string collections = 1;
3273
- * @return {!Array<string>}
3517
+ * repeated CollectionSummary collections = 1;
3518
+ * @return {!Array<!proto.hyperspace.CollectionSummary>}
3274
3519
  */
3275
3520
  proto.hyperspace.ListCollectionsResponse.prototype.getCollectionsList = function() {
3276
- return /** @type {!Array<string>} */ (jspb.Message.getRepeatedField(this, 1));
3521
+ return /** @type{!Array<!proto.hyperspace.CollectionSummary>} */ (
3522
+ jspb.Message.getRepeatedWrapperField(this, proto.hyperspace.CollectionSummary, 1));
3277
3523
  };
3278
3524
 
3279
3525
 
3280
3526
  /**
3281
- * @param {!Array<string>} value
3527
+ * @param {!Array<!proto.hyperspace.CollectionSummary>} value
3282
3528
  * @return {!proto.hyperspace.ListCollectionsResponse} returns this
3283
- */
3529
+ */
3284
3530
  proto.hyperspace.ListCollectionsResponse.prototype.setCollectionsList = function(value) {
3285
- return jspb.Message.setField(this, 1, value || []);
3531
+ return jspb.Message.setRepeatedWrapperField(this, 1, value);
3286
3532
  };
3287
3533
 
3288
3534
 
3289
3535
  /**
3290
- * @param {string} value
3536
+ * @param {!proto.hyperspace.CollectionSummary=} opt_value
3291
3537
  * @param {number=} opt_index
3292
- * @return {!proto.hyperspace.ListCollectionsResponse} returns this
3538
+ * @return {!proto.hyperspace.CollectionSummary}
3293
3539
  */
3294
- proto.hyperspace.ListCollectionsResponse.prototype.addCollections = function(value, opt_index) {
3295
- return jspb.Message.addToRepeatedField(this, 1, value, opt_index);
3540
+ proto.hyperspace.ListCollectionsResponse.prototype.addCollections = function(opt_value, opt_index) {
3541
+ return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.hyperspace.CollectionSummary, opt_index);
3296
3542
  };
3297
3543
 
3298
3544
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperspace-sdk-ts",
3
- "version": "3.0.9",
3
+ "version": "3.0.10",
4
4
  "description": "Official TypeScript SDK for HyperspaceDB gRPC API",
5
5
  "main": "dist/client.js",
6
6
  "types": "dist/client.d.ts",
@@ -31,4 +31,4 @@
31
31
  "ts-node": "^10.9.2",
32
32
  "typescript": "^5.9.3"
33
33
  }
34
- }
34
+ }