gencow 0.1.259 → 0.1.261

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.
@@ -2674,7 +2674,7 @@ function sql(strings, ...params) {
2674
2674
  return new SQL([new StringChunk(str)]);
2675
2675
  }
2676
2676
  _sql.raw = raw;
2677
- function join9(chunks, separator) {
2677
+ function join10(chunks, separator) {
2678
2678
  const result = [];
2679
2679
  for (const [i, chunk] of chunks.entries()) {
2680
2680
  if (i > 0 && separator !== void 0) result.push(separator);
@@ -2682,7 +2682,7 @@ function sql(strings, ...params) {
2682
2682
  }
2683
2683
  return new SQL(result);
2684
2684
  }
2685
- _sql.join = join9;
2685
+ _sql.join = join10;
2686
2686
  function identifier(value) {
2687
2687
  return new Name(value);
2688
2688
  }
@@ -4785,7 +4785,7 @@ import { spawn } from "node:child_process";
4785
4785
  function createNodeProcessRunner() {
4786
4786
  return {
4787
4787
  async run(input2) {
4788
- return new Promise((resolve16) => {
4788
+ return new Promise((resolve17) => {
4789
4789
  const child = spawn(input2.command, input2.args ?? [], {
4790
4790
  cwd: input2.cwd,
4791
4791
  env: input2.env ? { ...process.env, ...input2.env } : process.env,
@@ -4804,7 +4804,7 @@ function createNodeProcessRunner() {
4804
4804
  }
4805
4805
  child.stdin.end();
4806
4806
  child.on("close", (exitCode) => {
4807
- resolve16({ exitCode, stdout, stderr });
4807
+ resolve17({ exitCode, stdout, stderr });
4808
4808
  });
4809
4809
  });
4810
4810
  }
@@ -6695,13 +6695,13 @@ async function createWatchDeps() {
6695
6695
  };
6696
6696
  }
6697
6697
  async function watchCodegen(input2, depsInput) {
6698
- const { resolve: resolve16, relative: relative7 } = await import("node:path");
6698
+ const { resolve: resolve17, relative: relative8 } = await import("node:path");
6699
6699
  const deps = depsInput ?? await createWatchDeps();
6700
- const projectRoot = resolve16(input2.projectRoot);
6700
+ const projectRoot = resolve17(input2.projectRoot);
6701
6701
  const configuredRoot = input2.rootDir ?? input2.functionsDir ?? "gencow";
6702
- const functionsDirAbs = resolve16(projectRoot, configuredRoot);
6703
- const outDirAbs = resolve16(projectRoot, input2.outDir ?? ".gencow/codegen");
6704
- const outDirRel = relative7(projectRoot, outDirAbs).replace(/\\/g, "/");
6702
+ const functionsDirAbs = resolve17(projectRoot, configuredRoot);
6703
+ const outDirAbs = resolve17(projectRoot, input2.outDir ?? ".gencow/codegen");
6704
+ const outDirRel = relative8(projectRoot, outDirAbs).replace(/\\/g, "/");
6705
6705
  await input2.onRun?.();
6706
6706
  let debounceTimer;
6707
6707
  const invokeWithDebounce = () => {
@@ -6725,7 +6725,7 @@ async function watchCodegen(input2, depsInput) {
6725
6725
  } else {
6726
6726
  const watchedDirs = /* @__PURE__ */ new Set();
6727
6727
  const shouldIgnoreDir = (dirPath) => {
6728
- const rel = relative7(functionsDirAbs, dirPath).replace(/\\/g, "/");
6728
+ const rel = relative8(functionsDirAbs, dirPath).replace(/\\/g, "/");
6729
6729
  if (rel === "node_modules" || rel.startsWith("node_modules/")) return true;
6730
6730
  if (!outDirRel) return false;
6731
6731
  return rel === outDirRel || rel.startsWith(`${outDirRel}/`);
@@ -6741,7 +6741,7 @@ async function watchCodegen(input2, depsInput) {
6741
6741
  return;
6742
6742
  }
6743
6743
  for (const entry of entries) {
6744
- const next = resolve16(dirPath, entry);
6744
+ const next = resolve17(dirPath, entry);
6745
6745
  let nextStat;
6746
6746
  try {
6747
6747
  nextStat = await deps.stat(next);
@@ -6776,6 +6776,166 @@ function shouldTriggerCodegenFromPath(path, backendRoot = "gencow") {
6776
6776
  return normalizedPath.endsWith("schema.ts") || normalizedPath.endsWith("drizzle.config.ts") || backendRootPattern?.test(normalizedPath) === true;
6777
6777
  }
6778
6778
 
6779
+ // scripts/codegen-named-import-check.ts
6780
+ import { createRequire } from "node:module";
6781
+ import { join as join6, relative as relative4, resolve as resolve10, sep as sep2 } from "node:path";
6782
+ var SCRIPT_FILE = /\.(?:[cm]?[jt]sx?)$/u;
6783
+ var TYPESCRIPT_FILE = /\.(?:[cm]?tsx?)$/u;
6784
+ var RELATIVE_SPECIFIER = /^\.{1,2}\//u;
6785
+ var DECLARATION_FILE = /\.d\.[cm]?ts$/u;
6786
+ function loadProjectTypeScript(projectRoot) {
6787
+ try {
6788
+ const requireFromProject = createRequire(join6(projectRoot, "package.json"));
6789
+ const ts = requireFromProject(requireFromProject.resolve("typescript"));
6790
+ return typeof ts?.createSourceFile === "function" && typeof ts?.resolveModuleName === "function" ? ts : null;
6791
+ } catch {
6792
+ return null;
6793
+ }
6794
+ }
6795
+ function resolveRelativeModule(ctx, fromFile, specifier) {
6796
+ if (!RELATIVE_SPECIFIER.test(specifier)) return null;
6797
+ const resolved = ctx.ts.resolveModuleName(
6798
+ specifier,
6799
+ fromFile,
6800
+ ctx.compilerOptions,
6801
+ ctx.ts.sys
6802
+ ).resolvedModule;
6803
+ if (!resolved || resolved.isExternalLibraryImport) return null;
6804
+ if (DECLARATION_FILE.test(resolved.resolvedFileName)) return null;
6805
+ return resolved.resolvedFileName;
6806
+ }
6807
+ function parseSource(ctx, file2) {
6808
+ const text = ctx.ts.sys.readFile(file2);
6809
+ if (typeof text !== "string") return null;
6810
+ return ctx.ts.createSourceFile(file2, text, ctx.ts.ScriptTarget.Latest, true);
6811
+ }
6812
+ function hasExportModifier(ts, statement) {
6813
+ return (statement.modifiers ?? []).some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword);
6814
+ }
6815
+ function hasDefaultModifier(ts, statement) {
6816
+ return (statement.modifiers ?? []).some((modifier) => modifier.kind === ts.SyntaxKind.DefaultKeyword);
6817
+ }
6818
+ function bindingNames(binding, names) {
6819
+ if (!binding) return;
6820
+ if (typeof binding.text === "string") {
6821
+ names.push(binding.text);
6822
+ return;
6823
+ }
6824
+ for (const element of binding.elements ?? []) bindingNames(element.name, names);
6825
+ }
6826
+ function exportNamesOf(ctx, file2) {
6827
+ if (ctx.exportCache.has(file2)) return ctx.exportCache.get(file2) ?? null;
6828
+ ctx.exportCache.set(file2, null);
6829
+ const names = collectExportNames(ctx, file2);
6830
+ ctx.exportCache.set(file2, names);
6831
+ return names;
6832
+ }
6833
+ function collectExportNames(ctx, file2) {
6834
+ const { ts } = ctx;
6835
+ if (!TYPESCRIPT_FILE.test(file2)) return null;
6836
+ const source = parseSource(ctx, file2);
6837
+ if (!source) return null;
6838
+ const names = /* @__PURE__ */ new Set();
6839
+ for (const statement of source.statements) {
6840
+ if (ts.isExportDeclaration(statement)) {
6841
+ const clause = statement.exportClause;
6842
+ if (!clause) {
6843
+ const target = resolveRelativeModule(ctx, file2, statement.moduleSpecifier.text);
6844
+ const inner = target ? exportNamesOf(ctx, target) : null;
6845
+ if (!inner) return null;
6846
+ for (const name2 of inner) if (name2 !== "default") names.add(name2);
6847
+ } else if (ts.isNamespaceExport(clause)) {
6848
+ names.add(clause.name.text);
6849
+ } else {
6850
+ for (const element of clause.elements) names.add(element.name.text);
6851
+ }
6852
+ } else if (ts.isExportAssignment(statement)) {
6853
+ if (statement.isExportEquals) return null;
6854
+ names.add("default");
6855
+ } else if (hasExportModifier(ts, statement)) {
6856
+ if (hasDefaultModifier(ts, statement)) {
6857
+ names.add("default");
6858
+ } else if (ts.isVariableStatement(statement)) {
6859
+ const declared = [];
6860
+ for (const declaration of statement.declarationList.declarations)
6861
+ bindingNames(declaration.name, declared);
6862
+ for (const name2 of declared) names.add(name2);
6863
+ } else if (statement.name?.text) {
6864
+ names.add(statement.name.text);
6865
+ }
6866
+ }
6867
+ }
6868
+ return names;
6869
+ }
6870
+ function missingNamedImportsIn(ctx, file2) {
6871
+ const { ts } = ctx;
6872
+ const sourceFile = parseSource(ctx, file2);
6873
+ if (!sourceFile) return [];
6874
+ const missing = [];
6875
+ for (const statement of sourceFile.statements) {
6876
+ let specifiers = [];
6877
+ let specifier = null;
6878
+ if (ts.isImportDeclaration(statement)) {
6879
+ const clause = statement.importClause;
6880
+ const bindings = clause && !clause.isTypeOnly ? clause.namedBindings : void 0;
6881
+ if (bindings && ts.isNamedImports(bindings)) {
6882
+ specifiers = bindings.elements;
6883
+ specifier = statement.moduleSpecifier.text;
6884
+ }
6885
+ } else if (ts.isExportDeclaration(statement) && statement.moduleSpecifier && !statement.isTypeOnly && statement.exportClause && ts.isNamedExports(statement.exportClause)) {
6886
+ specifiers = statement.exportClause.elements;
6887
+ specifier = statement.moduleSpecifier.text;
6888
+ }
6889
+ if (!specifier) continue;
6890
+ const target = resolveRelativeModule(ctx, file2, specifier);
6891
+ if (!target) continue;
6892
+ const exported = exportNamesOf(ctx, target);
6893
+ if (!exported) continue;
6894
+ for (const element of specifiers) {
6895
+ if (element.isTypeOnly) continue;
6896
+ const nameNode = element.propertyName ?? element.name;
6897
+ const name2 = nameNode.text;
6898
+ if (exported.has(name2)) continue;
6899
+ const position = sourceFile.getLineAndCharacterOfPosition(nameNode.getStart(sourceFile));
6900
+ missing.push({ file: file2, line: position.line + 1, column: position.character, name: name2, target });
6901
+ }
6902
+ }
6903
+ return missing;
6904
+ }
6905
+ function isProjectSource(file2, projectRoot) {
6906
+ return file2.startsWith(`${projectRoot}${sep2}`) && !file2.split(sep2).includes("node_modules") && SCRIPT_FILE.test(file2);
6907
+ }
6908
+ function findMissingNamedImports(inputFiles, projectRootInput) {
6909
+ const projectRoot = resolve10(projectRootInput);
6910
+ const ts = loadProjectTypeScript(projectRoot);
6911
+ if (!ts) return [];
6912
+ const ctx = {
6913
+ ts,
6914
+ compilerOptions: {
6915
+ moduleResolution: ts.ModuleResolutionKind?.Bundler ?? ts.ModuleResolutionKind?.NodeJs ?? 2,
6916
+ module: ts.ModuleKind?.ESNext,
6917
+ allowJs: true,
6918
+ resolveJsonModule: true
6919
+ },
6920
+ exportCache: /* @__PURE__ */ new Map()
6921
+ };
6922
+ try {
6923
+ const missing = [];
6924
+ for (const file2 of inputFiles) {
6925
+ if (isProjectSource(file2, projectRoot)) missing.push(...missingNamedImportsIn(ctx, file2));
6926
+ }
6927
+ return missing;
6928
+ } catch {
6929
+ return [];
6930
+ }
6931
+ }
6932
+ function formatMissingNamedImports(missing, projectRoot) {
6933
+ return missing.map((item) => {
6934
+ const target = relative4(resolve10(projectRoot), item.target).split(sep2).join("/");
6935
+ return `${item.file}:${item.line}:${item.column}: ERROR: No matching export in "${target}" for import "${item.name}"`;
6936
+ });
6937
+ }
6938
+
6779
6939
  // ../shared/src/introspection/crud-route-maps.ts
6780
6940
  function collectCrudDefinitions(appModule) {
6781
6941
  if (!appModule || typeof appModule !== "object") return [];
@@ -6813,7 +6973,7 @@ function collectCrudCodegenMeta(appModule) {
6813
6973
  // scripts/tooling-codegen-runtime.ts
6814
6974
  import { builtinModules } from "node:module";
6815
6975
  import { mkdir, mkdtemp, rm } from "node:fs/promises";
6816
- import { join as join6, resolve as resolve10 } from "node:path";
6976
+ import { join as join7, resolve as resolve11 } from "node:path";
6817
6977
  import { fileURLToPath, pathToFileURL as pathToFileURL2 } from "node:url";
6818
6978
  var nodeBuiltinExternals = Array.from(
6819
6979
  /* @__PURE__ */ new Set([
@@ -6836,7 +6996,7 @@ function readBuildMessageSourcePosition(error62) {
6836
6996
  return null;
6837
6997
  }
6838
6998
  function resolveAppEntryDefault(functionsDirAbs) {
6839
- return resolveFunctionsImportPath(resolve10(functionsDirAbs));
6999
+ return resolveFunctionsImportPath(resolve11(functionsDirAbs));
6840
7000
  }
6841
7001
  async function importModuleDefault(modulePath) {
6842
7002
  return import(pathToFileURL2(modulePath).href);
@@ -6855,13 +7015,14 @@ async function loadEsbuildModule() {
6855
7015
  return { build: mod.build };
6856
7016
  }
6857
7017
  async function transpileTypescriptForNodeDefault(entryPath, context) {
6858
- const workDir = join6(resolve10(context.projectRoot), ".gencow");
7018
+ const workDir = join7(resolve11(context.projectRoot), ".gencow");
6859
7019
  await mkdir(workDir, { recursive: true });
6860
- const tempDir = await mkdtemp(join6(workDir, "codegen-extract-"));
6861
- const outFile = join6(tempDir, "index.mjs");
7020
+ const tempDir = await mkdtemp(join7(workDir, "codegen-extract-"));
7021
+ const outFile = join7(tempDir, "index.mjs");
7022
+ let inputFiles = [];
6862
7023
  try {
6863
7024
  const { build } = await loadEsbuildModule();
6864
- await build({
7025
+ const result = await build({
6865
7026
  entryPoints: [entryPath],
6866
7027
  outfile: outFile,
6867
7028
  bundle: true,
@@ -6872,6 +7033,7 @@ async function transpileTypescriptForNodeDefault(entryPath, context) {
6872
7033
  logLevel: "silent",
6873
7034
  packages: "external",
6874
7035
  external: [...nodeBuiltinExternals, "bun", "bun:*"],
7036
+ metafile: true,
6875
7037
  banner: {
6876
7038
  js: [
6877
7039
  'import { createRequire as __gencowCreateRequire } from "node:module";',
@@ -6879,6 +7041,7 @@ async function transpileTypescriptForNodeDefault(entryPath, context) {
6879
7041
  ].join("\n")
6880
7042
  }
6881
7043
  });
7044
+ inputFiles = Object.keys(result?.metafile?.inputs ?? {}).map((file2) => resolve11(file2));
6882
7045
  } catch (error62) {
6883
7046
  const details = error62 instanceof Error ? error62.message : String(error62);
6884
7047
  throw new Error(
@@ -6890,6 +7053,20 @@ async function transpileTypescriptForNodeDefault(entryPath, context) {
6890
7053
  ].join("\n")
6891
7054
  );
6892
7055
  }
7056
+ const missingImports = formatMissingNamedImports(
7057
+ findMissingNamedImports(inputFiles, context.projectRoot),
7058
+ context.projectRoot
7059
+ );
7060
+ if (missingImports.length > 0) {
7061
+ throw new Error(
7062
+ [
7063
+ "Failed to transpile TypeScript entry for codegen extraction.",
7064
+ `Resolved entry: ${entryPath}`,
7065
+ `Transpile error: Build failed with ${missingImports.length} error${missingImports.length === 1 ? "" : "s"}:`,
7066
+ ...missingImports
7067
+ ].join("\n")
7068
+ );
7069
+ }
6893
7070
  return {
6894
7071
  modulePath: outFile,
6895
7072
  cleanup: async () => {
@@ -6994,10 +7171,10 @@ async function runCodegen2(input2) {
6994
7171
 
6995
7172
  // ../shared/src/analyzer/consumers/doctor/run-app-doctor.ts
6996
7173
  import { existsSync as existsSync10, mkdirSync as mkdirSync3, readFileSync as readFileSync9, renameSync, rmSync as rmSync2, writeFileSync as writeFileSync4 } from "fs";
6997
- import { dirname as dirname9, resolve as resolve15 } from "path";
7174
+ import { dirname as dirname9, resolve as resolve16 } from "path";
6998
7175
 
6999
7176
  // ../shared/src/analyzer/shared/deprecated-api-fix-plugin.ts
7000
- import { dirname as dirname4, relative as relative4 } from "path";
7177
+ import { dirname as dirname4, relative as relative5 } from "path";
7001
7178
  var DEPRECATED_CORE_IMPORTS = {
7002
7179
  query: {
7003
7180
  code: "DOC_DEPRECATED_QUERY_API",
@@ -7051,7 +7228,7 @@ function stripExtension(pathValue) {
7051
7228
  }
7052
7229
  function toImportSpecifier2(fromFile, targetFile) {
7053
7230
  const fromDir = dirname4(fromFile);
7054
- const rel = relative4(fromDir, stripExtension(targetFile)).replace(/\\/g, "/");
7231
+ const rel = relative5(fromDir, stripExtension(targetFile)).replace(/\\/g, "/");
7055
7232
  if (!rel || rel === ".") return "./ai";
7056
7233
  return rel.startsWith(".") ? rel : `./${rel}`;
7057
7234
  }
@@ -7189,12 +7366,12 @@ function createDeprecatedApiFixPlugin() {
7189
7366
  import { readFileSync as readFileSync8 } from "fs";
7190
7367
 
7191
7368
  // ../shared/src/analyzer/adapters/app-schema-graph.ts
7192
- import { basename, dirname as dirname6, join as join8, resolve as resolve12 } from "path";
7369
+ import { basename, dirname as dirname6, join as join9, resolve as resolve13 } from "path";
7193
7370
  import { existsSync as existsSync7, readFileSync as readFileSync5 } from "fs";
7194
7371
 
7195
7372
  // ../shared/src/analyzer/internal/source-files.ts
7196
7373
  import { existsSync as existsSync6, readdirSync as readdirSync2, readFileSync as readFileSync4, statSync as statSync3 } from "fs";
7197
- import { dirname as dirname5, join as join7, relative as relative5, resolve as resolve11 } from "path";
7374
+ import { dirname as dirname5, join as join8, relative as relative6, resolve as resolve12 } from "path";
7198
7375
  var SOURCE_FILE_EXTENSIONS2 = [".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".mjs", ".cjs"];
7199
7376
  function findSourceFiles(dir) {
7200
7377
  if (!existsSync6(dir)) return [];
@@ -7209,7 +7386,7 @@ function findSourceFiles(dir) {
7209
7386
  try {
7210
7387
  for (const entry of readdirSync2(dir, { withFileTypes: true })) {
7211
7388
  if (entry.name === "node_modules" || entry.name.startsWith(".")) continue;
7212
- const fullPath = join7(dir, entry.name);
7389
+ const fullPath = join8(dir, entry.name);
7213
7390
  if (entry.isDirectory()) {
7214
7391
  files.push(...findSourceFiles(fullPath));
7215
7392
  continue;
@@ -7251,18 +7428,18 @@ function findStaticRelativeImports(filePath) {
7251
7428
  const imports = /* @__PURE__ */ new Set();
7252
7429
  for (const specifier of parseModuleSpecifiers(source)) {
7253
7430
  if (!specifier.startsWith(".")) continue;
7254
- const resolved = resolveRelativeModule(filePath, specifier);
7431
+ const resolved = resolveRelativeModule2(filePath, specifier);
7255
7432
  if (resolved) imports.add(resolved);
7256
7433
  }
7257
7434
  return [...imports];
7258
7435
  }
7259
- function resolveRelativeModule(fromPath, specifier) {
7436
+ function resolveRelativeModule2(fromPath, specifier) {
7260
7437
  if (!specifier.startsWith(".")) return null;
7261
- const base = resolve11(dirname5(fromPath), specifier);
7438
+ const base = resolve12(dirname5(fromPath), specifier);
7262
7439
  return resolveSourceFileCandidate(base);
7263
7440
  }
7264
7441
  function toProjectPath(projectRootAbs, absPath) {
7265
- const relPath = relative5(projectRootAbs, absPath).replace(/\\/g, "/");
7442
+ const relPath = relative6(projectRootAbs, absPath).replace(/\\/g, "/");
7266
7443
  return relPath.startsWith(".") ? relPath : `./${relPath}`;
7267
7444
  }
7268
7445
  function resolveSourceFileCandidate(base) {
@@ -7279,7 +7456,7 @@ function resolveSourceFileCandidate(base) {
7279
7456
  base,
7280
7457
  ...typescriptSubstitutions,
7281
7458
  ...SOURCE_FILE_EXTENSIONS2.map((extension) => `${base}${extension}`),
7282
- ...SOURCE_FILE_EXTENSIONS2.map((extension) => join7(base, `index${extension}`))
7459
+ ...SOURCE_FILE_EXTENSIONS2.map((extension) => join8(base, `index${extension}`))
7283
7460
  ];
7284
7461
  return candidates.find((candidate) => existsSync6(candidate)) ?? null;
7285
7462
  }
@@ -7345,12 +7522,12 @@ function parseJsoncObject(filePath) {
7345
7522
  function resolveTsConfigExtendsPath(configFile, extendsValue) {
7346
7523
  if (!extendsValue.startsWith(".") && !extendsValue.startsWith("/")) return null;
7347
7524
  const configDir = dirname5(configFile);
7348
- const rawPath = extendsValue.startsWith("/") ? extendsValue : resolve11(configDir, extendsValue);
7349
- const candidates = rawPath.endsWith(".json") ? [rawPath] : [rawPath, `${rawPath}.json`, join7(rawPath, "tsconfig.json")];
7525
+ const rawPath = extendsValue.startsWith("/") ? extendsValue : resolve12(configDir, extendsValue);
7526
+ const candidates = rawPath.endsWith(".json") ? [rawPath] : [rawPath, `${rawPath}.json`, join8(rawPath, "tsconfig.json")];
7350
7527
  return candidates.find((candidate) => existsSync6(candidate)) ?? null;
7351
7528
  }
7352
7529
  function loadTsConfigCompilerOptions(configFile, seen = /* @__PURE__ */ new Set()) {
7353
- const resolvedConfigFile = resolve11(configFile);
7530
+ const resolvedConfigFile = resolve12(configFile);
7354
7531
  if (seen.has(resolvedConfigFile)) return {};
7355
7532
  seen.add(resolvedConfigFile);
7356
7533
  const parsed = parseJsoncObject(resolvedConfigFile);
@@ -7380,13 +7557,13 @@ function loadTsConfigCompilerOptions(configFile, seen = /* @__PURE__ */ new Set(
7380
7557
  }
7381
7558
  function findNearestProjectConfigFiles(startDir) {
7382
7559
  const configFiles = [];
7383
- let currentDir = resolve11(startDir);
7560
+ let currentDir = resolve12(startDir);
7384
7561
  const visited = /* @__PURE__ */ new Set();
7385
7562
  while (!visited.has(currentDir)) {
7386
7563
  visited.add(currentDir);
7387
7564
  const discovered = /* @__PURE__ */ new Set();
7388
7565
  for (const filename of ["tsconfig.json", "jsconfig.json"]) {
7389
- const configPath = join7(currentDir, filename);
7566
+ const configPath = join8(currentDir, filename);
7390
7567
  if (!existsSync6(configPath)) continue;
7391
7568
  configFiles.push(configPath);
7392
7569
  discovered.add(filename);
@@ -7394,7 +7571,7 @@ function findNearestProjectConfigFiles(startDir) {
7394
7571
  try {
7395
7572
  const extraConfigFiles = readdirSync2(currentDir).filter((filename) => !discovered.has(filename) && /^tsconfig\.[^.]+\.json$/i.test(filename)).sort();
7396
7573
  for (const filename of extraConfigFiles) {
7397
- configFiles.push(join7(currentDir, filename));
7574
+ configFiles.push(join8(currentDir, filename));
7398
7575
  }
7399
7576
  } catch {
7400
7577
  }
@@ -7422,20 +7599,20 @@ function resolveTsconfigAliasImportFile(importerFile, specifier) {
7422
7599
  for (const configFile of findNearestProjectConfigFiles(dirname5(importerFile))) {
7423
7600
  const compilerOptions = loadTsConfigCompilerOptions(configFile);
7424
7601
  const configDir = dirname5(configFile);
7425
- const baseDir = compilerOptions.baseUrl ? resolve11(configDir, compilerOptions.baseUrl) : configDir;
7602
+ const baseDir = compilerOptions.baseUrl ? resolve12(configDir, compilerOptions.baseUrl) : configDir;
7426
7603
  for (const [pattern, targets] of Object.entries(compilerOptions.paths ?? {})) {
7427
7604
  const wildcardValue = matchTsconfigPathPattern(specifier, pattern);
7428
7605
  if (wildcardValue === null) continue;
7429
7606
  for (const target of targets) {
7430
7607
  const substituted = substituteTsconfigPathTarget(target, wildcardValue);
7431
7608
  if (!substituted) continue;
7432
- const resolvedTarget = substituted.startsWith("/") ? substituted : resolve11(baseDir, substituted);
7609
+ const resolvedTarget = substituted.startsWith("/") ? substituted : resolve12(baseDir, substituted);
7433
7610
  const candidate = resolveSourceFileCandidate(resolvedTarget);
7434
7611
  if (candidate) return candidate;
7435
7612
  }
7436
7613
  }
7437
7614
  if (compilerOptions.baseUrl) {
7438
- const candidate = resolveSourceFileCandidate(resolve11(baseDir, specifier));
7615
+ const candidate = resolveSourceFileCandidate(resolve12(baseDir, specifier));
7439
7616
  if (candidate) return candidate;
7440
7617
  }
7441
7618
  }
@@ -7443,7 +7620,7 @@ function resolveTsconfigAliasImportFile(importerFile, specifier) {
7443
7620
  }
7444
7621
  function resolveImportedSourceFile(importerFile, specifier) {
7445
7622
  if (specifier.startsWith(".")) {
7446
- return resolveRelativeModule(importerFile, specifier);
7623
+ return resolveRelativeModule2(importerFile, specifier);
7447
7624
  }
7448
7625
  if (specifier.startsWith("/")) {
7449
7626
  return resolveSourceFileCandidate(specifier);
@@ -7482,9 +7659,9 @@ function resolveSourceEntrypoint(basePath) {
7482
7659
  for (const candidate of directFileCandidates) {
7483
7660
  if (existsSync6(candidate)) return candidate;
7484
7661
  }
7485
- const indexCandidate = resolveSourceFileCandidate(join7(basePath, "index"));
7662
+ const indexCandidate = resolveSourceFileCandidate(join8(basePath, "index"));
7486
7663
  if (indexCandidate) return indexCandidate;
7487
- return join7(basePath, "index.ts");
7664
+ return join8(basePath, "index.ts");
7488
7665
  }
7489
7666
 
7490
7667
  // ../shared/src/analyzer/adapters/app-schema-graph.ts
@@ -7511,7 +7688,7 @@ function collectReachableSchemaModules(project) {
7511
7688
  function collectSchemaOwners(project, modulePaths) {
7512
7689
  const owners = [];
7513
7690
  for (const modulePath of modulePaths) {
7514
- const absPath = resolve12(project.projectRootAbs, modulePath);
7691
+ const absPath = resolve13(project.projectRootAbs, modulePath);
7515
7692
  if (!existsSync7(absPath)) continue;
7516
7693
  const source = safeReadText(absPath);
7517
7694
  if (source === null) continue;
@@ -7554,7 +7731,7 @@ function collectHiddenSchemaOwners(project, reachableModules) {
7554
7731
  function collectDynamicSchemaEdges(project, modulePaths) {
7555
7732
  const dynamic = /* @__PURE__ */ new Set();
7556
7733
  for (const modulePath of modulePaths) {
7557
- const absPath = resolve12(project.projectRootAbs, modulePath);
7734
+ const absPath = resolve13(project.projectRootAbs, modulePath);
7558
7735
  if (!existsSync7(absPath)) continue;
7559
7736
  const source = safeReadText(absPath);
7560
7737
  if (source === null) continue;
@@ -7565,7 +7742,7 @@ function collectDynamicSchemaEdges(project, modulePaths) {
7565
7742
  return [...dynamic].sort();
7566
7743
  }
7567
7744
  function detectAuthBoundary(project) {
7568
- const userAuthPath = join8(project.functionsDirAbs, "schema-auth.ts");
7745
+ const userAuthPath = join9(project.functionsDirAbs, "schema-auth.ts");
7569
7746
  if (existsSync7(userAuthPath)) {
7570
7747
  const source = safeReadText(userAuthPath);
7571
7748
  if (source === null) {
@@ -7617,9 +7794,9 @@ function resolveSchemaAuthGeneratedTarget(schemaAuthPathAbs, source) {
7617
7794
  /(?:export|import)\s+[^;\n]*\bfrom\s+["']([^"']*schema-auth\.gen(?:\.[cm]?[jt]sx?)?)["']/m
7618
7795
  );
7619
7796
  if (!match) {
7620
- return resolve12(dirname6(schemaAuthPathAbs), "./generated/schema-auth.gen.ts");
7797
+ return resolve13(dirname6(schemaAuthPathAbs), "./generated/schema-auth.gen.ts");
7621
7798
  }
7622
- return resolve12(dirname6(schemaAuthPathAbs), match[1]);
7799
+ return resolve13(dirname6(schemaAuthPathAbs), match[1]);
7623
7800
  }
7624
7801
  function classifySchemaSourceKind(pathValue) {
7625
7802
  const normalized = pathValue.replace(/\\/g, "/");
@@ -7656,11 +7833,11 @@ function dedupeOwners(owners) {
7656
7833
 
7657
7834
  // ../shared/src/analyzer/adapters/app-project.ts
7658
7835
  import { existsSync as existsSync8, statSync as statSync4 } from "fs";
7659
- import { dirname as dirname7, isAbsolute as isAbsolute3, resolve as resolve13 } from "path";
7836
+ import { dirname as dirname7, isAbsolute as isAbsolute3, resolve as resolve14 } from "path";
7660
7837
  function resolveAppProject(input2) {
7661
- const projectRootAbs = resolve13(input2.projectRoot);
7838
+ const projectRootAbs = resolve14(input2.projectRoot);
7662
7839
  const rootDir = input2.rootDir ?? input2.functionsDir ?? "gencow";
7663
- const functionsDirAbs = isAbsolute3(rootDir) ? rootDir : resolve13(projectRootAbs, rootDir);
7840
+ const functionsDirAbs = isAbsolute3(rootDir) ? rootDir : resolve14(projectRootAbs, rootDir);
7664
7841
  const entryPointAbs = resolveSourceEntrypoint(functionsDirAbs);
7665
7842
  const sourceBaseAbs = isExistingDirectory(functionsDirAbs) ? functionsDirAbs : dirname7(entryPointAbs);
7666
7843
  const sourceFilesAbs = existsSync8(entryPointAbs) ? collectReachableSourceFiles(entryPointAbs) : isExistingDirectory(functionsDirAbs) ? findSourceFiles(functionsDirAbs) : [];
@@ -7669,14 +7846,14 @@ function resolveAppProject(input2) {
7669
7846
  functionsDirAbs,
7670
7847
  input2.serverPublishDir
7671
7848
  );
7672
- const clientCodegenDirAbs = input2.clientOutDir === false ? null : resolve13(projectRootAbs, input2.clientOutDir ?? "./src/gencow");
7849
+ const clientCodegenDirAbs = input2.clientOutDir === false ? null : resolve14(projectRootAbs, input2.clientOutDir ?? "./src/gencow");
7673
7850
  const configuredSchemaPathsAbs = resolveAuthSchemaPaths(
7674
7851
  projectRootAbs,
7675
7852
  functionsDirAbs,
7676
7853
  input2.schema,
7677
7854
  serverCodegenDirAbs
7678
7855
  );
7679
- const rootSchemaPathAbs = configuredSchemaPathsAbs.find((path) => path.replace(/\\/g, "/").endsWith("/schema.ts")) ?? configuredSchemaPathsAbs[0] ?? resolve13(functionsDirAbs, "schema.ts");
7856
+ const rootSchemaPathAbs = configuredSchemaPathsAbs.find((path) => path.replace(/\\/g, "/").endsWith("/schema.ts")) ?? configuredSchemaPathsAbs[0] ?? resolve14(functionsDirAbs, "schema.ts");
7680
7857
  return {
7681
7858
  projectRootAbs,
7682
7859
  functionsDirAbs,
@@ -7698,7 +7875,7 @@ function isExistingDirectory(pathValue) {
7698
7875
  }
7699
7876
 
7700
7877
  // ../shared/src/analyzer/shared/db-operation-inspector.ts
7701
- import { basename as basename2, relative as relative6 } from "path";
7878
+ import { basename as basename2, relative as relative7 } from "path";
7702
7879
  import { readFileSync as readFileSync6 } from "fs";
7703
7880
  var ALLOW_COMMENT = "gencow-allow-unsafe-db";
7704
7881
  var SYSTEM_TABLE_PATTERN = /\b_(?:system|gencow)_[a-zA-Z0-9_]*\b/;
@@ -7722,7 +7899,7 @@ function collectDbOperations(project) {
7722
7899
  ]
7723
7900
  }));
7724
7901
  for (const file2 of findSourceFiles(project.sourceBaseAbs)) {
7725
- const relPath = relative6(project.sourceBaseAbs, file2);
7902
+ const relPath = relative7(project.sourceBaseAbs, file2);
7726
7903
  if (!isSeedFile(relPath)) continue;
7727
7904
  const content = safeReadText2(file2);
7728
7905
  if (content === null) continue;
@@ -7743,7 +7920,7 @@ function collectUnsafeDbIssues(project) {
7743
7920
  for (const file2 of findSourceFiles(project.sourceBaseAbs)) {
7744
7921
  const content = safeReadText2(file2);
7745
7922
  if (content === null) continue;
7746
- const relPath = relative6(project.sourceBaseAbs, file2);
7923
+ const relPath = relative7(project.sourceBaseAbs, file2);
7747
7924
  if (isSeedFile(relPath)) continue;
7748
7925
  const operations = findPublicOperationRanges(content);
7749
7926
  const executableLines = maskComments(content).split("\n");
@@ -8173,7 +8350,7 @@ function createSourcePatternsPlugin() {
8173
8350
 
8174
8351
  // ../shared/src/analyzer/consumers/auditor/source-auditor.ts
8175
8352
  import { existsSync as existsSync9 } from "fs";
8176
- import { basename as basename3, dirname as dirname8, extname, resolve as resolve14 } from "path";
8353
+ import { basename as basename3, dirname as dirname8, extname, resolve as resolve15 } from "path";
8177
8354
 
8178
8355
  // ../shared/src/analyzer/consumers/auditor/source-auditor-shared.ts
8179
8356
  import { readFileSync as readFileSync7 } from "fs";
@@ -8357,7 +8534,7 @@ function describeAnalyzerFunctionsLabel(entryPoint) {
8357
8534
  }
8358
8535
  function isGeneratedFrontendClientPath(project, file2) {
8359
8536
  if (project.clientCodegenDirAbs === null) return false;
8360
- const normalizedFile = resolve14(file2).replace(/\\/g, "/");
8537
+ const normalizedFile = resolve15(file2).replace(/\\/g, "/");
8361
8538
  const normalizedClientOutDir = project.clientCodegenDirAbs.replace(/\\/g, "/").replace(/\/+$/, "");
8362
8539
  return normalizedFile === normalizedClientOutDir || normalizedFile.startsWith(`${normalizedClientOutDir}/`);
8363
8540
  }
@@ -8537,7 +8714,7 @@ function printAnalyzerDataIsolationReport(result) {
8537
8714
  }
8538
8715
  }
8539
8716
  function auditAnalyzerFrontendAntiPatterns(project) {
8540
- const srcDir = resolve14(project.projectRootAbs, "src");
8717
+ const srcDir = resolve15(project.projectRootAbs, "src");
8541
8718
  const issues = [];
8542
8719
  if (!existsSync9(srcDir)) {
8543
8720
  return { issues };
@@ -9342,7 +9519,7 @@ function formatArtifactPatch(plan) {
9342
9519
  function snapshotTouchedFiles(projectRoot, touchedFiles) {
9343
9520
  const snapshots = /* @__PURE__ */ new Map();
9344
9521
  for (const file2 of touchedFiles) {
9345
- const absPath = resolve15(projectRoot, file2);
9522
+ const absPath = resolve16(projectRoot, file2);
9346
9523
  if (!existsSync10(absPath)) {
9347
9524
  snapshots.set(file2, { existed: false, content: null });
9348
9525
  continue;
@@ -9356,7 +9533,7 @@ function snapshotTouchedFiles(projectRoot, touchedFiles) {
9356
9533
  }
9357
9534
  function restoreTouchedFiles(projectRoot, snapshots) {
9358
9535
  for (const [file2, snapshot] of snapshots.entries()) {
9359
- const absPath = resolve15(projectRoot, file2);
9536
+ const absPath = resolve16(projectRoot, file2);
9360
9537
  if (!snapshot.existed) {
9361
9538
  rmSync2(absPath, { force: true });
9362
9539
  continue;
@@ -9443,7 +9620,7 @@ function createDoctorFixApplier() {
9443
9620
  }
9444
9621
  snapshots = snapshotTouchedFiles(projectRoot, touchedFiles);
9445
9622
  for (const [file2, edits] of editsByFile.entries()) {
9446
- const absPath = resolve15(projectRoot, file2);
9623
+ const absPath = resolve16(projectRoot, file2);
9447
9624
  const replaceEdits = edits.filter(
9448
9625
  (edit) => edit.kind === "replace-range"
9449
9626
  );
@@ -9465,12 +9642,12 @@ function createDoctorFixApplier() {
9465
9642
  writeFileSync4(absPath, nextSource);
9466
9643
  }
9467
9644
  if (createEdit) {
9468
- const createPath = resolve15(projectRoot, createEdit.file);
9645
+ const createPath = resolve16(projectRoot, createEdit.file);
9469
9646
  ensureParentDir(createPath);
9470
9647
  writeFileSync4(createPath, createEdit.content);
9471
9648
  }
9472
9649
  if (renameEdit) {
9473
- const targetPath = resolve15(projectRoot, renameEdit.to);
9650
+ const targetPath = resolve16(projectRoot, renameEdit.to);
9474
9651
  if (existsSync10(targetPath)) {
9475
9652
  throw new Error(`Cannot rename ${renameEdit.from} because target already exists: ${renameEdit.to}`);
9476
9653
  }
@@ -14601,7 +14778,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
14601
14778
  var NONE = 0;
14602
14779
  var ASSUMED = 1;
14603
14780
  var PROVEN = 2;
14604
- function isRecursive(inst, stack, resolve16) {
14781
+ function isRecursive(inst, stack, resolve17) {
14605
14782
  const cached2 = recursive.get(inst);
14606
14783
  if (cached2 !== void 0)
14607
14784
  return cached2 ? PROVEN : NONE;
@@ -14611,7 +14788,7 @@ function isRecursive(inst, stack, resolve16) {
14611
14788
  let result = NONE;
14612
14789
  const check2 = (child) => {
14613
14790
  if (result !== PROVEN && child?._zod) {
14614
- const answer = isRecursive(child, stack, resolve16);
14791
+ const answer = isRecursive(child, stack, resolve17);
14615
14792
  if (answer > result)
14616
14793
  result = answer;
14617
14794
  }
@@ -14622,7 +14799,7 @@ function isRecursive(inst, stack, resolve16) {
14622
14799
  const desc = Object.getOwnPropertyDescriptor(sh, key);
14623
14800
  if (spread && !desc.enumerable)
14624
14801
  continue;
14625
- const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve16) : NONE;
14802
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve17) : NONE;
14626
14803
  if (child > answer)
14627
14804
  answer = child;
14628
14805
  }
@@ -14686,7 +14863,7 @@ function isRecursive(inst, stack, resolve16) {
14686
14863
  break;
14687
14864
  // `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
14688
14865
  case "lazy": {
14689
- const inner = def._cachedInner ?? (resolve16 ? inst._zod.innerType : void 0);
14866
+ const inner = def._cachedInner ?? (resolve17 ? inst._zod.innerType : void 0);
14690
14867
  merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
14691
14868
  break;
14692
14869
  }