triangle-utils 1.4.39 → 1.4.41

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.
@@ -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);
@@ -52,10 +65,10 @@ export class UtilsS3 {
52
65
  .filter(key => key.substring(key.length - 1) !== "/")
53
66
  .map(key => "s3://" + s3_key.Bucket + "/" + key);
54
67
  s3_filenames.push(...new_s3_filenames);
55
- if (response.ContinuationToken === undefined || !compile) {
68
+ if (response.NextContinuationToken === undefined || !compile) {
56
69
  return s3_filenames;
57
70
  }
58
- last_token = response.ContinuationToken;
71
+ last_token = response.NextContinuationToken;
59
72
  }
60
73
  }
61
74
  async get_file(s3_filename, encoding = "utf-8") {
package/dist/src/f.js CHANGED
@@ -13,5 +13,5 @@ const config = {
13
13
  ...api_keys
14
14
  };
15
15
  const utils = new TriangleUtils(config);
16
- const foods = await utils.dynamodb.query("triage_docket_documents:register_document_id", { register_document_id: "E6-17065" });
17
- console.log(foods);
16
+ // const foods = await utils.dynamodb.query("triage_docket_documents:register_document_id", { register_document_id : "E6-17065" })
17
+ // console.log(foods)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-utils",
3
- "version": "1.4.39",
3
+ "version": "1.4.41",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "directories": {
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)
@@ -62,10 +75,10 @@ export class UtilsS3 {
62
75
  .filter(key => key.substring(key.length - 1) !== "/")
63
76
  .map(key => "s3://" + s3_key.Bucket + "/" + key)
64
77
  s3_filenames.push(...new_s3_filenames)
65
- if (response.ContinuationToken === undefined || !compile) {
78
+ if (response.NextContinuationToken === undefined || !compile) {
66
79
  return s3_filenames
67
80
  }
68
- last_token = response.ContinuationToken
81
+ last_token = response.NextContinuationToken
69
82
  }
70
83
  }
71
84
 
package/src/f.ts CHANGED
@@ -20,6 +20,6 @@ const config = {
20
20
 
21
21
  const utils = new TriangleUtils(config)
22
22
 
23
- const foods = await utils.dynamodb.query("triage_docket_documents:register_document_id", { register_document_id : "E6-17065" })
23
+ // const foods = await utils.dynamodb.query("triage_docket_documents:register_document_id", { register_document_id : "E6-17065" })
24
24
 
25
- console.log(foods)
25
+ // console.log(foods)