triangle-utils 1.4.74 → 1.4.75

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.
@@ -9,6 +9,7 @@ export declare class UtilsDynamoDB {
9
9
  attribute_names?: string[];
10
10
  segment_id?: number;
11
11
  num_segments?: number;
12
+ last_key?: Record<string, any>;
12
13
  }): Promise<Record<string, any>[]>;
13
14
  get(table: string, key: Record<string, any>, consistent?: boolean): Promise<Record<string, any> | undefined>;
14
15
  get_max(table_index_name: string, primary_key: Record<string, string | number>): Promise<Record<string, any> | undefined>;
@@ -20,6 +21,7 @@ export declare class UtilsDynamoDB {
20
21
  defined_attribute_names?: string[];
21
22
  attribute_names?: string[];
22
23
  max_num_items?: number;
24
+ last_key?: Record<string, any>;
23
25
  }): Promise<Record<string, any>[]>;
24
26
  query_prefix(table_index_name: string, primary_key: Record<string, any>, secondary_key_prefix: Record<string, string>, options?: {
25
27
  reverse?: boolean;
@@ -29,6 +31,7 @@ export declare class UtilsDynamoDB {
29
31
  defined_attribute_names?: string[];
30
32
  attribute_names?: string[];
31
33
  max_num_items?: number;
34
+ last_key?: Record<string, any>;
32
35
  }): Promise<Record<string, any>[]>;
33
36
  query_range(table_index_name: string, primary_key: Record<string, any>, secondary_key_range: Record<string, (string | number)[]>, options?: {
34
37
  reverse?: boolean;
@@ -38,6 +41,7 @@ export declare class UtilsDynamoDB {
38
41
  defined_attribute_names?: string[];
39
42
  attribute_names?: string[];
40
43
  max_num_items?: number;
44
+ last_key?: Record<string, any>;
41
45
  }): Promise<Record<string, any>[]>;
42
46
  set(table_name: string, key: Record<string, any>, attributes: Record<string, any>): Promise<void>;
43
47
  append(table_name: string, key: Record<string, any>, attributes: Record<string, any[]>): Promise<void>;
@@ -64,7 +64,7 @@ function convert_input(input) {
64
64
  }
65
65
  async function compile_pages(request, f, compile = true) {
66
66
  const items = [];
67
- let last_eval_key = undefined;
67
+ let last_eval_key = request.ExclusiveStartKey;
68
68
  while (true) {
69
69
  const request_page = {
70
70
  ...request,
@@ -130,7 +130,8 @@ export class UtilsDynamoDB {
130
130
  FilterExpression: filter_expression.length > 0 ? filter_expression : undefined,
131
131
  ProjectionExpression: projection_expression.length > 0 ? projection_expression : undefined,
132
132
  Segment: i,
133
- TotalSegments: num_segments
133
+ TotalSegments: num_segments,
134
+ ExclusiveStartKey: options.last_key !== undefined ? convert_input(options.last_key)?.M : undefined
134
135
  };
135
136
  iterators.push(compile_pages(request, (request) => this.dynamodb.scan(request)));
136
137
  }
@@ -228,7 +229,8 @@ export class UtilsDynamoDB {
228
229
  ProjectionExpression: projection_expression.length > 0 ? projection_expression : undefined,
229
230
  KeyConditionExpression: Object.keys(primary_key).map(key => "#" + key + " = :" + key).join(" AND "),
230
231
  ScanIndexForward: !reverse,
231
- Limit: options.max_num_items
232
+ Limit: options.max_num_items,
233
+ ExclusiveStartKey: options.last_key !== undefined ? convert_input(options.last_key)?.M : undefined
232
234
  };
233
235
  const items = await compile_pages(request, (request) => this.dynamodb.query(request), compile);
234
236
  // .then(async items => index_name === undefined || !project ? items :
@@ -289,7 +291,8 @@ export class UtilsDynamoDB {
289
291
  ...Object.keys(secondary_key_prefix).map(key => "begins_with(#" + key + ", :" + key + ")")
290
292
  ].join(" AND "),
291
293
  ScanIndexForward: !reverse,
292
- Limit: options.max_num_items
294
+ Limit: options.max_num_items,
295
+ ExclusiveStartKey: options.last_key !== undefined ? convert_input(options.last_key)?.M : undefined
293
296
  };
294
297
  const items = await compile_pages(request, (request) => this.dynamodb.query(request), compile);
295
298
  // .then(async items => index_name === undefined || !project ? items :
@@ -353,7 +356,8 @@ export class UtilsDynamoDB {
353
356
  ...Object.keys(secondary_key_range).map(key => "(#" + key + " BETWEEN :" + key + "_min AND :" + key + "_max)")
354
357
  ].join(" AND "),
355
358
  ScanIndexForward: !reverse,
356
- Limit: options.max_num_items
359
+ Limit: options.max_num_items,
360
+ ExclusiveStartKey: options.last_key !== undefined ? convert_input(options.last_key)?.M : undefined
357
361
  };
358
362
  const items = await compile_pages(request, (request) => this.dynamodb.query(request), compile);
359
363
  // .then(async items => index_name === undefined || !project ? items :
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-utils",
3
- "version": "1.4.74",
3
+ "version": "1.4.75",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "directories": {
@@ -64,7 +64,7 @@ async function compile_pages(
64
64
  compile : boolean = true
65
65
  ) : Promise<any[]> {
66
66
  const items = []
67
- let last_eval_key : Record<string, AttributeValue> | undefined = undefined
67
+ let last_eval_key : Record<string, AttributeValue> | undefined = request.ExclusiveStartKey
68
68
  while (true) {
69
69
  const request_page : ScanCommandInput|QueryCommandInput = {
70
70
  ...request,
@@ -113,7 +113,8 @@ export class UtilsDynamoDB {
113
113
  defined_attribute_names? : string[],
114
114
  attribute_names? : string[],
115
115
  segment_id? : number
116
- num_segments? : number
116
+ num_segments? : number,
117
+ last_key? : Record<string, any>
117
118
  } = {}
118
119
  ) : Promise<Record<string, any>[]> {
119
120
  const table_name : string = table_index_name.split(":")[0]
@@ -151,7 +152,8 @@ export class UtilsDynamoDB {
151
152
  FilterExpression : filter_expression.length > 0 ? filter_expression : undefined,
152
153
  ProjectionExpression : projection_expression.length > 0 ? projection_expression : undefined,
153
154
  Segment : i,
154
- TotalSegments : num_segments
155
+ TotalSegments : num_segments,
156
+ ExclusiveStartKey : options.last_key !== undefined ? convert_input(options.last_key)?.M : undefined
155
157
  }
156
158
  iterators.push(compile_pages(request, (request : ScanCommandInput) => this.dynamodb.scan(request)))
157
159
  }
@@ -232,7 +234,8 @@ export class UtilsDynamoDB {
232
234
  undefined_attribute_names? : string[],
233
235
  defined_attribute_names? : string[],
234
236
  attribute_names? : string[],
235
- max_num_items? : number
237
+ max_num_items? : number,
238
+ last_key? : Record<string, any>
236
239
  } = {}
237
240
  ) : Promise<Record<string, any>[]>{
238
241
  const table_name : string = table_index_name.split(":")[0]
@@ -277,7 +280,8 @@ export class UtilsDynamoDB {
277
280
  ProjectionExpression : projection_expression.length > 0 ? projection_expression : undefined,
278
281
  KeyConditionExpression: Object.keys(primary_key).map(key => "#" + key + " = :" + key).join(" AND "),
279
282
  ScanIndexForward : !reverse,
280
- Limit : options.max_num_items
283
+ Limit : options.max_num_items,
284
+ ExclusiveStartKey : options.last_key !== undefined ? convert_input(options.last_key)?.M : undefined
281
285
  }
282
286
  const items = await compile_pages(request, (request) => this.dynamodb.query(request), compile)
283
287
  // .then(async items => index_name === undefined || !project ? items :
@@ -303,7 +307,8 @@ export class UtilsDynamoDB {
303
307
  undefined_attribute_names? : string[],
304
308
  defined_attribute_names? : string[],
305
309
  attribute_names? : string[],
306
- max_num_items? : number
310
+ max_num_items? : number,
311
+ last_key? : Record<string, any>
307
312
  } = {}
308
313
  ) : Promise<Record<string, any>[]>{
309
314
  const table_name : string = table_index_name.split(":")[0]
@@ -355,7 +360,8 @@ export class UtilsDynamoDB {
355
360
  ...Object.keys(secondary_key_prefix).map(key => "begins_with(#" + key + ", :" + key + ")")
356
361
  ].join(" AND "),
357
362
  ScanIndexForward : !reverse,
358
- Limit : options.max_num_items
363
+ Limit : options.max_num_items,
364
+ ExclusiveStartKey : options.last_key !== undefined ? convert_input(options.last_key)?.M : undefined
359
365
  }
360
366
  const items = await compile_pages(request, (request) => this.dynamodb.query(request), compile)
361
367
  // .then(async items => index_name === undefined || !project ? items :
@@ -381,7 +387,8 @@ export class UtilsDynamoDB {
381
387
  undefined_attribute_names? : string[],
382
388
  defined_attribute_names? : string[],
383
389
  attribute_names? : string[],
384
- max_num_items? : number
390
+ max_num_items? : number,
391
+ last_key? : Record<string, any>
385
392
  } = {}
386
393
  ) : Promise<Record<string, any>[]>{
387
394
  const table_name : string = table_index_name.split(":")[0]
@@ -436,7 +443,8 @@ export class UtilsDynamoDB {
436
443
  ...Object.keys(secondary_key_range).map(key => "(#" + key + " BETWEEN :" + key + "_min AND :" + key + "_max)")
437
444
  ].join(" AND "),
438
445
  ScanIndexForward : !reverse,
439
- Limit : options.max_num_items
446
+ Limit : options.max_num_items,
447
+ ExclusiveStartKey : options.last_key !== undefined ? convert_input(options.last_key)?.M : undefined
440
448
  }
441
449
  const items = await compile_pages(request, (request) => this.dynamodb.query(request), compile)
442
450
  // .then(async items => index_name === undefined || !project ? items :