drizzle-kit 1.0.0-beta.1-2cd01ec → 1.0.0-beta.1-bc61bbe

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/api.js CHANGED
@@ -9514,7 +9514,7 @@ var init_utils = __esm({
9514
9514
  return `file:${it}`;
9515
9515
  }
9516
9516
  }
9517
- if (type === "better-sqlite") {
9517
+ if (type === "better-sqlite" || type === "@tursodatabase/database" || type === "bun") {
9518
9518
  if (it.startsWith("file:")) {
9519
9519
  return it.substring(5);
9520
9520
  }
@@ -20648,7 +20648,8 @@ var init_common = __esm({
20648
20648
  sqliteDriversLiterals = [
20649
20649
  literalType("d1-http"),
20650
20650
  literalType("expo"),
20651
- literalType("durable-sqlite")
20651
+ literalType("durable-sqlite"),
20652
+ literalType("sqlite-cloud")
20652
20653
  ];
20653
20654
  postgresqlDriversLiterals = [
20654
20655
  literalType("aws-data-api"),
@@ -25433,9 +25434,7 @@ var init_cli = __esm({
25433
25434
  extensionsFilters: literalType("postgis").array().optional(),
25434
25435
  casing,
25435
25436
  breakpoints: booleanType().optional().default(true),
25436
- migrations: objectType({
25437
- prefix: prefix.optional().default("index")
25438
- }).optional(),
25437
+ migrations: configMigrations,
25439
25438
  entities: objectType({
25440
25439
  roles: booleanType().or(objectType({
25441
25440
  provider: stringType().optional(),
@@ -25664,6 +25663,10 @@ var init_sqlite = __esm({
25664
25663
  databaseId: stringType().min(1),
25665
25664
  token: stringType().min(1)
25666
25665
  }),
25666
+ objectType({
25667
+ driver: literalType("sqlite-cloud"),
25668
+ url: stringType().min(1)
25669
+ }),
25667
25670
  objectType({
25668
25671
  driver: undefinedType(),
25669
25672
  url: stringType().min(1)
@@ -28701,7 +28704,7 @@ var init_compress2 = __esm({
28701
28704
  cacheControlNoTransformRegExp = /(?:^|,)\s*?no-transform\s*?(?:,|$)/i;
28702
28705
  compress = (options) => {
28703
28706
  const threshold = options?.threshold ?? 1024;
28704
- return async function compress2(ctx, next) {
28707
+ return async function compress22(ctx, next) {
28705
28708
  await next();
28706
28709
  const contentLength = ctx.res.headers.get("Content-Length");
28707
28710
  if (ctx.res.headers.has("Content-Encoding") || ctx.res.headers.has("Transfer-Encoding") || ctx.req.method === "HEAD" || contentLength && Number(contentLength) < threshold || !shouldCompress(ctx.res) || !shouldTransform(ctx.res)) {
@@ -28729,6 +28732,63 @@ var init_compress2 = __esm({
28729
28732
  }
28730
28733
  });
28731
28734
 
28735
+ // ../node_modules/.pnpm/@hono+bun-compress@0.1.0_hono@4.7.11/node_modules/@hono/bun-compress/dist/index.js
28736
+ var import_node_stream, import_node_zlib, ENCODING_TYPES2, cacheControlNoTransformRegExp2, compress2, shouldCompress2, shouldTransform2;
28737
+ var init_dist3 = __esm({
28738
+ "../node_modules/.pnpm/@hono+bun-compress@0.1.0_hono@4.7.11/node_modules/@hono/bun-compress/dist/index.js"() {
28739
+ "use strict";
28740
+ init_compress2();
28741
+ init_compress();
28742
+ import_node_stream = require("stream");
28743
+ import_node_zlib = require("zlib");
28744
+ ENCODING_TYPES2 = ["gzip", "deflate"];
28745
+ cacheControlNoTransformRegExp2 = /(?:^|,)\s*?no-transform\s*?(?:,|$)/i;
28746
+ compress2 = (options) => {
28747
+ if (typeof CompressionStream !== "undefined") {
28748
+ return compress(options);
28749
+ }
28750
+ const threshold = options?.threshold ?? 1024;
28751
+ return async function compress22(ctx, next) {
28752
+ await next();
28753
+ const contentLength = ctx.res.headers.get("Content-Length");
28754
+ if (ctx.res.headers.has("Content-Encoding") || // already encoded
28755
+ ctx.res.headers.has("Transfer-Encoding") || // already encoded or chunked
28756
+ ctx.req.method === "HEAD" || // HEAD request
28757
+ contentLength && Number(contentLength) < threshold || // content-length below threshold
28758
+ !shouldCompress2(ctx.res) || // not compressible type
28759
+ !shouldTransform2(ctx.res)) {
28760
+ return;
28761
+ }
28762
+ const accepted = ctx.req.header("Accept-Encoding");
28763
+ const encoding = options?.encoding ?? ENCODING_TYPES2.find((encoding2) => accepted?.includes(encoding2));
28764
+ if (!encoding || !ctx.res.body) {
28765
+ return;
28766
+ }
28767
+ try {
28768
+ const compressedStream = encoding === "gzip" ? (0, import_node_zlib.createGzip)() : (0, import_node_zlib.createDeflate)();
28769
+ const readableBody = ctx.res.body;
28770
+ const readableStream = import_node_stream.Readable.fromWeb(readableBody);
28771
+ const compressedBody = readableStream.pipe(compressedStream);
28772
+ const compressedReadableStream = import_node_stream.Readable.toWeb(compressedBody);
28773
+ ctx.res = new Response(compressedReadableStream, ctx.res);
28774
+ ctx.res.headers.delete("Content-Length");
28775
+ ctx.res.headers.set("Content-Encoding", encoding);
28776
+ } catch (error2) {
28777
+ console.error("Compression error:", error2);
28778
+ }
28779
+ };
28780
+ };
28781
+ shouldCompress2 = (res) => {
28782
+ const type = res.headers.get("Content-Type");
28783
+ return type && COMPRESSIBLE_CONTENT_TYPE_REGEX.test(type);
28784
+ };
28785
+ shouldTransform2 = (res) => {
28786
+ const cacheControl = res.headers.get("Cache-Control");
28787
+ return !cacheControl || !cacheControlNoTransformRegExp2.test(cacheControl);
28788
+ };
28789
+ }
28790
+ });
28791
+
28732
28792
  // ../node_modules/.pnpm/hono@4.7.11/node_modules/hono/dist/middleware/cors/index.js
28733
28793
  var cors;
28734
28794
  var init_cors = __esm({
@@ -28850,7 +28910,7 @@ function dataUriToBuffer(uri) {
28850
28910
  return buffer;
28851
28911
  }
28852
28912
  var dist_default;
28853
- var init_dist3 = __esm({
28913
+ var init_dist4 = __esm({
28854
28914
  "../node_modules/.pnpm/data-uri-to-buffer@4.0.1/node_modules/data-uri-to-buffer/dist/index.js"() {
28855
28915
  "use strict";
28856
28916
  dist_default = dataUriToBuffer;
@@ -34006,7 +34066,7 @@ async function consumeBody(data) {
34006
34066
  if (body === null) {
34007
34067
  return import_node_buffer.Buffer.alloc(0);
34008
34068
  }
34009
- if (!(body instanceof import_node_stream.default)) {
34069
+ if (!(body instanceof import_node_stream2.default)) {
34010
34070
  return import_node_buffer.Buffer.alloc(0);
34011
34071
  }
34012
34072
  const accum = [];
@@ -34038,11 +34098,11 @@ async function consumeBody(data) {
34038
34098
  throw new FetchError(`Premature close of server response while trying to fetch ${data.url}`);
34039
34099
  }
34040
34100
  }
34041
- var import_node_stream, import_node_util, import_node_buffer, pipeline, INTERNALS, Body, clone, getNonSpecFormDataBoundary, extractContentType, getTotalBytes, writeToStream;
34101
+ var import_node_stream2, import_node_util, import_node_buffer, pipeline, INTERNALS, Body, clone, getNonSpecFormDataBoundary, extractContentType, getTotalBytes, writeToStream;
34042
34102
  var init_body2 = __esm({
34043
34103
  "../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/body.js"() {
34044
34104
  "use strict";
34045
- import_node_stream = __toESM(require("stream"), 1);
34105
+ import_node_stream2 = __toESM(require("stream"), 1);
34046
34106
  import_node_util = require("util");
34047
34107
  import_node_buffer = require("buffer");
34048
34108
  init_fetch_blob();
@@ -34050,7 +34110,7 @@ var init_body2 = __esm({
34050
34110
  init_fetch_error();
34051
34111
  init_base();
34052
34112
  init_is();
34053
- pipeline = (0, import_node_util.promisify)(import_node_stream.default.pipeline);
34113
+ pipeline = (0, import_node_util.promisify)(import_node_stream2.default.pipeline);
34054
34114
  INTERNALS = Symbol("Body internals");
34055
34115
  Body = class {
34056
34116
  constructor(body, {
@@ -34067,7 +34127,7 @@ var init_body2 = __esm({
34067
34127
  body = import_node_buffer.Buffer.from(body);
34068
34128
  } else if (ArrayBuffer.isView(body)) {
34069
34129
  body = import_node_buffer.Buffer.from(body.buffer, body.byteOffset, body.byteLength);
34070
- } else if (body instanceof import_node_stream.default) {
34130
+ } else if (body instanceof import_node_stream2.default) {
34071
34131
  } else if (body instanceof FormData) {
34072
34132
  body = formDataToBlob(body);
34073
34133
  boundary = body.type.split("=")[1];
@@ -34076,9 +34136,9 @@ var init_body2 = __esm({
34076
34136
  }
34077
34137
  let stream = body;
34078
34138
  if (import_node_buffer.Buffer.isBuffer(body)) {
34079
- stream = import_node_stream.default.Readable.from(body);
34139
+ stream = import_node_stream2.default.Readable.from(body);
34080
34140
  } else if (isBlob(body)) {
34081
- stream = import_node_stream.default.Readable.from(body.stream());
34141
+ stream = import_node_stream2.default.Readable.from(body.stream());
34082
34142
  }
34083
34143
  this[INTERNALS] = {
34084
34144
  body,
@@ -34088,7 +34148,7 @@ var init_body2 = __esm({
34088
34148
  error: null
34089
34149
  };
34090
34150
  this.size = size;
34091
- if (body instanceof import_node_stream.default) {
34151
+ if (body instanceof import_node_stream2.default) {
34092
34152
  body.on("error", (error_) => {
34093
34153
  const error2 = error_ instanceof FetchBaseError ? error_ : new FetchError(`Invalid response body while trying to fetch ${this.url}: ${error_.message}`, "system", error_);
34094
34154
  this[INTERNALS].error = error2;
@@ -34184,9 +34244,9 @@ var init_body2 = __esm({
34184
34244
  if (instance.bodyUsed) {
34185
34245
  throw new Error("cannot clone body after it is used");
34186
34246
  }
34187
- if (body instanceof import_node_stream.default && typeof body.getBoundary !== "function") {
34188
- p1 = new import_node_stream.PassThrough({ highWaterMark });
34189
- p22 = new import_node_stream.PassThrough({ highWaterMark });
34247
+ if (body instanceof import_node_stream2.default && typeof body.getBoundary !== "function") {
34248
+ p1 = new import_node_stream2.PassThrough({ highWaterMark });
34249
+ p22 = new import_node_stream2.PassThrough({ highWaterMark });
34190
34250
  body.pipe(p1);
34191
34251
  body.pipe(p22);
34192
34252
  instance[INTERNALS].stream = p1;
@@ -34221,7 +34281,7 @@ var init_body2 = __esm({
34221
34281
  if (body && typeof body.getBoundary === "function") {
34222
34282
  return `multipart/form-data;boundary=${getNonSpecFormDataBoundary(body)}`;
34223
34283
  }
34224
- if (body instanceof import_node_stream.default) {
34284
+ if (body instanceof import_node_stream2.default) {
34225
34285
  return null;
34226
34286
  }
34227
34287
  return "text/plain;charset=UTF-8";
@@ -34985,7 +35045,7 @@ async function fetch2(url, options_) {
34985
35045
  const abort = () => {
34986
35046
  const error2 = new AbortError("The operation was aborted.");
34987
35047
  reject(error2);
34988
- if (request2.body && request2.body instanceof import_node_stream2.default.Readable) {
35048
+ if (request2.body && request2.body instanceof import_node_stream3.default.Readable) {
34989
35049
  request2.body.destroy(error2);
34990
35050
  }
34991
35051
  if (!response || !response.body) {
@@ -35084,7 +35144,7 @@ async function fetch2(url, options_) {
35084
35144
  requestOptions.headers.delete(name);
35085
35145
  }
35086
35146
  }
35087
- if (response_.statusCode !== 303 && request2.body && options_.body instanceof import_node_stream2.default.Readable) {
35147
+ if (response_.statusCode !== 303 && request2.body && options_.body instanceof import_node_stream3.default.Readable) {
35088
35148
  reject(new FetchError("Cannot follow redirect with body being a readable stream", "unsupported-redirect"));
35089
35149
  finalize();
35090
35150
  return;
@@ -35111,7 +35171,7 @@ async function fetch2(url, options_) {
35111
35171
  signal.removeEventListener("abort", abortAndFinalize);
35112
35172
  });
35113
35173
  }
35114
- let body = (0, import_node_stream2.pipeline)(response_, new import_node_stream2.PassThrough(), (error2) => {
35174
+ let body = (0, import_node_stream3.pipeline)(response_, new import_node_stream3.PassThrough(), (error2) => {
35115
35175
  if (error2) {
35116
35176
  reject(error2);
35117
35177
  }
@@ -35135,11 +35195,11 @@ async function fetch2(url, options_) {
35135
35195
  return;
35136
35196
  }
35137
35197
  const zlibOptions = {
35138
- flush: import_node_zlib.default.Z_SYNC_FLUSH,
35139
- finishFlush: import_node_zlib.default.Z_SYNC_FLUSH
35198
+ flush: import_node_zlib2.default.Z_SYNC_FLUSH,
35199
+ finishFlush: import_node_zlib2.default.Z_SYNC_FLUSH
35140
35200
  };
35141
35201
  if (codings === "gzip" || codings === "x-gzip") {
35142
- body = (0, import_node_stream2.pipeline)(body, import_node_zlib.default.createGunzip(zlibOptions), (error2) => {
35202
+ body = (0, import_node_stream3.pipeline)(body, import_node_zlib2.default.createGunzip(zlibOptions), (error2) => {
35143
35203
  if (error2) {
35144
35204
  reject(error2);
35145
35205
  }
@@ -35149,20 +35209,20 @@ async function fetch2(url, options_) {
35149
35209
  return;
35150
35210
  }
35151
35211
  if (codings === "deflate" || codings === "x-deflate") {
35152
- const raw2 = (0, import_node_stream2.pipeline)(response_, new import_node_stream2.PassThrough(), (error2) => {
35212
+ const raw2 = (0, import_node_stream3.pipeline)(response_, new import_node_stream3.PassThrough(), (error2) => {
35153
35213
  if (error2) {
35154
35214
  reject(error2);
35155
35215
  }
35156
35216
  });
35157
35217
  raw2.once("data", (chunk) => {
35158
35218
  if ((chunk[0] & 15) === 8) {
35159
- body = (0, import_node_stream2.pipeline)(body, import_node_zlib.default.createInflate(), (error2) => {
35219
+ body = (0, import_node_stream3.pipeline)(body, import_node_zlib2.default.createInflate(), (error2) => {
35160
35220
  if (error2) {
35161
35221
  reject(error2);
35162
35222
  }
35163
35223
  });
35164
35224
  } else {
35165
- body = (0, import_node_stream2.pipeline)(body, import_node_zlib.default.createInflateRaw(), (error2) => {
35225
+ body = (0, import_node_stream3.pipeline)(body, import_node_zlib2.default.createInflateRaw(), (error2) => {
35166
35226
  if (error2) {
35167
35227
  reject(error2);
35168
35228
  }
@@ -35180,7 +35240,7 @@ async function fetch2(url, options_) {
35180
35240
  return;
35181
35241
  }
35182
35242
  if (codings === "br") {
35183
- body = (0, import_node_stream2.pipeline)(body, import_node_zlib.default.createBrotliDecompress(), (error2) => {
35243
+ body = (0, import_node_stream3.pipeline)(body, import_node_zlib2.default.createBrotliDecompress(), (error2) => {
35184
35244
  if (error2) {
35185
35245
  reject(error2);
35186
35246
  }
@@ -35227,16 +35287,16 @@ function fixResponseChunkedTransferBadEnding(request2, errorCallback) {
35227
35287
  });
35228
35288
  });
35229
35289
  }
35230
- var import_node_http2, import_node_https, import_node_zlib, import_node_stream2, import_node_buffer2, supportedSchemas;
35290
+ var import_node_http2, import_node_https, import_node_zlib2, import_node_stream3, import_node_buffer2, supportedSchemas;
35231
35291
  var init_src = __esm({
35232
35292
  "../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/index.js"() {
35233
35293
  "use strict";
35234
35294
  import_node_http2 = __toESM(require("http"), 1);
35235
35295
  import_node_https = __toESM(require("https"), 1);
35236
- import_node_zlib = __toESM(require("zlib"), 1);
35237
- import_node_stream2 = __toESM(require("stream"), 1);
35296
+ import_node_zlib2 = __toESM(require("zlib"), 1);
35297
+ import_node_stream3 = __toESM(require("stream"), 1);
35238
35298
  import_node_buffer2 = require("buffer");
35239
- init_dist3();
35299
+ init_dist4();
35240
35300
  init_body2();
35241
35301
  init_response();
35242
35302
  init_headers();
@@ -37200,7 +37260,7 @@ var require_sender = __commonJS({
37200
37260
  * @param {Function} [cb] Callback
37201
37261
  * @private
37202
37262
  */
37203
- getBlobData(blob, compress2, options, cb) {
37263
+ getBlobData(blob, compress3, options, cb) {
37204
37264
  this._bufferedBytes += options[kByteLength];
37205
37265
  this._state = GET_BLOB_DATA;
37206
37266
  blob.arrayBuffer().then((arrayBuffer) => {
@@ -37213,12 +37273,12 @@ var require_sender = __commonJS({
37213
37273
  }
37214
37274
  this._bufferedBytes -= options[kByteLength];
37215
37275
  const data = toBuffer(arrayBuffer);
37216
- if (!compress2) {
37276
+ if (!compress3) {
37217
37277
  this._state = DEFAULT;
37218
37278
  this.sendFrame(_Sender.frame(data, options), cb);
37219
37279
  this.dequeue();
37220
37280
  } else {
37221
- this.dispatch(data, compress2, options, cb);
37281
+ this.dispatch(data, compress3, options, cb);
37222
37282
  }
37223
37283
  }).catch((err2) => {
37224
37284
  process.nextTick(onError, this, err2, cb);
@@ -37247,8 +37307,8 @@ var require_sender = __commonJS({
37247
37307
  * @param {Function} [cb] Callback
37248
37308
  * @private
37249
37309
  */
37250
- dispatch(data, compress2, options, cb) {
37251
- if (!compress2) {
37310
+ dispatch(data, compress3, options, cb) {
37311
+ if (!compress3) {
37252
37312
  this.sendFrame(_Sender.frame(data, options), cb);
37253
37313
  return;
37254
37314
  }
@@ -37718,7 +37778,7 @@ var require_websocket = __commonJS({
37718
37778
  var net = require("net");
37719
37779
  var tls = require("tls");
37720
37780
  var { randomBytes, createHash: createHash4 } = require("crypto");
37721
- var { Duplex, Readable: Readable6 } = require("stream");
37781
+ var { Duplex, Readable: Readable7 } = require("stream");
37722
37782
  var { URL: URL2 } = require("url");
37723
37783
  var PerMessageDeflate = require_permessage_deflate();
37724
37784
  var Receiver2 = require_receiver();
@@ -42583,11 +42643,11 @@ var init_createBufferedReadableStream = __esm({
42583
42643
  });
42584
42644
 
42585
42645
  // ../node_modules/.pnpm/@smithy+util-stream@4.2.2/node_modules/@smithy/util-stream/dist-es/createBufferedReadable.js
42586
- var import_node_stream3;
42646
+ var import_node_stream4;
42587
42647
  var init_createBufferedReadable = __esm({
42588
42648
  "../node_modules/.pnpm/@smithy+util-stream@4.2.2/node_modules/@smithy/util-stream/dist-es/createBufferedReadable.js"() {
42589
42649
  "use strict";
42590
- import_node_stream3 = require("stream");
42650
+ import_node_stream4 = require("stream");
42591
42651
  init_ByteArrayCollector();
42592
42652
  init_createBufferedReadableStream();
42593
42653
  init_stream_type_check();
@@ -49206,9 +49266,9 @@ var require_node2json = __commonJS({
49206
49266
  "../node_modules/.pnpm/fast-xml-parser@4.4.1/node_modules/fast-xml-parser/src/xmlparser/node2json.js"(exports2) {
49207
49267
  "use strict";
49208
49268
  function prettify(node, options) {
49209
- return compress2(node, options);
49269
+ return compress3(node, options);
49210
49270
  }
49211
- function compress2(arr, options, jPath) {
49271
+ function compress3(arr, options, jPath) {
49212
49272
  let text;
49213
49273
  const compressedObj = {};
49214
49274
  for (let i6 = 0; i6 < arr.length; i6++) {
@@ -49223,7 +49283,7 @@ var require_node2json = __commonJS({
49223
49283
  } else if (property === void 0) {
49224
49284
  continue;
49225
49285
  } else if (tagObj[property]) {
49226
- let val2 = compress2(tagObj[property], options, newJpath);
49286
+ let val2 = compress3(tagObj[property], options, newJpath);
49227
49287
  const isLeaf = isLeafTag(val2, options);
49228
49288
  if (tagObj[":@"]) {
49229
49289
  assignAttributes(val2, tagObj[":@"], newJpath, options);
@@ -72816,8 +72876,51 @@ var init_connections = __esm({
72816
72876
  };
72817
72877
  return { packageName: "@neondatabase/serverless", query, proxy, transactionProxy, migrate: migrateFn };
72818
72878
  }
72879
+ if (await checkPackage("bun")) {
72880
+ console.log(withStyle.info(`Using 'bun' driver for database querying`));
72881
+ const { SQL: SQL5 } = require("bun");
72882
+ const { drizzle } = require("drizzle-orm/bun-sql");
72883
+ const { migrate } = require("drizzle-orm/bun-sql/migrator");
72884
+ const ssl = "ssl" in credentials2 ? credentials2.ssl === "prefer" || credentials2.ssl === "require" || credentials2.ssl === "allow" ? true : false : void 0;
72885
+ const client = new SQL5({
72886
+ adapter: "postgres",
72887
+ ...credentials2,
72888
+ ssl,
72889
+ max: 1
72890
+ });
72891
+ const db = drizzle(client);
72892
+ const migrateFn = async (config) => {
72893
+ return migrate(db, config);
72894
+ };
72895
+ const query = async (sql, params) => {
72896
+ const result = await client.unsafe(sql, params ?? []);
72897
+ return result;
72898
+ };
72899
+ const proxy = async (params) => {
72900
+ const query2 = client.unsafe(params.sql, params.params);
72901
+ if (params.mode === "array") {
72902
+ return await query2.values();
72903
+ }
72904
+ return await query2;
72905
+ };
72906
+ const transactionProxy = async (queries) => {
72907
+ const results = [];
72908
+ try {
72909
+ await client.transaction(async (tx) => {
72910
+ for (const query2 of queries) {
72911
+ const result = await tx.unsafe(query2.sql);
72912
+ results.push(result);
72913
+ }
72914
+ });
72915
+ } catch (error2) {
72916
+ results.push(error2);
72917
+ }
72918
+ return results;
72919
+ };
72920
+ return { packageName: "bun", query, proxy, transactionProxy, migrate: migrateFn };
72921
+ }
72819
72922
  console.error(
72820
- "To connect to Postgres database - please install either of 'pg', 'postgres', '@neondatabase/serverless' or '@vercel/postgres' drivers"
72923
+ "To connect to Postgres database - please install either of 'pg', 'postgres', 'bun', '@neondatabase/serverless' or '@vercel/postgres' drivers"
72821
72924
  );
72822
72925
  process.exit(1);
72823
72926
  };
@@ -72978,6 +73081,7 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
72978
73081
  connectToMySQL = async (it) => {
72979
73082
  const result = parseMysqlCredentials(it);
72980
73083
  if (await checkPackage("mysql2")) {
73084
+ console.log(withStyle.info(`Using 'mysql2' driver for database querying`));
72981
73085
  const { createConnection } = require("mysql2/promise");
72982
73086
  const { drizzle } = require("drizzle-orm/mysql2");
72983
73087
  const { migrate } = require("drizzle-orm/mysql2/migrator");
@@ -73035,6 +73139,7 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
73035
73139
  };
73036
73140
  }
73037
73141
  if (await checkPackage("@planetscale/database")) {
73142
+ console.log(withStyle.info(`Using '@planetscale/database' driver for database querying`));
73038
73143
  const { Client: Client2 } = require("@planetscale/database");
73039
73144
  const { drizzle } = require("drizzle-orm/planetscale-serverless");
73040
73145
  const { migrate } = require("drizzle-orm/planetscale-serverless/migrator");
@@ -73078,8 +73183,57 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
73078
73183
  migrate: migrateFn
73079
73184
  };
73080
73185
  }
73186
+ if (await checkPackage("bun")) {
73187
+ console.log(withStyle.info(`Using 'bun' driver for database querying`));
73188
+ const { SQL: SQL5 } = require("bun");
73189
+ const { drizzle } = require("drizzle-orm/bun-sql");
73190
+ const { migrate } = require("drizzle-orm/bun-sql/migrator");
73191
+ const ssl = result.credentials && "ssl" in result.credentials ? result.credentials.ssl === "prefer" || result.credentials.ssl === "require" || result.credentials.ssl === "allow" ? true : false : void 0;
73192
+ const client = result.url ? new SQL5(result.url) : new SQL5({
73193
+ adapter: "mysql",
73194
+ ...result.credentials,
73195
+ ssl
73196
+ });
73197
+ const db = drizzle(client);
73198
+ const migrateFn = async (config) => {
73199
+ return migrate(db, config);
73200
+ };
73201
+ const query = async (sql, params) => {
73202
+ const result2 = await client.unsafe(sql, params ?? []);
73203
+ return result2;
73204
+ };
73205
+ const proxy = async (params) => {
73206
+ const query2 = client.unsafe(params.sql, params.params);
73207
+ if (params.mode === "array") {
73208
+ return await query2.values();
73209
+ }
73210
+ return await query2;
73211
+ };
73212
+ const transactionProxy = async (queries) => {
73213
+ const results = [];
73214
+ try {
73215
+ await client.transaction(async (tx) => {
73216
+ for (const query2 of queries) {
73217
+ const result2 = await tx.unsafe(query2.sql);
73218
+ results.push(result2);
73219
+ }
73220
+ });
73221
+ } catch (error2) {
73222
+ results.push(error2);
73223
+ }
73224
+ return results;
73225
+ };
73226
+ return {
73227
+ packageName: "bun",
73228
+ db: { query },
73229
+ proxy,
73230
+ transactionProxy,
73231
+ migrate: migrateFn,
73232
+ database: result.database
73233
+ };
73234
+ }
73081
73235
  console.error(
73082
- "To connect to MySQL database - please install either of 'mysql2' or '@planetscale/database' drivers"
73236
+ "To connect to MySQL database - please install either of 'mysql2', 'bun' or '@planetscale/database' drivers"
73083
73237
  );
73084
73238
  process.exit(1);
73085
73239
  };
@@ -73166,21 +73320,19 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
73166
73320
  return migrate(
73167
73321
  drzl,
73168
73322
  async (queries) => {
73169
- for (const query of queries) {
73170
- await remoteCallback(query, [], "run");
73323
+ for (const query2 of queries) {
73324
+ await remoteCallback(query2, [], "run");
73171
73325
  }
73172
73326
  },
73173
73327
  config
73174
73328
  );
73175
73329
  };
73176
- const db = {
73177
- query: async (sql, params) => {
73178
- const res = await remoteCallback(sql, params || [], "all");
73179
- return res.rows;
73180
- },
73181
- run: async (query) => {
73182
- await remoteCallback(query, [], "run");
73183
- }
73330
+ const query = async (sql, params) => {
73331
+ const res = await remoteCallback(sql, params || [], "all");
73332
+ return res.rows;
73333
+ };
73334
+ const run = async (query2) => {
73335
+ await remoteCallback(query2, [], "run");
73184
73336
  };
73185
73337
  const proxy = async (params) => {
73186
73338
  const preparedParams = prepareSqliteParams(params.params || [], "d1-http");
@@ -73195,12 +73347,90 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
73195
73347
  const result = await remoteBatchCallback(queries);
73196
73348
  return result.rows;
73197
73349
  };
73198
- return { ...db, packageName: "d1-http", proxy, transactionProxy, migrate: migrateFn };
73350
+ return { query, run, packageName: "d1-http", proxy, transactionProxy, migrate: migrateFn };
73351
+ } else if (driver2 === "sqlite-cloud") {
73352
+ assertPackages("@sqlitecloud/drivers");
73353
+ const { Database } = require("@sqlitecloud/drivers");
73354
+ const { drizzle } = require("drizzle-orm/sqlite-cloud");
73355
+ const { migrate } = require("drizzle-orm/sqlite-cloud/migrator");
73356
+ const client = new Database(credentials2.url);
73357
+ const drzl = drizzle(client);
73358
+ const migrateFn = async (config) => {
73359
+ return migrate(drzl, config);
73360
+ };
73361
+ const query = async (sql, params) => {
73362
+ const stmt = client.prepare(sql).bind(params || []);
73363
+ return await new Promise((resolve, reject) => {
73364
+ stmt.all((e6, d5) => {
73365
+ if (e6) return reject(e6);
73366
+ return resolve(d5.map((v6) => Object.fromEntries(Object.entries(v6))));
73367
+ });
73368
+ });
73369
+ };
73370
+ const run = async (query2) => {
73371
+ return await new Promise((resolve, reject) => {
73372
+ client.exec(query2, (e6) => {
73373
+ if (e6) return reject(e6);
73374
+ return resolve();
73375
+ });
73376
+ });
73377
+ };
73378
+ const proxy = async (params) => {
73379
+ const preparedParams = prepareSqliteParams(params.params || []);
73380
+ const stmt = client.prepare(params.sql).bind(preparedParams);
73381
+ return await new Promise((resolve, reject) => {
73382
+ stmt.all((e6, d5) => {
73383
+ if (e6) return reject(e6);
73384
+ if (params.mode === "array") {
73385
+ return resolve((d5 || []).map((v6) => v6.getData()));
73386
+ } else {
73387
+ return resolve((d5 || []).map((v6) => Object.fromEntries(Object.entries(v6))));
73388
+ }
73389
+ });
73390
+ });
73391
+ };
73392
+ const transactionProxy = async (queries) => {
73393
+ const results = [];
73394
+ try {
73395
+ await new Promise((resolve, reject) => {
73396
+ client.exec("BEGIN", (e6) => {
73397
+ if (e6) return reject(e6);
73398
+ return resolve();
73399
+ });
73400
+ });
73401
+ for (const query2 of queries) {
73402
+ const result = await new Promise((resolve, reject) => {
73403
+ client.all(query2.sql, (e6, d5) => {
73404
+ if (e6) return reject(e6);
73405
+ return resolve((d5 || []).map((v6) => Object.fromEntries(Object.entries(v6))));
73406
+ });
73407
+ });
73408
+ results.push(result);
73409
+ }
73410
+ await new Promise((resolve, reject) => {
73411
+ client.exec("COMMIT", (e6) => {
73412
+ if (e6) return reject(e6);
73413
+ return resolve();
73414
+ });
73415
+ });
73416
+ } catch (error2) {
73417
+ results.push(error2);
73418
+ await new Promise((resolve, reject) => {
73419
+ client.exec("ROLLBACK", (e6) => {
73420
+ if (e6) return reject(e6);
73421
+ return resolve();
73422
+ });
73423
+ });
73424
+ }
73425
+ return results;
73426
+ };
73427
+ return { query, run, packageName: "@sqlitecloud/drivers", proxy, transactionProxy, migrate: migrateFn };
73199
73428
  } else {
73200
73429
  assertUnreachable(driver2);
73201
73430
  }
73202
73431
  }
73203
73432
  if (await checkPackage("@libsql/client")) {
73433
+ console.log(withStyle.info(`Using '@libsql/client' driver for database querying`));
73204
73434
  const { createClient } = require("@libsql/client");
73205
73435
  const { drizzle } = require("drizzle-orm/libsql");
73206
73436
  const { migrate } = require("drizzle-orm/libsql/migrator");
@@ -73211,14 +73441,12 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
73211
73441
  const migrateFn = async (config) => {
73212
73442
  return migrate(drzl, config);
73213
73443
  };
73214
- const db = {
73215
- query: async (sql, params) => {
73216
- const res = await client.execute({ sql, args: params || [] });
73217
- return res.rows;
73218
- },
73219
- run: async (query) => {
73220
- await client.execute(query);
73221
- }
73444
+ const query = async (sql, params) => {
73445
+ const res = await client.execute({ sql, args: params || [] });
73446
+ return res.rows;
73447
+ };
73448
+ const run = async (query2) => {
73449
+ await client.execute(query2);
73222
73450
  };
73223
73451
  const proxy = async (params) => {
73224
73452
  const preparedParams = prepareSqliteParams(params.params || []);
@@ -73237,8 +73465,8 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
73237
73465
  let transaction = null;
73238
73466
  try {
73239
73467
  transaction = await client.transaction();
73240
- for (const query of queries) {
73241
- const result = await transaction.execute(query.sql);
73468
+ for (const query2 of queries) {
73469
+ const result = await transaction.execute(query2.sql);
73242
73470
  results.push(result.rows);
73243
73471
  }
73244
73472
  await transaction.commit();
@@ -73250,9 +73478,10 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
73250
73478
  }
73251
73479
  return results;
73252
73480
  };
73253
- return { ...db, packageName: "@libsql/client", proxy, transactionProxy, migrate: migrateFn };
73481
+ return { query, run, packageName: "@libsql/client", proxy, transactionProxy, migrate: migrateFn };
73254
73482
  }
73255
73483
  if (await checkPackage("better-sqlite3")) {
73484
+ console.log(withStyle.info(`Using 'better-sqlite3' driver for database querying`));
73256
73485
  const { default: Database } = require("better-sqlite3");
73257
73486
  const { drizzle } = require("drizzle-orm/better-sqlite3");
73258
73487
  const { migrate } = require("drizzle-orm/better-sqlite3/migrator");
@@ -73263,13 +73492,11 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
73263
73492
  const migrateFn = async (config) => {
73264
73493
  return migrate(drzl, config);
73265
73494
  };
73266
- const db = {
73267
- query: async (sql, params = []) => {
73268
- return sqlite.prepare(sql).bind(params).all();
73269
- },
73270
- run: async (query) => {
73271
- sqlite.prepare(query).run();
73272
- }
73495
+ const query = async (sql, params = []) => {
73496
+ return sqlite.prepare(sql).bind(params).all();
73497
+ };
73498
+ const run = async (query2) => {
73499
+ sqlite.prepare(query2).run();
73273
73500
  };
73274
73501
  const proxy = async (params) => {
73275
73502
  const preparedParams = prepareSqliteParams(params.params || []);
@@ -73282,12 +73509,12 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
73282
73509
  const transactionProxy = async (queries) => {
73283
73510
  const results = [];
73284
73511
  const tx = sqlite.transaction((queries2) => {
73285
- for (const query of queries2) {
73512
+ for (const query2 of queries2) {
73286
73513
  let result = [];
73287
- if (query.method === "values" || query.method === "get" || query.method === "all") {
73288
- result = sqlite.prepare(query.sql).all();
73514
+ if (query2.method === "values" || query2.method === "get" || query2.method === "all") {
73515
+ result = sqlite.prepare(query2.sql).all();
73289
73516
  } else {
73290
- sqlite.prepare(query.sql).run();
73517
+ sqlite.prepare(query2.sql).run();
73291
73518
  }
73292
73519
  results.push(result);
73293
73520
  }
@@ -73299,10 +73526,60 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
73299
73526
  }
73300
73527
  return results;
73301
73528
  };
73302
- return { ...db, packageName: "better-sqlite3", proxy, transactionProxy, migrate: migrateFn };
73529
+ return { query, run, packageName: "better-sqlite3", proxy, transactionProxy, migrate: migrateFn };
73530
+ }
73531
+ if (await checkPackage("bun")) {
73532
+ console.log(withStyle.info(`Using 'bun' driver for database querying`));
73533
+ const { SQL: SQL5 } = require("bun");
73534
+ const { drizzle } = require("drizzle-orm/bun-sql");
73535
+ const { migrate } = require("drizzle-orm/bun-sql/migrator");
73536
+ const client = new SQL5({
73537
+ adapter: "sqlite",
73538
+ filename: normaliseSQLiteUrl(credentials2.url, "bun")
73539
+ });
73540
+ const db = drizzle(client);
73541
+ const migrateFn = async (config) => {
73542
+ return migrate(db, config);
73543
+ };
73544
+ const query = async (sql, params) => {
73545
+ const result = await client.unsafe(sql, params ?? []);
73546
+ return result;
73547
+ };
73548
+ const run = async (sql) => {
73549
+ await client.unsafe(sql);
73550
+ };
73551
+ const proxy = async (params) => {
73552
+ const query2 = client.unsafe(params.sql, params.params);
73553
+ if (params.mode === "array") {
73554
+ return await query2.values();
73555
+ }
73556
+ return await query2;
73557
+ };
73558
+ const transactionProxy = async (queries) => {
73559
+ const results = [];
73560
+ try {
73561
+ await client.transaction(async (tx) => {
73562
+ for (const query2 of queries) {
73563
+ const result = await tx.unsafe(query2.sql);
73564
+ results.push(result);
73565
+ }
73566
+ });
73567
+ } catch (error2) {
73568
+ results.push(error2);
73569
+ }
73570
+ return results;
73571
+ };
73572
+ return {
73573
+ packageName: "bun",
73574
+ query,
73575
+ run,
73576
+ proxy,
73577
+ transactionProxy,
73578
+ migrate: migrateFn
73579
+ };
73303
73580
  }
73304
73581
  console.log(
73305
- "Please install either 'better-sqlite3' or '@libsql/client' for Drizzle Kit to connect to SQLite databases"
73582
+ "Please install either 'better-sqlite3', '@libsql/client' or 'bun' for Drizzle Kit to connect to SQLite databases"
73306
73583
  );
73307
73584
  process.exit(1);
73308
73585
  };
@@ -73401,7 +73678,7 @@ var init_studio2 = __esm({
73401
73678
  import_sqlite_core2 = require("drizzle-orm/sqlite-core");
73402
73679
  import_fs8 = __toESM(require("fs"));
73403
73680
  init_dist2();
73404
- init_compress2();
73681
+ init_dist3();
73405
73682
  init_cors();
73406
73683
  import_node_https2 = require("https");
73407
73684
  init_global();
@@ -73620,6 +73897,8 @@ var init_studio2 = __esm({
73620
73897
  const { driver: driver2 } = credentials2;
73621
73898
  if (driver2 === "d1-http") {
73622
73899
  dbUrl = `d1-http://${credentials2.accountId}/${credentials2.databaseId}/${credentials2.token}`;
73900
+ } else if (driver2 === "sqlite-cloud") {
73901
+ dbUrl = credentials2.url;
73623
73902
  } else {
73624
73903
  assertUnreachable(driver2);
73625
73904
  }
@@ -73818,7 +74097,7 @@ var init_studio2 = __esm({
73818
74097
  schemaFiles
73819
74098
  }, app) => {
73820
74099
  app = app !== void 0 ? app : new Hono2();
73821
- app.use(compress());
74100
+ app.use(compress2());
73822
74101
  app.use(async (ctx, next) => {
73823
74102
  await next();
73824
74103
  ctx.header("Access-Control-Allow-Private-Network", "true");