@zilliz/milvus2-sdk-node 2.2.9 → 2.2.11

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 (149) hide show
  1. package/README.md +76 -12
  2. package/dist/milvus/MilvusClient.d.ts +21 -2
  3. package/dist/milvus/MilvusClient.js +35 -29
  4. package/dist/milvus/MilvusClient.js.map +1 -1
  5. package/dist/milvus/OrmClient.d.ts +19 -0
  6. package/dist/milvus/OrmClient.js +77 -0
  7. package/dist/milvus/OrmClient.js.map +1 -0
  8. package/dist/milvus/const/ErrorReason.d.ts +36 -31
  9. package/dist/milvus/const/ErrorReason.js +39 -32
  10. package/dist/milvus/const/ErrorReason.js.map +1 -1
  11. package/dist/milvus/const/Milvus.d.ts +2 -9
  12. package/dist/milvus/const/Milvus.js +16 -33
  13. package/dist/milvus/const/Milvus.js.map +1 -1
  14. package/dist/milvus/const/client.d.ts +5 -0
  15. package/dist/milvus/const/client.js +10 -0
  16. package/dist/milvus/const/client.js.map +1 -0
  17. package/dist/milvus/const/defaults.d.ts +11 -0
  18. package/dist/milvus/const/defaults.js +16 -0
  19. package/dist/milvus/const/defaults.js.map +1 -0
  20. package/dist/milvus/const/highLevel.d.ts +23 -0
  21. package/dist/milvus/const/highLevel.js +26 -0
  22. package/dist/milvus/const/highLevel.js.map +1 -0
  23. package/dist/milvus/const/index.d.ts +5 -0
  24. package/dist/milvus/{types.js → const/index.js} +7 -10
  25. package/dist/milvus/const/index.js.map +1 -0
  26. package/dist/milvus/const/limits.d.ts +2 -0
  27. package/dist/milvus/const/limits.js +7 -0
  28. package/dist/milvus/const/limits.js.map +1 -0
  29. package/dist/milvus/{BaseClient.d.ts → grpc/BaseClient.d.ts} +20 -8
  30. package/dist/milvus/grpc/BaseClient.js +83 -0
  31. package/dist/milvus/grpc/BaseClient.js.map +1 -0
  32. package/dist/milvus/{Collection.d.ts → grpc/Collection.d.ts} +32 -3
  33. package/dist/milvus/grpc/Collection.js +786 -0
  34. package/dist/milvus/grpc/Collection.js.map +1 -0
  35. package/dist/milvus/{Data.d.ts → grpc/Data.d.ts} +68 -10
  36. package/dist/milvus/grpc/Data.js +880 -0
  37. package/dist/milvus/grpc/Data.js.map +1 -0
  38. package/dist/milvus/grpc/Database.d.ts +69 -0
  39. package/dist/milvus/grpc/Database.js +98 -0
  40. package/dist/milvus/grpc/Database.js.map +1 -0
  41. package/dist/milvus/grpc/GrpcClient.d.ts +46 -0
  42. package/dist/milvus/grpc/GrpcClient.js +150 -0
  43. package/dist/milvus/grpc/GrpcClient.js.map +1 -0
  44. package/dist/milvus/{MilvusIndex.d.ts → grpc/MilvusIndex.d.ts} +1 -1
  45. package/dist/milvus/grpc/MilvusIndex.js +203 -0
  46. package/dist/milvus/grpc/MilvusIndex.js.map +1 -0
  47. package/dist/milvus/{Partition.d.ts → grpc/Partition.d.ts} +1 -1
  48. package/dist/milvus/grpc/Partition.js +265 -0
  49. package/dist/milvus/grpc/Partition.js.map +1 -0
  50. package/dist/milvus/{Resource.d.ts → grpc/Resource.d.ts} +2 -2
  51. package/dist/milvus/grpc/Resource.js +250 -0
  52. package/dist/milvus/grpc/Resource.js.map +1 -0
  53. package/dist/milvus/{User.d.ts → grpc/User.d.ts} +1 -1
  54. package/dist/milvus/grpc/User.js +619 -0
  55. package/dist/milvus/grpc/User.js.map +1 -0
  56. package/dist/milvus/index.d.ts +4 -13
  57. package/dist/milvus/index.js +6 -14
  58. package/dist/milvus/index.js.map +1 -1
  59. package/dist/milvus/orm/Collection.d.ts +45 -0
  60. package/dist/milvus/orm/Collection.js +172 -0
  61. package/dist/milvus/orm/Collection.js.map +1 -0
  62. package/dist/milvus/orm/index.d.ts +2 -0
  63. package/dist/milvus/orm/index.js +19 -0
  64. package/dist/milvus/orm/index.js.map +1 -0
  65. package/dist/milvus/orm/utils.d.ts +27 -0
  66. package/dist/milvus/orm/utils.js +27 -0
  67. package/dist/milvus/orm/utils.js.map +1 -0
  68. package/dist/milvus/types/Client.d.ts +12 -1
  69. package/dist/milvus/types/Collection.d.ts +18 -4
  70. package/dist/milvus/types/Common.d.ts +1 -1
  71. package/dist/milvus/types/Data.d.ts +41 -5
  72. package/dist/milvus/types/Database.d.ts +12 -0
  73. package/dist/milvus/types/{Index.js → Database.js} +1 -1
  74. package/dist/milvus/types/Database.js.map +1 -0
  75. package/dist/milvus/types/HighLevel.d.ts +13 -0
  76. package/dist/milvus/types/HighLevel.js +3 -0
  77. package/dist/milvus/types/HighLevel.js.map +1 -0
  78. package/dist/milvus/types/{Index.d.ts → MilvusIndex.d.ts} +3 -2
  79. package/dist/milvus/types/MilvusIndex.js +3 -0
  80. package/dist/milvus/types/MilvusIndex.js.map +1 -0
  81. package/dist/milvus/types/Resource.d.ts +1 -1
  82. package/dist/milvus/types/User.d.ts +1 -1
  83. package/dist/milvus/types/index.d.ts +12 -0
  84. package/dist/milvus/types/index.js +30 -0
  85. package/dist/milvus/types/index.js.map +1 -0
  86. package/dist/{utils → milvus/utils}/Blob.js +4 -4
  87. package/dist/milvus/utils/Blob.js.map +1 -0
  88. package/dist/{utils → milvus/utils}/Format.d.ts +66 -2
  89. package/dist/milvus/utils/Format.js +416 -0
  90. package/dist/milvus/utils/Format.js.map +1 -0
  91. package/dist/{utils → milvus/utils}/Function.d.ts +1 -1
  92. package/dist/{utils → milvus/utils}/Function.js +7 -7
  93. package/dist/milvus/utils/Function.js.map +1 -0
  94. package/dist/{utils → milvus/utils}/Grpc.d.ts +9 -8
  95. package/dist/milvus/utils/Grpc.js +190 -0
  96. package/dist/milvus/utils/Grpc.js.map +1 -0
  97. package/dist/{utils → milvus/utils}/Validate.d.ts +7 -1
  98. package/dist/milvus/utils/Validate.js +140 -0
  99. package/dist/milvus/utils/Validate.js.map +1 -0
  100. package/dist/{utils → milvus/utils}/index.d.ts +2 -0
  101. package/dist/{utils → milvus/utils}/index.js +2 -0
  102. package/dist/milvus/utils/index.js.map +1 -0
  103. package/dist/milvus/utils/logger.d.ts +1 -0
  104. package/dist/milvus/utils/logger.js +18 -0
  105. package/dist/milvus/utils/logger.js.map +1 -0
  106. package/dist/proto/proto/common.proto +38 -14
  107. package/dist/proto/proto/google/protobuf/descriptor.proto +8 -4
  108. package/dist/proto/proto/milvus.proto +86 -83
  109. package/dist/proto/proto/schema.proto +5 -0
  110. package/dist/sdk.json +1 -1
  111. package/package.json +14 -11
  112. package/dist/milvus/BaseClient.js +0 -62
  113. package/dist/milvus/BaseClient.js.map +0 -1
  114. package/dist/milvus/Collection.js +0 -960
  115. package/dist/milvus/Collection.js.map +0 -1
  116. package/dist/milvus/Data.js +0 -909
  117. package/dist/milvus/Data.js.map +0 -1
  118. package/dist/milvus/GrpcClient.d.ts +0 -32
  119. package/dist/milvus/GrpcClient.js +0 -236
  120. package/dist/milvus/GrpcClient.js.map +0 -1
  121. package/dist/milvus/MilvusIndex.js +0 -299
  122. package/dist/milvus/MilvusIndex.js.map +0 -1
  123. package/dist/milvus/Partition.js +0 -369
  124. package/dist/milvus/Partition.js.map +0 -1
  125. package/dist/milvus/Resource.js +0 -356
  126. package/dist/milvus/Resource.js.map +0 -1
  127. package/dist/milvus/User.js +0 -806
  128. package/dist/milvus/User.js.map +0 -1
  129. package/dist/milvus/Utils.d.ts +0 -1
  130. package/dist/milvus/Utils.js +0 -8
  131. package/dist/milvus/Utils.js.map +0 -1
  132. package/dist/milvus/types/Index.js.map +0 -1
  133. package/dist/milvus/types.d.ts +0 -9
  134. package/dist/milvus/types.js.map +0 -1
  135. package/dist/proto/proto/feder.proto +0 -40
  136. package/dist/proto/proto/msg.proto +0 -107
  137. package/dist/utils/Blob.js.map +0 -1
  138. package/dist/utils/Format.js +0 -252
  139. package/dist/utils/Format.js.map +0 -1
  140. package/dist/utils/Function.js.map +0 -1
  141. package/dist/utils/Grpc.js +0 -170
  142. package/dist/utils/Grpc.js.map +0 -1
  143. package/dist/utils/Validate.js +0 -124
  144. package/dist/utils/Validate.js.map +0 -1
  145. package/dist/utils/index.js.map +0 -1
  146. package/dist/utils/test.d.ts +0 -15
  147. package/dist/utils/test.js +0 -98
  148. package/dist/utils/test.js.map +0 -1
  149. /package/dist/{utils → milvus/utils}/Blob.d.ts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../milvus/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,eAAe;AACf,6CAA2B;AAC3B,+CAA6B;AAC7B,yCAAuB;AACvB,2CAAyB;AACzB,gDAA8B;AAC9B,8CAA4B;AAC5B,6CAA2B;AAC3B,yCAAuB;AACvB,6CAA2B;AAC3B,2CAAyB;AACzB,gDAA8B;AAC9B,8CAA4B"}
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseBinaryVectorToBytes = exports.parseFloatVectorToBytes = void 0;
4
- var parseFloatVectorToBytes = function (array) {
4
+ const parseFloatVectorToBytes = (array) => {
5
5
  // create array buffer
6
- var a = new Float32Array(array);
6
+ const a = new Float32Array(array);
7
7
  // need return bytes to milvus proto
8
8
  return Buffer.from(a.buffer);
9
9
  };
10
10
  exports.parseFloatVectorToBytes = parseFloatVectorToBytes;
11
- var parseBinaryVectorToBytes = function (array) {
11
+ const parseBinaryVectorToBytes = (array) => {
12
12
  // create array buffer
13
- var a = new Uint8Array(array);
13
+ const a = new Uint8Array(array);
14
14
  // need return bytes to milvus proto
15
15
  return Buffer.from(a.buffer);
16
16
  };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Blob.js","sourceRoot":"","sources":["../../../milvus/utils/Blob.ts"],"names":[],"mappings":";;;AAAO,MAAM,uBAAuB,GAAG,CAAC,KAAe,EAAE,EAAE;IACzD,sBAAsB;IACtB,MAAM,CAAC,GAAG,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC;IAClC,oCAAoC;IACpC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC,CAAC;AALW,QAAA,uBAAuB,2BAKlC;AAEK,MAAM,wBAAwB,GAAG,CAAC,KAAe,EAAE,EAAE;IAC1D,sBAAsB;IACtB,MAAM,CAAC,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;IAChC,oCAAoC;IACpC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC,CAAC;AALW,QAAA,wBAAwB,4BAKnC"}
@@ -1,4 +1,5 @@
1
- import { KeyValuePair, FieldType } from '../milvus';
1
+ import { Type } from 'protobufjs';
2
+ import { KeyValuePair, FieldType, DataTypeMap, DataType, CreateCollectionReq, DescribeCollectionResponse } from '../';
2
3
  /**
3
4
  * parse [{key:"row_count",value:4}] to {row_count:4}
4
5
  * @param data key value pair array
@@ -113,7 +114,7 @@ export declare const formatAddress: (address: string) => string;
113
114
  * @param field The `FieldType` object to modify.
114
115
  * @returns The modified `FieldType` object.
115
116
  */
116
- export declare const assignTypeParams: (field: FieldType, typeParamKeys?: string[]) => any;
117
+ export declare const assignTypeParams: (field: FieldType, typeParamKeys?: string[]) => FieldType;
117
118
  /**
118
119
  * Parses a time token and returns the corresponding number of milliseconds.
119
120
  *
@@ -129,3 +130,66 @@ export declare const parseTimeToken: (token: string) => number;
129
130
  * @returns {string} The extracted method name.
130
131
  */
131
132
  export declare const extractMethodName: (query: string) => string;
133
+ /**
134
+ * Converts a `key` of type `keyof typeof DataTypeMap | DataType` to a `DataType`.
135
+ *
136
+ * @param {keyof typeof DataTypeMap | DataType} key - The key to convert.
137
+ * @returns {DataType} The converted `DataType`.
138
+ */
139
+ export declare const convertToDataType: (key: keyof typeof DataTypeMap | DataType) => DataType;
140
+ /**
141
+ * Creates a deep copy of the provided object using JSON.parse and JSON.stringify.
142
+ * Note that this function is not efficient and may cause performance issues if used with large or complex objects. It also does not handle cases where the object being cloned contains functions or prototype methods.
143
+ *
144
+ * @typeparam T The type of object being cloned.
145
+ * @param {T} obj - The object to clone.
146
+ * @returns {T} A new object with the same properties and values as the original.
147
+ */
148
+ export declare const cloneObj: <T>(obj: T) => T;
149
+ /**
150
+ * Formats the input data into a request payload for creating a collection.
151
+ *
152
+ * @param {CreateCollectionReq} data - The input data for creating a collection.
153
+ * @param {Type} schemaType - The schema type for the collection.
154
+ * @returns {Object} The formatted request payload.
155
+ */
156
+ export declare const formatCollectionSchema: (data: CreateCollectionReq, grpcMsgType: Type) => {
157
+ [k: string]: any;
158
+ };
159
+ /**
160
+ * Formats a `DescribeCollectionResponse` object by adding a `dataType` property to each field object in its `schema` array.
161
+ * The `dataType` property represents the numerical value of the `data_type` property.
162
+ *
163
+ * @param {DescribeCollectionResponse} data - The `DescribeCollectionResponse` object to format.
164
+ * @returns {DescribeCollectionResponse} A new `DescribeCollectionResponse` object with the updated `dataType` properties.
165
+ */
166
+ export declare const formatDescribedCol: (data: DescribeCollectionResponse) => DescribeCollectionResponse;
167
+ /**
168
+ * Generates a dynamic row object by separating fields into a dynamic field and non-dynamic fields.
169
+ *
170
+ * @param {Record<string, any>} data - The input data object.
171
+ * @param {Map<string, any>} fieldsDataMap - A map of field names to their corresponding data.
172
+ * @param {string} dynamicField - The name of the dynamic field.
173
+ * @returns {Record<string, any>} The generated dynamic row object.
174
+ */
175
+ export declare const generateDynamicRow: (data: Record<string, any>, fieldsDataMap: Map<string, any>, dynamicField: string) => Record<string, any>;
176
+ /**
177
+ * Check the data type of each field and parse the data accordingly.
178
+ * If the field is a vector, split the data into chunks of the appropriate size.
179
+ * If the field is a scalar, decode the JSON data if necessary.
180
+ */
181
+ export declare const getFieldDataMap: (fields_data: any[]) => Map<string, any>;
182
+ /**
183
+ * Generates an authentication string based on the provided credentials.
184
+ *
185
+ * @param {Object} data - An object containing the authentication credentials.
186
+ * @param {string} [data.username] - The username to use for authentication.
187
+ * @param {string} [data.password] - The password to use for authentication.
188
+ * @param {string} [data.token] - The token to use for authentication.
189
+ * @returns {string} The authentication string.
190
+ */
191
+ export declare const getAuthString: (data: {
192
+ username?: string;
193
+ password?: string;
194
+ token?: string;
195
+ }) => string;
@@ -0,0 +1,416 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.getAuthString = exports.getFieldDataMap = exports.generateDynamicRow = exports.formatDescribedCol = exports.formatCollectionSchema = exports.cloneObj = exports.convertToDataType = exports.extractMethodName = exports.parseTimeToken = exports.assignTypeParams = exports.formatAddress = exports.stringToBase64 = exports.datetimeToHybrids = exports.unixtimeToHybridts = exports.hybridtsToUnixtime = exports.checkTimeParam = exports.formatNumberPrecision = exports.parseToKeyValue = exports.formatKeyValueData = void 0;
15
+ const __1 = require("../");
16
+ /**
17
+ * parse [{key:"row_count",value:4}] to {row_count:4}
18
+ * @param data key value pair array
19
+ * @param keys all keys in data
20
+ * @returns {key:value}
21
+ */
22
+ const formatKeyValueData = (data, keys) => {
23
+ const result = {};
24
+ keys.forEach(k => {
25
+ const value = (0, __1.findKeyValue)(data, k);
26
+ result[k] = value;
27
+ });
28
+ return result;
29
+ };
30
+ exports.formatKeyValueData = formatKeyValueData;
31
+ /**
32
+ * parse {row_count:4} to [{key:"row_count",value:"4"}]
33
+ * @param data Object
34
+ * @returns {KeyValuePair[]}
35
+ */
36
+ const parseToKeyValue = (data) => {
37
+ return data
38
+ ? Object.keys(data).reduce((pre, cur) => [...pre, { key: cur, value: data[cur] }], [])
39
+ : [];
40
+ };
41
+ exports.parseToKeyValue = parseToKeyValue;
42
+ /**
43
+ *
44
+ * @param number Number like 3.1738998889923096
45
+ * @param precision The precision you want, if is 3 will return 3.173 and If is 2 will return 3.17
46
+ * @returns
47
+ */
48
+ const formatNumberPrecision = (number, precision) => {
49
+ return Number(number
50
+ .toString()
51
+ .split('.')
52
+ .map((v, i) => {
53
+ if (i === 1) {
54
+ return v.slice(0, precision);
55
+ }
56
+ return v;
57
+ })
58
+ .join('.'));
59
+ };
60
+ exports.formatNumberPrecision = formatNumberPrecision;
61
+ const LOGICAL_BITS = BigInt(18);
62
+ // const LOGICAL_BITS_MASK = (1 << LOGICAL_BITS) - 1;
63
+ const checkTimeParam = (ts) => {
64
+ switch (typeof ts) {
65
+ case 'bigint':
66
+ return true;
67
+ case 'string':
68
+ return isNaN(Number(ts)) ? false : true;
69
+ default:
70
+ return false;
71
+ }
72
+ };
73
+ exports.checkTimeParam = checkTimeParam;
74
+ /**
75
+ * Convert a hybrid timestamp to UNIX Epoch time ignoring the logic part.
76
+ *
77
+ * @param data
78
+ * | Property | Type | Description |
79
+ * | :---------------- | :---- | :------------------------------- |
80
+ * | hybridts | String or BigInt | The known hybrid timestamp to convert to UNIX Epoch time. Non-negative interger range from 0 to 18446744073709551615. |
81
+ *
82
+ *
83
+ *
84
+ * @returns
85
+ * | Property | Description |
86
+ * | :-----------| :------------------------------- |
87
+ * | unixtime as string | The Unix Epoch time is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). |
88
+ *
89
+ *
90
+ * #### Example
91
+ *
92
+ * ```
93
+ * const res = hybridtsToUnixtime("429642767925248000");
94
+ * ```
95
+ */
96
+ const hybridtsToUnixtime = (hybridts) => {
97
+ if (!(0, exports.checkTimeParam)(hybridts)) {
98
+ throw new Error(`hybridts ${__1.ERROR_REASONS.TIMESTAMP_PARAM_CHECK}`);
99
+ }
100
+ const timestamp = typeof hybridts === 'bigint' ? hybridts : BigInt(hybridts);
101
+ const physical = timestamp >> LOGICAL_BITS;
102
+ return (physical / BigInt(1000)).toString();
103
+ };
104
+ exports.hybridtsToUnixtime = hybridtsToUnixtime;
105
+ /**
106
+ * Generate a hybrid timestamp based on Unix Epoch time, timedelta and incremental time internval.
107
+ *
108
+ * @param data
109
+ * | Property | Type | Description |
110
+ * | :---------------- | :---- | :------------------------------- |
111
+ * | unixtime | string or bigint | The known Unix Epoch time used to generate a hybrid timestamp. The Unix Epoch time is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). |
112
+ *
113
+ *
114
+ *
115
+ * @returns
116
+ * | Property | Type | Description |
117
+ * | :-----------| :--- | :------------------------------- |
118
+ * | Hybrid timetamp | String | Hybrid timetamp is a non-negative interger range from 0 to 18446744073709551615. |
119
+ *
120
+ *
121
+ * #### Example
122
+ *
123
+ * ```
124
+ * const res = unixtimeToHybridts("429642767925248000");
125
+ * ```
126
+ */
127
+ const unixtimeToHybridts = (unixtime) => {
128
+ if (!(0, exports.checkTimeParam)(unixtime)) {
129
+ throw new Error(`hybridts ${__1.ERROR_REASONS.TIMESTAMP_PARAM_CHECK}`);
130
+ }
131
+ const timestamp = typeof unixtime === 'bigint' ? unixtime : BigInt(unixtime);
132
+ const physical = (timestamp * BigInt(1000)) << LOGICAL_BITS;
133
+ return physical.toString();
134
+ };
135
+ exports.unixtimeToHybridts = unixtimeToHybridts;
136
+ /**
137
+ * Generate a hybrid timestamp based on datetime。
138
+ *
139
+ * @param data
140
+ * | Property | Type | Description |
141
+ * | :---------------- | :---- | :------------------------------- |
142
+ * | datetime | Date | The known datetime used to generate a hybrid timestamp. |
143
+ *
144
+ *
145
+ *
146
+ * @returns
147
+ * | Property | Type | Description |
148
+ * | :-----------| :--- | :------------------------------- |
149
+ * | Hybrid timetamp | String | Hybrid timetamp is a non-negative interger range from 0 to 18446744073709551615. |
150
+ *
151
+ *
152
+ * #### Example
153
+ *
154
+ * ```
155
+ * const res = datetimeToHybrids("429642767925248000");
156
+ * ```
157
+ */
158
+ const datetimeToHybrids = (datetime) => {
159
+ if (!(datetime instanceof Date)) {
160
+ throw new Error(`hybridts ${__1.ERROR_REASONS.DATE_TYPE_CHECK}`);
161
+ }
162
+ return (0, exports.unixtimeToHybridts)((datetime.getTime() / 1000).toString());
163
+ };
164
+ exports.datetimeToHybrids = datetimeToHybrids;
165
+ /**
166
+ * Converts a string to base64 encoding.
167
+ * @param str The string to convert.
168
+ * @returns The base64 encoded string.
169
+ */
170
+ const stringToBase64 = (str) => Buffer.from(str, 'utf-8').toString('base64');
171
+ exports.stringToBase64 = stringToBase64;
172
+ /**
173
+ * Formats the given address by removing the http or https prefix and appending the default Milvus port if necessary.
174
+ * @param address The address to format.
175
+ * @returns The formatted address.
176
+ */
177
+ const formatAddress = (address) => {
178
+ // remove http or https prefix from address
179
+ const ip = address.replace(/(http|https)*:\/\//, '');
180
+ return ip.includes(':') ? ip : `${ip}:${__1.DEFAULT_MILVUS_PORT}`;
181
+ };
182
+ exports.formatAddress = formatAddress;
183
+ /**
184
+ * Assigns properties with keys `dim` or `max_length` to the `type_params` object of a `FieldType` object.
185
+ * If the property exists in the `field` object, it is converted to a string and then deleted from the `field` object.
186
+ * If the property already exists in the `type_params` object, it is also converted to a string.
187
+ *
188
+ * @param field The `FieldType` object to modify.
189
+ * @returns The modified `FieldType` object.
190
+ */
191
+ const assignTypeParams = (field, typeParamKeys = ['dim', 'max_length']) => {
192
+ let newField = (0, exports.cloneObj)(field);
193
+ typeParamKeys.forEach(key => {
194
+ if (newField.hasOwnProperty(key)) {
195
+ // if the property exists in the field object, assign it to the type_params object
196
+ newField.type_params = newField.type_params || {};
197
+ newField.type_params[key] = String(newField[key]);
198
+ // delete the property from the field object
199
+ delete newField[key];
200
+ }
201
+ if (newField.type_params && newField.type_params[key]) {
202
+ // if the property already exists in the type_params object, convert it to a string
203
+ newField.type_params[key] = String(newField.type_params[key]);
204
+ }
205
+ });
206
+ return newField;
207
+ };
208
+ exports.assignTypeParams = assignTypeParams;
209
+ /**
210
+ * Parses a time token and returns the corresponding number of milliseconds.
211
+ *
212
+ * @param {string} token - The time token to parse.
213
+ * @returns {number} The number of milliseconds corresponding to the time token.
214
+ * @throws {Error} If the time token is invalid.
215
+ */
216
+ const parseTimeToken = (token) => {
217
+ const num = parseInt(token.slice(0, -1));
218
+ const unit = token.slice(-1);
219
+ switch (unit) {
220
+ case 's':
221
+ return num * 1000;
222
+ case 'm':
223
+ return num * 60 * 1000;
224
+ case 'h':
225
+ return num * 60 * 60 * 1000;
226
+ case 'd':
227
+ return num * 24 * 60 * 60 * 1000;
228
+ case 'w':
229
+ return num * 7 * 24 * 60 * 60 * 1000;
230
+ case 'M':
231
+ return num * 30 * 24 * 60 * 60 * 1000;
232
+ case 'Y':
233
+ return num * 365 * 24 * 60 * 60 * 1000;
234
+ default:
235
+ throw new Error(`Invalid time token: ${token}`);
236
+ }
237
+ };
238
+ exports.parseTimeToken = parseTimeToken;
239
+ /**
240
+ * Extracts the method name from a URL path.
241
+ *
242
+ * @param {string} query - The URL path to extract the method name from.
243
+ * @returns {string} The extracted method name.
244
+ */
245
+ const extractMethodName = (query) => {
246
+ const parts = query.split('/');
247
+ return parts[parts.length - 1];
248
+ };
249
+ exports.extractMethodName = extractMethodName;
250
+ /**
251
+ * Converts a `key` of type `keyof typeof DataTypeMap | DataType` to a `DataType`.
252
+ *
253
+ * @param {keyof typeof DataTypeMap | DataType} key - The key to convert.
254
+ * @returns {DataType} The converted `DataType`.
255
+ */
256
+ const convertToDataType = (key) => {
257
+ if (typeof key === 'string' && key in __1.DataTypeMap) {
258
+ return __1.DataType[key];
259
+ }
260
+ else if (typeof key === 'number' && Object.values(__1.DataType).includes(key)) {
261
+ return key;
262
+ }
263
+ throw new Error(__1.ERROR_REASONS.FIELD_TYPE_IS_NOT_SUPPORT);
264
+ };
265
+ exports.convertToDataType = convertToDataType;
266
+ /**
267
+ * Creates a deep copy of the provided object using JSON.parse and JSON.stringify.
268
+ * Note that this function is not efficient and may cause performance issues if used with large or complex objects. It also does not handle cases where the object being cloned contains functions or prototype methods.
269
+ *
270
+ * @typeparam T The type of object being cloned.
271
+ * @param {T} obj - The object to clone.
272
+ * @returns {T} A new object with the same properties and values as the original.
273
+ */
274
+ const cloneObj = (obj) => {
275
+ return JSON.parse(JSON.stringify(obj));
276
+ };
277
+ exports.cloneObj = cloneObj;
278
+ /**
279
+ * Formats the input data into a request payload for creating a collection.
280
+ *
281
+ * @param {CreateCollectionReq} data - The input data for creating a collection.
282
+ * @param {Type} schemaType - The schema type for the collection.
283
+ * @returns {Object} The formatted request payload.
284
+ */
285
+ const formatCollectionSchema = (data, grpcMsgType) => {
286
+ const { fields, collection_name, description, enable_dynamic_field } = data;
287
+ const payload = {
288
+ name: collection_name,
289
+ description: description || '',
290
+ enableDynamicField: !!enable_dynamic_field,
291
+ fields: fields.map(field => {
292
+ // Assign the typeParams property to the result of parseToKeyValue(type_params).
293
+ const _a = (0, exports.assignTypeParams)(field), { type_params } = _a, rest = __rest(_a, ["type_params"]);
294
+ return grpcMsgType.create(Object.assign(Object.assign({}, rest), { typeParams: (0, exports.parseToKeyValue)(type_params), dataType: (0, exports.convertToDataType)(field.data_type), isPrimaryKey: !!field.is_primary_key, isPartitionKey: !!field.is_partition_key }));
295
+ }),
296
+ };
297
+ return payload;
298
+ };
299
+ exports.formatCollectionSchema = formatCollectionSchema;
300
+ /**
301
+ * Formats a `DescribeCollectionResponse` object by adding a `dataType` property to each field object in its `schema` array.
302
+ * The `dataType` property represents the numerical value of the `data_type` property.
303
+ *
304
+ * @param {DescribeCollectionResponse} data - The `DescribeCollectionResponse` object to format.
305
+ * @returns {DescribeCollectionResponse} A new `DescribeCollectionResponse` object with the updated `dataType` properties.
306
+ */
307
+ const formatDescribedCol = (data) => {
308
+ // clone object
309
+ const newData = (0, exports.cloneObj)(data);
310
+ // add a dataType property which indicate datatype number
311
+ newData.schema.fields.forEach(f => {
312
+ f.dataType = __1.DataTypeMap[f.data_type];
313
+ });
314
+ return newData;
315
+ };
316
+ exports.formatDescribedCol = formatDescribedCol;
317
+ /**
318
+ * Generates a dynamic row object by separating fields into a dynamic field and non-dynamic fields.
319
+ *
320
+ * @param {Record<string, any>} data - The input data object.
321
+ * @param {Map<string, any>} fieldsDataMap - A map of field names to their corresponding data.
322
+ * @param {string} dynamicField - The name of the dynamic field.
323
+ * @returns {Record<string, any>} The generated dynamic row object.
324
+ */
325
+ const generateDynamicRow = (data, fieldsDataMap, dynamicField) => {
326
+ const originRow = (0, exports.cloneObj)(data);
327
+ const row = {};
328
+ // iterate through each key in the input data object
329
+ for (let key in originRow) {
330
+ if (fieldsDataMap.has(key)) {
331
+ // if the key is in the fieldsDataMap, add it to the non-dynamic fields
332
+ row[key] = originRow[key];
333
+ }
334
+ else {
335
+ // otherwise, add it to the dynamic field
336
+ row[dynamicField] = row[dynamicField] || {}; // initialize the dynamic field object
337
+ row[dynamicField][key] = originRow[key];
338
+ }
339
+ }
340
+ return row; // return the generated dynamic row object
341
+ };
342
+ exports.generateDynamicRow = generateDynamicRow;
343
+ /**
344
+ * Check the data type of each field and parse the data accordingly.
345
+ * If the field is a vector, split the data into chunks of the appropriate size.
346
+ * If the field is a scalar, decode the JSON data if necessary.
347
+ */
348
+ const getFieldDataMap = (fields_data) => {
349
+ const fieldsDataMap = new Map();
350
+ fields_data.forEach((item, i) => {
351
+ var _a;
352
+ // field data
353
+ let field_data;
354
+ // parse vector data
355
+ if (item.field === 'vectors') {
356
+ const key = item.vectors.data;
357
+ const vectorValue = key === 'float_vector'
358
+ ? item.vectors[key].data
359
+ : item.vectors[key].toJSON().data;
360
+ // if binary vector , need use dim / 8 to split vector data
361
+ const dim = ((_a = item.vectors) === null || _a === void 0 ? void 0 : _a.data) === 'float_vector'
362
+ ? Number(item.vectors.dim)
363
+ : Number(item.vectors.dim) / 8;
364
+ field_data = [];
365
+ // parse number[] to number[][] by dim
366
+ vectorValue.forEach((v, i) => {
367
+ const index = Math.floor(i / dim);
368
+ if (!field_data[index]) {
369
+ field_data[index] = [];
370
+ }
371
+ field_data[index].push(v);
372
+ });
373
+ }
374
+ else {
375
+ // parse scalar data
376
+ const key = item.scalars.data;
377
+ field_data = item.scalars[key].data;
378
+ // decode json
379
+ switch (key) {
380
+ case 'json_data':
381
+ field_data.forEach((buffer, i) => {
382
+ // console.log(JSON.parse(buffer.toString()));
383
+ field_data[i] = JSON.parse(buffer.toString());
384
+ });
385
+ break;
386
+ default:
387
+ break;
388
+ }
389
+ }
390
+ // Add the parsed data to the fieldsDataMap
391
+ fieldsDataMap.set(item.field_name, field_data);
392
+ });
393
+ return fieldsDataMap;
394
+ };
395
+ exports.getFieldDataMap = getFieldDataMap;
396
+ /**
397
+ * Generates an authentication string based on the provided credentials.
398
+ *
399
+ * @param {Object} data - An object containing the authentication credentials.
400
+ * @param {string} [data.username] - The username to use for authentication.
401
+ * @param {string} [data.password] - The password to use for authentication.
402
+ * @param {string} [data.token] - The token to use for authentication.
403
+ * @returns {string} The authentication string.
404
+ */
405
+ const getAuthString = (data) => {
406
+ const { username, password, token } = data;
407
+ // build auth string
408
+ const authString = token ? token : `${username}:${password}`;
409
+ // Encode the username and password as a base64 string.
410
+ let auth = Buffer.from(authString, 'utf-8').toString('base64');
411
+ // if we need to create auth interceptors
412
+ const needAuth = (!!username && !!password) || !!token;
413
+ return needAuth ? auth : '';
414
+ };
415
+ exports.getAuthString = getAuthString;
416
+ //# sourceMappingURL=Format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Format.js","sourceRoot":"","sources":["../../../milvus/utils/Format.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,2BAUa;AAEb;;;;;GAKG;AACI,MAAM,kBAAkB,GAAG,CAAC,IAAoB,EAAE,IAAc,EAAE,EAAE;IACzE,MAAM,MAAM,GAAyB,EAAE,CAAC;IACxC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;QACf,MAAM,KAAK,GAAG,IAAA,gBAAY,EAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QACpC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,OA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AK,EAAE,GAAG,IAAI,CAAC;IAC3C,oBAAoB;IACpB,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,QAAQ,IAAI,QAAQ,EAAE,CAAC;IAC7D,uDAAuD;IACvD,IAAI,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAE/D,yCAAyC;IACzC,MAAM,QAAQ,GAAG,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC;IACvD,OAAO,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;AAC9B,CAAC,CAAC;AAdW,QAAA,aAAa,iBAcxB"}
@@ -1,4 +1,4 @@
1
- import { KeyValuePair } from '../milvus/types/Common';
1
+ import { KeyValuePair } from '../types/Common';
2
2
  /**
3
3
  * Promisify a function call with optional timeout
4
4
  * @param obj - The object containing the target function
@@ -11,12 +11,12 @@ exports.sleep = exports.findKeyValue = exports.promisify = void 0;
11
11
  */
12
12
  function promisify(obj, target, params, timeout) {
13
13
  // Calculate the deadline for the function call
14
- var deadline = new Date(Date.now() + timeout);
14
+ const deadline = new Date(Date.now() + timeout);
15
15
  // Create a new Promise that wraps the target function call
16
- var res = new Promise(function (resolve, reject) {
16
+ const res = new Promise((resolve, reject) => {
17
17
  try {
18
18
  // Call the target function with the provided parameters and deadline
19
- obj[target](params, { deadline: deadline }, function (err, result) {
19
+ obj[target](params, { deadline }, (err, result) => {
20
20
  if (err) {
21
21
  // If there was an error, reject the Promise with the error
22
22
  reject(err);
@@ -29,7 +29,7 @@ function promisify(obj, target, params, timeout) {
29
29
  // If there was an exception, throw a new Error
30
30
  throw new Error(e);
31
31
  }
32
- }).catch(function (err) {
32
+ }).catch(err => {
33
33
  // Return a rejected Promise with the error
34
34
  return Promise.reject(err);
35
35
  });
@@ -37,10 +37,10 @@ function promisify(obj, target, params, timeout) {
37
37
  return res;
38
38
  }
39
39
  exports.promisify = promisify;
40
- var findKeyValue = function (obj, key) { var _a; return (_a = obj.find(function (v) { return v.key === key; })) === null || _a === void 0 ? void 0 : _a.value; };
40
+ const findKeyValue = (obj, key) => { var _a; return (_a = obj.find(v => v.key === key)) === null || _a === void 0 ? void 0 : _a.value; };
41
41
  exports.findKeyValue = findKeyValue;
42
- var sleep = function (time) {
43
- return new Promise(function (resolve) { return setTimeout(resolve, time); });
42
+ const sleep = (time) => {
43
+ return new Promise(resolve => setTimeout(resolve, time));
44
44
  };
45
45
  exports.sleep = sleep;
46
46
  //# sourceMappingURL=Function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Function.js","sourceRoot":"","sources":["../../../milvus/utils/Function.ts"],"names":[],"mappings":";;;AAEA;;;;;;;GAOG;AACH,SAAgB,SAAS,CACvB,GAAQ,EACR,MAAc,EACd,MAAW,EACX,OAAe;IAEf,+CAA+C;IAC/C,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,CAAC;IAEhD,2DAA2D;IAC3D,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC1C,IAAI;YACF,qEAAqE;YACrE,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,EAAE,CAAC,GAAQ,EAAE,MAAW,EAAE,EAAE;gBAC1D,IAAI,GAAG,EAAE;oBACP,2DAA2D;oBAC3D,MAAM,CAAC,GAAG,CAAC,CAAC;iBACb;gBACD,iDAAiD;gBACjD,OAAO,CAAC,MAAM,CAAC,CAAC;YAClB,CAAC,CAAC,CAAC;SACJ;QAAC,OAAO,CAAM,EAAE;YACf,+CAA+C;YAC/C,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;SACpB;IACH,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;QACb,2CAA2C;QAC3C,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,qBAAqB;IACrB,OAAO,GAAG,CAAC;AACb,CAAC;AAhCD,8BAgCC;AAEM,MAAM,YAAY,GAAG,CAAC,GAAmB,EAAE,GAAW,EAAE,EAAE,WAC/D,OAAA,MAAA,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,0CAAE,KAAK,CAAA,EAAA,CAAC;AADzB,QAAA,YAAY,gBACa;AAE/B,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,EAAE;IACpC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;AAC3D,CAAC,CAAC;AAFW,QAAA,KAAK,SAEhB"}
@@ -10,24 +10,25 @@ interface IServiceDetails {
10
10
  */
11
11
  export declare const getGRPCService: (proto: IServiceDetails) => ServiceClientConstructor;
12
12
  /**
13
- * Returns an interceptor function that adds an authorization header to the metadata of a gRPC call.
14
- * @param username - The username to use for authentication.
15
- * @param password - The password to use for authentication.
16
- * @returns An interceptor function.
13
+ * Returns a gRPC interceptor function that adds metadata to outgoing requests.
14
+ *
15
+ * @param {Function} onInvoked - A function to be called with the modified metadata.
16
+ * @param {Object[]} initValues - An array of objects containing key-value pairs to add to the metadata.
17
+ * @returns {Function} The gRPC interceptor function.
17
18
  */
18
- export declare const getAuthInterceptor: (username: string, password: string) => (options: any, nextCall: any) => InterceptingCall;
19
+ export declare const getMetaInterceptor: (onInvoked: Function, initValues?: {
20
+ [key: string]: any;
21
+ }[]) => (options: any, nextCall: any) => InterceptingCall;
19
22
  /**
20
23
  * Returns a gRPC interceptor function that retries failed requests up to a maximum number of times.
21
24
  *
22
25
  * @param {Object} options - The options object.
23
26
  * @param {number} options.maxRetries - The maximum number of times to retry a failed request.
24
27
  * @param {number} options.retryDelay - The delay in milliseconds between retries.
25
- * @param {boolean} options.debug - Whether to log debug information.
26
28
  * @returns {Function} The gRPC interceptor function.
27
29
  */
28
- export declare const getRetryInterceptor: ({ maxRetries, retryDelay, debug, }: {
30
+ export declare const getRetryInterceptor: ({ maxRetries, retryDelay, }: {
29
31
  maxRetries: number;
30
32
  retryDelay: number;
31
- debug: boolean;
32
33
  }) => (options: any, nextCall: any) => InterceptingCall;
33
34
  export {};