@adtrackify/at-service-common 1.1.10 → 1.1.11

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.
package/build.js CHANGED
@@ -18,5 +18,5 @@ build({
18
18
  format: 'esm',
19
19
  platform: 'node',
20
20
  sourcemap: 'linked',
21
- external: [...Object.keys(dependencies), '@aws-sdk/client-dynamodb', '@aws-sdk/client-eventbridge', '@aws-sdk/lib-dynamodb', "@faker-js/faker"]
21
+ external: [...Object.keys(dependencies), '@aws-sdk/client-dynamodb', '@aws-sdk/client-eventbridge', '@aws-sdk/lib-dynamodb', '@aws-sdk/client-s3', "@faker-js/faker"]
22
22
  })
package/dist/index.d.ts CHANGED
@@ -74,6 +74,15 @@ declare module '@adtrackify/at-service-common/clients/generic/index' {
74
74
  export * from '@adtrackify/at-service-common/clients/generic/eventbridge-client';
75
75
  export * from '@adtrackify/at-service-common/clients/generic/http-client';
76
76
 
77
+ }
78
+ declare module '@adtrackify/at-service-common/clients/generic/s3-client' {
79
+ import { S3 } from '@aws-sdk/client-s3';
80
+ export default class S3Client {
81
+ s3: S3;
82
+ constructor(accessKeyId: string, secretAccessKey: string);
83
+ uploadJson(path: string, bucket: string, jsonData: any): Promise<unknown>;
84
+ }
85
+
77
86
  }
78
87
  declare module '@adtrackify/at-service-common/clients/index' {
79
88
  export * from '@adtrackify/at-service-common/clients/generic/index';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adtrackify/at-service-common",
3
- "version": "1.1.10",
3
+ "version": "1.1.11",
4
4
  "description": "",
5
5
  "module": "./dist/index.js",
6
6
  "main": "./dist/index.js",
@@ -49,6 +49,7 @@
49
49
  "@adtrackify/at-tracking-event-types": "^1.1.2",
50
50
  "@aws-sdk/client-dynamodb": "^3.278.0",
51
51
  "@aws-sdk/client-eventbridge": "^3.278.0",
52
+ "@aws-sdk/client-s3": "^3.282.0",
52
53
  "@aws-sdk/lib-dynamodb": "^3.279.0",
53
54
  "@babel/cli": "^7.13.16",
54
55
  "@babel/core": "^7.19.1",
@@ -102,4 +103,4 @@
102
103
  "author": "",
103
104
  "license": "ISC",
104
105
  "homepage": "https://bitbucket.org/eacap/at-service-common#readme"
105
- }
106
+ }
@@ -0,0 +1,31 @@
1
+ import { S3 } from '@aws-sdk/client-s3';
2
+ import * as log from 'lambda-log';
3
+
4
+ export default class S3Client {
5
+ s3: S3;
6
+
7
+ constructor(accessKeyId: string, secretAccessKey: string){
8
+ this.s3 = new S3({
9
+ credentials: {
10
+ accessKeyId,
11
+ secretAccessKey
12
+ }
13
+ })
14
+ }
15
+
16
+ async uploadJson(path: string, bucket: string, jsonData: any){
17
+ try {
18
+ const res = await this.s3.putObject({
19
+ Bucket: bucket,
20
+ ContentType: 'application/json; charset=utf-8',
21
+ Body: JSON.stringify(jsonData),
22
+ Key: path
23
+ });
24
+
25
+ return res;
26
+ } catch (error) {
27
+ log.error('Error in s3 upload json', { error });
28
+ return error;
29
+ }
30
+ }
31
+ }