@sqlanvil/cli 1.13.0 → 1.14.0

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/bundle.js CHANGED
@@ -35,6 +35,7 @@ var bigquery = require('@google-cloud/bigquery');
35
35
  var EventEmitter = require('events');
36
36
  var Long = require('long');
37
37
  var os = require('os');
38
+ var googleAuthLibrary = require('google-auth-library');
38
39
  var promisePoolExecutor = require('promise-pool-executor');
39
40
  var sizeof = require('object-sizeof');
40
41
  var QueryStream = require('pg-query-stream');
@@ -43305,6 +43306,7 @@ const sqlanvil = $root.sqlanvil = (() => {
43305
43306
  * @property {string|null} [projectId] BigQuery projectId
43306
43307
  * @property {string|null} [credentials] BigQuery credentials
43307
43308
  * @property {string|null} [location] BigQuery location
43309
+ * @property {string|null} [accessToken] BigQuery accessToken
43308
43310
  */
43309
43311
 
43310
43312
  /**
@@ -43346,6 +43348,14 @@ const sqlanvil = $root.sqlanvil = (() => {
43346
43348
  */
43347
43349
  BigQuery.prototype.location = "";
43348
43350
 
43351
+ /**
43352
+ * BigQuery accessToken.
43353
+ * @member {string} accessToken
43354
+ * @memberof sqlanvil.BigQuery
43355
+ * @instance
43356
+ */
43357
+ BigQuery.prototype.accessToken = "";
43358
+
43349
43359
  /**
43350
43360
  * Creates a new BigQuery instance using the specified properties.
43351
43361
  * @function create
@@ -43376,6 +43386,8 @@ const sqlanvil = $root.sqlanvil = (() => {
43376
43386
  writer.uint32(/* id 3, wireType 2 =*/26).string(message.credentials);
43377
43387
  if (message.location != null && Object.hasOwnProperty.call(message, "location"))
43378
43388
  writer.uint32(/* id 4, wireType 2 =*/34).string(message.location);
43389
+ if (message.accessToken != null && Object.hasOwnProperty.call(message, "accessToken"))
43390
+ writer.uint32(/* id 5, wireType 2 =*/42).string(message.accessToken);
43379
43391
  return writer;
43380
43392
  };
43381
43393
 
