triangle-utils 1.4.40 → 1.4.42

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.
@@ -7,6 +7,7 @@ export declare class UtilsDynamoDB {
7
7
  undefined_attribute_names?: string[];
8
8
  defined_attribute_names?: string[];
9
9
  attribute_names?: string[];
10
+ segment?: number;
10
11
  concurrency?: number;
11
12
  }): Promise<Record<string, any>[]>;
12
13
  get(table: string, key: Record<string, any>, consistent?: boolean): Promise<Record<string, any> | undefined>;
@@ -108,6 +108,9 @@ export class UtilsDynamoDB {
108
108
  const attribute_names = options.attribute_names !== undefined ? options.attribute_names : [];
109
109
  const iterators = [];
110
110
  for (let i = 0; i < concurrency; i++) {
111
+ if (options.segment !== undefined && i === options.segment) {
112
+ continue;
113
+ }
111
114
  const expression_attribute_names = Object.fromEntries([...Object.keys(filters), ...attribute_names, ...undefined_attribute_names, ...defined_attribute_names]
112
115
  .map(attribute_name => ["#" + attribute_name, attribute_name]));
113
116
  const expression_attribute_values = Object.fromEntries(Object.entries(filters)
@@ -3,6 +3,7 @@ export declare class UtilsS3 {
3
3
  private readonly s3;
4
4
  constructor(region: string);
5
5
  file_exists(s3_filename: string): Promise<boolean | undefined>;
6
+ get_file_size(s3_filename: string): Promise<number | undefined>;
6
7
  get_s3_filenames(s3_filename_prefix: string, options?: {
7
8
  compile?: boolean;
8
9
  }): Promise<string[]>;
@@ -28,6 +28,19 @@ export class UtilsS3 {
28
28
  return false;
29
29
  }
30
30
  }
31
+ async get_file_size(s3_filename) {
32
+ const s3_key = parse_s3_filename(s3_filename);
33
+ if (s3_key === undefined) {
34
+ return undefined;
35
+ }
36
+ try {
37
+ const head = await this.s3.headObject(s3_key);
38
+ return head.ContentLength;
39
+ }
40
+ catch (error) {
41
+ return undefined;
42
+ }
43
+ }
31
44
  async get_s3_filenames(s3_filename_prefix, options = {}) {
32
45
  const compile = options.compile !== undefined ? options.compile : false;
33
46
  const s3_key = parse_s3_filename(s3_filename_prefix);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-utils",
3
- "version": "1.4.40",
3
+ "version": "1.4.42",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "directories": {
@@ -112,6 +112,7 @@ export class UtilsDynamoDB {
112
112
  undefined_attribute_names? : string[],
113
113
  defined_attribute_names? : string[],
114
114
  attribute_names? : string[],
115
+ segment? : number
115
116
  concurrency? : number
116
117
  } = {}
117
118
  ) : Promise<Record<string, any>[]> {
@@ -124,6 +125,9 @@ export class UtilsDynamoDB {
124
125
  const attribute_names : string[] = options.attribute_names !== undefined ? options.attribute_names : []
125
126
  const iterators = []
126
127
  for (let i = 0; i < concurrency; i++) {
128
+ if (options.segment !== undefined && i === options.segment) {
129
+ continue
130
+ }
127
131
  const expression_attribute_names = Object.fromEntries(
128
132
  [...Object.keys(filters), ...attribute_names, ...undefined_attribute_names, ...defined_attribute_names]
129
133
  .map(attribute_name => ["#" + attribute_name, attribute_name])
package/src/UtilsS3.ts CHANGED
@@ -38,6 +38,19 @@ export class UtilsS3 {
38
38
  }
39
39
  }
40
40
 
41
+ async get_file_size(s3_filename : string) : Promise<number | undefined> {
42
+ const s3_key = parse_s3_filename(s3_filename)
43
+ if (s3_key === undefined) {
44
+ return undefined
45
+ }
46
+ try {
47
+ const head = await this.s3.headObject(s3_key)
48
+ return head.ContentLength
49
+ } catch (error) {
50
+ return undefined
51
+ }
52
+ }
53
+
41
54
  async get_s3_filenames(s3_filename_prefix : string, options : { compile? : boolean } = {}) {
42
55
  const compile = options.compile !== undefined ? options.compile : false
43
56
  const s3_key = parse_s3_filename(s3_filename_prefix)