@8ms/helpers 2.4.10 → 2.4.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/_class/BaseClass.cjs +31 -21
- package/dist/_class/BaseClass.mjs +31 -21
- package/dist/_class/BaseNamespace.cjs +10 -9
- package/dist/_class/BaseNamespace.mjs +10 -9
- package/dist/api/ApiResponseClass.cjs +96 -96
- package/dist/api/ApiResponseClass.mjs +96 -96
- package/dist/aws/cloudWatchLog/server/AwsCloudWatchLogNamespace.cjs +70 -60
- package/dist/aws/cloudWatchLog/server/AwsCloudWatchLogNamespace.mjs +70 -60
- package/dist/aws/cloudWatchMetric/server/AwsCloudWatchMetricNamespace.cjs +30 -28
- package/dist/aws/cloudWatchMetric/server/AwsCloudWatchMetricNamespace.mjs +30 -28
- package/dist/aws/ec2/server/AwsEc2Namespace.cjs +29 -32
- package/dist/aws/ec2/server/AwsEc2Namespace.mjs +29 -32
- package/dist/aws/ecs/server/AwsEcsNamespace.cjs +92 -78
- package/dist/aws/ecs/server/AwsEcsNamespace.mjs +92 -78
- package/dist/aws/glue/server/AwsGlueNamespace.cjs +17 -17
- package/dist/aws/glue/server/AwsGlueNamespace.mjs +17 -17
- package/dist/aws/lambda/server/AwsLambdaNamespace.cjs +33 -31
- package/dist/aws/lambda/server/AwsLambdaNamespace.mjs +33 -31
- package/dist/aws/s3/server/AwsS3Namespace.cjs +280 -265
- package/dist/aws/s3/server/AwsS3Namespace.mjs +280 -265
- package/dist/aws/ses/server/AwsSesNamespace.cjs +27 -30
- package/dist/aws/ses/server/AwsSesNamespace.mjs +27 -30
- package/dist/aws/ses/server/SimpleEmail.cjs +202 -199
- package/dist/aws/ses/server/SimpleEmail.mjs +202 -199
- package/dist/aws/sqs/server/AwsSqsNamespace.cjs +35 -38
- package/dist/aws/sqs/server/AwsSqsNamespace.mjs +35 -38
- package/dist/aws/ssm/server/AwsSsmNamespace.cjs +24 -23
- package/dist/aws/ssm/server/AwsSsmNamespace.mjs +24 -23
- package/dist/date/index.cjs +1 -1
- package/dist/date/index.mjs +1 -1
- package/dist/drizzle/server/DrizzleNamespace.cjs +39 -42
- package/dist/drizzle/server/DrizzleNamespace.mjs +39 -42
- package/dist/googleAds/server/GoogleAdsNamespace.cjs +21 -24
- package/dist/googleAds/server/GoogleAdsNamespace.mjs +21 -24
- package/dist/googleCloud/bigquery/server/GoogleCloudBigqueryNamespace.cjs +86 -70
- package/dist/googleCloud/bigquery/server/GoogleCloudBigqueryNamespace.mjs +86 -70
- package/dist/googleCloud/sheets/server/GoogleCloudSheetsNamespace.cjs +22 -25
- package/dist/googleCloud/sheets/server/GoogleCloudSheetsNamespace.mjs +22 -25
- package/dist/googleCloud/storage/server/GoogleCloudStorageNamespace.cjs +44 -38
- package/dist/googleCloud/storage/server/GoogleCloudStorageNamespace.mjs +44 -38
- package/dist/googlePageSpeed/server/GooglePageSpeedNamespace.cjs +12 -15
- package/dist/googlePageSpeed/server/GooglePageSpeedNamespace.mjs +12 -15
- package/dist/littleWarden/server/LittleWardenNamespace.cjs +12 -15
- package/dist/littleWarden/server/LittleWardenNamespace.mjs +12 -15
- package/dist/onePassword/server/OnePasswordNamespace.cjs +30 -33
- package/dist/onePassword/server/OnePasswordNamespace.mjs +30 -33
- package/dist/openAi/server/OpenAiNamespace.cjs +20 -20
- package/dist/openAi/server/OpenAiNamespace.mjs +20 -20
- package/dist/prisma/server/PrismaNamespace.cjs +35 -38
- package/dist/prisma/server/PrismaNamespace.mjs +35 -38
- package/dist/snapchat/server/SnapchatNamespace.cjs +12 -12
- package/dist/snapchat/server/SnapchatNamespace.mjs +12 -12
- package/dist/upTimeRobot/server/UpTimeRobotNamespace.cjs +19 -19
- package/dist/upTimeRobot/server/UpTimeRobotNamespace.mjs +19 -19
- package/package.json +1 -1
|
@@ -3,76 +3,92 @@ import { BaseNamespace } from "../../../_class/BaseNamespace.mjs";
|
|
|
3
3
|
import { getConfig } from "../../server/googleCloud.mjs";
|
|
4
4
|
//#region src/googleCloud/bigquery/server/GoogleCloudBigqueryNamespace.ts
|
|
5
5
|
var GoogleCloudBigqueryNamespace = class extends BaseNamespace {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
this.datasetExists
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
this.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
this.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
this.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
6
|
+
ensureInit = async () => {
|
|
7
|
+
if (!this.client) try {
|
|
8
|
+
const { BigQuery } = await import("@google-cloud/bigquery");
|
|
9
|
+
this.client = new BigQuery(getConfig(this.config, this.config?.projectId));
|
|
10
|
+
} catch (e) {
|
|
11
|
+
throw new Error("Google BigQuery Client not installed");
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Create a Dataset if it doesn't already exist.
|
|
16
|
+
* Returns table instance.
|
|
17
|
+
*/
|
|
18
|
+
createDataset = async (datasetId, options = {}) => {
|
|
19
|
+
await this.ensureInit();
|
|
20
|
+
if (!await this.datasetExists(datasetId)) await this.client.createDataset(datasetId);
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Check to see whether a given Bigquery dataset exists.
|
|
24
|
+
* Based off:
|
|
25
|
+
* https://github.com/googleapis/nodejs-bigquery/blob/main/samples/getDataset.js
|
|
26
|
+
*/
|
|
27
|
+
datasetExists = async (datasetId) => {
|
|
28
|
+
await this.ensureInit();
|
|
29
|
+
let response;
|
|
30
|
+
try {
|
|
31
|
+
await this.client.dataset(datasetId).get();
|
|
32
|
+
response = true;
|
|
33
|
+
} catch (exception) {
|
|
34
|
+
response = false;
|
|
35
|
+
}
|
|
36
|
+
return response;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Retrieve all the Datasets
|
|
40
|
+
*/
|
|
41
|
+
getDatasets = async () => {
|
|
42
|
+
await this.ensureInit();
|
|
43
|
+
let response = [];
|
|
44
|
+
const datasets = await this.client.getDatasets();
|
|
45
|
+
if (datasets?.[0]) for (let i = 0; i < datasets[0].length; i++) response.push({
|
|
46
|
+
id: datasets[0][i].id,
|
|
47
|
+
location: datasets[0][i].location,
|
|
48
|
+
projectId: datasets[0][i].bigQuery.projectId
|
|
49
|
+
});
|
|
50
|
+
return response;
|
|
51
|
+
};
|
|
52
|
+
query = async (props) => {
|
|
53
|
+
await this.ensureInit();
|
|
54
|
+
let options = { query: "" };
|
|
55
|
+
if ("string" === typeof props) options.query = props;
|
|
56
|
+
else if (isObject(props)) {
|
|
57
|
+
options.query = props.query;
|
|
58
|
+
if (props?.location) options["location"] = props.location;
|
|
59
|
+
if (props?.params) options["params"] = props.params;
|
|
60
|
+
}
|
|
61
|
+
return await this.client.query(options);
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Create a Table if it doesn't already exist.
|
|
65
|
+
*/
|
|
66
|
+
createTable = async (datasetId, datasetOptions = {}, tableId, options = {}) => {
|
|
67
|
+
await this.ensureInit();
|
|
68
|
+
await this.createDataset(datasetId, datasetOptions);
|
|
69
|
+
if (!await this.tableExists(datasetId, tableId)) await this.client.dataset(datasetId).createTable(tableId, options || {});
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Check to see whether a given BigQuery table exists.
|
|
73
|
+
* https://cloud.google.com/bigquery/docs/samples/bigquery-table-exists
|
|
74
|
+
*/
|
|
75
|
+
tableExists = async (datasetId, tableId) => {
|
|
76
|
+
await this.ensureInit();
|
|
77
|
+
let response = false;
|
|
78
|
+
const tables = await this.getTables(datasetId);
|
|
79
|
+
for (let i = 0; i < tables.length; i++) if (tables[i].id === tableId) {
|
|
80
|
+
response = true;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
return response;
|
|
84
|
+
};
|
|
85
|
+
getTables = async (datasetId) => {
|
|
86
|
+
await this.ensureInit();
|
|
87
|
+
let response = [];
|
|
88
|
+
const tables = await this.client.dataset(datasetId).getTables();
|
|
89
|
+
if (tables?.[0]) for (let i = 0; i < tables[0].length; i++) response.push({ id: tables[0][i].id });
|
|
90
|
+
return response;
|
|
91
|
+
};
|
|
76
92
|
};
|
|
77
93
|
//#endregion
|
|
78
94
|
export { GoogleCloudBigqueryNamespace };
|
|
@@ -3,31 +3,28 @@ const require__class_BaseNamespace = require("../../../_class/BaseNamespace.cjs"
|
|
|
3
3
|
const require_googleCloud_server_googleCloud = require("../../server/googleCloud.cjs");
|
|
4
4
|
//#region src/googleCloud/sheets/server/GoogleCloudSheetsNamespace.ts
|
|
5
5
|
var GoogleCloudSheetsNamespace = class extends require__class_BaseNamespace.BaseNamespace {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
})).data;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
6
|
+
ensureInit = async () => {
|
|
7
|
+
if (!this.client) try {
|
|
8
|
+
const googleApisSheets = await import("@googleapis/sheets");
|
|
9
|
+
const formattedConfig = require_googleCloud_server_googleCloud.getConfig(this.config, this.config?.projectId);
|
|
10
|
+
this.client = new googleApisSheets.auth.GoogleAuth({
|
|
11
|
+
...formattedConfig,
|
|
12
|
+
scopes: ["https://www.googleapis.com/auth/spreadsheets"]
|
|
13
|
+
});
|
|
14
|
+
} catch (e) {
|
|
15
|
+
throw new Error("Google Sheets Client not installed");
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
getBatchData = async (props) => {
|
|
19
|
+
await this.ensureInit();
|
|
20
|
+
return (await (await import("@googleapis/sheets")).sheets("v4").spreadsheets.values.batchGet({
|
|
21
|
+
auth: this.client,
|
|
22
|
+
dateTimeRenderOption: props?.dateTimeRender || "FORMATTED_STRING",
|
|
23
|
+
ranges: props.ranges,
|
|
24
|
+
spreadsheetId: props.spreadsheetId,
|
|
25
|
+
valueRenderOption: props?.valueRender || "UNFORMATTED_VALUE"
|
|
26
|
+
})).data;
|
|
27
|
+
};
|
|
31
28
|
};
|
|
32
29
|
//#endregion
|
|
33
30
|
exports.GoogleCloudSheetsNamespace = GoogleCloudSheetsNamespace;
|
|
@@ -2,31 +2,28 @@ import { BaseNamespace } from "../../../_class/BaseNamespace.mjs";
|
|
|
2
2
|
import { getConfig } from "../../server/googleCloud.mjs";
|
|
3
3
|
//#region src/googleCloud/sheets/server/GoogleCloudSheetsNamespace.ts
|
|
4
4
|
var GoogleCloudSheetsNamespace = class extends BaseNamespace {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
})).data;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
5
|
+
ensureInit = async () => {
|
|
6
|
+
if (!this.client) try {
|
|
7
|
+
const googleApisSheets = await import("@googleapis/sheets");
|
|
8
|
+
const formattedConfig = getConfig(this.config, this.config?.projectId);
|
|
9
|
+
this.client = new googleApisSheets.auth.GoogleAuth({
|
|
10
|
+
...formattedConfig,
|
|
11
|
+
scopes: ["https://www.googleapis.com/auth/spreadsheets"]
|
|
12
|
+
});
|
|
13
|
+
} catch (e) {
|
|
14
|
+
throw new Error("Google Sheets Client not installed");
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
getBatchData = async (props) => {
|
|
18
|
+
await this.ensureInit();
|
|
19
|
+
return (await (await import("@googleapis/sheets")).sheets("v4").spreadsheets.values.batchGet({
|
|
20
|
+
auth: this.client,
|
|
21
|
+
dateTimeRenderOption: props?.dateTimeRender || "FORMATTED_STRING",
|
|
22
|
+
ranges: props.ranges,
|
|
23
|
+
spreadsheetId: props.spreadsheetId,
|
|
24
|
+
valueRenderOption: props?.valueRender || "UNFORMATTED_VALUE"
|
|
25
|
+
})).data;
|
|
26
|
+
};
|
|
30
27
|
};
|
|
31
28
|
//#endregion
|
|
32
29
|
export { GoogleCloudSheetsNamespace };
|
|
@@ -3,45 +3,51 @@ const require__class_BaseNamespace = require("../../../_class/BaseNamespace.cjs"
|
|
|
3
3
|
const require_googleCloud_server_googleCloud = require("../../server/googleCloud.cjs");
|
|
4
4
|
//#region src/googleCloud/storage/server/GoogleCloudStorageNamespace.ts
|
|
5
5
|
var GoogleCloudStorageNamespace = class extends require__class_BaseNamespace.BaseNamespace {
|
|
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
|
-
|
|
6
|
+
ensureInit = async () => {
|
|
7
|
+
if (!this.client) try {
|
|
8
|
+
const { Storage } = await import("@google-cloud/storage");
|
|
9
|
+
this.client = new Storage(require_googleCloud_server_googleCloud.getConfig(this.config, this.config?.projectId));
|
|
10
|
+
} catch (e) {
|
|
11
|
+
throw new Error("Google Cloud Storage Client not installed");
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Copy a local file to Google Cloud Storage.
|
|
16
|
+
*/
|
|
17
|
+
copyToCloud = async (bucket, localFile, options = {}) => {
|
|
18
|
+
await this.ensureInit();
|
|
19
|
+
return await this.client.bucket(bucket).upload(localFile, options);
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Check to see if a file exists but don't get the contents.
|
|
23
|
+
*/
|
|
24
|
+
fileExists = async (bucket, key) => {
|
|
25
|
+
await this.ensureInit();
|
|
26
|
+
return (await this.client.bucket(bucket).file(key).exists())?.[0];
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Write a file to Google Cloud Storage.
|
|
30
|
+
*/
|
|
31
|
+
writeFile = async (bucket, key, data, options = {}) => {
|
|
32
|
+
await this.ensureInit();
|
|
33
|
+
const dataStream = new (await (import("stream"))).PassThrough();
|
|
34
|
+
const googleFile = this.client.bucket(bucket).file(key);
|
|
35
|
+
dataStream.push(data);
|
|
36
|
+
dataStream.push(null);
|
|
37
|
+
return await new Promise((resolve, reject) => {
|
|
38
|
+
dataStream.pipe(googleFile.createWriteStream({
|
|
39
|
+
contentType: "auto",
|
|
40
|
+
resumable: false,
|
|
41
|
+
validation: false,
|
|
42
|
+
metadata: {},
|
|
43
|
+
...options
|
|
44
|
+
})).on("error", (error) => {
|
|
45
|
+
reject(error);
|
|
46
|
+
}).on("finish", () => {
|
|
47
|
+
resolve(true);
|
|
42
48
|
});
|
|
43
|
-
};
|
|
44
|
-
}
|
|
49
|
+
});
|
|
50
|
+
};
|
|
45
51
|
};
|
|
46
52
|
//#endregion
|
|
47
53
|
exports.GoogleCloudStorageNamespace = GoogleCloudStorageNamespace;
|
|
@@ -2,45 +2,51 @@ import { BaseNamespace } from "../../../_class/BaseNamespace.mjs";
|
|
|
2
2
|
import { getConfig } from "../../server/googleCloud.mjs";
|
|
3
3
|
//#region src/googleCloud/storage/server/GoogleCloudStorageNamespace.ts
|
|
4
4
|
var GoogleCloudStorageNamespace = class extends BaseNamespace {
|
|
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
|
-
|
|
5
|
+
ensureInit = async () => {
|
|
6
|
+
if (!this.client) try {
|
|
7
|
+
const { Storage } = await import("@google-cloud/storage");
|
|
8
|
+
this.client = new Storage(getConfig(this.config, this.config?.projectId));
|
|
9
|
+
} catch (e) {
|
|
10
|
+
throw new Error("Google Cloud Storage Client not installed");
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Copy a local file to Google Cloud Storage.
|
|
15
|
+
*/
|
|
16
|
+
copyToCloud = async (bucket, localFile, options = {}) => {
|
|
17
|
+
await this.ensureInit();
|
|
18
|
+
return await this.client.bucket(bucket).upload(localFile, options);
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Check to see if a file exists but don't get the contents.
|
|
22
|
+
*/
|
|
23
|
+
fileExists = async (bucket, key) => {
|
|
24
|
+
await this.ensureInit();
|
|
25
|
+
return (await this.client.bucket(bucket).file(key).exists())?.[0];
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Write a file to Google Cloud Storage.
|
|
29
|
+
*/
|
|
30
|
+
writeFile = async (bucket, key, data, options = {}) => {
|
|
31
|
+
await this.ensureInit();
|
|
32
|
+
const dataStream = new (await (import("stream"))).PassThrough();
|
|
33
|
+
const googleFile = this.client.bucket(bucket).file(key);
|
|
34
|
+
dataStream.push(data);
|
|
35
|
+
dataStream.push(null);
|
|
36
|
+
return await new Promise((resolve, reject) => {
|
|
37
|
+
dataStream.pipe(googleFile.createWriteStream({
|
|
38
|
+
contentType: "auto",
|
|
39
|
+
resumable: false,
|
|
40
|
+
validation: false,
|
|
41
|
+
metadata: {},
|
|
42
|
+
...options
|
|
43
|
+
})).on("error", (error) => {
|
|
44
|
+
reject(error);
|
|
45
|
+
}).on("finish", () => {
|
|
46
|
+
resolve(true);
|
|
41
47
|
});
|
|
42
|
-
};
|
|
43
|
-
}
|
|
48
|
+
});
|
|
49
|
+
};
|
|
44
50
|
};
|
|
45
51
|
//#endregion
|
|
46
52
|
export { GoogleCloudStorageNamespace };
|
|
@@ -8,21 +8,18 @@ require("./index.cjs");
|
|
|
8
8
|
* Based on https://developers.google.com/speed/docs/insights/rest/v5/pagespeedapi/runpagespeed
|
|
9
9
|
*/
|
|
10
10
|
var GooglePageSpeedNamespace = class extends require__class_BaseNamespace.BaseNamespace {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return null;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
11
|
+
ensureInit = async () => {
|
|
12
|
+
if (!this.client) try {
|
|
13
|
+
this.client = true;
|
|
14
|
+
} catch (e) {
|
|
15
|
+
throw new Error("Google PageSpeed Client not installed");
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
getReport = async (url, inputCategory = require_googlePageSpeed_server_googlePageSpeed.category.PERFORMANCE, inputStrategy = require_googlePageSpeed_server_googlePageSpeed.strategy.MOBILE) => {
|
|
19
|
+
const apiResponse = await require_api_get.get(`https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=${url}&strategy=${inputStrategy}&category=${inputCategory}&key=${this.config.apiKey}`);
|
|
20
|
+
if (apiResponse.isSuccess()) return apiResponse.getBody();
|
|
21
|
+
return null;
|
|
22
|
+
};
|
|
26
23
|
};
|
|
27
24
|
//#endregion
|
|
28
25
|
exports.GooglePageSpeedNamespace = GooglePageSpeedNamespace;
|
|
@@ -7,21 +7,18 @@ import "./index.mjs";
|
|
|
7
7
|
* Based on https://developers.google.com/speed/docs/insights/rest/v5/pagespeedapi/runpagespeed
|
|
8
8
|
*/
|
|
9
9
|
var GooglePageSpeedNamespace = class extends BaseNamespace {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return null;
|
|
23
|
-
};
|
|
24
|
-
}
|
|
10
|
+
ensureInit = async () => {
|
|
11
|
+
if (!this.client) try {
|
|
12
|
+
this.client = true;
|
|
13
|
+
} catch (e) {
|
|
14
|
+
throw new Error("Google PageSpeed Client not installed");
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
getReport = async (url, inputCategory = category.PERFORMANCE, inputStrategy = strategy.MOBILE) => {
|
|
18
|
+
const apiResponse = await get(`https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=${url}&strategy=${inputStrategy}&category=${inputCategory}&key=${this.config.apiKey}`);
|
|
19
|
+
if (apiResponse.isSuccess()) return apiResponse.getBody();
|
|
20
|
+
return null;
|
|
21
|
+
};
|
|
25
22
|
};
|
|
26
23
|
//#endregion
|
|
27
24
|
export { GooglePageSpeedNamespace };
|
|
@@ -6,21 +6,18 @@ const require_api_get = require("../../api/get.cjs");
|
|
|
6
6
|
* Based on https://developers.google.com/speed/docs/insights/rest/v5/pagespeedapi/runpagespeed
|
|
7
7
|
*/
|
|
8
8
|
var LittleWardenNamespace = class extends require__class_BaseNamespace.BaseNamespace {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return null;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
9
|
+
ensureInit = async () => {
|
|
10
|
+
if (!this.client) try {
|
|
11
|
+
this.client = true;
|
|
12
|
+
} catch (e) {
|
|
13
|
+
throw new Error("Google PageSpeed Client not installed");
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
getReport = async (urlId) => {
|
|
17
|
+
const apiResponse = await require_api_get.get(`https://littlewarden.com/api/sites/${urlId}`, { headers: { "Authorization": `Token token="${this.config.apiKey}"` } });
|
|
18
|
+
if (apiResponse.isSuccess()) return apiResponse.getBody();
|
|
19
|
+
return null;
|
|
20
|
+
};
|
|
24
21
|
};
|
|
25
22
|
//#endregion
|
|
26
23
|
exports.LittleWardenNamespace = LittleWardenNamespace;
|
|
@@ -5,21 +5,18 @@ import { get } from "../../api/get.mjs";
|
|
|
5
5
|
* Based on https://developers.google.com/speed/docs/insights/rest/v5/pagespeedapi/runpagespeed
|
|
6
6
|
*/
|
|
7
7
|
var LittleWardenNamespace = class extends BaseNamespace {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return null;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
8
|
+
ensureInit = async () => {
|
|
9
|
+
if (!this.client) try {
|
|
10
|
+
this.client = true;
|
|
11
|
+
} catch (e) {
|
|
12
|
+
throw new Error("Google PageSpeed Client not installed");
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
getReport = async (urlId) => {
|
|
16
|
+
const apiResponse = await get(`https://littlewarden.com/api/sites/${urlId}`, { headers: { "Authorization": `Token token="${this.config.apiKey}"` } });
|
|
17
|
+
if (apiResponse.isSuccess()) return apiResponse.getBody();
|
|
18
|
+
return null;
|
|
19
|
+
};
|
|
23
20
|
};
|
|
24
21
|
//#endregion
|
|
25
22
|
export { LittleWardenNamespace };
|