triangle-utils 1.4.92 → 1.4.94

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.
@@ -19,7 +19,7 @@ export class S3Vector {
19
19
  }
20
20
  }
21
21
  function get_s3vectors_input(s3_vector_id) {
22
- const [s3_vector_bucket_name, s3_vector_index_name, s3_vector_key] = (s3_vector_id.match(/^s3vectors:\/\/([^\/]+)\/([^\/]+)\/([^$]*)$/) || []).slice(1, 4);
22
+ const [s3_vector_bucket_name, s3_vector_index_name, s3_vector_key] = (s3_vector_id.match(/^s3vectors:\/\/([^\/]+)\/([^\/]+)\/?([^$\/]*)$/) || []).slice(1, 4);
23
23
  if (s3_vector_bucket_name === undefined || s3_vector_index_name === undefined || s3_vector_key === undefined) {
24
24
  throw Error("Bad s3_vector_id: " + s3_vector_id);
25
25
  }
@@ -86,6 +86,9 @@ export class UtilsS3Vectors {
86
86
  return s3_vector;
87
87
  }
88
88
  async batch_get(s3_vector_ids) {
89
+ if (s3_vector_ids.length === 0) {
90
+ return [];
91
+ }
89
92
  const s3vectors_inputs = s3_vector_ids.map(get_s3vectors_input);
90
93
  const { s3_vector_bucket_name, s3_vector_index_name } = s3vectors_inputs[0];
91
94
  if (!s3vectors_inputs.every(s3vectors_input => s3vectors_input.s3_vector_bucket_name === s3_vector_bucket_name && s3vectors_input.s3_vector_index_name === s3_vector_index_name)) {
@@ -140,6 +143,9 @@ export class UtilsS3Vectors {
140
143
  });
141
144
  }
142
145
  async batch_put(s3_vectors) {
146
+ if (s3_vectors.length === 0) {
147
+ return;
148
+ }
143
149
  const s3vectors_inputs = s3_vectors.map(s3_vector => get_s3vectors_input(s3_vector.s3_vector_id));
144
150
  const { s3_vector_bucket_name, s3_vector_index_name } = s3vectors_inputs[0];
145
151
  if (!s3vectors_inputs.every(s3vectors_input => s3vectors_input.s3_vector_bucket_name === s3_vector_bucket_name && s3vectors_input.s3_vector_index_name === s3_vector_index_name)) {
@@ -168,6 +174,9 @@ export class UtilsS3Vectors {
168
174
  });
169
175
  }
170
176
  async batch_delete(s3_vector_ids) {
177
+ if (s3_vector_ids.length === 0) {
178
+ return;
179
+ }
171
180
  const s3vectors_inputs = s3_vector_ids.map(get_s3vectors_input);
172
181
  const { s3_vector_bucket_name, s3_vector_index_name } = s3vectors_inputs[0];
173
182
  if (!s3vectors_inputs.every(s3vectors_input => s3vectors_input.s3_vector_bucket_name === s3_vector_bucket_name && s3vectors_input.s3_vector_index_name === s3_vector_index_name)) {
@@ -205,7 +214,7 @@ export class UtilsS3Vectors {
205
214
  console.log("Bad s3_vector_key:", s3_vector_key);
206
215
  continue;
207
216
  }
208
- const s3_vector_id = s3_vector_id_prefix + "/" + s3_vector_key;
217
+ const s3_vector_id = s3_vector_id_prefix + s3_vector_key;
209
218
  const distance = new_vector.distance;
210
219
  if (distance === undefined) {
211
220
  console.log("Bad distance:", distance);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-utils",
3
- "version": "1.4.92",
3
+ "version": "1.4.94",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "directories": {
@@ -31,7 +31,7 @@ interface S3VectorsInput {
31
31
  }
32
32
 
33
33
  function get_s3vectors_input(s3_vector_id : string) : S3VectorsInput {
34
- const [s3_vector_bucket_name, s3_vector_index_name, s3_vector_key] = (s3_vector_id.match(/^s3vectors:\/\/([^\/]+)\/([^\/]+)\/([^$]*)$/) || []).slice(1, 4)
34
+ const [s3_vector_bucket_name, s3_vector_index_name, s3_vector_key] = (s3_vector_id.match(/^s3vectors:\/\/([^\/]+)\/([^\/]+)\/?([^$\/]*)$/) || []).slice(1, 4)
35
35
  if (s3_vector_bucket_name === undefined || s3_vector_index_name === undefined || s3_vector_key === undefined) {
36
36
  throw Error("Bad s3_vector_id: " + s3_vector_id)
37
37
  }
@@ -106,6 +106,9 @@ export class UtilsS3Vectors {
106
106
  }
107
107
 
108
108
  async batch_get(s3_vector_ids : string[]) {
109
+ if (s3_vector_ids.length === 0) {
110
+ return []
111
+ }
109
112
  const s3vectors_inputs : S3VectorsInput[] = s3_vector_ids.map(get_s3vectors_input)
110
113
  const { s3_vector_bucket_name, s3_vector_index_name } = s3vectors_inputs[0]
111
114
  if (!s3vectors_inputs.every(s3vectors_input => s3vectors_input.s3_vector_bucket_name === s3_vector_bucket_name && s3vectors_input.s3_vector_index_name === s3_vector_index_name)) {
@@ -162,6 +165,9 @@ export class UtilsS3Vectors {
162
165
  }
163
166
 
164
167
  async batch_put(s3_vectors : S3Vector[]) : Promise<void> {
168
+ if (s3_vectors.length === 0) {
169
+ return
170
+ }
165
171
  const s3vectors_inputs : S3VectorsInput[] = s3_vectors.map(s3_vector => get_s3vectors_input(s3_vector.s3_vector_id))
166
172
  const { s3_vector_bucket_name, s3_vector_index_name } = s3vectors_inputs[0]
167
173
  if (!s3vectors_inputs.every(s3vectors_input => s3vectors_input.s3_vector_bucket_name === s3_vector_bucket_name && s3vectors_input.s3_vector_index_name === s3_vector_index_name)) {
@@ -193,6 +199,9 @@ export class UtilsS3Vectors {
193
199
  }
194
200
 
195
201
  async batch_delete(s3_vector_ids : string[]) : Promise<void> {
202
+ if (s3_vector_ids.length === 0) {
203
+ return
204
+ }
196
205
  const s3vectors_inputs : S3VectorsInput[] = s3_vector_ids.map(get_s3vectors_input)
197
206
  const { s3_vector_bucket_name, s3_vector_index_name } = s3vectors_inputs[0]
198
207
  if (!s3vectors_inputs.every(s3vectors_input => s3vectors_input.s3_vector_bucket_name === s3_vector_bucket_name && s3vectors_input.s3_vector_index_name === s3_vector_index_name)) {
@@ -231,7 +240,7 @@ export class UtilsS3Vectors {
231
240
  console.log("Bad s3_vector_key:", s3_vector_key)
232
241
  continue
233
242
  }
234
- const s3_vector_id = s3_vector_id_prefix + "/" + s3_vector_key
243
+ const s3_vector_id = s3_vector_id_prefix + s3_vector_key
235
244
  const distance = new_vector.distance
236
245
  if (distance === undefined) {
237
246
  console.log("Bad distance:", distance)