@zilliz/milvus2-sdk-node 2.2.4 → 2.2.6

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.
Files changed (78) hide show
  1. package/README.md +4 -21
  2. package/dist/milvus/BaseClient.d.ts +17 -0
  3. package/dist/milvus/BaseClient.js +58 -0
  4. package/dist/milvus/BaseClient.js.map +1 -0
  5. package/dist/milvus/Collection.d.ts +116 -65
  6. package/dist/milvus/Collection.js +200 -125
  7. package/dist/milvus/Collection.js.map +1 -1
  8. package/dist/milvus/Data.d.ts +14 -18
  9. package/dist/milvus/Data.js +82 -94
  10. package/dist/milvus/Data.js.map +1 -1
  11. package/dist/milvus/MilvusClient.d.ts +17 -0
  12. package/dist/milvus/MilvusClient.js +163 -0
  13. package/dist/milvus/MilvusClient.js.map +1 -0
  14. package/dist/milvus/MilvusIndex.d.ts +8 -8
  15. package/dist/milvus/MilvusIndex.js +19 -20
  16. package/dist/milvus/MilvusIndex.js.map +1 -1
  17. package/dist/milvus/Partition.d.ts +10 -10
  18. package/dist/milvus/Partition.js +27 -29
  19. package/dist/milvus/Partition.js.map +1 -1
  20. package/dist/milvus/Resource.d.ts +10 -11
  21. package/dist/milvus/Resource.js +18 -18
  22. package/dist/milvus/Resource.js.map +1 -1
  23. package/dist/milvus/User.d.ts +20 -20
  24. package/dist/milvus/User.js +45 -47
  25. package/dist/milvus/User.js.map +1 -1
  26. package/dist/milvus/Utils.d.ts +1 -1
  27. package/dist/milvus/Utils.js +1 -1
  28. package/dist/milvus/Utils.js.map +1 -1
  29. package/dist/milvus/const/ErrorReason.d.ts +9 -9
  30. package/dist/milvus/const/ErrorReason.js +9 -9
  31. package/dist/milvus/const/ErrorReason.js.map +1 -1
  32. package/dist/milvus/const/Milvus.d.ts +23 -19
  33. package/dist/milvus/const/Milvus.js +25 -31
  34. package/dist/milvus/const/Milvus.js.map +1 -1
  35. package/dist/milvus/index.d.ts +11 -48
  36. package/dist/milvus/index.js +16 -188
  37. package/dist/milvus/index.js.map +1 -1
  38. package/dist/milvus/types/Collection.d.ts +33 -16
  39. package/dist/milvus/types/Collection.js.map +1 -1
  40. package/dist/milvus/types/Common.d.ts +1 -1
  41. package/dist/milvus/types/User.d.ts +3 -3
  42. package/dist/proto/proto/common.proto +7 -1
  43. package/dist/proto/proto/feder.proto +40 -0
  44. package/dist/proto/proto/google/protobuf/descriptor.proto +41 -3
  45. package/dist/proto/proto/milvus.proto +61 -0
  46. package/dist/proto/proto/schema.proto +21 -22
  47. package/dist/sdk.json +1 -1
  48. package/dist/utils/Blob.js.map +1 -0
  49. package/dist/{milvus/utils → utils}/Format.d.ts +21 -1
  50. package/dist/{milvus/utils → utils}/Format.js +48 -11
  51. package/dist/utils/Format.js.map +1 -0
  52. package/dist/utils/Function.d.ts +4 -0
  53. package/dist/utils/Function.js +33 -0
  54. package/dist/utils/Function.js.map +1 -0
  55. package/dist/utils/Grpc.d.ts +19 -0
  56. package/dist/utils/Grpc.js +64 -0
  57. package/dist/utils/Grpc.js.map +1 -0
  58. package/dist/{milvus/utils → utils}/Validate.d.ts +1 -1
  59. package/dist/{milvus/utils → utils}/Validate.js +2 -2
  60. package/dist/utils/Validate.js.map +1 -0
  61. package/dist/utils/index.d.ts +5 -1
  62. package/dist/utils/index.js +19 -24
  63. package/dist/utils/index.js.map +1 -1
  64. package/dist/utils/test.d.ts +14 -0
  65. package/dist/utils/test.js +68 -0
  66. package/dist/utils/test.js.map +1 -0
  67. package/package.json +4 -4
  68. package/dist/milvus/Client.d.ts +0 -4
  69. package/dist/milvus/Client.js +0 -11
  70. package/dist/milvus/Client.js.map +0 -1
  71. package/dist/milvus/utils/Blob.js.map +0 -1
  72. package/dist/milvus/utils/Format.js.map +0 -1
  73. package/dist/milvus/utils/Validate.js.map +0 -1
  74. package/dist/milvus/utils/index.d.ts +0 -3
  75. package/dist/milvus/utils/index.js +0 -10
  76. package/dist/milvus/utils/index.js.map +0 -1
  77. /package/dist/{milvus/utils → utils}/Blob.d.ts +0 -0
  78. /package/dist/{milvus/utils → utils}/Blob.js +0 -0
