@8ms/helpers 1.0.3 → 1.0.4
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/aws/athenaExpress/getClient.js +3 -2
- package/dist/aws/glue/getClient.js +3 -2
- package/dist/aws/lambda/getClient.js +3 -2
- package/dist/aws/s3/getClient.js +3 -2
- package/dist/aws/ses/getClient.js +3 -2
- package/dist/aws/ssm/getClient.js +3 -2
- package/dist/aws/ssm/getParameter.js +15 -8
- package/dist/googleAds/getClient.js +5 -3
- package/dist/prisma/getClient.js +1 -1
- package/dist/string/formatCapitalise.d.ts +9 -0
- package/dist/string/formatCapitalise.js +17 -0
- package/dist/string/index.d.ts +2 -1
- package/dist/string/index.js +3 -1
- package/package.json +1 -1
|
@@ -6,10 +6,10 @@ var athenaClient = undefined;
|
|
|
6
6
|
*/
|
|
7
7
|
var getClient = function (_a) {
|
|
8
8
|
var AthenaExpress = _a.AthenaExpress, AwsSdk = _a.AwsSdk, athenaS3 = _a.athenaS3, config = _a.config, database = _a.database;
|
|
9
|
-
if (
|
|
9
|
+
if (!global.awsAthenaClient) {
|
|
10
10
|
// Set the aws authentication
|
|
11
11
|
AwsSdk.config.update(config);
|
|
12
|
-
|
|
12
|
+
global.awsAthenaClient = new AthenaExpress.AthenaExpress({
|
|
13
13
|
aws: AwsSdk,
|
|
14
14
|
s3: athenaS3,
|
|
15
15
|
db: database,
|
|
@@ -18,6 +18,7 @@ var getClient = function (_a) {
|
|
|
18
18
|
getStats: false,
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
+
athenaClient = global.awsAthenaClient;
|
|
21
22
|
return athenaClient;
|
|
22
23
|
};
|
|
23
24
|
exports.default = getClient;
|
|
@@ -7,10 +7,11 @@ var glueClient = undefined;
|
|
|
7
7
|
*/
|
|
8
8
|
var getClient = function (_a) {
|
|
9
9
|
var GlueLib = _a.GlueLib, config = _a.config;
|
|
10
|
-
if (
|
|
10
|
+
if (!global.awsGlueClient) {
|
|
11
11
|
var GlueClient = GlueLib.GlueClient;
|
|
12
|
-
|
|
12
|
+
global.awsGlueClient = new GlueClient(config);
|
|
13
13
|
}
|
|
14
|
+
glueClient = global.awsGlueClient;
|
|
14
15
|
return glueClient;
|
|
15
16
|
};
|
|
16
17
|
exports.default = getClient;
|
|
@@ -7,10 +7,11 @@ var lambdaClient = undefined;
|
|
|
7
7
|
*/
|
|
8
8
|
var getClient = function (_a) {
|
|
9
9
|
var LambdaLib = _a.LambdaLib, config = _a.config;
|
|
10
|
-
if (
|
|
10
|
+
if (!global.awsLambdaClient) {
|
|
11
11
|
var LambdaClient = LambdaLib.LambdaClient;
|
|
12
|
-
|
|
12
|
+
global.awsLambdaClient = new LambdaClient(config);
|
|
13
13
|
}
|
|
14
|
+
lambdaClient = global.awsLambdaClient;
|
|
14
15
|
return lambdaClient;
|
|
15
16
|
};
|
|
16
17
|
exports.default = getClient;
|
package/dist/aws/s3/getClient.js
CHANGED
|
@@ -7,10 +7,11 @@ var s3Client = undefined;
|
|
|
7
7
|
*/
|
|
8
8
|
var getClient = function (_a) {
|
|
9
9
|
var S3Lib = _a.S3Lib, config = _a.config;
|
|
10
|
-
if (
|
|
10
|
+
if (!global.awsS3Client) {
|
|
11
11
|
var S3Client = S3Lib.S3Client;
|
|
12
|
-
|
|
12
|
+
global.awsS3Client = new S3Client(config);
|
|
13
13
|
}
|
|
14
|
+
s3Client = global.awsS3Client;
|
|
14
15
|
return s3Client;
|
|
15
16
|
};
|
|
16
17
|
exports.default = getClient;
|
|
@@ -7,10 +7,11 @@ var sesClient = undefined;
|
|
|
7
7
|
*/
|
|
8
8
|
var getClient = function (_a) {
|
|
9
9
|
var SesLib = _a.SesLib, config = _a.config;
|
|
10
|
-
if (
|
|
10
|
+
if (!global.awsSesClient) {
|
|
11
11
|
var SESClient = SesLib.SESClient;
|
|
12
|
-
sesClient = new SESClient(config);
|
|
12
|
+
global.sesClient = new SESClient(config);
|
|
13
13
|
}
|
|
14
|
+
sesClient = global.awsSesClient;
|
|
14
15
|
return sesClient;
|
|
15
16
|
};
|
|
16
17
|
exports.default = getClient;
|
|
@@ -7,10 +7,11 @@ var ssmClient = undefined;
|
|
|
7
7
|
*/
|
|
8
8
|
var getClient = function (_a) {
|
|
9
9
|
var SsmLib = _a.SsmLib, config = _a.config;
|
|
10
|
-
if (
|
|
10
|
+
if (!global.awsSsmClient) {
|
|
11
11
|
var SSMClient = SsmLib.SSMClient;
|
|
12
|
-
|
|
12
|
+
global.awsSsmClient = new SSMClient(config);
|
|
13
13
|
}
|
|
14
|
+
ssmClient = global.awsSsmClient;
|
|
14
15
|
return ssmClient;
|
|
15
16
|
};
|
|
16
17
|
exports.default = getClient;
|
|
@@ -48,7 +48,11 @@ var getParameter = function (_a) {
|
|
|
48
48
|
switch (_b.label) {
|
|
49
49
|
case 0:
|
|
50
50
|
response = undefined;
|
|
51
|
-
|
|
51
|
+
// Ensure the global property exists
|
|
52
|
+
if (!global.awsSsmParameters) {
|
|
53
|
+
global.awsSsmParameters = {};
|
|
54
|
+
}
|
|
55
|
+
if (!!global.awsSsmParameters[name]) return [3 /*break*/, 4];
|
|
52
56
|
_b.label = 1;
|
|
53
57
|
case 1:
|
|
54
58
|
_b.trys.push([1, 3, , 4]);
|
|
@@ -61,23 +65,26 @@ var getParameter = function (_a) {
|
|
|
61
65
|
apiResponse = _b.sent();
|
|
62
66
|
if (apiResponse.Parameter.Value) {
|
|
63
67
|
response = apiResponse.Parameter.Value;
|
|
64
|
-
|
|
68
|
+
global.awsSsmParameters[name] = response;
|
|
65
69
|
if (isJson && undefined !== response) {
|
|
66
70
|
response = JSON.parse(response) || undefined;
|
|
67
|
-
|
|
71
|
+
global.awsSsmParameters[name] = response;
|
|
68
72
|
}
|
|
69
73
|
}
|
|
74
|
+
// Value not found (null so it can be sent from server to front end)
|
|
75
|
+
else {
|
|
76
|
+
global.awsSsmParameters[name] = null;
|
|
77
|
+
}
|
|
70
78
|
return [3 /*break*/, 4];
|
|
71
79
|
case 3:
|
|
72
80
|
error_1 = _b.sent();
|
|
73
81
|
// @ts-ignore
|
|
74
82
|
console.log("SSM Error: ".concat(error_1.message));
|
|
75
83
|
return [3 /*break*/, 4];
|
|
76
|
-
case 4:
|
|
77
|
-
|
|
78
|
-
response =
|
|
79
|
-
|
|
80
|
-
case 6: return [2 /*return*/, response];
|
|
84
|
+
case 4:
|
|
85
|
+
// Return the loaded result
|
|
86
|
+
response = global.awsSsmParameters[name];
|
|
87
|
+
return [2 /*return*/, response];
|
|
81
88
|
}
|
|
82
89
|
});
|
|
83
90
|
});
|
|
@@ -49,7 +49,7 @@ var getClient = function (_a) {
|
|
|
49
49
|
return __generator(this, function (_b) {
|
|
50
50
|
switch (_b.label) {
|
|
51
51
|
case 0:
|
|
52
|
-
if (
|
|
52
|
+
if (!!global.googleAdsClient) return [3 /*break*/, 2];
|
|
53
53
|
ssmClient = (0, ssm_1.getClient)({ SsmLib: SsmLib, config: awsConfig });
|
|
54
54
|
return [4 /*yield*/, (0, ssm_1.getParameter)({
|
|
55
55
|
SsmLib: SsmLib,
|
|
@@ -62,7 +62,7 @@ var getClient = function (_a) {
|
|
|
62
62
|
parameter = _b.sent();
|
|
63
63
|
GoogleAdsApi = GoogleAdsLib.GoogleAdsApi;
|
|
64
64
|
// Create a new client instance
|
|
65
|
-
googleAdsClient = {
|
|
65
|
+
global.googleAdsClient = {
|
|
66
66
|
instance: new GoogleAdsApi({
|
|
67
67
|
client_id: parameter.clientId,
|
|
68
68
|
client_secret: parameter.clientSecret,
|
|
@@ -72,7 +72,9 @@ var getClient = function (_a) {
|
|
|
72
72
|
refreshToken: parameter.refreshToken,
|
|
73
73
|
};
|
|
74
74
|
_b.label = 2;
|
|
75
|
-
case 2:
|
|
75
|
+
case 2:
|
|
76
|
+
googleAdsClient = global.googleAdsClient;
|
|
77
|
+
return [2 /*return*/, googleAdsClient];
|
|
76
78
|
}
|
|
77
79
|
});
|
|
78
80
|
});
|
package/dist/prisma/getClient.js
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Convert a string into Capitalised Text.
|
|
5
|
+
* https://stackoverflow.com/a/196991/2664955
|
|
6
|
+
*/
|
|
7
|
+
var formatCapitalise = function (_a) {
|
|
8
|
+
var _b = _a === void 0 ? { input: '', split: '_' } : _a, input = _b.input, split = _b.split;
|
|
9
|
+
return input
|
|
10
|
+
.replace("/".concat(split, "/g"), ' ')
|
|
11
|
+
.replace(/\w\S*/g, function (txt) {
|
|
12
|
+
return txt.charAt(0)
|
|
13
|
+
.toUpperCase() + txt.substr(1)
|
|
14
|
+
.toLowerCase();
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
exports.default = formatCapitalise;
|
package/dist/string/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import formatCapitalise from './formatCapitalise';
|
|
1
2
|
import getCleanFolder from './getCleanFolder';
|
|
2
3
|
import getStringFromStream from './getStringFromStream';
|
|
3
4
|
export type {};
|
|
4
|
-
export { getCleanFolder, getStringFromStream, };
|
|
5
|
+
export { formatCapitalise, getCleanFolder, getStringFromStream, };
|
package/dist/string/index.js
CHANGED
|
@@ -3,7 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getStringFromStream = exports.getCleanFolder = void 0;
|
|
6
|
+
exports.getStringFromStream = exports.getCleanFolder = exports.formatCapitalise = void 0;
|
|
7
|
+
var formatCapitalise_1 = __importDefault(require("./formatCapitalise"));
|
|
8
|
+
exports.formatCapitalise = formatCapitalise_1.default;
|
|
7
9
|
var getCleanFolder_1 = __importDefault(require("./getCleanFolder"));
|
|
8
10
|
exports.getCleanFolder = getCleanFolder_1.default;
|
|
9
11
|
var getStringFromStream_1 = __importDefault(require("./getStringFromStream"));
|