triangle-utils 1.4.116 → 1.4.117

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.
@@ -4,11 +4,11 @@ interface S3Input {
4
4
  Bucket: string;
5
5
  Key: string;
6
6
  }
7
- export declare function get_s3_input(s3_id: string): S3Input | undefined;
8
7
  export declare class UtilsS3 {
9
8
  private readonly s3;
10
9
  constructor(region: string);
11
10
  get_client(): Promise<S3>;
11
+ get_s3_input(s3_id: string): S3Input | undefined;
12
12
  get_headers(s3_id: string): Promise<{
13
13
  DeleteMarker?: boolean | undefined;
14
14
  AcceptRanges?: string | undefined;
@@ -2,13 +2,6 @@ import { S3, NoSuchKey, GetObjectCommand, PutObjectCommand } from "@aws-sdk/clie
2
2
  import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
3
3
  import { Upload } from "@aws-sdk/lib-storage";
4
4
  import { Readable } from "stream";
5
- export function get_s3_input(s3_id) {
6
- const [bucket, path] = (s3_id.match(/^s3\:\/\/([^\/]+)\/([^$]+)$/) || []).slice(1, 3);
7
- if (bucket === undefined || path === undefined) {
8
- return undefined;
9
- }
10
- return { Bucket: bucket, Key: path };
11
- }
12
5
  export class UtilsS3 {
13
6
  s3;
14
7
  constructor(region) {
@@ -17,8 +10,15 @@ export class UtilsS3 {
17
10
  async get_client() {
18
11
  return this.s3;
19
12
  }
13
+ get_s3_input(s3_id) {
14
+ const [bucket, path] = (s3_id.match(/^s3\:\/\/([^\/]+)\/([^$]+)$/) || []).slice(1, 3);
15
+ if (bucket === undefined || path === undefined) {
16
+ return undefined;
17
+ }
18
+ return { Bucket: bucket, Key: path };
19
+ }
20
20
  async get_headers(s3_id) {
21
- const s3_input = get_s3_input(s3_id);
21
+ const s3_input = this.get_s3_input(s3_id);
22
22
  if (s3_input === undefined) {
23
23
  return undefined;
24
24
  }
@@ -34,7 +34,7 @@ export class UtilsS3 {
34
34
  }
35
35
  }
36
36
  async get(s3_id, encoding = "utf-8") {
37
- const s3_input = get_s3_input(s3_id);
37
+ const s3_input = this.get_s3_input(s3_id);
38
38
  if (s3_input === undefined) {
39
39
  return undefined;
40
40
  }
@@ -55,7 +55,7 @@ export class UtilsS3 {
55
55
  }
56
56
  }
57
57
  async get_buffer(s3_id) {
58
- const s3_input = get_s3_input(s3_id);
58
+ const s3_input = this.get_s3_input(s3_id);
59
59
  if (s3_input === undefined) {
60
60
  return undefined;
61
61
  }
@@ -76,7 +76,7 @@ export class UtilsS3 {
76
76
  }
77
77
  }
78
78
  async get_stream(s3_id) {
79
- const s3_input = get_s3_input(s3_id);
79
+ const s3_input = this.get_s3_input(s3_id);
80
80
  if (s3_input === undefined) {
81
81
  return undefined;
82
82
  }
@@ -100,7 +100,7 @@ export class UtilsS3 {
100
100
  }
101
101
  async query_prefix(s3_id_prefix, options = {}) {
102
102
  const compile = options.compile !== undefined ? options.compile : false;
103
- const s3_input = get_s3_input(s3_id_prefix);
103
+ const s3_input = this.get_s3_input(s3_id_prefix);
104
104
  if (s3_input === undefined) {
105
105
  return [];
106
106
  }
@@ -140,7 +140,7 @@ export class UtilsS3 {
140
140
  if (headers !== undefined) {
141
141
  return undefined;
142
142
  }
143
- const s3_input = get_s3_input(s3_id);
143
+ const s3_input = this.get_s3_input(s3_id);
144
144
  if (s3_input === undefined) {
145
145
  return undefined;
146
146
  }
@@ -152,7 +152,7 @@ export class UtilsS3 {
152
152
  }
153
153
  async upload(s3_id, content, options = {}) {
154
154
  const content_type_id = options.content_type_id !== undefined ? options.content_type_id : undefined;
155
- const s3_input = get_s3_input(s3_id);
155
+ const s3_input = this.get_s3_input(s3_id);
156
156
  if (s3_input === undefined) {
157
157
  return undefined;
158
158
  }
@@ -167,7 +167,7 @@ export class UtilsS3 {
167
167
  await upload.done();
168
168
  }
169
169
  async delete(s3_id) {
170
- const s3_input = get_s3_input(s3_id);
170
+ const s3_input = this.get_s3_input(s3_id);
171
171
  if (s3_input === undefined) {
172
172
  return undefined;
173
173
  }
@@ -178,7 +178,7 @@ export class UtilsS3 {
178
178
  if (headers === undefined) {
179
179
  return undefined;
180
180
  }
181
- const s3_input = get_s3_input(s3_id);
181
+ const s3_input = this.get_s3_input(s3_id);
182
182
  if (s3_input === undefined) {
183
183
  return undefined;
184
184
  }
@@ -188,7 +188,7 @@ export class UtilsS3 {
188
188
  }
189
189
  async get_upload_url(s3_id, options = {}) {
190
190
  const content_type_id = options.content_type_id !== undefined ? options.content_type_id : undefined;
191
- const s3_input = get_s3_input(s3_id);
191
+ const s3_input = this.get_s3_input(s3_id);
192
192
  if (s3_input === undefined) {
193
193
  return undefined;
194
194
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-utils",
3
- "version": "1.4.116",
3
+ "version": "1.4.117",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "directories": {
package/src/UtilsS3.ts CHANGED
@@ -8,14 +8,6 @@ interface S3Input {
8
8
  Key : string
9
9
  }
10
10
 
11
- export function get_s3_input(s3_id : string) : S3Input | undefined {
12
- const [bucket, path] = (s3_id.match(/^s3\:\/\/([^\/]+)\/([^$]+)$/) || []).slice(1, 3)
13
- if (bucket === undefined || path === undefined) {
14
- return undefined
15
- }
16
- return { Bucket : bucket, Key : path }
17
- }
18
-
19
11
  export class UtilsS3 {
20
12
 
21
13
  private readonly s3 : S3
@@ -28,8 +20,16 @@ export class UtilsS3 {
28
20
  return this.s3
29
21
  }
30
22
 
23
+ get_s3_input(s3_id : string) : S3Input | undefined {
24
+ const [bucket, path] = (s3_id.match(/^s3\:\/\/([^\/]+)\/([^$]+)$/) || []).slice(1, 3)
25
+ if (bucket === undefined || path === undefined) {
26
+ return undefined
27
+ }
28
+ return { Bucket : bucket, Key : path }
29
+ }
30
+
31
31
  async get_headers(s3_id : string) {
32
- const s3_input = get_s3_input(s3_id)
32
+ const s3_input = this.get_s3_input(s3_id)
33
33
  if (s3_input === undefined) {
34
34
  return undefined
35
35
  }
@@ -45,7 +45,7 @@ export class UtilsS3 {
45
45
  }
46
46
 
47
47
  async get(s3_id : string, encoding : string = "utf-8") : Promise<string | undefined> {
48
- const s3_input = get_s3_input(s3_id)
48
+ const s3_input = this.get_s3_input(s3_id)
49
49
  if (s3_input === undefined) {
50
50
  return undefined
51
51
  }
@@ -66,7 +66,7 @@ export class UtilsS3 {
66
66
  }
67
67
 
68
68
  async get_buffer(s3_id : string) : Promise<Buffer | undefined> {
69
- const s3_input = get_s3_input(s3_id)
69
+ const s3_input = this.get_s3_input(s3_id)
70
70
  if (s3_input === undefined) {
71
71
  return undefined
72
72
  }
@@ -87,7 +87,7 @@ export class UtilsS3 {
87
87
  }
88
88
 
89
89
  async get_stream(s3_id : string) : Promise<Readable | undefined> {
90
- const s3_input = get_s3_input(s3_id)
90
+ const s3_input = this.get_s3_input(s3_id)
91
91
  if (s3_input === undefined) {
92
92
  return undefined
93
93
  }
@@ -111,7 +111,7 @@ export class UtilsS3 {
111
111
 
112
112
  async query_prefix(s3_id_prefix : string, options : { compile? : boolean } = {}) {
113
113
  const compile = options.compile !== undefined ? options.compile : false
114
- const s3_input = get_s3_input(s3_id_prefix)
114
+ const s3_input = this.get_s3_input(s3_id_prefix)
115
115
  if (s3_input === undefined) {
116
116
  return []
117
117
  }
@@ -155,7 +155,7 @@ export class UtilsS3 {
155
155
  if (headers !== undefined) {
156
156
  return undefined
157
157
  }
158
- const s3_input = get_s3_input(s3_id)
158
+ const s3_input = this.get_s3_input(s3_id)
159
159
  if (s3_input === undefined) {
160
160
  return undefined
161
161
  }
@@ -170,7 +170,7 @@ export class UtilsS3 {
170
170
  content_type_id? : string
171
171
  } = {}) : Promise<void> {
172
172
  const content_type_id = options.content_type_id !== undefined ? options.content_type_id : undefined
173
- const s3_input = get_s3_input(s3_id)
173
+ const s3_input = this.get_s3_input(s3_id)
174
174
  if (s3_input === undefined) {
175
175
  return undefined
176
176
  }
@@ -186,7 +186,7 @@ export class UtilsS3 {
186
186
  }
187
187
 
188
188
  async delete(s3_id : string) : Promise<void>{
189
- const s3_input = get_s3_input(s3_id)
189
+ const s3_input = this.get_s3_input(s3_id)
190
190
  if (s3_input === undefined) {
191
191
  return undefined
192
192
  }
@@ -198,7 +198,7 @@ export class UtilsS3 {
198
198
  if (headers === undefined) {
199
199
  return undefined
200
200
  }
201
- const s3_input = get_s3_input(s3_id)
201
+ const s3_input = this.get_s3_input(s3_id)
202
202
  if (s3_input === undefined) {
203
203
  return undefined
204
204
  }
@@ -211,7 +211,7 @@ export class UtilsS3 {
211
211
  content_type_id? : string
212
212
  } = {}) : Promise<string | undefined> {
213
213
  const content_type_id = options.content_type_id !== undefined ? options.content_type_id : undefined
214
- const s3_input = get_s3_input(s3_id)
214
+ const s3_input = this.get_s3_input(s3_id)
215
215
  if (s3_input === undefined) {
216
216
  return undefined
217
217
  }