@adtrackify/at-service-common 1.1.7 → 1.1.8

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/.editorconfig CHANGED
@@ -1,12 +1,12 @@
1
- root = true
2
-
3
- [*]
4
- end_of_line = lf
5
- charset = utf-8
6
- trim_trailing_whitespace = true
7
- insert_final_newline = false
8
- indent_style = space
9
- indent_size = 2
10
-
11
- [*.{diff,md}]
12
- trim_trailing_whitespace = false
1
+ root = true
2
+
3
+ [*]
4
+ end_of_line = lf
5
+ charset = utf-8
6
+ trim_trailing_whitespace = true
7
+ insert_final_newline = false
8
+ indent_style = space
9
+ indent_size = 2
10
+
11
+ [*.{diff,md}]
12
+ trim_trailing_whitespace = false
@@ -1,10 +1,10 @@
1
- { "eslint.validate": [
2
- "javascript",
3
- "javascriptreact",
4
- "typescript",
5
- "typescriptreact"
6
- ],
7
- "editor.codeActionsOnSave": {
8
- "source.fixAll.eslint": true,
9
- },
1
+ { "eslint.validate": [
2
+ "javascript",
3
+ "javascriptreact",
4
+ "typescript",
5
+ "typescriptreact"
6
+ ],
7
+ "editor.codeActionsOnSave": {
8
+ "source.fixAll.eslint": true,
9
+ },
10
10
  }
@@ -1,20 +1,20 @@
1
- image: node:16.18.0
2
-
3
- pipelines:
4
- default:
5
- - step:
6
- caches:
7
- - node
8
- script:
9
- - printf "//`node -p \"require('url').parse(process.env.NPM_REGISTRY_URL || 'https://registry.npmjs.org').host\"`/:_authToken=${NPM_TOKEN}\nregistry=${NPM_REGISTRY_URL:-https://registry.npmjs.org}\n" >> ~/.npmrc
10
- - npm install
11
- - npm run build:dev
12
- branches:
13
- master:
14
- - step:
15
- deployment: prod
16
- caches:
17
- - node
18
- script:
19
- - printf "//`node -p \"require('url').parse(process.env.NPM_REGISTRY_URL || 'https://registry.npmjs.org').host\"`/:_authToken=${NPM_TOKEN}\nregistry=${NPM_REGISTRY_URL:-https://registry.npmjs.org}\n" >> ~/.npmrc
20
- - npm run push
1
+ image: node:16.18.0
2
+
3
+ pipelines:
4
+ default:
5
+ - step:
6
+ caches:
7
+ - node
8
+ script:
9
+ - printf "//`node -p \"require('url').parse(process.env.NPM_REGISTRY_URL || 'https://registry.npmjs.org').host\"`/:_authToken=${NPM_TOKEN}\nregistry=${NPM_REGISTRY_URL:-https://registry.npmjs.org}\n" >> ~/.npmrc
10
+ - npm install
11
+ - npm run build:dev
12
+ branches:
13
+ master:
14
+ - step:
15
+ deployment: prod
16
+ caches:
17
+ - node
18
+ script:
19
+ - printf "//`node -p \"require('url').parse(process.env.NPM_REGISTRY_URL || 'https://registry.npmjs.org').host\"`/:_authToken=${NPM_TOKEN}\nregistry=${NPM_REGISTRY_URL:-https://registry.npmjs.org}\n" >> ~/.npmrc
20
+ - npm run push
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', "@faker-js/faker"]
21
+ external: [...Object.keys(dependencies), '@aws-sdk/client-dynamodb', '@aws-sdk/client-eventbridge', "@faker-js/faker"]
22
22
  })
