@sqlanvil/cli 1.4.1 → 1.6.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 EventEmitter = require('events');
35
35
  var Long = require('long');
36
36
  var promisePoolExecutor = require('promise-pool-executor');
37
37
  var sizeof = require('object-sizeof');
38
+ var mysql = require('mysql2/promise');
38
39
  var QueryStream = require('pg-query-stream');
39
40
  var readlineSync = require('readline-sync');
40
41
  var untildify = require('untildify');
@@ -78,6 +79,7 @@ var pg__namespace = /*#__PURE__*/_interopNamespace(pg);
78
79
  var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
79
80
  var Long__default = /*#__PURE__*/_interopDefaultLegacy(Long);
80
81
  var sizeof__default = /*#__PURE__*/_interopDefaultLegacy(sizeof);
82
+ var mysql__namespace = /*#__PURE__*/_interopNamespace(mysql);
81
83
  var QueryStream__default = /*#__PURE__*/_interopDefaultLegacy(QueryStream);
82
84
  var readlineSync__namespace = /*#__PURE__*/_interopNamespace(readlineSync);
83
85
  var untildify__default = /*#__PURE__*/_interopDefaultLegacy(untildify);
@@ -3816,6 +3818,7 @@ const sqlanvil = $root.sqlanvil = (() => {
3816
3818
  * @property {string|null} [reservation] TableConfig reservation
3817
3819
  * @property {sqlanvil.IPostgresOptions|null} [postgres] TableConfig postgres
3818
3820
  * @property {sqlanvil.ISupabaseOptions|null} [supabase] TableConfig supabase
3821
+ * @property {sqlanvil.IMysqlOptions|null} [mysql] TableConfig mysql
3819
3822
  */
3820
3823
 
3821
3824
  /**
@@ -4041,6 +4044,14 @@ const sqlanvil = $root.sqlanvil = (() => {
4041
4044
  */
4042
4045
  TableConfig.prototype.supabase = null;
4043
4046
 
4047
+ /**
4048
+ * TableConfig mysql.
4049
+ * @member {sqlanvil.IMysqlOptions|null|undefined} mysql
4050
+ * @memberof sqlanvil.ActionConfig.TableConfig
4051
+ * @instance
4052
+ */
4053
+ TableConfig.prototype.mysql = null;
4054
+
4044
4055
  /**
4045
4056
  * Creates a new TableConfig instance using the specified properties.
4046
4057
  * @function create
@@ -4123,6 +4134,8 @@ const sqlanvil = $root.sqlanvil = (() => {
4123
4134
  $root.sqlanvil.PostgresOptions.encode(message.postgres, writer.uint32(/* id 25, wireType 2 =*/202).fork()).ldelim();
4124
4135
  if (message.supabase != null && Object.hasOwnProperty.call(message, "supabase"))
4125
4136
  $root.sqlanvil.SupabaseOptions.encode(message.supabase, writer.uint32(/* id 26, wireType 2 =*/210).fork()).ldelim();
4137
+ if (message.mysql != null && Object.hasOwnProperty.call(message, "mysql"))
4138
+ $root.sqlanvil.MysqlOptions.encode(message.mysql, writer.uint32(/* id 27, wireType 2 =*/218).fork()).ldelim();
4126
4139
  return writer;
4127
4140
  };
4128
4141
 
