triangle-utils 1.4.93 → 1.4.95

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.
@@ -12,6 +12,7 @@ export declare class UtilsDynamoDB {
12
12
  num_segments?: number;
13
13
  max_num_items?: number;
14
14
  last_key?: Record<string, any>;
15
+ print?: boolean;
15
16
  }): Promise<Record<string, any>[]>;
16
17
  get(table: string, key: Record<string, any>, options?: {
17
18
  consistent?: boolean;
@@ -26,6 +27,7 @@ export declare class UtilsDynamoDB {
26
27
  attribute_names?: string[];
27
28
  max_num_items?: number;
28
29
  last_key?: Record<string, any>;
30
+ print?: boolean;
29
31
  }): Promise<Record<string, any>[]>;
30
32
  query_prefix(table_index_name: string, primary_key: Record<string, any>, secondary_key_prefix: Record<string, string>, options?: {
31
33
  reverse?: boolean;
@@ -36,6 +38,7 @@ export declare class UtilsDynamoDB {
36
38
  attribute_names?: string[];
37
39
  max_num_items?: number;
38
40
  last_key?: Record<string, any>;
41
+ print?: boolean;
39
42
  }): Promise<Record<string, any>[]>;
40
43
  query_range(table_index_name: string, primary_key: Record<string, any>, secondary_key_range: Record<string, (string | number)[]>, options?: {
41
44
  reverse?: boolean;
@@ -46,6 +49,7 @@ export declare class UtilsDynamoDB {
46
49
  attribute_names?: string[];
47
50
  max_num_items?: number;
48
51
  last_key?: Record<string, any>;
52
+ print?: boolean;
49
53
  }): Promise<Record<string, any>[]>;
50
54
  set(table_name: string, key: Record<string, any>, attributes: Record<string, any>): Promise<void>;
51
55
  append(table_name: string, key: Record<string, any>, attributes: Record<string, any[]>): Promise<void>;
@@ -135,6 +135,7 @@ export class UtilsDynamoDB {
135
135
  Limit: options.max_num_items,
136
136
  ExclusiveStartKey: options.last_key !== undefined ? convert_input(options.last_key)?.M : undefined
137
137
  };
138
+ console.log(request);
138
139
  iterators.push(compile_pages(request, (request) => this.dynamodb.scan(request), compile));
139
140
  }
140
141
  const segments = await Promise.all(iterators);
@@ -235,6 +236,7 @@ export class UtilsDynamoDB {
235
236
  Limit: options.max_num_items,
236
237
  ExclusiveStartKey: options.last_key !== undefined ? convert_input(options.last_key)?.M : undefined
237
238
  };
239
+ console.log(request);
238
240
  const items = await compile_pages(request, (request) => this.dynamodb.query(request), compile);
239
241
  // .then(async items => index_name === undefined || !project ? items :
240
242
  // await Promise.all(items.map(async item => {
@@ -297,6 +299,7 @@ export class UtilsDynamoDB {
297
299
  Limit: options.max_num_items,
298
300
  ExclusiveStartKey: options.last_key !== undefined ? convert_input(options.last_key)?.M : undefined
299
301
  };
302
+ console.log(request);
300
303
  const items = await compile_pages(request, (request) => this.dynamodb.query(request), compile);
301
304
  // .then(async items => index_name === undefined || !project ? items :
302
305
  // await Promise.all(items.map(async item => {
@@ -362,6 +365,7 @@ export class UtilsDynamoDB {
362
365
  Limit: options.max_num_items,
363
366
  ExclusiveStartKey: options.last_key !== undefined ? convert_input(options.last_key)?.M : undefined
364
367
  };
368
+ console.log(request);
365
369
  const items = await compile_pages(request, (request) => this.dynamodb.query(request), compile);
366
370
  // .then(async items => index_name === undefined || !project ? items :
367
371
  // await Promise.all(items.map(async item => {
@@ -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)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-utils",
3
- "version": "1.4.93",
3
+ "version": "1.4.95",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "directories": {
@@ -116,7 +116,8 @@ export class UtilsDynamoDB {
116
116
  segment_id? : number
117
117
  num_segments? : number,
118
118
  max_num_items? : number,
119
- last_key? : Record<string, any>
119
+ last_key? : Record<string, any>,
120
+ print? : boolean
120
121
  } = {}
121
122
  ) : Promise<Record<string, any>[]> {
122
123
  const table_name : string = table_index_name.split(":")[0]
@@ -159,6 +160,7 @@ export class UtilsDynamoDB {
159
160
  Limit : options.max_num_items,
160
161
  ExclusiveStartKey : options.last_key !== undefined ? convert_input(options.last_key)?.M : undefined
161
162
  }
163
+ console.log(request)
162
164
  iterators.push(compile_pages(request, (request : ScanCommandInput) => this.dynamodb.scan(request), compile))
163
165
  }
164
166
  const segments = await Promise.all(iterators)
@@ -242,7 +244,8 @@ export class UtilsDynamoDB {
242
244
  defined_attribute_names? : string[],
243
245
  attribute_names? : string[],
244
246
  max_num_items? : number,
245
- last_key? : Record<string, any>
247
+ last_key? : Record<string, any>,
248
+ print? : boolean
246
249
  } = {}
247
250
  ) : Promise<Record<string, any>[]>{
248
251
  const table_name : string = table_index_name.split(":")[0]
@@ -290,6 +293,7 @@ export class UtilsDynamoDB {
290
293
  Limit : options.max_num_items,
291
294
  ExclusiveStartKey : options.last_key !== undefined ? convert_input(options.last_key)?.M : undefined
292
295
  }
296
+ console.log(request)
293
297
  const items = await compile_pages(request, (request) => this.dynamodb.query(request), compile)
294
298
  // .then(async items => index_name === undefined || !project ? items :
295
299
  // await Promise.all(items.map(async item => {
@@ -315,7 +319,8 @@ export class UtilsDynamoDB {
315
319
  defined_attribute_names? : string[],
316
320
  attribute_names? : string[],
317
321
  max_num_items? : number,
318
- last_key? : Record<string, any>
322
+ last_key? : Record<string, any>,
323
+ print? : boolean
319
324
  } = {}
320
325
  ) : Promise<Record<string, any>[]>{
321
326
  const table_name : string = table_index_name.split(":")[0]
@@ -370,6 +375,7 @@ export class UtilsDynamoDB {
370
375
  Limit : options.max_num_items,
371
376
  ExclusiveStartKey : options.last_key !== undefined ? convert_input(options.last_key)?.M : undefined
372
377
  }
378
+ console.log(request)
373
379
  const items = await compile_pages(request, (request) => this.dynamodb.query(request), compile)
374
380
  // .then(async items => index_name === undefined || !project ? items :
375
381
  // await Promise.all(items.map(async item => {
@@ -395,7 +401,8 @@ export class UtilsDynamoDB {
395
401
  defined_attribute_names? : string[],
396
402
  attribute_names? : string[],
397
403
  max_num_items? : number,
398
- last_key? : Record<string, any>
404
+ last_key? : Record<string, any>,
405
+ print? : boolean
399
406
  } = {}
400
407
  ) : Promise<Record<string, any>[]>{
401
408
  const table_name : string = table_index_name.split(":")[0]
@@ -453,6 +460,7 @@ export class UtilsDynamoDB {
453
460
  Limit : options.max_num_items,
454
461
  ExclusiveStartKey : options.last_key !== undefined ? convert_input(options.last_key)?.M : undefined
455
462
  }
463
+ console.log(request)
456
464
  const items = await compile_pages(request, (request) => this.dynamodb.query(request), compile)
457
465
  // .then(async items => index_name === undefined || !project ? items :
458
466
  // await Promise.all(items.map(async item => {
@@ -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)) {