package/dist/index.d.ts CHANGED
@@ -1,36 +1,40 @@
1
+ declare module '@adtrackify/at-service-common/__tests__/helpers/subscription-helper.spec' {
2
+ export {};
3
+
4
+ }
1
5
  declare module '@adtrackify/at-service-common/clients/generic/dynamodb-client' {
2
- import AWS from 'aws-sdk';
6
+ import { GetItemCommandOutput, PutItemCommandOutput, DeleteItemCommandOutput, BatchGetItemCommandOutput, QueryCommandInput, QueryCommandOutput } from '@aws-sdk/client-dynamodb';
3
7
  export class DynamoDbClient {
4
- static safeGet: (tableName: string, keyName: string, keyValue: any) => Promise<AWS.DynamoDB.DocumentClient.AttributeMap | null>;
5
- static safePut: (tableName: string, data: any) => Promise<import("aws-sdk/lib/request").PromiseResult<AWS.DynamoDB.DocumentClient.PutItemOutput, AWS.AWSError> | null>;
6
- static safeDelete: (tableName: string, keyName: string, keyValue: any) => Promise<import("aws-sdk/lib/request").PromiseResult<AWS.DynamoDB.DocumentClient.DeleteItemOutput, AWS.AWSError> | null>;
8
+ static safeGet: (tableName: string, keyName: string, keyValue: any) => Promise<Record<string, import("@aws-sdk/client-dynamodb").AttributeValue> | null>;
9
+ static safePut: (tableName: string, data: any) => Promise<PutItemCommandOutput | null>;
10
+ static safeDelete: (tableName: string, keyName: string, keyValue: any) => Promise<DeleteItemCommandOutput | null>;
7
11
  static safeQueryByGSI: (tableName: string, gsiName: string, keyName: string, keyValue: any) => Promise<any[] | null>;
8
- static safeBatchGet: (tableName: string, keys: any) => Promise<AWS.DynamoDB.DocumentClient.ItemList>;
9
- static queryAll: (params: any) => Promise<any[] | null>;
10
- static batchGet: (params: any) => Promise<import("aws-sdk/lib/request").PromiseResult<AWS.DynamoDB.DocumentClient.BatchGetItemOutput, AWS.AWSError>>;
11
- static get: (params: any) => Promise<import("aws-sdk/lib/request").PromiseResult<AWS.DynamoDB.DocumentClient.GetItemOutput, AWS.AWSError>>;
12
- static put: (params: any) => Promise<import("aws-sdk/lib/request").PromiseResult<AWS.DynamoDB.DocumentClient.PutItemOutput, AWS.AWSError>>;
13
- static query: (params: any) => Promise<import("aws-sdk/lib/request").PromiseResult<AWS.DynamoDB.DocumentClient.QueryOutput, AWS.AWSError>>;
14
- static scan: (params: any) => Promise<import("aws-sdk/lib/request").PromiseResult<AWS.DynamoDB.DocumentClient.ScanOutput, AWS.AWSError>>;
15
- static update: (params: any) => Promise<import("aws-sdk/lib/request").PromiseResult<AWS.DynamoDB.DocumentClient.UpdateItemOutput, AWS.AWSError>>;
16
- static delete: (params: any) => Promise<import("aws-sdk/lib/request").PromiseResult<AWS.DynamoDB.DocumentClient.DeleteItemOutput, AWS.AWSError>>;
12
+ static safeBatchGet: (tableName: string, keys: any) => Promise<Record<string, import("@aws-sdk/client-dynamodb").AttributeValue>[]>;
13
+ static queryAll: (params: QueryCommandInput) => Promise<any[] | null>;
14
+ static batchGet: (params: any) => Promise<BatchGetItemCommandOutput>;
15
+ static get: (params: any) => Promise<GetItemCommandOutput>;
16
+ static put: (params: any) => Promise<PutItemCommandOutput>;
17
+ static query: (params: any) => Promise<QueryCommandOutput>;
18
+ static scan: (params: any) => Promise<import("@aws-sdk/client-dynamodb").ScanCommandOutput>;
19
+ static update: (params: any) => Promise<import("@aws-sdk/client-dynamodb").UpdateItemCommandOutput>;
20
+ static delete: (params: any) => Promise<DeleteItemCommandOutput>;
17
21
  }
18
22
 
19
23
  }
20
24
  declare module '@adtrackify/at-service-common/clients/generic/eventbridge-client' {
21
- import { EventBridge } from 'aws-sdk';
25
+ import { EventBridgeClient as EventBridge } from '@aws-sdk/client-eventbridge';
22
26
  export class EventBridgeClient {
23
27
  eventBridge: EventBridge;
24
28
  EVENT_BUS_NAME: string;
25
29
  constructor(eventBusName: string);
26
- buildAndSendEvent: (eventSource: string, eventType: string, eventData: any) => Promise<import("aws-sdk/lib/request").PromiseResult<EventBridge.PutEventsResponse, import("aws-sdk").AWSError>>;
30
+ buildAndSendEvent: (eventSource: string, eventType: string, eventData: any) => Promise<import("@aws-sdk/client-eventbridge").PutEventsCommandOutput>;
27
31
  buildEvent: (eventType: string, eventData: any, eventId?: string, eventTime?: string) => {
28
32
  eventId: string;
29
33
  eventType: string;
30
34
  eventTime: string;
31
35
  eventData: any;
32
36
  };
33
- putEvent: (source: string, detailType: string, data: any, headers?: any) => Promise<import("aws-sdk/lib/request").PromiseResult<EventBridge.PutEventsResponse, import("aws-sdk").AWSError>>;
37
+ putEvent: (source: string, detailType: string, data: any, headers?: any) => Promise<import("@aws-sdk/client-eventbridge").PutEventsCommandOutput>;
34
38
  }
35
39
 
36
40
  }
