@8ms/helpers 2.4.9 → 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 (53) 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/drizzle/server/DrizzleNamespace.cjs +39 -42
  30. package/dist/drizzle/server/DrizzleNamespace.mjs +39 -42
  31. package/dist/googleAds/server/GoogleAdsNamespace.cjs +21 -24
  32. package/dist/googleAds/server/GoogleAdsNamespace.mjs +21 -24
  33. package/dist/googleCloud/bigquery/server/GoogleCloudBigqueryNamespace.cjs +86 -70
  34. package/dist/googleCloud/bigquery/server/GoogleCloudBigqueryNamespace.mjs +86 -70
  35. package/dist/googleCloud/sheets/server/GoogleCloudSheetsNamespace.cjs +22 -25
  36. package/dist/googleCloud/sheets/server/GoogleCloudSheetsNamespace.mjs +22 -25
  37. package/dist/googleCloud/storage/server/GoogleCloudStorageNamespace.cjs +44 -38
  38. package/dist/googleCloud/storage/server/GoogleCloudStorageNamespace.mjs +44 -38
  39. package/dist/googlePageSpeed/server/GooglePageSpeedNamespace.cjs +12 -15
  40. package/dist/googlePageSpeed/server/GooglePageSpeedNamespace.mjs +12 -15
  41. package/dist/littleWarden/server/LittleWardenNamespace.cjs +12 -15
  42. package/dist/littleWarden/server/LittleWardenNamespace.mjs +12 -15
  43. package/dist/onePassword/server/OnePasswordNamespace.cjs +30 -33
  44. package/dist/onePassword/server/OnePasswordNamespace.mjs +30 -33
  45. package/dist/openAi/server/OpenAiNamespace.cjs +20 -20
  46. package/dist/openAi/server/OpenAiNamespace.mjs +20 -20
  47. package/dist/prisma/server/PrismaNamespace.cjs +35 -38
  48. package/dist/prisma/server/PrismaNamespace.mjs +35 -38
  49. package/dist/snapchat/server/SnapchatNamespace.cjs +12 -12
  50. package/dist/snapchat/server/SnapchatNamespace.mjs +12 -12
  51. package/dist/upTimeRobot/server/UpTimeRobotNamespace.cjs +19 -19
  52. package/dist/upTimeRobot/server/UpTimeRobotNamespace.mjs +19 -19
  53. package/package.json +1 -1
@@ -1,33 +1,34 @@
1
1
  import { BaseNamespace } from "../../../_class/BaseNamespace.mjs";
2
2
  //#region src/aws/ssm/server/AwsSsmNamespace.ts
3
3
  var AwsSsmNamespace = class extends BaseNamespace {
4
+ parameters;
4
5
  constructor(key, config) {
5
6
  super(key, config);
6
- this.ensureInit = async () => {
7
- if (!this.client) try {
8
- const { SSMClient } = await import("@aws-sdk/client-ssm");
9
- this.client = new SSMClient(this.config);
10
- } catch (e) {
11
- throw new Error("AWS SSM Client not installed");
12
- }
13
- };
14
- this.getParameter = async (name, withDecryption = false, isJson = true) => {
15
- await this.ensureInit();
16
- if (!this.parameters.has(name)) {
17
- const { GetParameterCommand } = await import("@aws-sdk/client-ssm");
18
- const apiResponse = await this.client.send(new GetParameterCommand({
19
- Name: name,
20
- WithDecryption: void 0 === withDecryption ? true : withDecryption
21
- }));
22
- if (apiResponse.Parameter.Value) if (void 0 === apiResponse.Parameter.Value) this.parameters.set(name, null);
23
- else if (void 0 === isJson || true === isJson) this.parameters.set(name, JSON.parse(apiResponse.Parameter.Value) || null);
24
- else this.parameters.set(name, apiResponse.Parameter.Value);
25
- else this.parameters.set(name, null);
26
- }
27
- return this.parameters.get(name);
28
- };
29
7
  this.parameters = /* @__PURE__ */ new Map();
30
8
  }
9
+ ensureInit = async () => {
10
+ if (!this.client) try {
11
+ const { SSMClient } = await import("@aws-sdk/client-ssm");
12
+ this.client = new SSMClient(this.config);
13
+ } catch (e) {
14
+ throw new Error("AWS SSM Client not installed");
15
+ }
16
+ };
17
+ getParameter = async (name, withDecryption = false, isJson = true) => {
18
+ await this.ensureInit();
19
+ if (!this.parameters.has(name)) {
20
+ const { GetParameterCommand } = await import("@aws-sdk/client-ssm");
21
+ const apiResponse = await this.client.send(new GetParameterCommand({
22
+ Name: name,
23
+ WithDecryption: void 0 === withDecryption ? true : withDecryption
24
+ }));
25
+ if (apiResponse.Parameter.Value) if (void 0 === apiResponse.Parameter.Value) this.parameters.set(name, null);
26
+ else if (void 0 === isJson || true === isJson) this.parameters.set(name, JSON.parse(apiResponse.Parameter.Value) || null);
27
+ else this.parameters.set(name, apiResponse.Parameter.Value);
28
+ else this.parameters.set(name, null);
29
+ }
30
+ return this.parameters.get(name);
31
+ };
31
32
  };
