triangle-utils 1.4.90 → 1.4.92

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.
@@ -18,5 +18,6 @@ export declare class UtilsS3Vectors {
18
18
  query(s3_vector_id_prefix: string, coordinates: number[], num_vectors: number, filters?: Record<string, any> | undefined): Promise<{
19
19
  s3_vector_id: string;
20
20
  distance: number;
21
+ headers: Record<string, any>;
21
22
  }[]>;
22
23
  }
@@ -89,7 +89,7 @@ export class UtilsS3Vectors {
89
89
  const s3vectors_inputs = s3_vector_ids.map(get_s3vectors_input);
90
90
  const { s3_vector_bucket_name, s3_vector_index_name } = s3vectors_inputs[0];
91
91
  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)) {
92
- return [];
92
+ throw Error("Inconsistent prefixes.");
93
93
  }
94
94
  const s3_vectors = [];
95
95
  for (let i = 0; i < s3vectors_inputs.length; i += 100) {
@@ -143,7 +143,7 @@ export class UtilsS3Vectors {
143
143
  const s3vectors_inputs = s3_vectors.map(s3_vector => get_s3vectors_input(s3_vector.s3_vector_id));
144
144
  const { s3_vector_bucket_name, s3_vector_index_name } = s3vectors_inputs[0];
145
145
  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)) {
146
- return undefined;
146
+ throw Error("Inconsistent prefixes.");
147
147
  }
148
148
  for (let i = 0; i < s3_vectors.length; i += 500) {
149
149
  await this.s3vectors.putVectors({
@@ -171,7 +171,7 @@ export class UtilsS3Vectors {
171
171
  const s3vectors_inputs = s3_vector_ids.map(get_s3vectors_input);
172
172
  const { s3_vector_bucket_name, s3_vector_index_name } = s3vectors_inputs[0];
173
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)) {
174
- return undefined;
174
+ throw Error("Inconsistent prefixes.");
175
175
  }
176
176
  for (let i = 0; i < s3vectors_inputs.length; i += 500) {
177
177
  await this.s3vectors.deleteVectors({
@@ -211,9 +211,15 @@ export class UtilsS3Vectors {
211
211
  console.log("Bad distance:", distance);
212
212
  continue;
213
213
  }
214
+ const headers = new_vector.metadata;
215
+ if (!(typeof headers === "object" && Object.keys(headers).every((header_id) => typeof header_id === "string"))) {
216
+ console.log("Bad headers:", headers);
217
+ continue;
218
+ }
214
219
  results.push({
215
220
  s3_vector_id: s3_vector_id,
216
- distance: distance
221
+ distance: distance,
222
+ headers: headers
217
223
  });
218
224
  }
219
225
  return results;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-utils",
3
- "version": "1.4.90",
3
+ "version": "1.4.92",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "directories": {
@@ -109,7 +109,7 @@ export class UtilsS3Vectors {
109
109
  const s3vectors_inputs : S3VectorsInput[] = s3_vector_ids.map(get_s3vectors_input)
110
110
  const { s3_vector_bucket_name, s3_vector_index_name } = s3vectors_inputs[0]
111
111
  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)) {
112
- return []
112
+ throw Error("Inconsistent prefixes.")
113
113
  }
114
114
  const s3_vectors : (S3Vector | undefined)[] = []
115
115
  for (let i = 0; i < s3vectors_inputs.length; i += 100) {
@@ -165,7 +165,7 @@ export class UtilsS3Vectors {
165
165
  const s3vectors_inputs : S3VectorsInput[] = s3_vectors.map(s3_vector => get_s3vectors_input(s3_vector.s3_vector_id))
166
166
  const { s3_vector_bucket_name, s3_vector_index_name } = s3vectors_inputs[0]
167
167
  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
- return undefined
168
+ throw Error("Inconsistent prefixes.")
169
169
  }
170
170
  for (let i = 0; i < s3_vectors.length; i += 500) {
171
171
  await this.s3vectors.putVectors({
@@ -196,7 +196,7 @@ export class UtilsS3Vectors {
196
196
  const s3vectors_inputs : S3VectorsInput[] = s3_vector_ids.map(get_s3vectors_input)
197
197
  const { s3_vector_bucket_name, s3_vector_index_name } = s3vectors_inputs[0]
198
198
  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)) {
199
- return undefined
199
+ throw Error("Inconsistent prefixes.")
200
200
  }
201
201
  for (let i = 0; i < s3vectors_inputs.length; i += 500) {
202
202
  await this.s3vectors.deleteVectors({
@@ -224,7 +224,7 @@ export class UtilsS3Vectors {
224
224
  if (new_vectors === undefined) {
225
225
  return []
226
226
  }
227
- const results : { s3_vector_id : string, distance : number }[] = []
227
+ const results : { s3_vector_id : string, distance : number, headers : Record<string, any> }[] = []
228
228
  for (const new_vector of new_vectors) {
229
229
  const s3_vector_key = new_vector.key
230
230
  if (s3_vector_key === undefined) {
@@ -237,9 +237,15 @@ export class UtilsS3Vectors {
237
237
  console.log("Bad distance:", distance)
238
238
  continue
239
239
  }
240
+ const headers : any = new_vector.metadata
241
+ if (!(typeof headers === "object" && Object.keys(headers).every((header_id : any) => typeof header_id === "string"))) {
242
+ console.log("Bad headers:", headers)
243
+ continue
244
+ }
240
245
  results.push({
241
246
  s3_vector_id : s3_vector_id,
242
- distance : distance
247
+ distance : distance,
248
+ headers : headers
243
249
  })
244
250
  }
245
251
  return results