@sqlanvil/cli 1.12.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');
@@ -1277,6 +1278,7 @@ const sqlanvil = $root.sqlanvil = (() => {
1277
1278
  * @property {string|null} [project] ConnectionConfig project
1278
1279
  * @property {string|null} [dataset] ConnectionConfig dataset
1279
1280
  * @property {string|null} [saKeyId] ConnectionConfig saKeyId
1281
+ * @property {string|null} [billingProject] ConnectionConfig billingProject
1280
1282
  * @property {string|null} [host] ConnectionConfig host
1281
1283
  * @property {number|null} [port] ConnectionConfig port
1282
1284
  * @property {string|null} [database] ConnectionConfig database
@@ -1330,6 +1332,14 @@ const sqlanvil = $root.sqlanvil = (() => {
1330
1332
  */
1331
1333
  ConnectionConfig.prototype.saKeyId = "";
1332
1334
 
1335
+ /**
1336
+ * ConnectionConfig billingProject.
1337
+ * @member {string} billingProject
1338
+ * @memberof sqlanvil.ConnectionConfig
1339
+ * @instance
1340
+ */
1341
+ ConnectionConfig.prototype.billingProject = "";
1342
+
1333
1343
  /**
1334
1344
  * ConnectionConfig host.
1335
1345
  * @member {string} host
@@ -1402,6 +1412,8 @@ const sqlanvil = $root.sqlanvil = (() => {
1402
1412
  writer.uint32(/* id 7, wireType 2 =*/58).string(message.database);
1403
1413
  if (message.defaultSchema != null && Object.hasOwnProperty.call(message, "defaultSchema"))
1404
1414
  writer.uint32(/* id 8, wireType 2 =*/66).string(message.defaultSchema);
1415
+ if (message.billingProject != null && Object.hasOwnProperty.call(message, "billingProject"))
1416
+ writer.uint32(/* id 9, wireType 2 =*/74).string(message.billingProject);
1405
1417
  return writer;
1406
1418
  };
1407
1419
 
@@ -1458,6 +1470,10 @@ const sqlanvil = $root.sqlanvil = (() => {
1458
1470
  message.saKeyId = reader.string();
1459
1471
  break;
1460
1472
  }
1473
+ case 9: {
1474
+ message.billingProject = reader.string();
1475
+ break;
1476
+ }
1461
1477
  case 5: {
1462
1478
  message.host = reader.string();
1463
1479
  break;
@@ -1525,6 +1541,9 @@ const sqlanvil = $root.sqlanvil = (() => {
1525
1541
  if (message.saKeyId != null && message.hasOwnProperty("saKeyId"))
1526
1542
  if (!$util.isString(message.saKeyId))
1527
1543
  return "saKeyId: string expected";
1544
+ if (message.billingProject != null && message.hasOwnProperty("billingProject"))
1545
+ if (!$util.isString(message.billingProject))
1546
+ return "billingProject: string expected";
1528
1547
  if (message.host != null && message.hasOwnProperty("host"))
1529
1548
  if (!$util.isString(message.host))
1530
1549
  return "host: string expected";
@@ -1564,6 +1583,8 @@ const sqlanvil = $root.sqlanvil = (() => {
1564
1583
  message.dataset = String(object.dataset);
1565
1584
  if (object.saKeyId != null)
1566
1585
  message.saKeyId = String(object.saKeyId);
1586
+ if (object.billingProject != null)
1587
+ message.billingProject = String(object.billingProject);
1567
1588
  if (object.host != null)
1568
1589
  message.host = String(object.host);
1569
1590
  if (object.port != null)
@@ -1597,6 +1618,7 @@ const sqlanvil = $root.sqlanvil = (() => {
1597
1618
  object.port = 0;
1598
1619
  object.database = "";
1599
1620
  object.defaultSchema = "";
1621
+ object.billingProject = "";
1600
1622
  }
1601
1623
  if (message.platform != null && message.hasOwnProperty("platform"))
1602
1624
  object.platform = message.platform;
@@ -1614,6 +1636,8 @@ const sqlanvil = $root.sqlanvil = (() => {
1614
1636
  object.database = message.database;
1615
1637
  if (message.defaultSchema != null && message.hasOwnProperty("defaultSchema"))
1616
1638
  object.defaultSchema = message.defaultSchema;
1639
+ if (message.billingProject != null && message.hasOwnProperty("billingProject"))
1640
+ object.billingProject = message.billingProject;
1617
1641
  return object;
1618
1642
  };
1619
1643
 
@@ -43282,6 +43306,7 @@ const sqlanvil = $root.sqlanvil = (() => {
43282
43306
  * @property {string|null} [projectId] BigQuery projectId
43283
43307
  * @property {string|null} [credentials] BigQuery credentials
43284
43308
  * @property {string|null} [location] BigQuery location
43309
+ * @property {string|null} [accessToken] BigQuery accessToken
43285
43310
  */
43286
43311
 
43287
43312
  /**
@@ -43323,6 +43348,14 @@ const sqlanvil = $root.sqlanvil = (() => {
43323
43348
  */
43324
43349
  BigQuery.prototype.location = "";
43325
43350
 
43351
+ /**
43352
+ * BigQuery accessToken.
43353
+ * @member {string} accessToken
43354
+ * @memberof sqlanvil.BigQuery
43355
+ * @instance
43356
+ */
43357
+ BigQuery.prototype.accessToken = "";
43358
+
43326
43359
  /**
43327
43360
  * Creates a new BigQuery instance using the specified properties.
43328
43361
  * @function create
@@ -43353,6 +43386,8 @@ const sqlanvil = $root.sqlanvil = (() => {
43353
43386
  writer.uint32(/* id 3, wireType 2 =*/26).string(message.credentials);
43354
43387
  if (message.location != null && Object.hasOwnProperty.call(message, "location"))
43355
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);
43356
43391
  return writer;
43357
43392
  };
43358
43393
 
@@ -43405,6 +43440,10 @@ const sqlanvil = $root.sqlanvil = (() => {
43405
43440
  message.location = reader.string();
43406
43441
  break;
43407
43442
  }
43443
+ case 5: {
43444
+ message.accessToken = reader.string();
43445
+ break;
43446
+ }
43408
43447
  default:
43409
43448
  reader.skipType(tag & 7, long);
43410
43449
  break;
@@ -43453,6 +43492,9 @@ const sqlanvil = $root.sqlanvil = (() => {
43453
43492
  if (message.location != null && message.hasOwnProperty("location"))
43454
43493
  if (!$util.isString(message.location))
43455
43494
  return "location: string expected";
43495
+ if (message.accessToken != null && message.hasOwnProperty("accessToken"))
43496
+ if (!$util.isString(message.accessToken))
43497
+ return "accessToken: string expected";
43456
43498
  return null;
43457
43499
  };
43458
43500
 
@@ -43478,6 +43520,8 @@ const sqlanvil = $root.sqlanvil = (() => {
43478
43520
  message.credentials = String(object.credentials);
43479
43521
  if (object.location != null)
43480
43522
  message.location = String(object.location);
43523
+ if (object.accessToken != null)
43524
+ message.accessToken = String(object.accessToken);
43481
43525
  return message;
43482
43526
  };
43483
43527
 
@@ -43498,6 +43542,7 @@ const sqlanvil = $root.sqlanvil = (() => {
43498
43542
  object.projectId = "";
43499
43543
  object.credentials = "";
43500
43544
  object.location = "";
43545
+ object.accessToken = "";
43501
43546
  }
43502
43547
  if (message.projectId != null && message.hasOwnProperty("projectId"))
43503
43548
  object.projectId = message.projectId;
@@ -43505,6 +43550,8 @@ const sqlanvil = $root.sqlanvil = (() => {
43505
43550
  object.credentials = message.credentials;
43506
43551
  if (message.location != null && message.hasOwnProperty("location"))
43507
43552
  object.location = message.location;
43553
+ if (message.accessToken != null && message.hasOwnProperty("accessToken"))
43554
+ object.accessToken = message.accessToken;
43508
43555
  return object;
43509
43556
  };
43510
43557
 
@@ -46319,7 +46366,7 @@ function collectEvaluationQueries(queryOrAction, concatenate, queryModifier = (q
46319
46366
  .filter(validationQuery => !!validationQuery.query);
46320
46367
  }
46321
46368
 
46322
- const version = "1.12.0";
46369
+ const version = "1.14.0";
46323
46370
  const dataformVersion = "3.0.60";
46324
46371
 
46325
46372
  async function build(compiledGraph, runConfig, dbadapter) {
@@ -48436,6 +48483,19 @@ class LimitedResultSet {
48436
48483
  }
48437
48484
 
48438
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
+ }
48439
48499
  const BIGQUERY_DATE_RELATED_FIELDS = [
48440
48500
  "BigQueryDate",
48441
48501
  "BigQueryTime",
@@ -48635,12 +48695,7 @@ class BigQueryDbAdapter {
48635
48695
  }
48636
48696
  projectId = projectId || this.bigQueryCredentials.projectId;
48637
48697
  if (!this.clients.has(projectId)) {
48638
- this.clients.set(projectId, new bigquery.BigQuery({
48639
- projectId,
48640
- scopes: EXTRA_GOOGLE_SCOPES,
48641
- location: this.bigQueryCredentials.location,
48642
- credentials: this.bigQueryCredentials.credentials && JSON.parse(this.bigQueryCredentials.credentials)
48643
- }));
48698
+ this.clients.set(projectId, new bigquery.BigQuery(bigQueryClientOptions(this.bigQueryCredentials, projectId)));
48644
48699
  }
48645
48700
  return this.clients.get(projectId);
48646
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.12.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
@@ -1216,6 +1216,7 @@ const sqlanvil = $root.sqlanvil = (() => {
1216
1216
  * @property {string|null} [project] ConnectionConfig project
1217
1217
  * @property {string|null} [dataset] ConnectionConfig dataset
1218
1218
  * @property {string|null} [saKeyId] ConnectionConfig saKeyId
1219
+ * @property {string|null} [billingProject] ConnectionConfig billingProject
1219
1220
  * @property {string|null} [host] ConnectionConfig host
1220
1221
  * @property {number|null} [port] ConnectionConfig port
1221
1222
  * @property {string|null} [database] ConnectionConfig database
@@ -1269,6 +1270,14 @@ const sqlanvil = $root.sqlanvil = (() => {
1269
1270
  */
1270
1271
  ConnectionConfig.prototype.saKeyId = "";
1271
1272
 
1273
+ /**
1274
+ * ConnectionConfig billingProject.
1275
+ * @member {string} billingProject
1276
+ * @memberof sqlanvil.ConnectionConfig
1277
+ * @instance
1278
+ */
1279
+ ConnectionConfig.prototype.billingProject = "";
1280
+
1272
1281
  /**
1273
1282
  * ConnectionConfig host.
1274
1283
  * @member {string} host
@@ -1341,6 +1350,8 @@ const sqlanvil = $root.sqlanvil = (() => {
1341
1350
  writer.uint32(/* id 7, wireType 2 =*/58).string(message.database);
1342
1351
  if (message.defaultSchema != null && Object.hasOwnProperty.call(message, "defaultSchema"))
1343
1352
  writer.uint32(/* id 8, wireType 2 =*/66).string(message.defaultSchema);
1353
+ if (message.billingProject != null && Object.hasOwnProperty.call(message, "billingProject"))
1354
+ writer.uint32(/* id 9, wireType 2 =*/74).string(message.billingProject);
1344
1355
  return writer;
1345
1356
  };
1346
1357
 
@@ -1397,6 +1408,10 @@ const sqlanvil = $root.sqlanvil = (() => {
1397
1408
  message.saKeyId = reader.string();
1398
1409
  break;
1399
1410
  }
1411
+ case 9: {
1412
+ message.billingProject = reader.string();
1413
+ break;
1414
+ }
1400
1415
  case 5: {
1401
1416
  message.host = reader.string();
1402
1417
  break;
@@ -1464,6 +1479,9 @@ const sqlanvil = $root.sqlanvil = (() => {
1464
1479
  if (message.saKeyId != null && message.hasOwnProperty("saKeyId"))
1465
1480
  if (!$util.isString(message.saKeyId))
1466
1481
  return "saKeyId: string expected";
1482
+ if (message.billingProject != null && message.hasOwnProperty("billingProject"))
1483
+ if (!$util.isString(message.billingProject))
1484
+ return "billingProject: string expected";
1467
1485
  if (message.host != null && message.hasOwnProperty("host"))
1468
1486
  if (!$util.isString(message.host))
1469
1487
  return "host: string expected";
@@ -1503,6 +1521,8 @@ const sqlanvil = $root.sqlanvil = (() => {
1503
1521
  message.dataset = String(object.dataset);
1504
1522
  if (object.saKeyId != null)
1505
1523
  message.saKeyId = String(object.saKeyId);
1524
+ if (object.billingProject != null)
1525
+ message.billingProject = String(object.billingProject);
1506
1526
  if (object.host != null)
1507
1527
  message.host = String(object.host);
1508
1528
  if (object.port != null)
@@ -1536,6 +1556,7 @@ const sqlanvil = $root.sqlanvil = (() => {
1536
1556
  object.port = 0;
1537
1557
  object.database = "";
1538
1558
  object.defaultSchema = "";
1559
+ object.billingProject = "";
1539
1560
  }
1540
1561
  if (message.platform != null && message.hasOwnProperty("platform"))
1541
1562
  object.platform = message.platform;
@@ -1553,6 +1574,8 @@ const sqlanvil = $root.sqlanvil = (() => {
1553
1574
  object.database = message.database;
1554
1575
  if (message.defaultSchema != null && message.hasOwnProperty("defaultSchema"))
1555
1576
  object.defaultSchema = message.defaultSchema;
1577
+ if (message.billingProject != null && message.hasOwnProperty("billingProject"))
1578
+ object.billingProject = message.billingProject;
1556
1579
  return object;
1557
1580
  };
1558
1581
 
@@ -43221,6 +43244,7 @@ const sqlanvil = $root.sqlanvil = (() => {
43221
43244
  * @property {string|null} [projectId] BigQuery projectId
43222
43245
  * @property {string|null} [credentials] BigQuery credentials
43223
43246
  * @property {string|null} [location] BigQuery location
43247
+ * @property {string|null} [accessToken] BigQuery accessToken
43224
43248
  */
43225
43249
 
43226
43250
  /**
@@ -43262,6 +43286,14 @@ const sqlanvil = $root.sqlanvil = (() => {
43262
43286
  */
43263
43287
  BigQuery.prototype.location = "";
43264
43288
 
43289
+ /**
43290
+ * BigQuery accessToken.
43291
+ * @member {string} accessToken
43292
+ * @memberof sqlanvil.BigQuery
43293
+ * @instance
43294
+ */
43295
+ BigQuery.prototype.accessToken = "";
43296
+
43265
43297
  /**
43266
43298
  * Creates a new BigQuery instance using the specified properties.
43267
43299
  * @function create
@@ -43292,6 +43324,8 @@ const sqlanvil = $root.sqlanvil = (() => {
43292
43324
  writer.uint32(/* id 3, wireType 2 =*/26).string(message.credentials);
43293
43325
  if (message.location != null && Object.hasOwnProperty.call(message, "location"))
43294
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);
43295
43329
  return writer;
43296
43330
  };
43297
43331
 
@@ -43344,6 +43378,10 @@ const sqlanvil = $root.sqlanvil = (() => {
43344
43378
  message.location = reader.string();
43345
43379
  break;
43346
43380
  }
43381
+ case 5: {
43382
+ message.accessToken = reader.string();
43383
+ break;
43384
+ }
43347
43385
  default:
43348
43386
  reader.skipType(tag & 7, long);
43349
43387
  break;
@@ -43392,6 +43430,9 @@ const sqlanvil = $root.sqlanvil = (() => {
43392
43430
  if (message.location != null && message.hasOwnProperty("location"))
43393
43431
  if (!$util.isString(message.location))
43394
43432
  return "location: string expected";
43433
+ if (message.accessToken != null && message.hasOwnProperty("accessToken"))
43434
+ if (!$util.isString(message.accessToken))
43435
+ return "accessToken: string expected";
43395
43436
  return null;
43396
43437
  };
43397
43438
 
@@ -43417,6 +43458,8 @@ const sqlanvil = $root.sqlanvil = (() => {
43417
43458
  message.credentials = String(object.credentials);
43418
43459
  if (object.location != null)
43419
43460
  message.location = String(object.location);
43461
+ if (object.accessToken != null)
43462
+ message.accessToken = String(object.accessToken);
43420
43463
  return message;
43421
43464
  };
43422
43465
 
@@ -43437,6 +43480,7 @@ const sqlanvil = $root.sqlanvil = (() => {
43437
43480
  object.projectId = "";
43438
43481
  object.credentials = "";
43439
43482
  object.location = "";
43483
+ object.accessToken = "";
43440
43484
  }
43441
43485
  if (message.projectId != null && message.hasOwnProperty("projectId"))
43442
43486
  object.projectId = message.projectId;
@@ -43444,6 +43488,8 @@ const sqlanvil = $root.sqlanvil = (() => {
43444
43488
  object.credentials = message.credentials;
43445
43489
  if (message.location != null && message.hasOwnProperty("location"))
43446
43490
  object.location = message.location;
43491
+ if (message.accessToken != null && message.hasOwnProperty("accessToken"))
43492
+ object.accessToken = message.accessToken;
43447
43493
  return object;
43448
43494
  };
43449
43495