@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.
Files changed (55) hide show
  1. package/dist/_class/BaseClass.cjs +31 -21
  2. package/dist/_class/BaseClass.mjs +31 -21
  3. package/dist/_class/BaseNamespace.cjs +10 -9
  4. package/dist/_class/BaseNamespace.mjs +10 -9
  5. package/dist/api/ApiResponseClass.cjs +96 -96
  6. package/dist/api/ApiResponseClass.mjs +96 -96
  7. package/dist/aws/cloudWatchLog/server/AwsCloudWatchLogNamespace.cjs +70 -60
  8. package/dist/aws/cloudWatchLog/server/AwsCloudWatchLogNamespace.mjs +70 -60
  9. package/dist/aws/cloudWatchMetric/server/AwsCloudWatchMetricNamespace.cjs +30 -28
  10. package/dist/aws/cloudWatchMetric/server/AwsCloudWatchMetricNamespace.mjs +30 -28
  11. package/dist/aws/ec2/server/AwsEc2Namespace.cjs +29 -32
  12. package/dist/aws/ec2/server/AwsEc2Namespace.mjs +29 -32
  13. package/dist/aws/ecs/server/AwsEcsNamespace.cjs +92 -78
  14. package/dist/aws/ecs/server/AwsEcsNamespace.mjs +92 -78
  15. package/dist/aws/glue/server/AwsGlueNamespace.cjs +17 -17
  16. package/dist/aws/glue/server/AwsGlueNamespace.mjs +17 -17
  17. package/dist/aws/lambda/server/AwsLambdaNamespace.cjs +33 -31
  18. package/dist/aws/lambda/server/AwsLambdaNamespace.mjs +33 -31
  19. package/dist/aws/s3/server/AwsS3Namespace.cjs +280 -265
  20. package/dist/aws/s3/server/AwsS3Namespace.mjs +280 -265
  21. package/dist/aws/ses/server/AwsSesNamespace.cjs +27 -30
  22. package/dist/aws/ses/server/AwsSesNamespace.mjs +27 -30
  23. package/dist/aws/ses/server/SimpleEmail.cjs +202 -199
  24. package/dist/aws/ses/server/SimpleEmail.mjs +202 -199
  25. package/dist/aws/sqs/server/AwsSqsNamespace.cjs +35 -38
  26. package/dist/aws/sqs/server/AwsSqsNamespace.mjs +35 -38
  27. package/dist/aws/ssm/server/AwsSsmNamespace.cjs +24 -23
  28. package/dist/aws/ssm/server/AwsSsmNamespace.mjs +24 -23
  29. package/dist/date/index.cjs +1 -1
  30. package/dist/date/index.mjs +1 -1
  31. package/dist/drizzle/server/DrizzleNamespace.cjs +39 -42
  32. package/dist/drizzle/server/DrizzleNamespace.mjs +39 -42
  33. package/dist/googleAds/server/GoogleAdsNamespace.cjs +21 -24
  34. package/dist/googleAds/server/GoogleAdsNamespace.mjs +21 -24
  35. package/dist/googleCloud/bigquery/server/GoogleCloudBigqueryNamespace.cjs +86 -70
  36. package/dist/googleCloud/bigquery/server/GoogleCloudBigqueryNamespace.mjs +86 -70
  37. package/dist/googleCloud/sheets/server/GoogleCloudSheetsNamespace.cjs +22 -25
  38. package/dist/googleCloud/sheets/server/GoogleCloudSheetsNamespace.mjs +22 -25
  39. package/dist/googleCloud/storage/server/GoogleCloudStorageNamespace.cjs +44 -38
  40. package/dist/googleCloud/storage/server/GoogleCloudStorageNamespace.mjs +44 -38
  41. package/dist/googlePageSpeed/server/GooglePageSpeedNamespace.cjs +12 -15
  42. package/dist/googlePageSpeed/server/GooglePageSpeedNamespace.mjs +12 -15
  43. package/dist/littleWarden/server/LittleWardenNamespace.cjs +12 -15
  44. package/dist/littleWarden/server/LittleWardenNamespace.mjs +12 -15
  45. package/dist/onePassword/server/OnePasswordNamespace.cjs +30 -33
  46. package/dist/onePassword/server/OnePasswordNamespace.mjs +30 -33
  47. package/dist/openAi/server/OpenAiNamespace.cjs +20 -20
  48. package/dist/openAi/server/OpenAiNamespace.mjs +20 -20
  49. package/dist/prisma/server/PrismaNamespace.cjs +35 -38
  50. package/dist/prisma/server/PrismaNamespace.mjs +35 -38
  51. package/dist/snapchat/server/SnapchatNamespace.cjs +12 -12
  52. package/dist/snapchat/server/SnapchatNamespace.mjs +12 -12
  53. package/dist/upTimeRobot/server/UpTimeRobotNamespace.cjs +19 -19
  54. package/dist/upTimeRobot/server/UpTimeRobotNamespace.mjs +19 -19
  55. 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
