tempest.games 0.2.9 → 0.2.11
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/CHANGELOG.md +12 -0
- package/app/assets/index-BG6T8CzE.js +109 -0
- package/app/assets/index-ki_mruCb.css +1 -0
- package/app/index.html +2 -2
- package/bin/backend.bun.js +249 -244
- package/bin/backend.worker.tribunal.bun.js +86 -85
- package/bin/frontend.bun.js +31 -30
- package/bin/setup-db.bun.js +402 -222
- package/package.json +18 -18
- package/app/assets/index-B2F2ZwG-.css +0 -1
- package/app/assets/index-D-81-7hL.js +0 -109
package/bin/setup-db.bun.js
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
import * as os2 from "os";
|
|
6
6
|
import { resolve } from "path";
|
|
7
7
|
|
|
8
|
-
// ../../node_modules/.pnpm/postgres@3.4.
|
|
8
|
+
// ../../node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/src/index.js
|
|
9
9
|
import os from "os";
|
|
10
10
|
import fs from "fs";
|
|
11
11
|
|
|
12
|
-
// ../../node_modules/.pnpm/postgres@3.4.
|
|
12
|
+
// ../../node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/src/query.js
|
|
13
13
|
var originCache = new Map;
|
|
14
14
|
var originStackCache = new Map;
|
|
15
15
|
var originError = Symbol("OriginError");
|
|
@@ -147,7 +147,7 @@ function cachedError(xs) {
|
|
|
147
147
|
return originCache.get(xs);
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
// ../../node_modules/.pnpm/postgres@3.4.
|
|
150
|
+
// ../../node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/src/errors.js
|
|
151
151
|
class PostgresError extends Error {
|
|
152
152
|
constructor(x) {
|
|
153
153
|
super(x.message);
|
|
@@ -190,7 +190,7 @@ function notSupported(x) {
|
|
|
190
190
|
return error;
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
// ../../node_modules/.pnpm/postgres@3.4.
|
|
193
|
+
// ../../node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/src/types.js
|
|
194
194
|
var types = {
|
|
195
195
|
string: {
|
|
196
196
|
to: 25,
|
|
@@ -471,14 +471,14 @@ fromKebab.column = { to: fromKebab };
|
|
|
471
471
|
var kebab = { ...toKebab };
|
|
472
472
|
kebab.column.to = fromKebab;
|
|
473
473
|
|
|
474
|
-
// ../../node_modules/.pnpm/postgres@3.4.
|
|
474
|
+
// ../../node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/src/connection.js
|
|
475
475
|
import net from "net";
|
|
476
476
|
import tls from "tls";
|
|
477
|
-
import
|
|
477
|
+
import crypto2 from "crypto";
|
|
478
478
|
import Stream from "stream";
|
|
479
479
|
import { performance } from "perf_hooks";
|
|
480
480
|
|
|
481
|
-
// ../../node_modules/.pnpm/postgres@3.4.
|
|
481
|
+
// ../../node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/src/result.js
|
|
482
482
|
class Result extends Array {
|
|
483
483
|
constructor() {
|
|
484
484
|
super();
|
|
@@ -495,7 +495,7 @@ class Result extends Array {
|
|
|
495
495
|
}
|
|
496
496
|
}
|
|
497
497
|
|
|
498
|
-
// ../../node_modules/.pnpm/postgres@3.4.
|
|
498
|
+
// ../../node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/src/queue.js
|
|
499
499
|
var queue_default = Queue;
|
|
500
500
|
function Queue(initial = []) {
|
|
501
501
|
let xs = initial.slice();
|
|
@@ -522,7 +522,7 @@ function Queue(initial = []) {
|
|
|
522
522
|
};
|
|
523
523
|
}
|
|
524
524
|
|
|
525
|
-
// ../../node_modules/.pnpm/postgres@3.4.
|
|
525
|
+
// ../../node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/src/bytes.js
|
|
526
526
|
var size = 256;
|
|
527
527
|
var buffer = Buffer.allocUnsafe(size);
|
|
528
528
|
var messages = "BCcDdEFfHPpQSX".split("").reduce((acc, x) => {
|
|
@@ -595,7 +595,7 @@ function reset() {
|
|
|
595
595
|
return b;
|
|
596
596
|
}
|
|
597
597
|
|
|
598
|
-
// ../../node_modules/.pnpm/postgres@3.4.
|
|
598
|
+
// ../../node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/src/connection.js
|
|
599
599
|
var connection_default = Connection;
|
|
600
600
|
var uid = 1;
|
|
601
601
|
var Sync = bytes_default().S().end();
|
|
@@ -653,7 +653,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
653
653
|
queue: queues.closed,
|
|
654
654
|
idleTimer,
|
|
655
655
|
connect(query2) {
|
|
656
|
-
initial = query2
|
|
656
|
+
initial = query2;
|
|
657
657
|
reconnect();
|
|
658
658
|
},
|
|
659
659
|
terminate,
|
|
@@ -782,7 +782,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
782
782
|
if (incomings) {
|
|
783
783
|
incomings.push(x);
|
|
784
784
|
remaining -= x.length;
|
|
785
|
-
if (remaining
|
|
785
|
+
if (remaining > 0)
|
|
786
786
|
return;
|
|
787
787
|
}
|
|
788
788
|
incoming = incomings ? Buffer.concat(incomings, length - remaining) : incoming.length === 0 ? x : Buffer.concat([incoming, x], incoming.length + x.length);
|
|
@@ -853,6 +853,10 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
853
853
|
initial && (queryError(initial, err), initial = null);
|
|
854
854
|
}
|
|
855
855
|
function queryError(query2, err) {
|
|
856
|
+
if (query2.reserve)
|
|
857
|
+
return query2.reject(err);
|
|
858
|
+
if (!err || typeof err !== "object")
|
|
859
|
+
err = new Error(err);
|
|
856
860
|
"query" in err || "parameters" in err || Object.defineProperties(err, {
|
|
857
861
|
stack: { value: err.stack + query2.origin.replace(/.*\n/, `
|
|
858
862
|
`), enumerable: options.debug },
|
|
@@ -937,10 +941,10 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
937
941
|
return terminate();
|
|
938
942
|
}
|
|
939
943
|
if (needsTypes) {
|
|
940
|
-
initial
|
|
944
|
+
initial.reserve && (initial = null);
|
|
941
945
|
return fetchArrayTypes();
|
|
942
946
|
}
|
|
943
|
-
initial
|
|
947
|
+
initial && !initial.reserve && execute(initial);
|
|
944
948
|
options.shared.retries = retries = 0;
|
|
945
949
|
initial = null;
|
|
946
950
|
return;
|
|
@@ -1033,14 +1037,14 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
1033
1037
|
write(bytes_default().p().str(payload).z(1).end());
|
|
1034
1038
|
}
|
|
1035
1039
|
async function SASL() {
|
|
1036
|
-
nonce = (await
|
|
1040
|
+
nonce = (await crypto2.randomBytes(18)).toString("base64");
|
|
1037
1041
|
bytes_default().p().str("SCRAM-SHA-256" + bytes_default.N);
|
|
1038
1042
|
const i = bytes_default.i;
|
|
1039
1043
|
write(bytes_default.inc(4).str("n,,n=*,r=" + nonce).i32(bytes_default.i - i - 4, i).end());
|
|
1040
1044
|
}
|
|
1041
1045
|
async function SASLContinue(x) {
|
|
1042
1046
|
const res = x.toString("utf8", 9).split(",").reduce((acc, x2) => (acc[x2[0]] = x2.slice(2), acc), {});
|
|
1043
|
-
const saltedPassword = await
|
|
1047
|
+
const saltedPassword = await crypto2.pbkdf2Sync(await Pass(), Buffer.from(res.s, "base64"), parseInt(res.i), 32, "sha256");
|
|
1044
1048
|
const clientKey = await hmac(saltedPassword, "Client Key");
|
|
1045
1049
|
const auth = "n=*,r=" + nonce + "," + "r=" + res.r + ",s=" + res.s + ",i=" + res.i + ",c=biws,r=" + res.r;
|
|
1046
1050
|
serverSignature = (await hmac(await hmac(saltedPassword, "Server Key"), auth)).toString("base64");
|
|
@@ -1257,13 +1261,13 @@ function parseError(x) {
|
|
|
1257
1261
|
return error;
|
|
1258
1262
|
}
|
|
1259
1263
|
function md5(x) {
|
|
1260
|
-
return
|
|
1264
|
+
return crypto2.createHash("md5").update(x).digest("hex");
|
|
1261
1265
|
}
|
|
1262
1266
|
function hmac(key, x) {
|
|
1263
|
-
return
|
|
1267
|
+
return crypto2.createHmac("sha256", key).update(x).digest();
|
|
1264
1268
|
}
|
|
1265
1269
|
function sha256(x) {
|
|
1266
|
-
return
|
|
1270
|
+
return crypto2.createHash("sha256").update(x).digest();
|
|
1267
1271
|
}
|
|
1268
1272
|
function xor(a, b2) {
|
|
1269
1273
|
const length = Math.max(a.length, b2.length);
|
|
@@ -1292,7 +1296,7 @@ function timer(fn, seconds) {
|
|
|
1292
1296
|
}
|
|
1293
1297
|
}
|
|
1294
1298
|
|
|
1295
|
-
// ../../node_modules/.pnpm/postgres@3.4.
|
|
1299
|
+
// ../../node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/src/subscribe.js
|
|
1296
1300
|
var noop2 = () => {};
|
|
1297
1301
|
function Subscribe(postgres2, options) {
|
|
1298
1302
|
const subscribers = new Map, slot = "postgresjs_" + Math.random().toString(36).slice(2), state = {};
|
|
@@ -1488,7 +1492,7 @@ function parseEvent(x) {
|
|
|
1488
1492
|
return (command || "*") + (path ? ":" + (path.indexOf(".") === -1 ? "public." + path : path) : "") + (key ? "=" + key : "");
|
|
1489
1493
|
}
|
|
1490
1494
|
|
|
1491
|
-
// ../../node_modules/.pnpm/postgres@3.4.
|
|
1495
|
+
// ../../node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/src/large.js
|
|
1492
1496
|
import Stream2 from "stream";
|
|
1493
1497
|
function largeObject(sql, oid, mode = 131072 | 262144) {
|
|
1494
1498
|
return new Promise(async (resolve, reject) => {
|
|
@@ -1554,7 +1558,7 @@ function largeObject(sql, oid, mode = 131072 | 262144) {
|
|
|
1554
1558
|
});
|
|
1555
1559
|
}
|
|
1556
1560
|
|
|
1557
|
-
// ../../node_modules/.pnpm/postgres@3.4.
|
|
1561
|
+
// ../../node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/src/index.js
|
|
1558
1562
|
Object.assign(Postgres, {
|
|
1559
1563
|
PostgresError,
|
|
1560
1564
|
toPascal,
|
|
@@ -1689,9 +1693,10 @@ function Postgres(a, b2) {
|
|
|
1689
1693
|
}
|
|
1690
1694
|
async function reserve() {
|
|
1691
1695
|
const queue = queue_default();
|
|
1692
|
-
const c = open.length ? open.shift() : await new Promise((
|
|
1693
|
-
|
|
1694
|
-
|
|
1696
|
+
const c = open.length ? open.shift() : await new Promise((resolve, reject) => {
|
|
1697
|
+
const query = { reserve: resolve, reject };
|
|
1698
|
+
queries.push(query);
|
|
1699
|
+
closed.length && connect(closed.shift(), query);
|
|
1695
1700
|
});
|
|
1696
1701
|
move(c, reserved);
|
|
1697
1702
|
c.reserved = () => queue.length ? c.execute(queue.shift()) : move(c, reserved);
|
|
@@ -1873,7 +1878,7 @@ function parseOptions(a, b2) {
|
|
|
1873
1878
|
return acc;
|
|
1874
1879
|
}, {}),
|
|
1875
1880
|
connection: {
|
|
1876
|
-
application_name: "postgres.js",
|
|
1881
|
+
application_name: env.PGAPPNAME || "postgres.js",
|
|
1877
1882
|
...o.connection,
|
|
1878
1883
|
...Object.entries(query).reduce((acc, [k, v]) => ((k in defaults) || (acc[k] = v), acc), {})
|
|
1879
1884
|
},
|
|
@@ -1947,7 +1952,7 @@ function osUsername() {
|
|
|
1947
1952
|
}
|
|
1948
1953
|
}
|
|
1949
1954
|
|
|
1950
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
1955
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/entity.js
|
|
1951
1956
|
var entityKind = Symbol.for("drizzle:entityKind");
|
|
1952
1957
|
var hasOwnEntityKind = Symbol.for("drizzle:hasOwnEntityKind");
|
|
1953
1958
|
function is(value, type) {
|
|
@@ -1972,7 +1977,7 @@ function is(value, type) {
|
|
|
1972
1977
|
return false;
|
|
1973
1978
|
}
|
|
1974
1979
|
|
|
1975
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
1980
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/logger.js
|
|
1976
1981
|
class ConsoleLogWriter {
|
|
1977
1982
|
static [entityKind] = "ConsoleLogWriter";
|
|
1978
1983
|
write(message) {
|
|
@@ -2004,7 +2009,7 @@ class NoopLogger {
|
|
|
2004
2009
|
logQuery() {}
|
|
2005
2010
|
}
|
|
2006
2011
|
|
|
2007
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
2012
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/query-promise.js
|
|
2008
2013
|
class QueryPromise {
|
|
2009
2014
|
static [entityKind] = "QueryPromise";
|
|
2010
2015
|
[Symbol.toStringTag] = "QueryPromise";
|
|
@@ -2025,7 +2030,7 @@ class QueryPromise {
|
|
|
2025
2030
|
}
|
|
2026
2031
|
}
|
|
2027
2032
|
|
|
2028
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
2033
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/column.js
|
|
2029
2034
|
class Column {
|
|
2030
2035
|
constructor(table, config) {
|
|
2031
2036
|
this.table = table;
|
|
@@ -2075,20 +2080,20 @@ class Column {
|
|
|
2075
2080
|
}
|
|
2076
2081
|
}
|
|
2077
2082
|
|
|
2078
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
2083
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/table.utils.js
|
|
2079
2084
|
var TableName = Symbol.for("drizzle:Name");
|
|
2080
2085
|
|
|
2081
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
2086
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/tracing-utils.js
|
|
2082
2087
|
function iife(fn, ...args) {
|
|
2083
2088
|
return fn(...args);
|
|
2084
2089
|
}
|
|
2085
2090
|
|
|
2086
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
2091
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/pg-core/unique-constraint.js
|
|
2087
2092
|
function uniqueKeyName(table, columns) {
|
|
2088
2093
|
return `${table[TableName]}_${columns.join("_")}_unique`;
|
|
2089
2094
|
}
|
|
2090
2095
|
|
|
2091
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
2096
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/pg-core/columns/common.js
|
|
2092
2097
|
class PgColumn extends Column {
|
|
2093
2098
|
constructor(table, config) {
|
|
2094
2099
|
if (!config.uniqueName) {
|
|
@@ -2137,7 +2142,7 @@ class ExtraConfigColumn extends PgColumn {
|
|
|
2137
2142
|
}
|
|
2138
2143
|
}
|
|
2139
2144
|
|
|
2140
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
2145
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/pg-core/columns/enum.js
|
|
2141
2146
|
class PgEnumObjectColumn extends PgColumn {
|
|
2142
2147
|
static [entityKind] = "PgEnumObjectColumn";
|
|
2143
2148
|
enum;
|
|
@@ -2167,16 +2172,17 @@ class PgEnumColumn extends PgColumn {
|
|
|
2167
2172
|
}
|
|
2168
2173
|
}
|
|
2169
2174
|
|
|
2170
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
2175
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/subquery.js
|
|
2171
2176
|
class Subquery {
|
|
2172
2177
|
static [entityKind] = "Subquery";
|
|
2173
|
-
constructor(sql,
|
|
2178
|
+
constructor(sql, fields, alias, isWith = false, usedTables = []) {
|
|
2174
2179
|
this._ = {
|
|
2175
2180
|
brand: "Subquery",
|
|
2176
2181
|
sql,
|
|
2177
|
-
selectedFields:
|
|
2182
|
+
selectedFields: fields,
|
|
2178
2183
|
alias,
|
|
2179
|
-
isWith
|
|
2184
|
+
isWith,
|
|
2185
|
+
usedTables
|
|
2180
2186
|
};
|
|
2181
2187
|
}
|
|
2182
2188
|
}
|
|
@@ -2185,10 +2191,10 @@ class WithSubquery extends Subquery {
|
|
|
2185
2191
|
static [entityKind] = "WithSubquery";
|
|
2186
2192
|
}
|
|
2187
2193
|
|
|
2188
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
2189
|
-
var version = "0.
|
|
2194
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/version.js
|
|
2195
|
+
var version = "0.44.0";
|
|
2190
2196
|
|
|
2191
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
2197
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/tracing.js
|
|
2192
2198
|
var otel;
|
|
2193
2199
|
var rawTracer;
|
|
2194
2200
|
var tracer = {
|
|
@@ -2215,10 +2221,10 @@ var tracer = {
|
|
|
2215
2221
|
}
|
|
2216
2222
|
};
|
|
2217
2223
|
|
|
2218
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
2224
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/view-common.js
|
|
2219
2225
|
var ViewBaseConfig = Symbol.for("drizzle:ViewBaseConfig");
|
|
2220
2226
|
|
|
2221
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
2227
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/table.js
|
|
2222
2228
|
var Schema = Symbol.for("drizzle:Schema");
|
|
2223
2229
|
var Columns = Symbol.for("drizzle:Columns");
|
|
2224
2230
|
var ExtraConfigColumns = Symbol.for("drizzle:ExtraConfigColumns");
|
|
@@ -2262,7 +2268,7 @@ function getTableUniqueName(table) {
|
|
|
2262
2268
|
return `${table[Schema] ?? "public"}.${table[TableName]}`;
|
|
2263
2269
|
}
|
|
2264
2270
|
|
|
2265
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
2271
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/sql/sql.js
|
|
2266
2272
|
function isSQLWrapper(value) {
|
|
2267
2273
|
return value !== null && value !== undefined && typeof value.getSQL === "function";
|
|
2268
2274
|
}
|
|
@@ -2295,10 +2301,17 @@ class StringChunk {
|
|
|
2295
2301
|
class SQL {
|
|
2296
2302
|
constructor(queryChunks) {
|
|
2297
2303
|
this.queryChunks = queryChunks;
|
|
2304
|
+
for (const chunk of queryChunks) {
|
|
2305
|
+
if (is(chunk, Table)) {
|
|
2306
|
+
const schemaName = chunk[Table.Symbol.Schema];
|
|
2307
|
+
this.usedTables.push(schemaName === undefined ? chunk[Table.Symbol.Name] : schemaName + "." + chunk[Table.Symbol.Name]);
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2298
2310
|
}
|
|
2299
2311
|
static [entityKind] = "SQL";
|
|
2300
2312
|
decoder = noopDecoder;
|
|
2301
2313
|
shouldInlineParams = false;
|
|
2314
|
+
usedTables = [];
|
|
2302
2315
|
append(query) {
|
|
2303
2316
|
this.queryChunks.push(...query.queryChunks);
|
|
2304
2317
|
return this;
|
|
@@ -2635,7 +2648,7 @@ Subquery.prototype.getSQL = function() {
|
|
|
2635
2648
|
return new SQL([this]);
|
|
2636
2649
|
};
|
|
2637
2650
|
|
|
2638
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
2651
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/alias.js
|
|
2639
2652
|
class ColumnAliasProxyHandler {
|
|
2640
2653
|
constructor(table) {
|
|
2641
2654
|
this.table = table;
|
|
@@ -2714,7 +2727,7 @@ function mapColumnsInSQLToAlias(query, alias) {
|
|
|
2714
2727
|
}));
|
|
2715
2728
|
}
|
|
2716
2729
|
|
|
2717
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
2730
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/selection-proxy.js
|
|
2718
2731
|
class SelectionProxyHandler {
|
|
2719
2732
|
static [entityKind] = "SelectionProxyHandler";
|
|
2720
2733
|
config;
|
|
@@ -2766,7 +2779,7 @@ class SelectionProxyHandler {
|
|
|
2766
2779
|
}
|
|
2767
2780
|
}
|
|
2768
2781
|
|
|
2769
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
2782
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/utils.js
|
|
2770
2783
|
function mapResultRow(columns, row, joinsNotNullableMap) {
|
|
2771
2784
|
const nullifyMap = {};
|
|
2772
2785
|
const result = columns.reduce((result2, { path, field }, columnIndex) => {
|
|
@@ -2911,133 +2924,7 @@ function isConfig(data) {
|
|
|
2911
2924
|
return false;
|
|
2912
2925
|
}
|
|
2913
2926
|
|
|
2914
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
2915
|
-
class PgDeleteBase extends QueryPromise {
|
|
2916
|
-
constructor(table, session, dialect, withList) {
|
|
2917
|
-
super();
|
|
2918
|
-
this.session = session;
|
|
2919
|
-
this.dialect = dialect;
|
|
2920
|
-
this.config = { table, withList };
|
|
2921
|
-
}
|
|
2922
|
-
static [entityKind] = "PgDelete";
|
|
2923
|
-
config;
|
|
2924
|
-
where(where) {
|
|
2925
|
-
this.config.where = where;
|
|
2926
|
-
return this;
|
|
2927
|
-
}
|
|
2928
|
-
returning(fields = this.config.table[Table.Symbol.Columns]) {
|
|
2929
|
-
this.config.returningFields = fields;
|
|
2930
|
-
this.config.returning = orderSelectedFields(fields);
|
|
2931
|
-
return this;
|
|
2932
|
-
}
|
|
2933
|
-
getSQL() {
|
|
2934
|
-
return this.dialect.buildDeleteQuery(this.config);
|
|
2935
|
-
}
|
|
2936
|
-
toSQL() {
|
|
2937
|
-
const { typings: _typings, ...rest } = this.dialect.sqlToQuery(this.getSQL());
|
|
2938
|
-
return rest;
|
|
2939
|
-
}
|
|
2940
|
-
_prepare(name) {
|
|
2941
|
-
return tracer.startActiveSpan("drizzle.prepareQuery", () => {
|
|
2942
|
-
return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()), this.config.returning, name, true);
|
|
2943
|
-
});
|
|
2944
|
-
}
|
|
2945
|
-
prepare(name) {
|
|
2946
|
-
return this._prepare(name);
|
|
2947
|
-
}
|
|
2948
|
-
authToken;
|
|
2949
|
-
setToken(token) {
|
|
2950
|
-
this.authToken = token;
|
|
2951
|
-
return this;
|
|
2952
|
-
}
|
|
2953
|
-
execute = (placeholderValues) => {
|
|
2954
|
-
return tracer.startActiveSpan("drizzle.operation", () => {
|
|
2955
|
-
return this._prepare().execute(placeholderValues, this.authToken);
|
|
2956
|
-
});
|
|
2957
|
-
};
|
|
2958
|
-
getSelectedFields() {
|
|
2959
|
-
return this.config.returningFields ? new Proxy(this.config.returningFields, new SelectionProxyHandler({
|
|
2960
|
-
alias: getTableName(this.config.table),
|
|
2961
|
-
sqlAliasedBehavior: "alias",
|
|
2962
|
-
sqlBehavior: "error"
|
|
2963
|
-
})) : undefined;
|
|
2964
|
-
}
|
|
2965
|
-
$dynamic() {
|
|
2966
|
-
return this;
|
|
2967
|
-
}
|
|
2968
|
-
}
|
|
2969
|
-
|
|
2970
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.13_postgres@3.4.5/node_modules/drizzle-orm/casing.js
|
|
2971
|
-
function toSnakeCase(input) {
|
|
2972
|
-
const words = input.replace(/['\u2019]/g, "").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g) ?? [];
|
|
2973
|
-
return words.map((word) => word.toLowerCase()).join("_");
|
|
2974
|
-
}
|
|
2975
|
-
function toCamelCase(input) {
|
|
2976
|
-
const words = input.replace(/['\u2019]/g, "").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g) ?? [];
|
|
2977
|
-
return words.reduce((acc, word, i) => {
|
|
2978
|
-
const formattedWord = i === 0 ? word.toLowerCase() : `${word[0].toUpperCase()}${word.slice(1)}`;
|
|
2979
|
-
return acc + formattedWord;
|
|
2980
|
-
}, "");
|
|
2981
|
-
}
|
|
2982
|
-
function noopCase(input) {
|
|
2983
|
-
return input;
|
|
2984
|
-
}
|
|
2985
|
-
|
|
2986
|
-
class CasingCache {
|
|
2987
|
-
static [entityKind] = "CasingCache";
|
|
2988
|
-
cache = {};
|
|
2989
|
-
cachedTables = {};
|
|
2990
|
-
convert;
|
|
2991
|
-
constructor(casing) {
|
|
2992
|
-
this.convert = casing === "snake_case" ? toSnakeCase : casing === "camelCase" ? toCamelCase : noopCase;
|
|
2993
|
-
}
|
|
2994
|
-
getColumnCasing(column) {
|
|
2995
|
-
if (!column.keyAsName)
|
|
2996
|
-
return column.name;
|
|
2997
|
-
const schema = column.table[Table.Symbol.Schema] ?? "public";
|
|
2998
|
-
const tableName = column.table[Table.Symbol.OriginalName];
|
|
2999
|
-
const key = `${schema}.${tableName}.${column.name}`;
|
|
3000
|
-
if (!this.cache[key]) {
|
|
3001
|
-
this.cacheTable(column.table);
|
|
3002
|
-
}
|
|
3003
|
-
return this.cache[key];
|
|
3004
|
-
}
|
|
3005
|
-
cacheTable(table) {
|
|
3006
|
-
const schema = table[Table.Symbol.Schema] ?? "public";
|
|
3007
|
-
const tableName = table[Table.Symbol.OriginalName];
|
|
3008
|
-
const tableKey = `${schema}.${tableName}`;
|
|
3009
|
-
if (!this.cachedTables[tableKey]) {
|
|
3010
|
-
for (const column of Object.values(table[Table.Symbol.Columns])) {
|
|
3011
|
-
const columnKey = `${tableKey}.${column.name}`;
|
|
3012
|
-
this.cache[columnKey] = this.convert(column.name);
|
|
3013
|
-
}
|
|
3014
|
-
this.cachedTables[tableKey] = true;
|
|
3015
|
-
}
|
|
3016
|
-
}
|
|
3017
|
-
clearCache() {
|
|
3018
|
-
this.cache = {};
|
|
3019
|
-
this.cachedTables = {};
|
|
3020
|
-
}
|
|
3021
|
-
}
|
|
3022
|
-
|
|
3023
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.13_postgres@3.4.5/node_modules/drizzle-orm/errors.js
|
|
3024
|
-
class DrizzleError extends Error {
|
|
3025
|
-
static [entityKind] = "DrizzleError";
|
|
3026
|
-
constructor({ message, cause }) {
|
|
3027
|
-
super(message);
|
|
3028
|
-
this.name = "DrizzleError";
|
|
3029
|
-
this.cause = cause;
|
|
3030
|
-
}
|
|
3031
|
-
}
|
|
3032
|
-
|
|
3033
|
-
class TransactionRollbackError extends DrizzleError {
|
|
3034
|
-
static [entityKind] = "TransactionRollbackError";
|
|
3035
|
-
constructor() {
|
|
3036
|
-
super({ message: "Rollback" });
|
|
3037
|
-
}
|
|
3038
|
-
}
|
|
3039
|
-
|
|
3040
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.13_postgres@3.4.5/node_modules/drizzle-orm/pg-core/columns/date.js
|
|
2927
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/pg-core/columns/date.js
|
|
3041
2928
|
class PgDate extends PgColumn {
|
|
3042
2929
|
static [entityKind] = "PgDate";
|
|
3043
2930
|
getSQLType() {
|
|
@@ -3057,7 +2944,7 @@ class PgDateString extends PgColumn {
|
|
|
3057
2944
|
}
|
|
3058
2945
|
}
|
|
3059
2946
|
|
|
3060
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
2947
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/pg-core/columns/json.js
|
|
3061
2948
|
class PgJson extends PgColumn {
|
|
3062
2949
|
static [entityKind] = "PgJson";
|
|
3063
2950
|
constructor(table, config) {
|
|
@@ -3081,7 +2968,7 @@ class PgJson extends PgColumn {
|
|
|
3081
2968
|
}
|
|
3082
2969
|
}
|
|
3083
2970
|
|
|
3084
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
2971
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/pg-core/columns/jsonb.js
|
|
3085
2972
|
class PgJsonb extends PgColumn {
|
|
3086
2973
|
static [entityKind] = "PgJsonb";
|
|
3087
2974
|
constructor(table, config) {
|
|
@@ -3105,7 +2992,7 @@ class PgJsonb extends PgColumn {
|
|
|
3105
2992
|
}
|
|
3106
2993
|
}
|
|
3107
2994
|
|
|
3108
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
2995
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/pg-core/columns/numeric.js
|
|
3109
2996
|
class PgNumeric extends PgColumn {
|
|
3110
2997
|
static [entityKind] = "PgNumeric";
|
|
3111
2998
|
precision;
|
|
@@ -3131,7 +3018,7 @@ class PgNumeric extends PgColumn {
|
|
|
3131
3018
|
}
|
|
3132
3019
|
}
|
|
3133
3020
|
|
|
3134
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
3021
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/pg-core/columns/time.js
|
|
3135
3022
|
class PgTime extends PgColumn {
|
|
3136
3023
|
static [entityKind] = "PgTime";
|
|
3137
3024
|
withTimezone;
|
|
@@ -3147,7 +3034,7 @@ class PgTime extends PgColumn {
|
|
|
3147
3034
|
}
|
|
3148
3035
|
}
|
|
3149
3036
|
|
|
3150
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
3037
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/pg-core/columns/timestamp.js
|
|
3151
3038
|
class PgTimestamp extends PgColumn {
|
|
3152
3039
|
static [entityKind] = "PgTimestamp";
|
|
3153
3040
|
withTimezone;
|
|
@@ -3183,7 +3070,7 @@ class PgTimestampString extends PgColumn {
|
|
|
3183
3070
|
}
|
|
3184
3071
|
}
|
|
3185
3072
|
|
|
3186
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
3073
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/pg-core/columns/uuid.js
|
|
3187
3074
|
class PgUUID extends PgColumn {
|
|
3188
3075
|
static [entityKind] = "PgUUID";
|
|
3189
3076
|
getSQLType() {
|
|
@@ -3191,7 +3078,7 @@ class PgUUID extends PgColumn {
|
|
|
3191
3078
|
}
|
|
3192
3079
|
}
|
|
3193
3080
|
|
|
3194
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
3081
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/pg-core/table.js
|
|
3195
3082
|
var InlineForeignKeys = Symbol.for("drizzle:PgInlineForeignKeys");
|
|
3196
3083
|
var EnableRLS = Symbol.for("drizzle:EnableRLS");
|
|
3197
3084
|
|
|
@@ -3207,7 +3094,7 @@ class PgTable extends Table {
|
|
|
3207
3094
|
[Table.Symbol.ExtraConfigColumns] = {};
|
|
3208
3095
|
}
|
|
3209
3096
|
|
|
3210
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
3097
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/pg-core/primary-keys.js
|
|
3211
3098
|
class PrimaryKeyBuilder {
|
|
3212
3099
|
static [entityKind] = "PgPrimaryKeyBuilder";
|
|
3213
3100
|
columns;
|
|
@@ -3235,7 +3122,77 @@ class PrimaryKey {
|
|
|
3235
3122
|
}
|
|
3236
3123
|
}
|
|
3237
3124
|
|
|
3238
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
3125
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/casing.js
|
|
3126
|
+
function toSnakeCase(input) {
|
|
3127
|
+
const words = input.replace(/['\u2019]/g, "").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g) ?? [];
|
|
3128
|
+
return words.map((word) => word.toLowerCase()).join("_");
|
|
3129
|
+
}
|
|
3130
|
+
function toCamelCase(input) {
|
|
3131
|
+
const words = input.replace(/['\u2019]/g, "").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g) ?? [];
|
|
3132
|
+
return words.reduce((acc, word, i) => {
|
|
3133
|
+
const formattedWord = i === 0 ? word.toLowerCase() : `${word[0].toUpperCase()}${word.slice(1)}`;
|
|
3134
|
+
return acc + formattedWord;
|
|
3135
|
+
}, "");
|
|
3136
|
+
}
|
|
3137
|
+
function noopCase(input) {
|
|
3138
|
+
return input;
|
|
3139
|
+
}
|
|
3140
|
+
|
|
3141
|
+
class CasingCache {
|
|
3142
|
+
static [entityKind] = "CasingCache";
|
|
3143
|
+
cache = {};
|
|
3144
|
+
cachedTables = {};
|
|
3145
|
+
convert;
|
|
3146
|
+
constructor(casing) {
|
|
3147
|
+
this.convert = casing === "snake_case" ? toSnakeCase : casing === "camelCase" ? toCamelCase : noopCase;
|
|
3148
|
+
}
|
|
3149
|
+
getColumnCasing(column) {
|
|
3150
|
+
if (!column.keyAsName)
|
|
3151
|
+
return column.name;
|
|
3152
|
+
const schema = column.table[Table.Symbol.Schema] ?? "public";
|
|
3153
|
+
const tableName = column.table[Table.Symbol.OriginalName];
|
|
3154
|
+
const key = `${schema}.${tableName}.${column.name}`;
|
|
3155
|
+
if (!this.cache[key]) {
|
|
3156
|
+
this.cacheTable(column.table);
|
|
3157
|
+
}
|
|
3158
|
+
return this.cache[key];
|
|
3159
|
+
}
|
|
3160
|
+
cacheTable(table) {
|
|
3161
|
+
const schema = table[Table.Symbol.Schema] ?? "public";
|
|
3162
|
+
const tableName = table[Table.Symbol.OriginalName];
|
|
3163
|
+
const tableKey = `${schema}.${tableName}`;
|
|
3164
|
+
if (!this.cachedTables[tableKey]) {
|
|
3165
|
+
for (const column of Object.values(table[Table.Symbol.Columns])) {
|
|
3166
|
+
const columnKey = `${tableKey}.${column.name}`;
|
|
3167
|
+
this.cache[columnKey] = this.convert(column.name);
|
|
3168
|
+
}
|
|
3169
|
+
this.cachedTables[tableKey] = true;
|
|
3170
|
+
}
|
|
3171
|
+
}
|
|
3172
|
+
clearCache() {
|
|
3173
|
+
this.cache = {};
|
|
3174
|
+
this.cachedTables = {};
|
|
3175
|
+
}
|
|
3176
|
+
}
|
|
3177
|
+
|
|
3178
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/errors.js
|
|
3179
|
+
class DrizzleError extends Error {
|
|
3180
|
+
static [entityKind] = "DrizzleError";
|
|
3181
|
+
constructor({ message, cause }) {
|
|
3182
|
+
super(message);
|
|
3183
|
+
this.name = "DrizzleError";
|
|
3184
|
+
this.cause = cause;
|
|
3185
|
+
}
|
|
3186
|
+
}
|
|
3187
|
+
|
|
3188
|
+
class TransactionRollbackError extends DrizzleError {
|
|
3189
|
+
static [entityKind] = "TransactionRollbackError";
|
|
3190
|
+
constructor() {
|
|
3191
|
+
super({ message: "Rollback" });
|
|
3192
|
+
}
|
|
3193
|
+
}
|
|
3194
|
+
|
|
3195
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/sql/expressions/conditions.js
|
|
3239
3196
|
function bindIfParam(value, column) {
|
|
3240
3197
|
if (isDriverValueEncoder(column) && !isSQLWrapper(value) && !is(value, Param) && !is(value, Placeholder) && !is(value, Column) && !is(value, Table) && !is(value, View)) {
|
|
3241
3198
|
return new Param(value, column);
|
|
@@ -3340,7 +3297,7 @@ function notIlike(column, value) {
|
|
|
3340
3297
|
return sql`${column} not ilike ${value}`;
|
|
3341
3298
|
}
|
|
3342
3299
|
|
|
3343
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
3300
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/sql/expressions/select.js
|
|
3344
3301
|
function asc(column) {
|
|
3345
3302
|
return sql`${column} asc`;
|
|
3346
3303
|
}
|
|
@@ -3348,7 +3305,7 @@ function desc(column) {
|
|
|
3348
3305
|
return sql`${column} desc`;
|
|
3349
3306
|
}
|
|
3350
3307
|
|
|
3351
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
3308
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/relations.js
|
|
3352
3309
|
class Relation {
|
|
3353
3310
|
constructor(sourceTable, referencedTable, relationName) {
|
|
3354
3311
|
this.sourceTable = sourceTable;
|
|
@@ -3568,12 +3525,12 @@ function mapRelationalRow(tablesConfig, tableConfig, row, buildQueryResultSelect
|
|
|
3568
3525
|
return result;
|
|
3569
3526
|
}
|
|
3570
3527
|
|
|
3571
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
3528
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/pg-core/view-base.js
|
|
3572
3529
|
class PgViewBase extends View {
|
|
3573
3530
|
static [entityKind] = "PgViewBase";
|
|
3574
3531
|
}
|
|
3575
3532
|
|
|
3576
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
3533
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/pg-core/dialect.js
|
|
3577
3534
|
class PgDialect {
|
|
3578
3535
|
static [entityKind] = "PgDialect";
|
|
3579
3536
|
casing;
|
|
@@ -4131,7 +4088,7 @@ class PgDialect {
|
|
|
4131
4088
|
}
|
|
4132
4089
|
}
|
|
4133
4090
|
|
|
4134
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
4091
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/query-builders/query-builder.js
|
|
4135
4092
|
class TypedQueryBuilder {
|
|
4136
4093
|
static [entityKind] = "TypedQueryBuilder";
|
|
4137
4094
|
getSelectedFields() {
|
|
@@ -4139,7 +4096,7 @@ class TypedQueryBuilder {
|
|
|
4139
4096
|
}
|
|
4140
4097
|
}
|
|
4141
4098
|
|
|
4142
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
4099
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/pg-core/query-builders/select.js
|
|
4143
4100
|
class PgSelectBuilder {
|
|
4144
4101
|
static [entityKind] = "PgSelectBuilder";
|
|
4145
4102
|
fields;
|
|
@@ -4197,6 +4154,8 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
4197
4154
|
isPartialSelect;
|
|
4198
4155
|
session;
|
|
4199
4156
|
dialect;
|
|
4157
|
+
cacheConfig = undefined;
|
|
4158
|
+
usedTables = /* @__PURE__ */ new Set;
|
|
4200
4159
|
constructor({ table, fields, isPartialSelect, session, dialect, withList, distinct }) {
|
|
4201
4160
|
super();
|
|
4202
4161
|
this.config = {
|
|
@@ -4210,15 +4169,23 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
4210
4169
|
this.session = session;
|
|
4211
4170
|
this.dialect = dialect;
|
|
4212
4171
|
this._ = {
|
|
4213
|
-
selectedFields: fields
|
|
4172
|
+
selectedFields: fields,
|
|
4173
|
+
config: this.config
|
|
4214
4174
|
};
|
|
4215
4175
|
this.tableName = getTableLikeName(table);
|
|
4216
4176
|
this.joinsNotNullableMap = typeof this.tableName === "string" ? { [this.tableName]: true } : {};
|
|
4177
|
+
for (const item of extractUsedTable(table))
|
|
4178
|
+
this.usedTables.add(item);
|
|
4179
|
+
}
|
|
4180
|
+
getUsedTables() {
|
|
4181
|
+
return [...this.usedTables];
|
|
4217
4182
|
}
|
|
4218
4183
|
createJoin(joinType, lateral) {
|
|
4219
4184
|
return (table, on) => {
|
|
4220
4185
|
const baseTableName = this.tableName;
|
|
4221
4186
|
const tableName = getTableLikeName(table);
|
|
4187
|
+
for (const item of extractUsedTable(table))
|
|
4188
|
+
this.usedTables.add(item);
|
|
4222
4189
|
if (typeof tableName === "string" && this.config.joins?.some((join) => join.alias === tableName)) {
|
|
4223
4190
|
throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
4224
4191
|
}
|
|
@@ -4364,7 +4331,13 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
4364
4331
|
return rest;
|
|
4365
4332
|
}
|
|
4366
4333
|
as(alias) {
|
|
4367
|
-
|
|
4334
|
+
const usedTables = [];
|
|
4335
|
+
usedTables.push(...extractUsedTable(this.config.table));
|
|
4336
|
+
if (this.config.joins) {
|
|
4337
|
+
for (const it of this.config.joins)
|
|
4338
|
+
usedTables.push(...extractUsedTable(it.table));
|
|
4339
|
+
}
|
|
4340
|
+
return new Proxy(new Subquery(this.getSQL(), this.config.fields, alias, false, [...new Set(usedTables)]), new SelectionProxyHandler({ alias, sqlAliasedBehavior: "alias", sqlBehavior: "error" }));
|
|
4368
4341
|
}
|
|
4369
4342
|
getSelectedFields() {
|
|
4370
4343
|
return new Proxy(this.config.fields, new SelectionProxyHandler({ alias: this.tableName, sqlAliasedBehavior: "alias", sqlBehavior: "error" }));
|
|
@@ -4372,18 +4345,26 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
4372
4345
|
$dynamic() {
|
|
4373
4346
|
return this;
|
|
4374
4347
|
}
|
|
4348
|
+
$withCache(config) {
|
|
4349
|
+
this.cacheConfig = config === undefined ? { config: {}, enable: true, autoInvalidate: true } : config === false ? { enable: false } : { enable: true, autoInvalidate: true, ...config };
|
|
4350
|
+
return this;
|
|
4351
|
+
}
|
|
4375
4352
|
}
|
|
4376
4353
|
|
|
4377
4354
|
class PgSelectBase extends PgSelectQueryBuilderBase {
|
|
4378
4355
|
static [entityKind] = "PgSelect";
|
|
4379
4356
|
_prepare(name) {
|
|
4380
|
-
const { session, config, dialect, joinsNotNullableMap, authToken } = this;
|
|
4357
|
+
const { session, config, dialect, joinsNotNullableMap, authToken, cacheConfig, usedTables } = this;
|
|
4381
4358
|
if (!session) {
|
|
4382
4359
|
throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");
|
|
4383
4360
|
}
|
|
4361
|
+
const { fields } = config;
|
|
4384
4362
|
return tracer.startActiveSpan("drizzle.prepareQuery", () => {
|
|
4385
|
-
const fieldsList = orderSelectedFields(
|
|
4386
|
-
const query = session.prepareQuery(dialect.sqlToQuery(this.getSQL()), fieldsList, name, true
|
|
4363
|
+
const fieldsList = orderSelectedFields(fields);
|
|
4364
|
+
const query = session.prepareQuery(dialect.sqlToQuery(this.getSQL()), fieldsList, name, true, undefined, {
|
|
4365
|
+
type: "select",
|
|
4366
|
+
tables: [...usedTables]
|
|
4367
|
+
}, cacheConfig);
|
|
4387
4368
|
query.joinsNotNullableMap = joinsNotNullableMap;
|
|
4388
4369
|
return query.setToken(authToken);
|
|
4389
4370
|
});
|
|
@@ -4433,7 +4414,7 @@ var intersectAll = createSetOperator("intersect", true);
|
|
|
4433
4414
|
var except = createSetOperator("except", false);
|
|
4434
4415
|
var exceptAll = createSetOperator("except", true);
|
|
4435
4416
|
|
|
4436
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
4417
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/pg-core/query-builders/query-builder.js
|
|
4437
4418
|
class QueryBuilder {
|
|
4438
4419
|
static [entityKind] = "PgQueryBuilder";
|
|
4439
4420
|
dialect;
|
|
@@ -4511,7 +4492,81 @@ class QueryBuilder {
|
|
|
4511
4492
|
}
|
|
4512
4493
|
}
|
|
4513
4494
|
|
|
4514
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
4495
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/pg-core/utils.js
|
|
4496
|
+
function extractUsedTable(table) {
|
|
4497
|
+
if (is(table, PgTable)) {
|
|
4498
|
+
return [table[Schema] ? `${table[Schema]}.${table[Table.Symbol.BaseName]}` : table[Table.Symbol.BaseName]];
|
|
4499
|
+
}
|
|
4500
|
+
if (is(table, Subquery)) {
|
|
4501
|
+
return table._.usedTables ?? [];
|
|
4502
|
+
}
|
|
4503
|
+
if (is(table, SQL)) {
|
|
4504
|
+
return table.usedTables ?? [];
|
|
4505
|
+
}
|
|
4506
|
+
return [];
|
|
4507
|
+
}
|
|
4508
|
+
|
|
4509
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/pg-core/query-builders/delete.js
|
|
4510
|
+
class PgDeleteBase extends QueryPromise {
|
|
4511
|
+
constructor(table, session, dialect, withList) {
|
|
4512
|
+
super();
|
|
4513
|
+
this.session = session;
|
|
4514
|
+
this.dialect = dialect;
|
|
4515
|
+
this.config = { table, withList };
|
|
4516
|
+
}
|
|
4517
|
+
static [entityKind] = "PgDelete";
|
|
4518
|
+
config;
|
|
4519
|
+
cacheConfig;
|
|
4520
|
+
where(where) {
|
|
4521
|
+
this.config.where = where;
|
|
4522
|
+
return this;
|
|
4523
|
+
}
|
|
4524
|
+
returning(fields = this.config.table[Table.Symbol.Columns]) {
|
|
4525
|
+
this.config.returningFields = fields;
|
|
4526
|
+
this.config.returning = orderSelectedFields(fields);
|
|
4527
|
+
return this;
|
|
4528
|
+
}
|
|
4529
|
+
getSQL() {
|
|
4530
|
+
return this.dialect.buildDeleteQuery(this.config);
|
|
4531
|
+
}
|
|
4532
|
+
toSQL() {
|
|
4533
|
+
const { typings: _typings, ...rest } = this.dialect.sqlToQuery(this.getSQL());
|
|
4534
|
+
return rest;
|
|
4535
|
+
}
|
|
4536
|
+
_prepare(name) {
|
|
4537
|
+
return tracer.startActiveSpan("drizzle.prepareQuery", () => {
|
|
4538
|
+
return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()), this.config.returning, name, true, undefined, {
|
|
4539
|
+
type: "delete",
|
|
4540
|
+
tables: extractUsedTable(this.config.table)
|
|
4541
|
+
}, this.cacheConfig);
|
|
4542
|
+
});
|
|
4543
|
+
}
|
|
4544
|
+
prepare(name) {
|
|
4545
|
+
return this._prepare(name);
|
|
4546
|
+
}
|
|
4547
|
+
authToken;
|
|
4548
|
+
setToken(token) {
|
|
4549
|
+
this.authToken = token;
|
|
4550
|
+
return this;
|
|
4551
|
+
}
|
|
4552
|
+
execute = (placeholderValues) => {
|
|
4553
|
+
return tracer.startActiveSpan("drizzle.operation", () => {
|
|
4554
|
+
return this._prepare().execute(placeholderValues, this.authToken);
|
|
4555
|
+
});
|
|
4556
|
+
};
|
|
4557
|
+
getSelectedFields() {
|
|
4558
|
+
return this.config.returningFields ? new Proxy(this.config.returningFields, new SelectionProxyHandler({
|
|
4559
|
+
alias: getTableName(this.config.table),
|
|
4560
|
+
sqlAliasedBehavior: "alias",
|
|
4561
|
+
sqlBehavior: "error"
|
|
4562
|
+
})) : undefined;
|
|
4563
|
+
}
|
|
4564
|
+
$dynamic() {
|
|
4565
|
+
return this;
|
|
4566
|
+
}
|
|
4567
|
+
}
|
|
4568
|
+
|
|
4569
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/pg-core/query-builders/insert.js
|
|
4515
4570
|
class PgInsertBuilder {
|
|
4516
4571
|
constructor(table, session, dialect, withList, overridingSystemValue_) {
|
|
4517
4572
|
this.table = table;
|
|
@@ -4564,6 +4619,7 @@ class PgInsertBase extends QueryPromise {
|
|
|
4564
4619
|
}
|
|
4565
4620
|
static [entityKind] = "PgInsert";
|
|
4566
4621
|
config;
|
|
4622
|
+
cacheConfig;
|
|
4567
4623
|
returning(fields = this.config.table[Table.Symbol.Columns]) {
|
|
4568
4624
|
this.config.returningFields = fields;
|
|
4569
4625
|
this.config.returning = orderSelectedFields(fields);
|
|
@@ -4602,7 +4658,10 @@ class PgInsertBase extends QueryPromise {
|
|
|
4602
4658
|
}
|
|
4603
4659
|
_prepare(name) {
|
|
4604
4660
|
return tracer.startActiveSpan("drizzle.prepareQuery", () => {
|
|
4605
|
-
return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()), this.config.returning, name, true
|
|
4661
|
+
return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()), this.config.returning, name, true, undefined, {
|
|
4662
|
+
type: "insert",
|
|
4663
|
+
tables: extractUsedTable(this.config.table)
|
|
4664
|
+
}, this.cacheConfig);
|
|
4606
4665
|
});
|
|
4607
4666
|
}
|
|
4608
4667
|
prepare(name) {
|
|
@@ -4630,7 +4689,7 @@ class PgInsertBase extends QueryPromise {
|
|
|
4630
4689
|
}
|
|
4631
4690
|
}
|
|
4632
4691
|
|
|
4633
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
4692
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/pg-core/query-builders/refresh-materialized-view.js
|
|
4634
4693
|
class PgRefreshMaterializedView extends QueryPromise {
|
|
4635
4694
|
constructor(view, session, dialect) {
|
|
4636
4695
|
super();
|
|
@@ -4681,7 +4740,7 @@ class PgRefreshMaterializedView extends QueryPromise {
|
|
|
4681
4740
|
};
|
|
4682
4741
|
}
|
|
4683
4742
|
|
|
4684
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
4743
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/pg-core/query-builders/update.js
|
|
4685
4744
|
class PgUpdateBuilder {
|
|
4686
4745
|
constructor(table, session, dialect, withList) {
|
|
4687
4746
|
this.table = table;
|
|
@@ -4713,6 +4772,7 @@ class PgUpdateBase extends QueryPromise {
|
|
|
4713
4772
|
config;
|
|
4714
4773
|
tableName;
|
|
4715
4774
|
joinsNotNullableMap;
|
|
4775
|
+
cacheConfig;
|
|
4716
4776
|
from(source) {
|
|
4717
4777
|
const src = source;
|
|
4718
4778
|
const tableName = getTableLikeName(src);
|
|
@@ -4804,7 +4864,10 @@ class PgUpdateBase extends QueryPromise {
|
|
|
4804
4864
|
return rest;
|
|
4805
4865
|
}
|
|
4806
4866
|
_prepare(name) {
|
|
4807
|
-
const query = this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()), this.config.returning, name, true
|
|
4867
|
+
const query = this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()), this.config.returning, name, true, undefined, {
|
|
4868
|
+
type: "insert",
|
|
4869
|
+
tables: extractUsedTable(this.config.table)
|
|
4870
|
+
}, this.cacheConfig);
|
|
4808
4871
|
query.joinsNotNullableMap = this.joinsNotNullableMap;
|
|
4809
4872
|
return query;
|
|
4810
4873
|
}
|
|
@@ -4831,7 +4894,7 @@ class PgUpdateBase extends QueryPromise {
|
|
|
4831
4894
|
}
|
|
4832
4895
|
}
|
|
4833
4896
|
|
|
4834
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
4897
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/pg-core/query-builders/count.js
|
|
4835
4898
|
class PgCountBuilder extends SQL {
|
|
4836
4899
|
constructor(params) {
|
|
4837
4900
|
super(PgCountBuilder.buildEmbeddedCount(params.source, params.filters).queryChunks);
|
|
@@ -4872,7 +4935,7 @@ class PgCountBuilder extends SQL {
|
|
|
4872
4935
|
}
|
|
4873
4936
|
}
|
|
4874
4937
|
|
|
4875
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
4938
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/pg-core/query-builders/query.js
|
|
4876
4939
|
class RelationalQueryBuilder {
|
|
4877
4940
|
constructor(fullSchema, schema, tableNamesMap, table, tableConfig, dialect, session) {
|
|
4878
4941
|
this.fullSchema = fullSchema;
|
|
@@ -4955,7 +5018,7 @@ class PgRelationalQuery extends QueryPromise {
|
|
|
4955
5018
|
}
|
|
4956
5019
|
}
|
|
4957
5020
|
|
|
4958
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
5021
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/pg-core/query-builders/raw.js
|
|
4959
5022
|
class PgRaw extends QueryPromise {
|
|
4960
5023
|
constructor(execute, sql2, query, mapBatchResult) {
|
|
4961
5024
|
super();
|
|
@@ -4982,7 +5045,7 @@ class PgRaw extends QueryPromise {
|
|
|
4982
5045
|
}
|
|
4983
5046
|
}
|
|
4984
5047
|
|
|
4985
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
5048
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/pg-core/db.js
|
|
4986
5049
|
class PgDatabase {
|
|
4987
5050
|
constructor(dialect, session, schema) {
|
|
4988
5051
|
this.dialect = dialect;
|
|
@@ -5004,6 +5067,7 @@ class PgDatabase {
|
|
|
5004
5067
|
this.query[tableName] = new RelationalQueryBuilder(schema.fullSchema, this._.schema, this._.tableNamesMap, schema.fullSchema[tableName], columns, dialect, session);
|
|
5005
5068
|
}
|
|
5006
5069
|
}
|
|
5070
|
+
this.$cache = { invalidate: async (_params) => {} };
|
|
5007
5071
|
}
|
|
5008
5072
|
static [entityKind] = "PgDatabase";
|
|
5009
5073
|
query;
|
|
@@ -5020,6 +5084,7 @@ class PgDatabase {
|
|
|
5020
5084
|
$count(source, filters) {
|
|
5021
5085
|
return new PgCountBuilder({ source, filters, session: this.session });
|
|
5022
5086
|
}
|
|
5087
|
+
$cache;
|
|
5023
5088
|
with(...queries) {
|
|
5024
5089
|
const self = this;
|
|
5025
5090
|
function select2(fields) {
|
|
@@ -5106,10 +5171,59 @@ class PgDatabase {
|
|
|
5106
5171
|
}
|
|
5107
5172
|
}
|
|
5108
5173
|
|
|
5109
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
5174
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/cache/core/cache.js
|
|
5175
|
+
class Cache {
|
|
5176
|
+
static [entityKind] = "Cache";
|
|
5177
|
+
}
|
|
5178
|
+
|
|
5179
|
+
class NoopCache extends Cache {
|
|
5180
|
+
strategy() {
|
|
5181
|
+
return "all";
|
|
5182
|
+
}
|
|
5183
|
+
static [entityKind] = "NoopCache";
|
|
5184
|
+
async get(_key) {
|
|
5185
|
+
return;
|
|
5186
|
+
}
|
|
5187
|
+
async put(_hashedQuery, _response, _tables, _config) {}
|
|
5188
|
+
async onMutate(_params) {}
|
|
5189
|
+
}
|
|
5190
|
+
async function hashQuery(sql2, params) {
|
|
5191
|
+
const dataToHash = `${sql2}-${JSON.stringify(params)}`;
|
|
5192
|
+
const encoder = new TextEncoder;
|
|
5193
|
+
const data = encoder.encode(dataToHash);
|
|
5194
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
5195
|
+
const hashArray = [...new Uint8Array(hashBuffer)];
|
|
5196
|
+
const hashHex = hashArray.map((b2) => b2.toString(16).padStart(2, "0")).join("");
|
|
5197
|
+
return hashHex;
|
|
5198
|
+
}
|
|
5199
|
+
|
|
5200
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/errors/index.js
|
|
5201
|
+
class DrizzleQueryError extends Error {
|
|
5202
|
+
constructor(query, params, cause) {
|
|
5203
|
+
super(`Failed query: ${query}
|
|
5204
|
+
params: ${params}`);
|
|
5205
|
+
this.query = query;
|
|
5206
|
+
this.params = params;
|
|
5207
|
+
this.cause = cause;
|
|
5208
|
+
Error.captureStackTrace(this, DrizzleQueryError);
|
|
5209
|
+
if (cause)
|
|
5210
|
+
this.cause = cause;
|
|
5211
|
+
}
|
|
5212
|
+
}
|
|
5213
|
+
|
|
5214
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/pg-core/session.js
|
|
5110
5215
|
class PgPreparedQuery {
|
|
5111
|
-
constructor(query) {
|
|
5216
|
+
constructor(query, cache, queryMetadata, cacheConfig) {
|
|
5112
5217
|
this.query = query;
|
|
5218
|
+
this.cache = cache;
|
|
5219
|
+
this.queryMetadata = queryMetadata;
|
|
5220
|
+
this.cacheConfig = cacheConfig;
|
|
5221
|
+
if (cache && cache.strategy() === "all" && cacheConfig === undefined) {
|
|
5222
|
+
this.cacheConfig = { enable: true, autoInvalidate: true };
|
|
5223
|
+
}
|
|
5224
|
+
if (!this.cacheConfig?.enable) {
|
|
5225
|
+
this.cacheConfig = undefined;
|
|
5226
|
+
}
|
|
5113
5227
|
}
|
|
5114
5228
|
authToken;
|
|
5115
5229
|
getQuery() {
|
|
@@ -5124,6 +5238,59 @@ class PgPreparedQuery {
|
|
|
5124
5238
|
}
|
|
5125
5239
|
static [entityKind] = "PgPreparedQuery";
|
|
5126
5240
|
joinsNotNullableMap;
|
|
5241
|
+
async queryWithCache(queryString, params, query) {
|
|
5242
|
+
if (this.cache === undefined || is(this.cache, NoopCache) || this.queryMetadata === undefined) {
|
|
5243
|
+
try {
|
|
5244
|
+
return await query();
|
|
5245
|
+
} catch (e) {
|
|
5246
|
+
throw new DrizzleQueryError(queryString, params, e);
|
|
5247
|
+
}
|
|
5248
|
+
}
|
|
5249
|
+
if (this.cacheConfig && !this.cacheConfig.enable) {
|
|
5250
|
+
try {
|
|
5251
|
+
return await query();
|
|
5252
|
+
} catch (e) {
|
|
5253
|
+
throw new DrizzleQueryError(queryString, params, e);
|
|
5254
|
+
}
|
|
5255
|
+
}
|
|
5256
|
+
if ((this.queryMetadata.type === "insert" || this.queryMetadata.type === "update" || this.queryMetadata.type === "delete") && this.queryMetadata.tables.length > 0) {
|
|
5257
|
+
try {
|
|
5258
|
+
const [res] = await Promise.all([
|
|
5259
|
+
query(),
|
|
5260
|
+
this.cache.onMutate({ tables: this.queryMetadata.tables })
|
|
5261
|
+
]);
|
|
5262
|
+
return res;
|
|
5263
|
+
} catch (e) {
|
|
5264
|
+
throw new DrizzleQueryError(queryString, params, e);
|
|
5265
|
+
}
|
|
5266
|
+
}
|
|
5267
|
+
if (!this.cacheConfig) {
|
|
5268
|
+
try {
|
|
5269
|
+
return await query();
|
|
5270
|
+
} catch (e) {
|
|
5271
|
+
throw new DrizzleQueryError(queryString, params, e);
|
|
5272
|
+
}
|
|
5273
|
+
}
|
|
5274
|
+
if (this.queryMetadata.type === "select") {
|
|
5275
|
+
const fromCache = await this.cache.get(this.cacheConfig.tag ?? await hashQuery(queryString, params), this.queryMetadata.tables, this.cacheConfig.tag !== undefined, this.cacheConfig.autoInvalidate);
|
|
5276
|
+
if (fromCache === undefined) {
|
|
5277
|
+
let result;
|
|
5278
|
+
try {
|
|
5279
|
+
result = await query();
|
|
5280
|
+
} catch (e) {
|
|
5281
|
+
throw new DrizzleQueryError(queryString, params, e);
|
|
5282
|
+
}
|
|
5283
|
+
await this.cache.put(this.cacheConfig.tag ?? await hashQuery(queryString, params), result, this.cacheConfig.autoInvalidate ? this.queryMetadata.tables : [], this.cacheConfig.tag !== undefined, this.cacheConfig.config);
|
|
5284
|
+
return result;
|
|
5285
|
+
}
|
|
5286
|
+
return fromCache;
|
|
5287
|
+
}
|
|
5288
|
+
try {
|
|
5289
|
+
return await query();
|
|
5290
|
+
} catch (e) {
|
|
5291
|
+
throw new DrizzleQueryError(queryString, params, e);
|
|
5292
|
+
}
|
|
5293
|
+
}
|
|
5127
5294
|
}
|
|
5128
5295
|
|
|
5129
5296
|
class PgSession {
|
|
@@ -5176,10 +5343,10 @@ class PgTransaction extends PgDatabase {
|
|
|
5176
5343
|
}
|
|
5177
5344
|
}
|
|
5178
5345
|
|
|
5179
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
5346
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/postgres-js/session.js
|
|
5180
5347
|
class PostgresJsPreparedQuery extends PgPreparedQuery {
|
|
5181
|
-
constructor(client, queryString, params, logger, fields, _isResponseInArrayMode, customResultMapper) {
|
|
5182
|
-
super({ sql: queryString, params });
|
|
5348
|
+
constructor(client, queryString, params, logger, cache, queryMetadata, cacheConfig, fields, _isResponseInArrayMode, customResultMapper) {
|
|
5349
|
+
super({ sql: queryString, params }, cache, queryMetadata, cacheConfig);
|
|
5183
5350
|
this.client = client;
|
|
5184
5351
|
this.queryString = queryString;
|
|
5185
5352
|
this.params = params;
|
|
@@ -5200,7 +5367,9 @@ class PostgresJsPreparedQuery extends PgPreparedQuery {
|
|
|
5200
5367
|
const { fields, queryString: query, client, joinsNotNullableMap, customResultMapper } = this;
|
|
5201
5368
|
if (!fields && !customResultMapper) {
|
|
5202
5369
|
return tracer.startActiveSpan("drizzle.driver.execute", () => {
|
|
5203
|
-
return
|
|
5370
|
+
return this.queryWithCache(query, params, async () => {
|
|
5371
|
+
return await client.unsafe(query, params);
|
|
5372
|
+
});
|
|
5204
5373
|
});
|
|
5205
5374
|
}
|
|
5206
5375
|
const rows = await tracer.startActiveSpan("drizzle.driver.execute", () => {
|
|
@@ -5208,7 +5377,9 @@ class PostgresJsPreparedQuery extends PgPreparedQuery {
|
|
|
5208
5377
|
"drizzle.query.text": query,
|
|
5209
5378
|
"drizzle.query.params": JSON.stringify(params)
|
|
5210
5379
|
});
|
|
5211
|
-
return
|
|
5380
|
+
return this.queryWithCache(query, params, async () => {
|
|
5381
|
+
return await client.unsafe(query, params).values();
|
|
5382
|
+
});
|
|
5212
5383
|
});
|
|
5213
5384
|
return tracer.startActiveSpan("drizzle.mapResponse", () => {
|
|
5214
5385
|
return customResultMapper ? customResultMapper(rows) : rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
|
|
@@ -5228,7 +5399,9 @@ class PostgresJsPreparedQuery extends PgPreparedQuery {
|
|
|
5228
5399
|
"drizzle.query.text": this.queryString,
|
|
5229
5400
|
"drizzle.query.params": JSON.stringify(params)
|
|
5230
5401
|
});
|
|
5231
|
-
return this.
|
|
5402
|
+
return this.queryWithCache(this.queryString, params, async () => {
|
|
5403
|
+
return this.client.unsafe(this.queryString, params);
|
|
5404
|
+
});
|
|
5232
5405
|
});
|
|
5233
5406
|
});
|
|
5234
5407
|
}
|
|
@@ -5244,11 +5417,13 @@ class PostgresJsSession extends PgSession {
|
|
|
5244
5417
|
this.schema = schema;
|
|
5245
5418
|
this.options = options;
|
|
5246
5419
|
this.logger = options.logger ?? new NoopLogger;
|
|
5420
|
+
this.cache = options.cache ?? new NoopCache;
|
|
5247
5421
|
}
|
|
5248
5422
|
static [entityKind] = "PostgresJsSession";
|
|
5249
5423
|
logger;
|
|
5250
|
-
|
|
5251
|
-
|
|
5424
|
+
cache;
|
|
5425
|
+
prepareQuery(query, fields, name, isResponseInArrayMode, customResultMapper, queryMetadata, cacheConfig) {
|
|
5426
|
+
return new PostgresJsPreparedQuery(this.client, query.sql, query.params, this.logger, this.cache, queryMetadata, cacheConfig, fields, isResponseInArrayMode, customResultMapper);
|
|
5252
5427
|
}
|
|
5253
5428
|
query(query, params) {
|
|
5254
5429
|
this.logger.logQuery(query, params);
|
|
@@ -5284,7 +5459,7 @@ class PostgresJsTransaction extends PgTransaction {
|
|
|
5284
5459
|
}
|
|
5285
5460
|
}
|
|
5286
5461
|
|
|
5287
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
5462
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/postgres-js/driver.js
|
|
5288
5463
|
class PostgresJsDatabase extends PgDatabase {
|
|
5289
5464
|
static [entityKind] = "PostgresJsDatabase";
|
|
5290
5465
|
}
|
|
@@ -5312,9 +5487,13 @@ function construct(client, config = {}) {
|
|
|
5312
5487
|
tableNamesMap: tablesConfig.tableNamesMap
|
|
5313
5488
|
};
|
|
5314
5489
|
}
|
|
5315
|
-
const session = new PostgresJsSession(client, dialect, schema, { logger });
|
|
5490
|
+
const session = new PostgresJsSession(client, dialect, schema, { logger, cache: config.cache });
|
|
5316
5491
|
const db = new PostgresJsDatabase(dialect, session, schema);
|
|
5317
5492
|
db.$client = client;
|
|
5493
|
+
db.$cache = config.cache;
|
|
5494
|
+
if (db.$cache) {
|
|
5495
|
+
db.$cache["invalidate"] = config.cache?.onMutate;
|
|
5496
|
+
}
|
|
5318
5497
|
return db;
|
|
5319
5498
|
}
|
|
5320
5499
|
function drizzle(...params) {
|
|
@@ -5348,8 +5527,8 @@ function drizzle(...params) {
|
|
|
5348
5527
|
drizzle2.mock = mock;
|
|
5349
5528
|
})(drizzle || (drizzle = {}));
|
|
5350
5529
|
|
|
5351
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
5352
|
-
import
|
|
5530
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/migrator.js
|
|
5531
|
+
import crypto3 from "crypto";
|
|
5353
5532
|
import fs2 from "fs";
|
|
5354
5533
|
function readMigrationFiles(config) {
|
|
5355
5534
|
const migrationFolderTo = config.migrationsFolder;
|
|
@@ -5371,7 +5550,7 @@ function readMigrationFiles(config) {
|
|
|
5371
5550
|
sql: result,
|
|
5372
5551
|
bps: journalEntry.breakpoints,
|
|
5373
5552
|
folderMillis: journalEntry.when,
|
|
5374
|
-
hash:
|
|
5553
|
+
hash: crypto3.createHash("sha256").update(query).digest("hex")
|
|
5375
5554
|
});
|
|
5376
5555
|
} catch {
|
|
5377
5556
|
throw new Error(`No file ${migrationPath} found in ${migrationFolderTo} folder`);
|
|
@@ -5380,13 +5559,13 @@ function readMigrationFiles(config) {
|
|
|
5380
5559
|
return migrationQueries;
|
|
5381
5560
|
}
|
|
5382
5561
|
|
|
5383
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.
|
|
5562
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/postgres-js/migrator.js
|
|
5384
5563
|
async function migrate(db, config) {
|
|
5385
5564
|
const migrations = readMigrationFiles(config);
|
|
5386
5565
|
await db.dialect.migrate(migrations, db.session, config);
|
|
5387
5566
|
}
|
|
5388
5567
|
|
|
5389
|
-
// ../../node_modules/.pnpm/@t3-oss+env-core@0.13.
|
|
5568
|
+
// ../../node_modules/.pnpm/@t3-oss+env-core@0.13.6_arktype@2.1.20_typescript@5.8.3_valibot@1.0.0_typescript@5.8.3__zod@3.25.34/node_modules/@t3-oss/env-core/dist/src-Bb3GbGAa.js
|
|
5390
5569
|
function ensureSynchronous(value, message) {
|
|
5391
5570
|
if (value instanceof Promise)
|
|
5392
5571
|
throw new Error(message);
|
|
@@ -5400,6 +5579,7 @@ function parseWithDictionary(dictionary, value) {
|
|
|
5400
5579
|
if (propResult.issues) {
|
|
5401
5580
|
issues.push(...propResult.issues.map((issue) => ({
|
|
5402
5581
|
...issue,
|
|
5582
|
+
message: issue.message,
|
|
5403
5583
|
path: [key, ...issue.path ?? []]
|
|
5404
5584
|
})));
|
|
5405
5585
|
continue;
|