tempest.games 0.2.10 → 0.2.12

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.
@@ -474,7 +474,7 @@ kebab.column.to = fromKebab;
474
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 crypto from "crypto";
477
+ import crypto2 from "crypto";
478
478
  import Stream from "stream";
479
479
  import { performance } from "perf_hooks";
480
480
 
@@ -1037,14 +1037,14 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
1037
1037
  write(bytes_default().p().str(payload).z(1).end());
1038
1038
  }
1039
1039
  async function SASL() {
1040
- nonce = (await crypto.randomBytes(18)).toString("base64");
1040
+ nonce = (await crypto2.randomBytes(18)).toString("base64");
1041
1041
  bytes_default().p().str("SCRAM-SHA-256" + bytes_default.N);
1042
1042
  const i = bytes_default.i;
1043
1043
  write(bytes_default.inc(4).str("n,,n=*,r=" + nonce).i32(bytes_default.i - i - 4, i).end());
1044
1044
  }
1045
1045
  async function SASLContinue(x) {
1046
1046
  const res = x.toString("utf8", 9).split(",").reduce((acc, x2) => (acc[x2[0]] = x2.slice(2), acc), {});
1047
- const saltedPassword = await crypto.pbkdf2Sync(await Pass(), Buffer.from(res.s, "base64"), parseInt(res.i), 32, "sha256");
1047
+ const saltedPassword = await crypto2.pbkdf2Sync(await Pass(), Buffer.from(res.s, "base64"), parseInt(res.i), 32, "sha256");
1048
1048
  const clientKey = await hmac(saltedPassword, "Client Key");
1049
1049
  const auth = "n=*,r=" + nonce + "," + "r=" + res.r + ",s=" + res.s + ",i=" + res.i + ",c=biws,r=" + res.r;
1050
1050
  serverSignature = (await hmac(await hmac(saltedPassword, "Server Key"), auth)).toString("base64");
@@ -1261,13 +1261,13 @@ function parseError(x) {
1261
1261
  return error;
1262
1262
  }
1263
1263
  function md5(x) {
1264
- return crypto.createHash("md5").update(x).digest("hex");
1264
+ return crypto2.createHash("md5").update(x).digest("hex");
1265
1265
  }
1266
1266
  function hmac(key, x) {
1267
- return crypto.createHmac("sha256", key).update(x).digest();
1267
+ return crypto2.createHmac("sha256", key).update(x).digest();
1268
1268
  }
1269
1269
  function sha256(x) {
1270
- return crypto.createHash("sha256").update(x).digest();
1270
+ return crypto2.createHash("sha256").update(x).digest();
1271
1271
  }
1272
1272
  function xor(a, b2) {
1273
1273
  const length = Math.max(a.length, b2.length);
@@ -1952,7 +1952,7 @@ function osUsername() {
1952
1952
  }
1953
1953
  }
1954
1954
 
1955
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/entity.js
1955
+ // ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/entity.js
1956
1956
  var entityKind = Symbol.for("drizzle:entityKind");
1957
1957
  var hasOwnEntityKind = Symbol.for("drizzle:hasOwnEntityKind");
1958
1958
  function is(value, type) {
@@ -1977,7 +1977,7 @@ function is(value, type) {
1977
1977
  return false;
1978
1978
  }
1979
1979
 
1980
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/logger.js
1980
+ // ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/logger.js
1981
1981
  class ConsoleLogWriter {
1982
1982
  static [entityKind] = "ConsoleLogWriter";
1983
1983
  write(message) {
@@ -2009,7 +2009,7 @@ class NoopLogger {
2009
2009
  logQuery() {}
2010
2010
  }
2011
2011
 
2012
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/query-promise.js
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
2013
2013
  class QueryPromise {
2014
2014
  static [entityKind] = "QueryPromise";
2015
2015
  [Symbol.toStringTag] = "QueryPromise";
@@ -2030,7 +2030,7 @@ class QueryPromise {
2030
2030
  }
2031
2031
  }
2032
2032
 
2033
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/column.js
2033
+ // ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/column.js
2034
2034
  class Column {
2035
2035
  constructor(table, config) {
2036
2036
  this.table = table;
@@ -2080,20 +2080,20 @@ class Column {
2080
2080
  }
2081
2081
  }
2082
2082
 
2083
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/table.utils.js
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
2084
2084
  var TableName = Symbol.for("drizzle:Name");
2085
2085
 
2086
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/tracing-utils.js
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
2087
2087
  function iife(fn, ...args) {
2088
2088
  return fn(...args);
2089
2089
  }
2090
2090
 
2091
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/pg-core/unique-constraint.js
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
2092
2092
  function uniqueKeyName(table, columns) {
2093
2093
  return `${table[TableName]}_${columns.join("_")}_unique`;
2094
2094
  }
2095
2095
 
2096
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/pg-core/columns/common.js
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
2097
2097
  class PgColumn extends Column {
2098
2098
  constructor(table, config) {
2099
2099
  if (!config.uniqueName) {
@@ -2142,7 +2142,7 @@ class ExtraConfigColumn extends PgColumn {
2142
2142
  }
2143
2143
  }
2144
2144
 
2145
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/pg-core/columns/enum.js
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
2146
2146
  class PgEnumObjectColumn extends PgColumn {
2147
2147
  static [entityKind] = "PgEnumObjectColumn";
2148
2148
  enum;
@@ -2172,16 +2172,17 @@ class PgEnumColumn extends PgColumn {
2172
2172
  }
2173
2173
  }
2174
2174
 
2175
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/subquery.js
2175
+ // ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/subquery.js
2176
2176
  class Subquery {
2177
2177
  static [entityKind] = "Subquery";
2178
- constructor(sql, selection, alias, isWith = false) {
2178
+ constructor(sql, fields, alias, isWith = false, usedTables = []) {
2179
2179
  this._ = {
2180
2180
  brand: "Subquery",
2181
2181
  sql,
2182
- selectedFields: selection,
2182
+ selectedFields: fields,
2183
2183
  alias,
2184
- isWith
2184
+ isWith,
2185
+ usedTables
2185
2186
  };
2186
2187
  }
2187
2188
  }
@@ -2190,10 +2191,10 @@ class WithSubquery extends Subquery {
2190
2191
  static [entityKind] = "WithSubquery";
2191
2192
  }
2192
2193
 
2193
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/version.js
2194
- var version = "0.43.1";
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";
2195
2196
 
2196
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/tracing.js
2197
+ // ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/tracing.js
2197
2198
  var otel;
2198
2199
  var rawTracer;
2199
2200
  var tracer = {
@@ -2220,10 +2221,10 @@ var tracer = {
2220
2221
  }
2221
2222
  };
2222
2223
 
2223
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/view-common.js
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
2224
2225
  var ViewBaseConfig = Symbol.for("drizzle:ViewBaseConfig");
2225
2226
 
2226
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/table.js
2227
+ // ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/table.js
2227
2228
  var Schema = Symbol.for("drizzle:Schema");
2228
2229
  var Columns = Symbol.for("drizzle:Columns");
2229
2230
  var ExtraConfigColumns = Symbol.for("drizzle:ExtraConfigColumns");
@@ -2267,7 +2268,7 @@ function getTableUniqueName(table) {
2267
2268
  return `${table[Schema] ?? "public"}.${table[TableName]}`;
2268
2269
  }
2269
2270
 
2270
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/sql/sql.js
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
2271
2272
  function isSQLWrapper(value) {
2272
2273
  return value !== null && value !== undefined && typeof value.getSQL === "function";
2273
2274
  }
@@ -2300,10 +2301,17 @@ class StringChunk {
2300
2301
  class SQL {
2301
2302
  constructor(queryChunks) {
2302
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
+ }
2303
2310
  }
2304
2311
  static [entityKind] = "SQL";
2305
2312
  decoder = noopDecoder;
2306
2313
  shouldInlineParams = false;
2314
+ usedTables = [];
2307
2315
  append(query) {
2308
2316
  this.queryChunks.push(...query.queryChunks);
2309
2317
  return this;
@@ -2640,7 +2648,7 @@ Subquery.prototype.getSQL = function() {
2640
2648
  return new SQL([this]);
2641
2649
  };
2642
2650
 
2643
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/alias.js
2651
+ // ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/alias.js
2644
2652
  class ColumnAliasProxyHandler {
2645
2653
  constructor(table) {
2646
2654
  this.table = table;
@@ -2719,7 +2727,7 @@ function mapColumnsInSQLToAlias(query, alias) {
2719
2727
  }));
2720
2728
  }
2721
2729
 
2722
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/selection-proxy.js
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
2723
2731
  class SelectionProxyHandler {
2724
2732
  static [entityKind] = "SelectionProxyHandler";
2725
2733
  config;
@@ -2771,7 +2779,7 @@ class SelectionProxyHandler {
2771
2779
  }
2772
2780
  }
2773
2781
 
2774
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/utils.js
2782
+ // ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/utils.js
2775
2783
  function mapResultRow(columns, row, joinsNotNullableMap) {
2776
2784
  const nullifyMap = {};
2777
2785
  const result = columns.reduce((result2, { path, field }, columnIndex) => {
@@ -2916,133 +2924,7 @@ function isConfig(data) {
2916
2924
  return false;
2917
2925
  }
2918
2926
 
2919
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/pg-core/query-builders/delete.js
2920
- class PgDeleteBase extends QueryPromise {
2921
- constructor(table, session, dialect, withList) {
2922
- super();
2923
- this.session = session;
2924
- this.dialect = dialect;
2925
- this.config = { table, withList };
2926
- }
2927
- static [entityKind] = "PgDelete";
2928
- config;
2929
- where(where) {
2930
- this.config.where = where;
2931
- return this;
2932
- }
2933
- returning(fields = this.config.table[Table.Symbol.Columns]) {
2934
- this.config.returningFields = fields;
2935
- this.config.returning = orderSelectedFields(fields);
2936
- return this;
2937
- }
2938
- getSQL() {
2939
- return this.dialect.buildDeleteQuery(this.config);
2940
- }
2941
- toSQL() {
2942
- const { typings: _typings, ...rest } = this.dialect.sqlToQuery(this.getSQL());
2943
- return rest;
2944
- }
2945
- _prepare(name) {
2946
- return tracer.startActiveSpan("drizzle.prepareQuery", () => {
2947
- return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()), this.config.returning, name, true);
2948
- });
2949
- }
2950
- prepare(name) {
2951
- return this._prepare(name);
2952
- }
2953
- authToken;
2954
- setToken(token) {
2955
- this.authToken = token;
2956
- return this;
2957
- }
2958
- execute = (placeholderValues) => {
2959
- return tracer.startActiveSpan("drizzle.operation", () => {
2960
- return this._prepare().execute(placeholderValues, this.authToken);
2961
- });
2962
- };
2963
- getSelectedFields() {
2964
- return this.config.returningFields ? new Proxy(this.config.returningFields, new SelectionProxyHandler({
2965
- alias: getTableName(this.config.table),
2966
- sqlAliasedBehavior: "alias",
2967
- sqlBehavior: "error"
2968
- })) : undefined;
2969
- }
2970
- $dynamic() {
2971
- return this;
2972
- }
2973
- }
2974
-
2975
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/casing.js
2976
- function toSnakeCase(input) {
2977
- const words = input.replace(/['\u2019]/g, "").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g) ?? [];
2978
- return words.map((word) => word.toLowerCase()).join("_");
2979
- }
2980
- function toCamelCase(input) {
2981
- const words = input.replace(/['\u2019]/g, "").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g) ?? [];
2982
- return words.reduce((acc, word, i) => {
2983
- const formattedWord = i === 0 ? word.toLowerCase() : `${word[0].toUpperCase()}${word.slice(1)}`;
2984
- return acc + formattedWord;
2985
- }, "");
2986
- }
2987
- function noopCase(input) {
2988
- return input;
2989
- }
2990
-
2991
- class CasingCache {
2992
- static [entityKind] = "CasingCache";
2993
- cache = {};
2994
- cachedTables = {};
2995
- convert;
2996
- constructor(casing) {
2997
- this.convert = casing === "snake_case" ? toSnakeCase : casing === "camelCase" ? toCamelCase : noopCase;
2998
- }
2999
- getColumnCasing(column) {
3000
- if (!column.keyAsName)
3001
- return column.name;
3002
- const schema = column.table[Table.Symbol.Schema] ?? "public";
3003
- const tableName = column.table[Table.Symbol.OriginalName];
3004
- const key = `${schema}.${tableName}.${column.name}`;
3005
- if (!this.cache[key]) {
3006
- this.cacheTable(column.table);
3007
- }
3008
- return this.cache[key];
3009
- }
3010
- cacheTable(table) {
3011
- const schema = table[Table.Symbol.Schema] ?? "public";
3012
- const tableName = table[Table.Symbol.OriginalName];
3013
- const tableKey = `${schema}.${tableName}`;
3014
- if (!this.cachedTables[tableKey]) {
3015
- for (const column of Object.values(table[Table.Symbol.Columns])) {
3016
- const columnKey = `${tableKey}.${column.name}`;
3017
- this.cache[columnKey] = this.convert(column.name);
3018
- }
3019
- this.cachedTables[tableKey] = true;
3020
- }
3021
- }
3022
- clearCache() {
3023
- this.cache = {};
3024
- this.cachedTables = {};
3025
- }
3026
- }
3027
-
3028
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/errors.js
3029
- class DrizzleError extends Error {
3030
- static [entityKind] = "DrizzleError";
3031
- constructor({ message, cause }) {
3032
- super(message);
3033
- this.name = "DrizzleError";
3034
- this.cause = cause;
3035
- }
3036
- }
3037
-
3038
- class TransactionRollbackError extends DrizzleError {
3039
- static [entityKind] = "TransactionRollbackError";
3040
- constructor() {
3041
- super({ message: "Rollback" });
3042
- }
3043
- }
3044
-
3045
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/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
3046
2928
  class PgDate extends PgColumn {
3047
2929
  static [entityKind] = "PgDate";
3048
2930
  getSQLType() {
@@ -3062,7 +2944,7 @@ class PgDateString extends PgColumn {
3062
2944
  }
3063
2945
  }
3064
2946
 
3065
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/pg-core/columns/json.js
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
3066
2948
  class PgJson extends PgColumn {
3067
2949
  static [entityKind] = "PgJson";
3068
2950
  constructor(table, config) {
@@ -3086,7 +2968,7 @@ class PgJson extends PgColumn {
3086
2968
  }
3087
2969
  }
3088
2970
 
3089
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/pg-core/columns/jsonb.js
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
3090
2972
  class PgJsonb extends PgColumn {
3091
2973
  static [entityKind] = "PgJsonb";
3092
2974
  constructor(table, config) {
@@ -3110,7 +2992,7 @@ class PgJsonb extends PgColumn {
3110
2992
  }
3111
2993
  }
3112
2994
 
3113
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/pg-core/columns/numeric.js
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
3114
2996
  class PgNumeric extends PgColumn {
3115
2997
  static [entityKind] = "PgNumeric";
3116
2998
  precision;
@@ -3136,7 +3018,7 @@ class PgNumeric extends PgColumn {
3136
3018
  }
3137
3019
  }
3138
3020
 
3139
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/pg-core/columns/time.js
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
3140
3022
  class PgTime extends PgColumn {
3141
3023
  static [entityKind] = "PgTime";
3142
3024
  withTimezone;
@@ -3152,7 +3034,7 @@ class PgTime extends PgColumn {
3152
3034
  }
3153
3035
  }
3154
3036
 
3155
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/pg-core/columns/timestamp.js
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
3156
3038
  class PgTimestamp extends PgColumn {
3157
3039
  static [entityKind] = "PgTimestamp";
3158
3040
  withTimezone;
@@ -3188,7 +3070,7 @@ class PgTimestampString extends PgColumn {
3188
3070
  }
3189
3071
  }
3190
3072
 
3191
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/pg-core/columns/uuid.js
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
3192
3074
  class PgUUID extends PgColumn {
3193
3075
  static [entityKind] = "PgUUID";
3194
3076
  getSQLType() {
@@ -3196,7 +3078,7 @@ class PgUUID extends PgColumn {
3196
3078
  }
3197
3079
  }
3198
3080
 
3199
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/pg-core/table.js
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
3200
3082
  var InlineForeignKeys = Symbol.for("drizzle:PgInlineForeignKeys");
3201
3083
  var EnableRLS = Symbol.for("drizzle:EnableRLS");
3202
3084
 
@@ -3212,7 +3094,7 @@ class PgTable extends Table {
3212
3094
  [Table.Symbol.ExtraConfigColumns] = {};
3213
3095
  }
3214
3096
 
3215
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/pg-core/primary-keys.js
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
3216
3098
  class PrimaryKeyBuilder {
3217
3099
  static [entityKind] = "PgPrimaryKeyBuilder";
3218
3100
  columns;
@@ -3240,7 +3122,77 @@ class PrimaryKey {
3240
3122
  }
3241
3123
  }
3242
3124
 
3243
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/sql/expressions/conditions.js
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
3244
3196
  function bindIfParam(value, column) {
3245
3197
  if (isDriverValueEncoder(column) && !isSQLWrapper(value) && !is(value, Param) && !is(value, Placeholder) && !is(value, Column) && !is(value, Table) && !is(value, View)) {
3246
3198
  return new Param(value, column);
@@ -3345,7 +3297,7 @@ function notIlike(column, value) {
3345
3297
  return sql`${column} not ilike ${value}`;
3346
3298
  }
3347
3299
 
3348
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/sql/expressions/select.js
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
3349
3301
  function asc(column) {
3350
3302
  return sql`${column} asc`;
3351
3303
  }
@@ -3353,7 +3305,7 @@ function desc(column) {
3353
3305
  return sql`${column} desc`;
3354
3306
  }
3355
3307
 
3356
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/relations.js
3308
+ // ../../node_modules/.pnpm/drizzle-orm@0.44.0_bun-types@1.2.15_postgres@3.4.7/node_modules/drizzle-orm/relations.js
3357
3309
  class Relation {
3358
3310
  constructor(sourceTable, referencedTable, relationName) {
3359
3311
  this.sourceTable = sourceTable;
@@ -3573,12 +3525,12 @@ function mapRelationalRow(tablesConfig, tableConfig, row, buildQueryResultSelect
3573
3525
  return result;
3574
3526
  }
3575
3527
 
3576
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/pg-core/view-base.js
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
3577
3529
  class PgViewBase extends View {
3578
3530
  static [entityKind] = "PgViewBase";
3579
3531
  }
3580
3532
 
3581
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/pg-core/dialect.js
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
3582
3534
  class PgDialect {
3583
3535
  static [entityKind] = "PgDialect";
3584
3536
  casing;
@@ -4136,7 +4088,7 @@ class PgDialect {
4136
4088
  }
4137
4089
  }
4138
4090
 
4139
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/query-builders/query-builder.js
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
4140
4092
  class TypedQueryBuilder {
4141
4093
  static [entityKind] = "TypedQueryBuilder";
4142
4094
  getSelectedFields() {
@@ -4144,7 +4096,7 @@ class TypedQueryBuilder {
4144
4096
  }
4145
4097
  }
4146
4098
 
4147
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/pg-core/query-builders/select.js
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
4148
4100
  class PgSelectBuilder {
4149
4101
  static [entityKind] = "PgSelectBuilder";
4150
4102
  fields;
@@ -4202,6 +4154,8 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
4202
4154
  isPartialSelect;
4203
4155
  session;
4204
4156
  dialect;
4157
+ cacheConfig = undefined;
4158
+ usedTables = /* @__PURE__ */ new Set;
4205
4159
  constructor({ table, fields, isPartialSelect, session, dialect, withList, distinct }) {
4206
4160
  super();
4207
4161
  this.config = {
@@ -4215,15 +4169,23 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
4215
4169
  this.session = session;
4216
4170
  this.dialect = dialect;
4217
4171
  this._ = {
4218
- selectedFields: fields
4172
+ selectedFields: fields,
4173
+ config: this.config
4219
4174
  };
4220
4175
  this.tableName = getTableLikeName(table);
4221
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];
4222
4182
  }
4223
4183
  createJoin(joinType, lateral) {
4224
4184
  return (table, on) => {
4225
4185
  const baseTableName = this.tableName;
4226
4186
  const tableName = getTableLikeName(table);
4187
+ for (const item of extractUsedTable(table))
4188
+ this.usedTables.add(item);
4227
4189
  if (typeof tableName === "string" && this.config.joins?.some((join) => join.alias === tableName)) {
4228
4190
  throw new Error(`Alias "${tableName}" is already used in this query`);
4229
4191
  }
@@ -4369,7 +4331,13 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
4369
4331
  return rest;
4370
4332
  }
4371
4333
  as(alias) {
4372
- return new Proxy(new Subquery(this.getSQL(), this.config.fields, alias), new SelectionProxyHandler({ alias, sqlAliasedBehavior: "alias", sqlBehavior: "error" }));
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" }));
4373
4341
  }
4374
4342
  getSelectedFields() {
4375
4343
  return new Proxy(this.config.fields, new SelectionProxyHandler({ alias: this.tableName, sqlAliasedBehavior: "alias", sqlBehavior: "error" }));
@@ -4377,18 +4345,26 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
4377
4345
  $dynamic() {
4378
4346
  return this;
4379
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
+ }
4380
4352
  }
4381
4353
 
4382
4354
  class PgSelectBase extends PgSelectQueryBuilderBase {
4383
4355
  static [entityKind] = "PgSelect";
4384
4356
  _prepare(name) {
4385
- const { session, config, dialect, joinsNotNullableMap, authToken } = this;
4357
+ const { session, config, dialect, joinsNotNullableMap, authToken, cacheConfig, usedTables } = this;
4386
4358
  if (!session) {
4387
4359
  throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");
4388
4360
  }
4361
+ const { fields } = config;
4389
4362
  return tracer.startActiveSpan("drizzle.prepareQuery", () => {
4390
- const fieldsList = orderSelectedFields(config.fields);
4391
- 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);
4392
4368
  query.joinsNotNullableMap = joinsNotNullableMap;
4393
4369
  return query.setToken(authToken);
4394
4370
  });
@@ -4438,7 +4414,7 @@ var intersectAll = createSetOperator("intersect", true);
4438
4414
  var except = createSetOperator("except", false);
4439
4415
  var exceptAll = createSetOperator("except", true);
4440
4416
 
4441
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/pg-core/query-builders/query-builder.js
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
4442
4418
  class QueryBuilder {
4443
4419
  static [entityKind] = "PgQueryBuilder";
4444
4420
  dialect;
@@ -4516,7 +4492,81 @@ class QueryBuilder {
4516
4492
  }
4517
4493
  }
4518
4494
 
4519
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/pg-core/query-builders/insert.js
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
4520
4570
  class PgInsertBuilder {
4521
4571
  constructor(table, session, dialect, withList, overridingSystemValue_) {
4522
4572
  this.table = table;
@@ -4569,6 +4619,7 @@ class PgInsertBase extends QueryPromise {
4569
4619
  }
4570
4620
  static [entityKind] = "PgInsert";
4571
4621
  config;
4622
+ cacheConfig;
4572
4623
  returning(fields = this.config.table[Table.Symbol.Columns]) {
4573
4624
  this.config.returningFields = fields;
4574
4625
  this.config.returning = orderSelectedFields(fields);
@@ -4607,7 +4658,10 @@ class PgInsertBase extends QueryPromise {
4607
4658
  }
4608
4659
  _prepare(name) {
4609
4660
  return tracer.startActiveSpan("drizzle.prepareQuery", () => {
4610
- 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);
4611
4665
  });
4612
4666
  }
4613
4667
  prepare(name) {
@@ -4635,7 +4689,7 @@ class PgInsertBase extends QueryPromise {
4635
4689
  }
4636
4690
  }
4637
4691
 
4638
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/pg-core/query-builders/refresh-materialized-view.js
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
4639
4693
  class PgRefreshMaterializedView extends QueryPromise {
4640
4694
  constructor(view, session, dialect) {
4641
4695
  super();
@@ -4686,7 +4740,7 @@ class PgRefreshMaterializedView extends QueryPromise {
4686
4740
  };
4687
4741
  }
4688
4742
 
4689
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/pg-core/query-builders/update.js
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
4690
4744
  class PgUpdateBuilder {
4691
4745
  constructor(table, session, dialect, withList) {
4692
4746
  this.table = table;
@@ -4718,6 +4772,7 @@ class PgUpdateBase extends QueryPromise {
4718
4772
  config;
4719
4773
  tableName;
4720
4774
  joinsNotNullableMap;
4775
+ cacheConfig;
4721
4776
  from(source) {
4722
4777
  const src = source;
4723
4778
  const tableName = getTableLikeName(src);
@@ -4809,7 +4864,10 @@ class PgUpdateBase extends QueryPromise {
4809
4864
  return rest;
4810
4865
  }
4811
4866
  _prepare(name) {
4812
- 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);
4813
4871
  query.joinsNotNullableMap = this.joinsNotNullableMap;
4814
4872
  return query;
4815
4873
  }
@@ -4836,7 +4894,7 @@ class PgUpdateBase extends QueryPromise {
4836
4894
  }
4837
4895
  }
4838
4896
 
4839
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/pg-core/query-builders/count.js
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
4840
4898
  class PgCountBuilder extends SQL {
4841
4899
  constructor(params) {
4842
4900
  super(PgCountBuilder.buildEmbeddedCount(params.source, params.filters).queryChunks);
@@ -4877,7 +4935,7 @@ class PgCountBuilder extends SQL {
4877
4935
  }
4878
4936
  }
4879
4937
 
4880
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/pg-core/query-builders/query.js
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
4881
4939
  class RelationalQueryBuilder {
4882
4940
  constructor(fullSchema, schema, tableNamesMap, table, tableConfig, dialect, session) {
4883
4941
  this.fullSchema = fullSchema;
@@ -4960,7 +5018,7 @@ class PgRelationalQuery extends QueryPromise {
4960
5018
  }
4961
5019
  }
4962
5020
 
4963
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/pg-core/query-builders/raw.js
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
4964
5022
  class PgRaw extends QueryPromise {
4965
5023
  constructor(execute, sql2, query, mapBatchResult) {
4966
5024
  super();
@@ -4987,7 +5045,7 @@ class PgRaw extends QueryPromise {
4987
5045
  }
4988
5046
  }
4989
5047
 
4990
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/pg-core/db.js
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
4991
5049
  class PgDatabase {
4992
5050
  constructor(dialect, session, schema) {
4993
5051
  this.dialect = dialect;
@@ -5009,6 +5067,7 @@ class PgDatabase {
5009
5067
  this.query[tableName] = new RelationalQueryBuilder(schema.fullSchema, this._.schema, this._.tableNamesMap, schema.fullSchema[tableName], columns, dialect, session);
5010
5068
  }
5011
5069
  }
5070
+ this.$cache = { invalidate: async (_params) => {} };
5012
5071
  }
5013
5072
  static [entityKind] = "PgDatabase";
5014
5073
  query;
@@ -5025,6 +5084,7 @@ class PgDatabase {
5025
5084
  $count(source, filters) {
5026
5085
  return new PgCountBuilder({ source, filters, session: this.session });
5027
5086
  }
5087
+ $cache;
5028
5088
  with(...queries) {
5029
5089
  const self = this;
5030
5090
  function select2(fields) {
@@ -5111,10 +5171,59 @@ class PgDatabase {
5111
5171
  }
5112
5172
  }
5113
5173
 
5114
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/pg-core/session.js
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
5115
5215
  class PgPreparedQuery {
5116
- constructor(query) {
5216
+ constructor(query, cache, queryMetadata, cacheConfig) {
5117
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
+ }
5118
5227
  }
5119
5228
  authToken;
5120
5229
  getQuery() {
@@ -5129,6 +5238,59 @@ class PgPreparedQuery {
5129
5238
  }
5130
5239
  static [entityKind] = "PgPreparedQuery";
5131
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
+ }
5132
5294
  }
5133
5295
 
5134
5296
  class PgSession {
@@ -5181,10 +5343,10 @@ class PgTransaction extends PgDatabase {
5181
5343
  }
5182
5344
  }
5183
5345
 
5184
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/postgres-js/session.js
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
5185
5347
  class PostgresJsPreparedQuery extends PgPreparedQuery {
5186
- constructor(client, queryString, params, logger, fields, _isResponseInArrayMode, customResultMapper) {
5187
- super({ sql: queryString, params });
5348
+ constructor(client, queryString, params, logger, cache, queryMetadata, cacheConfig, fields, _isResponseInArrayMode, customResultMapper) {
5349
+ super({ sql: queryString, params }, cache, queryMetadata, cacheConfig);
5188
5350
  this.client = client;
5189
5351
  this.queryString = queryString;
5190
5352
  this.params = params;
@@ -5205,7 +5367,9 @@ class PostgresJsPreparedQuery extends PgPreparedQuery {
5205
5367
  const { fields, queryString: query, client, joinsNotNullableMap, customResultMapper } = this;
5206
5368
  if (!fields && !customResultMapper) {
5207
5369
  return tracer.startActiveSpan("drizzle.driver.execute", () => {
5208
- return client.unsafe(query, params);
5370
+ return this.queryWithCache(query, params, async () => {
5371
+ return await client.unsafe(query, params);
5372
+ });
5209
5373
  });
5210
5374
  }
5211
5375
  const rows = await tracer.startActiveSpan("drizzle.driver.execute", () => {
@@ -5213,7 +5377,9 @@ class PostgresJsPreparedQuery extends PgPreparedQuery {
5213
5377
  "drizzle.query.text": query,
5214
5378
  "drizzle.query.params": JSON.stringify(params)
5215
5379
  });
5216
- return client.unsafe(query, params).values();
5380
+ return this.queryWithCache(query, params, async () => {
5381
+ return await client.unsafe(query, params).values();
5382
+ });
5217
5383
  });
5218
5384
  return tracer.startActiveSpan("drizzle.mapResponse", () => {
5219
5385
  return customResultMapper ? customResultMapper(rows) : rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
@@ -5233,7 +5399,9 @@ class PostgresJsPreparedQuery extends PgPreparedQuery {
5233
5399
  "drizzle.query.text": this.queryString,
5234
5400
  "drizzle.query.params": JSON.stringify(params)
5235
5401
  });
5236
- return this.client.unsafe(this.queryString, params);
5402
+ return this.queryWithCache(this.queryString, params, async () => {
5403
+ return this.client.unsafe(this.queryString, params);
5404
+ });
5237
5405
  });
5238
5406
  });
5239
5407
  }
@@ -5249,11 +5417,13 @@ class PostgresJsSession extends PgSession {
5249
5417
  this.schema = schema;
5250
5418
  this.options = options;
5251
5419
  this.logger = options.logger ?? new NoopLogger;
5420
+ this.cache = options.cache ?? new NoopCache;
5252
5421
  }
5253
5422
  static [entityKind] = "PostgresJsSession";
5254
5423
  logger;
5255
- prepareQuery(query, fields, name, isResponseInArrayMode, customResultMapper) {
5256
- return new PostgresJsPreparedQuery(this.client, query.sql, query.params, this.logger, fields, isResponseInArrayMode, customResultMapper);
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);
5257
5427
  }
5258
5428
  query(query, params) {
5259
5429
  this.logger.logQuery(query, params);
@@ -5289,7 +5459,7 @@ class PostgresJsTransaction extends PgTransaction {
5289
5459
  }
5290
5460
  }
5291
5461
 
5292
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/postgres-js/driver.js
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
5293
5463
  class PostgresJsDatabase extends PgDatabase {
5294
5464
  static [entityKind] = "PostgresJsDatabase";
5295
5465
  }
@@ -5317,9 +5487,13 @@ function construct(client, config = {}) {
5317
5487
  tableNamesMap: tablesConfig.tableNamesMap
5318
5488
  };
5319
5489
  }
5320
- const session = new PostgresJsSession(client, dialect, schema, { logger });
5490
+ const session = new PostgresJsSession(client, dialect, schema, { logger, cache: config.cache });
5321
5491
  const db = new PostgresJsDatabase(dialect, session, schema);
5322
5492
  db.$client = client;
5493
+ db.$cache = config.cache;
5494
+ if (db.$cache) {
5495
+ db.$cache["invalidate"] = config.cache?.onMutate;
5496
+ }
5323
5497
  return db;
5324
5498
  }
5325
5499
  function drizzle(...params) {
@@ -5353,8 +5527,8 @@ function drizzle(...params) {
5353
5527
  drizzle2.mock = mock;
5354
5528
  })(drizzle || (drizzle = {}));
5355
5529
 
5356
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/migrator.js
5357
- import crypto2 from "crypto";
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";
5358
5532
  import fs2 from "fs";
5359
5533
  function readMigrationFiles(config) {
5360
5534
  const migrationFolderTo = config.migrationsFolder;
@@ -5376,7 +5550,7 @@ function readMigrationFiles(config) {
5376
5550
  sql: result,
5377
5551
  bps: journalEntry.breakpoints,
5378
5552
  folderMillis: journalEntry.when,
5379
- hash: crypto2.createHash("sha256").update(query).digest("hex")
5553
+ hash: crypto3.createHash("sha256").update(query).digest("hex")
5380
5554
  });
5381
5555
  } catch {
5382
5556
  throw new Error(`No file ${migrationPath} found in ${migrationFolderTo} folder`);
@@ -5385,13 +5559,13 @@ function readMigrationFiles(config) {
5385
5559
  return migrationQueries;
5386
5560
  }
5387
5561
 
5388
- // ../../node_modules/.pnpm/drizzle-orm@0.43.1_bun-types@1.2.14_postgres@3.4.7/node_modules/drizzle-orm/postgres-js/migrator.js
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
5389
5563
  async function migrate(db, config) {
5390
5564
  const migrations = readMigrationFiles(config);
5391
5565
  await db.dialect.migrate(migrations, db.session, config);
5392
5566
  }
5393
5567
 
5394
- // ../../node_modules/.pnpm/@t3-oss+env-core@0.13.4_arktype@2.1.20_typescript@5.8.3_valibot@1.0.0_typescript@5.8.3__zod@3.25.30/node_modules/@t3-oss/env-core/dist/src-Cq4nGjdj.js
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
5395
5569
  function ensureSynchronous(value, message) {
5396
5570
  if (value instanceof Promise)
5397
5571
  throw new Error(message);
@@ -5405,6 +5579,7 @@ function parseWithDictionary(dictionary, value) {
5405
5579
  if (propResult.issues) {
5406
5580
  issues.push(...propResult.issues.map((issue) => ({
5407
5581
  ...issue,
5582
+ message: issue.message,
5408
5583
  path: [key, ...issue.path ?? []]
5409
5584
  })));
5410
5585
  continue;