@8ms/helpers 1.3.7 → 1.3.8
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/api/isError.d.ts +2 -2
- package/aws/s3/getGlueJson.d.ts +3 -0
- package/aws/s3/getGlueJson.js +5 -9
- package/google/bigQuery/getDatasets.d.ts +13 -0
- package/google/bigQuery/getDatasets.js +27 -0
- package/google/bigQuery/loadData.d.ts +1 -0
- package/google/bigQuery/loadData.js +6 -3
- package/initClients.d.ts +3 -3
- package/initClients.js +17 -13
- package/json/getJsonNewline.d.ts +5 -0
- package/json/getJsonNewline.js +17 -0
- package/{deepcrawl → lumar}/api/initClient.d.ts +1 -1
- package/{deepcrawl → lumar}/api/initClient.js +4 -4
- package/{deepcrawl → lumar}/graphql/getData.js +2 -2
- package/{deepcrawl → lumar}/graphql/initClient.d.ts +2 -2
- package/{deepcrawl → lumar}/graphql/initClient.js +7 -7
- package/package.json +1 -1
- /package/{deepcrawl → lumar}/api/buildRequest.d.ts +0 -0
- /package/{deepcrawl → lumar}/api/buildRequest.js +0 -0
- /package/{deepcrawl → lumar}/api/filter.d.ts +0 -0
- /package/{deepcrawl → lumar}/api/filter.js +0 -0
- /package/{deepcrawl → lumar}/api/getData.d.ts +0 -0
- /package/{deepcrawl → lumar}/api/getData.js +0 -0
- /package/{deepcrawl → lumar}/api/operands.d.ts +0 -0
- /package/{deepcrawl → lumar}/api/operands.js +0 -0
- /package/{deepcrawl → lumar}/api/orders.d.ts +0 -0
- /package/{deepcrawl → lumar}/api/orders.js +0 -0
- /package/{deepcrawl → lumar}/api/reports.d.ts +0 -0
- /package/{deepcrawl → lumar}/api/reports.js +0 -0
- /package/{deepcrawl → lumar}/graphql/columns.d.ts +0 -0
- /package/{deepcrawl → lumar}/graphql/columns.js +0 -0
- /package/{deepcrawl → lumar}/graphql/getData.d.ts +0 -0
- /package/{deepcrawl → lumar}/graphql/getReportKey.d.ts +0 -0
- /package/{deepcrawl → lumar}/graphql/getReportKey.js +0 -0
- /package/{deepcrawl → lumar}/graphql/operands.d.ts +0 -0
- /package/{deepcrawl → lumar}/graphql/operands.js +0 -0
- /package/{deepcrawl → lumar}/graphql/queries/crawl.d.ts +0 -0
- /package/{deepcrawl → lumar}/graphql/queries/crawl.js +0 -0
- /package/{deepcrawl → lumar}/graphql/queries/getCrawls.d.ts +0 -0
- /package/{deepcrawl → lumar}/graphql/queries/getCrawls.js +0 -0
- /package/{deepcrawl → lumar}/graphql/queries/getReportDifferences.d.ts +0 -0
- /package/{deepcrawl → lumar}/graphql/queries/getReportDifferences.js +0 -0
- /package/{deepcrawl → lumar}/graphql/queries/getRows.d.ts +0 -0
- /package/{deepcrawl → lumar}/graphql/queries/getRows.js +0 -0
- /package/{deepcrawl → lumar}/graphql/queries/getTotals.d.ts +0 -0
- /package/{deepcrawl → lumar}/graphql/queries/getTotals.js +0 -0
- /package/{deepcrawl → lumar}/graphql/queries/row.d.ts +0 -0
- /package/{deepcrawl → lumar}/graphql/queries/row.js +0 -0
- /package/{deepcrawl → lumar}/graphql/reportTemplates.d.ts +0 -0
- /package/{deepcrawl → lumar}/graphql/reportTemplates.js +0 -0
- /package/{deepcrawl → lumar}/graphql/reportTypes.d.ts +0 -0
- /package/{deepcrawl → lumar}/graphql/reportTypes.js +0 -0
package/api/isError.d.ts
CHANGED
package/aws/s3/getGlueJson.d.ts
CHANGED
package/aws/s3/getGlueJson.js
CHANGED
|
@@ -3,13 +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
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const stringRows = inputArray.map(row => JSON.stringify(row));
|
|
12
|
-
// Combine each row with a line separator
|
|
13
|
-
return stringRows.join("\n");
|
|
14
|
-
};
|
|
6
|
+
const getJsonNewline_1 = __importDefault(require("../../json/getJsonNewline"));
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated in favour of getJsonNewline
|
|
9
|
+
*/
|
|
10
|
+
const getGlueJson = ({ data }) => (0, getJsonNewline_1.default)({ data });
|
|
15
11
|
exports.default = getGlueJson;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type GetDatasets = {
|
|
2
|
+
projectId?: string;
|
|
3
|
+
};
|
|
4
|
+
type Datasets = {
|
|
5
|
+
id: string;
|
|
6
|
+
location: string;
|
|
7
|
+
projectId: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Retrieve all the Datasets from a given Project.
|
|
11
|
+
*/
|
|
12
|
+
declare const getDatasets: ({ projectId }: GetDatasets) => Promise<Datasets[]>;
|
|
13
|
+
export default getDatasets;
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
const getClient_1 = __importDefault(require("./getClient"));
|
|
7
|
+
/**
|
|
8
|
+
* Retrieve all the Datasets from a given Project.
|
|
9
|
+
*/
|
|
10
|
+
const getDatasets = async ({ projectId }) => {
|
|
11
|
+
let response = [];
|
|
12
|
+
const client = (0, getClient_1.default)({
|
|
13
|
+
projectId,
|
|
14
|
+
});
|
|
15
|
+
const datasets = await client.getDatasets();
|
|
16
|
+
if (datasets?.[0]) {
|
|
17
|
+
for (let i = 0; i < datasets[0].length; i++) {
|
|
18
|
+
response.push({
|
|
19
|
+
id: datasets[0][i].id,
|
|
20
|
+
location: datasets[0][i].location,
|
|
21
|
+
projectId: datasets[0][i].bigQuery.projectId,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return response;
|
|
26
|
+
};
|
|
27
|
+
exports.default = getDatasets;
|
|
@@ -15,13 +15,16 @@ const loadData = async ({ file, table }) => {
|
|
|
15
15
|
tableId: table.tableId,
|
|
16
16
|
});
|
|
17
17
|
if (tableExists) {
|
|
18
|
-
let
|
|
18
|
+
let bigqueryClient = (0, getClient_1.default)({
|
|
19
19
|
projectId: table.projectId
|
|
20
20
|
});
|
|
21
|
-
|
|
21
|
+
let storageClient = (0, getClient_1.default)({
|
|
22
|
+
projectId: file.projectId
|
|
23
|
+
});
|
|
24
|
+
await bigqueryClient
|
|
22
25
|
.dataset(table.datasetId)
|
|
23
26
|
.table(table.tableId)
|
|
24
|
-
.load(
|
|
27
|
+
.load(storageClient.bucket(file.bucket)
|
|
25
28
|
.file(file.key), file.metadata);
|
|
26
29
|
}
|
|
27
30
|
};
|
package/initClients.d.ts
CHANGED
|
@@ -11,10 +11,10 @@ type InitClients = {
|
|
|
11
11
|
awsS3?: boolean;
|
|
12
12
|
awsSes?: boolean;
|
|
13
13
|
awsSsm?: boolean;
|
|
14
|
-
|
|
14
|
+
lumarApi?: {
|
|
15
15
|
parameterName: string;
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
lumarGraphql?: {
|
|
18
18
|
parameterName: string;
|
|
19
19
|
};
|
|
20
20
|
eskimi?: boolean;
|
|
@@ -36,5 +36,5 @@ type InitClients = {
|
|
|
36
36
|
/**
|
|
37
37
|
* Function to simplify initialising the clients.
|
|
38
38
|
*/
|
|
39
|
-
declare const initClients: ({ athenaExpress, awsConfig, awsGlue, awsLambda, awsS3, awsSes, awsSsm,
|
|
39
|
+
declare const initClients: ({ athenaExpress, awsConfig, awsGlue, awsLambda, awsS3, awsSes, awsSsm, lumarApi, lumarGraphql, googleAds, googleConfig, googleBigQuery, googleSheets, googleStorage, prisma, }: InitClients) => Promise<void>;
|
|
40
40
|
export default initClients;
|
package/initClients.js
CHANGED
|
@@ -10,8 +10,8 @@ const initClient_4 = __importDefault(require("./aws/s3/initClient"));
|
|
|
10
10
|
const initClient_5 = __importDefault(require("./aws/ses/initClient"));
|
|
11
11
|
const getParameter_1 = __importDefault(require("./aws/ssm/getParameter"));
|
|
12
12
|
const initClient_6 = __importDefault(require("./aws/ssm/initClient"));
|
|
13
|
-
const initClient_7 = __importDefault(require("./
|
|
14
|
-
const initClient_8 = __importDefault(require("./
|
|
13
|
+
const initClient_7 = __importDefault(require("./lumar/api/initClient"));
|
|
14
|
+
const initClient_8 = __importDefault(require("./lumar/graphql/initClient"));
|
|
15
15
|
const initClient_9 = __importDefault(require("./google/bigQuery/initClient"));
|
|
16
16
|
const initClient_10 = __importDefault(require("./google/sheets/initClient"));
|
|
17
17
|
const initClient_11 = __importDefault(require("./google/storage/initClient"));
|
|
@@ -20,7 +20,7 @@ const initClient_13 = __importDefault(require("./prisma/initClient"));
|
|
|
20
20
|
/**
|
|
21
21
|
* Function to simplify initialising the clients.
|
|
22
22
|
*/
|
|
23
|
-
const initClients = async ({ athenaExpress, awsConfig, awsGlue, awsLambda, awsS3, awsSes, awsSsm,
|
|
23
|
+
const initClients = async ({ athenaExpress, awsConfig, awsGlue, awsLambda, awsS3, awsSes, awsSsm, lumarApi, lumarGraphql, googleAds, googleConfig, googleBigQuery, googleSheets, googleStorage, prisma, }) => {
|
|
24
24
|
if (athenaExpress) {
|
|
25
25
|
(0, initClient_1.default)({
|
|
26
26
|
config: awsConfig,
|
|
@@ -54,19 +54,23 @@ const initClients = async ({ athenaExpress, awsConfig, awsGlue, awsLambda, awsS3
|
|
|
54
54
|
config: awsConfig,
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
//
|
|
58
|
-
if (
|
|
59
|
-
const
|
|
60
|
-
name:
|
|
57
|
+
// Lumar (API) authentication using SSM Parameter
|
|
58
|
+
if (lumarApi) {
|
|
59
|
+
const lumarApiParameter = await (0, getParameter_1.default)({
|
|
60
|
+
name: lumarApi.parameterName,
|
|
61
|
+
});
|
|
62
|
+
await (0, initClient_7.default)({
|
|
63
|
+
auth: lumarApiParameter
|
|
61
64
|
});
|
|
62
|
-
await (0, initClient_7.default)({ auth: deepcrawlApiParameter });
|
|
63
65
|
}
|
|
64
|
-
//
|
|
65
|
-
if (
|
|
66
|
-
const
|
|
67
|
-
name:
|
|
66
|
+
// Lumar (GraphQL) authentication using SSM Parameter
|
|
67
|
+
if (lumarGraphql) {
|
|
68
|
+
const lumarGraphqlParameter = await (0, getParameter_1.default)({
|
|
69
|
+
name: lumarGraphql.parameterName,
|
|
70
|
+
});
|
|
71
|
+
await (0, initClient_8.default)({
|
|
72
|
+
auth: lumarGraphqlParameter
|
|
68
73
|
});
|
|
69
|
-
await (0, initClient_8.default)({ auth: deepcrawlGraphqlParameter });
|
|
70
74
|
}
|
|
71
75
|
// Google authentication using SSM
|
|
72
76
|
if (googleConfig) {
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
const getArray_1 = __importDefault(require("../array/getArray"));
|
|
7
|
+
const GetJsonNewline = ({ data }) => {
|
|
8
|
+
// Must be an array
|
|
9
|
+
const inputArray = (0, getArray_1.default)({
|
|
10
|
+
input: data
|
|
11
|
+
});
|
|
12
|
+
// For each array row convert the row
|
|
13
|
+
const stringRows = inputArray.map(row => JSON.stringify(row));
|
|
14
|
+
// Combine each row with a line separator
|
|
15
|
+
return stringRows.join("\n");
|
|
16
|
+
};
|
|
17
|
+
exports.default = GetJsonNewline;
|
|
@@ -4,18 +4,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const post_1 = __importDefault(require("../../axios/post"));
|
|
7
|
-
global.
|
|
7
|
+
global.lumarApi = {
|
|
8
8
|
token: null,
|
|
9
9
|
updatedAt: null,
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
12
|
* http://api-docs.deepcrawl.com/
|
|
13
|
-
* Renew the
|
|
13
|
+
* Renew the Lumar user token.
|
|
14
14
|
* Token lasts for 6 hours.
|
|
15
15
|
*/
|
|
16
16
|
const initClient = async ({ auth }) => {
|
|
17
17
|
// todo: Or was more than 6 hours ago
|
|
18
|
-
if (null === global.
|
|
18
|
+
if (null === global.lumarApi.token) {
|
|
19
19
|
const apiResponse = await (0, post_1.default)({
|
|
20
20
|
config: {
|
|
21
21
|
auth: {
|
|
@@ -31,7 +31,7 @@ const initClient = async ({ auth }) => {
|
|
|
31
31
|
keys: ['token'],
|
|
32
32
|
});
|
|
33
33
|
if (token) {
|
|
34
|
-
global.
|
|
34
|
+
global.lumarApi.token = token;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
};
|
|
@@ -12,14 +12,14 @@ const getData = async ({ query, variables }) => {
|
|
|
12
12
|
const apiResponse = await (0, post_1.default)({
|
|
13
13
|
config: {
|
|
14
14
|
headers: {
|
|
15
|
-
'x-auth-token': global.
|
|
15
|
+
'x-auth-token': global.lumarGraphql.token,
|
|
16
16
|
},
|
|
17
17
|
},
|
|
18
18
|
data: {
|
|
19
19
|
query: queryClean,
|
|
20
20
|
variables,
|
|
21
21
|
},
|
|
22
|
-
url: 'https://
|
|
22
|
+
url: 'https://api.lumar.io/graphql',
|
|
23
23
|
});
|
|
24
24
|
return apiResponse;
|
|
25
25
|
};
|
|
@@ -5,8 +5,8 @@ type InitClient = {
|
|
|
5
5
|
};
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
|
-
* https://
|
|
9
|
-
* Renew the
|
|
8
|
+
* https://api-docs.lumar.io/graphql/explorer/
|
|
9
|
+
* Renew the Lumar user token.
|
|
10
10
|
*/
|
|
11
11
|
declare const initClient: ({ auth }: InitClient) => Promise<void>;
|
|
12
12
|
export default initClient;
|
|
@@ -4,17 +4,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const post_1 = __importDefault(require("../../axios/post"));
|
|
7
|
-
|
|
7
|
+
// Initialise
|
|
8
|
+
global.lumarGraphql = {
|
|
8
9
|
token: null,
|
|
9
10
|
updatedAt: null,
|
|
10
11
|
};
|
|
11
12
|
/**
|
|
12
|
-
* https://
|
|
13
|
-
* Renew the
|
|
13
|
+
* https://api-docs.lumar.io/graphql/explorer/
|
|
14
|
+
* Renew the Lumar user token.
|
|
14
15
|
*/
|
|
15
16
|
const initClient = async ({ auth }) => {
|
|
16
|
-
|
|
17
|
-
if (null === global.deepcrawlGraphql.token) {
|
|
17
|
+
if (null === global.lumarGraphql.token) {
|
|
18
18
|
const apiResponse = await (0, post_1.default)({
|
|
19
19
|
data: {
|
|
20
20
|
query: "mutation LoginWithUserKey($secret: String!, $userKeyId: ObjectID!) { createSessionUsingUserKey(input: {userKeyId: $userKeyId, secret: $secret}) { token }}",
|
|
@@ -23,7 +23,7 @@ const initClient = async ({ auth }) => {
|
|
|
23
23
|
secret: auth.secret,
|
|
24
24
|
},
|
|
25
25
|
},
|
|
26
|
-
url: `https://
|
|
26
|
+
url: `https://api.lumar.io/graphql`,
|
|
27
27
|
});
|
|
28
28
|
const token = apiResponse.getBodyDefaultTo({
|
|
29
29
|
defaultValue: null,
|
|
@@ -31,7 +31,7 @@ const initClient = async ({ auth }) => {
|
|
|
31
31
|
});
|
|
32
32
|
// Ensure the value exists
|
|
33
33
|
if (token) {
|
|
34
|
-
global.
|
|
34
|
+
global.lumarGraphql.token = token;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
};
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|