@adtrackify/at-service-common 1.1.13 → 1.1.16
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/dist/index.d.ts +7 -7
- package/dist/index.js +6 -10
- package/dist/index.js.map +2 -2
- package/jest.config.ts +40 -40
- package/package.json +2 -2
- 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 +2 -2
- package/src/clients/generic/s3-client.ts +5 -9
- 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
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @group unit
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/* eslint-disable */
|
|
7
|
-
|
|
8
|
-
jest.mock('lambda-log');
|
|
9
|
-
import * as Logger from 'lambda-log';
|
|
10
|
-
import { getPlanDetails } from '../../helpers';
|
|
11
|
-
|
|
12
|
-
describe('postmark service email test', () => {
|
|
13
|
-
jest.spyOn(Logger, 'warn').mockImplementation(() => {
|
|
14
|
-
return new Logger.LogMessage({ level: 'null', msg: 'null' }, {});
|
|
15
|
-
});
|
|
16
|
-
jest.spyOn(Logger, 'info').mockImplementation(() => {
|
|
17
|
-
return new Logger.LogMessage({ level: 'null', msg: 'null' }, {});
|
|
18
|
-
});
|
|
19
|
-
jest.spyOn(Logger, 'debug').mockImplementation(() => {
|
|
20
|
-
return new Logger.LogMessage({ level: 'null', msg: 'null' }, {});
|
|
21
|
-
});
|
|
22
|
-
jest.spyOn(Logger, 'error').mockImplementation(() => {
|
|
23
|
-
return new Logger.LogMessage({ level: 'null', msg: 'null' }, {});
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
beforeEach(async () => {
|
|
27
|
-
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
afterEach(() => {
|
|
31
|
-
jest.resetAllMocks();
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
it('should call send email message', async () => {
|
|
36
|
-
const plan = getPlanDetails(2, 'dev');
|
|
37
|
-
console.log(plan);
|
|
38
|
-
expect(plan).not.toEqual(null);
|
|
39
|
-
});
|
|
40
|
-
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @group unit
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* eslint-disable */
|
|
7
|
+
|
|
8
|
+
jest.mock('lambda-log');
|
|
9
|
+
import * as Logger from 'lambda-log';
|
|
10
|
+
import { getPlanDetails } from '../../helpers';
|
|
11
|
+
|
|
12
|
+
describe('postmark service email test', () => {
|
|
13
|
+
jest.spyOn(Logger, 'warn').mockImplementation(() => {
|
|
14
|
+
return new Logger.LogMessage({ level: 'null', msg: 'null' }, {});
|
|
15
|
+
});
|
|
16
|
+
jest.spyOn(Logger, 'info').mockImplementation(() => {
|
|
17
|
+
return new Logger.LogMessage({ level: 'null', msg: 'null' }, {});
|
|
18
|
+
});
|
|
19
|
+
jest.spyOn(Logger, 'debug').mockImplementation(() => {
|
|
20
|
+
return new Logger.LogMessage({ level: 'null', msg: 'null' }, {});
|
|
21
|
+
});
|
|
22
|
+
jest.spyOn(Logger, 'error').mockImplementation(() => {
|
|
23
|
+
return new Logger.LogMessage({ level: 'null', msg: 'null' }, {});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
beforeEach(async () => {
|
|
27
|
+
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
afterEach(() => {
|
|
31
|
+
jest.resetAllMocks();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
it('should call send email message', async () => {
|
|
36
|
+
const plan = getPlanDetails(2, 'dev');
|
|
37
|
+
console.log(plan);
|
|
38
|
+
expect(plan).not.toEqual(null);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
41
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
declare module 'axios/lib/adapters/http' {
|
|
2
|
-
import { AxiosAdapter } from 'axios';
|
|
3
|
-
|
|
4
|
-
const httpAdapter: AxiosAdapter;
|
|
5
|
-
namespace httpAdapter { }
|
|
6
|
-
|
|
7
|
-
export = httpAdapter;
|
|
1
|
+
declare module 'axios/lib/adapters/http' {
|
|
2
|
+
import { AxiosAdapter } from 'axios';
|
|
3
|
+
|
|
4
|
+
const httpAdapter: AxiosAdapter;
|
|
5
|
+
namespace httpAdapter { }
|
|
6
|
+
|
|
7
|
+
export = httpAdapter;
|
|
8
8
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { DynamoDBClient, QueryOutput } from '@aws-sdk/client-dynamodb';
|
|
2
|
-
import { DynamoDBDocument } from '@aws-sdk/lib-dynamodb';
|
|
2
|
+
import { DynamoDBDocument } from '@aws-sdk/lib-dynamodb';
|
|
3
3
|
import * as log from 'lambda-log';
|
|
4
4
|
|
|
5
5
|
const marshallOptions = {
|
|
6
6
|
convertEmptyValues: false,
|
|
7
7
|
removeUndefinedValues: false,
|
|
8
|
-
convertClassInstanceToMap:
|
|
8
|
+
convertClassInstanceToMap: true
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
const unmarshallOptions = {
|
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
import { S3 } from '@aws-sdk/client-s3';
|
|
1
|
+
import { ObjectCannedACL, S3 } from '@aws-sdk/client-s3';
|
|
2
2
|
import * as log from 'lambda-log';
|
|
3
3
|
|
|
4
4
|
export class S3Client {
|
|
5
5
|
s3: S3;
|
|
6
6
|
|
|
7
|
-
constructor(
|
|
8
|
-
this.s3 = new S3({
|
|
9
|
-
credentials: {
|
|
10
|
-
accessKeyId,
|
|
11
|
-
secretAccessKey
|
|
12
|
-
}
|
|
13
|
-
})
|
|
7
|
+
constructor (region = 'us-west-2') {
|
|
8
|
+
this.s3 = new S3({ region });
|
|
14
9
|
}
|
|
15
10
|
|
|
16
|
-
async uploadJson(path: string, bucket: string, jsonData: any){
|
|
11
|
+
async uploadJson(path: string, bucket: string, jsonData: any, ACL: ObjectCannedACL | string = ObjectCannedACL.private) {
|
|
17
12
|
try {
|
|
18
13
|
const res = await this.s3.putObject({
|
|
14
|
+
ACL,
|
|
19
15
|
Bucket: bucket,
|
|
20
16
|
ContentType: 'application/json; charset=utf-8',
|
|
21
17
|
Body: JSON.stringify(jsonData),
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import * as log from 'lambda-log';
|
|
2
|
-
//const log = require('lambda-log');
|
|
3
|
-
import { ApiResponse } from '../../types/api-response';
|
|
4
|
-
import { axiosHttpService } from '../generic/http-client';
|
|
5
|
-
import { Destination } from '@adtrackify/at-tracking-event-types';
|
|
6
|
-
//const BASE_API_URL = process.env.BASE_API_URL;
|
|
7
|
-
//const DESTINATIONS_API_KEY = process.env.DESTINATIONS_API_KEY;
|
|
8
|
-
|
|
9
|
-
export interface GetDestinationsResponseData {
|
|
10
|
-
destinations: Destination[];
|
|
11
|
-
[ key: string ]: any;
|
|
12
|
-
}
|
|
13
|
-
export interface CreateDestinationResponseData {
|
|
14
|
-
destination: Destination;
|
|
15
|
-
[ key: string ]: any;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export class DestinationsClient {
|
|
20
|
-
|
|
21
|
-
public BASE_API_URL: string;
|
|
22
|
-
public DESTINATIONS_API_KEY: string;
|
|
23
|
-
|
|
24
|
-
constructor (baseApiUrl: string, destinationsApiKey: string) {
|
|
25
|
-
this.BASE_API_URL = baseApiUrl;
|
|
26
|
-
this.DESTINATIONS_API_KEY = destinationsApiKey;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
getConfig = () => {
|
|
30
|
-
const SERVICE_API_ROOT_URL = `${this.BASE_API_URL}/destinations`;
|
|
31
|
-
return {
|
|
32
|
-
baseURL: SERVICE_API_ROOT_URL,
|
|
33
|
-
headers: {
|
|
34
|
-
common: {
|
|
35
|
-
'x-api-key': this.DESTINATIONS_API_KEY
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
getClient = async () => {
|
|
42
|
-
return axiosHttpService(this.getConfig());
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
createDestination = async (createDestinationRequest: any): Promise<ApiResponse<CreateDestinationResponseData>> => {
|
|
46
|
-
const client = await this.getClient();
|
|
47
|
-
const response = await client.post('/', createDestinationRequest);
|
|
48
|
-
log.info('createDestinationResponse', { response });
|
|
49
|
-
return response as ApiResponse<CreateDestinationResponseData>;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
getPixelDestinations = async (pixelId: string): Promise<ApiResponse<GetDestinationsResponseData>> => {
|
|
53
|
-
const client = await this.getClient();
|
|
54
|
-
const response = await client.get(`/?pixelId=${pixelId}`);
|
|
55
|
-
log.info('getPixelResponse', { response });
|
|
56
|
-
return response as ApiResponse<GetDestinationsResponseData>;
|
|
57
|
-
};
|
|
58
|
-
}
|
|
1
|
+
import * as log from 'lambda-log';
|
|
2
|
+
//const log = require('lambda-log');
|
|
3
|
+
import { ApiResponse } from '../../types/api-response';
|
|
4
|
+
import { axiosHttpService } from '../generic/http-client';
|
|
5
|
+
import { Destination } from '@adtrackify/at-tracking-event-types';
|
|
6
|
+
//const BASE_API_URL = process.env.BASE_API_URL;
|
|
7
|
+
//const DESTINATIONS_API_KEY = process.env.DESTINATIONS_API_KEY;
|
|
8
|
+
|
|
9
|
+
export interface GetDestinationsResponseData {
|
|
10
|
+
destinations: Destination[];
|
|
11
|
+
[ key: string ]: any;
|
|
12
|
+
}
|
|
13
|
+
export interface CreateDestinationResponseData {
|
|
14
|
+
destination: Destination;
|
|
15
|
+
[ key: string ]: any;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
export class DestinationsClient {
|
|
20
|
+
|
|
21
|
+
public BASE_API_URL: string;
|
|
22
|
+
public DESTINATIONS_API_KEY: string;
|
|
23
|
+
|
|
24
|
+
constructor (baseApiUrl: string, destinationsApiKey: string) {
|
|
25
|
+
this.BASE_API_URL = baseApiUrl;
|
|
26
|
+
this.DESTINATIONS_API_KEY = destinationsApiKey;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
getConfig = () => {
|
|
30
|
+
const SERVICE_API_ROOT_URL = `${this.BASE_API_URL}/destinations`;
|
|
31
|
+
return {
|
|
32
|
+
baseURL: SERVICE_API_ROOT_URL,
|
|
33
|
+
headers: {
|
|
34
|
+
common: {
|
|
35
|
+
'x-api-key': this.DESTINATIONS_API_KEY
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
getClient = async () => {
|
|
42
|
+
return axiosHttpService(this.getConfig());
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
createDestination = async (createDestinationRequest: any): Promise<ApiResponse<CreateDestinationResponseData>> => {
|
|
46
|
+
const client = await this.getClient();
|
|
47
|
+
const response = await client.post('/', createDestinationRequest);
|
|
48
|
+
log.info('createDestinationResponse', { response });
|
|
49
|
+
return response as ApiResponse<CreateDestinationResponseData>;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
getPixelDestinations = async (pixelId: string): Promise<ApiResponse<GetDestinationsResponseData>> => {
|
|
53
|
+
const client = await this.getClient();
|
|
54
|
+
const response = await client.get(`/?pixelId=${pixelId}`);
|
|
55
|
+
log.info('getPixelResponse', { response });
|
|
56
|
+
return response as ApiResponse<GetDestinationsResponseData>;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './destinations-client';
|
|
2
|
-
export * from './accounts-client';
|
|
3
|
-
export * from './users-auth-client';
|
|
4
|
-
export * from './shopify-app-install-client';
|
|
1
|
+
export * from './destinations-client';
|
|
2
|
+
export * from './accounts-client';
|
|
3
|
+
export * from './users-auth-client';
|
|
4
|
+
export * from './shopify-app-install-client';
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import log from 'lambda-log';
|
|
2
|
-
import { ApiResponse } from '../../types/api-response';
|
|
3
|
-
import { axiosHttpService } from '../generic/http-client';
|
|
4
|
-
import { ShopifyAppInstall, ShopifyAppSubscriptionStatus } from '@adtrackify/at-tracking-event-types';
|
|
5
|
-
//const BASE_API_URL = process.env.BASE_API_URL;
|
|
6
|
-
//const DESTINATIONS_API_KEY = process.env.DESTINATIONS_API_KEY;
|
|
7
|
-
|
|
8
|
-
export interface ShopifyAppInstallResponseData {
|
|
9
|
-
shopifyAppInstall: ShopifyAppInstall;
|
|
10
|
-
[ key: string ]: any;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface UpdateShopifyAppInstallRequest {
|
|
14
|
-
appSubscriptionStatus?: ShopifyAppSubscriptionStatus,
|
|
15
|
-
pixelId?: string,
|
|
16
|
-
shopifyAppInstallId: string;
|
|
17
|
-
isAppEnabled?: boolean;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export class ShopifyAppInstallClient {
|
|
21
|
-
|
|
22
|
-
public BASE_API_URL: string;
|
|
23
|
-
public SHOPIFY_APP_INSTALL_API_KEY: string;
|
|
24
|
-
|
|
25
|
-
constructor (baseApiUrl: string, shopifyAppInstallApiKey: string) {
|
|
26
|
-
this.BASE_API_URL = baseApiUrl;
|
|
27
|
-
this.SHOPIFY_APP_INSTALL_API_KEY = shopifyAppInstallApiKey;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
getConfig = () => {
|
|
31
|
-
const SERVICE_API_ROOT_URL = `${this.BASE_API_URL}/shopify-app-installs`;
|
|
32
|
-
return {
|
|
33
|
-
baseURL: SERVICE_API_ROOT_URL,
|
|
34
|
-
headers: {
|
|
35
|
-
common: {
|
|
36
|
-
'x-api-key': this.SHOPIFY_APP_INSTALL_API_KEY
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
getClient = async () => {
|
|
43
|
-
return axiosHttpService(this.getConfig());
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
updateShopifyAppInstall = async (shopifyAppInstallId: string, updateShopifyAppInstallRequest: UpdateShopifyAppInstallRequest): Promise<ApiResponse<ShopifyAppInstallResponseData>> => {
|
|
47
|
-
const client = await this.getClient();
|
|
48
|
-
const response = await client.put(`/${shopifyAppInstallId}`, updateShopifyAppInstallRequest);
|
|
49
|
-
log.info('updateShopifyAppInstall', { response });
|
|
50
|
-
return response as ApiResponse<ShopifyAppInstallResponseData>;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
getShopifyAppInstall = async (shopifyAppInstallId: string): Promise<ApiResponse<ShopifyAppInstallResponseData>> => {
|
|
54
|
-
const client = await this.getClient();
|
|
55
|
-
const response = await client.get(`/${shopifyAppInstallId}`);
|
|
56
|
-
log.info('getShopifyAppInstall', { response });
|
|
57
|
-
return response as ApiResponse<ShopifyAppInstallResponseData>;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
getShopifyAppInstallByShop = async (shop: string): Promise<ApiResponse<ShopifyAppInstallResponseData>> => {
|
|
61
|
-
const client = await this.getClient();
|
|
62
|
-
const response = await client.get(`/?shop=${shop}`);
|
|
63
|
-
log.info('getShopifyAppInstallByShop', { response });
|
|
64
|
-
return response as ApiResponse<ShopifyAppInstallResponseData>;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
1
|
+
import log from 'lambda-log';
|
|
2
|
+
import { ApiResponse } from '../../types/api-response';
|
|
3
|
+
import { axiosHttpService } from '../generic/http-client';
|
|
4
|
+
import { ShopifyAppInstall, ShopifyAppSubscriptionStatus } from '@adtrackify/at-tracking-event-types';
|
|
5
|
+
//const BASE_API_URL = process.env.BASE_API_URL;
|
|
6
|
+
//const DESTINATIONS_API_KEY = process.env.DESTINATIONS_API_KEY;
|
|
7
|
+
|
|
8
|
+
export interface ShopifyAppInstallResponseData {
|
|
9
|
+
shopifyAppInstall: ShopifyAppInstall;
|
|
10
|
+
[ key: string ]: any;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface UpdateShopifyAppInstallRequest {
|
|
14
|
+
appSubscriptionStatus?: ShopifyAppSubscriptionStatus,
|
|
15
|
+
pixelId?: string,
|
|
16
|
+
shopifyAppInstallId: string;
|
|
17
|
+
isAppEnabled?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class ShopifyAppInstallClient {
|
|
21
|
+
|
|
22
|
+
public BASE_API_URL: string;
|
|
23
|
+
public SHOPIFY_APP_INSTALL_API_KEY: string;
|
|
24
|
+
|
|
25
|
+
constructor (baseApiUrl: string, shopifyAppInstallApiKey: string) {
|
|
26
|
+
this.BASE_API_URL = baseApiUrl;
|
|
27
|
+
this.SHOPIFY_APP_INSTALL_API_KEY = shopifyAppInstallApiKey;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getConfig = () => {
|
|
31
|
+
const SERVICE_API_ROOT_URL = `${this.BASE_API_URL}/shopify-app-installs`;
|
|
32
|
+
return {
|
|
33
|
+
baseURL: SERVICE_API_ROOT_URL,
|
|
34
|
+
headers: {
|
|
35
|
+
common: {
|
|
36
|
+
'x-api-key': this.SHOPIFY_APP_INSTALL_API_KEY
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
getClient = async () => {
|
|
43
|
+
return axiosHttpService(this.getConfig());
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
updateShopifyAppInstall = async (shopifyAppInstallId: string, updateShopifyAppInstallRequest: UpdateShopifyAppInstallRequest): Promise<ApiResponse<ShopifyAppInstallResponseData>> => {
|
|
47
|
+
const client = await this.getClient();
|
|
48
|
+
const response = await client.put(`/${shopifyAppInstallId}`, updateShopifyAppInstallRequest);
|
|
49
|
+
log.info('updateShopifyAppInstall', { response });
|
|
50
|
+
return response as ApiResponse<ShopifyAppInstallResponseData>;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
getShopifyAppInstall = async (shopifyAppInstallId: string): Promise<ApiResponse<ShopifyAppInstallResponseData>> => {
|
|
54
|
+
const client = await this.getClient();
|
|
55
|
+
const response = await client.get(`/${shopifyAppInstallId}`);
|
|
56
|
+
log.info('getShopifyAppInstall', { response });
|
|
57
|
+
return response as ApiResponse<ShopifyAppInstallResponseData>;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
getShopifyAppInstallByShop = async (shop: string): Promise<ApiResponse<ShopifyAppInstallResponseData>> => {
|
|
61
|
+
const client = await this.getClient();
|
|
62
|
+
const response = await client.get(`/?shop=${shop}`);
|
|
63
|
+
log.info('getShopifyAppInstallByShop', { response });
|
|
64
|
+
return response as ApiResponse<ShopifyAppInstallResponseData>;
|
|
65
|
+
}
|
|
66
|
+
}
|