@8ms/helpers 1.1.57 → 1.1.60
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/aws/athenaExpress/initClient.d.ts +7 -5
- package/aws/athenaExpress/initClient.js +2 -2
- package/aws/s3/getGlueJson.d.ts +4 -0
- package/aws/s3/getGlueJson.js +16 -0
- package/initClients.d.ts +28 -0
- package/{aws/s3/writeGlueJsonFile.js → initClients.js} +43 -16
- package/package.json +43 -43
- package/aws/s3/writeGlueJsonFile.d.ts +0 -12
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Config } from '../config';
|
|
2
|
+
declare type InitClient = {
|
|
3
|
+
config: Config;
|
|
4
|
+
database: string;
|
|
5
|
+
s3Bucket: string;
|
|
6
|
+
s3Key: string;
|
|
7
|
+
};
|
|
2
8
|
/**
|
|
3
9
|
* Initialise the database using manually provided credentials.
|
|
4
10
|
*/
|
|
5
|
-
declare const initClient: ({
|
|
6
|
-
athenaS3?: string;
|
|
7
|
-
config?: Config;
|
|
8
|
-
database?: string;
|
|
9
|
-
}) => void;
|
|
11
|
+
declare const initClient: ({ config, database, s3Bucket, s3Key }: InitClient) => void;
|
|
10
12
|
export default initClient;
|
|
@@ -9,7 +9,7 @@ global.awsAthenaExpressClient = null;
|
|
|
9
9
|
* Initialise the database using manually provided credentials.
|
|
10
10
|
*/
|
|
11
11
|
var initClient = function (_a) {
|
|
12
|
-
var
|
|
12
|
+
var config = _a.config, database = _a.database, s3Bucket = _a.s3Bucket, s3Key = _a.s3Key;
|
|
13
13
|
if (!global.awsAthenaExpressClient) {
|
|
14
14
|
var athenaExpress = require('athena-express');
|
|
15
15
|
var awsSdk = require('aws-sdk');
|
|
@@ -18,7 +18,7 @@ var initClient = function (_a) {
|
|
|
18
18
|
awsSdk.config.update(formattedConfig);
|
|
19
19
|
global.awsAthenaExpressClient = new athenaExpress.AthenaExpress({
|
|
20
20
|
aws: awsSdk,
|
|
21
|
-
s3:
|
|
21
|
+
s3: "s3://".concat(s3Bucket, "/").concat(s3Key),
|
|
22
22
|
db: database,
|
|
23
23
|
formatJson: true,
|
|
24
24
|
retry: 200,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var getArray_1 = __importDefault(require("../../array/getArray"));
|
|
7
|
+
var getGlueJson = function (_a) {
|
|
8
|
+
var data = _a.data;
|
|
9
|
+
// Must be an array
|
|
10
|
+
var inputArray = (0, getArray_1.default)({ input: data });
|
|
11
|
+
// For each array row convert the row
|
|
12
|
+
var stringRows = inputArray.map(function (row) { return JSON.stringify(row); });
|
|
13
|
+
// Combine each row with a line separator
|
|
14
|
+
return stringRows.join("\n");
|
|
15
|
+
};
|
|
16
|
+
exports.default = getGlueJson;
|
package/initClients.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Config as ConfigAws } from './aws/config';
|
|
2
|
+
declare type InitClients = {
|
|
3
|
+
athenaExpress?: {
|
|
4
|
+
database: string;
|
|
5
|
+
s3Bucket: string;
|
|
6
|
+
s3Key: string;
|
|
7
|
+
};
|
|
8
|
+
awsConfig?: ConfigAws;
|
|
9
|
+
awsGlue?: boolean;
|
|
10
|
+
awsLambda?: boolean;
|
|
11
|
+
awsS3?: boolean;
|
|
12
|
+
awsSes?: boolean;
|
|
13
|
+
awsSsm?: boolean;
|
|
14
|
+
deepCrawl?: boolean;
|
|
15
|
+
eskimi?: boolean;
|
|
16
|
+
googleAds?: {
|
|
17
|
+
parameterName: string;
|
|
18
|
+
};
|
|
19
|
+
prisma?: {
|
|
20
|
+
debug?: boolean;
|
|
21
|
+
};
|
|
22
|
+
myTarget?: boolean;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Function to simplify initialising the clients.
|
|
26
|
+
*/
|
|
27
|
+
declare const initClients: ({ athenaExpress, awsConfig, awsGlue, awsS3, awsSes, awsSsm, googleAds, prisma, }: InitClients) => Promise<void>;
|
|
28
|
+
export default initClients;
|
|
@@ -39,29 +39,56 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
|
|
43
|
-
var
|
|
44
|
-
var
|
|
42
|
+
var initClient_1 = __importDefault(require("./aws/athenaExpress/initClient"));
|
|
43
|
+
var initClient_2 = __importDefault(require("./aws/glue/initClient"));
|
|
44
|
+
var initClient_3 = __importDefault(require("./aws/s3/initClient"));
|
|
45
|
+
var initClient_4 = __importDefault(require("./aws/ses/initClient"));
|
|
46
|
+
var initClient_5 = __importDefault(require("./aws/ssm/initClient"));
|
|
47
|
+
var initClient_6 = __importDefault(require("./googleAds/initClient"));
|
|
48
|
+
var initClient_7 = __importDefault(require("./prisma/initClient"));
|
|
45
49
|
/**
|
|
46
|
-
*
|
|
47
|
-
* Input: Must be an array of objects that are the same.
|
|
48
|
-
* Output: No array [] brackets, each object must on its own new line.
|
|
50
|
+
* Function to simplify initialising the clients.
|
|
49
51
|
*/
|
|
50
|
-
var
|
|
51
|
-
var
|
|
52
|
+
var initClients = function (_a) {
|
|
53
|
+
var athenaExpress = _a.athenaExpress, awsConfig = _a.awsConfig, awsGlue = _a.awsGlue, awsS3 = _a.awsS3, awsSes = _a.awsSes, awsSsm = _a.awsSsm, googleAds = _a.googleAds, prisma = _a.prisma;
|
|
52
54
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
53
|
-
var inputArray, stringRows, concatString;
|
|
54
55
|
return __generator(this, function (_b) {
|
|
55
56
|
switch (_b.label) {
|
|
56
57
|
case 0:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
if (undefined !== athenaExpress) {
|
|
59
|
+
(0, initClient_1.default)({
|
|
60
|
+
config: awsConfig,
|
|
61
|
+
database: athenaExpress.database,
|
|
62
|
+
s3Bucket: athenaExpress.s3Bucket,
|
|
63
|
+
s3Key: athenaExpress.s3Key,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
if (true === awsGlue) {
|
|
67
|
+
(0, initClient_2.default)({ config: awsConfig });
|
|
68
|
+
}
|
|
69
|
+
if (true === awsS3) {
|
|
70
|
+
(0, initClient_3.default)({ config: awsConfig });
|
|
71
|
+
}
|
|
72
|
+
if (true === awsSes) {
|
|
73
|
+
(0, initClient_4.default)({ config: awsConfig });
|
|
74
|
+
}
|
|
75
|
+
if (true === awsSsm) {
|
|
76
|
+
(0, initClient_5.default)({ config: awsConfig });
|
|
77
|
+
}
|
|
78
|
+
if (!(undefined !== googleAds)) return [3 /*break*/, 2];
|
|
79
|
+
return [4 /*yield*/, (0, initClient_6.default)({
|
|
80
|
+
parameterName: googleAds.parameterName,
|
|
81
|
+
})];
|
|
82
|
+
case 1:
|
|
83
|
+
_b.sent();
|
|
84
|
+
_b.label = 2;
|
|
85
|
+
case 2:
|
|
86
|
+
if (undefined !== prisma) {
|
|
87
|
+
(0, initClient_7.default)({ debug: true === prisma ? false : prisma.debug || false });
|
|
88
|
+
}
|
|
89
|
+
return [2 /*return*/];
|
|
62
90
|
}
|
|
63
91
|
});
|
|
64
92
|
});
|
|
65
93
|
};
|
|
66
|
-
exports.
|
|
67
|
-
exports.default = exports.writeGlueJsonFile;
|
|
94
|
+
exports.default = initClients;
|
package/package.json
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
2
|
+
"name": "@8ms/helpers",
|
|
3
|
+
"license": "UNLICENSED",
|
|
4
|
+
"version": "1.1.60",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"
|
|
8
|
+
},
|
|
9
|
+
"main": "index.js",
|
|
10
|
+
"types": "index.d.ts",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "rimraf dist && tsc",
|
|
13
|
+
"jest": "jest --watch"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"axios": "0.27.2",
|
|
17
|
+
"crypto-js": "4.1.1",
|
|
18
|
+
"date-fns": "2.29.2",
|
|
19
|
+
"date-fns-tz": "1.3.6",
|
|
20
|
+
"lodash": "4.17.21"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@aws-sdk/client-s3": "3.157.0",
|
|
24
|
+
"@aws-sdk/client-ses": "3.154.0",
|
|
25
|
+
"@aws-sdk/client-ssm": "3.154.0",
|
|
26
|
+
"@aws-sdk/s3-request-presigner": "3.157.0",
|
|
27
|
+
"@babel/preset-env": "7.18.10",
|
|
28
|
+
"@babel/preset-flow": "7.18.6",
|
|
29
|
+
"@babel/preset-typescript": "7.18.6",
|
|
30
|
+
"@google-cloud/storage": "6.4.1",
|
|
31
|
+
"@prisma/client": "4.2.1",
|
|
32
|
+
"@types/jest": "28.1.8",
|
|
33
|
+
"@types/lodash": "4.14.184",
|
|
34
|
+
"@types/node": "18.7.13",
|
|
35
|
+
"babel-jest": "28.1.3",
|
|
36
|
+
"jest": "28.1.3",
|
|
37
|
+
"node-fetch": "3.2.10",
|
|
38
|
+
"numbro": "2.3.6",
|
|
39
|
+
"prisma-query-log": "3.2.0",
|
|
40
|
+
"timezone-mock": "1.3.4",
|
|
41
|
+
"ts-node": "10.9.1",
|
|
42
|
+
"tslib": "2.4.0",
|
|
43
|
+
"typescript": "4.7.4"
|
|
44
|
+
}
|
|
45
45
|
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
declare type WriteGlueJsonFile = {
|
|
2
|
-
bucket: string;
|
|
3
|
-
data: object[];
|
|
4
|
-
key: string;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Convert the object into a JSON file so it's ready to be used with AWS Glue.
|
|
8
|
-
* Input: Must be an array of objects that are the same.
|
|
9
|
-
* Output: No array [] brackets, each object must on its own new line.
|
|
10
|
-
*/
|
|
11
|
-
export declare const writeGlueJsonFile: ({ bucket, data, key }: WriteGlueJsonFile) => Promise<any>;
|
|
12
|
-
export default writeGlueJsonFile;
|