@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 +12 -12
- package/.vscode/settings.json +9 -9
- package/bitbucket-pipelines.yml +20 -20
- package/build.js +1 -1
- package/dist/index.d.ts +22 -22
- package/dist/index.js +28 -21
- package/dist/index.js.map +2 -2
- package/jest.config.ts +40 -40
- package/package.json +4 -3
- package/src/__tests__/helpers/subscription-helper.spec.ts +40 -40
- package/src/clients/generic/axios.d.ts +7 -7
- package/src/clients/generic/dynamodb-client.ts +118 -113
- package/src/clients/generic/eventbridge-client.ts +53 -52
- package/src/clients/internal-api/destinations-client.ts +58 -58
- package/src/clients/internal-api/index.ts +4 -4
- package/src/clients/internal-api/shopify-app-install-client.ts +66 -66
- package/src/clients/third-party/shopify-client.ts +139 -139
- package/src/helpers/index.ts +5 -5
- package/src/helpers/input-validation-helper.ts +21 -21
- package/src/helpers/shopify-helper.ts +39 -39
- package/src/index.ts +4 -4
- package/src/libs/index.ts +7 -7
- package/src/libs/url.ts +9 -9
- package/src/services/eventbridge-integration-service.ts +44 -44
- package/src/types/internal-events/event-detail-types.ts +9 -9
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
|
package/.vscode/settings.json
CHANGED
|
@@ -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
|
}
|
package/bitbucket-pipelines.yml
CHANGED
|
@@ -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
|
|
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<
|
|
5
|
-
static safePut: (tableName: string, data: any) => Promise<
|
|
6
|
-
static safeDelete: (tableName: string, keyName: string, keyValue: any) => Promise<
|
|
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<
|
|
9
|
-
static queryAll: (params:
|
|
10
|
-
static batchGet: (params: any) => Promise<
|
|
11
|
-
static get: (params: any) => Promise<
|
|
12
|
-
static put: (params: any) => Promise<
|
|
13
|
-
static query: (params: any) => Promise<
|
|
14
|
-
static scan: (params: any) => Promise<import("aws-sdk/
|
|
15
|
-
static update: (params: any) => Promise<import("aws-sdk/
|
|
16
|
-
static delete: (params: any) => Promise<
|
|
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/
|
|
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/
|
|
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/
|
|
661
|
-
sendPostmarkTemplatedEmailEvent: (eventSource: string, postmarkMessage: TemplatedMessage, postmarkServerToken: string) => Promise<import("aws-sdk/
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
76
|
-
|
|
76
|
+
RequestItems: {
|
|
77
|
+
[tableName]: {
|
|
78
|
+
Keys: keys
|
|
79
|
+
}
|
|
80
|
+
}
|
|
77
81
|
};
|
|
78
|
-
const
|
|
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
|
-
|
|
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.
|
|
110
|
-
__publicField(DynamoDbClient, "get", (params) => client.
|
|
111
|
-
__publicField(DynamoDbClient, "put", (params) => client.
|
|
112
|
-
__publicField(DynamoDbClient, "query", (params) => client.
|
|
113
|
-
__publicField(DynamoDbClient, "scan", (params) => client.
|
|
114
|
-
__publicField(DynamoDbClient, "update", (params) => client.
|
|
115
|
-
__publicField(DynamoDbClient, "delete", (params) => client.
|
|
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
|
|
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
|
{
|