- constructor(..._args) {
7
- super(..._args);
8
- this.ensureInit = async () => {
9
- if (!this.client) try {
10
- const { BigQuery } = await import("@google-cloud/bigquery");
11
- this.client = new BigQuery(getConfig(this.config, this.config?.projectId));
12
- } catch (e) {
13
- throw new Error("Google BigQuery Client not installed");
14
- }
15
- };
16
- this.createDataset = async (datasetId, options = {}) => {
17
- await this.ensureInit();
18
- if (!await this.datasetExists(datasetId)) await this.client.createDataset(datasetId);
19
- };
20
- this.datasetExists = async (datasetId) => {
21
- await this.ensureInit();
22
- let response;
23
- try {
24
- await this.client.dataset(datasetId).get();
25
- response = true;
26
- } catch (exception) {
27
- response = false;
28
- }
29
- return response;
30
- };
31
- this.getDatasets = async () => {
32
- await this.ensureInit();
33
- let response = [];
34
- const datasets = await this.client.getDatasets();
35
- if (datasets?.[0]) for (let i = 0; i < datasets[0].length; i++) response.push({
36
- id: datasets[0][i].id,
37
- location: datasets[0][i].location,
38
- projectId: datasets[0][i].bigQuery.projectId
39
- });
40
- return response;
41
- };
42
- this.query = async (props) => {
43
- await this.ensureInit();
44
- let options = { query: "" };
45
- if ("string" === typeof props) options.query = props;
46
- else if (isObject(props)) {
47
- options.query = props.query;
48
- if (props?.location) options["location"] = props.location;
49
- if (props?.params) options["params"] = props.params;
50
- }
51
- return await this.client.query(options);
52
- };
53
- this.createTable = async (datasetId, datasetOptions = {}, tableId, options = {}) => {
54
- await this.ensureInit();
55
- await this.createDataset(datasetId, datasetOptions);
56
- if (!await this.tableExists(datasetId, tableId)) await this.client.dataset(datasetId).createTable(tableId, options || {});
57
- };
58
- this.tableExists = async (datasetId, tableId) => {
59
- await this.ensureInit();
60
- let response = false;
61
- const tables = await this.getTables(datasetId);
62
- for (let i = 0; i < tables.length; i++) if (tables[i].id === tableId) {
63
- response = true;
64
- break;
65
- }
66
- return response;
67
- };
68
- this.getTables = async (datasetId) => {
69
- await this.ensureInit();
70
- let response = [];
71
- const tables = await this.client.dataset(datasetId).getTables();
72
- if (tables?.[0]) for (let i = 0; i < tables[0].length; i++) response.push({ id: tables[0][i].id });
73
- return response;
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
- constructor(..._args) {
7
- super(..._args);
8
- this.ensureInit = async () => {
9
- if (!this.client) try {
10
- const googleApisSheets = await import("@googleapis/sheets");
11
- const formattedConfig = require_googleCloud_server_googleCloud.getConfig(this.config, this.config?.projectId);
12
- this.client = new googleApisSheets.auth.GoogleAuth({
13
- ...formattedConfig,
14
- scopes: ["https://www.googleapis.com/auth/spreadsheets"]
15
- });
16
- } catch (e) {
17
- throw new Error("Google Sheets Client not installed");
18
- }
19
- };
20
- this.getBatchData = async (props) => {
21
- await this.ensureInit();
22
- return (await (await import("@googleapis/sheets")).sheets("v4").spreadsheets.values.batchGet({
23
- auth: this.client,
24
- dateTimeRenderOption: props?.dateTimeRender || "FORMATTED_STRING",
25
- ranges: props.ranges,
26
- spreadsheetId: props.spreadsheetId,
27
- valueRenderOption: props?.valueRender || "UNFORMATTED_VALUE"
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
- constructor(..._args) {
6
- super(..._args);
7
- this.ensureInit = async () => {
8
- if (!this.client) try {
9
- const googleApisSheets = await import("@googleapis/sheets");
10
- const formattedConfig = getConfig(this.config, this.config?.projectId);
11
- this.client = new googleApisSheets.auth.GoogleAuth({
12
- ...formattedConfig,
13
- scopes: ["https://www.googleapis.com/auth/spreadsheets"]
14
- });
15
- } catch (e) {
16
- throw new Error("Google Sheets Client not installed");
17
- }
18
- };
19
- this.getBatchData = async (props) => {
20
- await this.ensureInit();
21
- return (await (await import("@googleapis/sheets")).sheets("v4").spreadsheets.values.batchGet({
22
- auth: this.client,
23
- dateTimeRenderOption: props?.dateTimeRender || "FORMATTED_STRING",
24
- ranges: props.ranges,
25
- spreadsheetId: props.spreadsheetId,
26
- valueRenderOption: props?.valueRender || "UNFORMATTED_VALUE"
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
- constructor(..._args) {
7
- super(..._args);
8
- this.ensureInit = async () => {
9
- if (!this.client) try {
10
- const { Storage } = await import("@google-cloud/storage");
11
- this.client = new Storage(require_googleCloud_server_googleCloud.getConfig(this.config, this.config?.projectId));
12
- } catch (e) {
13
- throw new Error("Google Cloud Storage Client not installed");
14
- }
15
- };
16
- this.copyToCloud = async (bucket, localFile, options = {}) => {
17
- await this.ensureInit();
18
- return await this.client.bucket(bucket).upload(localFile, options);
19
- };
20
- this.fileExists = async (bucket, key) => {
21
- await this.ensureInit();
22
- return (await this.client.bucket(bucket).file(key).exists())?.[0];
23
- };
24
- this.writeFile = async (bucket, key, data, options = {}) => {
25
- await this.ensureInit();
26
- const dataStream = new (await (import("stream"))).PassThrough();
27
- const googleFile = this.client.bucket(bucket).file(key);
28
- dataStream.push(data);
29
- dataStream.push(null);
30
- return await new Promise((resolve, reject) => {
31
- dataStream.pipe(googleFile.createWriteStream({
32
- contentType: "auto",
33
- resumable: false,
34
- validation: false,
35
- metadata: {},
36
- ...options
37
- })).on("error", (error) => {
38
- reject(error);
39
- }).on("finish", () => {
40
- resolve(true);
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
- constructor(..._args) {
6
- super(..._args);
7
- this.ensureInit = async () => {
8
- if (!this.client) try {
9
- const { Storage } = await import("@google-cloud/storage");
10
- this.client = new Storage(getConfig(this.config, this.config?.projectId));
11
- } catch (e) {
12
- throw new Error("Google Cloud Storage Client not installed");
13
- }
14
- };
15
- this.copyToCloud = async (bucket, localFile, options = {}) => {
16
- await this.ensureInit();
17
- return await this.client.bucket(bucket).upload(localFile, options);
18
- };
19
- this.fileExists = async (bucket, key) => {
20
- await this.ensureInit();
21
- return (await this.client.bucket(bucket).file(key).exists())?.[0];
22
- };
23
- this.writeFile = async (bucket, key, data, options = {}) => {
24
- await this.ensureInit();
25
- const dataStream = new (await (import("stream"))).PassThrough();
26
- const googleFile = this.client.bucket(bucket).file(key);
27
- dataStream.push(data);
28
- dataStream.push(null);
29
- return await new Promise((resolve, reject) => {
30
- dataStream.pipe(googleFile.createWriteStream({
31
- contentType: "auto",
32
- resumable: false,
33
- validation: false,
34
- metadata: {},
35
- ...options
36
- })).on("error", (error) => {
37
- reject(error);
38
- }).on("finish", () => {
39
- resolve(true);
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
- constructor(..._args) {
12
- super(..._args);
13
- this.ensureInit = async () => {
14
- if (!this.client) try {
15
- this.client = true;
16
- } catch (e) {
17
- throw new Error("Google PageSpeed Client not installed");
18
- }
19
- };
20
- this.getReport = async (url, inputCategory = require_googlePageSpeed_server_googlePageSpeed.category.PERFORMANCE, inputStrategy = require_googlePageSpeed_server_googlePageSpeed.strategy.MOBILE) => {
21
- const apiResponse = await require_api_get.get(`https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=${url}&strategy=${inputStrategy}&category=${inputCategory}&key=${this.config.apiKey}`);
22
- if (apiResponse.isSuccess()) return apiResponse.getBody();
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
- constructor(..._args) {
11
- super(..._args);
12
- this.ensureInit = async () => {
13
- if (!this.client) try {
14
- this.client = true;
15
- } catch (e) {
16
- throw new Error("Google PageSpeed Client not installed");
17
- }
18
- };
19
- this.getReport = async (url, inputCategory = category.PERFORMANCE, inputStrategy = strategy.MOBILE) => {
20
- const apiResponse = await get(`https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=${url}&strategy=${inputStrategy}&category=${inputCategory}&key=${this.config.apiKey}`);
21
- if (apiResponse.isSuccess()) return apiResponse.getBody();
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
- constructor(..._args) {
10
- super(..._args);
11
- this.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
- this.getReport = async (urlId) => {
19
- const apiResponse = await require_api_get.get(`https://littlewarden.com/api/sites/${urlId}`, { headers: { "Authorization": `Token token="${this.config.apiKey}"` } });
20
- if (apiResponse.isSuccess()) return apiResponse.getBody();
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
- constructor(..._args) {
9
- super(..._args);
10
- this.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
- this.getReport = async (urlId) => {
18
- const apiResponse = await get(`https://littlewarden.com/api/sites/${urlId}`, { headers: { "Authorization": `Token token="${this.config.apiKey}"` } });
19
- if (apiResponse.isSuccess()) return apiResponse.getBody();
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 };