@@ -43428,6 +43440,10 @@ const sqlanvil = $root.sqlanvil = (() => {
43428
43440
  message.location = reader.string();
43429
43441
  break;
43430
43442
  }
43443
+ case 5: {
43444
+ message.accessToken = reader.string();
43445
+ break;
43446
+ }
43431
43447
  default:
43432
43448
  reader.skipType(tag & 7, long);
43433
43449
  break;
@@ -43476,6 +43492,9 @@ const sqlanvil = $root.sqlanvil = (() => {
43476
43492
  if (message.location != null && message.hasOwnProperty("location"))
43477
43493
  if (!$util.isString(message.location))
43478
43494
  return "location: string expected";
43495
+ if (message.accessToken != null && message.hasOwnProperty("accessToken"))
43496
+ if (!$util.isString(message.accessToken))
43497
+ return "accessToken: string expected";
43479
43498
  return null;
43480
43499
  };
43481
43500
 
@@ -43501,6 +43520,8 @@ const sqlanvil = $root.sqlanvil = (() => {
43501
43520
  message.credentials = String(object.credentials);
43502
43521
  if (object.location != null)
43503
43522
  message.location = String(object.location);
43523
+ if (object.accessToken != null)
43524
+ message.accessToken = String(object.accessToken);
43504
43525
  return message;
43505
43526
  };
43506
43527
 
@@ -43521,6 +43542,7 @@ const sqlanvil = $root.sqlanvil = (() => {
43521
43542
  object.projectId = "";
43522
43543
  object.credentials = "";
43523
43544
  object.location = "";
43545
+ object.accessToken = "";
43524
43546
  }
43525
43547
  if (message.projectId != null && message.hasOwnProperty("projectId"))
43526
43548
  object.projectId = message.projectId;
@@ -43528,6 +43550,8 @@ const sqlanvil = $root.sqlanvil = (() => {
43528
43550
  object.credentials = message.credentials;
43529
43551
  if (message.location != null && message.hasOwnProperty("location"))
43530
43552
  object.location = message.location;
43553
+ if (message.accessToken != null && message.hasOwnProperty("accessToken"))
43554
+ object.accessToken = message.accessToken;
43531
43555
  return object;
43532
43556
  };
43533
43557
 
@@ -46342,7 +46366,7 @@ function collectEvaluationQueries(queryOrAction, concatenate, queryModifier = (q
46342
46366
  .filter(validationQuery => !!validationQuery.query);
46343
46367
  }
46344
46368
 
46345
- const version = "1.13.0";
46369
+ const version = "1.14.0";
46346
46370
  const dataformVersion = "3.0.60";
46347
46371
 
46348
46372
  async function build(compiledGraph, runConfig, dbadapter) {
@@ -48459,6 +48483,19 @@ class LimitedResultSet {
48459
48483
  }
48460
48484
 
48461
48485
  const EXTRA_GOOGLE_SCOPES = ["https://www.googleapis.com/auth/drive"];
48486
+ function bigQueryClientOptions(credentials, projectId) {
48487
+ const base = {
48488
+ projectId,
48489
+ scopes: EXTRA_GOOGLE_SCOPES,
48490
+ location: credentials.location
48491
+ };
48492
+ if (credentials.accessToken) {
48493
+ const authClient = new googleAuthLibrary.OAuth2Client();
48494
+ authClient.setCredentials({ access_token: credentials.accessToken });
48495
+ return Object.assign(Object.assign({}, base), { authClient: authClient });
48496
+ }
48497
+ return Object.assign(Object.assign({}, base), { credentials: credentials.credentials ? JSON.parse(credentials.credentials) : undefined });
48498
+ }
48462
48499
  const BIGQUERY_DATE_RELATED_FIELDS = [
48463
48500
  "BigQueryDate",
48464
48501
  "BigQueryTime",
@@ -48658,12 +48695,7 @@ class BigQueryDbAdapter {
48658
48695
  }
48659
48696
  projectId = projectId || this.bigQueryCredentials.projectId;
48660
48697
  if (!this.clients.has(projectId)) {
48661
- this.clients.set(projectId, new bigquery.BigQuery({
48662
- projectId,
48663
- scopes: EXTRA_GOOGLE_SCOPES,
48664
- location: this.bigQueryCredentials.location,
48665
- credentials: this.bigQueryCredentials.credentials && JSON.parse(this.bigQueryCredentials.credentials)
48666
- }));
48698
+ this.clients.set(projectId, new bigquery.BigQuery(bigQueryClientOptions(this.bigQueryCredentials, projectId)));
48667
48699
  }
48668
48700
  return this.clients.get(projectId);
48669
48701
  }
package/package.json CHANGED
@@ -6,6 +6,7 @@
6
6
  "deepmerge": "^4.2.2",
7
7
  "fs-extra": "^9.0.0",
8
8
  "glob": "13.0.6",
9
+ "google-auth-library": "^9.15.1",
9
10
  "google-sql-syntax-ts": "^1.0.3",
10
11
  "js-beautify": "^1.10.2",
11
12
  "js-yaml": "^4.1.1",
@@ -63,7 +64,7 @@
63
64
  "bin": {
64
65
  "sqlanvil": "bundle.js"
65
66
  },
66
- "version": "1.13.0",
67
+ "version": "1.14.0",
67
68
  "name": "@sqlanvil/cli",
68
69
  "description": "sqlanvil command line interface.",
69
70
  "main": "bundle.js"
package/worker_bundle.js CHANGED
@@ -43244,6 +43244,7 @@ const sqlanvil = $root.sqlanvil = (() => {
43244
43244
  * @property {string|null} [projectId] BigQuery projectId
43245
43245
  * @property {string|null} [credentials] BigQuery credentials
43246
43246
  * @property {string|null} [location] BigQuery location
43247
+ * @property {string|null} [accessToken] BigQuery accessToken
43247
43248
  */
43248
43249
 
43249
43250
  /**
@@ -43285,6 +43286,14 @@ const sqlanvil = $root.sqlanvil = (() => {
43285
43286
  */
43286
43287
  BigQuery.prototype.location = "";
43287
43288
 
43289
+ /**
43290
+ * BigQuery accessToken.
43291
+ * @member {string} accessToken
43292
+ * @memberof sqlanvil.BigQuery
43293
+ * @instance
43294
+ */
43295
+ BigQuery.prototype.accessToken = "";
43296
+
43288
43297
  /**
43289
43298
  * Creates a new BigQuery instance using the specified properties.
43290
43299
  * @function create
@@ -43315,6 +43324,8 @@ const sqlanvil = $root.sqlanvil = (() => {
43315
43324
  writer.uint32(/* id 3, wireType 2 =*/26).string(message.credentials);
43316
43325
  if (message.location != null && Object.hasOwnProperty.call(message, "location"))
43317
43326
  writer.uint32(/* id 4, wireType 2 =*/34).string(message.location);
43327
+ if (message.accessToken != null && Object.hasOwnProperty.call(message, "accessToken"))
43328
+ writer.uint32(/* id 5, wireType 2 =*/42).string(message.accessToken);
43318
43329
  return writer;
43319
43330
  };
43320
43331
 
@@ -43367,6 +43378,10 @@ const sqlanvil = $root.sqlanvil = (() => {
43367
43378
  message.location = reader.string();
43368
43379
  break;
43369
43380
  }
43381
+ case 5: {
43382
+ message.accessToken = reader.string();
43383
+ break;
43384
+ }
43370
43385
  default:
43371
43386
  reader.skipType(tag & 7, long);
43372
43387
  break;
@@ -43415,6 +43430,9 @@ const sqlanvil = $root.sqlanvil = (() => {
43415
43430
  if (message.location != null && message.hasOwnProperty("location"))
43416
43431
  if (!$util.isString(message.location))
43417
43432
  return "location: string expected";
43433
+ if (message.accessToken != null && message.hasOwnProperty("accessToken"))
43434
+ if (!$util.isString(message.accessToken))
43435
+ return "accessToken: string expected";
43418
43436
  return null;
43419
43437
  };
43420
43438
 
@@ -43440,6 +43458,8 @@ const sqlanvil = $root.sqlanvil = (() => {
43440
43458
  message.credentials = String(object.credentials);
43441
43459
  if (object.location != null)
43442
43460
  message.location = String(object.location);
43461
+ if (object.accessToken != null)
43462
+ message.accessToken = String(object.accessToken);
43443
43463
  return message;
43444
43464
  };
43445
43465
 
@@ -43460,6 +43480,7 @@ const sqlanvil = $root.sqlanvil = (() => {
43460
43480
  object.projectId = "";
43461
43481
  object.credentials = "";
43462
43482
  object.location = "";
43483
+ object.accessToken = "";
43463
43484
  }
43464
43485
  if (message.projectId != null && message.hasOwnProperty("projectId"))
43465
43486
  object.projectId = message.projectId;
@@ -43467,6 +43488,8 @@ const sqlanvil = $root.sqlanvil = (() => {
43467
43488
  object.credentials = message.credentials;
43468
43489
  if (message.location != null && message.hasOwnProperty("location"))
43469
43490
  object.location = message.location;
43491
+ if (message.accessToken != null && message.hasOwnProperty("accessToken"))
43492
+ object.accessToken = message.accessToken;
43470
43493
  return object;
43471
43494
  };
43472
43495