@8ms/helpers 2.0.39 → 2.0.41

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.
Binary file
@@ -11,13 +11,13 @@ type Datasets = {
11
11
  location: string;
12
12
  projectId: string;
13
13
  };
14
- type Tables = {
14
+ type Table = {
15
15
  id: string;
16
16
  };
17
17
  export declare class GoogleBigQueryNamespace extends BaseNamespace {
18
18
  client: BigQuery;
19
19
  config: GoogleCloudConfig & {
20
- projectId: string;
20
+ projectId?: string;
21
21
  };
22
22
  ensureInit: () => Promise<void>;
23
23
  /**
@@ -44,10 +44,7 @@ export declare class GoogleBigQueryNamespace extends BaseNamespace {
44
44
  * Check to see whether a given BigQuery table exists.
45
45
  * https://cloud.google.com/bigquery/docs/samples/bigquery-table-exists
46
46
  */
47
- tableExists: (datasetId: string, tableId: string) => Promise<any>;
48
- /**
49
- * Retrieve all the Tables from a given Project/Dataset.
50
- */
51
- getTable: (datasetId: string) => Promise<Tables[]>;
47
+ tableExists: (datasetId: string, tableId: string) => Promise<boolean>;
48
+ getTables: (datasetId: string) => Promise<Table[]>;
52
49
  }
53
50
  export {};
@@ -46,7 +46,7 @@ class GoogleBigQueryNamespace extends _class_1.BaseNamespace {
46
46
  const formattedConfig = (0, server_1.getConfig)(this.config);
47
47
  this.client = new BigQuery({
48
48
  ...formattedConfig,
49
- projectId: this.config.projectId,
49
+ projectId: this.config?.projectId,
50
50
  });
51
51
  }
52
52
  catch (e) {
@@ -129,22 +129,17 @@ class GoogleBigQueryNamespace extends _class_1.BaseNamespace {
129
129
  */
130
130
  this.tableExists = async (datasetId, tableId) => {
131
131
  await this.ensureInit();
132
- let response;
133
- const dataset = this.client.dataset(datasetId);
134
- try {
135
- await dataset.table(tableId)
136
- .get();
137
- response = true;
138
- }
139
- catch (exception) {
140
- response = false;
132
+ let response = false;
133
+ const tables = await this.getTables(datasetId);
134
+ for (let i = 0; i < tables.length; i++) {
135
+ if (tables[i].id === tableId) {
136
+ response = true;
137
+ break;
138
+ }
141
139
  }
142
140
  return response;
143
141
  };
144
- /**
145
- * Retrieve all the Tables from a given Project/Dataset.
146
- */
147
- this.getTable = async (datasetId) => {
142
+ this.getTables = async (datasetId) => {
148
143
  await this.ensureInit();
149
144
  let response = [];
150
145
  const tables = await this.client.dataset(datasetId)
@@ -1,6 +1,6 @@
1
1
  import { GoogleBigQueryNamespace } from "./GoogleBigQueryNamespace";
2
2
  import type { GoogleAuthOptions } from "@google-cloud/common";
3
- export declare const googleBigQueryClient: (key: string, projectId: string, config?: GoogleAuthOptions, vaultId?: string, itemId?: string) => Promise<GoogleBigQueryNamespace>;
3
+ export declare const googleBigQueryClient: (key?: string, projectId?: string, config?: GoogleAuthOptions, vaultId?: string, itemId?: string) => Promise<GoogleBigQueryNamespace>;
4
4
  export declare const getHandlerPath: (input: string) => string;
5
5
  export { loadData } from "./loadData";
6
6
  export type { QueryInput } from "./GoogleBigQueryNamespace";
@@ -10,7 +10,7 @@ type GetBatchDataProps = {
10
10
  export declare class GoogleSheetsNamespace extends BaseNamespace {
11
11
  client: GoogleAuth;
12
12
  config: GoogleCloudConfig & {
13
- projectId: string;
13
+ projectId?: string;
14
14
  };
15
15
  ensureInit: () => Promise<void>;
16
16
  getBatchData: (props: GetBatchDataProps) => Promise<import("@googleapis/sheets").sheets_v4.Schema$BatchGetValuesResponse>;
@@ -46,7 +46,7 @@ class GoogleSheetsNamespace extends _class_1.BaseNamespace {
46
46
  const formattedConfig = (0, server_1.getConfig)(this.config);
47
47
  this.client = new googleApisSheets.auth.GoogleAuth({
48
48
  credentials: formattedConfig,
49
- projectId: this.config.projectId,
49
+ projectId: this.config?.projectId,
50
50
  scopes: [
51
51
  "https://www.googleapis.com/auth/spreadsheets",
52
52
  ],
@@ -1,6 +1,6 @@
1
1
  import { GoogleSheetsNamespace } from "./GoogleSheetsNamespace";
2
2
  import type { GoogleAuthOptions } from "@google-cloud/common";
3
- export declare const googleSheetsAuths: (key: string, projectId: string, config?: GoogleAuthOptions, vaultId?: string, itemId?: string) => Promise<GoogleSheetsNamespace>;
3
+ export declare const googleSheetsAuths: (key?: string, projectId?: string, config?: GoogleAuthOptions, vaultId?: string, itemId?: string) => Promise<GoogleSheetsNamespace>;
4
4
  /**
5
5
  * Noticed sometimes Google Sheets can struggle with import XML resulting to N/A values.
6
6
  */
@@ -4,7 +4,7 @@ import { GoogleCloudConfig } from "../server";
4
4
  export declare class GoogleCloudStorageNamespace extends BaseNamespace {
5
5
  client: Storage;
6
6
  config: GoogleCloudConfig & {
7
- projectId: string;
7
+ projectId?: string;
8
8
  };
9
9
  ensureInit: () => Promise<void>;
10
10
  /**
@@ -46,7 +46,7 @@ class GoogleCloudStorageNamespace extends _class_1.BaseNamespace {
46
46
  const formattedConfig = (0, server_1.getConfig)(this.config);
47
47
  this.client = new Storage({
48
48
  ...formattedConfig,
49
- projectId: this.config.projectId,
49
+ projectId: this.config?.projectId,
50
50
  });
51
51
  }
52
52
  catch (e) {
@@ -1,3 +1,3 @@
1
1
  import { GoogleCloudStorageNamespace } from "./GoogleCloudStorageNamespace";
2
2
  import type { GoogleAuthOptions } from "@google-cloud/common";
3
- export declare const googleCloudStorageClient: (key: string, projectId: string, config?: GoogleAuthOptions, vaultId?: string, itemId?: string) => Promise<GoogleCloudStorageNamespace>;
3
+ export declare const googleCloudStorageClient: (key?: string, projectId?: string, config?: GoogleAuthOptions, vaultId?: string, itemId?: string) => Promise<GoogleCloudStorageNamespace>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "2.0.39",
4
+ "version": "2.0.41",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"
@@ -1,6 +1,8 @@
1
1
  export declare const WebWorkerState: {
2
+ IDLE: string;
3
+ CANCELLED: string;
4
+ PENDING: string;
2
5
  ERROR: string;
3
6
  SUCCESS: string;
4
- PROGRESS: string;
5
7
  };
6
8
  export type WebWorkerState = typeof WebWorkerState[keyof typeof WebWorkerState];
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WebWorkerState = void 0;
4
4
  exports.WebWorkerState = {
5
+ IDLE: "IDLE",
6
+ CANCELLED: "CANCELLED",
7
+ PENDING: "PENDING",
5
8
  ERROR: "ERROR",
6
9
  SUCCESS: "SUCCESS",
7
- PROGRESS: "PROGRESS",
8
10
  };