@8ms/helpers 1.0.7 → 1.0.11
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/api/types.d.ts +2 -1
- package/dist/aws/athenaExpress/getClient.js +6 -1
- package/dist/aws/getConfig.d.ts +9 -0
- package/dist/aws/getConfig.js +28 -0
- package/dist/aws/glue/getClient.js +6 -1
- package/dist/aws/lambda/getClient.js +6 -1
- package/dist/aws/s3/getClient.js +6 -1
- package/dist/aws/ses/getClient.js +6 -1
- package/dist/aws/ssm/getClient.js +6 -1
- package/package.json +2 -2
package/dist/api/types.d.ts
CHANGED
|
@@ -2,5 +2,6 @@ import { ApiStatus } from './constants';
|
|
|
2
2
|
export declare type ApiResponseType = {
|
|
3
3
|
body: any | null;
|
|
4
4
|
error: string | null;
|
|
5
|
-
status:
|
|
5
|
+
status: ApiStatusType;
|
|
6
6
|
};
|
|
7
|
+
export declare type ApiStatusType = typeof ApiStatus.ERROR | typeof ApiStatus.IDLE | typeof ApiStatus.PENDING | typeof ApiStatus.SUCCESS | typeof ApiStatus.VALIDATION_ERROR;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var getConfig_1 = __importDefault(require("../getConfig"));
|
|
3
7
|
var athenaClient = undefined;
|
|
4
8
|
/**
|
|
5
9
|
* Initialise the database using manually provided credentials.
|
|
@@ -7,8 +11,9 @@ var athenaClient = undefined;
|
|
|
7
11
|
var getClient = function (_a) {
|
|
8
12
|
var AthenaExpress = _a.AthenaExpress, AwsSdk = _a.AwsSdk, athenaS3 = _a.athenaS3, config = _a.config, database = _a.database;
|
|
9
13
|
if (!global.awsAthenaClient) {
|
|
14
|
+
var formattedConfig = (0, getConfig_1.default)({ config: config, isAthenaExpress: true });
|
|
10
15
|
// Set the aws authentication
|
|
11
|
-
AwsSdk.config.update(
|
|
16
|
+
AwsSdk.config.update(formattedConfig);
|
|
12
17
|
global.awsAthenaClient = new AthenaExpress.AthenaExpress({
|
|
13
18
|
aws: AwsSdk,
|
|
14
19
|
s3: athenaS3,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AwsConfigType } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* The config must be in a specific structure, if the properties aren't defined don't specify them as they could be inferred (e.g. Lambda).
|
|
4
|
+
*/
|
|
5
|
+
declare const getConfig: ({ config, isAthenaExpress }: {
|
|
6
|
+
config: AwsConfigType;
|
|
7
|
+
isAthenaExpress: boolean;
|
|
8
|
+
}) => object;
|
|
9
|
+
export default getConfig;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* The config must be in a specific structure, if the properties aren't defined don't specify them as they could be inferred (e.g. Lambda).
|
|
5
|
+
*/
|
|
6
|
+
var getConfig = function (_a) {
|
|
7
|
+
var config = _a.config, isAthenaExpress = _a.isAthenaExpress;
|
|
8
|
+
var response = {
|
|
9
|
+
region: config.region,
|
|
10
|
+
};
|
|
11
|
+
// Set the key id and access key if its defined (not required for AWS SAM)
|
|
12
|
+
if ('' !== config.accessKeyId && '' !== config.secretAccessKey) {
|
|
13
|
+
// Athena is a flat structure
|
|
14
|
+
if (isAthenaExpress) {
|
|
15
|
+
response['accessKeyId'] = config.accessKeyId;
|
|
16
|
+
response['secretAccessKey'] = config.secretAccessKey;
|
|
17
|
+
}
|
|
18
|
+
// AWS services are under credentials
|
|
19
|
+
else {
|
|
20
|
+
response['credentials'] = {
|
|
21
|
+
accessKeyId: config.accessKeyId,
|
|
22
|
+
secretAccessKey: config.secretAccessKey,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return response;
|
|
27
|
+
};
|
|
28
|
+
exports.default = getConfig;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var getConfig_1 = __importDefault(require("../getConfig"));
|
|
3
7
|
var glueClient = undefined;
|
|
4
8
|
/**
|
|
5
9
|
* Shorthand function to get the Glue Client.
|
|
@@ -9,7 +13,8 @@ var getClient = function (_a) {
|
|
|
9
13
|
var GlueLib = _a.GlueLib, config = _a.config;
|
|
10
14
|
if (!global.awsGlueClient) {
|
|
11
15
|
var GlueClient = GlueLib.GlueClient;
|
|
12
|
-
|
|
16
|
+
var formattedConfig = (0, getConfig_1.default)({ config: config, isAthenaExpress: false });
|
|
17
|
+
global.awsGlueClient = new GlueClient(formattedConfig);
|
|
13
18
|
}
|
|
14
19
|
glueClient = global.awsGlueClient;
|
|
15
20
|
return glueClient;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var getConfig_1 = __importDefault(require("../getConfig"));
|
|
3
7
|
var lambdaClient = undefined;
|
|
4
8
|
/**
|
|
5
9
|
* Shorthand function to get the Lambda Client.
|
|
@@ -9,7 +13,8 @@ var getClient = function (_a) {
|
|
|
9
13
|
var LambdaLib = _a.LambdaLib, config = _a.config;
|
|
10
14
|
if (!global.awsLambdaClient) {
|
|
11
15
|
var LambdaClient = LambdaLib.LambdaClient;
|
|
12
|
-
|
|
16
|
+
var formattedConfig = (0, getConfig_1.default)({ config: config, isAthenaExpress: false });
|
|
17
|
+
global.awsLambdaClient = new LambdaClient(formattedConfig);
|
|
13
18
|
}
|
|
14
19
|
lambdaClient = global.awsLambdaClient;
|
|
15
20
|
return lambdaClient;
|
package/dist/aws/s3/getClient.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var getConfig_1 = __importDefault(require("../getConfig"));
|
|
3
7
|
var s3Client = undefined;
|
|
4
8
|
/**
|
|
5
9
|
* Shorthand function to get the S3 Client.
|
|
@@ -9,7 +13,8 @@ var getClient = function (_a) {
|
|
|
9
13
|
var S3Lib = _a.S3Lib, config = _a.config;
|
|
10
14
|
if (!global.awsS3Client) {
|
|
11
15
|
var S3Client = S3Lib.S3Client;
|
|
12
|
-
|
|
16
|
+
var formattedConfig = (0, getConfig_1.default)({ config: config, isAthenaExpress: false });
|
|
17
|
+
global.awsS3Client = new S3Client(formattedConfig);
|
|
13
18
|
}
|
|
14
19
|
s3Client = global.awsS3Client;
|
|
15
20
|
return s3Client;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var getConfig_1 = __importDefault(require("../getConfig"));
|
|
3
7
|
var sesClient = undefined;
|
|
4
8
|
/**
|
|
5
9
|
* Shorthand function to get the SES Client.
|
|
@@ -9,7 +13,8 @@ var getClient = function (_a) {
|
|
|
9
13
|
var SesLib = _a.SesLib, config = _a.config;
|
|
10
14
|
if (!global.awsSesClient) {
|
|
11
15
|
var SESClient = SesLib.SESClient;
|
|
12
|
-
|
|
16
|
+
var formattedConfig = (0, getConfig_1.default)({ config: config, isAthenaExpress: false });
|
|
17
|
+
global.sesClient = new SESClient(formattedConfig);
|
|
13
18
|
}
|
|
14
19
|
sesClient = global.awsSesClient;
|
|
15
20
|
return sesClient;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var getConfig_1 = __importDefault(require("../getConfig"));
|
|
3
7
|
var ssmClient = undefined;
|
|
4
8
|
/**
|
|
5
9
|
* Shorthand function to get the Lambda Client.
|
|
@@ -9,7 +13,8 @@ var getClient = function (_a) {
|
|
|
9
13
|
var SsmLib = _a.SsmLib, config = _a.config;
|
|
10
14
|
if (!global.awsSsmClient) {
|
|
11
15
|
var SSMClient = SsmLib.SSMClient;
|
|
12
|
-
|
|
16
|
+
var formattedConfig = (0, getConfig_1.default)({ config: config, isAthenaExpress: false });
|
|
17
|
+
global.awsSsmClient = new SSMClient(formattedConfig);
|
|
13
18
|
}
|
|
14
19
|
ssmClient = global.awsSsmClient;
|
|
15
20
|
return ssmClient;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@8ms/helpers",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"dist/**/*"
|
|
12
12
|
],
|
|
13
13
|
"scripts": {
|
|
14
|
-
"build":
|
|
14
|
+
"build": "rimraf dist && tsc"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"axios": "0.25.0",
|