@adtrackify/at-service-common 1.0.42 → 1.0.44
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/dist/index.d.ts +81 -6
- package/dist/index.js +12883 -5136
- package/dist/index.js.map +4 -4
- package/package.json +18 -18
- package/src/clients/internal-api/accounts-client.ts +26 -1
- package/src/clients/internal-api/index.ts +2 -1
- package/src/clients/internal-api/shopify-app-install-client.ts +51 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adtrackify/at-service-common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.44",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -25,45 +25,45 @@
|
|
|
25
25
|
"type-check": "tsc --noEmit"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
+
"@types/axios": "^0.14.0",
|
|
29
|
+
"@types/lambda-log": "^2.2.1",
|
|
30
|
+
"@types/luxon": "^3.0.1",
|
|
31
|
+
"@types/ua-parser-js": "^0.7.36",
|
|
28
32
|
"axios": "^0.27.2",
|
|
29
33
|
"axios-retry": "^3.3.1",
|
|
30
34
|
"crypto": "^1.0.1",
|
|
31
35
|
"joi": "^17.6.0",
|
|
32
36
|
"lambda-log": "^3.1.0",
|
|
33
|
-
"luxon": "^3.0.
|
|
34
|
-
"ua-parser-js": "^1.0.2"
|
|
35
|
-
"@types/ua-parser-js": "^0.7.36",
|
|
36
|
-
"@types/lambda-log": "^2.2.1",
|
|
37
|
-
"@types/luxon": "^3.0.0",
|
|
38
|
-
"@types/axios": "^0.14.0"
|
|
37
|
+
"luxon": "^3.0.3",
|
|
38
|
+
"ua-parser-js": "^1.0.2"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@adtrackify/at-tracking-event-types": "^1.0.
|
|
41
|
+
"@adtrackify/at-tracking-event-types": "^1.0.25",
|
|
42
42
|
"@babel/cli": "^7.13.16",
|
|
43
|
-
"@babel/core": "^7.
|
|
43
|
+
"@babel/core": "^7.19.0",
|
|
44
44
|
"@babel/plugin-proposal-optional-chaining": "^7.13.8",
|
|
45
45
|
"@babel/plugin-transform-runtime": "^7.10.3",
|
|
46
|
-
"@babel/preset-env": "^7.
|
|
46
|
+
"@babel/preset-env": "^7.19.0",
|
|
47
47
|
"@babel/preset-typescript": "^7.16.7",
|
|
48
|
-
"@babel/runtime-corejs3": "^7.
|
|
48
|
+
"@babel/runtime-corejs3": "^7.19.0",
|
|
49
49
|
"@types/jest": "^27.4.1",
|
|
50
50
|
"@types/node": "^17.0.8",
|
|
51
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
52
|
-
"@typescript-eslint/parser": "^5.
|
|
53
|
-
"aws-sdk": "^2.
|
|
51
|
+
"@typescript-eslint/eslint-plugin": "^5.36.2",
|
|
52
|
+
"@typescript-eslint/parser": "^5.36.2",
|
|
53
|
+
"aws-sdk": "^2.1213.0",
|
|
54
54
|
"babel-eslint": "^10.1.0",
|
|
55
55
|
"babel-jest": "^26.6.3",
|
|
56
56
|
"babel-polyfill": "^6.26.0",
|
|
57
|
-
"core-js": "^3.
|
|
57
|
+
"core-js": "^3.25.1",
|
|
58
58
|
"cross-env": "^7.0.3",
|
|
59
59
|
"esbuild": "^0.14.54",
|
|
60
|
-
"eslint": "^8.
|
|
60
|
+
"eslint": "^8.23.0",
|
|
61
61
|
"eslint-config-standard": "^17.0.0",
|
|
62
62
|
"eslint-loader": "^4.0.2",
|
|
63
63
|
"eslint-plugin-babel": "^5.3.1",
|
|
64
64
|
"eslint-plugin-import": "^2.26.0",
|
|
65
|
-
"eslint-plugin-n": "^15.2.
|
|
66
|
-
"eslint-plugin-promise": "^6.0.
|
|
65
|
+
"eslint-plugin-n": "^15.2.5",
|
|
66
|
+
"eslint-plugin-promise": "^6.0.1",
|
|
67
67
|
"eslint-webpack-plugin": "^3.1.1",
|
|
68
68
|
"glob": "^8.0.3",
|
|
69
69
|
"husky": "^6.0.0",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as log from 'lambda-log';
|
|
2
2
|
import { ApiResponse } from '../../types/api-response';
|
|
3
|
-
import { Destination } from '@adtrackify/at-tracking-event-types';
|
|
3
|
+
import { ACCOUNT_STATUS, Destination } from '@adtrackify/at-tracking-event-types';
|
|
4
4
|
import { axiosHttpService } from '../generic/http-client';
|
|
5
5
|
|
|
6
6
|
//const BASE_API_URL = process.env.BASE_API_URL;
|
|
@@ -8,6 +8,10 @@ import { axiosHttpService } from '../generic/http-client';
|
|
|
8
8
|
//const SERVICE_API_ROOT_URL = `${BASE_API_URL}/accounts`;
|
|
9
9
|
//const ACCOUNTS_API_KEY = process.env.ACCOUNTS_API_KEY;
|
|
10
10
|
|
|
11
|
+
export interface AccountResponseData {
|
|
12
|
+
account: boolean;
|
|
13
|
+
[ key: string ]: any;
|
|
14
|
+
}
|
|
11
15
|
|
|
12
16
|
export interface IsAuthorizedUserResponseData {
|
|
13
17
|
isAccountUser: boolean;
|
|
@@ -19,6 +23,15 @@ export interface PixelConfigResponseData {
|
|
|
19
23
|
[ key: string ]: any;
|
|
20
24
|
}
|
|
21
25
|
|
|
26
|
+
export interface UpdateAccountRequest {
|
|
27
|
+
accountName?: string,
|
|
28
|
+
companyName?: string,
|
|
29
|
+
primaryEmail?: string,
|
|
30
|
+
ownerId?: string,
|
|
31
|
+
subscriptionId?: string,
|
|
32
|
+
accountStatus?: ACCOUNT_STATUS;
|
|
33
|
+
}
|
|
34
|
+
|
|
22
35
|
export class AccountsClient {
|
|
23
36
|
public BASE_API_URL: string;
|
|
24
37
|
public ACCOUNTS_API_KEY?: string;
|
|
@@ -53,6 +66,12 @@ export class AccountsClient {
|
|
|
53
66
|
log.info('createAccountResponse', { createAccountResponse });
|
|
54
67
|
return createAccountResponse;
|
|
55
68
|
};
|
|
69
|
+
updateAccount = async (accountId: string, body: any): Promise<ApiResponse<AccountResponseData>> => {
|
|
70
|
+
const client = await this.getClient();
|
|
71
|
+
const response = await client.patch(`/${accountId}/`, body);
|
|
72
|
+
log.info('update Account response', { response });
|
|
73
|
+
return response as ApiResponse<AccountResponseData>;
|
|
74
|
+
};
|
|
56
75
|
addOwner = async (accountId: string, userId: string) => {
|
|
57
76
|
const client = await this.getClient();
|
|
58
77
|
const addOwnerResponse = await client.post('/addOwner', { accountId, userId });
|
|
@@ -80,4 +99,10 @@ export class AccountsClient {
|
|
|
80
99
|
log.debug('pixelResponse', { pixelResponse });
|
|
81
100
|
return pixelResponse;
|
|
82
101
|
};
|
|
102
|
+
// setAccountSubscriptionId = async (accountId: string, subscriptionId: string): Promise<ApiResponse<any>> => {
|
|
103
|
+
// const client = await this.getClient();
|
|
104
|
+
// const pixelResponse = await client.get(`/px/${pixelId}/config`);
|
|
105
|
+
// log.debug('pixelResponse', { pixelResponse });
|
|
106
|
+
// return pixelResponse;
|
|
107
|
+
// };
|
|
83
108
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as 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
|
+
isAppEnabled?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class ShopifyAppInstallClient {
|
|
20
|
+
|
|
21
|
+
public BASE_API_URL: string;
|
|
22
|
+
public SHOPIFY_APP_INSTALL_API_KEY: string;
|
|
23
|
+
|
|
24
|
+
constructor (baseApiUrl: string, shopifyAppInstallApiKey: string) {
|
|
25
|
+
this.BASE_API_URL = baseApiUrl;
|
|
26
|
+
this.SHOPIFY_APP_INSTALL_API_KEY = shopifyAppInstallApiKey;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
getConfig = () => {
|
|
30
|
+
const SERVICE_API_ROOT_URL = `${this.BASE_API_URL}/shopify-app-installs`;
|
|
31
|
+
return {
|
|
32
|
+
baseURL: SERVICE_API_ROOT_URL,
|
|
33
|
+
headers: {
|
|
34
|
+
common: {
|
|
35
|
+
'x-api-key': this.SHOPIFY_APP_INSTALL_API_KEY
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
getClient = async () => {
|
|
42
|
+
return axiosHttpService(this.getConfig());
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
updateShopifyAppInstall = async (shopifyAppInstallId: string, updateShopifyAppInstallRequest: UpdateShopifyAppInstallRequest): Promise<ApiResponse<ShopifyAppInstallResponseData>> => {
|
|
46
|
+
const client = await this.getClient();
|
|
47
|
+
const response = await client.put(`/${shopifyAppInstallId}`, updateShopifyAppInstallRequest);
|
|
48
|
+
log.info('updateShopifyAppInstall', { response });
|
|
49
|
+
return response as ApiResponse<ShopifyAppInstallResponseData>;
|
|
50
|
+
};
|
|
51
|
+
}
|