@@ -4309,6 +4322,10 @@ const sqlanvil = $root.sqlanvil = (() => {
4309
4322
  message.supabase = $root.sqlanvil.SupabaseOptions.decode(reader, reader.uint32());
4310
4323
  break;
4311
4324
  }
4325
+ case 27: {
4326
+ message.mysql = $root.sqlanvil.MysqlOptions.decode(reader, reader.uint32());
4327
+ break;
4328
+ }
4312
4329
  default:
4313
4330
  reader.skipType(tag & 7);
4314
4331
  break;
@@ -4467,6 +4484,11 @@ const sqlanvil = $root.sqlanvil = (() => {
4467
4484
  if (error)
4468
4485
  return "supabase." + error;
4469
4486
  }
4487
+ if (message.mysql != null && message.hasOwnProperty("mysql")) {
4488
+ let error = $root.sqlanvil.MysqlOptions.verify(message.mysql);
4489
+ if (error)
4490
+ return "mysql." + error;
4491
+ }
4470
4492
  return null;
4471
4493
  };
4472
4494
 
@@ -4593,6 +4615,11 @@ const sqlanvil = $root.sqlanvil = (() => {
4593
4615
  throw TypeError(".sqlanvil.ActionConfig.TableConfig.supabase: object expected");
4594
4616
  message.supabase = $root.sqlanvil.SupabaseOptions.fromObject(object.supabase);
4595
4617
  }
4618
+ if (object.mysql != null) {
4619
+ if (typeof object.mysql !== "object")
4620
+ throw TypeError(".sqlanvil.ActionConfig.TableConfig.mysql: object expected");
4621
+ message.mysql = $root.sqlanvil.MysqlOptions.fromObject(object.mysql);
4622
+ }
4596
4623
  return message;
4597
4624
  };
4598
4625
 
@@ -4639,6 +4666,7 @@ const sqlanvil = $root.sqlanvil = (() => {
4639
4666
  object.reservation = "";
4640
4667
  object.postgres = null;
4641
4668
  object.supabase = null;
4669
+ object.mysql = null;
4642
4670
  }
4643
4671
  if (message.name != null && message.hasOwnProperty("name"))
4644
4672
  object.name = message.name;
@@ -4715,6 +4743,8 @@ const sqlanvil = $root.sqlanvil = (() => {
4715
4743
  object.postgres = $root.sqlanvil.PostgresOptions.toObject(message.postgres, options);
4716
4744
  if (message.supabase != null && message.hasOwnProperty("supabase"))
4717
4745
  object.supabase = $root.sqlanvil.SupabaseOptions.toObject(message.supabase, options);
4746
+ if (message.mysql != null && message.hasOwnProperty("mysql"))
4747
+ object.mysql = $root.sqlanvil.MysqlOptions.toObject(message.mysql, options);
4718
4748
  return object;
4719
4749
  };
4720
4750
 
@@ -5917,6 +5947,7 @@ const sqlanvil = $root.sqlanvil = (() => {
5917
5947
  * @property {string|null} [reservation] IncrementalTableConfig reservation
5918
5948
  * @property {sqlanvil.IPostgresOptions|null} [postgres] IncrementalTableConfig postgres
5919
5949
  * @property {sqlanvil.ISupabaseOptions|null} [supabase] IncrementalTableConfig supabase
5950
+ * @property {sqlanvil.IMysqlOptions|null} [mysql] IncrementalTableConfig mysql
5920
5951
  */
5921
5952
 
5922
5953
  /**
@@ -6175,6 +6206,14 @@ const sqlanvil = $root.sqlanvil = (() => {
6175
6206
  */
6176
6207
  IncrementalTableConfig.prototype.supabase = null;
6177
6208
 
6209
+ /**
6210
+ * IncrementalTableConfig mysql.
6211
+ * @member {sqlanvil.IMysqlOptions|null|undefined} mysql
6212
+ * @memberof sqlanvil.ActionConfig.IncrementalTableConfig
6213
+ * @instance
6214
+ */
6215
+ IncrementalTableConfig.prototype.mysql = null;
6216
+
6178
6217
  /**
6179
6218
  * Creates a new IncrementalTableConfig instance using the specified properties.
6180
6219
  * @function create
@@ -6266,6 +6305,8 @@ const sqlanvil = $root.sqlanvil = (() => {
6266
6305
  $root.sqlanvil.PostgresOptions.encode(message.postgres, writer.uint32(/* id 28, wireType 2 =*/226).fork()).ldelim();
6267
6306
  if (message.supabase != null && Object.hasOwnProperty.call(message, "supabase"))
6268
6307
  $root.sqlanvil.SupabaseOptions.encode(message.supabase, writer.uint32(/* id 29, wireType 2 =*/234).fork()).ldelim();
6308
+ if (message.mysql != null && Object.hasOwnProperty.call(message, "mysql"))
6309
+ $root.sqlanvil.MysqlOptions.encode(message.mysql, writer.uint32(/* id 30, wireType 2 =*/242).fork()).ldelim();
6269
6310
  return writer;
6270
6311
  };
6271
6312
 
@@ -6470,6 +6511,10 @@ const sqlanvil = $root.sqlanvil = (() => {
6470
6511
  message.supabase = $root.sqlanvil.SupabaseOptions.decode(reader, reader.uint32());
6471
6512
  break;
6472
6513
  }
6514
+ case 30: {
6515
+ message.mysql = $root.sqlanvil.MysqlOptions.decode(reader, reader.uint32());
6516
+ break;
6517
+ }
6473
6518
  default:
6474
6519
  reader.skipType(tag & 7);
6475
6520
  break;
@@ -6651,6 +6696,11 @@ const sqlanvil = $root.sqlanvil = (() => {
6651
6696
  if (error)
6652
6697
  return "supabase." + error;
6653
6698
  }
6699
+ if (message.mysql != null && message.hasOwnProperty("mysql")) {
6700
+ let error = $root.sqlanvil.MysqlOptions.verify(message.mysql);
6701
+ if (error)
6702
+ return "mysql." + error;
6703
+ }
6654
6704
  return null;
6655
6705
  };
6656
6706
 
@@ -6812,6 +6862,11 @@ const sqlanvil = $root.sqlanvil = (() => {
6812
6862
  throw TypeError(".sqlanvil.ActionConfig.IncrementalTableConfig.supabase: object expected");
6813
6863
  message.supabase = $root.sqlanvil.SupabaseOptions.fromObject(object.supabase);
6814
6864
  }
6865
+ if (object.mysql != null) {
6866
+ if (typeof object.mysql !== "object")
6867
+ throw TypeError(".sqlanvil.ActionConfig.IncrementalTableConfig.mysql: object expected");
6868
+ message.mysql = $root.sqlanvil.MysqlOptions.fromObject(object.mysql);
6869
+ }
6815
6870
  return message;
6816
6871
  };
6817
6872
 
@@ -6862,6 +6917,7 @@ const sqlanvil = $root.sqlanvil = (() => {
6862
6917
  object.reservation = "";
6863
6918
  object.postgres = null;
6864
6919
  object.supabase = null;
6920
+ object.mysql = null;
6865
6921
  }
6866
6922
  if (message.name != null && message.hasOwnProperty("name"))
6867
6923
  object.name = message.name;
@@ -6949,6 +7005,8 @@ const sqlanvil = $root.sqlanvil = (() => {
6949
7005
  object.postgres = $root.sqlanvil.PostgresOptions.toObject(message.postgres, options);
6950
7006
  if (message.supabase != null && message.hasOwnProperty("supabase"))
6951
7007
  object.supabase = $root.sqlanvil.SupabaseOptions.toObject(message.supabase, options);
7008
+ if (message.mysql != null && message.hasOwnProperty("mysql"))
7009
+ object.mysql = $root.sqlanvil.MysqlOptions.toObject(message.mysql, options);
6952
7010
  return object;
6953
7011
  };
6954
7012
 
@@ -13409,6 +13467,572 @@ const sqlanvil = $root.sqlanvil = (() => {
13409
13467
  return PostgresOptions;
13410
13468
  })();
13411
13469
 
13470
+ sqlanvil.MysqlOptions = (function() {
13471
+
13472
+ /**
13473
+ * Properties of a MysqlOptions.
13474
+ * @memberof sqlanvil
13475
+ * @interface IMysqlOptions
13476
+ * @property {string|null} [engine] MysqlOptions engine
13477
+ * @property {string|null} [charset] MysqlOptions charset
13478
+ * @property {string|null} [collation] MysqlOptions collation
13479
+ * @property {Array.<sqlanvil.MysqlOptions.IIndex>|null} [indexes] MysqlOptions indexes
13480
+ */
13481
+
13482
+ /**
13483
+ * Constructs a new MysqlOptions.
13484
+ * @memberof sqlanvil
13485
+ * @classdesc Represents a MysqlOptions.
13486
+ * @implements IMysqlOptions
13487
+ * @constructor
13488
+ * @param {sqlanvil.IMysqlOptions=} [properties] Properties to set
13489
+ */
13490
+ function MysqlOptions(properties) {
13491
+ this.indexes = [];
13492
+ if (properties)
13493
+ for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
13494
+ if (properties[keys[i]] != null)
13495
+ this[keys[i]] = properties[keys[i]];
13496
+ }
13497
+
13498
+ /**
13499
+ * MysqlOptions engine.
13500
+ * @member {string} engine
13501
+ * @memberof sqlanvil.MysqlOptions
13502
+ * @instance
13503
+ */
13504
+ MysqlOptions.prototype.engine = "";
13505
+
13506
+ /**
13507
+ * MysqlOptions charset.
13508
+ * @member {string} charset
13509
+ * @memberof sqlanvil.MysqlOptions
13510
+ * @instance
13511
+ */
13512
+ MysqlOptions.prototype.charset = "";
13513
+
13514
+ /**
13515
+ * MysqlOptions collation.
13516
+ * @member {string} collation
13517
+ * @memberof sqlanvil.MysqlOptions
13518
+ * @instance
13519
+ */
13520
+ MysqlOptions.prototype.collation = "";
13521
+
13522
+ /**
13523
+ * MysqlOptions indexes.
13524
+ * @member {Array.<sqlanvil.MysqlOptions.IIndex>} indexes
13525
+ * @memberof sqlanvil.MysqlOptions
13526
+ * @instance
13527
+ */
13528
+ MysqlOptions.prototype.indexes = $util.emptyArray;
13529
+
13530
+ /**
13531
+ * Creates a new MysqlOptions instance using the specified properties.
13532
+ * @function create
13533
+ * @memberof sqlanvil.MysqlOptions
13534
+ * @static
13535
+ * @param {sqlanvil.IMysqlOptions=} [properties] Properties to set
13536
+ * @returns {sqlanvil.MysqlOptions} MysqlOptions instance
13537
+ */
13538
+ MysqlOptions.create = function create(properties) {
13539
+ return new MysqlOptions(properties);
13540
+ };
13541
+
13542
+ /**
13543
+ * Encodes the specified MysqlOptions message. Does not implicitly {@link sqlanvil.MysqlOptions.verify|verify} messages.
13544
+ * @function encode
13545
+ * @memberof sqlanvil.MysqlOptions
13546
+ * @static
13547
+ * @param {sqlanvil.IMysqlOptions} message MysqlOptions message or plain object to encode
13548
+ * @param {$protobuf.Writer} [writer] Writer to encode to
13549
+ * @returns {$protobuf.Writer} Writer
13550
+ */
13551
+ MysqlOptions.encode = function encode(message, writer) {
13552
+ if (!writer)
13553
+ writer = $Writer.create();
13554
+ if (message.engine != null && Object.hasOwnProperty.call(message, "engine"))
13555
+ writer.uint32(/* id 1, wireType 2 =*/10).string(message.engine);
13556
+ if (message.charset != null && Object.hasOwnProperty.call(message, "charset"))
13557
+ writer.uint32(/* id 2, wireType 2 =*/18).string(message.charset);
13558
+ if (message.collation != null && Object.hasOwnProperty.call(message, "collation"))
13559
+ writer.uint32(/* id 3, wireType 2 =*/26).string(message.collation);
13560
+ if (message.indexes != null && message.indexes.length)
13561
+ for (let i = 0; i < message.indexes.length; ++i)
13562
+ $root.sqlanvil.MysqlOptions.Index.encode(message.indexes[i], writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim();
13563
+ return writer;
13564
+ };
13565
+
13566
+ /**
13567
+ * Encodes the specified MysqlOptions message, length delimited. Does not implicitly {@link sqlanvil.MysqlOptions.verify|verify} messages.
13568
+ * @function encodeDelimited
13569
+ * @memberof sqlanvil.MysqlOptions
13570
+ * @static
13571
+ * @param {sqlanvil.IMysqlOptions} message MysqlOptions message or plain object to encode
13572
+ * @param {$protobuf.Writer} [writer] Writer to encode to
13573
+ * @returns {$protobuf.Writer} Writer
13574
+ */
13575
+ MysqlOptions.encodeDelimited = function encodeDelimited(message, writer) {
13576
+ return this.encode(message, writer).ldelim();
13577
+ };
13578
+
13579
+ /**
13580
+ * Decodes a MysqlOptions message from the specified reader or buffer.
13581
+ * @function decode
13582
+ * @memberof sqlanvil.MysqlOptions
13583
+ * @static
13584
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
13585
+ * @param {number} [length] Message length if known beforehand
13586
+ * @returns {sqlanvil.MysqlOptions} MysqlOptions
13587
+ * @throws {Error} If the payload is not a reader or valid buffer
13588
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
13589
+ */
13590
+ MysqlOptions.decode = function decode(reader, length, error) {
13591
+ if (!(reader instanceof $Reader))
13592
+ reader = $Reader.create(reader);
13593
+ let end = length === undefined ? reader.len : reader.pos + length, message = new $root.sqlanvil.MysqlOptions();
13594
+ while (reader.pos < end) {
13595
+ let tag = reader.uint32();
13596
+ if (tag === error)
13597
+ break;
13598
+ switch (tag >>> 3) {
13599
+ case 1: {
13600
+ message.engine = reader.string();
13601
+ break;
13602
+ }
13603
+ case 2: {
13604
+ message.charset = reader.string();
13605
+ break;
13606
+ }
13607
+ case 3: {
13608
+ message.collation = reader.string();
13609
+ break;
13610
+ }
13611
+ case 4: {
13612
+ if (!(message.indexes && message.indexes.length))
13613
+ message.indexes = [];
13614
+ message.indexes.push($root.sqlanvil.MysqlOptions.Index.decode(reader, reader.uint32()));
13615
+ break;
13616
+ }
13617
+ default:
13618
+ reader.skipType(tag & 7);
13619
+ break;
13620
+ }
13621
+ }
13622
+ return message;
13623
+ };
13624
+
13625
+ /**
13626
+ * Decodes a MysqlOptions message from the specified reader or buffer, length delimited.
13627
+ * @function decodeDelimited
13628
+ * @memberof sqlanvil.MysqlOptions
13629
+ * @static
13630
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
13631
+ * @returns {sqlanvil.MysqlOptions} MysqlOptions
13632
+ * @throws {Error} If the payload is not a reader or valid buffer
13633
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
13634
+ */
13635
+ MysqlOptions.decodeDelimited = function decodeDelimited(reader) {
13636
+ if (!(reader instanceof $Reader))
13637
+ reader = new $Reader(reader);
13638
+ return this.decode(reader, reader.uint32());
13639
+ };
13640
+
13641
+ /**
13642
+ * Verifies a MysqlOptions message.
13643
+ * @function verify
13644
+ * @memberof sqlanvil.MysqlOptions
13645
+ * @static
13646
+ * @param {Object.<string,*>} message Plain object to verify
13647
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
13648
+ */
13649
+ MysqlOptions.verify = function verify(message) {
13650
+ if (typeof message !== "object" || message === null)
13651
+ return "object expected";
13652
+ if (message.engine != null && message.hasOwnProperty("engine"))
13653
+ if (!$util.isString(message.engine))
13654
+ return "engine: string expected";
13655
+ if (message.charset != null && message.hasOwnProperty("charset"))
13656
+ if (!$util.isString(message.charset))
13657
+ return "charset: string expected";
13658
+ if (message.collation != null && message.hasOwnProperty("collation"))
13659
+ if (!$util.isString(message.collation))
13660
+ return "collation: string expected";
13661
+ if (message.indexes != null && message.hasOwnProperty("indexes")) {
13662
+ if (!Array.isArray(message.indexes))
13663
+ return "indexes: array expected";
13664
+ for (let i = 0; i < message.indexes.length; ++i) {
13665
+ let error = $root.sqlanvil.MysqlOptions.Index.verify(message.indexes[i]);
13666
+ if (error)
13667
+ return "indexes." + error;
13668
+ }
13669
+ }
13670
+ return null;
13671
+ };
13672
+
13673
+ /**
13674
+ * Creates a MysqlOptions message from a plain object. Also converts values to their respective internal types.
13675
+ * @function fromObject
13676
+ * @memberof sqlanvil.MysqlOptions
13677
+ * @static
13678
+ * @param {Object.<string,*>} object Plain object
13679
+ * @returns {sqlanvil.MysqlOptions} MysqlOptions
13680
+ */
13681
+ MysqlOptions.fromObject = function fromObject(object) {
13682
+ if (object instanceof $root.sqlanvil.MysqlOptions)
13683
+ return object;
13684
+ let message = new $root.sqlanvil.MysqlOptions();
13685
+ if (object.engine != null)
13686
+ message.engine = String(object.engine);
13687
+ if (object.charset != null)
13688
+ message.charset = String(object.charset);
13689
+ if (object.collation != null)
13690
+ message.collation = String(object.collation);
13691
+ if (object.indexes) {
13692
+ if (!Array.isArray(object.indexes))
13693
+ throw TypeError(".sqlanvil.MysqlOptions.indexes: array expected");
13694
+ message.indexes = [];
13695
+ for (let i = 0; i < object.indexes.length; ++i) {
13696
+ if (typeof object.indexes[i] !== "object")
13697
+ throw TypeError(".sqlanvil.MysqlOptions.indexes: object expected");
13698
+ message.indexes[i] = $root.sqlanvil.MysqlOptions.Index.fromObject(object.indexes[i]);
13699
+ }
13700
+ }
13701
+ return message;
13702
+ };
13703
+
13704
+ /**
13705
+ * Creates a plain object from a MysqlOptions message. Also converts values to other types if specified.
13706
+ * @function toObject
13707
+ * @memberof sqlanvil.MysqlOptions
13708
+ * @static
13709
+ * @param {sqlanvil.MysqlOptions} message MysqlOptions
13710
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
13711
+ * @returns {Object.<string,*>} Plain object
13712
+ */
13713
+ MysqlOptions.toObject = function toObject(message, options) {
13714
+ if (!options)
13715
+ options = {};
13716
+ let object = {};
13717
+ if (options.arrays || options.defaults)
13718
+ object.indexes = [];
13719
+ if (options.defaults) {
13720
+ object.engine = "";
13721
+ object.charset = "";
13722
+ object.collation = "";
13723
+ }
13724
+ if (message.engine != null && message.hasOwnProperty("engine"))
13725
+ object.engine = message.engine;
13726
+ if (message.charset != null && message.hasOwnProperty("charset"))
13727
+ object.charset = message.charset;
13728
+ if (message.collation != null && message.hasOwnProperty("collation"))
13729
+ object.collation = message.collation;
13730
+ if (message.indexes && message.indexes.length) {
13731
+ object.indexes = [];
13732
+ for (let j = 0; j < message.indexes.length; ++j)
13733
+ object.indexes[j] = $root.sqlanvil.MysqlOptions.Index.toObject(message.indexes[j], options);
13734
+ }
13735
+ return object;
13736
+ };
13737
+
13738
+ /**
13739
+ * Converts this MysqlOptions to JSON.
13740
+ * @function toJSON
13741
+ * @memberof sqlanvil.MysqlOptions
13742
+ * @instance
13743
+ * @returns {Object.<string,*>} JSON object
13744
+ */
13745
+ MysqlOptions.prototype.toJSON = function toJSON() {
13746
+ return this.constructor.toObject(this, $protobuf__namespace.util.toJSONOptions);
13747
+ };
13748
+
13749
+ /**
13750
+ * Gets the default type url for MysqlOptions
13751
+ * @function getTypeUrl
13752
+ * @memberof sqlanvil.MysqlOptions
13753
+ * @static
13754
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
13755
+ * @returns {string} The default type url
13756
+ */
13757
+ MysqlOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
13758
+ if (typeUrlPrefix === undefined) {
13759
+ typeUrlPrefix = "type.googleapis.com";
13760
+ }
13761
+ return typeUrlPrefix + "/sqlanvil.MysqlOptions";
13762
+ };
13763
+
13764
+ MysqlOptions.Index = (function() {
13765
+
13766
+ /**
13767
+ * Properties of an Index.
13768
+ * @memberof sqlanvil.MysqlOptions
13769
+ * @interface IIndex
13770
+ * @property {string|null} [name] Index name
13771
+ * @property {Array.<string>|null} [columns] Index columns
13772
+ * @property {boolean|null} [unique] Index unique
13773
+ */
13774
+
13775
+ /**
13776
+ * Constructs a new Index.
13777
+ * @memberof sqlanvil.MysqlOptions
13778
+ * @classdesc Represents an Index.
13779
+ * @implements IIndex
13780
+ * @constructor
13781
+ * @param {sqlanvil.MysqlOptions.IIndex=} [properties] Properties to set
13782
+ */
13783
+ function Index(properties) {
13784
+ this.columns = [];
13785
+ if (properties)
13786
+ for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
13787
+ if (properties[keys[i]] != null)
13788
+ this[keys[i]] = properties[keys[i]];
13789
+ }
13790
+
13791
+ /**
13792
+ * Index name.
13793
+ * @member {string} name
13794
+ * @memberof sqlanvil.MysqlOptions.Index
13795
+ * @instance
13796
+ */
13797
+ Index.prototype.name = "";
13798
+
13799
+ /**
13800
+ * Index columns.
13801
+ * @member {Array.<string>} columns
13802
+ * @memberof sqlanvil.MysqlOptions.Index
13803
+ * @instance
13804
+ */
13805
+ Index.prototype.columns = $util.emptyArray;
13806
+
13807
+ /**
13808
+ * Index unique.
13809
+ * @member {boolean} unique
13810
+ * @memberof sqlanvil.MysqlOptions.Index
13811
+ * @instance
13812
+ */
13813
+ Index.prototype.unique = false;
13814
+
13815
+ /**
13816
+ * Creates a new Index instance using the specified properties.
13817
+ * @function create
13818
+ * @memberof sqlanvil.MysqlOptions.Index
13819
+ * @static
13820
+ * @param {sqlanvil.MysqlOptions.IIndex=} [properties] Properties to set
13821
+ * @returns {sqlanvil.MysqlOptions.Index} Index instance
13822
+ */
13823
+ Index.create = function create(properties) {
13824
+ return new Index(properties);
13825
+ };
13826
+
13827
+ /**
13828
+ * Encodes the specified Index message. Does not implicitly {@link sqlanvil.MysqlOptions.Index.verify|verify} messages.
13829
+ * @function encode
13830
+ * @memberof sqlanvil.MysqlOptions.Index
13831
+ * @static
13832
+ * @param {sqlanvil.MysqlOptions.IIndex} message Index message or plain object to encode
13833
+ * @param {$protobuf.Writer} [writer] Writer to encode to
13834
+ * @returns {$protobuf.Writer} Writer
13835
+ */
13836
+ Index.encode = function encode(message, writer) {
13837
+ if (!writer)
13838
+ writer = $Writer.create();
13839
+ if (message.name != null && Object.hasOwnProperty.call(message, "name"))
13840
+ writer.uint32(/* id 1, wireType 2 =*/10).string(message.name);
13841
+ if (message.columns != null && message.columns.length)
13842
+ for (let i = 0; i < message.columns.length; ++i)
13843
+ writer.uint32(/* id 2, wireType 2 =*/18).string(message.columns[i]);
13844
+ if (message.unique != null && Object.hasOwnProperty.call(message, "unique"))
13845
+ writer.uint32(/* id 3, wireType 0 =*/24).bool(message.unique);
13846
+ return writer;
13847
+ };
13848
+
13849
+ /**
13850
+ * Encodes the specified Index message, length delimited. Does not implicitly {@link sqlanvil.MysqlOptions.Index.verify|verify} messages.
13851
+ * @function encodeDelimited
13852
+ * @memberof sqlanvil.MysqlOptions.Index
13853
+ * @static
13854
+ * @param {sqlanvil.MysqlOptions.IIndex} message Index message or plain object to encode
13855
+ * @param {$protobuf.Writer} [writer] Writer to encode to
13856
+ * @returns {$protobuf.Writer} Writer
13857
+ */
13858
+ Index.encodeDelimited = function encodeDelimited(message, writer) {
13859
+ return this.encode(message, writer).ldelim();
13860
+ };
13861
+
13862
+ /**
13863
+ * Decodes an Index message from the specified reader or buffer.
13864
+ * @function decode
13865
+ * @memberof sqlanvil.MysqlOptions.Index
13866
+ * @static
13867
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
13868
+ * @param {number} [length] Message length if known beforehand
13869
+ * @returns {sqlanvil.MysqlOptions.Index} Index
13870
+ * @throws {Error} If the payload is not a reader or valid buffer
13871
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
13872
+ */
13873
+ Index.decode = function decode(reader, length, error) {
13874
+ if (!(reader instanceof $Reader))
13875
+ reader = $Reader.create(reader);
13876
+ let end = length === undefined ? reader.len : reader.pos + length, message = new $root.sqlanvil.MysqlOptions.Index();
13877
+ while (reader.pos < end) {
13878
+ let tag = reader.uint32();
13879
+ if (tag === error)
13880
+ break;
13881
+ switch (tag >>> 3) {
13882
+ case 1: {
13883
+ message.name = reader.string();
13884
+ break;
13885
+ }
13886
+ case 2: {
13887
+ if (!(message.columns && message.columns.length))
13888
+ message.columns = [];
13889
+ message.columns.push(reader.string());
13890
+ break;
13891
+ }
13892
+ case 3: {
13893
+ message.unique = reader.bool();
13894
+ break;
13895
+ }
13896
+ default:
13897
+ reader.skipType(tag & 7);
13898
+ break;
13899
+ }
13900
+ }
13901
+ return message;
13902
+ };
13903
+
13904
+ /**
13905
+ * Decodes an Index message from the specified reader or buffer, length delimited.
13906
+ * @function decodeDelimited
13907
+ * @memberof sqlanvil.MysqlOptions.Index
13908
+ * @static
13909
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
13910
+ * @returns {sqlanvil.MysqlOptions.Index} Index
13911
+ * @throws {Error} If the payload is not a reader or valid buffer
13912
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
13913
+ */
13914
+ Index.decodeDelimited = function decodeDelimited(reader) {
13915
+ if (!(reader instanceof $Reader))
13916
+ reader = new $Reader(reader);
13917
+ return this.decode(reader, reader.uint32());
13918
+ };
13919
+
13920
+ /**
13921
+ * Verifies an Index message.
13922
+ * @function verify
13923
+ * @memberof sqlanvil.MysqlOptions.Index
13924
+ * @static
13925
+ * @param {Object.<string,*>} message Plain object to verify
13926
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
13927
+ */
13928
+ Index.verify = function verify(message) {
13929
+ if (typeof message !== "object" || message === null)
13930
+ return "object expected";
13931
+ if (message.name != null && message.hasOwnProperty("name"))
13932
+ if (!$util.isString(message.name))
13933
+ return "name: string expected";
13934
+ if (message.columns != null && message.hasOwnProperty("columns")) {
13935
+ if (!Array.isArray(message.columns))
13936
+ return "columns: array expected";
13937
+ for (let i = 0; i < message.columns.length; ++i)
13938
+ if (!$util.isString(message.columns[i]))
13939
+ return "columns: string[] expected";
13940
+ }
13941
+ if (message.unique != null && message.hasOwnProperty("unique"))
13942
+ if (typeof message.unique !== "boolean")
13943
+ return "unique: boolean expected";
13944
+ return null;
13945
+ };
13946
+
13947
+ /**
13948
+ * Creates an Index message from a plain object. Also converts values to their respective internal types.
13949
+ * @function fromObject
13950
+ * @memberof sqlanvil.MysqlOptions.Index
13951
+ * @static
13952
+ * @param {Object.<string,*>} object Plain object
13953
+ * @returns {sqlanvil.MysqlOptions.Index} Index
13954
+ */
13955
+ Index.fromObject = function fromObject(object) {
13956
+ if (object instanceof $root.sqlanvil.MysqlOptions.Index)
13957
+ return object;
13958
+ let message = new $root.sqlanvil.MysqlOptions.Index();
13959
+ if (object.name != null)
13960
+ message.name = String(object.name);
13961
+ if (object.columns) {
13962
+ if (!Array.isArray(object.columns))
13963
+ throw TypeError(".sqlanvil.MysqlOptions.Index.columns: array expected");
13964
+ message.columns = [];
13965
+ for (let i = 0; i < object.columns.length; ++i)
13966
+ message.columns[i] = String(object.columns[i]);
13967
+ }
13968
+ if (object.unique != null)
13969
+ message.unique = Boolean(object.unique);
13970
+ return message;
13971
+ };
13972
+
13973
+ /**
13974
+ * Creates a plain object from an Index message. Also converts values to other types if specified.
13975
+ * @function toObject
13976
+ * @memberof sqlanvil.MysqlOptions.Index
13977
+ * @static
13978
+ * @param {sqlanvil.MysqlOptions.Index} message Index
13979
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
13980
+ * @returns {Object.<string,*>} Plain object
13981
+ */
13982
+ Index.toObject = function toObject(message, options) {
13983
+ if (!options)
13984
+ options = {};
13985
+ let object = {};
13986
+ if (options.arrays || options.defaults)
13987
+ object.columns = [];
13988
+ if (options.defaults) {
13989
+ object.name = "";
13990
+ object.unique = false;
13991
+ }
13992
+ if (message.name != null && message.hasOwnProperty("name"))
13993
+ object.name = message.name;
13994
+ if (message.columns && message.columns.length) {
13995
+ object.columns = [];
13996
+ for (let j = 0; j < message.columns.length; ++j)
13997
+ object.columns[j] = message.columns[j];
13998
+ }
13999
+ if (message.unique != null && message.hasOwnProperty("unique"))
14000
+ object.unique = message.unique;
14001
+ return object;
14002
+ };
14003
+
14004
+ /**
14005
+ * Converts this Index to JSON.
14006
+ * @function toJSON
14007
+ * @memberof sqlanvil.MysqlOptions.Index
14008
+ * @instance
14009
+ * @returns {Object.<string,*>} JSON object
14010
+ */
14011
+ Index.prototype.toJSON = function toJSON() {
14012
+ return this.constructor.toObject(this, $protobuf__namespace.util.toJSONOptions);
14013
+ };
14014
+
14015
+ /**
14016
+ * Gets the default type url for Index
14017
+ * @function getTypeUrl
14018
+ * @memberof sqlanvil.MysqlOptions.Index
14019
+ * @static
14020
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
14021
+ * @returns {string} The default type url
14022
+ */
14023
+ Index.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
14024
+ if (typeUrlPrefix === undefined) {
14025
+ typeUrlPrefix = "type.googleapis.com";
14026
+ }
14027
+ return typeUrlPrefix + "/sqlanvil.MysqlOptions.Index";
14028
+ };
14029
+
14030
+ return Index;
14031
+ })();
14032
+
14033
+ return MysqlOptions;
14034
+ })();
14035
+
13412
14036
  sqlanvil.SupabaseOptions = (function() {
13413
14037
 
13414
14038
  /**
@@ -14949,6 +15573,327 @@ const sqlanvil = $root.sqlanvil = (() => {
14949
15573
  return SupabaseConnection;
14950
15574
  })();
14951
15575
 
15576
+ sqlanvil.MysqlConnection = (function() {
15577
+
15578
+ /**
15579
+ * Properties of a MysqlConnection.
15580
+ * @memberof sqlanvil
15581
+ * @interface IMysqlConnection
15582
+ * @property {string|null} [host] MysqlConnection host
15583
+ * @property {number|null} [port] MysqlConnection port
15584
+ * @property {string|null} [database] MysqlConnection database
15585
+ * @property {string|null} [user] MysqlConnection user
15586
+ * @property {string|null} [password] MysqlConnection password
15587
+ * @property {string|null} [sslMode] MysqlConnection sslMode
15588
+ */
15589
+
15590
+ /**
15591
+ * Constructs a new MysqlConnection.
15592
+ * @memberof sqlanvil
15593
+ * @classdesc Represents a MysqlConnection.
15594
+ * @implements IMysqlConnection
15595
+ * @constructor
15596
+ * @param {sqlanvil.IMysqlConnection=} [properties] Properties to set
15597
+ */
15598
+ function MysqlConnection(properties) {
15599
+ if (properties)
15600
+ for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
15601
+ if (properties[keys[i]] != null)
15602
+ this[keys[i]] = properties[keys[i]];
15603
+ }
15604
+
15605
+ /**
15606
+ * MysqlConnection host.
15607
+ * @member {string} host
15608
+ * @memberof sqlanvil.MysqlConnection
15609
+ * @instance
15610
+ */
15611
+ MysqlConnection.prototype.host = "";
15612
+
15613
+ /**
15614
+ * MysqlConnection port.
15615
+ * @member {number} port
15616
+ * @memberof sqlanvil.MysqlConnection
15617
+ * @instance
15618
+ */
15619
+ MysqlConnection.prototype.port = 0;
15620
+
15621
+ /**
15622
+ * MysqlConnection database.
15623
+ * @member {string} database
15624
+ * @memberof sqlanvil.MysqlConnection
15625
+ * @instance
15626
+ */
15627
+ MysqlConnection.prototype.database = "";
15628
+
15629
+ /**
15630
+ * MysqlConnection user.
15631
+ * @member {string} user
15632
+ * @memberof sqlanvil.MysqlConnection
15633
+ * @instance
15634
+ */
15635
+ MysqlConnection.prototype.user = "";
15636
+
15637
+ /**
15638
+ * MysqlConnection password.
15639
+ * @member {string} password
15640
+ * @memberof sqlanvil.MysqlConnection
15641
+ * @instance
15642
+ */
15643
+ MysqlConnection.prototype.password = "";
15644
+
15645
+ /**
15646
+ * MysqlConnection sslMode.
15647
+ * @member {string} sslMode
15648
+ * @memberof sqlanvil.MysqlConnection
15649
+ * @instance
15650
+ */
15651
+ MysqlConnection.prototype.sslMode = "";
15652
+
15653
+ /**
15654
+ * Creates a new MysqlConnection instance using the specified properties.
15655
+ * @function create
15656
+ * @memberof sqlanvil.MysqlConnection
15657
+ * @static
15658
+ * @param {sqlanvil.IMysqlConnection=} [properties] Properties to set
15659
+ * @returns {sqlanvil.MysqlConnection} MysqlConnection instance
15660
+ */
15661
+ MysqlConnection.create = function create(properties) {
15662
+ return new MysqlConnection(properties);
15663
+ };
15664
+
15665
+ /**
15666
+ * Encodes the specified MysqlConnection message. Does not implicitly {@link sqlanvil.MysqlConnection.verify|verify} messages.
15667
+ * @function encode
15668
+ * @memberof sqlanvil.MysqlConnection
15669
+ * @static
15670
+ * @param {sqlanvil.IMysqlConnection} message MysqlConnection message or plain object to encode
15671
+ * @param {$protobuf.Writer} [writer] Writer to encode to
15672
+ * @returns {$protobuf.Writer} Writer
15673
+ */
15674
+ MysqlConnection.encode = function encode(message, writer) {
15675
+ if (!writer)
15676
+ writer = $Writer.create();
15677
+ if (message.host != null && Object.hasOwnProperty.call(message, "host"))
15678
+ writer.uint32(/* id 1, wireType 2 =*/10).string(message.host);
15679
+ if (message.port != null && Object.hasOwnProperty.call(message, "port"))
15680
+ writer.uint32(/* id 2, wireType 0 =*/16).uint32(message.port);
15681
+ if (message.database != null && Object.hasOwnProperty.call(message, "database"))
15682
+ writer.uint32(/* id 3, wireType 2 =*/26).string(message.database);
15683
+ if (message.user != null && Object.hasOwnProperty.call(message, "user"))
15684
+ writer.uint32(/* id 4, wireType 2 =*/34).string(message.user);
15685
+ if (message.password != null && Object.hasOwnProperty.call(message, "password"))
15686
+ writer.uint32(/* id 5, wireType 2 =*/42).string(message.password);
15687
+ if (message.sslMode != null && Object.hasOwnProperty.call(message, "sslMode"))
15688
+ writer.uint32(/* id 6, wireType 2 =*/50).string(message.sslMode);
15689
+ return writer;
15690
+ };
15691
+
15692
+ /**
15693
+ * Encodes the specified MysqlConnection message, length delimited. Does not implicitly {@link sqlanvil.MysqlConnection.verify|verify} messages.
15694
+ * @function encodeDelimited
15695
+ * @memberof sqlanvil.MysqlConnection
15696
+ * @static
15697
+ * @param {sqlanvil.IMysqlConnection} message MysqlConnection message or plain object to encode
15698
+ * @param {$protobuf.Writer} [writer] Writer to encode to
15699
+ * @returns {$protobuf.Writer} Writer
15700
+ */
15701
+ MysqlConnection.encodeDelimited = function encodeDelimited(message, writer) {
15702
+ return this.encode(message, writer).ldelim();
15703
+ };
15704
+
15705
+ /**
15706
+ * Decodes a MysqlConnection message from the specified reader or buffer.
15707
+ * @function decode
15708
+ * @memberof sqlanvil.MysqlConnection
15709
+ * @static
15710
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
15711
+ * @param {number} [length] Message length if known beforehand
15712
+ * @returns {sqlanvil.MysqlConnection} MysqlConnection
15713
+ * @throws {Error} If the payload is not a reader or valid buffer
15714
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
15715
+ */
15716
+ MysqlConnection.decode = function decode(reader, length, error) {
15717
+ if (!(reader instanceof $Reader))
15718
+ reader = $Reader.create(reader);
15719
+ let end = length === undefined ? reader.len : reader.pos + length, message = new $root.sqlanvil.MysqlConnection();
15720
+ while (reader.pos < end) {
15721
+ let tag = reader.uint32();
15722
+ if (tag === error)
15723
+ break;
15724
+ switch (tag >>> 3) {
15725
+ case 1: {
15726
+ message.host = reader.string();
15727
+ break;
15728
+ }
15729
+ case 2: {
15730
+ message.port = reader.uint32();
15731
+ break;
15732
+ }
15733
+ case 3: {
15734
+ message.database = reader.string();
15735
+ break;
15736
+ }
15737
+ case 4: {
15738
+ message.user = reader.string();
15739
+ break;
15740
+ }
15741
+ case 5: {
15742
+ message.password = reader.string();
15743
+ break;
15744
+ }
15745
+ case 6: {
15746
+ message.sslMode = reader.string();
15747
+ break;
15748
+ }
15749
+ default:
15750
+ reader.skipType(tag & 7);
15751
+ break;
15752
+ }
15753
+ }
15754
+ return message;
15755
+ };
15756
+
15757
+ /**
15758
+ * Decodes a MysqlConnection message from the specified reader or buffer, length delimited.
15759
+ * @function decodeDelimited
15760
+ * @memberof sqlanvil.MysqlConnection
15761
+ * @static
15762
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
15763
+ * @returns {sqlanvil.MysqlConnection} MysqlConnection
15764
+ * @throws {Error} If the payload is not a reader or valid buffer
15765
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
15766
+ */
15767
+ MysqlConnection.decodeDelimited = function decodeDelimited(reader) {
15768
+ if (!(reader instanceof $Reader))
15769
+ reader = new $Reader(reader);
15770
+ return this.decode(reader, reader.uint32());
15771
+ };
15772
+
15773
+ /**
15774
+ * Verifies a MysqlConnection message.
15775
+ * @function verify
15776
+ * @memberof sqlanvil.MysqlConnection
15777
+ * @static
15778
+ * @param {Object.<string,*>} message Plain object to verify
15779
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
15780
+ */
15781
+ MysqlConnection.verify = function verify(message) {
15782
+ if (typeof message !== "object" || message === null)
15783
+ return "object expected";
15784
+ if (message.host != null && message.hasOwnProperty("host"))
15785
+ if (!$util.isString(message.host))
15786
+ return "host: string expected";
15787
+ if (message.port != null && message.hasOwnProperty("port"))
15788
+ if (!$util.isInteger(message.port))
15789
+ return "port: integer expected";
15790
+ if (message.database != null && message.hasOwnProperty("database"))
15791
+ if (!$util.isString(message.database))
15792
+ return "database: string expected";
15793
+ if (message.user != null && message.hasOwnProperty("user"))
15794
+ if (!$util.isString(message.user))
15795
+ return "user: string expected";
15796
+ if (message.password != null && message.hasOwnProperty("password"))
15797
+ if (!$util.isString(message.password))
15798
+ return "password: string expected";
15799
+ if (message.sslMode != null && message.hasOwnProperty("sslMode"))
15800
+ if (!$util.isString(message.sslMode))
15801
+ return "sslMode: string expected";
15802
+ return null;
15803
+ };
15804
+
15805
+ /**
15806
+ * Creates a MysqlConnection message from a plain object. Also converts values to their respective internal types.
15807
+ * @function fromObject
15808
+ * @memberof sqlanvil.MysqlConnection
15809
+ * @static
15810
+ * @param {Object.<string,*>} object Plain object
15811
+ * @returns {sqlanvil.MysqlConnection} MysqlConnection
15812
+ */
15813
+ MysqlConnection.fromObject = function fromObject(object) {
15814
+ if (object instanceof $root.sqlanvil.MysqlConnection)
15815
+ return object;
15816
+ let message = new $root.sqlanvil.MysqlConnection();
15817
+ if (object.host != null)
15818
+ message.host = String(object.host);
15819
+ if (object.port != null)
15820
+ message.port = object.port >>> 0;
15821
+ if (object.database != null)
15822
+ message.database = String(object.database);
15823
+ if (object.user != null)
15824
+ message.user = String(object.user);
15825
+ if (object.password != null)
15826
+ message.password = String(object.password);
15827
+ if (object.sslMode != null)
15828
+ message.sslMode = String(object.sslMode);
15829
+ return message;
15830
+ };
15831
+
15832
+ /**
15833
+ * Creates a plain object from a MysqlConnection message. Also converts values to other types if specified.
15834
+ * @function toObject
15835
+ * @memberof sqlanvil.MysqlConnection
15836
+ * @static
15837
+ * @param {sqlanvil.MysqlConnection} message MysqlConnection
15838
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
15839
+ * @returns {Object.<string,*>} Plain object
15840
+ */
15841
+ MysqlConnection.toObject = function toObject(message, options) {
15842
+ if (!options)
15843
+ options = {};
15844
+ let object = {};
15845
+ if (options.defaults) {
15846
+ object.host = "";
15847
+ object.port = 0;
15848
+ object.database = "";
15849
+ object.user = "";
15850
+ object.password = "";
15851
+ object.sslMode = "";
15852
+ }
15853
+ if (message.host != null && message.hasOwnProperty("host"))
15854
+ object.host = message.host;
15855
+ if (message.port != null && message.hasOwnProperty("port"))
15856
+ object.port = message.port;
15857
+ if (message.database != null && message.hasOwnProperty("database"))
15858
+ object.database = message.database;
15859
+ if (message.user != null && message.hasOwnProperty("user"))
15860
+ object.user = message.user;
15861
+ if (message.password != null && message.hasOwnProperty("password"))
15862
+ object.password = message.password;
15863
+ if (message.sslMode != null && message.hasOwnProperty("sslMode"))
15864
+ object.sslMode = message.sslMode;
15865
+ return object;
15866
+ };
15867
+
15868
+ /**
15869
+ * Converts this MysqlConnection to JSON.
15870
+ * @function toJSON
15871
+ * @memberof sqlanvil.MysqlConnection
15872
+ * @instance
15873
+ * @returns {Object.<string,*>} JSON object
15874
+ */
15875
+ MysqlConnection.prototype.toJSON = function toJSON() {
15876
+ return this.constructor.toObject(this, $protobuf__namespace.util.toJSONOptions);
15877
+ };
15878
+
15879
+ /**
15880
+ * Gets the default type url for MysqlConnection
15881
+ * @function getTypeUrl
15882
+ * @memberof sqlanvil.MysqlConnection
15883
+ * @static
15884
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
15885
+ * @returns {string} The default type url
15886
+ */
15887
+ MysqlConnection.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
15888
+ if (typeUrlPrefix === undefined) {
15889
+ typeUrlPrefix = "type.googleapis.com";
15890
+ }
15891
+ return typeUrlPrefix + "/sqlanvil.MysqlConnection";
15892
+ };
15893
+
15894
+ return MysqlConnection;
15895
+ })();
15896
+
14952
15897
  sqlanvil.WarehouseConfig = (function() {
14953
15898
 
14954
15899
  /**
@@ -14958,6 +15903,7 @@ const sqlanvil = $root.sqlanvil = (() => {
14958
15903
  * @property {sqlanvil.IBigQueryConnection|null} [bigquery] WarehouseConfig bigquery
14959
15904
  * @property {sqlanvil.IPostgresConnection|null} [postgres] WarehouseConfig postgres
14960
15905
  * @property {sqlanvil.ISupabaseConnection|null} [supabase] WarehouseConfig supabase
15906
+ * @property {sqlanvil.IMysqlConnection|null} [mysql] WarehouseConfig mysql
14961
15907
  */
14962
15908
 
14963
15909
  /**
@@ -14999,17 +15945,25 @@ const sqlanvil = $root.sqlanvil = (() => {
14999
15945
  */
15000
15946
  WarehouseConfig.prototype.supabase = null;
15001
15947
 
15948
+ /**
15949
+ * WarehouseConfig mysql.
15950
+ * @member {sqlanvil.IMysqlConnection|null|undefined} mysql
15951
+ * @memberof sqlanvil.WarehouseConfig
15952
+ * @instance
15953
+ */
15954
+ WarehouseConfig.prototype.mysql = null;
15955
+
15002
15956
  // OneOf field names bound to virtual getters and setters
15003
15957
  let $oneOfFields;
15004
15958
 
15005
15959
  /**
15006
15960
  * WarehouseConfig connection.
15007
- * @member {"bigquery"|"postgres"|"supabase"|undefined} connection
15961
+ * @member {"bigquery"|"postgres"|"supabase"|"mysql"|undefined} connection
15008
15962
  * @memberof sqlanvil.WarehouseConfig
15009
15963
  * @instance
15010
15964
  */
15011
15965
  Object.defineProperty(WarehouseConfig.prototype, "connection", {
15012
- get: $util.oneOfGetter($oneOfFields = ["bigquery", "postgres", "supabase"]),
15966
+ get: $util.oneOfGetter($oneOfFields = ["bigquery", "postgres", "supabase", "mysql"]),
15013
15967
  set: $util.oneOfSetter($oneOfFields)
15014
15968
  });
15015
15969
 
@@ -15043,6 +15997,8 @@ const sqlanvil = $root.sqlanvil = (() => {
15043
15997
  $root.sqlanvil.PostgresConnection.encode(message.postgres, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim();
15044
15998
  if (message.supabase != null && Object.hasOwnProperty.call(message, "supabase"))
15045
15999
  $root.sqlanvil.SupabaseConnection.encode(message.supabase, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim();
16000
+ if (message.mysql != null && Object.hasOwnProperty.call(message, "mysql"))
16001
+ $root.sqlanvil.MysqlConnection.encode(message.mysql, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim();
15046
16002
  return writer;
15047
16003
  };
15048
16004
 
@@ -15091,6 +16047,10 @@ const sqlanvil = $root.sqlanvil = (() => {
15091
16047
  message.supabase = $root.sqlanvil.SupabaseConnection.decode(reader, reader.uint32());
15092
16048
  break;
15093
16049
  }
16050
+ case 4: {
16051
+ message.mysql = $root.sqlanvil.MysqlConnection.decode(reader, reader.uint32());
16052
+ break;
16053
+ }
15094
16054
  default:
15095
16055
  reader.skipType(tag & 7);
15096
16056
  break;
@@ -15155,6 +16115,16 @@ const sqlanvil = $root.sqlanvil = (() => {
15155
16115
  return "supabase." + error;
15156
16116
  }
15157
16117
  }
16118
+ if (message.mysql != null && message.hasOwnProperty("mysql")) {
16119
+ if (properties.connection === 1)
16120
+ return "connection: multiple values";
16121
+ properties.connection = 1;
16122
+ {
16123
+ let error = $root.sqlanvil.MysqlConnection.verify(message.mysql);
16124
+ if (error)
16125
+ return "mysql." + error;
16126
+ }
16127
+ }
15158
16128
  return null;
15159
16129
  };
15160
16130
 
@@ -15185,6 +16155,11 @@ const sqlanvil = $root.sqlanvil = (() => {
15185
16155
  throw TypeError(".sqlanvil.WarehouseConfig.supabase: object expected");
15186
16156
  message.supabase = $root.sqlanvil.SupabaseConnection.fromObject(object.supabase);
15187
16157
  }
16158
+ if (object.mysql != null) {
16159
+ if (typeof object.mysql !== "object")
16160
+ throw TypeError(".sqlanvil.WarehouseConfig.mysql: object expected");
16161
+ message.mysql = $root.sqlanvil.MysqlConnection.fromObject(object.mysql);
16162
+ }
15188
16163
  return message;
15189
16164
  };
15190
16165
 
@@ -15216,6 +16191,11 @@ const sqlanvil = $root.sqlanvil = (() => {
15216
16191
  if (options.oneofs)
15217
16192
  object.connection = "supabase";
15218
16193
  }
16194
+ if (message.mysql != null && message.hasOwnProperty("mysql")) {
16195
+ object.mysql = $root.sqlanvil.MysqlConnection.toObject(message.mysql, options);
16196
+ if (options.oneofs)
16197
+ object.connection = "mysql";
16198
+ }
15219
16199
  return object;
15220
16200
  };
15221
16201
 
@@ -19052,6 +20032,7 @@ const sqlanvil = $root.sqlanvil = (() => {
19052
20032
  * @property {sqlanvil.IBigQueryOptions|null} [bigquery] Table bigquery
19053
20033
  * @property {sqlanvil.IPostgresOptions|null} [postgres] Table postgres
19054
20034
  * @property {sqlanvil.ISupabaseOptions|null} [supabase] Table supabase
20035
+ * @property {sqlanvil.IMysqlOptions|null} [mysql] Table mysql
19055
20036
  * @property {string|null} [fileName] Table fileName
19056
20037
  */
19057
20038
 
@@ -19269,6 +20250,14 @@ const sqlanvil = $root.sqlanvil = (() => {
19269
20250
  */
19270
20251
  Table.prototype.supabase = null;
19271
20252
 
20253
+ /**
20254
+ * Table mysql.
20255
+ * @member {sqlanvil.IMysqlOptions|null|undefined} mysql
20256
+ * @memberof sqlanvil.Table
20257
+ * @instance
20258
+ */
20259
+ Table.prototype.mysql = null;
20260
+
19272
20261
  /**
19273
20262
  * Table fileName.
19274
20263
  * @member {string} fileName
@@ -19358,6 +20347,8 @@ const sqlanvil = $root.sqlanvil = (() => {
19358
20347
  $root.sqlanvil.PostgresOptions.encode(message.postgres, writer.uint32(/* id 39, wireType 2 =*/314).fork()).ldelim();
19359
20348
  if (message.supabase != null && Object.hasOwnProperty.call(message, "supabase"))
19360
20349
  $root.sqlanvil.SupabaseOptions.encode(message.supabase, writer.uint32(/* id 40, wireType 2 =*/322).fork()).ldelim();
20350
+ if (message.mysql != null && Object.hasOwnProperty.call(message, "mysql"))
20351
+ $root.sqlanvil.MysqlOptions.encode(message.mysql, writer.uint32(/* id 41, wireType 2 =*/330).fork()).ldelim();
19361
20352
  return writer;
19362
20353
  };
19363
20354
 
@@ -19504,6 +20495,10 @@ const sqlanvil = $root.sqlanvil = (() => {
19504
20495
  message.supabase = $root.sqlanvil.SupabaseOptions.decode(reader, reader.uint32());
19505
20496
  break;
19506
20497
  }
20498
+ case 41: {
20499
+ message.mysql = $root.sqlanvil.MysqlOptions.decode(reader, reader.uint32());
20500
+ break;
20501
+ }
19507
20502
  case 18: {
19508
20503
  message.fileName = reader.string();
19509
20504
  break;
@@ -19677,6 +20672,11 @@ const sqlanvil = $root.sqlanvil = (() => {
19677
20672
  if (error)
19678
20673
  return "supabase." + error;
19679
20674
  }
20675
+ if (message.mysql != null && message.hasOwnProperty("mysql")) {
20676
+ let error = $root.sqlanvil.MysqlOptions.verify(message.mysql);
20677
+ if (error)
20678
+ return "mysql." + error;
20679
+ }
19680
20680
  if (message.fileName != null && message.hasOwnProperty("fileName"))
19681
20681
  if (!$util.isString(message.fileName))
19682
20682
  return "fileName: string expected";
@@ -19861,6 +20861,11 @@ const sqlanvil = $root.sqlanvil = (() => {
19861
20861
  throw TypeError(".sqlanvil.Table.supabase: object expected");
19862
20862
  message.supabase = $root.sqlanvil.SupabaseOptions.fromObject(object.supabase);
19863
20863
  }
20864
+ if (object.mysql != null) {
20865
+ if (typeof object.mysql !== "object")
20866
+ throw TypeError(".sqlanvil.Table.mysql: object expected");
20867
+ message.mysql = $root.sqlanvil.MysqlOptions.fromObject(object.mysql);
20868
+ }
19864
20869
  if (object.fileName != null)
19865
20870
  message.fileName = String(object.fileName);
19866
20871
  return message;
@@ -19907,6 +20912,7 @@ const sqlanvil = $root.sqlanvil = (() => {
19907
20912
  object.jitCode = "";
19908
20913
  object.postgres = null;
19909
20914
  object.supabase = null;
20915
+ object.mysql = null;
19910
20916
  }
19911
20917
  if (message.type != null && message.hasOwnProperty("type"))
19912
20918
  object.type = message.type;
@@ -19979,6 +20985,8 @@ const sqlanvil = $root.sqlanvil = (() => {
19979
20985
  object.postgres = $root.sqlanvil.PostgresOptions.toObject(message.postgres, options);
19980
20986
  if (message.supabase != null && message.hasOwnProperty("supabase"))
19981
20987
  object.supabase = $root.sqlanvil.SupabaseOptions.toObject(message.supabase, options);
20988
+ if (message.mysql != null && message.hasOwnProperty("mysql"))
20989
+ object.mysql = $root.sqlanvil.MysqlOptions.toObject(message.mysql, options);
19982
20990
  return object;
19983
20991
  };
19984
20992
 
@@ -37904,6 +38912,9 @@ class CompilationSql {
37904
38912
  }
37905
38913
  return `"${database}"."${schema}"."${name}"`;
37906
38914
  }
38915
+ if (this.warehouse === "mysql") {
38916
+ return `\`${schema}\`.\`${name}\``;
38917
+ }
37907
38918
  if (!database) {
37908
38919
  return `\`${schema}.${name}\``;
37909
38920
  }
@@ -37920,6 +38931,9 @@ class CompilationSql {
37920
38931
  if (this.warehouse === "postgres" || this.warehouse === "supabase") {
37921
38932
  return `"${col.replace(/"/g, '""')}"`;
37922
38933
  }
38934
+ if (this.warehouse === "mysql") {
38935
+ return `\`${col.replace(/`/g, "``")}\``;
38936
+ }
37923
38937
  return col;
37924
38938
  };
37925
38939
  const commaSeparatedColumns = indexCols.map(quoteCol).join(", ");
@@ -38265,6 +39279,130 @@ when not matched then
38265
39279
  }
38266
39280
  }
38267
39281
 
39282
+ class MysqlExecutionSql {
39283
+ constructor(project, sqlanvilCoreVersion, uniqueIdGenerator = () => Math.random().toString(36).substring(2)) {
39284
+ this.project = project;
39285
+ this.sqlanvilCoreVersion = sqlanvilCoreVersion;
39286
+ this.uniqueIdGenerator = uniqueIdGenerator;
39287
+ this.CompilationSql = new CompilationSql(project, sqlanvilCoreVersion);
39288
+ }
39289
+ resolveTarget(target) {
39290
+ return this.CompilationSql.resolveTarget(target);
39291
+ }
39292
+ dropIfExists(target, type) {
39293
+ if (type === sqlanvil.TableMetadata.Type.VIEW) {
39294
+ return `drop view if exists ${this.resolveTarget(target)}`;
39295
+ }
39296
+ return `drop table if exists ${this.resolveTarget(target)}`;
39297
+ }
39298
+ publishTasks(table, runConfig, tableMetadata) {
39299
+ const tasks = new Tasks();
39300
+ const target = this.resolveTarget(table.target);
39301
+ if (table.enumType === sqlanvil.TableType.VIEW) {
39302
+ if (table.materialized) {
39303
+ tasks.add(Task.statement(this.dropIfExists(table.target, sqlanvil.TableMetadata.Type.VIEW)));
39304
+ tasks.add(Task.statement(this.dropIfExists(table.target, sqlanvil.TableMetadata.Type.TABLE)));
39305
+ tasks.add(Task.statement(`create table ${target}${this.tableOptions(table)} as ${table.query}`));
39306
+ this.createIndexes(table).forEach(stmt => tasks.add(Task.statement(stmt)));
39307
+ return tasks;
39308
+ }
39309
+ tasks.add(Task.statement(`create or replace view ${target} as ${table.query}`));
39310
+ return tasks;
39311
+ }
39312
+ if (table.enumType === sqlanvil.TableType.INCREMENTAL) {
39313
+ const fresh = !this.shouldWriteIncrementally(table, runConfig, tableMetadata);
39314
+ if (fresh) {
39315
+ tasks.add(Task.statement(this.dropIfExists(table.target, sqlanvil.TableMetadata.Type.TABLE)));
39316
+ tasks.add(Task.statement(`create table ${target}${this.tableOptions(table)} as ${table.query}`));
39317
+ if (table.uniqueKey && table.uniqueKey.length > 0) {
39318
+ const idx = `uq_${table.target.schema}_${table.target.name}`.slice(0, 63);
39319
+ const cols = table.uniqueKey.map(k => `\`${k}\``).join(", ");
39320
+ tasks.add(Task.statement(`alter table ${target} add unique index \`${idx}\` (${cols})`));
39321
+ }
39322
+ this.createIndexes(table).forEach(stmt => tasks.add(Task.statement(stmt)));
39323
+ }
39324
+ else {
39325
+ tasks.add(Task.statement(this.upsertInto(table, tableMetadata)));
39326
+ }
39327
+ return tasks;
39328
+ }
39329
+ tasks.add(Task.statement(this.dropIfExists(table.target, sqlanvil.TableMetadata.Type.TABLE)));
39330
+ tasks.add(Task.statement(`create table ${target}${this.tableOptions(table)} as ${table.query}`));
39331
+ this.createIndexes(table).forEach(stmt => tasks.add(Task.statement(stmt)));
39332
+ return tasks;
39333
+ }
39334
+ assertTasks(assertion, projectConfig) {
39335
+ const tasks = new Tasks();
39336
+ const target = this.resolveTarget(assertion.target);
39337
+ tasks.add(Task.statement(this.dropIfExists(assertion.target, sqlanvil.TableMetadata.Type.VIEW)));
39338
+ tasks.add(Task.statement(`create or replace view ${target} as ${assertion.query}`));
39339
+ tasks.add(Task.assertion(`select sum(1) as row_count from ${target}`));
39340
+ return tasks;
39341
+ }
39342
+ shouldWriteIncrementally(table, runConfig, tableMetadata) {
39343
+ return (!runConfig.fullRefresh &&
39344
+ !!tableMetadata &&
39345
+ tableMetadata.type === sqlanvil.TableMetadata.Type.TABLE);
39346
+ }
39347
+ getIncrementalQuery(table) {
39348
+ return table.incrementalQuery || table.query;
39349
+ }
39350
+ upsertInto(table, tableMetadata) {
39351
+ const target = this.resolveTarget(table.target);
39352
+ const columns = ((tableMetadata === null || tableMetadata === void 0 ? void 0 : tableMetadata.fields) || []).map(f => f.name);
39353
+ const query = this.getIncrementalQuery(table);
39354
+ if (columns.length === 0) {
39355
+ return `insert into ${target} select * from (${query}) as insertions`;
39356
+ }
39357
+ const backticked = columns.map(c => `\`${c}\``);
39358
+ const uniqueKey = table.uniqueKey || [];
39359
+ const updates = uniqueKey.length > 0
39360
+ ? columns
39361
+ .filter(c => !uniqueKey.includes(c))
39362
+ .map(c => `\`${c}\` = values(\`${c}\`)`)
39363
+ .join(", ")
39364
+ : "";
39365
+ const tail = updates.length > 0 ? ` on duplicate key update ${updates}` : "";
39366
+ return `insert into ${target} (${backticked.join(", ")}) select ${backticked.join(", ")} from (${query}) as insertions${tail}`;
39367
+ }
39368
+ tableOptions(table) {
39369
+ const opts = table.mysql;
39370
+ if (!opts) {
39371
+ return "";
39372
+ }
39373
+ let suffix = "";
39374
+ if (opts.engine) {
39375
+ suffix += ` engine=${opts.engine}`;
39376
+ }
39377
+ if (opts.charset) {
39378
+ suffix += ` default charset=${opts.charset}`;
39379
+ }
39380
+ if (opts.collation) {
39381
+ suffix += ` collate=${opts.collation}`;
39382
+ }
39383
+ return suffix;
39384
+ }
39385
+ createIndexes(table) {
39386
+ var _a;
39387
+ const indexes = (_a = table.mysql) === null || _a === void 0 ? void 0 : _a.indexes;
39388
+ if (!indexes || indexes.length === 0) {
39389
+ return [];
39390
+ }
39391
+ const target = this.resolveTarget(table.target);
39392
+ return indexes.map(index => {
39393
+ const unique = index.unique ? "unique " : "";
39394
+ const cols = (index.columns || []).map(c => `\`${c}\``).join(", ");
39395
+ const name = index.name || this.defaultIndexName(table.target.name, index.columns, !!index.unique);
39396
+ return `alter table ${target} add ${unique}index \`${name}\` (${cols})`;
39397
+ });
39398
+ }
39399
+ defaultIndexName(tableName, columns, unique) {
39400
+ const parts = [tableName, ...(columns || [])].filter(Boolean);
39401
+ const suffix = unique ? "_key" : "_idx";
39402
+ return `${parts.join("_")}${suffix}`.slice(0, 63);
39403
+ }
39404
+ }
39405
+
38268
39406
  class PostgresExecutionSql {
38269
39407
  constructor(project, sqlanvilCoreVersion, uniqueIdGenerator = () => Math.random().toString(36).substring(2)) {
38270
39408
  this.project = project;
@@ -38576,6 +39714,9 @@ class ExecutionSql {
38576
39714
  if (warehouse === "postgres" || warehouse === "supabase") {
38577
39715
  this.delegate = new PostgresExecutionSql(project, sqlanvilCoreVersion, uniqueIdGenerator);
38578
39716
  }
39717
+ else if (warehouse === "mysql") {
39718
+ this.delegate = new MysqlExecutionSql(project, sqlanvilCoreVersion, uniqueIdGenerator);
39719
+ }
38579
39720
  else {
38580
39721
  this.delegate = new BigQueryExecutionSql(project, sqlanvilCoreVersion, uniqueIdGenerator);
38581
39722
  }
@@ -38660,7 +39801,7 @@ function collectEvaluationQueries(queryOrAction, concatenate, queryModifier = (q
38660
39801
  .filter(validationQuery => !!validationQuery.query);
38661
39802
  }
38662
39803
 
38663
- const version = "1.4.1";
39804
+ const version = "1.6.0";
38664
39805
  const dataformVersion = "3.0.59";
38665
39806
 
38666
39807
  async function build(compiledGraph, runConfig, dbadapter) {
@@ -38921,6 +40062,13 @@ function read(credentialsPath, warehouse = "bigquery") {
38921
40062
  throw new Error(`Error reading credentials file: ${e.message}`);
38922
40063
  }
38923
40064
  const warehouseCredentials = __rest(credentialsAsJson, ["connections"]);
40065
+ if (warehouse.toLowerCase() === "mysql") {
40066
+ const credentials = verifyObjectMatchesProto(sqlanvil.MysqlConnection, warehouseCredentials);
40067
+ if (!credentials.host) {
40068
+ throw new Error(`Error reading credentials file: the host field is required`);
40069
+ }
40070
+ return credentials;
40071
+ }
38924
40072
  const isPostgres = warehouse.toLowerCase() === "postgres" || warehouse.toLowerCase() === "supabase";
38925
40073
  if (isPostgres) {
38926
40074
  const credentials = verifyObjectMatchesProto(sqlanvil.PostgresConnection, warehouseCredentials);
@@ -38995,6 +40143,17 @@ function postgresCredentialsTemplate(warehouse) {
38995
40143
  };
38996
40144
  return `${JSON.stringify(template, null, 2)}\n`;
38997
40145
  }
40146
+ function mysqlCredentialsTemplate() {
40147
+ const template = {
40148
+ host: "localhost",
40149
+ port: 3306,
40150
+ database: "sqlanvil",
40151
+ user: "root",
40152
+ password: "",
40153
+ sslMode: "disable"
40154
+ };
40155
+ return `${JSON.stringify(template, null, 2)}\n`;
40156
+ }
38998
40157
  async function init(projectDir, projectConfig) {
38999
40158
  const workflowSettingsYamlPath = path__namespace.join(projectDir, "workflow_settings.yaml");
39000
40159
  const packageJsonPath = path__namespace.join(projectDir, "package.json");
@@ -39046,7 +40205,7 @@ async function init(projectDir, projectConfig) {
39046
40205
  fs__namespace$1.writeFileSync(gitignorePath, gitIgnoreContents);
39047
40206
  filesWritten.push(gitignorePath);
39048
40207
  if (!isBigQuery) {
39049
- fs__namespace$1.writeFileSync(path__namespace.join(projectDir, CREDENTIALS_FILENAME), postgresCredentialsTemplate(warehouse));
40208
+ fs__namespace$1.writeFileSync(path__namespace.join(projectDir, CREDENTIALS_FILENAME), warehouse === "mysql" ? mysqlCredentialsTemplate() : postgresCredentialsTemplate(warehouse));
39050
40209
  filesWritten.push(path__namespace.join(projectDir, CREDENTIALS_FILENAME));
39051
40210
  }
39052
40211
  const definitionsDir = path__namespace.join(projectDir, "definitions");
@@ -40249,11 +41408,11 @@ function convertField(field) {
40249
41408
  });
40250
41409
  }
40251
41410
  else {
40252
- result.primitive = convertFieldType$1(field.type);
41411
+ result.primitive = convertFieldType$2(field.type);
40253
41412
  }
40254
41413
  return sqlanvil.Field.create(result);
40255
41414
  }
40256
- function convertFieldType$1(type) {
41415
+ function convertFieldType$2(type) {
40257
41416
  switch (String(type).toUpperCase()) {
40258
41417
  case "FLOAT":
40259
41418
  case "FLOAT64":
@@ -40326,6 +41485,361 @@ function createBigQueryError(jobMetadata) {
40326
41485
  return error;
40327
41486
  }
40328
41487
 
41488
+ class MySqlPoolExecutor {
41489
+ constructor(config, options) {
41490
+ this.pool = mysql__namespace.createPool(Object.assign(Object.assign({}, config), { connectionLimit: (options === null || options === void 0 ? void 0 : options.concurrencyLimit) || 10, waitForConnections: true, multipleStatements: false }));
41491
+ }
41492
+ async verifyConnection() {
41493
+ const conn = await this.pool.getConnection();
41494
+ try {
41495
+ await conn.query("select 1");
41496
+ }
41497
+ finally {
41498
+ conn.release();
41499
+ }
41500
+ }
41501
+ async withClientLock(callback) {
41502
+ const conn = await this.pool.getConnection();
41503
+ let released = false;
41504
+ const releaseOnce = () => {
41505
+ if (released) {
41506
+ return;
41507
+ }
41508
+ released = true;
41509
+ conn.release();
41510
+ };
41511
+ try {
41512
+ return await callback({
41513
+ execute: async (statement, options = { rowLimit: 1000 }) => {
41514
+ const [rows] = await conn.query(statement, options.params || []);
41515
+ const arr = Array.isArray(rows) ? rows : [];
41516
+ return options.rowLimit && arr.length > options.rowLimit
41517
+ ? arr.slice(0, options.rowLimit)
41518
+ : arr;
41519
+ }
41520
+ });
41521
+ }
41522
+ finally {
41523
+ releaseOnce();
41524
+ }
41525
+ }
41526
+ async close() {
41527
+ await this.pool.end();
41528
+ }
41529
+ }
41530
+ function convertFieldType$1(type) {
41531
+ switch (String(type).toUpperCase()) {
41532
+ case "FLOAT":
41533
+ case "DOUBLE":
41534
+ case "REAL":
41535
+ return sqlanvil.Field.Primitive.FLOAT;
41536
+ case "TINYINT":
41537
+ case "SMALLINT":
41538
+ case "MEDIUMINT":
41539
+ case "INT":
41540
+ case "INTEGER":
41541
+ case "BIGINT":
41542
+ case "YEAR":
41543
+ case "BIT":
41544
+ return sqlanvil.Field.Primitive.INTEGER;
41545
+ case "DECIMAL":
41546
+ case "DEC":
41547
+ case "NUMERIC":
41548
+ case "FIXED":
41549
+ return sqlanvil.Field.Primitive.NUMERIC;
41550
+ case "BOOL":
41551
+ case "BOOLEAN":
41552
+ return sqlanvil.Field.Primitive.BOOLEAN;
41553
+ case "CHAR":
41554
+ case "VARCHAR":
41555
+ case "TINYTEXT":
41556
+ case "TEXT":
41557
+ case "MEDIUMTEXT":
41558
+ case "LONGTEXT":
41559
+ case "ENUM":
41560
+ case "SET":
41561
+ case "JSON":
41562
+ case "TIME":
41563
+ return sqlanvil.Field.Primitive.STRING;
41564
+ case "DATE":
41565
+ return sqlanvil.Field.Primitive.DATE;
41566
+ case "DATETIME":
41567
+ case "TIMESTAMP":
41568
+ return sqlanvil.Field.Primitive.TIMESTAMP;
41569
+ default:
41570
+ return sqlanvil.Field.Primitive.UNKNOWN;
41571
+ }
41572
+ }
41573
+ function escapeMysqlString(s) {
41574
+ return s.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
41575
+ }
41576
+ function reconstructColumnDef(col) {
41577
+ const extra = (col.extra || "").toLowerCase();
41578
+ const notNull = col.isNullable === "NO";
41579
+ if (extra.includes("generated") && col.generationExpression) {
41580
+ const storage = extra.includes("stored") ? "STORED" : "VIRTUAL";
41581
+ return `${col.columnType} GENERATED ALWAYS AS (${col.generationExpression}) ${storage}${notNull ? " NOT NULL" : ""}`;
41582
+ }
41583
+ let def = col.columnType;
41584
+ if (col.collationName) {
41585
+ def += ` COLLATE ${col.collationName}`;
41586
+ }
41587
+ def += notNull ? " NOT NULL" : " NULL";
41588
+ def += defaultClause(col, extra);
41589
+ if (extra.includes("on update current_timestamp")) {
41590
+ def += " ON UPDATE CURRENT_TIMESTAMP";
41591
+ }
41592
+ if (extra.includes("auto_increment")) {
41593
+ def += " AUTO_INCREMENT";
41594
+ }
41595
+ return def;
41596
+ }
41597
+ function defaultClause(col, extra) {
41598
+ if (extra.includes("default_generated")) {
41599
+ const d = col.columnDefault || "";
41600
+ return /^current_timestamp/i.test(d) ? ` DEFAULT ${d}` : ` DEFAULT (${d})`;
41601
+ }
41602
+ if (col.columnDefault === null || col.columnDefault === undefined) {
41603
+ return "";
41604
+ }
41605
+ const d = col.columnDefault;
41606
+ if (d.toUpperCase() === "NULL" || /^-?\d+(\.\d+)?$/.test(d)) {
41607
+ return ` DEFAULT ${d}`;
41608
+ }
41609
+ return ` DEFAULT '${escapeMysqlString(d)}'`;
41610
+ }
41611
+
41612
+ const INTERNAL_SCHEMAS$1 = new Set([
41613
+ "information_schema",
41614
+ "mysql",
41615
+ "performance_schema",
41616
+ "sys"
41617
+ ]);
41618
+ class MySqlDbAdapter {
41619
+ constructor(queryExecutor) {
41620
+ this.queryExecutor = queryExecutor;
41621
+ }
41622
+ static async create(credentials, options) {
41623
+ const sslMode = (credentials.sslMode || "").toLowerCase();
41624
+ const ssl = !(options === null || options === void 0 ? void 0 : options.disableSslForTestsOnly) && sslMode && sslMode !== "disable"
41625
+ ?
41626
+ { rejectUnauthorized: false }
41627
+ : undefined;
41628
+ const queryExecutor = new MySqlPoolExecutor({
41629
+ host: credentials.host,
41630
+ port: credentials.port || 3306,
41631
+ user: credentials.user,
41632
+ password: credentials.password,
41633
+ database: credentials.database || undefined,
41634
+ ssl
41635
+ }, options);
41636
+ try {
41637
+ await queryExecutor.verifyConnection();
41638
+ }
41639
+ catch (e) {
41640
+ await queryExecutor.close().catch(() => undefined);
41641
+ throw new ErrorWithCause(`Could not connect to MySQL at ${credentials.host}:${credentials.port || 3306} ` +
41642
+ `as "${credentials.user}": ${e.message}`, e);
41643
+ }
41644
+ return new MySqlDbAdapter(queryExecutor);
41645
+ }
41646
+ async execute(statement, options = { rowLimit: 1000, byteLimit: 1024 * 1024 }) {
41647
+ return await this.withClientLock(client => client.execute(statement, options));
41648
+ }
41649
+ async executeRaw(statement, options = { rowLimit: 1000 }) {
41650
+ const result = await this.execute(statement, options);
41651
+ return Object.assign(Object.assign({}, result), { schema: [] });
41652
+ }
41653
+ async withClientLock(callback) {
41654
+ return await this.queryExecutor.withClientLock(client => callback({
41655
+ execute: async (stmt, opts = { rowLimit: 1000, byteLimit: 1024 * 1024 }) => {
41656
+ try {
41657
+ const rows = await client.execute(stmt, { params: opts.params, rowLimit: opts.rowLimit });
41658
+ return { rows, metadata: {} };
41659
+ }
41660
+ catch (e) {
41661
+ if (opts.includeQueryInError) {
41662
+ throw new Error(`Error encountered while running "${stmt}": ${e.message}`);
41663
+ }
41664
+ throw new ErrorWithCause(`Error executing mysql query: ${e.message}`, e);
41665
+ }
41666
+ },
41667
+ executeRaw: async (stmt, opts = { rowLimit: 1000 }) => {
41668
+ const positional = opts.params ? Object.values(opts.params) : undefined;
41669
+ const rows = await client.execute(stmt, { params: positional, rowLimit: opts.rowLimit });
41670
+ return { rows, schema: [], metadata: {} };
41671
+ }
41672
+ }));
41673
+ }
41674
+ async evaluate(queryOrAction) {
41675
+ const validationQueries = collectEvaluationQueries(queryOrAction, false, (query) => !!query ? `explain ${query}` : "").map((validationQuery, index) => ({ index, validationQuery }));
41676
+ const validationQueriesWithoutWrappers = collectEvaluationQueries(queryOrAction, false);
41677
+ const queryEvaluations = new Array();
41678
+ for (const { index, validationQuery } of validationQueries) {
41679
+ let evaluationResponse = {
41680
+ status: sqlanvil.QueryEvaluation.QueryEvaluationStatus.SUCCESS
41681
+ };
41682
+ try {
41683
+ await this.execute(validationQuery.query);
41684
+ }
41685
+ catch (e) {
41686
+ evaluationResponse = {
41687
+ status: sqlanvil.QueryEvaluation.QueryEvaluationStatus.FAILURE,
41688
+ error: sqlanvil.QueryEvaluationError.create({
41689
+ message: (e === null || e === void 0 ? void 0 : e.message) ? String(e.message) : String(e)
41690
+ })
41691
+ };
41692
+ }
41693
+ queryEvaluations.push(sqlanvil.QueryEvaluation.create(Object.assign(Object.assign({}, evaluationResponse), { incremental: validationQuery.incremental, query: validationQueriesWithoutWrappers[index].query })));
41694
+ }
41695
+ return queryEvaluations;
41696
+ }
41697
+ async tables(_database, schema) {
41698
+ const params = [];
41699
+ let schemaClause = "";
41700
+ if (schema) {
41701
+ schemaClause = "and table_schema = ?";
41702
+ params.push(schema);
41703
+ }
41704
+ const queryResult = await this.execute(`select table_name, table_schema
41705
+ from information_schema.tables
41706
+ where table_schema not in ('information_schema', 'mysql', 'performance_schema', 'sys')
41707
+ ${schemaClause}`, { params, rowLimit: 10000, includeQueryInError: true });
41708
+ const targets = queryResult.rows.map(row => ({
41709
+ schema: row.table_schema,
41710
+ name: row.table_name
41711
+ }));
41712
+ return await Promise.all(targets.map(target => this.table(target)));
41713
+ }
41714
+ async search(searchText, options = { limit: 1000 }) {
41715
+ const results = await this.execute(`select tables.table_schema as table_schema, tables.table_name as table_name
41716
+ from information_schema.tables as tables
41717
+ left join information_schema.columns columns
41718
+ on tables.table_schema = columns.table_schema
41719
+ and tables.table_name = columns.table_name
41720
+ where tables.table_schema like ?
41721
+ or tables.table_name like ?
41722
+ or columns.column_name like ?
41723
+ group by 1, 2`, {
41724
+ params: [`%${searchText}%`, `%${searchText}%`, `%${searchText}%`],
41725
+ rowLimit: options.limit
41726
+ });
41727
+ return await Promise.all(results.rows.map(row => this.table({
41728
+ schema: row.table_schema,
41729
+ name: row.table_name
41730
+ })));
41731
+ }
41732
+ async table(target) {
41733
+ var _a, _b, _c;
41734
+ const params = [target.schema, target.name];
41735
+ const [tableResults, columnResults] = await Promise.all([
41736
+ this.execute(`select table_type, table_comment from information_schema.tables
41737
+ where table_schema = ? and table_name = ?`, { params, includeQueryInError: true }),
41738
+ this.execute(`select column_name, data_type, ordinal_position, column_comment
41739
+ from information_schema.columns
41740
+ where table_schema = ? and table_name = ?
41741
+ order by ordinal_position`, { params, includeQueryInError: true })
41742
+ ]);
41743
+ if (tableResults.rows.length === 0) {
41744
+ return null;
41745
+ }
41746
+ const tableType = String((_a = tableResults.rows[0].table_type) !== null && _a !== void 0 ? _a : tableResults.rows[0].TABLE_TYPE).toUpperCase();
41747
+ const tableComment = String((_c = (_b = tableResults.rows[0].table_comment) !== null && _b !== void 0 ? _b : tableResults.rows[0].TABLE_COMMENT) !== null && _c !== void 0 ? _c : "");
41748
+ return sqlanvil.TableMetadata.create({
41749
+ target,
41750
+ type: tableType === "VIEW" ? sqlanvil.TableMetadata.Type.VIEW : sqlanvil.TableMetadata.Type.TABLE,
41751
+ description: tableComment || undefined,
41752
+ fields: columnResults.rows.map(row => {
41753
+ var _a, _b, _c, _d;
41754
+ const comment = String((_b = (_a = row.column_comment) !== null && _a !== void 0 ? _a : row.COLUMN_COMMENT) !== null && _b !== void 0 ? _b : "");
41755
+ return sqlanvil.Field.create({
41756
+ name: ((_c = row.column_name) !== null && _c !== void 0 ? _c : row.COLUMN_NAME),
41757
+ primitive: convertFieldType$1(((_d = row.data_type) !== null && _d !== void 0 ? _d : row.DATA_TYPE)),
41758
+ description: comment || undefined
41759
+ });
41760
+ })
41761
+ });
41762
+ }
41763
+ async deleteTable(target) {
41764
+ const metadata = await this.table(target);
41765
+ if (!metadata) {
41766
+ return;
41767
+ }
41768
+ const kind = metadata.type === sqlanvil.TableMetadata.Type.VIEW ? "view" : "table";
41769
+ await this.execute(`drop ${kind} if exists \`${target.schema}\`.\`${target.name}\``, {
41770
+ includeQueryInError: true
41771
+ });
41772
+ }
41773
+ async schemas(_database) {
41774
+ const result = await this.execute(`select schema_name from information_schema.schemata`, {
41775
+ includeQueryInError: true
41776
+ });
41777
+ return result.rows
41778
+ .map(row => { var _a; return ((_a = row.schema_name) !== null && _a !== void 0 ? _a : row.SCHEMA_NAME); })
41779
+ .filter(name => !INTERNAL_SCHEMAS$1.has(name));
41780
+ }
41781
+ async createSchema(_database, schema) {
41782
+ await this.execute(`create database if not exists \`${schema}\``, {
41783
+ includeQueryInError: true
41784
+ });
41785
+ }
41786
+ async setMetadata(action) {
41787
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
41788
+ const { target, actionDescriptor } = action;
41789
+ const actualMetadata = await this.table(target);
41790
+ if (!actualMetadata) {
41791
+ return;
41792
+ }
41793
+ if (actualMetadata.type === sqlanvil.TableMetadata.Type.VIEW) {
41794
+ return;
41795
+ }
41796
+ const resolved = `\`${target.schema}\`.\`${target.name}\``;
41797
+ if (actionDescriptor === null || actionDescriptor === void 0 ? void 0 : actionDescriptor.description) {
41798
+ await this.execute(`alter table ${resolved} comment = '${escapeMysqlString(actionDescriptor.description)}'`, { includeQueryInError: true });
41799
+ }
41800
+ const columnComments = ((actionDescriptor === null || actionDescriptor === void 0 ? void 0 : actionDescriptor.columns) || []).filter(column => {
41801
+ var _a;
41802
+ return ((_a = column.path) === null || _a === void 0 ? void 0 : _a.length) === 1 &&
41803
+ column.description != null &&
41804
+ actualMetadata.fields.some(f => f.name === column.path[0]);
41805
+ });
41806
+ if (columnComments.length === 0) {
41807
+ return;
41808
+ }
41809
+ const defResult = await this.execute(`select column_name, column_type, is_nullable, column_default, extra,
41810
+ collation_name, generation_expression
41811
+ from information_schema.columns
41812
+ where table_schema = ? and table_name = ?`, { params: [target.schema, target.name], includeQueryInError: true });
41813
+ const defByName = new Map();
41814
+ defResult.rows.forEach(row => { var _a; return defByName.set(String((_a = row.column_name) !== null && _a !== void 0 ? _a : row.COLUMN_NAME), row); });
41815
+ for (const column of columnComments) {
41816
+ const name = column.path[0];
41817
+ const row = defByName.get(name);
41818
+ if (!row) {
41819
+ continue;
41820
+ }
41821
+ const def = reconstructColumnDef({
41822
+ columnType: String((_a = row.column_type) !== null && _a !== void 0 ? _a : row.COLUMN_TYPE),
41823
+ isNullable: String((_b = row.is_nullable) !== null && _b !== void 0 ? _b : row.IS_NULLABLE),
41824
+ columnDefault: ((_d = (_c = row.column_default) !== null && _c !== void 0 ? _c : row.COLUMN_DEFAULT) !== null && _d !== void 0 ? _d : null) === null
41825
+ ? null
41826
+ : String((_e = row.column_default) !== null && _e !== void 0 ? _e : row.COLUMN_DEFAULT),
41827
+ extra: String((_g = (_f = row.extra) !== null && _f !== void 0 ? _f : row.EXTRA) !== null && _g !== void 0 ? _g : ""),
41828
+ collationName: ((_j = (_h = row.collation_name) !== null && _h !== void 0 ? _h : row.COLLATION_NAME) !== null && _j !== void 0 ? _j : null) === null
41829
+ ? null
41830
+ : String((_k = row.collation_name) !== null && _k !== void 0 ? _k : row.COLLATION_NAME),
41831
+ generationExpression: ((_m = (_l = row.generation_expression) !== null && _l !== void 0 ? _l : row.GENERATION_EXPRESSION) !== null && _m !== void 0 ? _m : null) === null
41832
+ ? null
41833
+ : String((_o = row.generation_expression) !== null && _o !== void 0 ? _o : row.GENERATION_EXPRESSION)
41834
+ });
41835
+ await this.execute(`alter table ${resolved} modify column \`${name}\` ${def} comment '${escapeMysqlString(column.description)}'`, { includeQueryInError: true });
41836
+ }
41837
+ }
41838
+ async close() {
41839
+ await this.queryExecutor.close();
41840
+ }
41841
+ }
41842
+
40329
41843
  const maybeInitializePg = (() => {
40330
41844
  let initialized = false;
40331
41845
  return () => {
@@ -42105,7 +43619,7 @@ const icebergOption = option("iceberg", {
42105
43619
  const warehouseOption = option("warehouse", {
42106
43620
  describe: "Target warehouse for the new project.",
42107
43621
  type: "string",
42108
- choices: ["bigquery", "postgres", "supabase"],
43622
+ choices: ["bigquery", "postgres", "supabase", "mysql"],
42109
43623
  default: "supabase"
42110
43624
  });
42111
43625
  const testConnectionOptionName = "test-connection";
@@ -42382,6 +43896,9 @@ function runCli() {
42382
43896
  else if (warehouse.toLowerCase() === "postgres") {
42383
43897
  dbadapter = await PostgresDbAdapter.create(readCredentials);
42384
43898
  }
43899
+ else if (warehouse.toLowerCase() === "mysql") {
43900
+ dbadapter = await MySqlDbAdapter.create(readCredentials);
43901
+ }
42385
43902
  else {
42386
43903
  dbadapter = new BigQueryDbAdapter(readCredentials);
42387
43904
  }
@@ -42455,6 +43972,9 @@ function runCli() {
42455
43972
  else if (warehouse.toLowerCase() === "postgres") {
42456
43973
  dbadapter = await PostgresDbAdapter.create(readCredentials);
42457
43974
  }
43975
+ else if (warehouse.toLowerCase() === "mysql") {
43976
+ dbadapter = await MySqlDbAdapter.create(readCredentials);
43977
+ }
42458
43978
  else {
42459
43979
  dbadapter = new BigQueryDbAdapter(readCredentials);
42460
43980
  }