@zilliz/milvus2-sdk-node 2.1.2 → 2.2.0-alpha.1

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 (47) hide show
  1. package/README.md +29 -40
  2. package/dist/milvus/Collection.d.ts +65 -11
  3. package/dist/milvus/Collection.js +111 -35
  4. package/dist/milvus/Collection.js.map +1 -1
  5. package/dist/milvus/Data.d.ts +71 -13
  6. package/dist/milvus/Data.js +153 -50
  7. package/dist/milvus/Data.js.map +1 -1
  8. package/dist/milvus/MilvusIndex.d.ts +5 -1
  9. package/dist/milvus/MilvusIndex.js +11 -9
  10. package/dist/milvus/MilvusIndex.js.map +1 -1
  11. package/dist/milvus/Partition.d.ts +10 -6
  12. package/dist/milvus/Partition.js +15 -11
  13. package/dist/milvus/Partition.js.map +1 -1
  14. package/dist/milvus/User.d.ts +3 -3
  15. package/dist/milvus/User.js +10 -10
  16. package/dist/milvus/User.js.map +1 -1
  17. package/dist/milvus/const/ErrorReason.d.ts +4 -1
  18. package/dist/milvus/const/ErrorReason.js +3 -0
  19. package/dist/milvus/const/ErrorReason.js.map +1 -1
  20. package/dist/milvus/index.d.ts +3 -1
  21. package/dist/milvus/index.js +33 -5
  22. package/dist/milvus/index.js.map +1 -1
  23. package/dist/milvus/types/Collection.d.ts +16 -8
  24. package/dist/milvus/types/Common.d.ts +12 -1
  25. package/dist/milvus/types/Common.js +10 -1
  26. package/dist/milvus/types/Common.js.map +1 -1
  27. package/dist/milvus/types/Data.d.ts +22 -8
  28. package/dist/milvus/types/Index.d.ts +7 -6
  29. package/dist/milvus/types/Partition.d.ts +5 -4
  30. package/dist/milvus/types/Response.d.ts +45 -1
  31. package/dist/milvus/types/Response.js.map +1 -1
  32. package/dist/milvus/types/Search.d.ts +13 -10
  33. package/dist/milvus/types/User.d.ts +6 -3
  34. package/dist/milvus/types.js +5 -1
  35. package/dist/milvus/types.js.map +1 -1
  36. package/dist/milvus/utils/Format.js +14 -10
  37. package/dist/milvus/utils/Format.js.map +1 -1
  38. package/dist/milvus/utils/index.d.ts +1 -1
  39. package/dist/proto/proto/common.proto +71 -33
  40. package/dist/proto/proto/google/protobuf/descriptor.proto +17 -19
  41. package/dist/proto/proto/milvus.proto +293 -82
  42. package/dist/proto/proto/schema.proto +10 -2
  43. package/dist/sdk.json +1 -1
  44. package/dist/utils/index.d.ts +1 -1
  45. package/dist/utils/index.js +12 -7
  46. package/dist/utils/index.js.map +1 -1
  47. package/package.json +10 -10
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  # Milvus2-sdk-node
7
7
 
