@malloydata/db-bigquery 0.0.120-dev240131223846 → 0.0.120

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.
@@ -1,7 +1,7 @@
1
1
  import { RowMetadata } from '@google-cloud/bigquery';
2
2
  import bigquery from '@google-cloud/bigquery/build/src/types';
3
3
  import { ResourceStream } from '@google-cloud/paginator';
4
- import { Connection, FetchSchemaOptions, MalloyQueryData, PersistSQLResults, PooledConnection, QueryData, QueryDataRow, QueryRunStats, RunSQLOptions, SQLBlock, StreamingConnection, StructDef } from '@malloydata/malloy';
4
+ import { Connection, ConnectionConfig, FetchSchemaOptions, MalloyQueryData, PersistSQLResults, PooledConnection, QueryData, QueryDataRow, QueryOptionsReader, QueryRunStats, RunSQLOptions, SQLBlock, StreamingConnection, StructDef } from '@malloydata/malloy';
5
5
  export interface BigQueryManagerOptions {
6
6
  credentials?: {
7
7
  clientId: string;
@@ -11,15 +11,13 @@ export interface BigQueryManagerOptions {
11
11
  projectId?: string | undefined;
12
12
  userAgent: string;
13
13
  }
14
- export interface BigQueryQueryOptions {
15
- rowLimit: number;
16
- }
17
14
  interface CredentialBody {
18
15
  client_email?: string;
19
16
  private_key?: string;
20
17
  }
21
18
  interface BigQueryConnectionConfiguration {
22
- projectId?: string /** This ID is used for Bigquery Table Normalization */;
19
+ /** This ID is used for Bigquery Table Normalization */
20
+ projectId?: string;
23
21
  serviceAccountKeyPath?: string;
24
22
  location?: string;
25
23
  maximumBytesBilled?: string;
@@ -27,20 +25,30 @@ interface BigQueryConnectionConfiguration {
27
25
  billingProjectId?: string;
28
26
  credentials?: CredentialBody;
29
27
  }
28
+ interface BigQueryConnectionOptions extends ConnectionConfig {
29
+ /** This ID is used for Bigquery Table Normalization */
30
+ projectId?: string;
31
+ serviceAccountKeyPath?: string;
32
+ location?: string;
33
+ maximumBytesBilled?: string;
34
+ timeoutMs?: string;
35
+ billingProjectId?: string;
36
+ client_email?: string;
37
+ private_key?: string;
38
+ }
30
39
  interface SchemaInfo {
31
40
  schema: bigquery.ITableFieldSchema;
32
41
  needsTableSuffixPseudoColumn: boolean;
33
42
  needsPartitionTimePseudoColumn: boolean;
34
43
  needsPartitionDatePseudoColumn: boolean;
35
44
  }
36
- type QueryOptionsReader = Partial<BigQueryQueryOptions> | (() => Partial<BigQueryQueryOptions>);
37
45
  export declare class BigQueryAuthenticationError extends Error {
38
46
  constructor(message: string);
39
47
  }
40
48
  export declare class BigQueryConnection implements Connection, PersistSQLResults, StreamingConnection {
41
49
  readonly name: string;
42
50
  private readonly dialect;
43
- static DEFAULT_QUERY_OPTIONS: BigQueryQueryOptions;
51
+ static DEFAULT_QUERY_OPTIONS: RunSQLOptions;
44
52
  private bigQuery;
45
53
  private billingProjectId;
46
54
  private temporaryTables;
@@ -50,6 +58,7 @@ export declare class BigQueryConnection implements Connection, PersistSQLResults
50
58
  private queryOptions?;
51
59
  private config;
52
60
  private location;
61
+ constructor(option: BigQueryConnectionOptions, queryOptions?: QueryOptionsReader);
53
62
  constructor(name: string, queryOptions?: QueryOptionsReader, config?: BigQueryConnectionConfiguration);
54
63
  get dialectName(): string;
55
64
  private readQueryOptions;
@@ -58,10 +67,8 @@ export declare class BigQueryConnection implements Connection, PersistSQLResults
58
67
  canStream(): this is StreamingConnection;
59
68
  get supportsNesting(): boolean;
60
69
  private _runSQL;
61
- runSQL(sqlCommand: string, options?: Partial<BigQueryQueryOptions>, rowIndex?: number): Promise<MalloyQueryData>;
62
- runSQLBlockAndFetchResultSchema(sqlBlock: SQLBlock, options?: {
63
- rowLimit?: number | undefined;
64
- }): Promise<{
70
+ runSQL(sqlCommand: string, options?: RunSQLOptions, rowIndex?: number): Promise<MalloyQueryData>;
71
+ runSQLBlockAndFetchResultSchema(sqlBlock: SQLBlock, options?: RunSQLOptions): Promise<{
65
72
  data: MalloyQueryData;
66
73
  schema: StructDef;
67
74
  }>;
@@ -88,12 +88,25 @@ const MAXIMUM_BYTES_BILLED = String(25 * 1024 * 1024 * 1024);
88
88
  const TIMEOUT_MS = 1000 * 60 * 10;
89
89
  // manage access to BQ, control costs, enforce global data/API limits
90
90
  class BigQueryConnection {
91
- constructor(name, queryOptions, config = {}) {
92
- this.name = name;
91
+ constructor(arg, queryOptions, config = {}) {
93
92
  this.dialect = new malloy_1.StandardSQLDialect();
94
93
  this.temporaryTables = new Map();
95
94
  this.schemaCache = new Map();
96
95
  this.sqlSchemaCache = new Map();
96
+ if (typeof arg === 'string') {
97
+ this.name = arg;
98
+ }
99
+ else {
100
+ const { name, client_email, private_key, ...args } = arg;
101
+ this.name = name;
102
+ config = args;
103
+ if (client_email || private_key) {
104
+ config.credentials = {
105
+ client_email,
106
+ private_key,
107
+ };
108
+ }
109
+ }
97
110
  this.bigQuery = new bigquery_1.BigQuery({
98
111
  userAgent: `Malloy/${malloy_1.Malloy.version}`,
99
112
  keyFilename: config.serviceAccountKeyPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/db-bigquery",
3
- "version": "0.0.120-dev240131223846",
3
+ "version": "0.0.120",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -25,7 +25,7 @@
25
25
  "@google-cloud/bigquery": "^7.3.0",
26
26
  "@google-cloud/common": "^5.0.1",
27
27
  "@google-cloud/paginator": "^5.0.0",
28
- "@malloydata/malloy": "^0.0.120-dev240131223846",
28
+ "@malloydata/malloy": "^0.0.120",
29
29
  "gaxios": "^4.2.0"
30
30
  }
31
31
  }