@@ -657,8 +661,8 @@ declare module '@adtrackify/at-service-common/services/eventbridge-integration-s
657
661
  eventBridgeClient: EventBridgeClient;
658
662
  EVENT_BUS_NAME: string;
659
663
  constructor(eventBusName: string);
660
- sendPostmarkEmailEvent: (eventSource: string, postmarkMessage: Message, postmarkServerToken: string) => Promise<import("aws-sdk/lib/request").PromiseResult<import("aws-sdk/clients/eventbridge").PutEventsResponse, import("aws-sdk").AWSError>>;
661
- sendPostmarkTemplatedEmailEvent: (eventSource: string, postmarkMessage: TemplatedMessage, postmarkServerToken: string) => Promise<import("aws-sdk/lib/request").PromiseResult<import("aws-sdk/clients/eventbridge").PutEventsResponse, import("aws-sdk").AWSError>>;
664
+ sendPostmarkEmailEvent: (eventSource: string, postmarkMessage: Message, postmarkServerToken: string) => Promise<import("@aws-sdk/client-eventbridge").PutEventsCommandOutput>;
665
+ sendPostmarkTemplatedEmailEvent: (eventSource: string, postmarkMessage: TemplatedMessage, postmarkServerToken: string) => Promise<import("@aws-sdk/client-eventbridge").PutEventsCommandOutput>;
662
666
  }
663
667
 
664
668
  }
@@ -694,10 +698,6 @@ declare module '@adtrackify/at-service-common/types/internal-events/event-detail
694
698
  declare module '@adtrackify/at-service-common/types/internal-events/index' {
695
699
  export * from '@adtrackify/at-service-common/types/internal-events/event-detail-types';
696
700
 
697
- }
698
- declare module '@adtrackify/at-service-common/__tests__/helpers/subscription-helper.spec' {
699
- export {};
700
-
701
701
  }
702
702
  declare module '@adtrackify/at-service-common' {
703
703
  import main = require('@adtrackify/at-service-common/src/index');
package/dist/index.js CHANGED
@@ -6,9 +6,9 @@ var __publicField = (obj, key, value) => {
6
6
  };
7
7
 
8
8
  // src/clients/generic/dynamodb-client.ts
9
- import AWS from "aws-sdk";
9
+ import { DynamoDBClient, GetItemCommand, PutItemCommand, DeleteItemCommand, BatchGetItemCommand, QueryCommand, ScanCommand, UpdateItemCommand } from "@aws-sdk/client-dynamodb";
10
10
  import * as log from "lambda-log";
11
- var client = new AWS.DynamoDB.DocumentClient();
11
+ var client = new DynamoDBClient({});
12
12
  var _DynamoDbClient = class {
13
13
  };
14
14
  var DynamoDbClient = _DynamoDbClient;
@@ -20,7 +20,8 @@ __publicField(DynamoDbClient, "safeGet", async (tableName, keyName, keyValue) =>
20
20
  [keyName]: keyValue
21
21
  }
22
22
  };
23
- const res = await client.get(params).promise();
23
+ const getItemCommand = new GetItemCommand(params);
24
+ const res = await client.send(getItemCommand);
24
25
  return res?.Item ?? null;