8
- This is node sdk for [Milvus](https://github.com/milvus-io/milvus).
8
+ Node.js sdk for [Milvus](https://github.com/milvus-io/milvus).
9
9
 
10
10
  ## Compatibility
11
11
 
@@ -15,56 +15,41 @@ The following collection shows Milvus versions and recommended @zilliz/milvus2-s
15
15
  | :------------: | :------------------------------------------: |
16
16
  | 2.0.0 | 2.0.0 |
17
17
  | 2.0.1 | 2.0.0, 2.0.1 |
18
+ | 2.1.x | 2.1.x |
19
+ | 2.2.x | 2.2.x |
18
20
 
19
21
  ## Dependencies
20
22
 
21
- Milvus: v2+
22
-
23
- Node: v12+
23
+ - Milvus: v2+
24
+ - Node: v12+
24
25
 
25
26
  ## Installation
26
27
 
27
28
  ```javascript
28
- npm install @zilliz/milvus2-sdk-node
29
+ npm install @zilliz/milvus2-sdk-node
29
30
  ```
30
31
 
31
- ## API Support
32
-
33
- | Name | Async | Description |
34
- | :---------------------- | :---- | :--------------------------------------: |
35
- | createCollection | false | Create collection in milvus |
36
- | hasCollection | false | Check collection exist or not |
37
- | showCollections | false | List all collections |
38
- | describeCollection | false | Get collection detail, like name ,schema |
39
- | getCollectionStatistics | false | Get collection statistics like row count |
40
- | loadCollection | true | Load data into cache |
41
- | releaseCollection | true | Release data from cache |
42
- | dropCollection | false | Drop collection from milvus |
43
- | createPartition | false | Create partition in one collection |
44
- | hasPartition | false | Check partition exist or not |
45
- | showPartitions | false | List all partitions for one collection |
46
- | getPartitionStatistics | false | Get partition statistics like row_count |
47
- | loadPartitions | true | Load data into cache |
48
- | releasePartitions | true | Release data from cache |
49
- | dropPartition | false | Drop partition from milvus |
50
- | createIndex | true | Creat index on vector field |
51
- | describeIndex | false | Get index info |
52
- | getIndexState | false | Get index build state |
53
- | getIndexBuildProgress | false | Get index building progress |
54
- | dropIndex | true | Drop index |
55
- | insert | false | Insert data into milvus |
56
- | search | false | Vector similarity search |
57
- | flush | true | Flush Data |
58
- | flushSync | false | Flush Data Sync |
59
- | query | false | Get data by expr |
60
- | compact | true | Do compaction for the collection |
61
- | getCompactionState | true | Get compaction states by compact id |
32
+ ## SDK
33
+
34
+ - [Client](./milvus/Index.ts)
35
+ - [Collection](./milvus/Collection.ts)
36
+ - [Index](./milvus/MilvusIndex.ts)
37
+ - [Partition](./milvus/Partition.ts)
38
+ - [User](./milvus/User.ts)
39
+ - [Utils](./milvus/Utils.ts)
40
+ - [Data](./milvus/Data.ts)
41
+
42
+ More documentation, you can refer [Milvus offical website](https://milvus.io/).
62
43
 
63
44
  ## How to dev
64
- 1. yarn
65
- 2. git submodule init (if this is your first time)
66
- 3. git submodule update --remote
67
- 4. In milvus folder has all milvus related functions.
45
+
46
+ 1. yarn install
47
+ 2. Fetch milvus proto
48
+ 1. `git submodule init` (if this is your first time)
49
+ 2. `git submodule update --remote`
50
+ 3. Add feature in milvus folder.
51
+ 4. Run test `yarn test -- test/Your-test-for-your-feature.spec.ts`
52
+
68
53
  ## Example
69
54
 
70
55
  1. [Hello World](https://github.com/milvus-io/milvus-sdk-node/blob/main/example/HelloMilvus.ts)
@@ -72,3 +57,7 @@ Node: v12+
72
57
  3. [How to insert data](https://github.com/milvus-io/milvus-sdk-node/blob/main/example/Insert.ts)
73
58
  4. [Vector similarity search on float field](https://github.com/milvus-io/milvus-sdk-node/blob/main/example/Search.ts)
74
59
  5. [Vector similarity search on binary field](https://github.com/milvus-io/milvus-sdk-node/blob/main/example/BinarySearch.ts)
60
+
61
+ ## Others
62
+
63
+ [Attu](https://github.com/zilliztech/attu) which is a Milvus web interface tool, depends on Milvus node.js SDK.
@@ -1,6 +1,6 @@
1
- import { CreateCollectionReq, DescribeCollectionReq, DropCollectionReq, GetCollectionStatisticsReq, LoadCollectionReq, ReleaseLoadCollectionReq, ShowCollectionsReq, HasCollectionReq, CreateAliasReq, DropAliasReq, AlterAliasReq, CompactReq, GetCompactionStateReq, GetCompactionPlansReq } from "./types/Collection";
2
- import { BoolResponse, CompactionResponse, DescribeCollectionResponse, GetCompactionPlansResponse, GetCompactionStateResponse, ResStatus, ShowCollectionsResponse, StatisticsResponse } from "./types/Response";
3
- import { Client } from "./Client";
1
+ import { CreateCollectionReq, DescribeCollectionReq, DropCollectionReq, GetCollectionStatisticsReq, LoadCollectionReq, ReleaseLoadCollectionReq, ShowCollectionsReq, HasCollectionReq, CreateAliasReq, DropAliasReq, AlterAliasReq, CompactReq, GetCompactionStateReq, GetCompactionPlansReq, GetReplicaReq } from './types/Collection';
2
+ import { BoolResponse, CompactionResponse, DescribeCollectionResponse, GetCompactionPlansResponse, GetCompactionStateResponse, ResStatus, ShowCollectionsResponse, StatisticsResponse, ReplicasResponse } from './types/Response';
3
+ import { Client } from './Client';
4
4
  /**
5
5
  * See all [collection operation examples](https://github.com/milvus-io/milvus-sdk-node/blob/main/example/Collection.ts).
6
6
  */
@@ -13,8 +13,9 @@ export declare class Collection extends Client {
13
13
  * | :---------------------- | :---- | :------------------------------- |
14
14
  * | collection_name | String | Collection name |
15
15
  * | description | String | Collection description |
16
- * | consistency_level | String | "Strong" | "Session" (default) | "Bounded"| "Eventually" | "Customized"; |
16
+ * | consistency_level | String | "Strong"(Milvus default) | "Session" | "Bounded"| "Eventually" | "Customized"; |
17
17
  * | fields | <a href="https://github.com/milvus-io/milvus-sdk-node/blob/main/milvus/types/Collection.ts#L8" target="_blank">FieldType</a> | Field data |
18
+ * | 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 |
18
19
  *
19
20
  * @return
20
21
  * | Property | Description |
@@ -55,12 +56,14 @@ export declare class Collection extends Client {
55
56
  * | Property | Type | Description |
56
57
  * | :---------------------- | :---- | :------------------------------- |
57
58
  * | collection_name | String | Collection name |
59
+ * | 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 |
58
60
  *
59
61
  * @return
60
62
  * | Property | Description |
61
63
  * | :-------------| :------------------------------- |
62
64
  * | status | { error_code: number, reason: string }|
63
65
  * | value | `true` or `false` |
66
+
64
67
  *
65
68
  * #### Example
66
69
  *
@@ -79,7 +82,7 @@ export declare class Collection extends Client {
79
82
  * | :----------------- | :---- | :------------------------------- |
80
83
  * | type(optional) | enum | All -> 0, Loaded -> 1 |
81
84
  * | collection_names(optional) | String[] | If `type = Loaded`, Milvus will return `collection_names inMemory_percentages` |
82
- *
85
+ * | 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 |
83
86
  *
84
87
  * @return
85
88
  * | Property | Description |
@@ -101,7 +104,8 @@ export declare class Collection extends Client {
101
104
  * @param data
102
105
  * | Property | Type | Description |
103
106
  * | :----------------- | :---- | :------------------------------- |
104
- * | collection_name | String | Collection name |
107
+ * | collection_name | String | Collection name |
108
+ * | 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 |
105
109
  *
106
110
  * @return
107
111
  * | Property | Description |
@@ -126,7 +130,8 @@ export declare class Collection extends Client {
126
130
  * @param data
127
131
  * | Property | Type | Description |
128
132
  * | :----------------- | :---- | :------------------------------- |
129
- * | collection_name | String | Collection name |
133
+ * | collection_name | String | Collection name |
134
+ * | 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 |
130
135
  *
131
136
  * @return
132
137
  * | Property | Description |
@@ -152,7 +157,9 @@ export declare class Collection extends Client {
152
157
  * @param data
153
158
  * | Property | Type | Description |
154
159
  * | :----------------- | :---- | :------------------------------- |
155
- * | collection_name | String | Collection name |
160
+ * | collection_name | String | Collection name |
161
+ * | replica_number? | number | Collection name |
162
+ * | 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 |
156
163
  *
157
164
  * @return
158
165
  * | Property | Description |
@@ -176,7 +183,8 @@ export declare class Collection extends Client {
176
183
  * @param data
177
184
  * | Property | Type | Description |
178
185
  * | :----------------- | :---- | :------------------------------- |
179
- * | collection_name | String | Collection name |
186
+ * | collection_name | String | Collection name |
187
+ * | 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 |
180
188
  *
181
189
  * @return
182
190
  * | Property | Description |
@@ -200,7 +208,8 @@ export declare class Collection extends Client {
200
208
  * @param data
201
209
  * | Property | Type | Description |
202
210
  * | :----------------- | :---- | :------------------------------- |
203
- * | collection_name | String | Collection name |
211
+ * | collection_name | String | Collection name |
212
+ * | 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 |
204
213
  *
205
214
  * @return
206
215
  * | Property | Description |
@@ -224,6 +233,7 @@ export declare class Collection extends Client {
224
233
  * | Property | Type | Description |
225
234
  * | :----------------- | :---- | :------------------------------- |
226
235
  * | collection_name | String | Collection name |
236
+ * | 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 |
227
237
  *
228
238
  * @return
229
239
  * | Property | Description |
@@ -262,7 +272,8 @@ export declare class Collection extends Client {
262
272
  * @param data
263
273
  * | Property | Type | Description |
264
274
  * | :----------------- | :---- | :------------------------------- |
265
- * | collection_name | String | The collection name to compact |
275
+ * | collection_name | String | The collection name to compact |
276
+ * | 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 |
266
277
  *
267
278
  * @return
268
279
  * | Property | Description |
@@ -286,6 +297,7 @@ export declare class Collection extends Client {
286
297
  * | Property | Type | Description |
287
298
  * | :----------------- | :---- | :------------------------------- |
288
299
  * | compactionID | number or string | the id returned by compact |
300
+ * | 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 |
289
301
  *
290
302
  * @return
291
303
  * | Property | Description |
@@ -309,6 +321,7 @@ export declare class Collection extends Client {
309
321
  * | Property | Type | Description |
310
322
  * | :----------------- | :---- | :------------------------------- |
311
323
  * | compactionID | number or string | the id returned by compact |
324
+ * | 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 |
312
325
  *
313
326
  * @return
314
327
  * | Property | Description |
@@ -325,4 +338,45 @@ export declare class Collection extends Client {
325
338
  * ```
326
339
  */
327
340
  getCompactionStateWithPlans(data: GetCompactionPlansReq): Promise<GetCompactionPlansResponse>;
341
+ /**
342
+ * Get replicas
343
+ *
344
+ * @param data
345
+ * | Property | Type | Description |
346
+ * | :----------------- | :---- | :------------------------------- |
347
+ * | collectionID | number or string | the id returned by compact |
348
+ * | 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 |
349
+ *
350
+ * @return
351
+ * | Property | Description |
352
+ * | :-------------| :-------- |
353
+ * | status | { error_code: number, reason: string }|
354
+ * | ReplicaInfo[] | replica info array |
355
+ *
356
+ * #### Example
357
+ *
358
+ * ```
359
+ * new milvusClient(MILUVS_ADDRESS).collectionManager.getReplicas({
360
+ * collectionID: collectionID,
361
+ * });
362
+ *
363
+ * ```
364
+ *
365
+ * Return
366
+ * ```
367
+ * {
368
+ * replicas: [
369
+ * {
370
+ * partition_ids: [Array],
371
+ * shard_replicas: [Array],
372
+ * node_ids: [Array],
373
+ * replicaID: '436724291187770258',
374
+ * collectionID: '436777253933154305'
375
+ * }
376
+ * ],
377
+ * status: { error_code: 'Success', reason: '' }
378
+ * }
379
+ * ```
380
+ */
381
+ getReplicas(data: GetReplicaReq): Promise<ReplicasResponse>;
328
382
  }
@@ -75,7 +75,7 @@ var Validate_1 = require("./utils/Validate");
75
75
  var path_1 = __importDefault(require("path"));
76
76
  var Format_1 = require("./utils/Format");
77
77
  var Client_1 = require("./Client");
78
- var schemaPath = path_1.default.resolve(__dirname, "../proto/proto/schema.proto");
78
+ var schemaPath = path_1.default.resolve(__dirname, '../proto/proto/schema.proto');
79
79
  /**
80
80
  * See all [collection operation examples](https://github.com/milvus-io/milvus-sdk-node/blob/main/example/Collection.ts).
81
81
  */
@@ -92,8 +92,9 @@ var Collection = /** @class */ (function (_super) {
92
92
  * | :---------------------- | :---- | :------------------------------- |
93
93
  * | collection_name | String | Collection name |
94
94
  * | description | String | Collection description |
95
- * | consistency_level | String | "Strong" | "Session" (default) | "Bounded"| "Eventually" | "Customized"; |
95
+ * | consistency_level | String | "Strong"(Milvus default) | "Session" | "Bounded"| "Eventually" | "Customized"; |
96
96
  * | fields | <a href="https://github.com/milvus-io/milvus-sdk-node/blob/main/milvus/types/Collection.ts#L8" target="_blank">FieldType</a> | Field data |
97
+ * | 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 |
97
98
  *
98
99
  * @return
99
100
  * | Property | Description |
@@ -128,33 +129,36 @@ var Collection = /** @class */ (function (_super) {
128
129
  */
129
130
  Collection.prototype.createCollection = function (data) {
130
131
  return __awaiter(this, void 0, void 0, function () {
131
- var _a, fields, collection_name, description, _b, consistency_level, root, CollectionSchema, FieldSchema, payload, collectionParams, schemaBtyes, promise;
132
+ var _a, fields, collection_name, description, _b, consistency_level, root, CollectionSchema, FieldSchema, payload, collectionParams, schemaBtyes, level, promise;
132
133
  return __generator(this, function (_c) {
133
134
  switch (_c.label) {
134
135
  case 0:
135
- _a = data || {}, fields = _a.fields, collection_name = _a.collection_name, description = _a.description, _b = _a.consistency_level, consistency_level = _b === void 0 ? "Session" : _b;
136
+ _a = data || {}, fields = _a.fields, collection_name = _a.collection_name, description = _a.description, _b = _a.consistency_level, consistency_level = _b === void 0 ? 'Bounded' : _b;
136
137
  if (!fields || !fields.length || !collection_name) {
137
138
  throw new Error(ErrorReason_1.ERROR_REASONS.CREATE_COLLECTION_CHECK_PARAMS);
138
139
  }
139
- Validate_1.checkCollectionFields(fields);
140
+ (0, Validate_1.checkCollectionFields)(fields);
140
141
  return [4 /*yield*/, protobufjs_1.default.load(schemaPath)];
141
142
  case 1:
142
143
  root = _c.sent();
143
- CollectionSchema = root.lookupType("milvus.proto.schema.CollectionSchema");
144
- FieldSchema = root.lookupType("milvus.proto.schema.FieldSchema");
144
+ CollectionSchema = root.lookupType('milvus.proto.schema.CollectionSchema');
145
+ FieldSchema = root.lookupType('milvus.proto.schema.FieldSchema');
145
146
  payload = {
146
147
  name: collection_name,
147
- description: description || "",
148
+ description: description || '',
148
149
  fields: [],
149
150
  };
150
151
  data.fields.forEach(function (field) {
151
- var value = __assign(__assign({}, field), { typeParams: Format_1.parseToKeyValue(field.type_params), dataType: field.data_type, isPrimaryKey: field.is_primary_key });
152
+ var value = __assign(__assign({}, field), { typeParams: (0, Format_1.parseToKeyValue)(field.type_params), dataType: field.data_type, isPrimaryKey: field.is_primary_key });
152
153
  var fieldParams = FieldSchema.create(value);
153
154
  payload.fields.push(fieldParams);
154
155
  });
155
156
  collectionParams = CollectionSchema.create(payload);
156
157
  schemaBtyes = CollectionSchema.encode(collectionParams).finish();
157
- return [4 /*yield*/, utils_1.promisify(this.client, "CreateCollection", __assign(__assign({}, data), { schema: schemaBtyes, consistency_level: Collection_1.ConsistencyLevelEnum[consistency_level] || Collection_1.ConsistencyLevelEnum.Session }))];
158
+ level = Object.keys(Collection_1.ConsistencyLevelEnum).includes(consistency_level)
159
+ ? Collection_1.ConsistencyLevelEnum[consistency_level]
160
+ : Collection_1.ConsistencyLevelEnum['Bounded'];
161
+ return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'CreateCollection', __assign(__assign({}, data), { schema: schemaBtyes, consistency_level: level }), data.timeout)];
158
162
  case 2:
159
163
  promise = _c.sent();
160
164
  return [2 /*return*/, promise];
@@ -169,12 +173,14 @@ var Collection = /** @class */ (function (_super) {
169
173
  * | Property | Type | Description |
170
174
  * | :---------------------- | :---- | :------------------------------- |
171
175
  * | collection_name | String | Collection name |
176
+ * | 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 |
172
177
  *
173
178
  * @return
174
179
  * | Property | Description |
175
180
  * | :-------------| :------------------------------- |
176
181
  * | status | { error_code: number, reason: string }|
177
182
  * | value | `true` or `false` |
183
+
178
184
  *
179
185
  * #### Example
180
186
  *
@@ -191,7 +197,7 @@ var Collection = /** @class */ (function (_super) {
191
197
  switch (_a.label) {
192
198
  case 0:
193
199
  this.checkCollectionName(data);
194
- return [4 /*yield*/, utils_1.promisify(this.client, "HasCollection", data)];
200
+ return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'HasCollection', data, data.timeout)];
195
201
  case 1:
196
202
  promise = _a.sent();
197
203
  return [2 /*return*/, promise];
@@ -207,7 +213,7 @@ var Collection = /** @class */ (function (_super) {
207
213
  * | :----------------- | :---- | :------------------------------- |
208
214
  * | type(optional) | enum | All -> 0, Loaded -> 1 |
209
215
  * | collection_names(optional) | String[] | If `type = Loaded`, Milvus will return `collection_names inMemory_percentages` |
210
- *
216
+ * | 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 |
211
217
  *
212
218
  * @return
213
219
  * | Property | Description |
@@ -227,10 +233,10 @@ var Collection = /** @class */ (function (_super) {
227
233
  var promise, result;
228
234
  return __generator(this, function (_a) {
229
235
  switch (_a.label) {
230
- case 0: return [4 /*yield*/, utils_1.promisify(this.client, "ShowCollections", {
236
+ case 0: return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'ShowCollections', {
231
237
  type: data ? data.type : Collection_1.ShowCollectionsType.All,
232
238
  collection_names: (data === null || data === void 0 ? void 0 : data.collection_names) || [],
233
- })];
239
+ }, data === null || data === void 0 ? void 0 : data.timeout)];
234
240
  case 1:
235
241
  promise = _a.sent();
236
242
  result = [];
@@ -254,7 +260,8 @@ var Collection = /** @class */ (function (_super) {
254
260
  * @param data
255
261
  * | Property | Type | Description |
256
262
  * | :----------------- | :---- | :------------------------------- |
257
- * | collection_name | String | Collection name |
263
+ * | collection_name | String | Collection name |
264
+ * | 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 |
258
265
  *
259
266
  * @return
260
267
  * | Property | Description |
@@ -279,7 +286,7 @@ var Collection = /** @class */ (function (_super) {
279
286
  switch (_a.label) {
280
287
  case 0:
281
288
  this.checkCollectionName(data);
282
- return [4 /*yield*/, utils_1.promisify(this.client, "DescribeCollection", data)];
289
+ return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'DescribeCollection', data, data.timeout)];
283
290
  case 1:
284
291
  promise = _a.sent();
285
292
  return [2 /*return*/, promise];
@@ -293,7 +300,8 @@ var Collection = /** @class */ (function (_super) {
293
300
  * @param data
294
301
  * | Property | Type | Description |
295
302
  * | :----------------- | :---- | :------------------------------- |
296
- * | collection_name | String | Collection name |
303
+ * | collection_name | String | Collection name |
304
+ * | 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 |
297
305
  *
298
306
  * @return
299
307
  * | Property | Description |
@@ -318,10 +326,10 @@ var Collection = /** @class */ (function (_super) {
318
326
  switch (_a.label) {
319
327
  case 0:
320
328
  this.checkCollectionName(data);
321
- return [4 /*yield*/, utils_1.promisify(this.client, "GetCollectionStatistics", data)];
329
+ return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'GetCollectionStatistics', data, data.timeout)];
322
330
  case 1:
323
331
  promise = _a.sent();
324
- promise.data = Format_1.formatKeyValueData(promise.stats, ["row_count"]);
332
+ promise.data = (0, Format_1.formatKeyValueData)(promise.stats, ['row_count']);
325
333
  return [2 /*return*/, promise];
326
334
  }
327
335
  });
@@ -334,7 +342,9 @@ var Collection = /** @class */ (function (_super) {
334
342
  * @param data
335
343
  * | Property | Type | Description |
336
344
  * | :----------------- | :---- | :------------------------------- |
337
- * | collection_name | String | Collection name |
345
+ * | collection_name | String | Collection name |
346
+ * | replica_number? | number | Collection name |
347
+ * | 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 |
338
348
  *
339
349
  * @return
340
350
  * | Property | Description |
@@ -357,7 +367,7 @@ var Collection = /** @class */ (function (_super) {
357
367
  switch (_a.label) {
358
368
  case 0:
359
369
  this.checkCollectionName(data);
360
- return [4 /*yield*/, utils_1.promisify(this.client, "LoadCollection", data)];
370
+ return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'LoadCollection', data, data.timeout)];
361
371
  case 1:
362
372
  promise = _a.sent();
363
373
  return [2 /*return*/, promise];
@@ -372,7 +382,8 @@ var Collection = /** @class */ (function (_super) {
372
382
  * @param data
373
383
  * | Property | Type | Description |
374
384
  * | :----------------- | :---- | :------------------------------- |
375
- * | collection_name | String | Collection name |
385
+ * | collection_name | String | Collection name |
386
+ * | 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 |
376
387
  *
377
388
  * @return
378
389
  * | Property | Description |
@@ -395,9 +406,12 @@ var Collection = /** @class */ (function (_super) {
395
406
  switch (_a.label) {
396
407
  case 0:
397
408
  this.checkCollectionName(data);
398
- return [4 /*yield*/, utils_1.promisify(this.client, "LoadCollection", data)];
409
+ return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'LoadCollection', data, data.timeout)];
399
410
  case 1:
400
411
  promise = _a.sent();
412
+ if (promise.error_code !== Response_1.ErrorCode.SUCCESS) {
413
+ throw new Error("ErrorCode: ".concat(promise.error_code, ". Reason: ").concat(promise.reason));
414
+ }
401
415
  loadedPercentage = 0;
402
416
  _a.label = 2;
403
417
  case 2:
@@ -409,7 +423,7 @@ var Collection = /** @class */ (function (_super) {
409
423
  case 3:
410
424
  res = _a.sent();
411
425
  if (res.status.error_code !== Response_1.ErrorCode.SUCCESS) {
412
- throw new Error("ErrorCode: " + res.status.error_code + ". Reason: " + res.status.reason);
426
+ throw new Error("ErrorCode: ".concat(res.status.error_code, ". Reason: ").concat(res.status.reason));
413
427
  }
414
428
  // Because we pass collection_names in showCollections, so it will only this collection in result.
415
429
  loadedPercentage = Number(res.data[0].loadedPercentage);
@@ -426,7 +440,8 @@ var Collection = /** @class */ (function (_super) {
426
440
  * @param data
427
441
  * | Property | Type | Description |
428
442
  * | :----------------- | :---- | :------------------------------- |
429
- * | collection_name | String | Collection name |
443
+ * | collection_name | String | Collection name |
444
+ * | 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 |
430
445
  *
431
446
  * @return
432
447
  * | Property | Description |
@@ -449,7 +464,7 @@ var Collection = /** @class */ (function (_super) {
449
464
  switch (_a.label) {
450
465
  case 0:
451
466
  this.checkCollectionName(data);
452
- return [4 /*yield*/, utils_1.promisify(this.client, "ReleaseCollection", data)];
467
+ return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'ReleaseCollection', data, data.timeout)];
453
468
  case 1:
454
469
  promise = _a.sent();
455
470
  return [2 /*return*/, promise];
@@ -464,6 +479,7 @@ var Collection = /** @class */ (function (_super) {
464
479
  * | Property | Type | Description |
465
480
  * | :----------------- | :---- | :------------------------------- |
466
481
  * | collection_name | String | Collection name |
482
+ * | 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 |
467
483
  *
468
484
  * @return
469
485
  * | Property | Description |
@@ -486,7 +502,7 @@ var Collection = /** @class */ (function (_super) {
486
502
  switch (_a.label) {
487
503
  case 0:
488
504
  this.checkCollectionName(data);
489
- return [4 /*yield*/, utils_1.promisify(this.client, "DropCollection", data)];
505
+ return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'DropCollection', data, data.timeout)];
490
506
  case 1:
491
507
  promise = _a.sent();
492
508
  return [2 /*return*/, promise];
@@ -509,7 +525,7 @@ var Collection = /** @class */ (function (_super) {
509
525
  if (!data.alias) {
510
526
  throw new Error(ErrorReason_1.ERROR_REASONS.ALIAS_NAME_IS_REQUIRED);
511
527
  }
512
- return [4 /*yield*/, utils_1.promisify(this.client, "CreateAlias", data)];
528
+ return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'CreateAlias', data, data.timeout)];
513
529
  case 1:
514
530
  promise = _a.sent();
515
531
  return [2 /*return*/, promise];
@@ -530,7 +546,7 @@ var Collection = /** @class */ (function (_super) {
530
546
  if (!data.alias) {
531
547
  throw new Error(ErrorReason_1.ERROR_REASONS.ALIAS_NAME_IS_REQUIRED);
532
548
  }
533
- return [4 /*yield*/, utils_1.promisify(this.client, "DropAlias", data)];
549
+ return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'DropAlias', data, data.timeout)];
534
550
  case 1:
535
551
  promise = _a.sent();
536
552
  return [2 /*return*/, promise];
@@ -552,7 +568,7 @@ var Collection = /** @class */ (function (_super) {
552
568
  if (!data.alias) {
553
569
  throw new Error(ErrorReason_1.ERROR_REASONS.ALIAS_NAME_IS_REQUIRED);
554
570
  }
555
- return [4 /*yield*/, utils_1.promisify(this.client, "AlterAlias", data)];
571
+ return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'AlterAlias', data, data.timeout)];
556
572
  case 1:
557
573
  promise = _a.sent();
558
574
  return [2 /*return*/, promise];
@@ -566,7 +582,8 @@ var Collection = /** @class */ (function (_super) {
566
582
  * @param data
567
583
  * | Property | Type | Description |
568
584
  * | :----------------- | :---- | :------------------------------- |
569
- * | collection_name | String | The collection name to compact |
585
+ * | collection_name | String | The collection name to compact |
586
+ * | 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 |
570
587
  *
571
588
  * @return
572
589
  * | Property | Description |
@@ -592,9 +609,9 @@ var Collection = /** @class */ (function (_super) {
592
609
  return [4 /*yield*/, this.describeCollection(data)];
593
610
  case 1:
594
611
  collectionInfo = _a.sent();
595
- return [4 /*yield*/, utils_1.promisify(this.client, "ManualCompaction", {
612
+ return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'ManualCompaction', {
596
613
  collectionID: collectionInfo.collectionID,
597
- })];
614
+ }, data.timeout)];
598
615
  case 2:
599
616
  res = _a.sent();
600
617
  return [2 /*return*/, res];
@@ -609,6 +626,7 @@ var Collection = /** @class */ (function (_super) {
609
626
  * | Property | Type | Description |
610
627
  * | :----------------- | :---- | :------------------------------- |
611
628
  * | compactionID | number or string | the id returned by compact |
629
+ * | 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 |
612
630
  *
613
631
  * @return
614
632
  * | Property | Description |
@@ -633,7 +651,7 @@ var Collection = /** @class */ (function (_super) {
633
651
  if (!data || !data.compactionID) {
634
652
  throw new Error(ErrorReason_1.ERROR_REASONS.COMPACTIONID_IS_REQUIRED);
635
653
  }
636
- return [4 /*yield*/, utils_1.promisify(this.client, "GetCompactionState", data)];
654
+ return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'GetCompactionState', data, data.timeout)];
637
655
  case 1:
638
656
  res = _a.sent();
639
657
  return [2 /*return*/, res];
@@ -648,6 +666,7 @@ var Collection = /** @class */ (function (_super) {
648
666
  * | Property | Type | Description |
649
667
  * | :----------------- | :---- | :------------------------------- |
650
668
  * | compactionID | number or string | the id returned by compact |
669
+ * | 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 |
651
670
  *
652
671
  * @return
653
672
  * | Property | Description |
@@ -672,7 +691,64 @@ var Collection = /** @class */ (function (_super) {
672
691
  if (!data || !data.compactionID) {
673
692
  throw new Error(ErrorReason_1.ERROR_REASONS.COMPACTIONID_IS_REQUIRED);
674
693
  }
675
- return [4 /*yield*/, utils_1.promisify(this.client, "GetCompactionStateWithPlans", data)];
694
+ return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'GetCompactionStateWithPlans', data, data.timeout)];
695
+ case 1:
696
+ res = _a.sent();
697
+ return [2 /*return*/, res];
698
+ }
699
+ });
700
+ });
701
+ };
702
+ /**
703
+ * Get replicas
704
+ *
705
+ * @param data
706
+ * | Property | Type | Description |
707
+ * | :----------------- | :---- | :------------------------------- |
708
+ * | collectionID | number or string | the id returned by compact |
709
+ * | 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 |
710
+ *
711
+ * @return
712
+ * | Property | Description |
713
+ * | :-------------| :-------- |
714
+ * | status | { error_code: number, reason: string }|
715
+ * | ReplicaInfo[] | replica info array |
716
+ *
717
+ * #### Example
718
+ *
719
+ * ```
720
+ * new milvusClient(MILUVS_ADDRESS).collectionManager.getReplicas({
721
+ * collectionID: collectionID,
722
+ * });
723
+ *
724
+ * ```
725
+ *
726
+ * Return
727
+ * ```
728
+ * {
729
+ * replicas: [
730
+ * {
731
+ * partition_ids: [Array],
732
+ * shard_replicas: [Array],
733
+ * node_ids: [Array],
734
+ * replicaID: '436724291187770258',
735
+ * collectionID: '436777253933154305'
736
+ * }
737
+ * ],
738
+ * status: { error_code: 'Success', reason: '' }
739
+ * }
740
+ * ```
741
+ */
742
+ Collection.prototype.getReplicas = function (data) {
743
+ return __awaiter(this, void 0, void 0, function () {
744
+ var res;
745
+ return __generator(this, function (_a) {
746
+ switch (_a.label) {
747
+ case 0:
748
+ if (!data || !data.collectionID) {
749
+ throw new Error(ErrorReason_1.ERROR_REASONS.COLLECTION_ID_IS_REQUIRED);
750
+ }
751
+ return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'GetReplicas', data, data.timeout)];
676
752
  case 1:
677
753
  res = _a.sent();
678
754
  return [2 /*return*/, res];