32
33
  //#endregion
33
34
  export { AwsSsmNamespace };
@@ -3,49 +3,46 @@ const require_util_getError = require("../../util/getError.cjs");
3
3
  const require__class_BaseNamespace = require("../../_class/BaseNamespace.cjs");
4
4
  //#region src/drizzle/server/DrizzleNamespace.ts
5
5
  var DrizzleNamespace = class extends require__class_BaseNamespace.BaseNamespace {
6
- constructor(..._args) {
7
- super(..._args);
8
- this.ensureInit = async () => {
9
- if (!this.client) {
10
- let logger = void 0;
11
- if (this.config.isDebug) {
12
- const { DefaultLogger } = await import("drizzle-orm/logger");
13
- logger = new DefaultLogger();
14
- }
15
- if (this.config.isPlanetScale) try {
16
- const { drizzle } = await import("drizzle-orm/planetscale-serverless");
17
- this.client = drizzle({
18
- connection: { url: this.config.url },
19
- relations: this.config?.relations,
20
- logger
21
- });
22
- } catch (e) {
23
- throw new Error(`PlanetScale driver not installed - ${require_util_getError.getError(e)}`);
24
- }
25
- else if (this.config.isMysql) try {
26
- const { drizzle } = await import("drizzle-orm/mysql2");
27
- this.client = drizzle({
28
- connection: this.config.url,
29
- relations: this.config?.relations,
30
- logger
31
- });
32
- } catch (e) {
33
- throw new Error(`MySQL2 driver not installed - ${require_util_getError.getError(e)}`);
34
- }
35
- else if (this.config.isPostgres) try {
36
- const { drizzle } = await import("drizzle-orm/node-postgres");
37
- this.client = drizzle({
38
- connection: this.config.url,
39
- relations: this.config?.relations,
40
- logger
41
- });
42
- } catch (e) {
43
- throw new Error(`Postgres (pg) driver not installed - ${require_util_getError.getError(e)}`);
44
- }
45
- else throw new Error(`No database type configured — set DATABASE_IS_PLANETSCALE, DATABASE_IS_MYSQL or DATABASE_IS_POSTGRES to "true"`);
6
+ ensureInit = async () => {
7
+ if (!this.client) {
8
+ let logger = void 0;
9
+ if (this.config.isDebug) {
10
+ const { DefaultLogger } = await import("drizzle-orm/logger");
11
+ logger = new DefaultLogger();
46
12
  }
47
- };
48
- }
13
+ if (this.config.isPlanetScale) try {
14
+ const { drizzle } = await import("drizzle-orm/planetscale-serverless");
15
+ this.client = drizzle({
16
+ connection: { url: this.config.url },
17
+ relations: this.config?.relations,
18
+ logger
19
+ });
20
+ } catch (e) {
21
+ throw new Error(`PlanetScale driver not installed - ${require_util_getError.getError(e)}`);
22
+ }
23
+ else if (this.config.isMysql) try {
24
+ const { drizzle } = await import("drizzle-orm/mysql2");
25
+ this.client = drizzle({
26
+ connection: this.config.url,
27
+ relations: this.config?.relations,
28
+ logger
29
+ });
30
+ } catch (e) {
31
+ throw new Error(`MySQL2 driver not installed - ${require_util_getError.getError(e)}`);
32
+ }
33
+ else if (this.config.isPostgres) try {
34
+ const { drizzle } = await import("drizzle-orm/node-postgres");
35
+ this.client = drizzle({
36
+ connection: this.config.url,
37
+ relations: this.config?.relations,
38
+ logger
39
+ });
40
+ } catch (e) {
41
+ throw new Error(`Postgres (pg) driver not installed - ${require_util_getError.getError(e)}`);
42
+ }
43
+ else throw new Error(`No database type configured — set DATABASE_IS_PLANETSCALE, DATABASE_IS_MYSQL or DATABASE_IS_POSTGRES to "true"`);
44
+ }
45
+ };
49
46
  };
50
47
  //#endregion
51
48
  exports.DrizzleNamespace = DrizzleNamespace;
@@ -2,49 +2,46 @@ import { getError } from "../../util/getError.mjs";
2
2
  import { BaseNamespace } from "../../_class/BaseNamespace.mjs";
3
3
  //#region src/drizzle/server/DrizzleNamespace.ts
4
4
  var DrizzleNamespace = class extends BaseNamespace {
5
- constructor(..._args) {
6
- super(..._args);
7
- this.ensureInit = async () => {
8
- if (!this.client) {
9
- let logger = void 0;
10
- if (this.config.isDebug) {
11
- const { DefaultLogger } = await import("drizzle-orm/logger");
12
- logger = new DefaultLogger();
13
- }
14
- if (this.config.isPlanetScale) try {
15
- const { drizzle } = await import("drizzle-orm/planetscale-serverless");
16
- this.client = drizzle({
17
- connection: { url: this.config.url },
18
- relations: this.config?.relations,
19
- logger
20
- });
21
- } catch (e) {
22
- throw new Error(`PlanetScale driver not installed - ${getError(e)}`);
23
- }
24
- else if (this.config.isMysql) try {
25
- const { drizzle } = await import("drizzle-orm/mysql2");
26
- this.client = drizzle({
27
- connection: this.config.url,
28
- relations: this.config?.relations,
29
- logger
30
- });
31
- } catch (e) {
32
- throw new Error(`MySQL2 driver not installed - ${getError(e)}`);
33
- }
34
- else if (this.config.isPostgres) try {
35
- const { drizzle } = await import("drizzle-orm/node-postgres");
36
- this.client = drizzle({
37
- connection: this.config.url,
38
- relations: this.config?.relations,
39
- logger
40
- });
41
- } catch (e) {
42
- throw new Error(`Postgres (pg) driver not installed - ${getError(e)}`);
43
- }
44
- else throw new Error(`No database type configured — set DATABASE_IS_PLANETSCALE, DATABASE_IS_MYSQL or DATABASE_IS_POSTGRES to "true"`);
5
+ ensureInit = async () => {
6
+ if (!this.client) {
7
+ let logger = void 0;
8
+ if (this.config.isDebug) {
9
+ const { DefaultLogger } = await import("drizzle-orm/logger");
10
+ logger = new DefaultLogger();
45
11
  }
46
- };
47
- }
12
+ if (this.config.isPlanetScale) try {
13
+ const { drizzle } = await import("drizzle-orm/planetscale-serverless");
14
+ this.client = drizzle({
15
+ connection: { url: this.config.url },
16
+ relations: this.config?.relations,
17
+ logger
18
+ });
19
+ } catch (e) {
20
+ throw new Error(`PlanetScale driver not installed - ${getError(e)}`);
21
+ }
22
+ else if (this.config.isMysql) try {
23
+ const { drizzle } = await import("drizzle-orm/mysql2");
24
+ this.client = drizzle({
25
+ connection: this.config.url,
26
+ relations: this.config?.relations,
27
+ logger
28
+ });
29
+ } catch (e) {
30
+ throw new Error(`MySQL2 driver not installed - ${getError(e)}`);
31
+ }
32
+ else if (this.config.isPostgres) try {
33
+ const { drizzle } = await import("drizzle-orm/node-postgres");
34
+ this.client = drizzle({
35
+ connection: this.config.url,
36
+ relations: this.config?.relations,
37
+ logger
38
+ });
39
+ } catch (e) {
40
+ throw new Error(`Postgres (pg) driver not installed - ${getError(e)}`);
41
+ }
42
+ else throw new Error(`No database type configured — set DATABASE_IS_PLANETSCALE, DATABASE_IS_MYSQL or DATABASE_IS_POSTGRES to "true"`);
43
+ }
44
+ };
48
45
  };
49
46
  //#endregion
50
47
  export { DrizzleNamespace };
@@ -2,32 +2,29 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require__class_BaseNamespace = require("../../_class/BaseNamespace.cjs");
3
3
  //#region src/googleAds/server/GoogleAdsNamespace.ts
4
4
  var GoogleAdsNamespace = class extends require__class_BaseNamespace.BaseNamespace {
5
- constructor(..._args) {
6
- super(..._args);
7
- this.mccAccountId = "";
8
- this.refreshToken = "";
9
- this.ensureInit = async () => {
10
- if (!this.client) try {
11
- this.client = {
12
- client_id: this.config.client.clientId,
13
- client_secret: this.config.client.clientSecret,
14
- developer_token: this.config.client.developerToken
15
- };
16
- this.mccAccountId = this.config.mccAccountId;
17
- this.refreshToken = this.config.refreshToken;
18
- } catch (e) {
19
- throw new Error("Google Sheets Client not installed");
20
- }
21
- };
22
- this.getCustomer = async (customerId) => {
23
- await this.ensureInit();
24
- return {
25
- customer_id: customerId,
26
- login_customer_id: this.mccAccountId,
27
- refresh_token: this.refreshToken
5
+ mccAccountId = "";
6
+ refreshToken = "";
7
+ ensureInit = async () => {
8
+ if (!this.client) try {
9
+ this.client = {
10
+ client_id: this.config.client.clientId,
11
+ client_secret: this.config.client.clientSecret,
12
+ developer_token: this.config.client.developerToken
28
13
  };
14
+ this.mccAccountId = this.config.mccAccountId;
15
+ this.refreshToken = this.config.refreshToken;
16
+ } catch (e) {
17
+ throw new Error("Google Sheets Client not installed");
18
+ }
19
+ };
20
+ getCustomer = async (customerId) => {
21
+ await this.ensureInit();
22
+ return {
23
+ customer_id: customerId,
24
+ login_customer_id: this.mccAccountId,
25
+ refresh_token: this.refreshToken
29
26
  };
30
- }
27
+ };
31
28
  };
32
29
  //#endregion
33
30
  exports.GoogleAdsNamespace = GoogleAdsNamespace;
@@ -1,32 +1,29 @@
1
1
  import { BaseNamespace } from "../../_class/BaseNamespace.mjs";
2
2
  //#region src/googleAds/server/GoogleAdsNamespace.ts
3
3
  var GoogleAdsNamespace = class extends BaseNamespace {
4
- constructor(..._args) {
5
- super(..._args);
6
- this.mccAccountId = "";
7
- this.refreshToken = "";
8
- this.ensureInit = async () => {
9
- if (!this.client) try {
10
- this.client = {
11
- client_id: this.config.client.clientId,
12
- client_secret: this.config.client.clientSecret,
13
- developer_token: this.config.client.developerToken
14
- };
15
- this.mccAccountId = this.config.mccAccountId;
16
- this.refreshToken = this.config.refreshToken;
17
- } catch (e) {
18
- throw new Error("Google Sheets Client not installed");
19
- }
20
- };
21
- this.getCustomer = async (customerId) => {
22
- await this.ensureInit();
23
- return {
24
- customer_id: customerId,
25
- login_customer_id: this.mccAccountId,
26
- refresh_token: this.refreshToken
4
+ mccAccountId = "";
5
+ refreshToken = "";
6
+ ensureInit = async () => {
7
+ if (!this.client) try {
8
+ this.client = {
9
+ client_id: this.config.client.clientId,
10
+ client_secret: this.config.client.clientSecret,
11
+ developer_token: this.config.client.developerToken
27
12
  };
13
+ this.mccAccountId = this.config.mccAccountId;
14
+ this.refreshToken = this.config.refreshToken;
15
+ } catch (e) {
16
+ throw new Error("Google Sheets Client not installed");
17
+ }
18
+ };
19
+ getCustomer = async (customerId) => {
20
+ await this.ensureInit();
21
+ return {
22
+ customer_id: customerId,
23
+ login_customer_id: this.mccAccountId,
24
+ refresh_token: this.refreshToken
28
25
  };
29
- }
26
+ };
30
27
  };
31
28
  //#endregion
32
29
  export { GoogleAdsNamespace };
@@ -4,76 +4,92 @@ const require__class_BaseNamespace = require("../../../_class/BaseNamespace.cjs"
4
4
  const require_googleCloud_server_googleCloud = require("../../server/googleCloud.cjs");
5
5
  //#region src/googleCloud/bigquery/server/GoogleCloudBigqueryNamespace.ts
6
6
  var GoogleCloudBigqueryNamespace = class extends require__class_BaseNamespace.BaseNamespace {
7
- constructor(..._args) {
8
- super(..._args);
9
- this.ensureInit = async () => {
10
- if (!this.client) try {
11
- const { BigQuery } = await import("@google-cloud/bigquery");
12
- this.client = new BigQuery(require_googleCloud_server_googleCloud.getConfig(this.config, this.config?.projectId));
13
- } catch (e) {
14
- throw new Error("Google BigQuery Client not installed");
15
- }
16
- };
17
- this.createDataset = async (datasetId, options = {}) => {
18
- await this.ensureInit();
19
- if (!await this.datasetExists(datasetId)) await this.client.createDataset(datasetId);
20
- };
21
- this.datasetExists = async (datasetId) => {
22
- await this.ensureInit();
23
- let response;
24
- try {
25
- await this.client.dataset(datasetId).get();
26
- response = true;
27
- } catch (exception) {
28
- response = false;
29
- }
30
- return response;
31
- };
32
- this.getDatasets = async () => {
33
- await this.ensureInit();
34
- let response = [];
35
- const datasets = await this.client.getDatasets();
36
- if (datasets?.[0]) for (let i = 0; i < datasets[0].length; i++) response.push({
37
- id: datasets[0][i].id,
38
- location: datasets[0][i].location,
39
- projectId: datasets[0][i].bigQuery.projectId
40
- });
41
- return response;
42
- };
43
- this.query = async (props) => {
44
- await this.ensureInit();
45
- let options = { query: "" };
46
- if ("string" === typeof props) options.query = props;
47
- else if (require_lodash_isObject.isObject(props)) {
48
- options.query = props.query;
49
- if (props?.location) options["location"] = props.location;
50
- if (props?.params) options["params"] = props.params;
51
- }
52
- return await this.client.query(options);
53
- };
54
- this.createTable = async (datasetId, datasetOptions = {}, tableId, options = {}) => {
55
- await this.ensureInit();
56
- await this.createDataset(datasetId, datasetOptions);
57
- if (!await this.tableExists(datasetId, tableId)) await this.client.dataset(datasetId).createTable(tableId, options || {});
58
- };
59
- this.tableExists = async (datasetId, tableId) => {
60
- await this.ensureInit();
61
- let response = false;
62
- const tables = await this.getTables(datasetId);
63
- for (let i = 0; i < tables.length; i++) if (tables[i].id === tableId) {
64
- response = true;
65
- break;
66
- }
67
- return response;
68
- };
69
- this.getTables = async (datasetId) => {
70
- await this.ensureInit();
71
- let response = [];
72
- const tables = await this.client.dataset(datasetId).getTables();
73
- if (tables?.[0]) for (let i = 0; i < tables[0].length; i++) response.push({ id: tables[0][i].id });
74
- return response;
75
- };
76
- }
7
+ ensureInit = async () => {
8
+ if (!this.client) try {
9
+ const { BigQuery } = await import("@google-cloud/bigquery");
10
+ this.client = new BigQuery(require_googleCloud_server_googleCloud.getConfig(this.config, this.config?.projectId));
11
+ } catch (e) {
12
+ throw new Error("Google BigQuery Client not installed");
13
+ }
14
+ };
15
+ /**
16
+ * Create a Dataset if it doesn't already exist.
17
+ * Returns table instance.
18
+ */
19
+ createDataset = async (datasetId, options = {}) => {
20
+ await this.ensureInit();
21
+ if (!await this.datasetExists(datasetId)) await this.client.createDataset(datasetId);
22
+ };
23
+ /**
24
+ * Check to see whether a given Bigquery dataset exists.
25
+ * Based off:
26
+ * https://github.com/googleapis/nodejs-bigquery/blob/main/samples/getDataset.js
27
+ */
28
+ datasetExists = async (datasetId) => {
29
+ await this.ensureInit();
30
+ let response;
31
+ try {
32
+ await this.client.dataset(datasetId).get();
33
+ response = true;
34
+ } catch (exception) {
35
+ response = false;
36
+ }
37
+ return response;
38
+ };
39
+ /**
40
+ * Retrieve all the Datasets
41
+ */
42
+ getDatasets = async () => {
43
+ await this.ensureInit();
44
+ let response = [];
45
+ const datasets = await this.client.getDatasets();
46
+ if (datasets?.[0]) for (let i = 0; i < datasets[0].length; i++) response.push({
47
+ id: datasets[0][i].id,
48
+ location: datasets[0][i].location,
49
+ projectId: datasets[0][i].bigQuery.projectId
50
+ });
51
+ return response;
52
+ };
53
+ query = async (props) => {
54
+ await this.ensureInit();
55
+ let options = { query: "" };
56
+ if ("string" === typeof props) options.query = props;
57
+ else if (require_lodash_isObject.isObject(props)) {
58
+ options.query = props.query;
59
+ if (props?.location) options["location"] = props.location;
60
+ if (props?.params) options["params"] = props.params;
61
+ }
62
+ return await this.client.query(options);
63
+ };
64
+ /**
65
+ * Create a Table if it doesn't already exist.
66
+ */
67
+ createTable = async (datasetId, datasetOptions = {}, tableId, options = {}) => {
68
+ await this.ensureInit();
69
+ await this.createDataset(datasetId, datasetOptions);
70
+ if (!await this.tableExists(datasetId, tableId)) await this.client.dataset(datasetId).createTable(tableId, options || {});
71
+ };
72
+ /**
73
+ * Check to see whether a given BigQuery table exists.
74
+ * https://cloud.google.com/bigquery/docs/samples/bigquery-table-exists
75
+ */
76
+ tableExists = async (datasetId, tableId) => {
77
+ await this.ensureInit();
78
+ let response = false;
79
+ const tables = await this.getTables(datasetId);
80
+ for (let i = 0; i < tables.length; i++) if (tables[i].id === tableId) {
81
+ response = true;
82
+ break;
83
+ }
84
+ return response;
85
+ };
86
+ getTables = async (datasetId) => {
87
+ await this.ensureInit();
88
+ let response = [];
89
+ const tables = await this.client.dataset(datasetId).getTables();
90
+ if (tables?.[0]) for (let i = 0; i < tables[0].length; i++) response.push({ id: tables[0][i].id });
91
+ return response;
92
+ };
77
93
  };
78
94
  //#endregion
79
95
  exports.GoogleCloudBigqueryNamespace = GoogleCloudBigqueryNamespace;