25
26
  } catch (e) {
26
27
  log.error(e, { message: "Dynamo Client Get Failed" });
@@ -33,7 +34,8 @@ __publicField(DynamoDbClient, "safePut", async (tableName, data) => {
33
34
  TableName: tableName,
34
35
  Item: data
35
36
  };
36
- const res = await client.put(params).promise();
37
+ const putItemCommand = new PutItemCommand(params);
38
+ const res = await client.send(putItemCommand);
37
39
  return res;
38
40
  } catch (e) {
39
41
  log.error(e, { message: "Dynamo failed simplePut" });
@@ -48,7 +50,8 @@ __publicField(DynamoDbClient, "safeDelete", async (tableName, keyName, keyValue)
48
50
  [keyName]: keyValue
49
51
  }
50
52
  };
51
- const res = await client.delete(params).promise();
53
+ const deleteItemCommand = new DeleteItemCommand(params);
54
+ const res = await client.send(deleteItemCommand);
52
55
  return res;
53
56
  } catch (e) {
54
57
  log.error(e, { message: "Dynamo failed safeDelete" });
@@ -70,12 +73,14 @@ __publicField(DynamoDbClient, "safeQueryByGSI", async (tableName, gsiName, keyNa
70
73
  __publicField(DynamoDbClient, "safeBatchGet", async (tableName, keys) => {
71
74
  try {
72
75
  const params = {
73
- RequestItems: {}
74
- };
75
- params.RequestItems[tableName] = {
76
- Keys: keys
76
+ RequestItems: {
77
+ [tableName]: {
78
+ Keys: keys
79
+ }
80
+ }
77
81
  };
78
- const res = await client.batchGet(params).promise();
82
+ const batchGetItemCommand = new BatchGetItemCommand(params);
83
+ const res = await client.send(batchGetItemCommand);
79
84
  log.info("batchget res", { batchGetRes: res });
80
85
  if (res?.Responses?.[tableName]) {
81
86
  return res?.Responses?.[tableName];
@@ -94,7 +99,8 @@ __publicField(DynamoDbClient, "queryAll", async (params) => {
94
99
  do {
95
100
  params.ExclusiveStartKey = exclusiveStartKey;
96
101
  params.Limit = 200;
97
- currentResult = await client.query(params).promise();
102
+ const queryCommand = new QueryCommand(params);
103
+ currentResult = await client.send(queryCommand);
98
104
  if (currentResult.Items) {
99
105
  exclusiveStartKey = currentResult.LastEvaluatedKey;
100
106
  accumulatedResults = [...accumulatedResults, ...currentResult.Items];
@@ -106,16 +112,16 @@ __publicField(DynamoDbClient, "queryAll", async (params) => {
106
112
  return null;
107
113
  }
108
114
  });
109
- __publicField(DynamoDbClient, "batchGet", (params) => client.batchGet(params).promise());
110
- __publicField(DynamoDbClient, "get", (params) => client.get(params).promise());
111
- __publicField(DynamoDbClient, "put", (params) => client.put(params).promise());
112
- __publicField(DynamoDbClient, "query", (params) => client.query(params).promise());
113
- __publicField(DynamoDbClient, "scan", (params) => client.scan(params).promise());
114
- __publicField(DynamoDbClient, "update", (params) => client.update(params).promise());
115
- __publicField(DynamoDbClient, "delete", (params) => client.delete(params).promise());
115
+ __publicField(DynamoDbClient, "batchGet", (params) => client.send(new BatchGetItemCommand(params)));
116
+ __publicField(DynamoDbClient, "get", (params) => client.send(new GetItemCommand(params)));
117
+ __publicField(DynamoDbClient, "put", (params) => client.send(new PutItemCommand(params)));
118
+ __publicField(DynamoDbClient, "query", (params) => client.send(new QueryCommand(params)));
119
+ __publicField(DynamoDbClient, "scan", (params) => client.send(new ScanCommand(params)));
120
+ __publicField(DynamoDbClient, "update", (params) => client.send(new UpdateItemCommand(params)));
121
+ __publicField(DynamoDbClient, "delete", (params) => client.send(new DeleteItemCommand(params)));
116
122
 
117
123
  // src/clients/generic/eventbridge-client.ts
118
- import { EventBridge } from "aws-sdk";
124
+ import { EventBridgeClient as EventBridge, PutEventsCommand } from "@aws-sdk/client-eventbridge";
119
125
  import { v4 as uuidv4 } from "uuid";
120
126
 
121
127
  // src/libs/dates.ts
@@ -136,7 +142,7 @@ var EventBridgeClient = class {
136
142
  eventBridge;
137
143
  EVENT_BUS_NAME;
138
144
  constructor(eventBusName) {
139
- this.eventBridge = new EventBridge();
145
+ this.eventBridge = new EventBridge({});
140
146
  this.EVENT_BUS_NAME = eventBusName;
141
147
  }
142
148
  buildAndSendEvent = async (eventSource, eventType, eventData) => {
@@ -161,7 +167,8 @@ var EventBridgeClient = class {
161
167
  Time: new Date()
162
168
  }]
163
169
  };
164
- const response = await this.eventBridge.putEvents(params).promise();
170
+ const putEventscommand = new PutEventsCommand(params);
171
+ const response = await this.eventBridge.send(putEventscommand);
165
172
  log2.debug(
166
173
  "EventBus Event Published",
167
174
  {