bun-query-builder 0.2.26 → 0.2.27

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/dist/src/index.js CHANGED
@@ -3048,25 +3048,27 @@ var init_dynamodb = __esm(() => {
3048
3048
 
3049
3049
  // ../../node_modules/bunfig/dist/index.js
3050
3050
  import { existsSync, statSync } from "fs";
3051
+ import { resolve } from "path";
3052
+ import process2 from "process";
3051
3053
  import { existsSync as existsSync13, mkdirSync as mkdirSync4, readdirSync as readdirSync4, readFileSync, writeFileSync as writeFileSync7 } from "fs";
3052
3054
  import { homedir as homedir3 } from "os";
3053
3055
  import { dirname as dirname4, resolve as resolve12 } from "path";
3054
3056
  import process20 from "process";
3055
- import { existsSync as existsSync2, statSync as statSync2 } from "fs";
3057
+ import { existsSync as existsSync3, statSync as statSync2 } from "fs";
3056
3058
  import { existsSync as existsSync8, mkdirSync as mkdirSync3, readdirSync as readdirSync3, writeFileSync as writeFileSync5 } from "fs";
3057
3059
  import { homedir as homedir2 } from "os";
3058
3060
  import { dirname as dirname3, resolve as resolve7 } from "path";
3059
3061
  import process12 from "process";
3060
3062
  import { join as join3, relative as relative2, resolve as resolve4 } from "path";
3061
3063
  import process7 from "process";
3062
- import { existsSync as existsSync3, mkdirSync as mkdirSync2, readdirSync as readdirSync2, writeFileSync as writeFileSync3 } from "fs";
3064
+ import { existsSync as existsSync32, mkdirSync as mkdirSync2, readdirSync as readdirSync2, writeFileSync as writeFileSync3 } from "fs";
3063
3065
  import { homedir } from "os";
3064
3066
  import { dirname as dirname2, resolve as resolve3 } from "path";
3065
3067
  import process6 from "process";
3066
3068
  import { join, relative, resolve as resolve2 } from "path";
3067
- import process2 from "process";
3069
+ import process22 from "process";
3068
3070
  import { existsSync as existsSync22, mkdirSync, readdirSync, writeFileSync } from "fs";
3069
- import { dirname, resolve } from "path";
3071
+ import { dirname, resolve as resolve5 } from "path";
3070
3072
  import process3 from "process";
3071
3073
  import { Buffer as Buffer2 } from "buffer";
3072
3074
  import { createCipheriv, createDecipheriv, randomBytes } from "crypto";
@@ -3090,7 +3092,7 @@ import process10 from "process";
3090
3092
  import process9 from "process";
3091
3093
  import process8 from "process";
3092
3094
  import { existsSync as existsSync5 } from "fs";
3093
- import { resolve as resolve5 } from "path";
3095
+ import { resolve as resolve52 } from "path";
3094
3096
  import { existsSync as existsSync7 } from "fs";
3095
3097
  import { existsSync as existsSync9, readdirSync as readdirSync5 } from "fs";
3096
3098
  import { extname, resolve as resolve8 } from "path";
@@ -3350,6 +3352,34 @@ class PerformanceMonitor {
3350
3352
  return this.metrics.filter((m) => m.duration > threshold);
3351
3353
  }
3352
3354
  }
3355
+ function getConfigNamePatterns(options = {}) {
3356
+ const { name = "", alias } = options;
3357
+ const patterns = ["config", ".config"];
3358
+ if (name)
3359
+ patterns.push(name, `.${name}.config`, `${name}.config`, `.${name}`);
3360
+ const aliases = alias === undefined ? [] : Array.isArray(alias) ? alias : [alias];
3361
+ for (const alternative of aliases) {
3362
+ if (!alternative)
3363
+ continue;
3364
+ patterns.push(alternative, `.${alternative}.config`, `${alternative}.config`, `.${alternative}`);
3365
+ if (name)
3366
+ patterns.push(`${name}.${alternative}.config`, `.${name}.${alternative}.config`);
3367
+ }
3368
+ return Array.from(new Set(patterns.filter(Boolean)));
3369
+ }
3370
+ function getConfigPaths(options) {
3371
+ const patterns = getConfigNamePatterns(options);
3372
+ return patterns.flatMap((pattern) => CONFIG_FILE_EXTENSIONS.map((extension) => resolve(options.directory, `${pattern}${extension}`)));
3373
+ }
3374
+ function getLocalConfigDirectories(options = {}) {
3375
+ const cwd = resolve(options.cwd || process2.cwd());
3376
+ return Array.from(new Set([
3377
+ cwd,
3378
+ resolve(cwd, "config"),
3379
+ resolve(cwd, ".config"),
3380
+ options.configDir ? resolve(cwd, options.configDir) : undefined
3381
+ ].filter((directory) => Boolean(directory))));
3382
+ }
3353
3383
  function __exportSetter2(name, newValue) {
3354
3384
  this[name] = __returnValue2.bind(null, newValue);
3355
3385
  }
@@ -3433,7 +3463,7 @@ class ConfigCache2 {
3433
3463
  }
3434
3464
  isFileModified(configPath, cachedTimestamp) {
3435
3465
  try {
3436
- if (!existsSync2(configPath)) {
3466
+ if (!existsSync3(configPath)) {
3437
3467
  return true;
3438
3468
  }
3439
3469
  const stats = statSync2(configPath);
@@ -3455,7 +3485,7 @@ class ConfigCache2 {
3455
3485
  }
3456
3486
  setWithFileCheck(configName, value, configPath, customTtl) {
3457
3487
  try {
3458
- const stats = existsSync2(configPath) ? statSync2(configPath) : null;
3488
+ const stats = existsSync3(configPath) ? statSync2(configPath) : null;
3459
3489
  const fileTimestamp = stats ? stats.mtime : new Date;
3460
3490
  this.set(configName, { value, fileTimestamp }, configPath, customTtl);
3461
3491
  } catch {
@@ -3765,7 +3795,7 @@ async function loadConfig({
3765
3795
  ];
3766
3796
  for (const configPath of configPaths) {
3767
3797
  for (const ext of extensions) {
3768
- const fullPath = resolve(baseDir, `${configPath}${ext}`);
3798
+ const fullPath = resolve5(baseDir, `${configPath}${ext}`);
3769
3799
  const config2 = await tryLoadConfig(fullPath, defaultConfig);
3770
3800
  if (config2 !== null) {
3771
3801
  return config2;
@@ -3773,7 +3803,7 @@ async function loadConfig({
3773
3803
  }
3774
3804
  }
3775
3805
  try {
3776
- const pkgPath = resolve(baseDir, "package.json");
3806
+ const pkgPath = resolve5(baseDir, "package.json");
3777
3807
  if (existsSync22(pkgPath)) {
3778
3808
  const pkg = await import(pkgPath);
3779
3809
  const pkgConfig = pkg[name];
@@ -3787,12 +3817,12 @@ async function loadConfig({
3787
3817
  return defaultConfig;
3788
3818
  }
3789
3819
  function getProjectRoot(filePath, options = {}) {
3790
- let path = process2.cwd();
3820
+ let path = process22.cwd();
3791
3821
  while (path.includes("storage"))
3792
3822
  path = resolve2(path, "..");
3793
3823
  const finalPath = resolve2(path, filePath || "");
3794
3824
  if (options?.relative)
3795
- return relative(process2.cwd(), finalPath);
3825
+ return relative(process22.cwd(), finalPath);
3796
3826
  return finalPath;
3797
3827
  }
3798
3828
  async function loadConfig2() {
@@ -3800,7 +3830,7 @@ async function loadConfig2() {
3800
3830
  const loadedConfig = await loadConfig({
3801
3831
  name: "clarity",
3802
3832
  defaultConfig,
3803
- cwd: process2.cwd(),
3833
+ cwd: process22.cwd(),
3804
3834
  endpoint: "",
3805
3835
  headers: {}
3806
3836
  });
@@ -5142,7 +5172,7 @@ function isObject2(item) {
5142
5172
  return Boolean(item && typeof item === "object" && !Array.isArray(item));
5143
5173
  }
5144
5174
  async function tryLoadConfig2(configPath, defaultConfig2, arrayStrategy = "replace") {
5145
- if (!existsSync3(configPath))
5175
+ if (!existsSync32(configPath))
5146
5176
  return null;
5147
5177
  try {
5148
5178
  const importedConfig = await import(configPath);
@@ -5313,7 +5343,7 @@ async function loadConfig3({
5313
5343
  }
5314
5344
  try {
5315
5345
  const pkgPath = resolve3(baseDir, "package.json");
5316
- if (existsSync3(pkgPath)) {
5346
+ if (existsSync32(pkgPath)) {
5317
5347
  const pkg = await import(pkgPath);
5318
5348
  let pkgConfig = pkg[name];
5319
5349
  if (!pkgConfig && alias) {
@@ -5604,7 +5634,7 @@ class Logger2 {
5604
5634
  const errorMessage = typeof error.message === "string" ? error.message : "Unknown error";
5605
5635
  console.error(`Network error during write attempt ${retries + 1}/${maxRetries}:`, errorMessage);
5606
5636
  const delay = backoffDelay * 2 ** retries;
5607
- await new Promise((resolve52) => setTimeout(resolve52, delay));
5637
+ await new Promise((resolve522) => setTimeout(resolve522, delay));
5608
5638
  retries++;
5609
5639
  continue;
5610
5640
  }
@@ -5632,7 +5662,7 @@ class Logger2 {
5632
5662
  }
5633
5663
  retries++;
5634
5664
  const delay = backoffDelay * 2 ** (retries - 1);
5635
- await new Promise((resolve52) => setTimeout(resolve52, delay));
5665
+ await new Promise((resolve522) => setTimeout(resolve522, delay));
5636
5666
  }
5637
5667
  }
5638
5668
  })();
@@ -5762,11 +5792,11 @@ class Logger2 {
5762
5792
  };
5763
5793
  }
5764
5794
  async compressData(data) {
5765
- return new Promise((resolve52, reject) => {
5795
+ return new Promise((resolve522, reject) => {
5766
5796
  const gzip = createGzip2();
5767
5797
  const chunks = [];
5768
5798
  gzip.on("data", (chunk2) => chunks.push(chunk2));
5769
- gzip.on("end", () => resolve52(Buffer22.from(Buffer22.concat(chunks))));
5799
+ gzip.on("end", () => resolve522(Buffer22.from(Buffer22.concat(chunks))));
5770
5800
  gzip.on("error", reject);
5771
5801
  gzip.write(data);
5772
5802
  gzip.end();
@@ -6455,7 +6485,7 @@ class Logger2 {
6455
6485
  if (isBrowserProcess2()) {
6456
6486
  return Promise.resolve(true);
6457
6487
  }
6458
- return new Promise((resolve52) => {
6488
+ return new Promise((resolve522) => {
6459
6489
  console.error(`${styles2.cyan("?")} ${message} (y/n) `);
6460
6490
  const onData = (data) => {
6461
6491
  const input = data.toString().trim().toLowerCase();
@@ -6467,7 +6497,7 @@ class Logger2 {
6467
6497
  } catch {}
6468
6498
  process11.stdin.pause();
6469
6499
  console.error("");
6470
- resolve52(input === "y" || input === "yes");
6500
+ resolve522(input === "y" || input === "yes");
6471
6501
  };
6472
6502
  try {
6473
6503
  if (typeof process11.stdin.setRawMode === "function") {
@@ -6633,7 +6663,7 @@ async function withErrorRecovery(fn, options = {}) {
6633
6663
  break;
6634
6664
  }
6635
6665
  if (retryDelay > 0) {
6636
- await new Promise((resolve52) => setTimeout(resolve52, retryDelay));
6666
+ await new Promise((resolve522) => setTimeout(resolve522, retryDelay));
6637
6667
  }
6638
6668
  }
6639
6669
  }
@@ -7161,7 +7191,7 @@ class ConfigFileLoader {
7161
7191
  const paths = [];
7162
7192
  for (const pattern of patterns) {
7163
7193
  for (const ext of this.extensions) {
7164
- paths.push(resolve5(directory, `${pattern}${ext}`));
7194
+ paths.push(resolve52(directory, `${pattern}${ext}`));
7165
7195
  }
7166
7196
  }
7167
7197
  return paths;
@@ -7198,7 +7228,7 @@ class ConfigFileLoader {
7198
7228
  const patterns = this.generateNamePatterns(configName || "", alias);
7199
7229
  for (const pattern of patterns) {
7200
7230
  for (const ext of this.extensions) {
7201
- const filePath = resolve5(directory, `${pattern}${ext}`);
7231
+ const filePath = resolve52(directory, `${pattern}${ext}`);
7202
7232
  if (await this.checkFileAccess(filePath)) {
7203
7233
  discoveredFiles.push(filePath);
7204
7234
  }
@@ -7210,7 +7240,7 @@ class ConfigFileLoader {
7210
7240
  const files = readdirSync32(directory);
7211
7241
  for (const file of files) {
7212
7242
  if (this.looksLikeConfigFile(file)) {
7213
- const filePath = resolve5(directory, file);
7243
+ const filePath = resolve52(directory, file);
7214
7244
  if (await this.checkFileAccess(filePath)) {
7215
7245
  discoveredFiles.push(filePath);
7216
7246
  }
@@ -9935,7 +9965,7 @@ function isObject4(item) {
9935
9965
  }
9936
9966
 
9937
9967
  class ConfigFileLoader2 {
9938
- extensions = [".ts", ".js", ".mjs", ".cjs", ".json", ".mts", ".cts"];
9968
+ extensions = CONFIG_FILE_EXTENSIONS;
9939
9969
  async loadFromPath(configPath, defaultConfig4, options = {}) {
9940
9970
  const {
9941
9971
  arrayStrategy = "replace",
@@ -10010,37 +10040,10 @@ class ConfigFileLoader2 {
10010
10040
  return null;
10011
10041
  }
10012
10042
  generateConfigPaths(configName, directory, alias) {
10013
- const patterns = this.generateNamePatterns(configName, alias);
10014
- const paths = [];
10015
- for (const pattern of patterns) {
10016
- for (const ext of this.extensions) {
10017
- paths.push(resolve10(directory, `${pattern}${ext}`));
10018
- }
10019
- }
10020
- return paths;
10043
+ return getConfigPaths({ name: configName, directory, alias });
10021
10044
  }
10022
10045
  generateNamePatterns(configName, alias) {
10023
- const patterns = [];
10024
- patterns.push("config", ".config");
10025
- if (configName) {
10026
- patterns.push(configName, `.${configName}.config`, `${configName}.config`, `.${configName}`);
10027
- }
10028
- const aliases = alias === undefined ? [] : Array.isArray(alias) ? alias : [alias];
10029
- for (const a of aliases) {
10030
- if (!a)
10031
- continue;
10032
- patterns.push(a, `.${a}.config`, `${a}.config`, `.${a}`);
10033
- if (configName) {
10034
- patterns.push(`${configName}.${a}.config`, `.${configName}.${a}.config`);
10035
- }
10036
- }
10037
- const seen = new Set;
10038
- return patterns.filter((p) => {
10039
- if (!p || seen.has(p))
10040
- return false;
10041
- seen.add(p);
10042
- return true;
10043
- });
10046
+ return getConfigNamePatterns({ name: configName, alias });
10044
10047
  }
10045
10048
  checkFileAccess(filePath) {
10046
10049
  return withErrorRecovery2(async () => {
@@ -10551,6 +10554,8 @@ class ConfigLoader2 {
10551
10554
  try {
10552
10555
  result = await this.loadConfigurationStrategies(baseOptions, true, cache);
10553
10556
  } catch (error) {
10557
+ if (baseOptions.configFile)
10558
+ throw error;
10554
10559
  const isStrictMode = baseOptions.__strictErrorHandling;
10555
10560
  if (error instanceof Error && error.name === "ConfigNotFoundError") {
10556
10561
  if (isStrictMode) {
@@ -10625,6 +10630,7 @@ class ConfigLoader2 {
10625
10630
  const {
10626
10631
  name = "",
10627
10632
  alias,
10633
+ configFile,
10628
10634
  cwd,
10629
10635
  configDir,
10630
10636
  defaultConfig: defaultConfig4,
@@ -10634,6 +10640,17 @@ class ConfigLoader2 {
10634
10640
  } = options;
10635
10641
  const baseDir = cwd || process20.cwd();
10636
10642
  const searchPaths = [];
10643
+ if (configFile) {
10644
+ const explicitPath = resolve12(baseDir, configFile);
10645
+ searchPaths.push(explicitPath);
10646
+ const envDefaults = checkEnv ? applyEnvVarsToConfig3(name, defaultConfig4, verbose) : defaultConfig4;
10647
+ const explicitResult = await this.fileLoader.tryLoadFromPaths([explicitPath], envDefaults, { arrayStrategy, verbose, cacheTtl: cacheOptions?.ttl, useCache: !cacheOptions?.ttl || cacheOptions.ttl > 100 });
10648
+ if (!explicitResult)
10649
+ throw ErrorFactory2.configNotFound(name || configFile, searchPaths, alias);
10650
+ if (verbose)
10651
+ log3.success(`Configuration loaded from explicit path: ${explicitPath}`);
10652
+ return this.finalizeResult(explicitResult, searchPaths, checkEnv, name, verbose);
10653
+ }
10637
10654
  const localResult = await this.loadLocalConfiguration(name, alias, baseDir, configDir, defaultConfig4, arrayStrategy, verbose, checkEnv, cacheOptions);
10638
10655
  if (localResult) {
10639
10656
  searchPaths.push(...this.getLocalSearchPaths(name, alias, baseDir, configDir));
@@ -10821,6 +10838,8 @@ class ConfigLoader2 {
10821
10838
  }
10822
10839
  if (options.cwd)
10823
10840
  keyParts.push(`cwd:${options.cwd}`);
10841
+ if (options.configFile)
10842
+ keyParts.push(`configFile:${options.configFile}`);
10824
10843
  if (options.configDir)
10825
10844
  keyParts.push(`configDir:${options.configDir}`);
10826
10845
  if ("checkEnv" in options)
@@ -10828,12 +10847,7 @@ class ConfigLoader2 {
10828
10847
  return keyParts.join("|");
10829
10848
  }
10830
10849
  getLocalDirectories(baseDir, configDir) {
10831
- return Array.from(new Set([
10832
- baseDir,
10833
- resolve12(baseDir, "config"),
10834
- resolve12(baseDir, ".config"),
10835
- configDir ? resolve12(baseDir, configDir) : undefined
10836
- ].filter(Boolean)));
10850
+ return getLocalConfigDirectories({ cwd: baseDir, configDir });
10837
10851
  }
10838
10852
  getAllSearchPaths(name, alias, baseDir, configDir) {
10839
10853
  const paths = [];
@@ -10885,6 +10899,8 @@ async function loadConfig6(options) {
10885
10899
  }
10886
10900
  return result?.config ?? defaultConfig4;
10887
10901
  } catch (error) {
10902
+ if (options.configFile)
10903
+ throw error;
10888
10904
  const errorName = error instanceof Error ? error.name : "UnknownError";
10889
10905
  const errorMessage = error instanceof Error ? error.message : String(error);
10890
10906
  const isConfigError = errorName === "ConfigNotFoundError" || errorName === "ConfigLoadError" || errorName === "ConfigValidationError" || errorMessage.includes("config");
@@ -10952,7 +10968,7 @@ function applyEnvVarsToConfig3(name, config6, verbose = false) {
10952
10968
  }
10953
10969
  return processConfigLevel(config6);
10954
10970
  }
10955
- var globalCache, globalPerformanceMonitor, __defProp2, __returnValue2 = (v) => v, __export2 = (target, all) => {
10971
+ var globalCache, globalPerformanceMonitor, CONFIG_FILE_EXTENSIONS, __defProp2, __returnValue2 = (v) => v, __export2 = (target, all) => {
10956
10972
  for (var name in all)
10957
10973
  __defProp2(target, name, {
10958
10974
  get: all[name],
@@ -10964,6 +10980,15 @@ var globalCache, globalPerformanceMonitor, __defProp2, __returnValue2 = (v) => v
10964
10980
  var init_dist = __esm(() => {
10965
10981
  globalCache = new ConfigCache;
10966
10982
  globalPerformanceMonitor = new PerformanceMonitor;
10983
+ CONFIG_FILE_EXTENSIONS = [
10984
+ ".ts",
10985
+ ".js",
10986
+ ".mjs",
10987
+ ".cjs",
10988
+ ".json",
10989
+ ".mts",
10990
+ ".cts"
10991
+ ];
10967
10992
  __defProp2 = Object.defineProperty;
10968
10993
  exports_dist = {};
10969
10994
  __export2(exports_dist, {
@@ -11016,9 +11041,9 @@ var init_dist = __esm(() => {
11016
11041
  isEquivalent: isEquivalent2,
11017
11042
  estimateMemoryUsage: estimateMemoryUsage2
11018
11043
  };
11019
- defaultConfigDir = resolve(process3.cwd(), "config");
11020
- defaultGeneratedDir = resolve(process3.cwd(), "src/generated");
11021
- defaultLogDirectory = process2.env.CLARITY_LOG_DIR || join(getProjectRoot(), "logs");
11044
+ defaultConfigDir = resolve5(process3.cwd(), "config");
11045
+ defaultGeneratedDir = resolve5(process3.cwd(), "src/generated");
11046
+ defaultLogDirectory = process22.env.CLARITY_LOG_DIR || join(getProjectRoot(), "logs");
11022
11047
  defaultConfig = {
11023
11048
  level: "info",
11024
11049
  defaultName: "clarity",
@@ -11635,8 +11660,8 @@ var init_dist = __esm(() => {
11635
11660
  showTags: true
11636
11661
  });
11637
11662
  globalConfigLoader2 = new ConfigLoader2;
11638
- defaultConfigDir4 = resolve12(process20.cwd(), "config");
11639
- defaultGeneratedDir4 = resolve12(process20.cwd(), "src/generated");
11663
+ defaultConfigDir4 = /* @__PURE__ */ resolve12(process20.cwd(), "config");
11664
+ defaultGeneratedDir4 = /* @__PURE__ */ resolve12(process20.cwd(), "src/generated");
11640
11665
  });
11641
11666
 
11642
11667
  // src/config.ts
@@ -11960,12 +11985,12 @@ function createSQLiteSQL(filename) {
11960
11985
  const params = [];
11961
11986
  for (let i = 0;i < values.length; i++) {
11962
11987
  const value = values[i];
11963
- if (value && typeof value === "object" && (value.__raw || value.raw)) {
11964
- const rawValue = value.__raw ? value.value : typeof value.raw === "string" ? value.raw : value.raw();
11965
- sql += rawValue + (strings[i + 1] || "");
11966
- } else if (value && typeof value === "object" && "sql" in value && "values" in value) {
11988
+ if (value && typeof value === "object" && typeof value.sql === "string" && Array.isArray(value.values)) {
11967
11989
  sql += value.sql + (strings[i + 1] || "");
11968
11990
  params.push(...value.values);
11991
+ } else if (value && typeof value === "object" && (value.__raw || value.raw)) {
11992
+ const rawValue = value.__raw ? value.value : typeof value.raw === "string" ? value.raw : value.raw();
11993
+ sql += rawValue + (strings[i + 1] || "");
11969
11994
  } else if (Array.isArray(value)) {
11970
11995
  const placeholders = value.map(() => "?").join(", ");
11971
11996
  sql += placeholders + (strings[i + 1] || "");
@@ -12600,6 +12625,11 @@ function renderSelectColumn(col) {
12600
12625
  }
12601
12626
  throw new TypeError(`[query-builder] select(): unsupported column ${String(col)} \u2014 pass a column name, a string[], or a SQL fragment (e.g. sql\`count(*) as c\`)`);
12602
12627
  }
12628
+ function renderInPredicate(column, values, negated, placeholders) {
12629
+ if (values.length === 0)
12630
+ return negated ? TRUE_PREDICATE : FALSE_PREDICATE;
12631
+ return `${column} ${negated ? "NOT IN" : "IN"} (${placeholders})`;
12632
+ }
12603
12633
  function validateIdentifier(name, context) {
12604
12634
  if (!SQL_PATTERNS.IDENTIFIER.test(name)) {
12605
12635
  const contextMsg = context ? ` in ${context}` : "";
@@ -14317,8 +14347,12 @@ function createQueryBuilder(state) {
14317
14347
  return this;
14318
14348
  },
14319
14349
  whereAny(cols, op, value) {
14320
- if (cols.length === 0)
14350
+ if (cols.length === 0) {
14351
+ const kw = SQL_PATTERNS.WHERE.test(text) ? "AND" : "WHERE";
14352
+ text += ` ${kw} (${FALSE_PREDICATE})`;
14353
+ built = null;
14321
14354
  return this;
14355
+ }
14322
14356
  const keyword = SQL_PATTERNS.WHERE.test(text) ? "AND" : "WHERE";
14323
14357
  const idx = whereParams.length + 1;
14324
14358
  const conds = cols.map((c, i) => `${c} ${op} ${getPlaceholder(idx + i)}`);
@@ -14400,7 +14434,7 @@ function createQueryBuilder(state) {
14400
14434
  const keyword = SQL_PATTERNS.WHERE.test(text) ? "AND" : "WHERE";
14401
14435
  if (Array.isArray(values)) {
14402
14436
  const placeholders = getPlaceholders(values.length, whereParams.length + 1);
14403
- text += ` ${keyword} ${column} IN (${placeholders})`;
14437
+ text += ` ${keyword} ${renderInPredicate(column, values, false, placeholders)}`;
14404
14438
  whereParams.push(...values);
14405
14439
  } else {
14406
14440
  text += ` ${keyword} ${column} IN (${String(values.toSQL())})`;
@@ -14412,7 +14446,7 @@ function createQueryBuilder(state) {
14412
14446
  validateIdentifier(String(column), "orWhereIn(column)");
14413
14447
  if (Array.isArray(values)) {
14414
14448
  const placeholders = getPlaceholders(values.length, whereParams.length + 1);
14415
- text += ` OR ${column} IN (${placeholders})`;
14449
+ text += ` OR ${renderInPredicate(column, values, false, placeholders)}`;
14416
14450
  whereParams.push(...values);
14417
14451
  } else {
14418
14452
  text += ` OR ${column} IN (${String(values.toSQL())})`;
@@ -14425,7 +14459,7 @@ function createQueryBuilder(state) {
14425
14459
  const keyword = SQL_PATTERNS.WHERE.test(text) ? "AND" : "WHERE";
14426
14460
  if (Array.isArray(values)) {
14427
14461
  const placeholders = getPlaceholders(values.length, whereParams.length + 1);
14428
- text += ` ${keyword} ${column} NOT IN (${placeholders})`;
14462
+ text += ` ${keyword} ${renderInPredicate(column, values, true, placeholders)}`;
14429
14463
  whereParams.push(...values);
14430
14464
  } else {
14431
14465
  text += ` ${keyword} ${column} NOT IN (${String(values.toSQL())})`;
@@ -14437,7 +14471,7 @@ function createQueryBuilder(state) {
14437
14471
  validateIdentifier(String(column), "orWhereNotIn(column)");
14438
14472
  if (Array.isArray(values)) {
14439
14473
  const placeholders = getPlaceholders(values.length, whereParams.length + 1);
14440
- text += ` OR ${column} NOT IN (${placeholders})`;
14474
+ text += ` OR ${renderInPredicate(column, values, true, placeholders)}`;
14441
14475
  whereParams.push(...values);
14442
14476
  } else {
14443
14477
  text += ` OR ${column} NOT IN (${String(values.toSQL())})`;
@@ -16696,7 +16730,7 @@ function clearQueryCache() {
16696
16730
  function setQueryCacheMaxSize(size) {
16697
16731
  queryCache.setMaxSize(size);
16698
16732
  }
16699
- var SQL_PATTERNS, SAFE_WHERE_OPERATORS, warnedSqlFragmentContexts, queryCache, reorderCache, REORDER_CACHE_MAX = 500;
16733
+ var FALSE_PREDICATE = "1 = 0", TRUE_PREDICATE = "1 = 1", SQL_PATTERNS, SAFE_WHERE_OPERATORS, warnedSqlFragmentContexts, queryCache, reorderCache, REORDER_CACHE_MAX = 500;
16700
16734
  var init_client = __esm(() => {
16701
16735
  init_config();
16702
16736
  init_db();
@@ -16789,7 +16823,7 @@ var init_cache = __esm(() => {
16789
16823
  });
16790
16824
 
16791
16825
  // src/actions/console.ts
16792
- import process22 from "process";
16826
+ import process23 from "process";
16793
16827
  import { createInterface } from "readline";
16794
16828
  async function startConsole() {
16795
16829
  console.log("-- Query Builder Interactive Console");
@@ -16798,8 +16832,8 @@ async function startConsole() {
16798
16832
  console.log();
16799
16833
  const qb = createQueryBuilder();
16800
16834
  const rl = createInterface({
16801
- input: process22.stdin,
16802
- output: process22.stdout,
16835
+ input: process23.stdin,
16836
+ output: process23.stdout,
16803
16837
  prompt: "qb> "
16804
16838
  });
16805
16839
  let multilineBuffer = "";
@@ -16850,7 +16884,7 @@ Tips:
16850
16884
  if (cmd === ".exit" || cmd === ".quit") {
16851
16885
  console.log("Goodbye!");
16852
16886
  rl.close();
16853
- process22.exit(0);
16887
+ process23.exit(0);
16854
16888
  } else if (cmd === ".help") {
16855
16889
  console.log(helpText);
16856
16890
  } else if (cmd === ".clear") {
@@ -16921,7 +16955,7 @@ Tips:
16921
16955
  rl.on("close", () => {
16922
16956
  console.log(`
16923
16957
  Goodbye!`);
16924
- process22.exit(0);
16958
+ process23.exit(0);
16925
16959
  });
16926
16960
  rl.prompt();
16927
16961
  }
@@ -16933,7 +16967,7 @@ var init_console = __esm(() => {
16933
16967
  });
16934
16968
 
16935
16969
  // src/actions/data.ts
16936
- import { existsSync as existsSync11, readFileSync as readFileSync2, writeFileSync as writeFileSync8 } from "fs";
16970
+ import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync8 } from "fs";
16937
16971
  async function exportData(tableName, options = {}) {
16938
16972
  const format = options.format || "json";
16939
16973
  const output = options.output || `${tableName}.${format}`;
@@ -17008,7 +17042,7 @@ async function exportData(tableName, options = {}) {
17008
17042
  }
17009
17043
  }
17010
17044
  async function importData(tableName, filePath, options = {}) {
17011
- if (!existsSync11(filePath)) {
17045
+ if (!existsSync2(filePath)) {
17012
17046
  console.error(`-- File not found: ${filePath}`);
17013
17047
  throw new Error(`File not found: ${filePath}`);
17014
17048
  }
@@ -18154,23 +18188,23 @@ var init_introspect_db = __esm(() => {
18154
18188
  });
18155
18189
 
18156
18190
  // src/actions/make-model.ts
18157
- import { existsSync as existsSync14, mkdirSync as mkdirSync7, writeFileSync as writeFileSync10 } from "fs";
18191
+ import { existsSync as existsSync11, mkdirSync as mkdirSync7, writeFileSync as writeFileSync10 } from "fs";
18158
18192
  import { dirname as dirname7, join as join7 } from "path";
18159
- import process23 from "process";
18193
+ import process25 from "process";
18160
18194
  function findWorkspaceRoot(startPath) {
18161
18195
  let currentPath = startPath;
18162
18196
  while (currentPath !== dirname7(currentPath)) {
18163
- if (existsSync14(join7(currentPath, "package.json"))) {
18197
+ if (existsSync11(join7(currentPath, "package.json"))) {
18164
18198
  return currentPath;
18165
18199
  }
18166
18200
  currentPath = dirname7(currentPath);
18167
18201
  }
18168
- return process23.cwd();
18202
+ return process25.cwd();
18169
18203
  }
18170
18204
  async function makeModel(name, options = {}) {
18171
- const workspaceRoot = findWorkspaceRoot(process23.cwd());
18205
+ const workspaceRoot = findWorkspaceRoot(process25.cwd());
18172
18206
  const modelsDir = options.dir || join7(workspaceRoot, "app/Models");
18173
- if (!existsSync14(modelsDir)) {
18207
+ if (!existsSync11(modelsDir)) {
18174
18208
  mkdirSync7(modelsDir, { recursive: true });
18175
18209
  console.log(`-- Created models directory: ${modelsDir}`);
18176
18210
  }
@@ -18178,7 +18212,7 @@ async function makeModel(name, options = {}) {
18178
18212
  const tableName = options.table || `${name.toLowerCase()}s`;
18179
18213
  const fileName = `${className}.ts`;
18180
18214
  const filePath = join7(modelsDir, fileName);
18181
- if (existsSync14(filePath)) {
18215
+ if (existsSync11(filePath)) {
18182
18216
  console.error(`-- Model already exists: ${filePath}`);
18183
18217
  throw new Error(`Model already exists: ${filePath}`);
18184
18218
  }
@@ -18938,17 +18972,17 @@ var init_drivers = __esm(() => {
18938
18972
  });
18939
18973
 
18940
18974
  // src/workspace.ts
18941
- import { existsSync as existsSync16 } from "fs";
18975
+ import { existsSync as existsSync14 } from "fs";
18942
18976
  import { dirname as dirname8, isAbsolute as isAbsolute3, join as join9 } from "path";
18943
- import process24 from "process";
18944
- function findWorkspaceRoot2(startPath = process24.cwd()) {
18977
+ import process26 from "process";
18978
+ function findWorkspaceRoot2(startPath = process26.cwd()) {
18945
18979
  let currentPath = startPath;
18946
18980
  while (currentPath !== dirname8(currentPath)) {
18947
- if (existsSync16(join9(currentPath, "package.json")))
18981
+ if (existsSync14(join9(currentPath, "package.json")))
18948
18982
  return currentPath;
18949
18983
  currentPath = dirname8(currentPath);
18950
18984
  }
18951
- return process24.cwd();
18985
+ return process26.cwd();
18952
18986
  }
18953
18987
  function getSqlDirectory(workspaceRoot, migrationDir = "database/migrations") {
18954
18988
  const configured = migrationDir || "database/migrations";
@@ -18967,10 +19001,10 @@ __export(exports_migrate, {
18967
19001
  copyModelsToGenerated: () => copyModelsToGenerated,
18968
19002
  clearGeneratedDirectory: () => clearGeneratedDirectory
18969
19003
  });
18970
- import { existsSync as existsSync17, mkdirSync as mkdirSync8, mkdtempSync, readdirSync as readdirSync6, readFileSync as readFileSync3, rmSync, unlinkSync, writeFileSync as writeFileSync11 } from "fs";
19004
+ import { existsSync as existsSync16, mkdirSync as mkdirSync8, mkdtempSync, readdirSync as readdirSync6, readFileSync as readFileSync3, rmSync, unlinkSync, writeFileSync as writeFileSync11 } from "fs";
18971
19005
  import { tmpdir } from "os";
18972
19006
  import { join as join10 } from "path";
18973
- import process25 from "process";
19007
+ import process27 from "process";
18974
19008
  async function settleAppliedFiles(qb, dialect, files) {
18975
19009
  if (files.length === 0)
18976
19010
  return;
@@ -19008,7 +19042,7 @@ function getSnapshotPath(workspaceRoot, dialect) {
19008
19042
  }
19009
19043
  function loadPlanSnapshot(workspaceRoot, dialect) {
19010
19044
  const snapshotPath = getSnapshotPath(workspaceRoot, dialect);
19011
- if (!existsSync17(snapshotPath)) {
19045
+ if (!existsSync16(snapshotPath)) {
19012
19046
  return;
19013
19047
  }
19014
19048
  try {
@@ -19031,7 +19065,7 @@ function savePlanSnapshot(workspaceRoot, dialect, plan) {
19031
19065
  const snapshotPath = getSnapshotPath(workspaceRoot, dialect);
19032
19066
  const snapshotDir = getSnapshotDir(workspaceRoot);
19033
19067
  const hash = hashMigrationPlan(plan);
19034
- if (existsSync17(snapshotPath)) {
19068
+ if (existsSync16(snapshotPath)) {
19035
19069
  try {
19036
19070
  const current = JSON.parse(readFileSync3(snapshotPath, "utf8"));
19037
19071
  if (current?.hash === hash && current?.dialect === dialect && current?.plan) {
@@ -19040,7 +19074,7 @@ function savePlanSnapshot(workspaceRoot, dialect, plan) {
19040
19074
  }
19041
19075
  } catch {}
19042
19076
  }
19043
- if (!existsSync17(snapshotDir)) {
19077
+ if (!existsSync16(snapshotDir)) {
19044
19078
  mkdirSync8(snapshotDir, { recursive: true });
19045
19079
  info(`-- Created snapshot directory: ${snapshotDir}`);
19046
19080
  }
@@ -19062,7 +19096,7 @@ function getWorkspaceRoot() {
19062
19096
  }
19063
19097
  function ensureSqlDirectory(workspaceRoot) {
19064
19098
  const sqlDir = getSqlDirectory(workspaceRoot, config5.migrationDir);
19065
- if (!existsSync17(sqlDir)) {
19099
+ if (!existsSync16(sqlDir)) {
19066
19100
  mkdirSync8(sqlDir, { recursive: true });
19067
19101
  info(`-- Created SQL directory: ${sqlDir}`);
19068
19102
  }
@@ -19071,7 +19105,7 @@ function ensureSqlDirectory(workspaceRoot) {
19071
19105
  async function generateMigration(dir, opts = {}) {
19072
19106
  await getConfig();
19073
19107
  if (!dir) {
19074
- dir = join10(process25.cwd(), "app/Models");
19108
+ dir = join10(process27.cwd(), "app/Models");
19075
19109
  }
19076
19110
  const dialect = opts.dialect || config5.dialect || "postgres";
19077
19111
  const workspaceRoot = getWorkspaceRoot();
@@ -19086,7 +19120,7 @@ async function generateMigration(dir, opts = {}) {
19086
19120
  } else {
19087
19121
  const defaultStatePath = join10(dir, `.qb-migrations.${dialect}.json`);
19088
19122
  const statePath = String(opts.state || defaultStatePath);
19089
- if (existsSync17(statePath)) {
19123
+ if (existsSync16(statePath)) {
19090
19124
  try {
19091
19125
  const raw2 = readFileSync3(statePath, "utf8");
19092
19126
  const parsed = JSON.parse(raw2);
@@ -19192,8 +19226,8 @@ async function executeMigration(dir) {
19192
19226
  info(`-- Found ${scriptFiles.length} script files to execute`);
19193
19227
  try {
19194
19228
  const qb = createQueryBuilder();
19195
- await createMigrationsTable(qb, dialect);
19196
19229
  return await withMigrationLock(dialect, async () => {
19230
+ await createMigrationsTable(qb, dialect);
19197
19231
  const executedMigrations = await getExecutedMigrations(qb, dialect);
19198
19232
  const pending = scriptFiles.filter((file2) => !executedMigrations.includes(file2));
19199
19233
  if (pending.length === 0) {
@@ -19242,7 +19276,7 @@ async function executeMigration(dir) {
19242
19276
  async function resetDatabase(dir, opts = {}) {
19243
19277
  await getConfig();
19244
19278
  if (!dir) {
19245
- dir = join10(process25.cwd(), "app/Models");
19279
+ dir = join10(process27.cwd(), "app/Models");
19246
19280
  }
19247
19281
  const dialect = opts.dialect || config5.dialect || "postgres";
19248
19282
  const driver = getDialectDriver(dialect);
@@ -19339,27 +19373,27 @@ async function resetDatabase(dir, opts = {}) {
19339
19373
  }
19340
19374
  async function deleteMigrationFiles(dir, workspaceRoot, opts = {}) {
19341
19375
  if (!dir) {
19342
- dir = join10(process25.cwd(), "app/Models");
19376
+ dir = join10(process27.cwd(), "app/Models");
19343
19377
  }
19344
19378
  if (!workspaceRoot) {
19345
19379
  workspaceRoot = getWorkspaceRoot();
19346
19380
  }
19347
19381
  const dialect = String(opts.dialect || config5.dialect || "postgres");
19348
19382
  const snapshotPath = getSnapshotPath(workspaceRoot, dialect);
19349
- if (existsSync17(snapshotPath)) {
19383
+ if (existsSync16(snapshotPath)) {
19350
19384
  unlinkSync(snapshotPath);
19351
19385
  info(`-- Removed model snapshot file: ${snapshotPath}`);
19352
19386
  }
19353
19387
  const defaultStatePath = join10(dir, `.qb-migrations.${dialect}.json`);
19354
19388
  const statePath = String(opts.state || defaultStatePath);
19355
- if (existsSync17(statePath)) {
19389
+ if (existsSync16(statePath)) {
19356
19390
  unlinkSync(statePath);
19357
19391
  info(`-- Removed legacy migration state file: ${statePath}`);
19358
19392
  }
19359
19393
  removeGeneratedMigrationFiles(getSqlDirectory(workspaceRoot, config5.migrationDir));
19360
19394
  }
19361
19395
  function removeGeneratedMigrationFiles(sqlDir) {
19362
- if (!existsSync17(sqlDir))
19396
+ if (!existsSync16(sqlDir))
19363
19397
  return;
19364
19398
  let removed = 0;
19365
19399
  const kept = [];
@@ -19382,7 +19416,7 @@ async function clearGeneratedDirectory(workspaceRoot) {
19382
19416
  workspaceRoot = getWorkspaceRoot();
19383
19417
  }
19384
19418
  const generatedDir = join10(workspaceRoot, "generated");
19385
- if (existsSync17(generatedDir)) {
19419
+ if (existsSync16(generatedDir)) {
19386
19420
  try {
19387
19421
  rmSync(generatedDir, { recursive: true, force: true });
19388
19422
  info("-- Cleared generated directory");
@@ -19443,7 +19477,7 @@ var init_migrate_generate = __esm(() => {
19443
19477
  });
19444
19478
 
19445
19479
  // src/actions/migrate-rollback.ts
19446
- import { existsSync as existsSync18, readFileSync as readFileSync4, unlinkSync as unlinkSync2 } from "fs";
19480
+ import { existsSync as existsSync17, readFileSync as readFileSync4, unlinkSync as unlinkSync2 } from "fs";
19447
19481
  import { join as join11 } from "path";
19448
19482
  function splitSqlStatements2(sql) {
19449
19483
  const out = [];
@@ -19558,7 +19592,7 @@ async function migrateRollback(options = {}) {
19558
19592
  for (const migration of migrationsToRollback) {
19559
19593
  try {
19560
19594
  const filePath = join11(sqlDir, migration.migration);
19561
- if (reverseSchema && existsSync18(filePath)) {
19595
+ if (reverseSchema && existsSync17(filePath)) {
19562
19596
  const forwardSql = readFileSync4(filePath, "utf8");
19563
19597
  const { down, skipped } = deriveDownStatements(forwardSql);
19564
19598
  for (const stmt of down) {
@@ -19572,7 +19606,7 @@ async function migrateRollback(options = {}) {
19572
19606
  const deleteSql = `DELETE FROM migrations WHERE migration = ${getPlaceholder(1)}`;
19573
19607
  await qb.unsafe(deleteSql, [migration.migration]);
19574
19608
  console.log(`-- \u2713 Removed migration record: ${migration.migration}`);
19575
- if (options.deleteFiles && existsSync18(filePath)) {
19609
+ if (options.deleteFiles && existsSync17(filePath)) {
19576
19610
  unlinkSync2(filePath);
19577
19611
  console.log(`-- \uD83D\uDDD1\uFE0F Deleted migration file: ${migration.migration}`);
19578
19612
  }
@@ -19599,7 +19633,7 @@ var init_migrate_rollback = __esm(() => {
19599
19633
  });
19600
19634
 
19601
19635
  // src/actions/migrate-status.ts
19602
- import { existsSync as existsSync19, readdirSync as readdirSync8 } from "fs";
19636
+ import { existsSync as existsSync18, readdirSync as readdirSync8 } from "fs";
19603
19637
  async function migrateStatus() {
19604
19638
  const dialect = config5.dialect || "postgres";
19605
19639
  const driver = getDialectDriver(dialect);
@@ -19608,7 +19642,7 @@ async function migrateStatus() {
19608
19642
  console.log(`-- Dialect: ${dialect}`);
19609
19643
  console.log(`-- SQL directory: ${sqlDir}`);
19610
19644
  console.log();
19611
- if (!existsSync19(sqlDir)) {
19645
+ if (!existsSync18(sqlDir)) {
19612
19646
  console.log("-- No SQL directory found. No migrations have been created yet.");
19613
19647
  return [];
19614
19648
  }
@@ -19673,9 +19707,9 @@ var init_migrate_status = __esm(() => {
19673
19707
  // src/actions/model-show.ts
19674
19708
  import { readdirSync as readdirSync9 } from "fs";
19675
19709
  import { extname as extname2, join as join12 } from "path";
19676
- import process26 from "process";
19710
+ import process28 from "process";
19677
19711
  async function modelShow(modelName, options = {}) {
19678
- const dir = options.dir || join12(process26.cwd(), "app/Models");
19712
+ const dir = options.dir || join12(process28.cwd(), "app/Models");
19679
19713
  try {
19680
19714
  const files = readdirSync9(dir);
19681
19715
  const modelFile = files.find((f) => {
@@ -19889,9 +19923,9 @@ var init_query_explain_all = __esm(() => {
19889
19923
  // src/actions/relation-diagram.ts
19890
19924
  import { writeFileSync as writeFileSync12 } from "fs";
19891
19925
  import { join as join14 } from "path";
19892
- import process27 from "process";
19926
+ import process29 from "process";
19893
19927
  async function relationDiagram(options = {}) {
19894
- const dir = options.dir || join14(process27.cwd(), "app/Models");
19928
+ const dir = options.dir || join14(process29.cwd(), "app/Models");
19895
19929
  const format = options.format || "mermaid";
19896
19930
  try {
19897
19931
  const models = await loadModels({ modelsDir: dir });
@@ -20011,21 +20045,21 @@ var init_relation_diagram = __esm(() => {
20011
20045
  });
20012
20046
 
20013
20047
  // src/actions/seed.ts
20014
- import { existsSync as existsSync20, mkdirSync as mkdirSync9, readdirSync as readdirSync11, writeFileSync as writeFileSync13 } from "fs";
20048
+ import { existsSync as existsSync19, mkdirSync as mkdirSync9, readdirSync as readdirSync11, writeFileSync as writeFileSync13 } from "fs";
20015
20049
  import { dirname as dirname10, join as join15 } from "path";
20016
- import process28 from "process";
20050
+ import process30 from "process";
20017
20051
  function findWorkspaceRoot3(startPath) {
20018
20052
  let currentPath = startPath;
20019
20053
  while (currentPath !== dirname10(currentPath)) {
20020
- if (existsSync20(join15(currentPath, "package.json"))) {
20054
+ if (existsSync19(join15(currentPath, "package.json"))) {
20021
20055
  return currentPath;
20022
20056
  }
20023
20057
  currentPath = dirname10(currentPath);
20024
20058
  }
20025
- return process28.cwd();
20059
+ return process30.cwd();
20026
20060
  }
20027
20061
  async function loadSeeders(seedersDir) {
20028
- if (!existsSync20(seedersDir)) {
20062
+ if (!existsSync19(seedersDir)) {
20029
20063
  console.log(`-- Seeders directory not found: ${seedersDir}`);
20030
20064
  return [];
20031
20065
  }
@@ -20055,7 +20089,7 @@ async function loadSeeders(seedersDir) {
20055
20089
  return seeders;
20056
20090
  }
20057
20091
  async function runSeeders(config6 = {}) {
20058
- const workspaceRoot = findWorkspaceRoot3(process28.cwd());
20092
+ const workspaceRoot = findWorkspaceRoot3(process30.cwd());
20059
20093
  const seedersDir = config6.seedersDir || join15(workspaceRoot, "database/seeders");
20060
20094
  const verbose = config6.verbose ?? true;
20061
20095
  if (verbose) {
@@ -20090,7 +20124,7 @@ async function runSeeders(config6 = {}) {
20090
20124
  }
20091
20125
  }
20092
20126
  async function runSeeder(className, options = {}) {
20093
- const workspaceRoot = findWorkspaceRoot3(process28.cwd());
20127
+ const workspaceRoot = findWorkspaceRoot3(process30.cwd());
20094
20128
  const seedersDir = join15(workspaceRoot, "database/seeders");
20095
20129
  const verbose = options.verbose ?? true;
20096
20130
  if (verbose) {
@@ -20115,9 +20149,9 @@ async function runSeeder(className, options = {}) {
20115
20149
  }
20116
20150
  }
20117
20151
  async function makeSeeder(name) {
20118
- const workspaceRoot = findWorkspaceRoot3(process28.cwd());
20152
+ const workspaceRoot = findWorkspaceRoot3(process30.cwd());
20119
20153
  const seedersDir = join15(workspaceRoot, "database/seeders");
20120
- if (!existsSync20(seedersDir)) {
20154
+ if (!existsSync19(seedersDir)) {
20121
20155
  mkdirSync9(seedersDir, { recursive: true });
20122
20156
  console.log(`-- Created seeders directory: ${seedersDir}`);
20123
20157
  }
@@ -20125,7 +20159,7 @@ async function makeSeeder(name) {
20125
20159
  const className = `${baseName}Seeder`;
20126
20160
  const fileName = `${className}.ts`;
20127
20161
  const filePath = join15(seedersDir, fileName);
20128
- if (existsSync20(filePath)) {
20162
+ if (existsSync19(filePath)) {
20129
20163
  console.error(`-- Seeder already exists: ${filePath}`);
20130
20164
  throw new Error(`Seeder already exists: ${filePath}`);
20131
20165
  }
@@ -20179,7 +20213,7 @@ export default class ${className} extends Seeder {
20179
20213
  console.log(`-- \u2713 Created seeder: ${filePath}`);
20180
20214
  }
20181
20215
  async function freshDatabase(options = {}) {
20182
- const workspaceRoot = findWorkspaceRoot3(process28.cwd());
20216
+ const workspaceRoot = findWorkspaceRoot3(process30.cwd());
20183
20217
  const modelsDir = options.modelsDir || join15(workspaceRoot, "app/Models");
20184
20218
  const seedersDir = options.seedersDir || join15(workspaceRoot, "database/seeders");
20185
20219
  const verbose = options.verbose ?? true;
@@ -20239,22 +20273,22 @@ var init_unsafe = __esm(() => {
20239
20273
  });
20240
20274
 
20241
20275
  // src/actions/validate.ts
20242
- import { existsSync as existsSync21 } from "fs";
20276
+ import { existsSync as existsSync20 } from "fs";
20243
20277
  import { dirname as dirname11, join as join16 } from "path";
20244
- import process29 from "process";
20278
+ import process31 from "process";
20245
20279
  function findWorkspaceRoot4(startPath) {
20246
20280
  let currentPath = startPath;
20247
20281
  while (currentPath !== dirname11(currentPath)) {
20248
- if (existsSync21(join16(currentPath, "package.json"))) {
20282
+ if (existsSync20(join16(currentPath, "package.json"))) {
20249
20283
  return currentPath;
20250
20284
  }
20251
20285
  currentPath = dirname11(currentPath);
20252
20286
  }
20253
- return process29.cwd();
20287
+ return process31.cwd();
20254
20288
  }
20255
20289
  async function validateSchema(dir) {
20256
20290
  if (!dir) {
20257
- dir = join16(findWorkspaceRoot4(process29.cwd()), "app/Models");
20291
+ dir = join16(findWorkspaceRoot4(process31.cwd()), "app/Models");
20258
20292
  }
20259
20293
  const dialect = config5.dialect || "postgres";
20260
20294
  console.log("-- Validating Schema");
@@ -28332,7 +28366,7 @@ var init_factory = () => {};
28332
28366
  // src/loader.ts
28333
28367
  import { readdirSync as readdirSync12 } from "fs";
28334
28368
  import { basename, extname as extname4, isAbsolute as isAbsolute5, join as join17 } from "path";
28335
- import process30 from "process";
28369
+ import process33 from "process";
28336
28370
  function isModelFile(name) {
28337
28371
  const ext = extname4(name);
28338
28372
  if (!MODEL_EXTENSIONS.has(ext))
@@ -28363,7 +28397,7 @@ function collectModelFiles(dir) {
28363
28397
  return files;
28364
28398
  }
28365
28399
  async function loadModels(options) {
28366
- const cwd = options.cwd ?? process30.cwd();
28400
+ const cwd = options.cwd ?? process33.cwd();
28367
28401
  const dir = isAbsolute5(options.modelsDir) ? options.modelsDir : join17(cwd, options.modelsDir);
28368
28402
  const result = {};
28369
28403
  for (const full of collectModelFiles(dir)) {
@@ -28470,9 +28504,9 @@ function buildSchemaMeta(models) {
28470
28504
  var init_meta = () => {};
28471
28505
 
28472
28506
  // src/migrations.ts
28473
- import { existsSync as existsSync23, mkdirSync as mkdirSync10, readdirSync as readdirSync13, readFileSync as readFileSync6, writeFileSync as writeFileSync14 } from "fs";
28507
+ import { existsSync as existsSync21, mkdirSync as mkdirSync10, readdirSync as readdirSync13, readFileSync as readFileSync6, writeFileSync as writeFileSync14 } from "fs";
28474
28508
  import { dirname as dirname12, join as join18 } from "path";
28475
- import process31 from "process";
28509
+ import process35 from "process";
28476
28510
  function info2(message) {
28477
28511
  if (config5.verbose)
28478
28512
  console.log(message);
@@ -28489,17 +28523,17 @@ function lastCreatedMigrationFiles() {
28489
28523
  function findWorkspaceRoot5(startPath) {
28490
28524
  let currentPath = startPath;
28491
28525
  while (currentPath !== dirname12(currentPath)) {
28492
- if (existsSync23(join18(currentPath, "package.json"))) {
28526
+ if (existsSync21(join18(currentPath, "package.json"))) {
28493
28527
  return currentPath;
28494
28528
  }
28495
28529
  currentPath = dirname12(currentPath);
28496
28530
  }
28497
- return process31.cwd();
28531
+ return process35.cwd();
28498
28532
  }
28499
28533
  function ensureSqlDirectory2() {
28500
- const workspaceRoot = findWorkspaceRoot5(process31.cwd());
28534
+ const workspaceRoot = findWorkspaceRoot5(process35.cwd());
28501
28535
  const sqlDir = getSqlDirectory(workspaceRoot, config5.migrationDir);
28502
- if (!existsSync23(sqlDir)) {
28536
+ if (!existsSync21(sqlDir)) {
28503
28537
  mkdirSync10(sqlDir, { recursive: true });
28504
28538
  info2(`-- Created SQL directory: ${sqlDir}`);
28505
28539
  }
@@ -28544,7 +28578,7 @@ function createMigrationFile(statement, fileName) {
28544
28578
  let fullFileName = `${sequence}-${fileName}.sql`;
28545
28579
  if (!useDeterministicNames) {
28546
28580
  let next = Number(sequence);
28547
- while (existsSync23(join18(sqlDir, fullFileName))) {
28581
+ while (existsSync21(join18(sqlDir, fullFileName))) {
28548
28582
  next += 1;
28549
28583
  sequence = String(next);
28550
28584
  fullFileName = `${sequence}-${fileName}.sql`;