@adtrackify/at-service-common 1.1.18 → 1.1.20
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/.eslintignore +3 -0
- package/.vscode/settings.json +9 -9
- package/build.js +27 -10
- package/dist/index.d.ts +57 -54
- package/dist/index.esm.js +1335 -0
- package/dist/index.esm.js.map +7 -0
- package/dist/index.js +357 -234
- package/dist/index.js.map +4 -4
- package/jest.config.ts +40 -40
- package/package.json +27 -27
- package/src/__tests__/helpers/subscription-helper.spec.ts +1 -1
- package/src/clients/generic/axios.d.ts +7 -7
- package/src/clients/generic/cognito-client.ts +37 -36
- package/src/clients/generic/eventbridge-client.ts +1 -1
- package/src/clients/generic/http-client.ts +2 -3
- package/src/clients/generic/index.ts +5 -5
- package/src/clients/generic/s3-client.ts +5 -9
- package/src/clients/index.ts +3 -3
- package/src/clients/internal-api/accounts-client.ts +2 -2
- package/src/clients/internal-api/destinations-client.ts +2 -2
- package/src/clients/internal-api/index.ts +4 -4
- package/src/clients/internal-api/shopify-app-install-client.ts +4 -4
- package/src/clients/internal-api/users-auth-client.ts +4 -3
- package/src/clients/third-party/index.ts +1 -1
- package/src/clients/third-party/shopify-client.ts +1 -1
- package/src/helpers/index.ts +5 -5
- package/src/helpers/input-validation-helper.ts +1 -1
- package/src/helpers/shopify-helper.ts +2 -2
- package/src/index.ts +5 -5
- package/src/libs/index.ts +6 -6
- package/src/libs/url.ts +9 -9
- package/src/services/eventbridge-integration-service.ts +1 -1
- package/src/services/index.ts +1 -1
- package/src/types/index.ts +1 -1
- package/src/types/internal-events/event-detail-types.ts +9 -9
- package/src/types/internal-events/index.ts +1 -1
- package/tsconfig.json +2 -3
package/jest.config.ts
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
/*eslint-disable */
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
globals: {
|
|
5
|
-
'ts-jest': {
|
|
6
|
-
isolatedModules: true
|
|
7
|
-
},
|
|
8
|
-
'@swc/jest': {
|
|
9
|
-
isolatedModules: true
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
},
|
|
13
|
-
roots: [ '<rootDir>/src' ],
|
|
14
|
-
testRegex: '\\.spec\\.(js|ts)$',
|
|
15
|
-
transform: {
|
|
16
|
-
"^.+\\.(t|j)sx?$": [ "@swc/jest" ],
|
|
17
|
-
},
|
|
18
|
-
moduleFileExtensions: [ 'js', 'json', 'ts' ],
|
|
19
|
-
transformIgnorePatterns: [],
|
|
20
|
-
runner: 'groups',
|
|
21
|
-
verbose: false,
|
|
22
|
-
coverageThreshold: {
|
|
23
|
-
global: {
|
|
24
|
-
branches: 0,
|
|
25
|
-
functions: 0,
|
|
26
|
-
lines: 0,
|
|
27
|
-
statements: 0
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
coverageReporters: [ 'html', 'text', 'text-summary', 'cobertura' ],
|
|
31
|
-
reporters: [ 'default', 'jest-junit' ],
|
|
32
|
-
collectCoverageFrom: [
|
|
33
|
-
'src/**/*.ts',
|
|
34
|
-
'!src/**/*.spec.js',
|
|
35
|
-
'src/**/*.js',
|
|
36
|
-
'!src/**/*.spec.ts',
|
|
37
|
-
'!src/**/tests/**'
|
|
38
|
-
],
|
|
39
|
-
setupFilesAfterEnv: [],
|
|
40
|
-
};
|
|
1
|
+
/*eslint-disable */
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
globals: {
|
|
5
|
+
'ts-jest': {
|
|
6
|
+
isolatedModules: true
|
|
7
|
+
},
|
|
8
|
+
'@swc/jest': {
|
|
9
|
+
isolatedModules: true
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
},
|
|
13
|
+
roots: [ '<rootDir>/src' ],
|
|
14
|
+
testRegex: '\\.spec\\.(js|ts)$',
|
|
15
|
+
transform: {
|
|
16
|
+
"^.+\\.(t|j)sx?$": [ "@swc/jest" ],
|
|
17
|
+
},
|
|
18
|
+
moduleFileExtensions: [ 'js', 'json', 'ts' ],
|
|
19
|
+
transformIgnorePatterns: [],
|
|
20
|
+
runner: 'groups',
|
|
21
|
+
verbose: false,
|
|
22
|
+
coverageThreshold: {
|
|
23
|
+
global: {
|
|
24
|
+
branches: 0,
|
|
25
|
+
functions: 0,
|
|
26
|
+
lines: 0,
|
|
27
|
+
statements: 0
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
coverageReporters: [ 'html', 'text', 'text-summary', 'cobertura' ],
|
|
31
|
+
reporters: [ 'default', 'jest-junit' ],
|
|
32
|
+
collectCoverageFrom: [
|
|
33
|
+
'src/**/*.ts',
|
|
34
|
+
'!src/**/*.spec.js',
|
|
35
|
+
'src/**/*.js',
|
|
36
|
+
'!src/**/*.spec.ts',
|
|
37
|
+
'!src/**/tests/**'
|
|
38
|
+
],
|
|
39
|
+
setupFilesAfterEnv: [],
|
|
40
|
+
};
|
|
41
41
|
/*eslint-enable */
|
package/package.json
CHANGED
|
@@ -1,25 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adtrackify/at-service-common",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.20",
|
|
4
4
|
"description": "",
|
|
5
|
-
"module": "./dist/index.js",
|
|
6
5
|
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.esm.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
|
+
"typings": "./dist/index.d.ts",
|
|
9
|
+
"type": "module",
|
|
8
10
|
"modules": "esm",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"require": "./dist/index.js",
|
|
14
|
+
"import": "./dist/index.esm.js",
|
|
15
|
+
"types": "./dist/index.d.ts"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
9
18
|
"engines": {
|
|
10
19
|
"npm": ">=8.0.0 <9.0.0",
|
|
11
20
|
"node": ">=16.0.0 <18.14.2"
|
|
12
21
|
},
|
|
13
22
|
"scripts": {
|
|
14
23
|
"clean": "rimraf dist",
|
|
15
|
-
"build": "
|
|
24
|
+
"build": "cross-env NODE_ENV=production node build.js",
|
|
16
25
|
"build:dev": "npm run clean && npm run verify && cross-env NODE_ENV=production stage=dev APP_ENV=dev npm run build",
|
|
17
|
-
"build:qa": "npm run clean && npm run verify && cross-env NODE_ENV=production stage=qa APP_ENV=qa
|
|
18
|
-
"build:prod": "npm run clean && npm run verify && cross-env NODE_ENV=production stage=prod APP_ENV=prod
|
|
19
|
-
"elint": "eslint
|
|
26
|
+
"build:qa": "npm run clean && npm run verify && cross-env NODE_ENV=production stage=qa APP_ENV=qa npm run build",
|
|
27
|
+
"build:prod": "npm run clean && npm run verify && cross-env NODE_ENV=production stage=prod APP_ENV=prod npm run build",
|
|
28
|
+
"elint": "eslint .",
|
|
20
29
|
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
|
|
21
30
|
"lint": "eslint src/",
|
|
22
|
-
"lint:fix": "eslint
|
|
31
|
+
"lint:fix": "eslint . --fix",
|
|
23
32
|
"coverage": "npm run test:all -- --coverage --group=unit",
|
|
24
33
|
"test": "jest --group=unit --coverage",
|
|
25
34
|
"test:all": "cross-env AWS_REGION=us-east-2 NODE_ENV=test jest --group=unit --coverage",
|
|
@@ -31,13 +40,8 @@
|
|
|
31
40
|
"type-check": "tsc --noEmit"
|
|
32
41
|
},
|
|
33
42
|
"dependencies": {
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"@types/luxon": "^3.0.1",
|
|
37
|
-
"@types/ua-parser-js": "^0.7.36",
|
|
38
|
-
"@types/uuid": "^8.3.4",
|
|
39
|
-
"axios": "^0.27.2",
|
|
40
|
-
"axios-retry": "^3.3.1",
|
|
43
|
+
"axios": "^1.3.4",
|
|
44
|
+
"axios-retry": "^3.4.0",
|
|
41
45
|
"joi": "^17.6.0",
|
|
42
46
|
"lambda-log": "^3.1.0",
|
|
43
47
|
"luxon": "^3.0.3",
|
|
@@ -52,30 +56,26 @@
|
|
|
52
56
|
"@aws-sdk/client-eventbridge": "^3.278.0",
|
|
53
57
|
"@aws-sdk/client-s3": "^3.282.0",
|
|
54
58
|
"@aws-sdk/lib-dynamodb": "^3.279.0",
|
|
55
|
-
"@babel/cli": "^7.13.16",
|
|
56
|
-
"@babel/core": "^7.19.1",
|
|
57
|
-
"@babel/plugin-proposal-optional-chaining": "^7.13.8",
|
|
58
|
-
"@babel/plugin-transform-runtime": "^7.19.1",
|
|
59
|
-
"@babel/preset-env": "^7.19.1",
|
|
60
|
-
"@babel/preset-typescript": "^7.16.7",
|
|
61
|
-
"@babel/runtime-corejs3": "^7.19.1",
|
|
62
59
|
"@faker-js/faker": "^7.5.0",
|
|
63
60
|
"@swc/core": "^1.3.1",
|
|
64
61
|
"@swc/jest": "^0.2.22",
|
|
65
62
|
"@types/jest": "^28.1.8",
|
|
63
|
+
"@types/lambda-log": "^2.2.1",
|
|
64
|
+
"@types/luxon": "^3.0.1",
|
|
66
65
|
"@types/node": "^17.0.8",
|
|
66
|
+
"@types/ua-parser-js": "^0.7.36",
|
|
67
|
+
"@types/uuid": "^8.3.4",
|
|
67
68
|
"@typescript-eslint/eslint-plugin": "^5.37.0",
|
|
68
69
|
"@typescript-eslint/parser": "^5.37.0",
|
|
69
70
|
"core-js": "^3.25.1",
|
|
70
71
|
"cross-env": "^7.0.3",
|
|
71
|
-
"esbuild": "^0.
|
|
72
|
+
"esbuild": "^0.17.1",
|
|
72
73
|
"eslint": "^8.23.1",
|
|
73
74
|
"eslint-config-standard": "^17.0.0",
|
|
74
75
|
"eslint-plugin-babel": "^5.3.1",
|
|
75
76
|
"eslint-plugin-import": "^2.26.0",
|
|
76
77
|
"eslint-plugin-n": "^15.2.5",
|
|
77
78
|
"eslint-plugin-promise": "^6.0.1",
|
|
78
|
-
"eslint-webpack-plugin": "^3.1.1",
|
|
79
79
|
"glob": "^8.0.3",
|
|
80
80
|
"husky": "^6.0.0",
|
|
81
81
|
"jest": "^29.2.1",
|
|
@@ -90,12 +90,12 @@
|
|
|
90
90
|
"regenerator-runtime": "^0.13.9",
|
|
91
91
|
"rimraf": "^3.0.2",
|
|
92
92
|
"swc-loader": "^0.2.3",
|
|
93
|
-
"ts-jest": "^29.0.
|
|
94
|
-
"ts-loader": "^9.
|
|
93
|
+
"ts-jest": "^29.0.5",
|
|
94
|
+
"ts-loader": "^9.4.2",
|
|
95
95
|
"ts-node": "^10.9.1",
|
|
96
96
|
"tslint": "^6.1.3",
|
|
97
97
|
"tslint-config-prettier": "^1.18.0",
|
|
98
|
-
"typescript": "4.
|
|
98
|
+
"typescript": "4.9.5"
|
|
99
99
|
},
|
|
100
100
|
"repository": {
|
|
101
101
|
"type": "git",
|
|
@@ -104,4 +104,4 @@
|
|
|
104
104
|
"author": "",
|
|
105
105
|
"license": "ISC",
|
|
106
106
|
"homepage": "https://bitbucket.org/eacap/at-service-common#readme"
|
|
107
|
-
}
|
|
107
|
+
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
jest.mock('lambda-log');
|
|
9
9
|
import * as Logger from 'lambda-log';
|
|
10
|
-
import { getPlanDetails } from '../../helpers';
|
|
10
|
+
import { getPlanDetails } from '../../helpers/subscription-helper.js';
|
|
11
11
|
|
|
12
12
|
describe('postmark service email test', () => {
|
|
13
13
|
jest.spyOn(Logger, 'warn').mockImplementation(() => {
|
|
@@ -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,10 +1,6 @@
|
|
|
1
1
|
/* eslint-disable no-useless-escape */
|
|
2
2
|
import { AdminConfirmSignUpCommandInput, AdminDeleteUserCommandInput, AdminUpdateUserAttributesCommandInput, CognitoIdentityProvider, ConfirmSignUpCommandInput, ForgotPasswordCommandInput, ListUsersCommandInput, ResendConfirmationCodeCommandInput, SignUpCommandInput } from '@aws-sdk/client-cognito-identity-provider';
|
|
3
3
|
import * as log from 'lambda-log';
|
|
4
|
-
const cognitoClient = new CognitoIdentityProvider({});
|
|
5
|
-
|
|
6
|
-
let USER_POOL_NO_SECRET_CLIENT_ID: string;
|
|
7
|
-
let USER_POOL_ID: string;
|
|
8
4
|
|
|
9
5
|
export function dictToAwsAttributes(input: any) {
|
|
10
6
|
delete input.email;
|
|
@@ -27,49 +23,54 @@ const buildAttributes = (data: any) => {
|
|
|
27
23
|
};
|
|
28
24
|
|
|
29
25
|
export class CognitoClient {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
public cognitoClient: any
|
|
27
|
+
public USER_POOL_ID: string;
|
|
28
|
+
public USER_POOL_NO_SECRET_CLIENT_ID: string;
|
|
29
|
+
|
|
30
|
+
constructor(userPoolId: string, userPoolNoSecretClientId: string) {
|
|
31
|
+
this.cognitoClient = new CognitoIdentityProvider({});
|
|
32
|
+
this.USER_POOL_ID = userPoolId;
|
|
33
|
+
this.USER_POOL_NO_SECRET_CLIENT_ID = userPoolNoSecretClientId;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
public signupUser = async (data: any) => {
|
|
36
37
|
const params: SignUpCommandInput = {
|
|
37
|
-
ClientId: USER_POOL_NO_SECRET_CLIENT_ID,
|
|
38
|
+
ClientId: this.USER_POOL_NO_SECRET_CLIENT_ID,
|
|
38
39
|
Password: data.password,
|
|
39
40
|
Username: data.email,
|
|
40
41
|
UserAttributes: buildAttributes(data),
|
|
41
42
|
};
|
|
42
|
-
const cognitoResponse = await cognitoClient.signUp(params);
|
|
43
|
+
const cognitoResponse = await this.cognitoClient.signUp(params);
|
|
43
44
|
log.debug('Successfully Registered User', { cognitoResponse });
|
|
44
45
|
return cognitoResponse;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
await
|
|
48
|
+
public forgotPassword = async (email: string) => {
|
|
49
|
+
await this.adminEmailVerify(email);
|
|
49
50
|
const params: ForgotPasswordCommandInput = {
|
|
50
|
-
ClientId: USER_POOL_NO_SECRET_CLIENT_ID,
|
|
51
|
+
ClientId: this.USER_POOL_NO_SECRET_CLIENT_ID,
|
|
51
52
|
Username: email,
|
|
52
53
|
};
|
|
53
|
-
const cognitoResponse = await cognitoClient.forgotPassword(params);
|
|
54
|
+
const cognitoResponse = await this.cognitoClient.forgotPassword(params);
|
|
54
55
|
log.debug('Sent Forgot Password', { cognitoResponse });
|
|
55
56
|
return cognitoResponse;
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
|
|
59
|
+
public adminEmailVerify = async (email: string) => {
|
|
59
60
|
try {
|
|
60
|
-
const user: any = await
|
|
61
|
+
const user: any = await this.getUserByEmail(email);
|
|
61
62
|
if (user && user?.UserStatus === 'CONFIRMED' && user?.email_verified !== 'true') {
|
|
62
|
-
await
|
|
63
|
+
await this.forceValidateEmail(email);
|
|
63
64
|
}
|
|
64
65
|
} catch (error) {
|
|
65
66
|
log.error('Failed admin email verify', { error });
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
|
|
70
|
+
public forceValidateEmail = async (email: string) => {
|
|
70
71
|
try {
|
|
71
72
|
const params: AdminUpdateUserAttributesCommandInput = {
|
|
72
|
-
UserPoolId: USER_POOL_ID,
|
|
73
|
+
UserPoolId: this.USER_POOL_ID,
|
|
73
74
|
Username: email,
|
|
74
75
|
UserAttributes: [
|
|
75
76
|
{
|
|
@@ -78,60 +79,60 @@ export class CognitoClient {
|
|
|
78
79
|
},
|
|
79
80
|
],
|
|
80
81
|
};
|
|
81
|
-
await cognitoClient.adminUpdateUserAttributes(params);
|
|
82
|
+
await this.cognitoClient.adminUpdateUserAttributes(params);
|
|
82
83
|
} catch (error) {
|
|
83
84
|
log.error('Failed force validate email', { email, error });
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
87
|
|
|
87
|
-
|
|
88
|
+
public adminConfirmUser = async (data: any) => {
|
|
88
89
|
const params: AdminConfirmSignUpCommandInput = {
|
|
89
|
-
UserPoolId: USER_POOL_ID,
|
|
90
|
+
UserPoolId: this.USER_POOL_ID,
|
|
90
91
|
Username: data.email,
|
|
91
92
|
};
|
|
92
|
-
const cognitoResponse = await cognitoClient.adminConfirmSignUp(params);
|
|
93
|
-
await
|
|
93
|
+
const cognitoResponse = await this.cognitoClient.adminConfirmSignUp(params);
|
|
94
|
+
await this.forceValidateEmail(data.email);
|
|
94
95
|
log.debug('Admin Successfully Confirmed User', { cognitoResponse });
|
|
95
96
|
return cognitoResponse;
|
|
96
97
|
}
|
|
97
98
|
|
|
98
|
-
|
|
99
|
+
public confirmUser = async (data: any) => {
|
|
99
100
|
const params: ConfirmSignUpCommandInput = {
|
|
100
|
-
ClientId: USER_POOL_NO_SECRET_CLIENT_ID,
|
|
101
|
+
ClientId: this.USER_POOL_NO_SECRET_CLIENT_ID,
|
|
101
102
|
ConfirmationCode: data.confirmationCode,
|
|
102
103
|
Username: data.email,
|
|
103
104
|
};
|
|
104
|
-
const cognitoResponse = await cognitoClient.confirmSignUp(params);
|
|
105
|
+
const cognitoResponse = await this.cognitoClient.confirmSignUp(params);
|
|
105
106
|
log.debug('Successfully Confirmed User', { cognitoResponse });
|
|
106
107
|
return cognitoResponse;
|
|
107
108
|
}
|
|
108
109
|
|
|
109
|
-
|
|
110
|
+
public resendCode = async (email: string) => {
|
|
110
111
|
const params: ResendConfirmationCodeCommandInput = {
|
|
111
|
-
ClientId: USER_POOL_NO_SECRET_CLIENT_ID,
|
|
112
|
+
ClientId: this.USER_POOL_NO_SECRET_CLIENT_ID,
|
|
112
113
|
Username: email,
|
|
113
114
|
};
|
|
114
|
-
await cognitoClient.resendConfirmationCode(params);
|
|
115
|
+
await this.cognitoClient.resendConfirmationCode(params);
|
|
115
116
|
log.debug('Successfully Resend Confirmation Code', { email });
|
|
116
117
|
return;
|
|
117
118
|
}
|
|
118
119
|
|
|
119
|
-
|
|
120
|
+
public adminDeleteUser = async (userId: string) => {
|
|
120
121
|
const params: AdminDeleteUserCommandInput = {
|
|
121
|
-
UserPoolId: USER_POOL_ID,
|
|
122
|
+
UserPoolId: this.USER_POOL_ID,
|
|
122
123
|
Username: userId,
|
|
123
124
|
};
|
|
124
|
-
await cognitoClient.adminDeleteUser(params);
|
|
125
|
+
await this.cognitoClient.adminDeleteUser(params);
|
|
125
126
|
return true;
|
|
126
127
|
}
|
|
127
128
|
|
|
128
|
-
|
|
129
|
+
public getUserByEmail = async (email: string) => {
|
|
129
130
|
const params: ListUsersCommandInput = {
|
|
130
|
-
UserPoolId: USER_POOL_ID,
|
|
131
|
+
UserPoolId: this.USER_POOL_ID,
|
|
131
132
|
Filter: `email=\"${email}\"`,
|
|
132
133
|
Limit: 1,
|
|
133
134
|
};
|
|
134
|
-
const cognitoResponse: any = await cognitoClient.listUsers(params);
|
|
135
|
+
const cognitoResponse: any = await this.cognitoClient.listUsers(params);
|
|
135
136
|
log.debug('Get Users by Email', { cognitoResponse });
|
|
136
137
|
|
|
137
138
|
if (cognitoResponse?.Users && cognitoResponse?.Users.length > 0) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventBridgeClient as EventBridge, PutEventsCommand, PutEventsCommandInput } from '@aws-sdk/client-eventbridge';
|
|
2
2
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
|
-
import { getCurrentTimestamp } from '../../libs/dates';
|
|
3
|
+
import { getCurrentTimestamp } from '../../libs/dates.js';
|
|
4
4
|
import * as log from 'lambda-log';
|
|
5
5
|
|
|
6
6
|
export class EventBridgeClient {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
-
import axiosRetry from 'axios-retry';
|
|
2
|
+
//import axiosRetry from 'axios-retry';
|
|
3
3
|
import https from 'https';
|
|
4
4
|
import httpAdapter from 'axios/lib/adapters/http';
|
|
5
5
|
|
|
@@ -20,8 +20,7 @@ export const axiosHttpService = (config: any = {}) => {
|
|
|
20
20
|
config.adapter = httpAdapter;
|
|
21
21
|
config.httpsAgent = new https.Agent({ keepAlive: true });
|
|
22
22
|
const axiosService = axios.create(config);
|
|
23
|
-
|
|
24
|
-
axiosRetry(axiosService, { retryDelay: axiosRetry.exponentialDelay, retries: 3 });
|
|
23
|
+
// axiosRetry(axiosService, { retryDelay: axiosRetry.exponentialDelay, retries: 3 });
|
|
25
24
|
|
|
26
25
|
return {
|
|
27
26
|
instance: () => axiosService,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './dynamodb-client';
|
|
2
|
-
export * from './eventbridge-client';
|
|
3
|
-
export * from './http-client';
|
|
4
|
-
export * from './s3-client';
|
|
5
|
-
export * from './cognito-client';
|
|
1
|
+
export * from './dynamodb-client.js';
|
|
2
|
+
export * from './eventbridge-client.js';
|
|
3
|
+
export * from './http-client.js';
|
|
4
|
+
export * from './s3-client.js';
|
|
5
|
+
export * from './cognito-client.js';
|
|
@@ -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),
|
package/src/clients/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './generic';
|
|
2
|
-
export * from './internal-api';
|
|
3
|
-
export * from './third-party';
|
|
1
|
+
export * from './generic/index.js';
|
|
2
|
+
export * from './internal-api/index.js';
|
|
3
|
+
export * from './third-party/index.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as log from 'lambda-log';
|
|
2
|
-
import { ApiResponse } from '../../types/api-response';
|
|
2
|
+
import { ApiResponse } from '../../types/api-response.js';
|
|
3
3
|
import { Account, ACCOUNT_STATUS, Destination } from '@adtrackify/at-tracking-event-types';
|
|
4
|
-
import { axiosHttpService } from '../generic/http-client';
|
|
4
|
+
import { axiosHttpService } from '../generic/http-client.js';
|
|
5
5
|
|
|
6
6
|
//const BASE_API_URL = process.env.BASE_API_URL;
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as log from 'lambda-log';
|
|
2
2
|
//const log = require('lambda-log');
|
|
3
|
-
import { ApiResponse } from '../../types/api-response';
|
|
4
|
-
import { axiosHttpService } from '../generic/http-client';
|
|
3
|
+
import { ApiResponse } from '../../types/api-response.js';
|
|
4
|
+
import { axiosHttpService } from '../generic/http-client.js';
|
|
5
5
|
import { Destination } from '@adtrackify/at-tracking-event-types';
|
|
6
6
|
//const BASE_API_URL = process.env.BASE_API_URL;
|
|
7
7
|
//const DESTINATIONS_API_KEY = process.env.DESTINATIONS_API_KEY;
|
|
@@ -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.js';
|
|
2
|
+
export * from './accounts-client.js';
|
|
3
|
+
export * from './users-auth-client.js';
|
|
4
|
+
export * from './shopify-app-install-client.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import log from 'lambda-log';
|
|
2
|
-
import { ApiResponse } from '../../types/api-response';
|
|
3
|
-
import { axiosHttpService } from '../generic/http-client';
|
|
2
|
+
import { ApiResponse } from '../../types/api-response.js';
|
|
3
|
+
import { axiosHttpService } from '../generic/http-client.js';
|
|
4
4
|
import { ShopifyAppInstall, ShopifyAppSubscriptionStatus } from '@adtrackify/at-tracking-event-types';
|
|
5
5
|
//const BASE_API_URL = process.env.BASE_API_URL;
|
|
6
6
|
//const DESTINATIONS_API_KEY = process.env.DESTINATIONS_API_KEY;
|
|
@@ -61,6 +61,6 @@ export class ShopifyAppInstallClient {
|
|
|
61
61
|
const client = await this.getClient();
|
|
62
62
|
const response = await client.get(`/?shop=${shop}`);
|
|
63
63
|
log.info('getShopifyAppInstallByShop', { response });
|
|
64
|
-
return response as ApiResponse<ShopifyAppInstallResponseData>;
|
|
65
|
-
}
|
|
64
|
+
return response as ApiResponse<ShopifyAppInstallResponseData>;
|
|
65
|
+
};
|
|
66
66
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { User } from '@adtrackify/at-tracking-event-types';
|
|
2
2
|
import * as log from 'lambda-log';
|
|
3
|
-
import { HttpError
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { HttpError } from '../../libs/http-error.js';
|
|
4
|
+
import { HttpStatusCodes } from '../../libs/http-status-codes.js';
|
|
5
|
+
import { ApiResponse } from '../../types/api-response.js';
|
|
6
|
+
import { axiosHttpService } from '../generic/http-client.js';
|
|
6
7
|
|
|
7
8
|
export interface UserResponseData {
|
|
8
9
|
user: User;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './shopify-client';
|
|
1
|
+
export * from './shopify-client.js';
|
package/src/helpers/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './input-validation-helper';
|
|
2
|
-
export * from './logging-helper';
|
|
3
|
-
export * from './response-helper';
|
|
4
|
-
export * from './shopify-helper';
|
|
5
|
-
export * from './subscription-helper';
|
|
1
|
+
export * from './input-validation-helper.js';
|
|
2
|
+
export * from './logging-helper.js';
|
|
3
|
+
export * from './response-helper.js';
|
|
4
|
+
export * from './shopify-helper.js';
|
|
5
|
+
export * from './subscription-helper.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Joi from 'joi';
|
|
2
2
|
import * as log from 'lambda-log';
|
|
3
|
-
import { HttpError } from '../libs/http-error';
|
|
3
|
+
import { HttpError } from '../libs/http-error.js';
|
|
4
4
|
|
|
5
5
|
export const validateInput = (schema: Joi.ObjectSchema<any>, input: any) => {
|
|
6
6
|
const { error, value } = schema.validate(input);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHmac } from 'crypto';
|
|
2
2
|
import * as log from 'lambda-log';
|
|
3
|
-
import { HttpError } from '../libs';
|
|
4
|
-
import { mapObjectToQueryString } from '../libs/url';
|
|
3
|
+
import { HttpError } from '../libs/http-error.js';
|
|
4
|
+
import { mapObjectToQueryString } from '../libs/url.js';
|
|
5
5
|
export interface ShopifyRequestValidationParameters {
|
|
6
6
|
code: string,
|
|
7
7
|
hmac?: string,
|
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';
|
|
5
|
-
export * from './services';
|
|
1
|
+
export * from './clients/index.js';
|
|
2
|
+
export * from './helpers/index.js';
|
|
3
|
+
export * from './libs/index.js';
|
|
4
|
+
export * from './types/index.js';
|
|
5
|
+
export * from './services/index.js';
|
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';
|
|
1
|
+
export * from '../helpers/shopify-helper.js';
|
|
2
|
+
export * from './crypto.js';
|
|
3
|
+
export * from './dates.js';
|
|
4
|
+
export * from './http-error.js';
|
|
5
|
+
export * from './http-status-codes.js';
|
|
6
|
+
export * from './url.js';
|
|
7
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
|
};
|
package/src/services/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './eventbridge-integration-service';
|
|
1
|
+
export * from './eventbridge-integration-service.js';
|
package/src/types/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './internal-events';
|
|
1
|
+
export * from './internal-events/index.js';
|