@@ -61,30 +61,19 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
61
61
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
62
62
  }
63
63
  };
64
- var __importDefault = (this && this.__importDefault) || function (mod) {
65
- return (mod && mod.__esModule) ? mod : { "default": mod };
66
- };
67
64
  Object.defineProperty(exports, "__esModule", { value: true });
68
65
  exports.Collection = void 0;
69
- var protobufjs_1 = __importDefault(require("protobufjs"));
70
- var path_1 = __importDefault(require("path"));
71
66
  var utils_1 = require("../utils");
72
- var ErrorReason_1 = require("./const/ErrorReason");
73
- var Validate_1 = require("./utils/Validate");
74
- var Format_1 = require("./utils/Format");
75
- var Client_1 = require("./Client");
76
- var Milvus_1 = require("./const/Milvus");
77
- var types_1 = require("./types");
78
- var schemaPath = path_1.default.resolve(__dirname, '../proto/proto/schema.proto');
67
+ var BaseClient_1 = require("./BaseClient");
68
+ var _1 = require(".");
69
+ var utils_2 = require("../utils");
79
70
  /**
80
71
  * @see [collection operation examples](https://github.com/milvus-io/milvus-sdk-node/blob/main/example/Collection.ts)
81
72
  */
82
73
  var Collection = /** @class */ (function (_super) {
83
74
  __extends(Collection, _super);
84
- function Collection(client) {
85
- var _this = _super.call(this, client) || this;
86
- _this._protoRoot = protobufjs_1.default.loadSync(schemaPath);
87
- return _this;
75
+ function Collection() {
76
+ return _super !== null && _super.apply(this, arguments) || this;
88
77
  }
89
78
  /**
90
79
  * Create a collection in Milvus.
@@ -107,7 +96,7 @@ var Collection = /** @class */ (function (_super) {
107
96
  * #### Example
108
97
  *
109
98
  * ```
110
- * new milvusClient(MILUVS_ADDRESS).collectionManager.createCollection({
99
+ * new milvusClient(MILUVS_ADDRESS).createCollection({
111
100
  * collection_name: 'my_collection',
112
101
  * fields: [
113
102
  * {
@@ -131,33 +120,34 @@ var Collection = /** @class */ (function (_super) {
131
120
  */
132
121
  Collection.prototype.createCollection = function (data) {
133
122
  return __awaiter(this, void 0, void 0, function () {
134
- var _a, fields, collection_name, description, _b, consistency_level, CollectionSchema, FieldSchema, payload, collectionParams, schemaBtyes, level, promise;
123
+ var _a, fields, collection_name, description, _b, consistency_level, CollectionSchema, FieldSchema, payload, collectionParams, schemaBytes, level, promise;
135
124
  return __generator(this, function (_c) {
136
125
  switch (_c.label) {
137
126
  case 0:
138
127
  _a = data || {}, fields = _a.fields, collection_name = _a.collection_name, description = _a.description, _b = _a.consistency_level, consistency_level = _b === void 0 ? 'Bounded' : _b;
139
128
  if (!fields || !fields.length || !collection_name) {
140
- throw new Error(ErrorReason_1.ERROR_REASONS.CREATE_COLLECTION_CHECK_PARAMS);
129
+ throw new Error(_1.ERROR_REASONS.CREATE_COLLECTION_CHECK_PARAMS);
141
130
  }
142
- (0, Validate_1.checkCollectionFields)(fields);
143
- CollectionSchema = this._protoRoot.lookupType('milvus.proto.schema.CollectionSchema');
144
- FieldSchema = this._protoRoot.lookupType('milvus.proto.schema.FieldSchema');
131
+ (0, utils_1.checkCollectionFields)(fields);
132
+ CollectionSchema = this.schemaProto.lookupType('milvus.proto.schema.CollectionSchema');
133
+ FieldSchema = this.schemaProto.lookupType('milvus.proto.schema.FieldSchema');
145
134
  payload = {
146
135
  name: collection_name,
147
136
  description: description || '',
148
137
  fields: [],
149
138
  };
150
139
  data.fields.forEach(function (field) {
151
- var value = __assign(__assign({}, field), { typeParams: (0, Format_1.parseToKeyValue)(field.type_params), dataType: field.data_type, isPrimaryKey: field.is_primary_key });
140
+ field = (0, utils_2.assignTypeParams)(field);
141
+ var value = __assign(__assign({}, field), { typeParams: (0, utils_1.parseToKeyValue)(field.type_params), dataType: field.data_type, isPrimaryKey: field.is_primary_key });
152
142
  var fieldParams = FieldSchema.create(value);
153
143
  payload.fields.push(fieldParams);
154
144
  });
155
145
  collectionParams = CollectionSchema.create(payload);
156
- schemaBtyes = CollectionSchema.encode(collectionParams).finish();
157
- level = Object.keys(Milvus_1.ConsistencyLevelEnum).includes(consistency_level)
158
- ? Milvus_1.ConsistencyLevelEnum[consistency_level]
159
- : Milvus_1.ConsistencyLevelEnum['Bounded'];
160
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'CreateCollection', __assign(__assign({}, data), { schema: schemaBtyes, consistency_level: level }), data.timeout)];
146
+ schemaBytes = CollectionSchema.encode(collectionParams).finish();
147
+ level = Object.keys(_1.ConsistencyLevelEnum).includes(consistency_level)
148
+ ? _1.ConsistencyLevelEnum[consistency_level]
149
+ : _1.ConsistencyLevelEnum['Bounded'];
150
+ return [4 /*yield*/, (0, utils_1.promisify)(this.grpcClient, 'CreateCollection', __assign(__assign({}, data), { schema: schemaBytes, consistency_level: level }), data.timeout)];
161
151
  case 1:
162
152
  promise = _c.sent();
163
153
  return [2 /*return*/, promise];
@@ -166,37 +156,37 @@ var Collection = /** @class */ (function (_super) {
166
156
  });
167
157
  };
168
158
  /**
169
- * Check if a collection exists.
170
- *
171
- * @param data
172
- * | Property | Type | Description |
173
- * | :-- | :-- | :-- |
174
- * | collection_name | String | Collection name |
175
- * | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
176
- *
177
- * @returns
178
- * | Property | Description |
179
- * | :-- | :-- |
180
- * | status | { error_code: number, reason: string } |
181
- * | value | `true` or `false` |
182
-
183
- *
184
- * #### Example
185
- *
186
- * ```
187
- * new milvusClient(MILUVS_ADDRESS).collectionManager.hasCollection({
188
- * collection_name: 'my_collection',
189
- * });
190
- * ```
191
- */
159
+ * Check if a collection exists.
160
+ *
161
+ * @param data
162
+ * | Property | Type | Description |
163
+ * | :-- | :-- | :-- |
164
+ * | collection_name | String | Collection name |
165
+ * | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
166
+ *
167
+ * @returns
168
+ * | Property | Description |
169
+ * | :-- | :-- |
170
+ * | status | { error_code: number, reason: string } |
171
+ * | value | `true` or `false` |
172
+
173
+ *
174
+ * #### Example
175
+ *
176
+ * ```
177
+ * new milvusClient(MILUVS_ADDRESS).hasCollection({
178
+ * collection_name: 'my_collection',
179
+ * });
180
+ * ```
181
+ */
192
182
  Collection.prototype.hasCollection = function (data) {
193
183
  return __awaiter(this, void 0, void 0, function () {
194
184
  var promise;
195
185
  return __generator(this, function (_a) {
196
186
  switch (_a.label) {
197
187
  case 0:
198
- (0, Validate_1.checkCollectionName)(data);
199
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'HasCollection', data, data.timeout)];
188
+ (0, utils_1.checkCollectionName)(data);
189
+ return [4 /*yield*/, (0, utils_1.promisify)(this.grpcClient, 'HasCollection', data, data.timeout)];
200
190
  case 1:
201
191
  promise = _a.sent();
202
192
  return [2 /*return*/, promise];
@@ -205,36 +195,36 @@ var Collection = /** @class */ (function (_super) {
205
195
  });
206
196
  };
207
197
  /**
208
- * List all collections or get collection loading status.
209
- *
210
- * @param data
211
- * | Property | Type | Description |
212
- * | :-- | :-- | :-- |
213
- * | type(optional) | enum | All -> 0, Loaded -> 1 |
214
- * | collection_names(optional) | String[] | If `type = Loaded`, Milvus will return `collection_names inMemory_percentages` |
215
- * | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
198
+ * List all collections or get collection loading status.
199
+ *
200
+ * @param data
201
+ * | Property | Type | Description |
202
+ * | :-- | :-- | :-- |
203
+ * | type(optional) | enum | All -> 0, Loaded -> 1 |
204
+ * | collection_names(optional) | String[] | If `type = Loaded`, Milvus will return `collection_names inMemory_percentages` |
205
+ * | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
216
206
 
217
- *
218
- * @returns
219
- * | Property | Description |
220
- * | :-- | :-- |
221
- * | status | { error_code: number, reason: string } |
222
- * | data | Contains collection name, ID , timestamp (UTC created time), and loadedPercentage (100 means loaded) |
223
- *
224
- *
225
- * #### Example
226
- *
227
- * ```
228
- * new milvusClient(MILUVS_ADDRESS).collectionManager.showCollections();
229
- * ```
230
- */
207
+ *
208
+ * @returns
209
+ * | Property | Description |
210
+ * | :-- | :-- |
211
+ * | status | { error_code: number, reason: string } |
212
+ * | data | Contains collection name, ID , timestamp (UTC created time), and loadedPercentage (100 means loaded) |
213
+ *
214
+ *
215
+ * #### Example
216
+ *
217
+ * ```
218
+ * new milvusClient(MILUVS_ADDRESS).showCollections();
219
+ * ```
220
+ */
231
221
  Collection.prototype.showCollections = function (data) {
232
222
  return __awaiter(this, void 0, void 0, function () {
233
223
  var promise, result;
234
224
  return __generator(this, function (_a) {
235
225
  switch (_a.label) {
236
- case 0: return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'ShowCollections', {
237
- type: data ? data.type : types_1.ShowCollectionsType.All,
226
+ case 0: return [4 /*yield*/, (0, utils_1.promisify)(this.grpcClient, 'ShowCollections', {
227
+ type: data ? data.type : _1.ShowCollectionsType.All,
238
228
  collection_names: (data === null || data === void 0 ? void 0 : data.collection_names) || [],
239
229
  }, data === null || data === void 0 ? void 0 : data.timeout)];
240
230
  case 1:
@@ -274,7 +264,7 @@ var Collection = /** @class */ (function (_super) {
274
264
  * #### Example
275
265
  *
276
266
  * ```
277
- * new milvusClient(MILUVS_ADDRESS).collectionManager.describeCollection({
267
+ * new milvusClient(MILUVS_ADDRESS).describeCollection({
278
268
  * collection_name: 'my_collection',
279
269
  * });
280
270
  * ```
@@ -285,8 +275,8 @@ var Collection = /** @class */ (function (_super) {
285
275
  return __generator(this, function (_a) {
286
276
  switch (_a.label) {
287
277
  case 0:
288
- (0, Validate_1.checkCollectionName)(data);
289
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'DescribeCollection', data, data.timeout)];
278
+ (0, utils_1.checkCollectionName)(data);
279
+ return [4 /*yield*/, (0, utils_1.promisify)(this.grpcClient, 'DescribeCollection', data, data.timeout)];
290
280
  case 1:
291
281
  promise = _a.sent();
292
282
  return [2 /*return*/, promise];
@@ -314,7 +304,7 @@ var Collection = /** @class */ (function (_super) {
314
304
  * #### Example
315
305
  *
316
306
  * ```
317
- * new milvusClient(MILUVS_ADDRESS).collectionManager.getCollectionStatistics({
307
+ * new milvusClient(MILUVS_ADDRESS).getCollectionStatistics({
318
308
  * collection_name: 'my_collection',
319
309
  * });
320
310
  * ```
@@ -325,11 +315,11 @@ var Collection = /** @class */ (function (_super) {
325
315
  return __generator(this, function (_a) {
326
316
  switch (_a.label) {
327
317
  case 0:
328
- (0, Validate_1.checkCollectionName)(data);
329
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'GetCollectionStatistics', data, data.timeout)];
318
+ (0, utils_1.checkCollectionName)(data);
319
+ return [4 /*yield*/, (0, utils_1.promisify)(this.grpcClient, 'GetCollectionStatistics', data, data.timeout)];
330
320
  case 1:
331
321
  promise = _a.sent();
332
- promise.data = (0, Format_1.formatKeyValueData)(promise.stats, ['row_count']);
322
+ promise.data = (0, utils_1.formatKeyValueData)(promise.stats, ['row_count']);
333
323
  return [2 /*return*/, promise];
334
324
  }
335
325
  });
@@ -356,7 +346,7 @@ var Collection = /** @class */ (function (_super) {
356
346
  * #### Example
357
347
  *
358
348
  * ```
359
- * new milvusClient(MILUVS_ADDRESS).collectionManager.loadCollection({
349
+ * new milvusClient(MILUVS_ADDRESS).loadCollection({
360
350
  * collection_name: 'my_collection',
361
351
  * });
362
352
  * ```
@@ -367,8 +357,8 @@ var Collection = /** @class */ (function (_super) {
367
357
  return __generator(this, function (_a) {
368
358
  switch (_a.label) {
369
359
  case 0:
370
- (0, Validate_1.checkCollectionName)(data);
371
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'LoadCollection', data, data.timeout)];
360
+ (0, utils_1.checkCollectionName)(data);
361
+ return [4 /*yield*/, (0, utils_1.promisify)(this.grpcClient, 'LoadCollection', data, data.timeout)];
372
362
  case 1:
373
363
  promise = _a.sent();
374
364
  return [2 /*return*/, promise];
@@ -397,7 +387,7 @@ var Collection = /** @class */ (function (_super) {
397
387
  * #### Example
398
388
  *
399
389
  * ```
400
- * new milvusClient(MILUVS_ADDRESS).collectionManager.loadCollectionSync({
390
+ * new milvusClient(MILUVS_ADDRESS).loadCollectionSync({
401
391
  * collection_name: 'my_collection',
402
392
  * });
403
393
  * ```
@@ -408,11 +398,11 @@ var Collection = /** @class */ (function (_super) {
408
398
  return __generator(this, function (_a) {
409
399
  switch (_a.label) {
410
400
  case 0:
411
- (0, Validate_1.checkCollectionName)(data);
412
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'LoadCollection', data, data.timeout)];
401
+ (0, utils_1.checkCollectionName)(data);
402
+ return [4 /*yield*/, (0, utils_1.promisify)(this.grpcClient, 'LoadCollection', data, data.timeout)];
413
403
  case 1:
414
404
  promise = _a.sent();
415
- if (promise.error_code !== types_1.ErrorCode.SUCCESS) {
405
+ if (promise.error_code !== _1.ErrorCode.SUCCESS) {
416
406
  throw new Error("ErrorCode: ".concat(promise.error_code, ". Reason: ").concat(promise.reason));
417
407
  }
418
408
  loadedPercentage = 0;
@@ -421,11 +411,11 @@ var Collection = /** @class */ (function (_super) {
421
411
  if (!(Number(loadedPercentage) < 100)) return [3 /*break*/, 4];
422
412
  return [4 /*yield*/, this.showCollections({
423
413
  collection_names: [data.collection_name],
424
- type: types_1.ShowCollectionsType.Loaded,
414
+ type: _1.ShowCollectionsType.Loaded,
425
415
  })];
426
416
  case 3:
427
417
  res = _a.sent();
428
- if (res.status.error_code !== types_1.ErrorCode.SUCCESS) {
418
+ if (res.status.error_code !== _1.ErrorCode.SUCCESS) {
429
419
  throw new Error("ErrorCode: ".concat(res.status.error_code, ". Reason: ").concat(res.status.reason));
430
420
  }
431
421
  // Because we pass collection_names in showCollections, so it will only this collection in result.
@@ -455,7 +445,7 @@ var Collection = /** @class */ (function (_super) {
455
445
  * #### Example
456
446
  *
457
447
  * ```
458
- * new milvusClient(MILUVS_ADDRESS).collectionManager.releaseCollection({
448
+ * new milvusClient(MILUVS_ADDRESS).releaseCollection({
459
449
  * collection_name: 'my_collection',
460
450
  * });
461
451
  * ```
@@ -466,8 +456,8 @@ var Collection = /** @class */ (function (_super) {
466
456
  return __generator(this, function (_a) {
467
457
  switch (_a.label) {
468
458
  case 0:
469
- (0, Validate_1.checkCollectionName)(data);
470
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'ReleaseCollection', data, data.timeout)];
459
+ (0, utils_1.checkCollectionName)(data);
460
+ return [4 /*yield*/, (0, utils_1.promisify)(this.grpcClient, 'ReleaseCollection', data, data.timeout)];
471
461
  case 1:
472
462
  promise = _a.sent();
473
463
  return [2 /*return*/, promise];
@@ -494,7 +484,7 @@ var Collection = /** @class */ (function (_super) {
494
484
  * #### Example
495
485
  *
496
486
  * ```
497
- * new milvusClient(MILUVS_ADDRESS).collectionManager.renameCollection({
487
+ * new milvusClient(MILUVS_ADDRESS).renameCollection({
498
488
  * collection_name: 'my_collection',
499
489
  * new_collection_name: 'my_new_collection'
500
490
  * });
@@ -505,7 +495,7 @@ var Collection = /** @class */ (function (_super) {
505
495
  var promise;
506
496
  return __generator(this, function (_a) {
507
497
  switch (_a.label) {
508
- case 0: return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'RenameCollection', {
498
+ case 0: return [4 /*yield*/, (0, utils_1.promisify)(this.grpcClient, 'RenameCollection', {
509
499
  oldName: data.collection_name,
510
500
  newName: data.new_collection_name,
511
501
  }, data.timeout)];
@@ -534,7 +524,7 @@ var Collection = /** @class */ (function (_super) {
534
524
  * #### Example
535
525
  *
536
526
  * ```
537
- * new milvusClient(MILUVS_ADDRESS).collectionManager.dropCollection({
527
+ * new milvusClient(MILUVS_ADDRESS).dropCollection({
538
528
  * collection_name: 'my_collection',
539
529
  * });
540
530
  * ```
@@ -545,8 +535,8 @@ var Collection = /** @class */ (function (_super) {
545
535
  return __generator(this, function (_a) {
546
536
  switch (_a.label) {
547
537
  case 0:
548
- (0, Validate_1.checkCollectionName)(data);
549
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'DropCollection', data, data.timeout)];
538
+ (0, utils_1.checkCollectionName)(data);
539
+ return [4 /*yield*/, (0, utils_1.promisify)(this.grpcClient, 'DropCollection', data, data.timeout)];
550
540
  case 1:
551
541
  promise = _a.sent();
552
542
  return [2 /*return*/, promise];
@@ -574,7 +564,7 @@ var Collection = /** @class */ (function (_super) {
574
564
  * #### Example
575
565
  *
576
566
  * ```
577
- * new milvusClient(MILUVS_ADDRESS).collectionManager.createAlias({
567
+ * new milvusClient(MILUVS_ADDRESS).createAlias({
578
568
  * alias: 'my_collection_alis',
579
569
  * collection_name: 'my_collection',
580
570
  * });
@@ -586,11 +576,11 @@ var Collection = /** @class */ (function (_super) {
586
576
  return __generator(this, function (_a) {
587
577
  switch (_a.label) {
588
578
  case 0:
589
- (0, Validate_1.checkCollectionName)(data);
579
+ (0, utils_1.checkCollectionName)(data);
590
580
  if (!data.alias) {
591
- throw new Error(ErrorReason_1.ERROR_REASONS.ALIAS_NAME_IS_REQUIRED);
581
+ throw new Error(_1.ERROR_REASONS.ALIAS_NAME_IS_REQUIRED);
592
582
  }
593
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'CreateAlias', data, data.timeout)];
583
+ return [4 /*yield*/, (0, utils_1.promisify)(this.grpcClient, 'CreateAlias', data, data.timeout)];
594
584
  case 1:
595
585
  promise = _a.sent();
596
586
  return [2 /*return*/, promise];
@@ -618,7 +608,7 @@ var Collection = /** @class */ (function (_super) {
618
608
  * #### Example
619
609
  *
620
610
  * ```
621
- * new milvusClient(MILUVS_ADDRESS).collectionManager.dropAlias({
611
+ * new milvusClient(MILUVS_ADDRESS).dropAlias({
622
612
  * alias: 'my_collection_alis',
623
613
  * collection_name: 'my_collection',
624
614
  * });
@@ -631,9 +621,9 @@ var Collection = /** @class */ (function (_super) {
631
621
  switch (_a.label) {
632
622
  case 0:
633
623
  if (!data.alias) {
634
- throw new Error(ErrorReason_1.ERROR_REASONS.ALIAS_NAME_IS_REQUIRED);
624
+ throw new Error(_1.ERROR_REASONS.ALIAS_NAME_IS_REQUIRED);
635
625
  }
636
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'DropAlias', data, data.timeout)];
626
+ return [4 /*yield*/, (0, utils_1.promisify)(this.grpcClient, 'DropAlias', data, data.timeout)];
637
627
  case 1:
638
628
  promise = _a.sent();
639
629
  return [2 /*return*/, promise];
@@ -661,7 +651,7 @@ var Collection = /** @class */ (function (_super) {
661
651
  * #### Example
662
652
  *
663
653
  * ```
664
- * new milvusClient(MILUVS_ADDRESS).collectionManager.alterAlais({
654
+ * new milvusClient(MILUVS_ADDRESS).alterAlais({
665
655
  * alias: 'my_collection_alis',
666
656
  * collection_name: 'my_collection',
667
657
  * });
@@ -673,11 +663,11 @@ var Collection = /** @class */ (function (_super) {
673
663
  return __generator(this, function (_a) {
674
664
  switch (_a.label) {
675
665
  case 0:
676
- (0, Validate_1.checkCollectionName)(data);
666
+ (0, utils_1.checkCollectionName)(data);
677
667
  if (!data.alias) {
678
- throw new Error(ErrorReason_1.ERROR_REASONS.ALIAS_NAME_IS_REQUIRED);
668
+ throw new Error(_1.ERROR_REASONS.ALIAS_NAME_IS_REQUIRED);
679
669
  }
680
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'AlterAlias', data, data.timeout)];
670
+ return [4 /*yield*/, (0, utils_1.promisify)(this.grpcClient, 'AlterAlias', data, data.timeout)];
681
671
  case 1:
682
672
  promise = _a.sent();
683
673
  return [2 /*return*/, promise];
@@ -703,7 +693,7 @@ var Collection = /** @class */ (function (_super) {
703
693
  * #### Example
704
694
  *
705
695
  * ```
706
- * new milvusClient(MILUVS_ADDRESS).collectionManager.compact({
696
+ * new milvusClient(MILUVS_ADDRESS).compact({
707
697
  * collection_name: 'my_collection',
708
698
  * });
709
699
  * ```
@@ -714,11 +704,11 @@ var Collection = /** @class */ (function (_super) {
714
704
  return __generator(this, function (_a) {
715
705
  switch (_a.label) {
716
706
  case 0:
717
- (0, Validate_1.checkCollectionName)(data);
707
+ (0, utils_1.checkCollectionName)(data);
718
708
  return [4 /*yield*/, this.describeCollection(data)];
719
709
  case 1:
720
710
  collectionInfo = _a.sent();
721
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'ManualCompaction', {
711
+ return [4 /*yield*/, (0, utils_1.promisify)(this.grpcClient, 'ManualCompaction', {
722
712
  collectionID: collectionInfo.collectionID,
723
713
  }, data.timeout)];
724
714
  case 2:
@@ -746,7 +736,7 @@ var Collection = /** @class */ (function (_super) {
746
736
  * #### Example
747
737
  *
748
738
  * ```
749
- * new milvusClient(MILUVS_ADDRESS).collectionManager.getCompactionState({
739
+ * new milvusClient(MILUVS_ADDRESS).getCompactionState({
750
740
  * compactionID: compactionID,
751
741
  * });
752
742
  * ```
@@ -758,9 +748,9 @@ var Collection = /** @class */ (function (_super) {
758
748
  switch (_a.label) {
759
749
  case 0:
760
750
  if (!data || !data.compactionID) {
761
- throw new Error(ErrorReason_1.ERROR_REASONS.COMPACTIONID_IS_REQUIRED);
751
+ throw new Error(_1.ERROR_REASONS.COMPACTIONID_IS_REQUIRED);
762
752
  }
763
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'GetCompactionState', data, data.timeout)];
753
+ return [4 /*yield*/, (0, utils_1.promisify)(this.grpcClient, 'GetCompactionState', data, data.timeout)];
764
754
  case 1:
765
755
  res = _a.sent();
766
756
  return [2 /*return*/, res];
@@ -786,7 +776,7 @@ var Collection = /** @class */ (function (_super) {
786
776
  * #### Example
787
777
  *
788
778
  * ```
789
- * new milvusClient(MILUVS_ADDRESS).collectionManager.getCompactionStateWithPlans({
779
+ * new milvusClient(MILUVS_ADDRESS).getCompactionStateWithPlans({
790
780
  * compactionID: compactionID,
791
781
  * });
792
782
  * ```
@@ -798,9 +788,9 @@ var Collection = /** @class */ (function (_super) {
798
788
  switch (_a.label) {
799
789
  case 0:
800
790
  if (!data || !data.compactionID) {
801
- throw new Error(ErrorReason_1.ERROR_REASONS.COMPACTIONID_IS_REQUIRED);
791
+ throw new Error(_1.ERROR_REASONS.COMPACTIONID_IS_REQUIRED);
802
792
  }
803
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'GetCompactionStateWithPlans', data, data.timeout)];
793
+ return [4 /*yield*/, (0, utils_1.promisify)(this.grpcClient, 'GetCompactionStateWithPlans', data, data.timeout)];
804
794
  case 1:
805
795
  res = _a.sent();
806
796
  return [2 /*return*/, res];
@@ -826,7 +816,7 @@ var Collection = /** @class */ (function (_super) {
826
816
  * #### Example
827
817
  *
828
818
  * ```
829
- * new milvusClient(MILUVS_ADDRESS).collectionManager.getReplicas({
819
+ * new milvusClient(MILUVS_ADDRESS).getReplicas({
830
820
  * collectionID: collectionID,
831
821
  * });
832
822
  *
@@ -855,9 +845,94 @@ var Collection = /** @class */ (function (_super) {
855
845
  switch (_a.label) {
856
846
  case 0:
857
847
  if (!data || !data.collectionID) {
858
- throw new Error(ErrorReason_1.ERROR_REASONS.COLLECTION_ID_IS_REQUIRED);
848
+ throw new Error(_1.ERROR_REASONS.COLLECTION_ID_IS_REQUIRED);
849
+ }
850
+ return [4 /*yield*/, (0, utils_1.promisify)(this.grpcClient, 'GetReplicas', data, data.timeout)];
851
+ case 1:
852
+ res = _a.sent();
853
+ return [2 /*return*/, res];
854
+ }
855
+ });
856
+ });
857
+ };
858
+ /**
859
+ * Get loading progress of a collection
860
+ *
861
+ * @param data
862
+ * | Property | Type | Description |
863
+ * | :-- | :-- | :-- |
864
+ * | collection_name | string | the name of the collection |
865
+ * | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
866
+ *
867
+ * @returns
868
+ * | Property | Description |
869
+ * | :-- | :-- |
870
+ * | status | { error_code: number, reason: string } |
871
+ * | total_row_num | the total number of rows in the collection |
872
+ * | total_loaded_row_num | the total number of loaded rows in the collection |
873
+ *
874
+ * @throws {Error} if `collection_name` property is not present in `data`
875
+ *
876
+ * #### Example
877
+ *
878
+ * ```
879
+ * new milvusClient(MILUVS_ADDRESS).getLoadingProgress({
880
+ * collection_name: 'my_collection',
881
+ * });
882
+ * ```
883
+ */
884
+ Collection.prototype.getLoadingProgress = function (data) {
885
+ return __awaiter(this, void 0, void 0, function () {
886
+ var res;
887
+ return __generator(this, function (_a) {
888
+ switch (_a.label) {
889
+ case 0:
890
+ if (!data || !data.collection_name) {
891
+ throw new Error(_1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
892
+ }
893
+ return [4 /*yield*/, (0, utils_1.promisify)(this.grpcClient, 'GetLoadingProgress', data, data.timeout)];
894
+ case 1:
895
+ res = _a.sent();
896
+ return [2 /*return*/, res];
897
+ }
898
+ });
899
+ });
900
+ };
901
+ /**
902
+ * Get the loading state of a collection
903
+ *
904
+ * @param data
905
+ * | Property | Type | Description |
906
+ * | :-- | :-- | :-- |
907
+ * | collection_name | string | the name of the collection |
908
+ * | timeout? | number | An optional duration of time in milliseconds to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or an error occurs. Default is undefined |
909
+ *
910
+ * @returns
911
+ * | Property | Description |
912
+ * | :-- | :-- |
913
+ * | status | { error_code: number, reason: string } |
914
+ * | state | the loading state of the collection |
915
+ *
916
+ * @throws {Error} if `collection_name` property is not present in `data`
917
+ *
918
+ * #### Example
919
+ *
920
+ * ```
921
+ * new milvusClient(MILUVS_ADDRESS).getLoadState({
922
+ * collection_name: 'my_collection',
923
+ * });
924
+ * ```
925
+ */
926
+ Collection.prototype.getLoadState = function (data) {
927
+ return __awaiter(this, void 0, void 0, function () {
928
+ var res;
929
+ return __generator(this, function (_a) {
930
+ switch (_a.label) {
931
+ case 0:
932
+ if (!data || !data.collection_name) {
933
+ throw new Error(_1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
859
934
  }
860
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'GetReplicas', data, data.timeout)];
935
+ return [4 /*yield*/, (0, utils_1.promisify)(this.grpcClient, 'GetLoadState', data, data.timeout)];
861
936
  case 1:
862
937
  res = _a.sent();
863
938
  return [2 /*return*/, res];
@@ -866,6 +941,6 @@ var Collection = /** @class */ (function (_super) {
866
941
  });
867
942
  };
868
943
  return Collection;
869
- }(Client_1.Client));
944
+ }(BaseClient_1.BaseClient));
870
945
  exports.Collection = Collection;
871
946
  //# sourceMappingURL=Collection.js.map