@adtrackify/at-service-common 1.0.81 → 1.0.82
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 +21 -21
- package/dist/index.d.ts +5 -4
- package/dist/index.js +49 -68
- package/dist/index.js.map +2 -2
- package/jest.config.ts +40 -40
- package/package.json +1 -1
- 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 +113 -113
- package/src/clients/generic/eventbridge-client.ts +52 -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/internal-api/users-auth-client.ts +111 -111
- 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/helpers/subscription-helper.ts +55 -72
- 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/tsconfig.json +35 -35
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import Joi from 'joi';
|
|
2
|
-
import * as log from 'lambda-log';
|
|
3
|
-
import { HttpError } from '../libs/http-error';
|
|
4
|
-
|
|
5
|
-
export const validateInput = (schema: Joi.ObjectSchema<any>, input: any) => {
|
|
6
|
-
const { error, value } = schema.validate(input);
|
|
7
|
-
if (error) {
|
|
8
|
-
log.info('', { error });
|
|
9
|
-
|
|
10
|
-
const httperr = HttpError.badRequest('Bad Request', {
|
|
11
|
-
errors: error.details.map(detail => ({
|
|
12
|
-
message: detail?.message,
|
|
13
|
-
key: detail?.context?.key,
|
|
14
|
-
path: detail?.path,
|
|
15
|
-
}))
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
log.info('', { httperr });
|
|
19
|
-
throw httperr;
|
|
20
|
-
}
|
|
21
|
-
return value;
|
|
1
|
+
import Joi from 'joi';
|
|
2
|
+
import * as log from 'lambda-log';
|
|
3
|
+
import { HttpError } from '../libs/http-error';
|
|
4
|
+
|
|
5
|
+
export const validateInput = (schema: Joi.ObjectSchema<any>, input: any) => {
|
|
6
|
+
const { error, value } = schema.validate(input);
|
|
7
|
+
if (error) {
|
|
8
|
+
log.info('', { error });
|
|
9
|
+
|
|
10
|
+
const httperr = HttpError.badRequest('Bad Request', {
|
|
11
|
+
errors: error.details.map(detail => ({
|
|
12
|
+
message: detail?.message,
|
|
13
|
+
key: detail?.context?.key,
|
|
14
|
+
path: detail?.path,
|
|
15
|
+
}))
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
log.info('', { httperr });
|
|
19
|
+
throw httperr;
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
22
|
};
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { createHmac } from 'crypto';
|
|
2
|
-
import * as log from 'lambda-log';
|
|
3
|
-
import { HttpError } from '../libs';
|
|
4
|
-
import { mapObjectToQueryString } from '../libs/url';
|
|
5
|
-
export interface ShopifyRequestValidationParameters {
|
|
6
|
-
code: string,
|
|
7
|
-
hmac?: string,
|
|
8
|
-
shop: string,
|
|
9
|
-
state: string,
|
|
10
|
-
timestamp: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const isShopifyRequestValid = (validationParams: ShopifyRequestValidationParameters, validationHmac: string, shopifyAppApiSecret: string): boolean => {
|
|
14
|
-
// remove hmac if it exists
|
|
15
|
-
// map input to query string
|
|
16
|
-
// generate hash using api secret key and validate it matches hmac
|
|
17
|
-
delete validationParams.hmac;
|
|
18
|
-
const hmacString = mapObjectToQueryString(validationParams);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const generatedHash = createHmac('sha256', shopifyAppApiSecret)
|
|
22
|
-
.update(hmacString)
|
|
23
|
-
.digest('hex');
|
|
24
|
-
|
|
25
|
-
return generatedHash === validationHmac;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const validateShopifyRequest = (validationParams: ShopifyRequestValidationParameters, validationHmac: string, shopifyAppApiSecret: string) => {
|
|
29
|
-
log.info('Validating shopify request is authentic', { validationParams });
|
|
30
|
-
const isValid = isShopifyRequestValid(validationParams, validationHmac as string, shopifyAppApiSecret);
|
|
31
|
-
if (!isValid) {
|
|
32
|
-
const message = 'Failed: Shopify Request hmac validation';
|
|
33
|
-
log.error(message);
|
|
34
|
-
throw HttpError.badRequest(message);
|
|
35
|
-
}
|
|
36
|
-
log.info('Sucess: Shopify Request hmac validation');
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
|
|
1
|
+
import { createHmac } from 'crypto';
|
|
2
|
+
import * as log from 'lambda-log';
|
|
3
|
+
import { HttpError } from '../libs';
|
|
4
|
+
import { mapObjectToQueryString } from '../libs/url';
|
|
5
|
+
export interface ShopifyRequestValidationParameters {
|
|
6
|
+
code: string,
|
|
7
|
+
hmac?: string,
|
|
8
|
+
shop: string,
|
|
9
|
+
state: string,
|
|
10
|
+
timestamp: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const isShopifyRequestValid = (validationParams: ShopifyRequestValidationParameters, validationHmac: string, shopifyAppApiSecret: string): boolean => {
|
|
14
|
+
// remove hmac if it exists
|
|
15
|
+
// map input to query string
|
|
16
|
+
// generate hash using api secret key and validate it matches hmac
|
|
17
|
+
delete validationParams.hmac;
|
|
18
|
+
const hmacString = mapObjectToQueryString(validationParams);
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
const generatedHash = createHmac('sha256', shopifyAppApiSecret)
|
|
22
|
+
.update(hmacString)
|
|
23
|
+
.digest('hex');
|
|
24
|
+
|
|
25
|
+
return generatedHash === validationHmac;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const validateShopifyRequest = (validationParams: ShopifyRequestValidationParameters, validationHmac: string, shopifyAppApiSecret: string) => {
|
|
29
|
+
log.info('Validating shopify request is authentic', { validationParams });
|
|
30
|
+
const isValid = isShopifyRequestValid(validationParams, validationHmac as string, shopifyAppApiSecret);
|
|
31
|
+
if (!isValid) {
|
|
32
|
+
const message = 'Failed: Shopify Request hmac validation';
|
|
33
|
+
log.error(message);
|
|
34
|
+
throw HttpError.badRequest(message);
|
|
35
|
+
}
|
|
36
|
+
log.info('Sucess: Shopify Request hmac validation');
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
|
|
@@ -29,6 +29,19 @@ export const StripeBillingMap: any = {
|
|
|
29
29
|
'growth_yearly': 'price_1KAFs7K7krGh4037rZElg12s'
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
|
+
|
|
33
|
+
export const CommonPlanInfo = [
|
|
34
|
+
//'60-day Risk Free Trial',
|
|
35
|
+
'Fixes IOS14.5 ad-tracking',
|
|
36
|
+
'Increase ROAS & Attribution Data',
|
|
37
|
+
'Enhanced Fingerprinting & Identity Resolution',
|
|
38
|
+
'Unlimited Pixel Integrations',
|
|
39
|
+
'Server Side Tracking & Conversion API',
|
|
40
|
+
'Unlimited Facebook Conversion API',
|
|
41
|
+
'MultiPixel Support (Multiple facebook, tiktok, etc)',
|
|
42
|
+
'Advanced Integrations (Webhooks, Custom JS/HTML, Hubspot)'
|
|
43
|
+
];
|
|
44
|
+
|
|
32
45
|
export const SubscriptionPlanSeedItems: {
|
|
33
46
|
items: SubscriptionPlan[];
|
|
34
47
|
} = {
|
|
@@ -41,16 +54,11 @@ export const SubscriptionPlanSeedItems: {
|
|
|
41
54
|
price: '0',
|
|
42
55
|
displayPrice: '$0',
|
|
43
56
|
billingFrequency: PLAN_BILLING_FREQUENCY.MONTHLY,
|
|
44
|
-
trialLengthDays:
|
|
57
|
+
trialLengthDays: 0,
|
|
45
58
|
trialRequiresCreditCard: false,
|
|
46
59
|
planDesc: [
|
|
47
|
-
|
|
48
|
-
'
|
|
49
|
-
'Enhanced Tracking / Attribution',
|
|
50
|
-
'Unlimited Facebook Conversion API',
|
|
51
|
-
'Unlimited Integrations',
|
|
52
|
-
'Easy no code setup',
|
|
53
|
-
'1,000 tracking events/mo'
|
|
60
|
+
...CommonPlanInfo,
|
|
61
|
+
'2,500 tracking events/mo'
|
|
54
62
|
],
|
|
55
63
|
unitPriceText: 'try now - free forever',
|
|
56
64
|
isHighlighted: false,
|
|
@@ -63,20 +71,15 @@ export const SubscriptionPlanSeedItems: {
|
|
|
63
71
|
displayName: 'Starter',
|
|
64
72
|
sku: 'ADT-002',
|
|
65
73
|
description: 'Starter Plan - Monthly',
|
|
66
|
-
price: '
|
|
67
|
-
displayPrice: '$
|
|
74
|
+
price: '49.99',
|
|
75
|
+
displayPrice: '$49.99',
|
|
68
76
|
billingFrequency: PLAN_BILLING_FREQUENCY.MONTHLY,
|
|
69
|
-
trialLengthDays:
|
|
77
|
+
trialLengthDays: 60,
|
|
70
78
|
trialRequiresCreditCard: false,
|
|
71
79
|
planDesc: [
|
|
72
|
-
'
|
|
73
|
-
|
|
74
|
-
'
|
|
75
|
-
'Enhanced Tracking / Attribution',
|
|
76
|
-
'Unlimited Facebook Conversion API',
|
|
77
|
-
'Unlimited Integrations',
|
|
78
|
-
'Easy no code setup',
|
|
79
|
-
'2,500 tracking events/mo'
|
|
80
|
+
'60-day Risk Free Trial',
|
|
81
|
+
...CommonPlanInfo,
|
|
82
|
+
'50,000 tracking events/mo'
|
|
80
83
|
],
|
|
81
84
|
unitPriceText: '',
|
|
82
85
|
isHighlighted: false,
|
|
@@ -87,22 +90,17 @@ export const SubscriptionPlanSeedItems: {
|
|
|
87
90
|
displayName: 'Starter',
|
|
88
91
|
sku: 'ADT-003',
|
|
89
92
|
description: 'Starter Plan - Yearly',
|
|
90
|
-
price: '
|
|
91
|
-
displayPrice: '$
|
|
93
|
+
price: '479.90',
|
|
94
|
+
displayPrice: '$39.99',
|
|
92
95
|
billingFrequency: PLAN_BILLING_FREQUENCY.YEARLY,
|
|
93
96
|
trialLengthDays: 30,
|
|
94
97
|
trialRequiresCreditCard: false,
|
|
95
98
|
planDesc: [
|
|
96
|
-
'
|
|
97
|
-
|
|
98
|
-
'
|
|
99
|
-
'Enhanced Tracking / Attribution',
|
|
100
|
-
'Unlimited Facebook Conversion API',
|
|
101
|
-
'Unlimited Integrations',
|
|
102
|
-
'Easy no code setup',
|
|
103
|
-
'2,500 tracking events/mo'
|
|
99
|
+
'60-day Risk Free Trial',
|
|
100
|
+
...CommonPlanInfo,
|
|
101
|
+
'50,000 tracking events/mo'
|
|
104
102
|
],
|
|
105
|
-
unitPriceText: 'billed yearly ($
|
|
103
|
+
unitPriceText: 'billed yearly ($479.90) - 20% savings',
|
|
106
104
|
isHighlighted: false,
|
|
107
105
|
isBanner: false
|
|
108
106
|
},
|
|
@@ -113,20 +111,15 @@ export const SubscriptionPlanSeedItems: {
|
|
|
113
111
|
displayName: 'Scale',
|
|
114
112
|
sku: 'ADT-004',
|
|
115
113
|
description: 'Scale Plan - Monthly',
|
|
116
|
-
price: '
|
|
117
|
-
displayPrice: '$
|
|
114
|
+
price: '99.99',
|
|
115
|
+
displayPrice: '$99.99',
|
|
118
116
|
billingFrequency: PLAN_BILLING_FREQUENCY.MONTHLY,
|
|
119
|
-
trialLengthDays:
|
|
117
|
+
trialLengthDays: 60,
|
|
120
118
|
trialRequiresCreditCard: false,
|
|
121
119
|
planDesc: [
|
|
122
|
-
'
|
|
123
|
-
|
|
124
|
-
'
|
|
125
|
-
'Enhanced Tracking / Attribution',
|
|
126
|
-
'Unlimited Facebook Conversion API',
|
|
127
|
-
'Unlimited Integrations',
|
|
128
|
-
'Easy no code setup',
|
|
129
|
-
'25,000 tracking events/mo'
|
|
120
|
+
'60-day Risk Free Trial',
|
|
121
|
+
...CommonPlanInfo,
|
|
122
|
+
'100,000 tracking events/mo'
|
|
130
123
|
],
|
|
131
124
|
unitPriceText: 'billed yearly ($96) - 20% savings',
|
|
132
125
|
isHighlighted: true,
|
|
@@ -139,22 +132,17 @@ export const SubscriptionPlanSeedItems: {
|
|
|
139
132
|
displayName: 'Scale',
|
|
140
133
|
sku: 'ADT-005',
|
|
141
134
|
description: 'Scale Plan - Yearly',
|
|
142
|
-
price: '
|
|
143
|
-
displayPrice: '$
|
|
135
|
+
price: '911.99',
|
|
136
|
+
displayPrice: '$75.99',
|
|
144
137
|
billingFrequency: PLAN_BILLING_FREQUENCY.YEARLY,
|
|
145
|
-
trialLengthDays:
|
|
138
|
+
trialLengthDays: 60,
|
|
146
139
|
trialRequiresCreditCard: false,
|
|
147
140
|
planDesc: [
|
|
148
|
-
'
|
|
149
|
-
|
|
150
|
-
'
|
|
151
|
-
'Enhanced Tracking / Attribution',
|
|
152
|
-
'Unlimited Facebook Conversion API',
|
|
153
|
-
'Unlimited Integrations',
|
|
154
|
-
'Easy no code setup',
|
|
155
|
-
'25,000 tracking events/mo'
|
|
141
|
+
'60-day Risk Free Trial',
|
|
142
|
+
...CommonPlanInfo,
|
|
143
|
+
'100,000 tracking events/mo'
|
|
156
144
|
],
|
|
157
|
-
unitPriceText: 'billed yearly ($
|
|
145
|
+
unitPriceText: 'billed yearly ($911.99) - 24% savings',
|
|
158
146
|
isHighlighted: true,
|
|
159
147
|
isBanner: true,
|
|
160
148
|
bannerColor: 'blue',
|
|
@@ -167,20 +155,15 @@ export const SubscriptionPlanSeedItems: {
|
|
|
167
155
|
displayName: 'Growth',
|
|
168
156
|
sku: 'ADT-006',
|
|
169
157
|
description: 'Growth Plan - Monthly',
|
|
170
|
-
price: '
|
|
171
|
-
displayPrice: '$
|
|
158
|
+
price: '199.99',
|
|
159
|
+
displayPrice: '$199.99',
|
|
172
160
|
billingFrequency: PLAN_BILLING_FREQUENCY.MONTHLY,
|
|
173
|
-
trialLengthDays:
|
|
161
|
+
trialLengthDays: 60,
|
|
174
162
|
trialRequiresCreditCard: false,
|
|
175
163
|
planDesc: [
|
|
176
|
-
'
|
|
177
|
-
|
|
178
|
-
'
|
|
179
|
-
'Enhanced Tracking / Attribution',
|
|
180
|
-
'Unlimited Facebook Conversion API',
|
|
181
|
-
'Unlimited Integrations',
|
|
182
|
-
'Easy no code setup',
|
|
183
|
-
'100,000 tracking events/mo'
|
|
164
|
+
'60-day Risk Free Trial',
|
|
165
|
+
...CommonPlanInfo,
|
|
166
|
+
'250,000 tracking events/mo'
|
|
184
167
|
],
|
|
185
168
|
unitPriceText: 'billed yearly ($540) - 25% savings',
|
|
186
169
|
isHighlighted: false,
|
|
@@ -193,10 +176,10 @@ export const SubscriptionPlanSeedItems: {
|
|
|
193
176
|
displayName: 'Growth',
|
|
194
177
|
sku: 'ADT-007',
|
|
195
178
|
description: 'Growth Plan - Yearly',
|
|
196
|
-
price: '
|
|
197
|
-
displayPrice: '$
|
|
179
|
+
price: '1799.91',
|
|
180
|
+
displayPrice: '$149.99',
|
|
198
181
|
billingFrequency: PLAN_BILLING_FREQUENCY.YEARLY,
|
|
199
|
-
trialLengthDays:
|
|
182
|
+
trialLengthDays: 60,
|
|
200
183
|
trialRequiresCreditCard: false,
|
|
201
184
|
planDesc: [
|
|
202
185
|
'30-day Risk Free Trial',
|
|
@@ -208,7 +191,7 @@ export const SubscriptionPlanSeedItems: {
|
|
|
208
191
|
'Easy no code setup',
|
|
209
192
|
'100,000 tracking events/mo'
|
|
210
193
|
],
|
|
211
|
-
unitPriceText: 'billed yearly ($
|
|
194
|
+
unitPriceText: 'billed yearly ($1799.91) - 25% savings',
|
|
212
195
|
isHighlighted: false,
|
|
213
196
|
isBanner: true,
|
|
214
197
|
bannerColor: 'orange',
|
|
@@ -225,11 +208,11 @@ export const getPlanDetails = (planId: number, stage: string) => {
|
|
|
225
208
|
};
|
|
226
209
|
|
|
227
210
|
export const getPlanByStripePriceId = (stripePriceId: string, stage: string) => {
|
|
228
|
-
const stripePriceIds = StripeBillingMap[stage];
|
|
229
|
-
const planName = Object.keys(stripePriceIds).find(key => stripePriceIds[key] === stripePriceId);
|
|
211
|
+
const stripePriceIds = StripeBillingMap[ stage ];
|
|
212
|
+
const planName = Object.keys(stripePriceIds).find(key => stripePriceIds[ key ] === stripePriceId);
|
|
230
213
|
|
|
231
|
-
const plan = SubscriptionPlanSeedItems.items.filter(x => x.planName === planName)[0] as any;
|
|
214
|
+
const plan = SubscriptionPlanSeedItems.items.filter(x => x.planName === planName)[ 0 ] as any;
|
|
232
215
|
plan.stripePriceId = stripePriceId;
|
|
233
216
|
|
|
234
217
|
return plan as SubscriptionPlan;
|
|
235
|
-
}
|
|
218
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './clients';
|
|
2
|
-
export * from './helpers';
|
|
3
|
-
export * from './libs';
|
|
4
|
-
export * from './types';
|
|
1
|
+
export * from './clients';
|
|
2
|
+
export * from './helpers';
|
|
3
|
+
export * from './libs';
|
|
4
|
+
export * from './types';
|
|
5
5
|
export * from './services';
|
package/src/libs/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from '../helpers/shopify-helper';
|
|
2
|
-
export * from './crypto';
|
|
3
|
-
export * from './dates';
|
|
4
|
-
export * from './http-error';
|
|
5
|
-
export * from './http-status-codes';
|
|
6
|
-
export * from './url';
|
|
7
|
-
|
|
1
|
+
export * from '../helpers/shopify-helper';
|
|
2
|
+
export * from './crypto';
|
|
3
|
+
export * from './dates';
|
|
4
|
+
export * from './http-error';
|
|
5
|
+
export * from './http-status-codes';
|
|
6
|
+
export * from './url';
|
|
7
|
+
|
package/src/libs/url.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
// Record<string, string> is any object
|
|
2
|
-
export const mapObjectToQueryString = (inputObj: any): string => {
|
|
3
|
-
const qsp = Object.entries(inputObj).sort((a, b) => a[ 0 ] < b[ 0 ] ? -1 : 1);
|
|
4
|
-
const urlParams = new URLSearchParams();
|
|
5
|
-
qsp.map(p => {
|
|
6
|
-
urlParams.append(p[ 0 ], p[ 1 ] as string);
|
|
7
|
-
});
|
|
8
|
-
const qs = urlParams.toString();
|
|
9
|
-
return qs;
|
|
1
|
+
// Record<string, string> is any object
|
|
2
|
+
export const mapObjectToQueryString = (inputObj: any): string => {
|
|
3
|
+
const qsp = Object.entries(inputObj).sort((a, b) => a[ 0 ] < b[ 0 ] ? -1 : 1);
|
|
4
|
+
const urlParams = new URLSearchParams();
|
|
5
|
+
qsp.map(p => {
|
|
6
|
+
urlParams.append(p[ 0 ], p[ 1 ] as string);
|
|
7
|
+
});
|
|
8
|
+
const qs = urlParams.toString();
|
|
9
|
+
return qs;
|
|
10
10
|
};
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { EventBridgeClient } from '../clients';
|
|
2
|
-
import { Message, TemplatedMessage } from 'postmark';
|
|
3
|
-
|
|
4
|
-
export const enum PostmarkRequestType {
|
|
5
|
-
SINGLE_EMAIL = 'single_email',
|
|
6
|
-
TEMPLATE_EMAIL = 'template_email'
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export enum ADTRACKIFY_EVENT_BRIDGE_EVENTS {
|
|
10
|
-
SEND_POSTMARK_EMAIL = 'integration.sendPostmarkEmail',
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export class EventBridgeIntegrationService {
|
|
14
|
-
public eventBridgeClient: EventBridgeClient;
|
|
15
|
-
public EVENT_BUS_NAME: string;
|
|
16
|
-
|
|
17
|
-
constructor (eventBusName: string) {
|
|
18
|
-
this.eventBridgeClient = new EventBridgeClient(eventBusName);
|
|
19
|
-
this.EVENT_BUS_NAME = eventBusName;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public sendPostmarkEmailEvent = async (eventSource: string, postmarkMessage: Message, postmarkServerToken: string) => {
|
|
23
|
-
return await this.eventBridgeClient.buildAndSendEvent(
|
|
24
|
-
eventSource,
|
|
25
|
-
ADTRACKIFY_EVENT_BRIDGE_EVENTS.SEND_POSTMARK_EMAIL,
|
|
26
|
-
{
|
|
27
|
-
postmarkMessage,
|
|
28
|
-
postmarkRequestType: PostmarkRequestType.SINGLE_EMAIL,
|
|
29
|
-
postmarkServerToken
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
public sendPostmarkTemplatedEmailEvent = async (eventSource: string, postmarkMessage: TemplatedMessage, postmarkServerToken: string) => {
|
|
34
|
-
return await this.eventBridgeClient.buildAndSendEvent(
|
|
35
|
-
eventSource,
|
|
36
|
-
ADTRACKIFY_EVENT_BRIDGE_EVENTS.SEND_POSTMARK_EMAIL,
|
|
37
|
-
{
|
|
38
|
-
postmarkMessage,
|
|
39
|
-
postmarkRequestType: PostmarkRequestType.TEMPLATE_EMAIL,
|
|
40
|
-
postmarkServerToken
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
}
|
|
1
|
+
import { EventBridgeClient } from '../clients';
|
|
2
|
+
import { Message, TemplatedMessage } from 'postmark';
|
|
3
|
+
|
|
4
|
+
export const enum PostmarkRequestType {
|
|
5
|
+
SINGLE_EMAIL = 'single_email',
|
|
6
|
+
TEMPLATE_EMAIL = 'template_email'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export enum ADTRACKIFY_EVENT_BRIDGE_EVENTS {
|
|
10
|
+
SEND_POSTMARK_EMAIL = 'integration.sendPostmarkEmail',
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class EventBridgeIntegrationService {
|
|
14
|
+
public eventBridgeClient: EventBridgeClient;
|
|
15
|
+
public EVENT_BUS_NAME: string;
|
|
16
|
+
|
|
17
|
+
constructor (eventBusName: string) {
|
|
18
|
+
this.eventBridgeClient = new EventBridgeClient(eventBusName);
|
|
19
|
+
this.EVENT_BUS_NAME = eventBusName;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public sendPostmarkEmailEvent = async (eventSource: string, postmarkMessage: Message, postmarkServerToken: string) => {
|
|
23
|
+
return await this.eventBridgeClient.buildAndSendEvent(
|
|
24
|
+
eventSource,
|
|
25
|
+
ADTRACKIFY_EVENT_BRIDGE_EVENTS.SEND_POSTMARK_EMAIL,
|
|
26
|
+
{
|
|
27
|
+
postmarkMessage,
|
|
28
|
+
postmarkRequestType: PostmarkRequestType.SINGLE_EMAIL,
|
|
29
|
+
postmarkServerToken
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
public sendPostmarkTemplatedEmailEvent = async (eventSource: string, postmarkMessage: TemplatedMessage, postmarkServerToken: string) => {
|
|
34
|
+
return await this.eventBridgeClient.buildAndSendEvent(
|
|
35
|
+
eventSource,
|
|
36
|
+
ADTRACKIFY_EVENT_BRIDGE_EVENTS.SEND_POSTMARK_EMAIL,
|
|
37
|
+
{
|
|
38
|
+
postmarkMessage,
|
|
39
|
+
postmarkRequestType: PostmarkRequestType.TEMPLATE_EMAIL,
|
|
40
|
+
postmarkServerToken
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export enum ADTRACKIFY_EVENT_TYPES {
|
|
2
|
-
NOTIFY_SHOPIFY_SUBSCRIPTION_CREATED = 'shopifySubscriptionCreated',
|
|
3
|
-
NOTIFY_SUBSCRIPTION_SIGNUP_COMPLETED = 'subscription.signupCompleted',
|
|
4
|
-
REQUEST_SET_ACCOUNT_OWNER = 'setAccountOwner',
|
|
5
|
-
REQUEST_SET_ACCOUNT_SUBSCRIPTION_ID = 'setAccountSubscriptionId',
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export enum ADTRACKIFY_EVENT_SOURCES {
|
|
9
|
-
SUBSCRIPTIONS = 'subscriptions',
|
|
1
|
+
export enum ADTRACKIFY_EVENT_TYPES {
|
|
2
|
+
NOTIFY_SHOPIFY_SUBSCRIPTION_CREATED = 'shopifySubscriptionCreated',
|
|
3
|
+
NOTIFY_SUBSCRIPTION_SIGNUP_COMPLETED = 'subscription.signupCompleted',
|
|
4
|
+
REQUEST_SET_ACCOUNT_OWNER = 'setAccountOwner',
|
|
5
|
+
REQUEST_SET_ACCOUNT_SUBSCRIPTION_ID = 'setAccountSubscriptionId',
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export enum ADTRACKIFY_EVENT_SOURCES {
|
|
9
|
+
SUBSCRIPTIONS = 'subscriptions',
|
|
10
10
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
|
|
4
|
-
"module": "ES2022" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
|
|
5
|
-
|
|
6
|
-
"allowJs": false, /* Allow javascript files to be compiled. */
|
|
7
|
-
"checkJs": false /* Report errors in .js files. */,
|
|
8
|
-
"outDir": "dist", /* Redirect output to the directory. */
|
|
9
|
-
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
|
|
10
|
-
"strict": true, /* Enable all strict type-checking options. */
|
|
11
|
-
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
|
|
12
|
-
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
|
13
|
-
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
|
|
14
|
-
"useUnknownInCatchVariables": true,
|
|
15
|
-
"experimentalDecorators": true,
|
|
16
|
-
"sourceMap": true,
|
|
17
|
-
"declaration": true,
|
|
18
|
-
"moduleResolution": "node",
|
|
19
|
-
"resolveJsonModule": true,
|
|
20
|
-
"isolatedModules": true,
|
|
21
|
-
"removeComments": true,
|
|
22
|
-
"typeRoots": [
|
|
23
|
-
"./node_modules/@types"
|
|
24
|
-
],
|
|
25
|
-
"types": [
|
|
26
|
-
"node",
|
|
27
|
-
"jest"
|
|
28
|
-
]
|
|
29
|
-
},
|
|
30
|
-
"include": [
|
|
31
|
-
"./src"
|
|
32
|
-
],
|
|
33
|
-
"exclude": [
|
|
34
|
-
"node_modules"
|
|
35
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
|
|
4
|
+
"module": "ES2022" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
|
|
5
|
+
|
|
6
|
+
"allowJs": false, /* Allow javascript files to be compiled. */
|
|
7
|
+
"checkJs": false /* Report errors in .js files. */,
|
|
8
|
+
"outDir": "dist", /* Redirect output to the directory. */
|
|
9
|
+
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
|
|
10
|
+
"strict": true, /* Enable all strict type-checking options. */
|
|
11
|
+
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
|
|
12
|
+
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
|
13
|
+
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
|
|
14
|
+
"useUnknownInCatchVariables": true,
|
|
15
|
+
"experimentalDecorators": true,
|
|
16
|
+
"sourceMap": true,
|
|
17
|
+
"declaration": true,
|
|
18
|
+
"moduleResolution": "node",
|
|
19
|
+
"resolveJsonModule": true,
|
|
20
|
+
"isolatedModules": true,
|
|
21
|
+
"removeComments": true,
|
|
22
|
+
"typeRoots": [
|
|
23
|
+
"./node_modules/@types"
|
|
24
|
+
],
|
|
25
|
+
"types": [
|
|
26
|
+
"node",
|
|
27
|
+
"jest"
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
"include": [
|
|
31
|
+
"./src"
|
|
32
|
+
],
|
|
33
|
+
"exclude": [
|
|
34
|
+
"node_modules"
|
|
35
|
+
]
|
|
36
36
|
}
|