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.d.mts +7 -1
- package/api.d.ts +7 -1
- package/api.js +362 -83
- package/api.mjs +344 -65
- package/bin.cjs +1142 -829
- package/index.d.mts +4 -1
- package/index.d.ts +4 -1
- package/package.json +6 -2
- package/utils.js +1 -1
- package/utils.mjs +1 -1
package/api.mjs
CHANGED
|
@@ -9520,7 +9520,7 @@ var init_utils = __esm({
|
|
|
9520
9520
|
return `file:${it}`;
|
|
9521
9521
|
}
|
|
9522
9522
|
}
|
|
9523
|
-
if (type === "better-sqlite") {
|
|
9523
|
+
if (type === "better-sqlite" || type === "@tursodatabase/database" || type === "bun") {
|
|
9524
9524
|
if (it.startsWith("file:")) {
|
|
9525
9525
|
return it.substring(5);
|
|
9526
9526
|
}
|
|
@@ -20654,7 +20654,8 @@ var init_common = __esm({
|
|
|
20654
20654
|
sqliteDriversLiterals = [
|
|
20655
20655
|
literalType("d1-http"),
|
|
20656
20656
|
literalType("expo"),
|
|
20657
|
-
literalType("durable-sqlite")
|
|
20657
|
+
literalType("durable-sqlite"),
|
|
20658
|
+
literalType("sqlite-cloud")
|
|
20658
20659
|
];
|
|
20659
20660
|
postgresqlDriversLiterals = [
|
|
20660
20661
|
literalType("aws-data-api"),
|
|
@@ -25463,9 +25464,7 @@ var init_cli = __esm({
|
|
|
25463
25464
|
extensionsFilters: literalType("postgis").array().optional(),
|
|
25464
25465
|
casing,
|
|
25465
25466
|
breakpoints: booleanType().optional().default(true),
|
|
25466
|
-
migrations:
|
|
25467
|
-
prefix: prefix.optional().default("index")
|
|
25468
|
-
}).optional(),
|
|
25467
|
+
migrations: configMigrations,
|
|
25469
25468
|
entities: objectType({
|
|
25470
25469
|
roles: booleanType().or(objectType({
|
|
25471
25470
|
provider: stringType().optional(),
|
|
@@ -25694,6 +25693,10 @@ var init_sqlite = __esm({
|
|
|
25694
25693
|
databaseId: stringType().min(1),
|
|
25695
25694
|
token: stringType().min(1)
|
|
25696
25695
|
}),
|
|
25696
|
+
objectType({
|
|
25697
|
+
driver: literalType("sqlite-cloud"),
|
|
25698
|
+
url: stringType().min(1)
|
|
25699
|
+
}),
|
|
25697
25700
|
objectType({
|
|
25698
25701
|
driver: undefinedType(),
|
|
25699
25702
|
url: stringType().min(1)
|
|
@@ -28744,7 +28747,7 @@ var init_compress2 = __esm({
|
|
|
28744
28747
|
cacheControlNoTransformRegExp = /(?:^|,)\s*?no-transform\s*?(?:,|$)/i;
|
|
28745
28748
|
compress = (options) => {
|
|
28746
28749
|
const threshold = options?.threshold ?? 1024;
|
|
28747
|
-
return async function
|
|
28750
|
+
return async function compress22(ctx, next) {
|
|
28748
28751
|
await next();
|
|
28749
28752
|
const contentLength = ctx.res.headers.get("Content-Length");
|
|
28750
28753
|
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)) {
|
|
@@ -28772,6 +28775,63 @@ var init_compress2 = __esm({
|
|
|
28772
28775
|
}
|
|
28773
28776
|
});
|
|
28774
28777
|
|
|
28778
|
+
// ../node_modules/.pnpm/@hono+bun-compress@0.1.0_hono@4.7.11/node_modules/@hono/bun-compress/dist/index.js
|
|
28779
|
+
import { Readable as Readable2 } from "stream";
|
|
28780
|
+
import { createDeflate, createGzip } from "zlib";
|
|
28781
|
+
var ENCODING_TYPES2, cacheControlNoTransformRegExp2, compress2, shouldCompress2, shouldTransform2;
|
|
28782
|
+
var init_dist3 = __esm({
|
|
28783
|
+
"../node_modules/.pnpm/@hono+bun-compress@0.1.0_hono@4.7.11/node_modules/@hono/bun-compress/dist/index.js"() {
|
|
28784
|
+
"use strict";
|
|
28785
|
+
init_compress2();
|
|
28786
|
+
init_compress();
|
|
28787
|
+
ENCODING_TYPES2 = ["gzip", "deflate"];
|
|
28788
|
+
cacheControlNoTransformRegExp2 = /(?:^|,)\s*?no-transform\s*?(?:,|$)/i;
|
|
28789
|
+
compress2 = (options) => {
|
|
28790
|
+
if (typeof CompressionStream !== "undefined") {
|
|
28791
|
+
return compress(options);
|
|
28792
|
+
}
|
|
28793
|
+
const threshold = options?.threshold ?? 1024;
|
|
28794
|
+
return async function compress22(ctx, next) {
|
|
28795
|
+
await next();
|
|
28796
|
+
const contentLength = ctx.res.headers.get("Content-Length");
|
|
28797
|
+
if (ctx.res.headers.has("Content-Encoding") || // already encoded
|
|
28798
|
+
ctx.res.headers.has("Transfer-Encoding") || // already encoded or chunked
|
|
28799
|
+
ctx.req.method === "HEAD" || // HEAD request
|
|
28800
|
+
contentLength && Number(contentLength) < threshold || // content-length below threshold
|
|
28801
|
+
!shouldCompress2(ctx.res) || // not compressible type
|
|
28802
|
+
!shouldTransform2(ctx.res)) {
|
|
28803
|
+
return;
|
|
28804
|
+
}
|
|
28805
|
+
const accepted = ctx.req.header("Accept-Encoding");
|
|
28806
|
+
const encoding = options?.encoding ?? ENCODING_TYPES2.find((encoding2) => accepted?.includes(encoding2));
|
|
28807
|
+
if (!encoding || !ctx.res.body) {
|
|
28808
|
+
return;
|
|
28809
|
+
}
|
|
28810
|
+
try {
|
|
28811
|
+
const compressedStream = encoding === "gzip" ? createGzip() : createDeflate();
|
|
28812
|
+
const readableBody = ctx.res.body;
|
|
28813
|
+
const readableStream = Readable2.fromWeb(readableBody);
|
|
28814
|
+
const compressedBody = readableStream.pipe(compressedStream);
|
|
28815
|
+
const compressedReadableStream = Readable2.toWeb(compressedBody);
|
|
28816
|
+
ctx.res = new Response(compressedReadableStream, ctx.res);
|
|
28817
|
+
ctx.res.headers.delete("Content-Length");
|
|
28818
|
+
ctx.res.headers.set("Content-Encoding", encoding);
|
|
28819
|
+
} catch (error2) {
|
|
28820
|
+
console.error("Compression error:", error2);
|
|
28821
|
+
}
|
|
28822
|
+
};
|
|
28823
|
+
};
|
|
28824
|
+
shouldCompress2 = (res) => {
|
|
28825
|
+
const type = res.headers.get("Content-Type");
|
|
28826
|
+
return type && COMPRESSIBLE_CONTENT_TYPE_REGEX.test(type);
|
|
28827
|
+
};
|
|
28828
|
+
shouldTransform2 = (res) => {
|
|
28829
|
+
const cacheControl = res.headers.get("Cache-Control");
|
|
28830
|
+
return !cacheControl || !cacheControlNoTransformRegExp2.test(cacheControl);
|
|
28831
|
+
};
|
|
28832
|
+
}
|
|
28833
|
+
});
|
|
28834
|
+
|
|
28775
28835
|
// ../node_modules/.pnpm/hono@4.7.11/node_modules/hono/dist/middleware/cors/index.js
|
|
28776
28836
|
var cors;
|
|
28777
28837
|
var init_cors = __esm({
|
|
@@ -28893,7 +28953,7 @@ function dataUriToBuffer(uri) {
|
|
|
28893
28953
|
return buffer;
|
|
28894
28954
|
}
|
|
28895
28955
|
var dist_default;
|
|
28896
|
-
var
|
|
28956
|
+
var init_dist4 = __esm({
|
|
28897
28957
|
"../node_modules/.pnpm/data-uri-to-buffer@4.0.1/node_modules/data-uri-to-buffer/dist/index.js"() {
|
|
28898
28958
|
"use strict";
|
|
28899
28959
|
dist_default = dataUriToBuffer;
|
|
@@ -35279,7 +35339,7 @@ var supportedSchemas;
|
|
|
35279
35339
|
var init_src = __esm({
|
|
35280
35340
|
"../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/index.js"() {
|
|
35281
35341
|
"use strict";
|
|
35282
|
-
|
|
35342
|
+
init_dist4();
|
|
35283
35343
|
init_body2();
|
|
35284
35344
|
init_response();
|
|
35285
35345
|
init_headers();
|
|
@@ -37243,7 +37303,7 @@ var require_sender = __commonJS({
|
|
|
37243
37303
|
* @param {Function} [cb] Callback
|
|
37244
37304
|
* @private
|
|
37245
37305
|
*/
|
|
37246
|
-
getBlobData(blob,
|
|
37306
|
+
getBlobData(blob, compress3, options, cb) {
|
|
37247
37307
|
this._bufferedBytes += options[kByteLength];
|
|
37248
37308
|
this._state = GET_BLOB_DATA;
|
|
37249
37309
|
blob.arrayBuffer().then((arrayBuffer) => {
|
|
@@ -37256,12 +37316,12 @@ var require_sender = __commonJS({
|
|
|
37256
37316
|
}
|
|
37257
37317
|
this._bufferedBytes -= options[kByteLength];
|
|
37258
37318
|
const data = toBuffer(arrayBuffer);
|
|
37259
|
-
if (!
|
|
37319
|
+
if (!compress3) {
|
|
37260
37320
|
this._state = DEFAULT;
|
|
37261
37321
|
this.sendFrame(_Sender.frame(data, options), cb);
|
|
37262
37322
|
this.dequeue();
|
|
37263
37323
|
} else {
|
|
37264
|
-
this.dispatch(data,
|
|
37324
|
+
this.dispatch(data, compress3, options, cb);
|
|
37265
37325
|
}
|
|
37266
37326
|
}).catch((err2) => {
|
|
37267
37327
|
process.nextTick(onError, this, err2, cb);
|
|
@@ -37290,8 +37350,8 @@ var require_sender = __commonJS({
|
|
|
37290
37350
|
* @param {Function} [cb] Callback
|
|
37291
37351
|
* @private
|
|
37292
37352
|
*/
|
|
37293
|
-
dispatch(data,
|
|
37294
|
-
if (!
|
|
37353
|
+
dispatch(data, compress3, options, cb) {
|
|
37354
|
+
if (!compress3) {
|
|
37295
37355
|
this.sendFrame(_Sender.frame(data, options), cb);
|
|
37296
37356
|
return;
|
|
37297
37357
|
}
|
|
@@ -37761,7 +37821,7 @@ var require_websocket = __commonJS({
|
|
|
37761
37821
|
var net = __require("net");
|
|
37762
37822
|
var tls = __require("tls");
|
|
37763
37823
|
var { randomBytes, createHash: createHash4 } = __require("crypto");
|
|
37764
|
-
var { Duplex, Readable:
|
|
37824
|
+
var { Duplex, Readable: Readable7 } = __require("stream");
|
|
37765
37825
|
var { URL: URL2 } = __require("url");
|
|
37766
37826
|
var PerMessageDeflate = require_permessage_deflate();
|
|
37767
37827
|
var Receiver2 = require_receiver();
|
|
@@ -42626,7 +42686,7 @@ var init_createBufferedReadableStream = __esm({
|
|
|
42626
42686
|
});
|
|
42627
42687
|
|
|
42628
42688
|
// ../node_modules/.pnpm/@smithy+util-stream@4.2.2/node_modules/@smithy/util-stream/dist-es/createBufferedReadable.js
|
|
42629
|
-
import { Readable as
|
|
42689
|
+
import { Readable as Readable3 } from "stream";
|
|
42630
42690
|
var init_createBufferedReadable = __esm({
|
|
42631
42691
|
"../node_modules/.pnpm/@smithy+util-stream@4.2.2/node_modules/@smithy/util-stream/dist-es/createBufferedReadable.js"() {
|
|
42632
42692
|
"use strict";
|
|
@@ -42853,7 +42913,7 @@ var init_set_socket_timeout = __esm({
|
|
|
42853
42913
|
});
|
|
42854
42914
|
|
|
42855
42915
|
// ../node_modules/.pnpm/@smithy+node-http-handler@4.0.6/node_modules/@smithy/node-http-handler/dist-es/write-request-body.js
|
|
42856
|
-
import { Readable as
|
|
42916
|
+
import { Readable as Readable4 } from "stream";
|
|
42857
42917
|
async function writeRequestBody(httpRequest2, request2, maxContinueTimeoutMs = MIN_WAIT_TIME) {
|
|
42858
42918
|
const headers = request2.headers ?? {};
|
|
42859
42919
|
const expect = headers["Expect"] || headers["expect"];
|
|
@@ -42885,7 +42945,7 @@ async function writeRequestBody(httpRequest2, request2, maxContinueTimeoutMs = M
|
|
|
42885
42945
|
}
|
|
42886
42946
|
}
|
|
42887
42947
|
function writeBody(httpRequest2, body) {
|
|
42888
|
-
if (body instanceof
|
|
42948
|
+
if (body instanceof Readable4) {
|
|
42889
42949
|
body.pipe(httpRequest2);
|
|
42890
42950
|
return;
|
|
42891
42951
|
}
|
|
@@ -43429,7 +43489,7 @@ var init_sdk_stream_mixin_browser = __esm({
|
|
|
43429
43489
|
});
|
|
43430
43490
|
|
|
43431
43491
|
// ../node_modules/.pnpm/@smithy+util-stream@4.2.2/node_modules/@smithy/util-stream/dist-es/sdk-stream-mixin.js
|
|
43432
|
-
import { Readable as
|
|
43492
|
+
import { Readable as Readable5 } from "stream";
|
|
43433
43493
|
var ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED2, sdkStreamMixin2;
|
|
43434
43494
|
var init_sdk_stream_mixin = __esm({
|
|
43435
43495
|
"../node_modules/.pnpm/@smithy+util-stream@4.2.2/node_modules/@smithy/util-stream/dist-es/sdk-stream-mixin.js"() {
|
|
@@ -43439,7 +43499,7 @@ var init_sdk_stream_mixin = __esm({
|
|
|
43439
43499
|
init_sdk_stream_mixin_browser();
|
|
43440
43500
|
ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED2 = "The stream has already been transformed.";
|
|
43441
43501
|
sdkStreamMixin2 = (stream) => {
|
|
43442
|
-
if (!(stream instanceof
|
|
43502
|
+
if (!(stream instanceof Readable5)) {
|
|
43443
43503
|
try {
|
|
43444
43504
|
return sdkStreamMixin(stream);
|
|
43445
43505
|
} catch (e6) {
|
|
@@ -43473,11 +43533,11 @@ var init_sdk_stream_mixin = __esm({
|
|
|
43473
43533
|
if (stream.readableFlowing !== null) {
|
|
43474
43534
|
throw new Error("The stream has been consumed by other callbacks.");
|
|
43475
43535
|
}
|
|
43476
|
-
if (typeof
|
|
43536
|
+
if (typeof Readable5.toWeb !== "function") {
|
|
43477
43537
|
throw new Error("Readable.toWeb() is not supported. Please ensure a polyfill is available.");
|
|
43478
43538
|
}
|
|
43479
43539
|
transformed = true;
|
|
43480
|
-
return
|
|
43540
|
+
return Readable5.toWeb(stream);
|
|
43481
43541
|
}
|
|
43482
43542
|
});
|
|
43483
43543
|
};
|
|
@@ -49248,9 +49308,9 @@ var require_node2json = __commonJS({
|
|
|
49248
49308
|
"../node_modules/.pnpm/fast-xml-parser@4.4.1/node_modules/fast-xml-parser/src/xmlparser/node2json.js"(exports) {
|
|
49249
49309
|
"use strict";
|
|
49250
49310
|
function prettify(node, options) {
|
|
49251
|
-
return
|
|
49311
|
+
return compress3(node, options);
|
|
49252
49312
|
}
|
|
49253
|
-
function
|
|
49313
|
+
function compress3(arr, options, jPath) {
|
|
49254
49314
|
let text;
|
|
49255
49315
|
const compressedObj = {};
|
|
49256
49316
|
for (let i6 = 0; i6 < arr.length; i6++) {
|
|
@@ -49265,7 +49325,7 @@ var require_node2json = __commonJS({
|
|
|
49265
49325
|
} else if (property === void 0) {
|
|
49266
49326
|
continue;
|
|
49267
49327
|
} else if (tagObj[property]) {
|
|
49268
|
-
let val2 =
|
|
49328
|
+
let val2 = compress3(tagObj[property], options, newJpath);
|
|
49269
49329
|
const isLeaf = isLeafTag(val2, options);
|
|
49270
49330
|
if (tagObj[":@"]) {
|
|
49271
49331
|
assignAttributes(val2, tagObj[":@"], newJpath, options);
|
|
@@ -51866,12 +51926,12 @@ var init_omitRetryHeadersMiddleware = __esm({
|
|
|
51866
51926
|
});
|
|
51867
51927
|
|
|
51868
51928
|
// ../node_modules/.pnpm/@smithy+middleware-retry@4.1.10/node_modules/@smithy/middleware-retry/dist-es/isStreamingPayload/isStreamingPayload.js
|
|
51869
|
-
import { Readable as
|
|
51929
|
+
import { Readable as Readable6 } from "stream";
|
|
51870
51930
|
var isStreamingPayload;
|
|
51871
51931
|
var init_isStreamingPayload = __esm({
|
|
51872
51932
|
"../node_modules/.pnpm/@smithy+middleware-retry@4.1.10/node_modules/@smithy/middleware-retry/dist-es/isStreamingPayload/isStreamingPayload.js"() {
|
|
51873
51933
|
"use strict";
|
|
51874
|
-
isStreamingPayload = (request2) => request2?.body instanceof
|
|
51934
|
+
isStreamingPayload = (request2) => request2?.body instanceof Readable6 || typeof ReadableStream !== "undefined" && request2?.body instanceof ReadableStream;
|
|
51875
51935
|
}
|
|
51876
51936
|
});
|
|
51877
51937
|
|
|
@@ -72857,8 +72917,51 @@ var init_connections = __esm({
|
|
|
72857
72917
|
};
|
|
72858
72918
|
return { packageName: "@neondatabase/serverless", query, proxy, transactionProxy, migrate: migrateFn };
|
|
72859
72919
|
}
|
|
72920
|
+
if (await checkPackage("bun")) {
|
|
72921
|
+
console.log(withStyle.info(`Using 'bun' driver for database querying`));
|
|
72922
|
+
const { SQL: SQL5 } = await import("bun");
|
|
72923
|
+
const { drizzle } = await import("drizzle-orm/bun-sql");
|
|
72924
|
+
const { migrate } = await import("drizzle-orm/bun-sql/migrator");
|
|
72925
|
+
const ssl = "ssl" in credentials2 ? credentials2.ssl === "prefer" || credentials2.ssl === "require" || credentials2.ssl === "allow" ? true : false : void 0;
|
|
72926
|
+
const client = new SQL5({
|
|
72927
|
+
adapter: "postgres",
|
|
72928
|
+
...credentials2,
|
|
72929
|
+
ssl,
|
|
72930
|
+
max: 1
|
|
72931
|
+
});
|
|
72932
|
+
const db = drizzle(client);
|
|
72933
|
+
const migrateFn = async (config) => {
|
|
72934
|
+
return migrate(db, config);
|
|
72935
|
+
};
|
|
72936
|
+
const query = async (sql, params) => {
|
|
72937
|
+
const result = await client.unsafe(sql, params ?? []);
|
|
72938
|
+
return result;
|
|
72939
|
+
};
|
|
72940
|
+
const proxy = async (params) => {
|
|
72941
|
+
const query2 = client.unsafe(params.sql, params.params);
|
|
72942
|
+
if (params.mode === "array") {
|
|
72943
|
+
return await query2.values();
|
|
72944
|
+
}
|
|
72945
|
+
return await query2;
|
|
72946
|
+
};
|
|
72947
|
+
const transactionProxy = async (queries) => {
|
|
72948
|
+
const results = [];
|
|
72949
|
+
try {
|
|
72950
|
+
await client.transaction(async (tx) => {
|
|
72951
|
+
for (const query2 of queries) {
|
|
72952
|
+
const result = await tx.unsafe(query2.sql);
|
|
72953
|
+
results.push(result);
|
|
72954
|
+
}
|
|
72955
|
+
});
|
|
72956
|
+
} catch (error2) {
|
|
72957
|
+
results.push(error2);
|
|
72958
|
+
}
|
|
72959
|
+
return results;
|
|
72960
|
+
};
|
|
72961
|
+
return { packageName: "bun", query, proxy, transactionProxy, migrate: migrateFn };
|
|
72962
|
+
}
|
|
72860
72963
|
console.error(
|
|
72861
|
-
"To connect to Postgres database - please install either of 'pg', 'postgres', '@neondatabase/serverless' or '@vercel/postgres' drivers"
|
|
72964
|
+
"To connect to Postgres database - please install either of 'pg', 'postgres', 'bun', '@neondatabase/serverless' or '@vercel/postgres' drivers"
|
|
72862
72965
|
);
|
|
72863
72966
|
process.exit(1);
|
|
72864
72967
|
};
|
|
@@ -73019,6 +73122,7 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
73019
73122
|
connectToMySQL = async (it) => {
|
|
73020
73123
|
const result = parseMysqlCredentials(it);
|
|
73021
73124
|
if (await checkPackage("mysql2")) {
|
|
73125
|
+
console.log(withStyle.info(`Using 'mysql2' driver for database querying`));
|
|
73022
73126
|
const { createConnection } = await import("mysql2/promise");
|
|
73023
73127
|
const { drizzle } = await import("drizzle-orm/mysql2");
|
|
73024
73128
|
const { migrate } = await import("drizzle-orm/mysql2/migrator");
|
|
@@ -73076,6 +73180,7 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
73076
73180
|
};
|
|
73077
73181
|
}
|
|
73078
73182
|
if (await checkPackage("@planetscale/database")) {
|
|
73183
|
+
console.log(withStyle.info(`Using '@planetscale/database' driver for database querying`));
|
|
73079
73184
|
const { Client: Client2 } = await import("@planetscale/database");
|
|
73080
73185
|
const { drizzle } = await import("drizzle-orm/planetscale-serverless");
|
|
73081
73186
|
const { migrate } = await import("drizzle-orm/planetscale-serverless/migrator");
|
|
@@ -73119,8 +73224,57 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
73119
73224
|
migrate: migrateFn
|
|
73120
73225
|
};
|
|
73121
73226
|
}
|
|
73227
|
+
if (await checkPackage("bun")) {
|
|
73228
|
+
console.log(withStyle.info(`Using 'bun' driver for database querying`));
|
|
73229
|
+
const { SQL: SQL5 } = await import("bun");
|
|
73230
|
+
const { drizzle } = await import("drizzle-orm/bun-sql");
|
|
73231
|
+
const { migrate } = await import("drizzle-orm/bun-sql/migrator");
|
|
73232
|
+
const ssl = result.credentials && "ssl" in result.credentials ? result.credentials.ssl === "prefer" || result.credentials.ssl === "require" || result.credentials.ssl === "allow" ? true : false : void 0;
|
|
73233
|
+
const client = result.url ? new SQL5(result.url) : new SQL5({
|
|
73234
|
+
adapter: "mysql",
|
|
73235
|
+
...result.credentials,
|
|
73236
|
+
ssl
|
|
73237
|
+
});
|
|
73238
|
+
const db = drizzle(client);
|
|
73239
|
+
const migrateFn = async (config) => {
|
|
73240
|
+
return migrate(db, config);
|
|
73241
|
+
};
|
|
73242
|
+
const query = async (sql, params) => {
|
|
73243
|
+
const result2 = await client.unsafe(sql, params ?? []);
|
|
73244
|
+
return result2;
|
|
73245
|
+
};
|
|
73246
|
+
const proxy = async (params) => {
|
|
73247
|
+
const query2 = client.unsafe(params.sql, params.params);
|
|
73248
|
+
if (params.mode === "array") {
|
|
73249
|
+
return await query2.values();
|
|
73250
|
+
}
|
|
73251
|
+
return await query2;
|
|
73252
|
+
};
|
|
73253
|
+
const transactionProxy = async (queries) => {
|
|
73254
|
+
const results = [];
|
|
73255
|
+
try {
|
|
73256
|
+
await client.transaction(async (tx) => {
|
|
73257
|
+
for (const query2 of queries) {
|
|
73258
|
+
const result2 = await tx.unsafe(query2.sql);
|
|
73259
|
+
results.push(result2);
|
|
73260
|
+
}
|
|
73261
|
+
});
|
|
73262
|
+
} catch (error2) {
|
|
73263
|
+
results.push(error2);
|
|
73264
|
+
}
|
|
73265
|
+
return results;
|
|
73266
|
+
};
|
|
73267
|
+
return {
|
|
73268
|
+
packageName: "bun",
|
|
73269
|
+
db: { query },
|
|
73270
|
+
proxy,
|
|
73271
|
+
transactionProxy,
|
|
73272
|
+
migrate: migrateFn,
|
|
73273
|
+
database: result.database
|
|
73274
|
+
};
|
|
73275
|
+
}
|
|
73122
73276
|
console.error(
|
|
73123
|
-
"To connect to MySQL database - please install either of 'mysql2' or '@planetscale/database' drivers"
|
|
73277
|
+
"To connect to MySQL database - please install either of 'mysql2', 'bun' or '@planetscale/database' drivers"
|
|
73124
73278
|
);
|
|
73125
73279
|
process.exit(1);
|
|
73126
73280
|
};
|
|
@@ -73207,21 +73361,19 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
73207
73361
|
return migrate(
|
|
73208
73362
|
drzl,
|
|
73209
73363
|
async (queries) => {
|
|
73210
|
-
for (const
|
|
73211
|
-
await remoteCallback(
|
|
73364
|
+
for (const query2 of queries) {
|
|
73365
|
+
await remoteCallback(query2, [], "run");
|
|
73212
73366
|
}
|
|
73213
73367
|
},
|
|
73214
73368
|
config
|
|
73215
73369
|
);
|
|
73216
73370
|
};
|
|
73217
|
-
const
|
|
73218
|
-
|
|
73219
|
-
|
|
73220
|
-
|
|
73221
|
-
|
|
73222
|
-
|
|
73223
|
-
await remoteCallback(query, [], "run");
|
|
73224
|
-
}
|
|
73371
|
+
const query = async (sql, params) => {
|
|
73372
|
+
const res = await remoteCallback(sql, params || [], "all");
|
|
73373
|
+
return res.rows;
|
|
73374
|
+
};
|
|
73375
|
+
const run = async (query2) => {
|
|
73376
|
+
await remoteCallback(query2, [], "run");
|
|
73225
73377
|
};
|
|
73226
73378
|
const proxy = async (params) => {
|
|
73227
73379
|
const preparedParams = prepareSqliteParams(params.params || [], "d1-http");
|
|
@@ -73236,12 +73388,90 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
73236
73388
|
const result = await remoteBatchCallback(queries);
|
|
73237
73389
|
return result.rows;
|
|
73238
73390
|
};
|
|
73239
|
-
return {
|
|
73391
|
+
return { query, run, packageName: "d1-http", proxy, transactionProxy, migrate: migrateFn };
|
|
73392
|
+
} else if (driver2 === "sqlite-cloud") {
|
|
73393
|
+
assertPackages("@sqlitecloud/drivers");
|
|
73394
|
+
const { Database } = await import("@sqlitecloud/drivers");
|
|
73395
|
+
const { drizzle } = await import("drizzle-orm/sqlite-cloud");
|
|
73396
|
+
const { migrate } = await import("drizzle-orm/sqlite-cloud/migrator");
|
|
73397
|
+
const client = new Database(credentials2.url);
|
|
73398
|
+
const drzl = drizzle(client);
|
|
73399
|
+
const migrateFn = async (config) => {
|
|
73400
|
+
return migrate(drzl, config);
|
|
73401
|
+
};
|
|
73402
|
+
const query = async (sql, params) => {
|
|
73403
|
+
const stmt = client.prepare(sql).bind(params || []);
|
|
73404
|
+
return await new Promise((resolve, reject) => {
|
|
73405
|
+
stmt.all((e6, d5) => {
|
|
73406
|
+
if (e6) return reject(e6);
|
|
73407
|
+
return resolve(d5.map((v6) => Object.fromEntries(Object.entries(v6))));
|
|
73408
|
+
});
|
|
73409
|
+
});
|
|
73410
|
+
};
|
|
73411
|
+
const run = async (query2) => {
|
|
73412
|
+
return await new Promise((resolve, reject) => {
|
|
73413
|
+
client.exec(query2, (e6) => {
|
|
73414
|
+
if (e6) return reject(e6);
|
|
73415
|
+
return resolve();
|
|
73416
|
+
});
|
|
73417
|
+
});
|
|
73418
|
+
};
|
|
73419
|
+
const proxy = async (params) => {
|
|
73420
|
+
const preparedParams = prepareSqliteParams(params.params || []);
|
|
73421
|
+
const stmt = client.prepare(params.sql).bind(preparedParams);
|
|
73422
|
+
return await new Promise((resolve, reject) => {
|
|
73423
|
+
stmt.all((e6, d5) => {
|
|
73424
|
+
if (e6) return reject(e6);
|
|
73425
|
+
if (params.mode === "array") {
|
|
73426
|
+
return resolve((d5 || []).map((v6) => v6.getData()));
|
|
73427
|
+
} else {
|
|
73428
|
+
return resolve((d5 || []).map((v6) => Object.fromEntries(Object.entries(v6))));
|
|
73429
|
+
}
|
|
73430
|
+
});
|
|
73431
|
+
});
|
|
73432
|
+
};
|
|
73433
|
+
const transactionProxy = async (queries) => {
|
|
73434
|
+
const results = [];
|
|
73435
|
+
try {
|
|
73436
|
+
await new Promise((resolve, reject) => {
|
|
73437
|
+
client.exec("BEGIN", (e6) => {
|
|
73438
|
+
if (e6) return reject(e6);
|
|
73439
|
+
return resolve();
|
|
73440
|
+
});
|
|
73441
|
+
});
|
|
73442
|
+
for (const query2 of queries) {
|
|
73443
|
+
const result = await new Promise((resolve, reject) => {
|
|
73444
|
+
client.all(query2.sql, (e6, d5) => {
|
|
73445
|
+
if (e6) return reject(e6);
|
|
73446
|
+
return resolve((d5 || []).map((v6) => Object.fromEntries(Object.entries(v6))));
|
|
73447
|
+
});
|
|
73448
|
+
});
|
|
73449
|
+
results.push(result);
|
|
73450
|
+
}
|
|
73451
|
+
await new Promise((resolve, reject) => {
|
|
73452
|
+
client.exec("COMMIT", (e6) => {
|
|
73453
|
+
if (e6) return reject(e6);
|
|
73454
|
+
return resolve();
|
|
73455
|
+
});
|
|
73456
|
+
});
|
|
73457
|
+
} catch (error2) {
|
|
73458
|
+
results.push(error2);
|
|
73459
|
+
await new Promise((resolve, reject) => {
|
|
73460
|
+
client.exec("ROLLBACK", (e6) => {
|
|
73461
|
+
if (e6) return reject(e6);
|
|
73462
|
+
return resolve();
|
|
73463
|
+
});
|
|
73464
|
+
});
|
|
73465
|
+
}
|
|
73466
|
+
return results;
|
|
73467
|
+
};
|
|
73468
|
+
return { query, run, packageName: "@sqlitecloud/drivers", proxy, transactionProxy, migrate: migrateFn };
|
|
73240
73469
|
} else {
|
|
73241
73470
|
assertUnreachable(driver2);
|
|
73242
73471
|
}
|
|
73243
73472
|
}
|
|
73244
73473
|
if (await checkPackage("@libsql/client")) {
|
|
73474
|
+
console.log(withStyle.info(`Using '@libsql/client' driver for database querying`));
|
|
73245
73475
|
const { createClient } = await import("@libsql/client");
|
|
73246
73476
|
const { drizzle } = await import("drizzle-orm/libsql");
|
|
73247
73477
|
const { migrate } = await import("drizzle-orm/libsql/migrator");
|
|
@@ -73252,14 +73482,12 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
73252
73482
|
const migrateFn = async (config) => {
|
|
73253
73483
|
return migrate(drzl, config);
|
|
73254
73484
|
};
|
|
73255
|
-
const
|
|
73256
|
-
|
|
73257
|
-
|
|
73258
|
-
|
|
73259
|
-
|
|
73260
|
-
|
|
73261
|
-
await client.execute(query);
|
|
73262
|
-
}
|
|
73485
|
+
const query = async (sql, params) => {
|
|
73486
|
+
const res = await client.execute({ sql, args: params || [] });
|
|
73487
|
+
return res.rows;
|
|
73488
|
+
};
|
|
73489
|
+
const run = async (query2) => {
|
|
73490
|
+
await client.execute(query2);
|
|
73263
73491
|
};
|
|
73264
73492
|
const proxy = async (params) => {
|
|
73265
73493
|
const preparedParams = prepareSqliteParams(params.params || []);
|
|
@@ -73278,8 +73506,8 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
73278
73506
|
let transaction = null;
|
|
73279
73507
|
try {
|
|
73280
73508
|
transaction = await client.transaction();
|
|
73281
|
-
for (const
|
|
73282
|
-
const result = await transaction.execute(
|
|
73509
|
+
for (const query2 of queries) {
|
|
73510
|
+
const result = await transaction.execute(query2.sql);
|
|
73283
73511
|
results.push(result.rows);
|
|
73284
73512
|
}
|
|
73285
73513
|
await transaction.commit();
|
|
@@ -73291,9 +73519,10 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
73291
73519
|
}
|
|
73292
73520
|
return results;
|
|
73293
73521
|
};
|
|
73294
|
-
return {
|
|
73522
|
+
return { query, run, packageName: "@libsql/client", proxy, transactionProxy, migrate: migrateFn };
|
|
73295
73523
|
}
|
|
73296
73524
|
if (await checkPackage("better-sqlite3")) {
|
|
73525
|
+
console.log(withStyle.info(`Using 'better-sqlite3' driver for database querying`));
|
|
73297
73526
|
const { default: Database } = await import("better-sqlite3");
|
|
73298
73527
|
const { drizzle } = await import("drizzle-orm/better-sqlite3");
|
|
73299
73528
|
const { migrate } = await import("drizzle-orm/better-sqlite3/migrator");
|
|
@@ -73304,13 +73533,11 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
73304
73533
|
const migrateFn = async (config) => {
|
|
73305
73534
|
return migrate(drzl, config);
|
|
73306
73535
|
};
|
|
73307
|
-
const
|
|
73308
|
-
|
|
73309
|
-
|
|
73310
|
-
|
|
73311
|
-
run
|
|
73312
|
-
sqlite.prepare(query).run();
|
|
73313
|
-
}
|
|
73536
|
+
const query = async (sql, params = []) => {
|
|
73537
|
+
return sqlite.prepare(sql).bind(params).all();
|
|
73538
|
+
};
|
|
73539
|
+
const run = async (query2) => {
|
|
73540
|
+
sqlite.prepare(query2).run();
|
|
73314
73541
|
};
|
|
73315
73542
|
const proxy = async (params) => {
|
|
73316
73543
|
const preparedParams = prepareSqliteParams(params.params || []);
|
|
@@ -73323,12 +73550,12 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
73323
73550
|
const transactionProxy = async (queries) => {
|
|
73324
73551
|
const results = [];
|
|
73325
73552
|
const tx = sqlite.transaction((queries2) => {
|
|
73326
|
-
for (const
|
|
73553
|
+
for (const query2 of queries2) {
|
|
73327
73554
|
let result = [];
|
|
73328
|
-
if (
|
|
73329
|
-
result = sqlite.prepare(
|
|
73555
|
+
if (query2.method === "values" || query2.method === "get" || query2.method === "all") {
|
|
73556
|
+
result = sqlite.prepare(query2.sql).all();
|
|
73330
73557
|
} else {
|
|
73331
|
-
sqlite.prepare(
|
|
73558
|
+
sqlite.prepare(query2.sql).run();
|
|
73332
73559
|
}
|
|
73333
73560
|
results.push(result);
|
|
73334
73561
|
}
|
|
@@ -73340,10 +73567,60 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
73340
73567
|
}
|
|
73341
73568
|
return results;
|
|
73342
73569
|
};
|
|
73343
|
-
return {
|
|
73570
|
+
return { query, run, packageName: "better-sqlite3", proxy, transactionProxy, migrate: migrateFn };
|
|
73571
|
+
}
|
|
73572
|
+
if (await checkPackage("bun")) {
|
|
73573
|
+
console.log(withStyle.info(`Using 'bun' driver for database querying`));
|
|
73574
|
+
const { SQL: SQL5 } = await import("bun");
|
|
73575
|
+
const { drizzle } = await import("drizzle-orm/bun-sql");
|
|
73576
|
+
const { migrate } = await import("drizzle-orm/bun-sql/migrator");
|
|
73577
|
+
const client = new SQL5({
|
|
73578
|
+
adapter: "sqlite",
|
|
73579
|
+
filename: normaliseSQLiteUrl(credentials2.url, "bun")
|
|
73580
|
+
});
|
|
73581
|
+
const db = drizzle(client);
|
|
73582
|
+
const migrateFn = async (config) => {
|
|
73583
|
+
return migrate(db, config);
|
|
73584
|
+
};
|
|
73585
|
+
const query = async (sql, params) => {
|
|
73586
|
+
const result = await client.unsafe(sql, params ?? []);
|
|
73587
|
+
return result;
|
|
73588
|
+
};
|
|
73589
|
+
const run = async (sql) => {
|
|
73590
|
+
await client.unsafe(sql);
|
|
73591
|
+
};
|
|
73592
|
+
const proxy = async (params) => {
|
|
73593
|
+
const query2 = client.unsafe(params.sql, params.params);
|
|
73594
|
+
if (params.mode === "array") {
|
|
73595
|
+
return await query2.values();
|
|
73596
|
+
}
|
|
73597
|
+
return await query2;
|
|
73598
|
+
};
|
|
73599
|
+
const transactionProxy = async (queries) => {
|
|
73600
|
+
const results = [];
|
|
73601
|
+
try {
|
|
73602
|
+
await client.transaction(async (tx) => {
|
|
73603
|
+
for (const query2 of queries) {
|
|
73604
|
+
const result = await tx.unsafe(query2.sql);
|
|
73605
|
+
results.push(result);
|
|
73606
|
+
}
|
|
73607
|
+
});
|
|
73608
|
+
} catch (error2) {
|
|
73609
|
+
results.push(error2);
|
|
73610
|
+
}
|
|
73611
|
+
return results;
|
|
73612
|
+
};
|
|
73613
|
+
return {
|
|
73614
|
+
packageName: "bun",
|
|
73615
|
+
query,
|
|
73616
|
+
run,
|
|
73617
|
+
proxy,
|
|
73618
|
+
transactionProxy,
|
|
73619
|
+
migrate: migrateFn
|
|
73620
|
+
};
|
|
73344
73621
|
}
|
|
73345
73622
|
console.log(
|
|
73346
|
-
"Please install either 'better-sqlite3'
|
|
73623
|
+
"Please install either 'better-sqlite3', '@libsql/client' or 'bun' for Drizzle Kit to connect to SQLite databases"
|
|
73347
73624
|
);
|
|
73348
73625
|
process.exit(1);
|
|
73349
73626
|
};
|
|
@@ -73453,7 +73730,7 @@ var init_studio2 = __esm({
|
|
|
73453
73730
|
init_dist();
|
|
73454
73731
|
init_esm2();
|
|
73455
73732
|
init_dist2();
|
|
73456
|
-
|
|
73733
|
+
init_dist3();
|
|
73457
73734
|
init_cors();
|
|
73458
73735
|
init_global();
|
|
73459
73736
|
init_esm();
|
|
@@ -73671,6 +73948,8 @@ var init_studio2 = __esm({
|
|
|
73671
73948
|
const { driver: driver2 } = credentials2;
|
|
73672
73949
|
if (driver2 === "d1-http") {
|
|
73673
73950
|
dbUrl = `d1-http://${credentials2.accountId}/${credentials2.databaseId}/${credentials2.token}`;
|
|
73951
|
+
} else if (driver2 === "sqlite-cloud") {
|
|
73952
|
+
dbUrl = credentials2.url;
|
|
73674
73953
|
} else {
|
|
73675
73954
|
assertUnreachable(driver2);
|
|
73676
73955
|
}
|
|
@@ -73869,7 +74148,7 @@ var init_studio2 = __esm({
|
|
|
73869
74148
|
schemaFiles
|
|
73870
74149
|
}, app) => {
|
|
73871
74150
|
app = app !== void 0 ? app : new Hono2();
|
|
73872
|
-
app.use(
|
|
74151
|
+
app.use(compress2());
|
|
73873
74152
|
app.use(async (ctx, next) => {
|
|
73874
74153
|
await next();
|
|
73875
74154
|
ctx.header("Access-Control-Allow-Private-Network", "true");
|