cvx-kit 0.1.27 → 0.1.29
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/auth.d.mts +34 -4
- package/dist/auth.mjs +1 -1
- package/dist/auth.mjs.map +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/modules/effect/auth.d.mts +5 -1
- package/dist/modules/effect/auth.mjs +1 -1
- package/dist/modules/effect/auth.mjs.map +1 -1
- package/dist/oxlint/architecture.d.mts +3 -1
- package/dist/oxlint/architecture.mjs +1 -1
- package/dist/oxlint/architecture.mjs.map +1 -1
- package/dist/oxlint/ast.d.mts +2 -0
- package/dist/oxlint/ast.mjs +1 -1
- package/dist/oxlint/ast.mjs.map +1 -1
- package/dist/oxlint/components.d.mts +6 -0
- package/dist/oxlint/components.mjs +2 -0
- package/dist/oxlint/components.mjs.map +1 -0
- package/dist/oxlint/ownership.mjs +1 -1
- package/dist/oxlint/ownership.mjs.map +1 -1
- package/dist/oxlint.mjs +1 -1
- package/dist/oxlint.mjs.map +1 -1
- package/dist/relations.mjs +1 -1
- package/dist/relations.mjs.map +1 -1
- package/dist/triggers.d.mts +5 -1
- package/dist/triggers.mjs +1 -1
- package/dist/triggers.mjs.map +1 -1
- package/dist/zod-registration.d.mts +6 -1
- package/dist/zod-registration.mjs +1 -1
- package/dist/zod-registration.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"architecture.mjs","names":["inspectArchitecture","requestedRoot","resolve","options","root","existsSync","realpathSync","diagnostics","files","sourceFiles","required","tested","graph","dependencies","resolver","createResolver","file","filename","parsed","parseSync","readFileSync","testFile","dirname","hasRunnableTest","executable","narrowRootDeclaration","owner","moduleOwner","targets","source","runtimeImports","target","resolveImport","targetFile","relative","sep","targetOwner","edges","directory","sharedOwnership","cycle","cycles","a","b","ResolverFactory","architectureAnchor","factory","imports","aliases","factories","exported","factoryName","node","active","init","declarative","relationParameter","registryCallback","value","property","body","callee","path","argument","statement","specifier","declaration","item","index","allowed","scan","entry","readdirSync","program","names","calls","Visitor","skipped","parts","testCallee","part","skip","name","base","s","completed","stack","found","visit","dependency","consumers","visited","owners","next"],"sources":["../../src/oxlint/architecture.ts"],"sourcesContent":["import { existsSync, readdirSync, readFileSync, realpathSync } from 'node:fs'\nimport { dirname, relative, resolve, sep } from 'node:path'\nimport { parseSync, Visitor, type Program, type Node, type CallExpression } from 'oxc-parser'\nimport { ResolverFactory } from 'oxc-resolver'\n\nexport interface ArchitectureOptions {\n\tcwd?: string\n\tconvexDir?: string\n\t/** Build these registries to surface deferred configuration errors in tests. */\n\tregistries?: readonly object[]\n}\nexport interface ArchitectureDiagnostic {\n\tcode:\n\t\t| 'missing-root'\n\t\t| 'root-directory'\n\t\t| 'tests'\n\t\t| 'test-location'\n\t\t| 'parse'\n\t\t| 'cycle'\n\t\t| 'symlink'\n\t\t| 'domain-entry'\n\t\t| 'shared-owner'\n\tfile: string\n\tmessage: string\n}\n\n/** Full-project checks, independent of the consumer's test runner. No persistent cache. */\nexport function inspectArchitecture(options: ArchitectureOptions = {}): ArchitectureDiagnostic[] {\n\tconst requestedRoot = resolve(options.cwd ?? process.cwd(), options.convexDir ?? 'convex')\n\tconst root = existsSync(requestedRoot) ? realpathSync(requestedRoot) : requestedRoot\n\tconst diagnostics: ArchitectureDiagnostic[] = []\n\tif (!existsSync(root))\n\t\treturn [\n\t\t\t{ code: 'missing-root', file: '.', message: `Convex directory does not exist: ${root}` },\n\t\t]\n\tconst files = sourceFiles(root, diagnostics)\n\tconst required = new Set<string>()\n\tconst tested = new Set<string>()\n\tconst graph = new Map<string, Set<string>>()\n\tconst dependencies = new Map<string, Set<string>>()\n\tconst resolver = createResolver()\n\tfor (const file of files) {\n\t\tconst filename = resolve(root, file)\n\t\tconst parsed = parseSync(filename, readFileSync(filename, 'utf8'))\n\t\tif (parsed.errors.length) {\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: 'parse',\n\t\t\t\tfile,\n\t\t\t\tmessage: `Cannot validate ${file}: ${parsed.errors[0].message}`,\n\t\t\t})\n\t\t\tcontinue\n\t\t}\n\t\tif (testFile(file)) {\n\t\t\tif (!file.includes('__tests__/'))\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\tcode: 'test-location',\n\t\t\t\t\tfile,\n\t\t\t\t\tmessage: 'Place tests in a sibling __tests__/ directory.',\n\t\t\t\t})\n\t\t\telse if (dirname(file).endsWith('__tests__') && hasRunnableTest(parsed.program))\n\t\t\t\ttested.add(dirname(dirname(file)))\n\t\t\tcontinue\n\t\t}\n\t\tif (file.split('/').includes('__tests__')) continue\n\t\tif (/^domain\\/[^/]+$/.test(file) && file !== 'domain/table.ts')\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: 'domain-entry',\n\t\t\t\tfile,\n\t\t\t\tmessage:\n\t\t\t\t\t'Domain source belongs in domain/<module>/ or domain/shared/. Only domain/table.ts assembles module tables.',\n\t\t\t})\n\t\tif (\n\t\t\texecutable(parsed.program) &&\n\t\t\tfile !== 'domain/table.ts' &&\n\t\t\t!narrowRootDeclaration(file, readFileSync(filename, 'utf8'))\n\t\t)\n\t\t\trequired.add(dirname(file))\n\t\tconst owner = moduleOwner(file) ?? ''\n\t\tconst targets = new Set<string>()\n\t\tdependencies.set(file, targets)\n\t\tfor (const source of runtimeImports(parsed.program)) {\n\t\t\tconst target = resolveImport(resolver, filename, source)\n\t\t\tif (!target) continue\n\t\t\tconst targetFile = relative(root, target).split(sep).join('/')\n\t\t\ttargets.add(targetFile)\n\t\t\tconst targetOwner = moduleOwner(targetFile)\n\t\t\tif (owner && targetOwner && owner !== targetOwner) {\n\t\t\t\tconst edges = graph.get(owner) ?? new Set<string>()\n\t\t\t\tgraph.set(owner, edges)\n\t\t\t\tedges.add(targetOwner)\n\t\t\t}\n\t\t}\n\t}\n\tfor (const directory of required) {\n\t\tif (!tested.has(directory))\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: 'tests',\n\t\t\t\tfile: directory,\n\t\t\t\tmessage: `${directory}/__tests__/ must contain a .test or .spec file with a nonempty, non-skipped test. Parent or child suites do not count.`,\n\t\t\t})\n\t}\n\tdiagnostics.push(...sharedOwnership(dependencies))\n\tfor (const cycle of cycles(graph))\n\t\tdiagnostics.push({\n\t\t\tcode: 'cycle',\n\t\t\tfile: cycle[0],\n\t\t\tmessage: `Module dependency cycle: ${cycle.join(' → ')}.`,\n\t\t})\n\treturn diagnostics.sort((a, b) => a.file.localeCompare(b.file) || a.code.localeCompare(b.code))\n}\n\nexport function createResolver() {\n\treturn new ResolverFactory({\n\t\ttsconfig: 'auto',\n\t\textensions: ['.ts', '.tsx', '.mts', '.cts', '.js', '.jsx', '.mjs', '.cjs', '.json'],\n\t\textensionAlias: {\n\t\t\t'.js': ['.ts', '.tsx', '.js'],\n\t\t\t'.mjs': ['.mts', '.mjs'],\n\t\t\t'.cjs': ['.cts', '.cjs'],\n\t\t},\n\t\tconditionNames: ['types', 'import', 'node', 'default'],\n\t\tsymlinks: true,\n\t})\n}\n\nexport function resolveImport(resolver: ResolverFactory, filename: string, source: string) {\n\tconst found = resolver.resolveFileSync(filename, source).path\n\tif (found) return found\n\t// Keep path checks useful in unsaved/editor fixtures and before Convex codegen.\n\treturn source.startsWith('.') ? resolve(dirname(filename), source) : null\n}\n\n/** The lint rule runs the project scan on one deterministic source file. */\nexport function architectureAnchor(root: string) {\n\tif (!existsSync(root)) return null\n\tif (existsSync(resolve(root, 'convex.config.ts')))\n\t\treturn realpathSync(resolve(root, 'convex.config.ts'))\n\troot = realpathSync(root)\n\tfor (const file of sourceFiles(root, []))\n\t\tif (!file.includes('__tests__/') && !testFile(file)) return resolve(root, file)\n\treturn null\n}\n\n/** Only these two factory declarations may omit root business ownership. */\nexport function narrowRootDeclaration(file: string, source: string): boolean {\n\tconst factory =\n\t\tfile === 'relations.ts'\n\t\t\t? 'defineRelations'\n\t\t\t: file === 'querying.ts'\n\t\t\t\t? 'createQueryEngine'\n\t\t\t\t: null\n\tif (!factory) return false\n\tconst parsed = parseSync(file, source)\n\tif (parsed.errors.length) return false\n\tconst imports = new Map<string, string>()\n\tconst aliases = new Map<string, Node>()\n\tlet factories = 0\n\tlet exported = false\n\tfunction factoryName(node: Node, active = new Set<string>()): string | null {\n\t\tif (node.type === 'Identifier') {\n\t\t\tif (active.has(node.name)) return null\n\t\t\tconst init = aliases.get(node.name)\n\t\t\treturn init\n\t\t\t\t? factoryName(init, new Set(active).add(node.name))\n\t\t\t\t: (imports.get(node.name) ?? null)\n\t\t}\n\t\tif (\n\t\t\tnode.type === 'MemberExpression' &&\n\t\t\t!node.computed &&\n\t\t\tnode.property.type === 'Identifier' &&\n\t\t\tfactoryName(node.object, active) === '*'\n\t\t)\n\t\t\treturn node.property.name\n\t\treturn null\n\t}\n\tfunction declarative(node: Node, relationParameter?: string, registryCallback = false): boolean {\n\t\tif (node.type === 'Identifier' || node.type === 'Literal') return true\n\t\tif (\n\t\t\tnode.type === 'TSAsExpression' ||\n\t\t\tnode.type === 'TSSatisfiesExpression' ||\n\t\t\tnode.type === 'ParenthesizedExpression'\n\t\t)\n\t\t\treturn declarative(node.expression, relationParameter, registryCallback)\n\t\tif (node.type === 'MemberExpression')\n\t\t\treturn !node.computed && declarative(node.object, relationParameter)\n\t\tif (node.type === 'ArrayExpression')\n\t\t\treturn node.elements.every((value) => value !== null && declarative(value, relationParameter))\n\t\tif (node.type === 'ObjectExpression')\n\t\t\treturn node.properties.every(\n\t\t\t\t(property) =>\n\t\t\t\t\tproperty.type === 'Property' &&\n\t\t\t\t\t!property.computed &&\n\t\t\t\t\tproperty.kind === 'init' &&\n\t\t\t\t\t!property.method &&\n\t\t\t\t\tdeclarative(property.value, relationParameter),\n\t\t\t)\n\t\tif (\n\t\t\tnode.type === 'ArrowFunctionExpression' &&\n\t\t\tregistryCallback &&\n\t\t\t!relationParameter &&\n\t\t\tnode.params.length === 1 &&\n\t\t\tnode.params[0].type === 'Identifier' &&\n\t\t\t!node.async\n\t\t) {\n\t\t\tconst body = node.body.type === 'ParenthesizedExpression' ? node.body.expression : node.body\n\t\t\treturn body.type === 'ObjectExpression' && declarative(body, node.params[0].name)\n\t\t}\n\t\tif (node.type === 'CallExpression' && relationParameter) {\n\t\t\tlet callee: Node = node.callee\n\t\t\tconst path: string[] = []\n\t\t\twhile (\n\t\t\t\tcallee.type === 'MemberExpression' &&\n\t\t\t\t!callee.computed &&\n\t\t\t\tcallee.property.type === 'Identifier'\n\t\t\t) {\n\t\t\t\tpath.unshift(callee.property.name)\n\t\t\t\tcallee = callee.object\n\t\t\t}\n\t\t\treturn (\n\t\t\t\tcallee.type === 'Identifier' &&\n\t\t\t\tcallee.name === relationParameter &&\n\t\t\t\t((path.length === 2 && ['one', 'many'].includes(path[0])) ||\n\t\t\t\t\t(path.length === 3 && path[2] === 'through')) &&\n\t\t\t\tnode.arguments.every((argument) => declarative(argument, relationParameter))\n\t\t\t)\n\t\t}\n\t\treturn false\n\t}\n\tfor (const statement of parsed.program.body) {\n\t\tif (statement.type === 'ImportDeclaration') {\n\t\t\tif (statement.importKind === 'type') continue\n\t\t\tfor (const specifier of statement.specifiers) {\n\t\t\t\tif (specifier.type === 'ImportSpecifier' && specifier.importKind === 'type') continue\n\t\t\t\tif (['cvx-kit', `cvx-kit/${file.slice(0, -3)}`].includes(statement.source.value))\n\t\t\t\t\timports.set(\n\t\t\t\t\t\tspecifier.local.name,\n\t\t\t\t\t\tspecifier.type === 'ImportSpecifier'\n\t\t\t\t\t\t\t? specifier.imported.type === 'Identifier'\n\t\t\t\t\t\t\t\t? specifier.imported.name\n\t\t\t\t\t\t\t\t: ''\n\t\t\t\t\t\t\t: specifier.type === 'ImportNamespaceSpecifier'\n\t\t\t\t\t\t\t\t? '*'\n\t\t\t\t\t\t\t\t: '',\n\t\t\t\t\t)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tif (\n\t\t\tstatement.type === 'EmptyStatement' ||\n\t\t\tstatement.type === 'TSTypeAliasDeclaration' ||\n\t\t\tstatement.type === 'TSInterfaceDeclaration'\n\t\t)\n\t\t\tcontinue\n\t\tconst declaration =\n\t\t\tstatement.type === 'ExportNamedDeclaration' ? statement.declaration : statement\n\t\tif (declaration?.type !== 'VariableDeclaration' || declaration.kind !== 'const') return false\n\t\tfor (const item of declaration.declarations) {\n\t\t\tif (item.id.type !== 'Identifier' || !item.init) return false\n\t\t\tif (item.init.type === 'CallExpression' && factoryName(item.init.callee) === factory) {\n\t\t\t\tif (\n\t\t\t\t\t!item.init.arguments.every((argument, index) =>\n\t\t\t\t\t\tdeclarative(argument, undefined, factory === 'defineRelations' && index === 1),\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t\treturn false\n\t\t\t\tfactories++\n\t\t\t\texported ||= statement.type === 'ExportNamedDeclaration'\n\t\t\t} else if (statement.type === 'ExportNamedDeclaration' || !declarative(item.init))\n\t\t\t\treturn false\n\t\t\taliases.set(item.id.name, item.init)\n\t\t}\n\t}\n\treturn factories === 1 && exported\n}\n\nfunction* sourceFiles(root: string, diagnostics: ArchitectureDiagnostic[]): Generator<string> {\n\tconst allowed = new Set([\n\t\t'_generated',\n\t\t'__tests__',\n\t\t'api',\n\t\t'domain',\n\t\t'application',\n\t\t'migrations',\n\t\t'components',\n\t])\n\tfunction* scan(directory: string): Generator<string> {\n\t\tfor (const entry of readdirSync(directory, { withFileTypes: true }).sort((a, b) =>\n\t\t\ta.name.localeCompare(b.name),\n\t\t)) {\n\t\t\tconst path = resolve(directory, entry.name)\n\t\t\tconst file = relative(root, path).split(sep).join('/')\n\t\t\tif (entry.isSymbolicLink()) {\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\tcode: 'symlink',\n\t\t\t\t\tfile,\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t'Keep application source inside its owning directory; symlinked files and folders are not allowed.',\n\t\t\t\t})\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tif (directory === root && !allowed.has(entry.name))\n\t\t\t\t\tdiagnostics.push({\n\t\t\t\t\t\tcode: 'root-directory',\n\t\t\t\t\t\tfile,\n\t\t\t\t\t\tmessage: `Root folder ${entry.name}/ is not allowed. Use api/, domain/, application/, migrations/, components/, __tests__/, or _generated/.`,\n\t\t\t\t\t})\n\t\t\t\tif (\n\t\t\t\t\tentry.name !== '_generated' &&\n\t\t\t\t\tentry.name !== 'node_modules' &&\n\t\t\t\t\t!entry.name.startsWith('.')\n\t\t\t\t)\n\t\t\t\t\tyield* scan(path)\n\t\t\t} else if (/\\.[cm]?[jt]sx?$/.test(entry.name) && !/\\.d\\.[cm]?ts$/.test(entry.name)) yield file\n\t\t}\n\t}\n\tyield* scan(root)\n}\n\nfunction testFile(file: string) {\n\treturn /\\.(?:test|spec)\\.[cm]?[jt]sx?$/.test(file)\n}\n\nfunction executable(program: Program) {\n\treturn program.body.some((statement) => {\n\t\tconst declaration =\n\t\t\tstatement.type === 'ExportNamedDeclaration' ? statement.declaration : statement\n\t\tif (declaration && 'declare' in declaration && declaration.declare) return false\n\t\tif (statement.type === 'ImportDeclaration' || statement.type === 'EmptyStatement') return false\n\t\tif (statement.type === 'ExportNamedDeclaration') {\n\t\t\tif (statement.exportKind === 'type' || !statement.declaration) return false\n\t\t\treturn !['TSInterfaceDeclaration', 'TSTypeAliasDeclaration', 'TSDeclareFunction'].includes(\n\t\t\t\tstatement.declaration.type,\n\t\t\t)\n\t\t}\n\t\treturn ![\n\t\t\t'TSInterfaceDeclaration',\n\t\t\t'TSTypeAliasDeclaration',\n\t\t\t'TSDeclareFunction',\n\t\t\t'ExportAllDeclaration',\n\t\t].includes(statement.type)\n\t})\n}\n\nfunction hasRunnableTest(program: Program) {\n\tconst names = new Map([\n\t\t['test', 'test'],\n\t\t['it', 'it'],\n\t\t['describe', 'describe'],\n\t\t['suite', 'suite'],\n\t])\n\tfor (const statement of program.body) {\n\t\tconst declaration =\n\t\t\tstatement.type === 'ExportNamedDeclaration' ? statement.declaration : statement\n\t\tif (declaration?.type === 'FunctionDeclaration' && declaration.id)\n\t\t\tnames.delete(declaration.id.name)\n\t\tif (declaration?.type === 'VariableDeclaration')\n\t\t\tfor (const item of declaration.declarations) {\n\t\t\t\tif (item.id.type === 'Identifier') names.delete(item.id.name)\n\t\t\t}\n\t\tif (statement.type !== 'ImportDeclaration') continue\n\t\tfor (const specifier of statement.specifiers) {\n\t\t\tnames.delete(specifier.local.name)\n\t\t\tif (\n\t\t\t\t!['vitest', 'vite-plus/test', 'bun:test', 'node:test', '@jest/globals'].includes(\n\t\t\t\t\tstatement.source.value,\n\t\t\t\t)\n\t\t\t)\n\t\t\t\tcontinue\n\t\t\tif (specifier.type === 'ImportNamespaceSpecifier') names.set(specifier.local.name, '*')\n\t\t\telse if (specifier.type === 'ImportDefaultSpecifier') names.set(specifier.local.name, 'test')\n\t\t\telse if (specifier.imported.type === 'Identifier')\n\t\t\t\tnames.set(specifier.local.name, specifier.imported.name)\n\t\t}\n\t}\n\tconst calls: CallExpression[] = []\n\tnew Visitor({\n\t\tCallExpression(node) {\n\t\t\tcalls.push(node)\n\t\t},\n\t}).visit(program)\n\tconst skipped = calls.filter((node) => {\n\t\tconst parts = testCallee(node.callee, names)\n\t\treturn (\n\t\t\t['test', 'it', 'describe', 'suite'].includes(parts[0]) &&\n\t\t\t(parts.some((part) => ['skip', 'todo', 'skipIf', 'runIf'].includes(part)) ||\n\t\t\t\tnode.arguments.some(\n\t\t\t\t\t(argument) =>\n\t\t\t\t\t\targument.type === 'ObjectExpression' &&\n\t\t\t\t\t\targument.properties.some(\n\t\t\t\t\t\t\t(property) =>\n\t\t\t\t\t\t\t\tproperty.type === 'Property' &&\n\t\t\t\t\t\t\t\t['skip', 'todo'].includes(\n\t\t\t\t\t\t\t\t\tproperty.key.type === 'Identifier'\n\t\t\t\t\t\t\t\t\t\t? property.key.name\n\t\t\t\t\t\t\t\t\t\t: property.key.type === 'Literal'\n\t\t\t\t\t\t\t\t\t\t\t? String(property.key.value)\n\t\t\t\t\t\t\t\t\t\t\t: '',\n\t\t\t\t\t\t\t\t) &&\n\t\t\t\t\t\t\t\t!(property.value.type === 'Literal' && property.value.value === false),\n\t\t\t\t\t\t),\n\t\t\t\t))\n\t\t)\n\t})\n\treturn calls.some((node) => {\n\t\tconst parts = testCallee(node.callee, names)\n\t\tif (\n\t\t\t!['test', 'it'].includes(parts[0]) ||\n\t\t\tskipped.some((skip) => node.start >= skip.start && node.end <= skip.end)\n\t\t)\n\t\t\treturn false\n\t\t// each(...) is a factory; only the outer call has the test callback.\n\t\treturn node.arguments.some(\n\t\t\t(argument) =>\n\t\t\t\t(argument.type === 'ArrowFunctionExpression' || argument.type === 'FunctionExpression') &&\n\t\t\t\targument.body &&\n\t\t\t\t(argument.body.type !== 'BlockStatement' ||\n\t\t\t\t\targument.body.body.some((statement) => statement.type !== 'EmptyStatement')),\n\t\t)\n\t})\n}\n\nfunction testCallee(node: Node, names: Map<string, string>): string[] {\n\tif (node.type === 'Identifier') {\n\t\tconst name = names.get(node.name)\n\t\treturn name ? [name] : []\n\t}\n\tif (node.type === 'CallExpression') return testCallee(node.callee, names)\n\tif (node.type === 'MemberExpression') {\n\t\tconst base = testCallee(node.object, names)\n\t\tconst property =\n\t\t\t!node.computed && node.property.type === 'Identifier'\n\t\t\t\t? node.property.name\n\t\t\t\t: node.property.type === 'Literal'\n\t\t\t\t\t? String(node.property.value)\n\t\t\t\t\t: ''\n\t\tif (!base.length || !property) return []\n\t\treturn base[0] === '*' ? [property] : [...base, property]\n\t}\n\treturn []\n}\n\nfunction runtimeImports(program: Program) {\n\tconst imports: string[] = []\n\tnew Visitor({\n\t\tImportDeclaration(node) {\n\t\t\tif (\n\t\t\t\tnode.importKind !== 'type' &&\n\t\t\t\t(node.specifiers.length === 0 ||\n\t\t\t\t\tnode.specifiers.some((s) => s.type !== 'ImportSpecifier' || s.importKind !== 'type'))\n\t\t\t)\n\t\t\t\timports.push(node.source.value)\n\t\t},\n\t\tExportNamedDeclaration(node) {\n\t\t\tif (\n\t\t\t\tnode.source &&\n\t\t\t\tnode.exportKind !== 'type' &&\n\t\t\t\tnode.specifiers.some((specifier) => specifier.exportKind !== 'type')\n\t\t\t)\n\t\t\t\timports.push(node.source.value)\n\t\t},\n\t\tExportAllDeclaration(node) {\n\t\t\tif (node.exportKind !== 'type') imports.push(node.source.value)\n\t\t},\n\t\tImportExpression(node) {\n\t\t\tif (node.source.type === 'Literal' && String(node.source.value) === node.source.value)\n\t\t\t\timports.push(String(node.source.value))\n\t\t},\n\t}).visit(program)\n\treturn imports\n}\n\nfunction moduleOwner(file: string) {\n\tconst parts = file.split('/')\n\treturn parts[0] === 'domain' && parts.length >= 3 && parts[1] !== '__tests__'\n\t\t? `domain/${parts[1]}`\n\t\t: null\n}\n\nfunction cycles(graph: Map<string, Set<string>>) {\n\tconst completed = new Set<string>()\n\tconst stack: string[] = []\n\tconst found: string[][] = []\n\tfunction visit(owner: string) {\n\t\tconst index = stack.indexOf(owner)\n\t\tif (index >= 0) {\n\t\t\tfound.push([...stack.slice(index), owner])\n\t\t\treturn\n\t\t}\n\t\tif (completed.has(owner)) return\n\t\tstack.push(owner)\n\t\tfor (const dependency of graph.get(owner) ?? []) visit(dependency)\n\t\tstack.pop()\n\t\tcompleted.add(owner)\n\t}\n\tfor (const owner of graph.keys()) visit(owner)\n\treturn found\n}\n\nfunction sharedOwnership(dependencies: Map<string, Set<string>>): ArchitectureDiagnostic[] {\n\tconst consumers = new Map<string, Set<string>>()\n\tfor (const [file, targets] of dependencies) {\n\t\tconst owner = moduleOwner(file) ?? ''\n\t\tif (!owner || owner === 'domain/shared') continue\n\t\tconst visited = new Set<string>()\n\t\tfunction visit(target: string) {\n\t\t\tif (!target.startsWith('domain/shared/') || visited.has(target)) return\n\t\t\tvisited.add(target)\n\t\t\tconst owners = consumers.get(target) ?? new Set<string>()\n\t\t\towners.add(owner)\n\t\t\tconsumers.set(target, owners)\n\t\t\tfor (const next of dependencies.get(target) ?? []) visit(next)\n\t\t}\n\t\tfor (const target of targets) visit(target)\n\t}\n\tconst diagnostics: ArchitectureDiagnostic[] = []\n\tfor (const [file, owners] of consumers) {\n\t\tif (owners.size === 1)\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: 'shared-owner',\n\t\t\t\tfile,\n\t\t\t\tmessage: `This shared implementation is used only by ${[...owners][0]}. Move it into that module until another module needs it.`,\n\t\t\t})\n\t}\n\treturn diagnostics\n}\n"],"mappings":"qQA2BA,SAAgBA,EAAoB,EAA+B,CAAC,EAA6B,CAChG,IAAMC,EAAgBC,EAAQC,EAAQ,KAAO,QAAQ,IAAI,EAAGA,EAAQ,WAAa,QAAQ,EACnFC,EAAOC,EAAWJ,CAAa,EAAIK,EAAaL,CAAa,EAAIA,EACjEM,EAAwC,CAAC,EAC/C,GAAI,CAACF,EAAWD,CAAI,EACnB,MAAO,CACN,CAAE,KAAM,eAAgB,KAAM,IAAK,QAAS,oCAAoCA,GAAO,CACxF,EACD,IAAMI,EAAQC,EAAYL,EAAMG,CAAW,EACrCG,kBAAW,IAAI,IACfC,kBAAS,IAAI,IACbC,kBAAQ,IAAI,IACZC,kBAAe,IAAI,IACnBC,EAAWC,EAAe,EAChC,IAAK,IAAMC,KAAQR,EAAO,CACzB,IAAMS,EAAWf,EAAQE,EAAMY,CAAI,EAC7BE,EAASC,EAAUF,EAAUG,EAAaH,EAAU,MAAM,CAAC,EACjE,GAAIC,EAAO,OAAO,OAAQ,CACzBX,EAAY,KAAK,CAChB,KAAM,QACN,OACA,QAAS,mBAAmBS,EAAK,IAAIE,EAAO,OAAO,EAAE,CAAC,SACvD,CAAC,EACD,QACD,CACA,GAAIG,EAASL,CAAI,EAAG,CACdA,EAAK,SAAS,YAAY,EAMtBM,EAAQN,CAAI,CAAC,CAAC,SAAS,WAAW,GAAKO,EAAgBL,EAAO,OAAO,GAC7EP,EAAO,IAAIW,EAAQA,EAAQN,CAAI,CAAC,CAAC,EANjCT,EAAY,KAAK,CAChB,KAAM,gBAC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,CAC9B,GAAI,CAACzD,EAAO,WAAW,gBAAgB,GAAK4D,EAAQ,IAAI5D,CAAM,EAAG,OACjE4D,EAAQ,IAAI5D,CAAM,EAClB,IAAM6D,EAASF,EAAU,IAAI3D,CAAM,mBAAK,IAAI,IAC5C6D,EAAO,IAAIlE,CAAK,EAChBgE,EAAU,IAAI3D,EAAQ6D,CAAM,EAC5B,IAAK,IAAMC,KAAQhF,EAAa,IAAIkB,CAAM,GAAK,CAAC,EAAGyD,EAAMK,CAAI,CAC9D,CACA,IAAK,IAAM9D,KAAUH,EAAS4D,EAAMzD,CAAM,CAC3C,CACA,IAAMxB,EAAwC,CAAC,EAC/C,IAAK,GAAM,CAACS,EAAM4E,KAAWF,EACxBE,EAAO,OAAS,GACnBrF,EAAY,KAAK,CAChB,KAAM,eACN,OACA,QAAS,8CAA8C,CAAC,GAAGqF,CAAM,CAAC,CAAC,GAAG,0DACvE,CAAC,EAEH,OAAOrF,CACR"}
|
|
1
|
+
{"version":3,"file":"architecture.mjs","names":["inspectArchitecture","requestedRoot","resolve","options","root","existsSync","realpathSync","diagnostics","explicitRoots","path","files","sourceFiles","owners","file","owner","findComponentRoot","conventionalComponentRoot","sep","relative","componentRoots","index","issue","required","tested","graph","componentGraph","dependencies","resolver","createResolver","filename","parsed","parseSync","readFileSync","testFile","dirname","hasRunnableTest","component","localFile","executable","narrowRootDeclaration","moduleOwner","targets","source","runtimeImports","target","resolveImport","targetFile","edges","targetOwner","directory","sharedOwnership","cycle","cycles","a","b","ResolverFactory","architectureAnchor","factory","imports","aliases","factories","exported","factoryName","node","active","init","declarative","relationParameter","registryCallback","value","property","body","callee","argument","statement","specifier","declaration","item","allowed","scan","entry","readdirSync","program","names","calls","Visitor","skipped","parts","testCallee","part","skip","name","base","s","completed","stack","found","visit","dependency","consumers","visited","next"],"sources":["../../src/oxlint/architecture.ts"],"sourcesContent":["import { existsSync, readdirSync, readFileSync, realpathSync } from 'node:fs'\nimport { dirname, relative, resolve, sep } from 'node:path'\nimport { parseSync, Visitor, type Program, type Node, type CallExpression } from 'oxc-parser'\nimport { ResolverFactory } from 'oxc-resolver'\nimport { findComponentRoot, conventionalComponentRoot } from './components'\n\nexport interface ArchitectureOptions {\n\tcwd?: string\n\tconvexDir?: string\n\t/** Additional component roots, relative to convexDir. */\n\tcomponentDirs?: readonly string[]\n\t/** Build these registries to surface deferred configuration errors in tests. */\n\tregistries?: readonly object[]\n}\nexport interface ArchitectureDiagnostic {\n\tcode:\n\t\t| 'missing-root'\n\t\t| 'root-directory'\n\t\t| 'tests'\n\t\t| 'test-location'\n\t\t| 'parse'\n\t\t| 'cycle'\n\t\t| 'symlink'\n\t\t| 'domain-entry'\n\t\t| 'shared-owner'\n\tfile: string\n\tmessage: string\n}\n\n/** Full-project checks, independent of the consumer's test runner. No persistent cache. */\nexport function inspectArchitecture(options: ArchitectureOptions = {}): ArchitectureDiagnostic[] {\n\tconst requestedRoot = resolve(options.cwd ?? process.cwd(), options.convexDir ?? 'convex')\n\tconst root = existsSync(requestedRoot) ? realpathSync(requestedRoot) : requestedRoot\n\tconst diagnostics: ArchitectureDiagnostic[] = []\n\tif (!existsSync(root))\n\t\treturn [\n\t\t\t{ code: 'missing-root', file: '.', message: `Convex directory does not exist: ${root}` },\n\t\t]\n\tconst explicitRoots = (options.componentDirs ?? []).map((path) => resolve(root, path))\n\tconst files = [...sourceFiles(root, diagnostics)]\n\tconst owners = new Map<string, string>()\n\tfor (const file of files) {\n\t\tconst owner =\n\t\t\tfindComponentRoot(resolve(root, file), explicitRoots) ??\n\t\t\tconventionalComponentRoot(resolve(root, file), root)\n\t\tif (owner && (owner === root || owner.startsWith(root + sep)))\n\t\t\towners.set(file, relative(root, owner).split(sep).join('/'))\n\t}\n\tconst componentRoots = new Set(owners.values())\n\t// Component submodules have their own layout; only host directories use the app allowlist.\n\tfor (let index = diagnostics.length - 1; index >= 0; index--) {\n\t\tconst issue = diagnostics[index]\n\t\tif (\n\t\t\tissue.code === 'root-directory' &&\n\t\t\t[...componentRoots].some(\n\t\t\t\t(owner) => !owner || owner === issue.file || owner.startsWith(issue.file + '/'),\n\t\t\t) &&\n\t\t\t!files.some((file) => file.startsWith(issue.file + '/') && !owners.has(file))\n\t\t)\n\t\t\tdiagnostics.splice(index, 1)\n\t}\n\tconst required = new Set<string>()\n\tconst tested = new Set<string>()\n\tconst graph = new Map<string, Set<string>>()\n\tconst componentGraph = new Map<string, Set<string>>()\n\tconst dependencies = new Map<string, Set<string>>()\n\tconst resolver = createResolver()\n\tfor (const file of files) {\n\t\tconst filename = resolve(root, file)\n\t\tconst parsed = parseSync(filename, readFileSync(filename, 'utf8'))\n\t\tif (parsed.errors.length) {\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: 'parse',\n\t\t\t\tfile,\n\t\t\t\tmessage: `Cannot validate ${file}: ${parsed.errors[0].message}`,\n\t\t\t})\n\t\t\tcontinue\n\t\t}\n\t\tif (testFile(file)) {\n\t\t\tif (!file.includes('__tests__/'))\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\tcode: 'test-location',\n\t\t\t\t\tfile,\n\t\t\t\t\tmessage: 'Place tests in a sibling __tests__/ directory.',\n\t\t\t\t})\n\t\t\telse if (dirname(file).endsWith('__tests__') && hasRunnableTest(parsed.program))\n\t\t\t\ttested.add(dirname(dirname(file)))\n\t\t\tcontinue\n\t\t}\n\t\tif (file.split('/').includes('__tests__')) continue\n\t\tconst component = owners.get(file)\n\t\tconst localFile =\n\t\t\tcomponent === undefined\n\t\t\t\t? file\n\t\t\t\t: relative(resolve(root, component), filename).split(sep).join('/')\n\t\tif (component === undefined && /^domain\\/[^/]+$/.test(file) && file !== 'domain/table.ts')\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: 'domain-entry',\n\t\t\t\tfile,\n\t\t\t\tmessage:\n\t\t\t\t\t'Domain source belongs in domain/<module>/ or domain/shared/. Only domain/table.ts assembles module tables.',\n\t\t\t})\n\t\tif (\n\t\t\texecutable(parsed.program) &&\n\t\t\tfile !== 'domain/table.ts' &&\n\t\t\t!narrowRootDeclaration(localFile, readFileSync(filename, 'utf8'))\n\t\t)\n\t\t\trequired.add(dirname(file))\n\t\tconst owner = moduleOwner(file) ?? ''\n\t\tconst targets = new Set<string>()\n\t\tdependencies.set(file, targets)\n\t\tfor (const source of runtimeImports(parsed.program)) {\n\t\t\tconst target = resolveImport(resolver, filename, source)\n\t\t\tif (!target) continue\n\t\t\tconst targetFile = relative(root, target).split(sep).join('/')\n\t\t\ttargets.add(targetFile)\n\t\t\tif (component !== undefined && owners.get(targetFile) === component) {\n\t\t\t\tconst edges = componentGraph.get(file) ?? new Set<string>()\n\t\t\t\tcomponentGraph.set(file, edges)\n\t\t\t\tedges.add(targetFile)\n\t\t\t}\n\t\t\tconst targetOwner = moduleOwner(targetFile)\n\t\t\tif (owner && targetOwner && owner !== targetOwner) {\n\t\t\t\tconst edges = graph.get(owner) ?? new Set<string>()\n\t\t\t\tgraph.set(owner, edges)\n\t\t\t\tedges.add(targetOwner)\n\t\t\t}\n\t\t}\n\t}\n\tfor (const directory of required) {\n\t\tif (!tested.has(directory))\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: 'tests',\n\t\t\t\tfile: directory,\n\t\t\t\tmessage: `${directory}/__tests__/ must contain a .test or .spec file with a nonempty, non-skipped test. Parent or child suites do not count.`,\n\t\t\t})\n\t}\n\tdiagnostics.push(...sharedOwnership(dependencies))\n\tfor (const cycle of [...cycles(graph), ...cycles(componentGraph)])\n\t\tdiagnostics.push({\n\t\t\tcode: 'cycle',\n\t\t\tfile: cycle[0],\n\t\t\tmessage: `Module dependency cycle: ${cycle.join(' → ')}.`,\n\t\t})\n\treturn diagnostics.sort((a, b) => a.file.localeCompare(b.file) || a.code.localeCompare(b.code))\n}\n\nexport function createResolver(symlinks = true) {\n\treturn new ResolverFactory({\n\t\ttsconfig: 'auto',\n\t\textensions: ['.ts', '.tsx', '.mts', '.cts', '.js', '.jsx', '.mjs', '.cjs', '.json'],\n\t\textensionAlias: {\n\t\t\t'.js': ['.ts', '.tsx', '.js'],\n\t\t\t'.mjs': ['.mts', '.mjs'],\n\t\t\t'.cjs': ['.cts', '.cjs'],\n\t\t},\n\t\tconditionNames: ['types', 'import', 'node', 'default'],\n\t\tsymlinks,\n\t})\n}\n\nexport function resolveImport(resolver: ResolverFactory, filename: string, source: string) {\n\tconst found = resolver.resolveFileSync(filename, source).path\n\tif (found) return found\n\t// Keep path checks useful in unsaved/editor fixtures and before Convex codegen.\n\treturn source.startsWith('.') ? resolve(dirname(filename), source) : null\n}\n\n/** The lint rule runs the project scan on one deterministic source file. */\nexport function architectureAnchor(root: string) {\n\tif (!existsSync(root)) return null\n\tif (existsSync(resolve(root, 'convex.config.ts')))\n\t\treturn realpathSync(resolve(root, 'convex.config.ts'))\n\troot = realpathSync(root)\n\tfor (const file of sourceFiles(root, []))\n\t\tif (!file.includes('__tests__/') && !testFile(file)) return resolve(root, file)\n\treturn null\n}\n\n/** Only these two factory declarations may omit root business ownership. */\nexport function narrowRootDeclaration(file: string, source: string): boolean {\n\tconst factory =\n\t\tfile === 'relations.ts'\n\t\t\t? 'defineRelations'\n\t\t\t: file === 'querying.ts'\n\t\t\t\t? 'createQueryEngine'\n\t\t\t\t: null\n\tif (!factory) return false\n\tconst parsed = parseSync(file, source)\n\tif (parsed.errors.length) return false\n\tconst imports = new Map<string, string>()\n\tconst aliases = new Map<string, Node>()\n\tlet factories = 0\n\tlet exported = false\n\tfunction factoryName(node: Node, active = new Set<string>()): string | null {\n\t\tif (node.type === 'Identifier') {\n\t\t\tif (active.has(node.name)) return null\n\t\t\tconst init = aliases.get(node.name)\n\t\t\treturn init\n\t\t\t\t? factoryName(init, new Set(active).add(node.name))\n\t\t\t\t: (imports.get(node.name) ?? null)\n\t\t}\n\t\tif (\n\t\t\tnode.type === 'MemberExpression' &&\n\t\t\t!node.computed &&\n\t\t\tnode.property.type === 'Identifier' &&\n\t\t\tfactoryName(node.object, active) === '*'\n\t\t)\n\t\t\treturn node.property.name\n\t\treturn null\n\t}\n\tfunction declarative(node: Node, relationParameter?: string, registryCallback = false): boolean {\n\t\tif (node.type === 'Identifier' || node.type === 'Literal') return true\n\t\tif (\n\t\t\tnode.type === 'TSAsExpression' ||\n\t\t\tnode.type === 'TSSatisfiesExpression' ||\n\t\t\tnode.type === 'ParenthesizedExpression'\n\t\t)\n\t\t\treturn declarative(node.expression, relationParameter, registryCallback)\n\t\tif (node.type === 'MemberExpression')\n\t\t\treturn !node.computed && declarative(node.object, relationParameter)\n\t\tif (node.type === 'ArrayExpression')\n\t\t\treturn node.elements.every((value) => value !== null && declarative(value, relationParameter))\n\t\tif (node.type === 'ObjectExpression')\n\t\t\treturn node.properties.every(\n\t\t\t\t(property) =>\n\t\t\t\t\tproperty.type === 'Property' &&\n\t\t\t\t\t!property.computed &&\n\t\t\t\t\tproperty.kind === 'init' &&\n\t\t\t\t\t!property.method &&\n\t\t\t\t\tdeclarative(property.value, relationParameter),\n\t\t\t)\n\t\tif (\n\t\t\tnode.type === 'ArrowFunctionExpression' &&\n\t\t\tregistryCallback &&\n\t\t\t!relationParameter &&\n\t\t\tnode.params.length === 1 &&\n\t\t\tnode.params[0].type === 'Identifier' &&\n\t\t\t!node.async\n\t\t) {\n\t\t\tconst body = node.body.type === 'ParenthesizedExpression' ? node.body.expression : node.body\n\t\t\treturn body.type === 'ObjectExpression' && declarative(body, node.params[0].name)\n\t\t}\n\t\tif (node.type === 'CallExpression' && relationParameter) {\n\t\t\tlet callee: Node = node.callee\n\t\t\tconst path: string[] = []\n\t\t\twhile (\n\t\t\t\tcallee.type === 'MemberExpression' &&\n\t\t\t\t!callee.computed &&\n\t\t\t\tcallee.property.type === 'Identifier'\n\t\t\t) {\n\t\t\t\tpath.unshift(callee.property.name)\n\t\t\t\tcallee = callee.object\n\t\t\t}\n\t\t\treturn (\n\t\t\t\tcallee.type === 'Identifier' &&\n\t\t\t\tcallee.name === relationParameter &&\n\t\t\t\t((path.length === 2 && ['one', 'many'].includes(path[0])) ||\n\t\t\t\t\t(path.length === 3 && path[2] === 'through')) &&\n\t\t\t\tnode.arguments.every((argument) => declarative(argument, relationParameter))\n\t\t\t)\n\t\t}\n\t\treturn false\n\t}\n\tfor (const statement of parsed.program.body) {\n\t\tif (statement.type === 'ImportDeclaration') {\n\t\t\tif (statement.importKind === 'type') continue\n\t\t\tfor (const specifier of statement.specifiers) {\n\t\t\t\tif (specifier.type === 'ImportSpecifier' && specifier.importKind === 'type') continue\n\t\t\t\tif (['cvx-kit', `cvx-kit/${file.slice(0, -3)}`].includes(statement.source.value))\n\t\t\t\t\timports.set(\n\t\t\t\t\t\tspecifier.local.name,\n\t\t\t\t\t\tspecifier.type === 'ImportSpecifier'\n\t\t\t\t\t\t\t? specifier.imported.type === 'Identifier'\n\t\t\t\t\t\t\t\t? specifier.imported.name\n\t\t\t\t\t\t\t\t: ''\n\t\t\t\t\t\t\t: specifier.type === 'ImportNamespaceSpecifier'\n\t\t\t\t\t\t\t\t? '*'\n\t\t\t\t\t\t\t\t: '',\n\t\t\t\t\t)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tif (\n\t\t\tstatement.type === 'EmptyStatement' ||\n\t\t\tstatement.type === 'TSTypeAliasDeclaration' ||\n\t\t\tstatement.type === 'TSInterfaceDeclaration'\n\t\t)\n\t\t\tcontinue\n\t\tconst declaration =\n\t\t\tstatement.type === 'ExportNamedDeclaration' ? statement.declaration : statement\n\t\tif (declaration?.type !== 'VariableDeclaration' || declaration.kind !== 'const') return false\n\t\tfor (const item of declaration.declarations) {\n\t\t\tif (item.id.type !== 'Identifier' || !item.init) return false\n\t\t\tif (item.init.type === 'CallExpression' && factoryName(item.init.callee) === factory) {\n\t\t\t\tif (\n\t\t\t\t\t!item.init.arguments.every((argument, index) =>\n\t\t\t\t\t\tdeclarative(argument, undefined, factory === 'defineRelations' && index === 1),\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t\treturn false\n\t\t\t\tfactories++\n\t\t\t\texported ||= statement.type === 'ExportNamedDeclaration'\n\t\t\t} else if (statement.type === 'ExportNamedDeclaration' || !declarative(item.init))\n\t\t\t\treturn false\n\t\t\taliases.set(item.id.name, item.init)\n\t\t}\n\t}\n\treturn factories === 1 && exported\n}\n\nfunction* sourceFiles(root: string, diagnostics: ArchitectureDiagnostic[]): Generator<string> {\n\tconst allowed = new Set([\n\t\t'_generated',\n\t\t'__tests__',\n\t\t'api',\n\t\t'domain',\n\t\t'application',\n\t\t'migrations',\n\t\t'components',\n\t])\n\tfunction* scan(directory: string): Generator<string> {\n\t\tfor (const entry of readdirSync(directory, { withFileTypes: true }).sort((a, b) =>\n\t\t\ta.name.localeCompare(b.name),\n\t\t)) {\n\t\t\tconst path = resolve(directory, entry.name)\n\t\t\tconst file = relative(root, path).split(sep).join('/')\n\t\t\tif (entry.isSymbolicLink()) {\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\tcode: 'symlink',\n\t\t\t\t\tfile,\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t'Keep application source inside its owning directory; symlinked files and folders are not allowed.',\n\t\t\t\t})\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tif (directory === root && !allowed.has(entry.name))\n\t\t\t\t\tdiagnostics.push({\n\t\t\t\t\t\tcode: 'root-directory',\n\t\t\t\t\t\tfile,\n\t\t\t\t\t\tmessage: `Root folder ${entry.name}/ is not allowed. Use api/, domain/, application/, migrations/, components/, __tests__/, or _generated/.`,\n\t\t\t\t\t})\n\t\t\t\tif (\n\t\t\t\t\tentry.name !== '_generated' &&\n\t\t\t\t\tentry.name !== 'node_modules' &&\n\t\t\t\t\t!entry.name.startsWith('.')\n\t\t\t\t)\n\t\t\t\t\tyield* scan(path)\n\t\t\t} else if (/\\.[cm]?[jt]sx?$/.test(entry.name) && !/\\.d\\.[cm]?ts$/.test(entry.name)) yield file\n\t\t}\n\t}\n\tyield* scan(root)\n}\n\nfunction testFile(file: string) {\n\treturn /\\.(?:test|spec)\\.[cm]?[jt]sx?$/.test(file)\n}\n\nfunction executable(program: Program) {\n\treturn program.body.some((statement) => {\n\t\tconst declaration =\n\t\t\tstatement.type === 'ExportNamedDeclaration' ? statement.declaration : statement\n\t\tif (declaration && 'declare' in declaration && declaration.declare) return false\n\t\tif (statement.type === 'ImportDeclaration' || statement.type === 'EmptyStatement') return false\n\t\tif (statement.type === 'ExportNamedDeclaration') {\n\t\t\tif (statement.exportKind === 'type' || !statement.declaration) return false\n\t\t\treturn !['TSInterfaceDeclaration', 'TSTypeAliasDeclaration', 'TSDeclareFunction'].includes(\n\t\t\t\tstatement.declaration.type,\n\t\t\t)\n\t\t}\n\t\treturn ![\n\t\t\t'TSInterfaceDeclaration',\n\t\t\t'TSTypeAliasDeclaration',\n\t\t\t'TSDeclareFunction',\n\t\t\t'ExportAllDeclaration',\n\t\t].includes(statement.type)\n\t})\n}\n\nfunction hasRunnableTest(program: Program) {\n\tconst names = new Map([\n\t\t['test', 'test'],\n\t\t['it', 'it'],\n\t\t['describe', 'describe'],\n\t\t['suite', 'suite'],\n\t])\n\tfor (const statement of program.body) {\n\t\tconst declaration =\n\t\t\tstatement.type === 'ExportNamedDeclaration' ? statement.declaration : statement\n\t\tif (declaration?.type === 'FunctionDeclaration' && declaration.id)\n\t\t\tnames.delete(declaration.id.name)\n\t\tif (declaration?.type === 'VariableDeclaration')\n\t\t\tfor (const item of declaration.declarations) {\n\t\t\t\tif (item.id.type === 'Identifier') names.delete(item.id.name)\n\t\t\t}\n\t\tif (statement.type !== 'ImportDeclaration') continue\n\t\tfor (const specifier of statement.specifiers) {\n\t\t\tnames.delete(specifier.local.name)\n\t\t\tif (\n\t\t\t\t!['vitest', 'vite-plus/test', 'bun:test', 'node:test', '@jest/globals'].includes(\n\t\t\t\t\tstatement.source.value,\n\t\t\t\t)\n\t\t\t)\n\t\t\t\tcontinue\n\t\t\tif (specifier.type === 'ImportNamespaceSpecifier') names.set(specifier.local.name, '*')\n\t\t\telse if (specifier.type === 'ImportDefaultSpecifier') names.set(specifier.local.name, 'test')\n\t\t\telse if (specifier.imported.type === 'Identifier')\n\t\t\t\tnames.set(specifier.local.name, specifier.imported.name)\n\t\t}\n\t}\n\tconst calls: CallExpression[] = []\n\tnew Visitor({\n\t\tCallExpression(node) {\n\t\t\tcalls.push(node)\n\t\t},\n\t}).visit(program)\n\tconst skipped = calls.filter((node) => {\n\t\tconst parts = testCallee(node.callee, names)\n\t\treturn (\n\t\t\t['test', 'it', 'describe', 'suite'].includes(parts[0]) &&\n\t\t\t(parts.some((part) => ['skip', 'todo', 'skipIf', 'runIf'].includes(part)) ||\n\t\t\t\tnode.arguments.some(\n\t\t\t\t\t(argument) =>\n\t\t\t\t\t\targument.type === 'ObjectExpression' &&\n\t\t\t\t\t\targument.properties.some(\n\t\t\t\t\t\t\t(property) =>\n\t\t\t\t\t\t\t\tproperty.type === 'Property' &&\n\t\t\t\t\t\t\t\t['skip', 'todo'].includes(\n\t\t\t\t\t\t\t\t\tproperty.key.type === 'Identifier'\n\t\t\t\t\t\t\t\t\t\t? property.key.name\n\t\t\t\t\t\t\t\t\t\t: property.key.type === 'Literal'\n\t\t\t\t\t\t\t\t\t\t\t? String(property.key.value)\n\t\t\t\t\t\t\t\t\t\t\t: '',\n\t\t\t\t\t\t\t\t) &&\n\t\t\t\t\t\t\t\t!(property.value.type === 'Literal' && property.value.value === false),\n\t\t\t\t\t\t),\n\t\t\t\t))\n\t\t)\n\t})\n\treturn calls.some((node) => {\n\t\tconst parts = testCallee(node.callee, names)\n\t\tif (\n\t\t\t!['test', 'it'].includes(parts[0]) ||\n\t\t\tskipped.some((skip) => node.start >= skip.start && node.end <= skip.end)\n\t\t)\n\t\t\treturn false\n\t\t// each(...) is a factory; only the outer call has the test callback.\n\t\treturn node.arguments.some(\n\t\t\t(argument) =>\n\t\t\t\t(argument.type === 'ArrowFunctionExpression' || argument.type === 'FunctionExpression') &&\n\t\t\t\targument.body &&\n\t\t\t\t(argument.body.type !== 'BlockStatement' ||\n\t\t\t\t\targument.body.body.some((statement) => statement.type !== 'EmptyStatement')),\n\t\t)\n\t})\n}\n\nfunction testCallee(node: Node, names: Map<string, string>): string[] {\n\tif (node.type === 'Identifier') {\n\t\tconst name = names.get(node.name)\n\t\treturn name ? [name] : []\n\t}\n\tif (node.type === 'CallExpression') return testCallee(node.callee, names)\n\tif (node.type === 'MemberExpression') {\n\t\tconst base = testCallee(node.object, names)\n\t\tconst property =\n\t\t\t!node.computed && node.property.type === 'Identifier'\n\t\t\t\t? node.property.name\n\t\t\t\t: node.property.type === 'Literal'\n\t\t\t\t\t? String(node.property.value)\n\t\t\t\t\t: ''\n\t\tif (!base.length || !property) return []\n\t\treturn base[0] === '*' ? [property] : [...base, property]\n\t}\n\treturn []\n}\n\nfunction runtimeImports(program: Program) {\n\tconst imports: string[] = []\n\tnew Visitor({\n\t\tImportDeclaration(node) {\n\t\t\tif (\n\t\t\t\tnode.importKind !== 'type' &&\n\t\t\t\t(node.specifiers.length === 0 ||\n\t\t\t\t\tnode.specifiers.some((s) => s.type !== 'ImportSpecifier' || s.importKind !== 'type'))\n\t\t\t)\n\t\t\t\timports.push(node.source.value)\n\t\t},\n\t\tExportNamedDeclaration(node) {\n\t\t\tif (\n\t\t\t\tnode.source &&\n\t\t\t\tnode.exportKind !== 'type' &&\n\t\t\t\tnode.specifiers.some((specifier) => specifier.exportKind !== 'type')\n\t\t\t)\n\t\t\t\timports.push(node.source.value)\n\t\t},\n\t\tExportAllDeclaration(node) {\n\t\t\tif (node.exportKind !== 'type') imports.push(node.source.value)\n\t\t},\n\t\tImportExpression(node) {\n\t\t\tif (node.source.type === 'Literal' && String(node.source.value) === node.source.value)\n\t\t\t\timports.push(String(node.source.value))\n\t\t},\n\t}).visit(program)\n\treturn imports\n}\n\nfunction moduleOwner(file: string) {\n\tconst parts = file.split('/')\n\treturn parts[0] === 'domain' && parts.length >= 3 && parts[1] !== '__tests__'\n\t\t? `domain/${parts[1]}`\n\t\t: null\n}\n\nfunction cycles(graph: Map<string, Set<string>>) {\n\tconst completed = new Set<string>()\n\tconst stack: string[] = []\n\tconst found: string[][] = []\n\tfunction visit(owner: string) {\n\t\tconst index = stack.indexOf(owner)\n\t\tif (index >= 0) {\n\t\t\tfound.push([...stack.slice(index), owner])\n\t\t\treturn\n\t\t}\n\t\tif (completed.has(owner)) return\n\t\tstack.push(owner)\n\t\tfor (const dependency of graph.get(owner) ?? []) visit(dependency)\n\t\tstack.pop()\n\t\tcompleted.add(owner)\n\t}\n\tfor (const owner of graph.keys()) visit(owner)\n\treturn found\n}\n\nfunction sharedOwnership(dependencies: Map<string, Set<string>>): ArchitectureDiagnostic[] {\n\tconst consumers = new Map<string, Set<string>>()\n\tfor (const [file, targets] of dependencies) {\n\t\tconst owner = moduleOwner(file) ?? ''\n\t\tif (!owner || owner === 'domain/shared') continue\n\t\tconst visited = new Set<string>()\n\t\tfunction visit(target: string) {\n\t\t\tif (!target.startsWith('domain/shared/') || visited.has(target)) return\n\t\t\tvisited.add(target)\n\t\t\tconst owners = consumers.get(target) ?? new Set<string>()\n\t\t\towners.add(owner)\n\t\t\tconsumers.set(target, owners)\n\t\t\tfor (const next of dependencies.get(target) ?? []) visit(next)\n\t\t}\n\t\tfor (const target of targets) visit(target)\n\t}\n\tconst diagnostics: ArchitectureDiagnostic[] = []\n\tfor (const [file, owners] of consumers) {\n\t\tif (owners.size === 1)\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: 'shared-owner',\n\t\t\t\tfile,\n\t\t\t\tmessage: `This shared implementation is used only by ${[...owners][0]}. Move it into that module until another module needs it.`,\n\t\t\t})\n\t}\n\treturn diagnostics\n}\n"],"mappings":"yVA8BA,SAAgBA,EAAoB,EAA+B,CAAC,EAA6B,CAChG,IAAMC,EAAgBC,EAAQC,EAAQ,KAAO,QAAQ,IAAI,EAAGA,EAAQ,WAAa,QAAQ,EACnFC,EAAOC,EAAWJ,CAAa,EAAIK,EAAaL,CAAa,EAAIA,EACjEM,EAAwC,CAAC,EAC/C,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ASwD,EAAMrD,CAAM,CAC3C,CACA,IAAMrC,EAAwC,CAAC,EAC/C,IAAK,GAAM,CAACM,EAAMD,KAAWuF,EACxBvF,EAAO,OAAS,GACnBL,EAAY,KAAK,CAChB,KAAM,eACN,OACA,QAAS,8CAA8C,CAAC,GAAGK,CAAM,CAAC,CAAC,GAAG,0DACvE,CAAC,EAEH,OAAOL,CACR"}
|
package/dist/oxlint/ast.d.mts
CHANGED
|
@@ -3,6 +3,8 @@ import { Context, ESTree, RuleMeta, Visitor } from "@oxlint/plugins";
|
|
|
3
3
|
//#region src/oxlint/ast.d.ts
|
|
4
4
|
export declare const consumerOptions: z.ZodObject<{
|
|
5
5
|
convexDir: z.ZodDefault<z.ZodString>;
|
|
6
|
+
componentDirs: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
7
|
+
domainPublicFiles: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
|
|
6
8
|
}, z.core.$strip>;
|
|
7
9
|
export declare function appFile(context: Context, filename?: string): string | null;
|
|
8
10
|
export declare function imported(context: Context, node: ESTree.Node, active?: Set<ESTree.Node>): {
|
package/dist/oxlint/ast.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createResolver as e,resolveImport as t}from"./architecture.mjs";import{z as n}from"zod";import{dirname as r,relative as i,resolve as a,sep as o}from"node:path";import{existsSync as s,readFileSync as c,realpathSync as l}from"node:fs";import{parseSync as u}from"oxc-parser";const d=n.object({convexDir:n.string().min(1).default(`convex`)});function f(e,t=e.filename){let n=a(e.cwd,d.parse(e.options[0]??{}).convexDir),r=s(n)?l(n):n,c=i(r,s(t)?l(t):t).split(o).join(`/`);return c===`..`||c.startsWith(`../`)||c.startsWith(`/`)?null:c}function p(e,t,n=/* @__PURE__ */ new Set){if(n.has(t)||n.size>32)return null;if(n=new Set(n).add(t),t.type===`TSAsExpression`||t.type===`TSSatisfiesExpression`||t.type===`TSNonNullExpression`)return p(e,t.expression,n);if(t.type===`CallExpression`)return p(e,t.callee,n);if(t.type===`MemberExpression`){let r=p(e,t.object,n),i=N(t);return r&&i&&[`*`,`z`,`v`,`default`].includes(r.name)?{source:r.source,name:i}:null}if(t.type!==`Identifier`)return null;let r=m(e,t);if(r&&r.type!==`CallExpression`&&r.type!==`AwaitExpression`)return p(e,r,n);let i=h(e,t);if(i){let t=p(e,i.expression,n);return t&&[`*`,`z`,`v`,`default`].includes(t.name)?{source:t.source,name:i.name}:null}for(let n of P(e,t)?.defs??[]){if(n.type!==`ImportBinding`||n.parent?.type!==`ImportDeclaration`||n.parent.importKind===`type`)continue;let e=n.node;if(e.type!==`ImportSpecifier`||e.importKind!==`type`)return{source:n.parent.source.value,name:e.type===`ImportSpecifier`?I(e.imported)??``:e.type===`ImportDefaultSpecifier`?`default`:`*`}}return null}function m(e,t){let n=P(e,t);if(!n||n.references.some(e=>e.isWrite()&&!e.init))return null;let r=n.defs.length===1?n.defs[0]:null;return r?.type===`Variable`&&r.parent?.type===`VariableDeclaration`&&r.parent.kind===`const`&&r.node.type===`VariableDeclarator`&&r.node.id.type===`Identifier`?r.node.init:null}function h(e,t){let n=P(e,t);if(!n||n.references.some(e=>e.isWrite()&&!e.init))return null;let r=n.defs.length===1?n.defs[0]:null;if(r?.type!==`Variable`||r.parent?.type!==`VariableDeclaration`||r.parent.kind!==`const`||r.node.type!==`VariableDeclarator`||r.node.id.type!==`ObjectPattern`||!r.node.init)return null;for(let e of r.node.id.properties)if(e.type===`Property`&&e.value.type===`Identifier`&&e.value.name===n.name){let t=e.computed?M(e.key):I(e.key);if(t)return{expression:r.node.init,name:t}}return null}const g=[`query`,`internalQuery`,`mutation`,`internalMutation`],_=/* @__PURE__ */ new WeakMap;function v(e,t){let n=B(e).nodes;if(n.has(t))return n.get(t)??null;n.set(t,null);let r=[{node:t,evaluation:V(e,t)}],i=null;for(;r.length;){let t=r[r.length-1],a=t.evaluation.next(i);a.done?(i=a.value,n.set(t.node,i),r.pop()):n.has(a.value)?i=n.get(a.value)??null:(n.set(a.value,null),r.push({node:a.value,evaluation:V(e,a.value)}),i=null)}return i}function y(e,t){function n(e,n){let r=M(n);r&&t(e,r)}return{ImportDeclaration(e){n(e,e.source)},ExportNamedDeclaration(e){n(e,e.source)},ExportAllDeclaration(e){n(e,e.source)},ImportExpression(e){n(e,e.source)},TSImportType(e){n(e,e.source)},CallExpression(t){t.callee.type===`Identifier`&&t.callee.name===`require`&&!P(e,t.callee)?.defs.length&&n(t,t.arguments[0])}}}function b(n,i){let o=i.startsWith(`.`)?a(r(n.filename),i):t(e(),n.filename,i);return o!==null&&f(n,o)?.replace(/\.[cm]?[jt]s$/,``)===`functions`}function x(e){return e.type===`TSImportType`||e.type===`ImportDeclaration`&&(e.importKind===`type`||e.specifiers.length>0&&e.specifiers.every(e=>e.type===`ImportSpecifier`&&e.importKind===`type`))||(e.type===`ExportNamedDeclaration`||e.type===`ExportAllDeclaration`)&&e.exportKind===`type`}function S(e){return e.callee.type===`MemberExpression`&&e.callee.object.type===`MemberExpression`&&N(e.callee.object)===`db`}function C(e,t){let n=p(e,t.callee);return n&&/^(?:node:)?(?:https?|net|tls|fs)(?:\/|$)|^(?:undici|axios)(?:\/|$)/.test(n.source)?!0:t.callee.type===`Identifier`&&t.callee.name===`fetch`&&!P(e,t.callee)?.defs.length||t.callee.type===`MemberExpression`&&N(t.callee)===`fetch`&&t.callee.object.type===`Identifier`&&t.callee.object.name===`globalThis`&&!P(e,t.callee.object)?.defs.length}function w(e,t){if(t.type===`MemberExpression`){let n=p(e,t.object);return n?.name===`components`&&/_generated\/api/.test(n.source)?!0:w(e,t.object)}return t.type===`ObjectExpression`&&t.properties.some(t=>t.type===`Property`&&w(e,t.value))}function T(e){return e.type===`MemberExpression`?T(e.object):e}function E(e){return e.type===`Identifier`?[e.name]:e.type===`MemberExpression`?[...E(e.object),N(e)??``]:[]}function D(e){return e.type===`MemberExpression`?N(e)===`table`||D(e.object):e.type===`CallExpression`&&D(e.callee)}function O(e){return e.callee.type===`MemberExpression`&&[`insert`,`patch`,`replace`,`delete`].includes(N(e.callee)??``)&&e.callee.object.type===`MemberExpression`&&N(e.callee.object)===`db`}function k(e,t){return e.type===`CallExpression`?e.callee.type===`MemberExpression`&&N(e.callee)===t&&(t!==`query`||N(e.callee.object)===`db`)||k(e.callee,t):e.type===`MemberExpression`&&k(e.object,t)}function A(e,t){return{type:`problem`,docs:{description:e},schema:[],messages:t}}function j(e,t){let n=a(e.cwd,d.parse(e.options[0]??{}).convexDir),r=s(n)?l(n):n,c=i(r,s(t)?l(t):t).split(o).join(`/`).match(/^components\/([^/]+)(?:\/|$)/);return c?a(r,`components`,c[1]):null}function M(e){return e?.type===`Literal`&&`value`in e&&String(e.value)===e.value?String(e.value):e?.type===`TemplateLiteral`&&e.expressions.length===0?e.quasis[0].value.cooked:null}function N(e){return e.type===`MemberExpression`?e.computed?M(e.property):e.property.name:null}function P(e,t){if(t.type!==`Identifier`)return null;let n=e.sourceCode.getScope(t);for(;n;){let e=n.set.get(t.name);if(e)return e;n=n.upper}return null}function F(e){let t=/* @__PURE__ */ new Set;for(let n of e.body)if(n.type===`ExportNamedDeclaration`&&!n.source)for(let e of n.specifiers)t.add(I(e.local)??``);else n.type===`ExportDefaultDeclaration`&&n.declaration.type===`Identifier`&&t.add(n.declaration.name);return t}function I(e){return e.type===`Identifier`?e.name:M(e)}function L(e){return e.type===`CallExpression`?!0:e.type===`AwaitExpression`?L(e.argument):e.type===`BlockStatement`&&e.body.length>0&&e.body.every(e=>e.type===`ReturnStatement`&&e.argument!==null&&L(e.argument)||e.type===`ExpressionStatement`&&L(e.expression))}function R(e,n){let r=B(e),i=t(r.resolver,e.filename,n.source),a=i&&f(e,i);if(!i||!a||!/^(?:domain\/.+\/schema\.ts|querying\.ts|foundation\.ts)$/.test(a)||!s(i))return null;let o=`${i}:${n.name}`;if(r.imports.has(o))return r.imports.get(o)??null;let c=z(e,i,n.name);return r.imports.set(o,c),c}function z(e,t,n){let r=B(e),i=r.files.get(t);if(i||(i=u(t,c(t,`utf8`)),r.files.set(t,i)),i.errors.length)return null;let a=/* @__PURE__ */ new Map,o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map,l=/* @__PURE__ */ new Map;for(let e of i.program.body){if(e.type===`ImportDeclaration`&&e.importKind!==`type`)for(let t of e.specifiers)t.type===`ImportSpecifier`&&t.importKind!==`type`&&a.set(t.local.name,{source:e.source.value,name:t.imported.type===`Identifier`?t.imported.name:``}),t.type===`ImportNamespaceSpecifier`&&a.set(t.local.name,{source:e.source.value,name:`*`});let t=e.type===`ExportNamedDeclaration`?e.declaration:e;if(t?.type===`VariableDeclaration`&&t.kind===`const`){for(let n of t.declarations)if(n.init){if(n.id.type===`ObjectPattern`)for(let t of n.id.properties){if(t.type!==`Property`||t.value.type!==`Identifier`)continue;let r=t.computed?G(t.key):t.key.type===`Identifier`?t.key.name:null;r&&(o.set(t.value.name,n.init),s.set(t.value.name,r),e.type===`ExportNamedDeclaration`&&l.set(t.value.name,t.value.name))}n.id.type===`Identifier`&&(o.set(n.id.name,n.init),e.type===`ExportNamedDeclaration`&&l.set(n.id.name,n.id.name))}}if(e.type===`ExportNamedDeclaration`&&!e.source&&e.exportKind!==`type`)for(let t of e.specifiers)t.exportKind!==`type`&&t.local.type===`Identifier`&&t.exported.type===`Identifier`&&l.set(t.exported.name,t.local.name)}let d=l.get(n);if(!d)return null;function f(e,t=/* @__PURE__ */ new Set){if(e.type===`Identifier`){if(t.has(e.name)||t.size>16)return null;let n=a.get(e.name);if(n)return n;let r=o.get(e.name);return r?f(r,new Set(t).add(e.name)):null}if(e.type===`MemberExpression`&&!e.computed&&e.property.type===`Identifier`){let n=f(e.object,t);if(n?.name===`*`)return{source:n.source,name:e.property.name}}return null}function p(e,t=/* @__PURE__ */ new Set){if(e.type===`TSAsExpression`||e.type===`TSSatisfiesExpression`||e.type===`ParenthesizedExpression`)return p(e.expression,t);if(e.type===`Identifier`){if(t.has(e.name)||t.size>16)return null;let n=o.get(e.name),r=n?p(n,new Set(t).add(e.name)):null;return s.has(e.name)?r===`foundation`&&s.get(e.name)===`Query`?`queryRegistry`:null:r}if(e.type===`MemberExpression`&&!e.computed&&e.property.type===`Identifier`)return p(e.object,t)===`foundation`&&e.property.name===`Query`?`queryRegistry`:null;if(e.type!==`CallExpression`&&e.type!==`NewExpression`)return null;let n=f(e.callee);return n&&U(n)?`foundation`:n&&[`cvx-kit`,`cvx-kit/zod-table`,`cvx-kit/tenancy`].includes(n.source)&&[`zodTable`,`tenantTable`,`zodVariantTable`].includes(n.name)?`table`:n&&[`cvx-kit`,`cvx-kit/querying`].includes(n.source)&&n.name===`createQueryEngine`?`engine`:null}let m=o.get(d),h=m?p(m):null;return s.has(d)?h===`foundation`&&s.get(d)===`Query`?`queryRegistry`:null:h}function B(t){let n=_.get(t);return n||(n={nodes:/* @__PURE__ */ new Map,files:/* @__PURE__ */ new Map,imports:/* @__PURE__ */ new Map,resolver:e()},_.set(t,n)),n}function*V(e,t){if(t.type===`AwaitExpression`)return yield t.argument;if(t.type===`TSAsExpression`||t.type===`TSSatisfiesExpression`||t.type===`TSNonNullExpression`)return yield t.expression;if(t.type===`Identifier`){if(P(e,t)?.references.some(e=>e.isWrite()&&!e.init))return null;let n=m(e,t);if(n)return yield n;let r=h(e,t);if(r){let e=yield r.expression;if(e===`context`&&r.name===`db`)return`db`;if(e===`page`&&r.name===`page`)return`bounded`;if(e===`table`&&r.name===`publicDto`)return`dtoSchema`;if(e===`foundation`&&r.name===`Query`)return`queryRegistry`}let i=P(e,t)?.defs[0];if(i?.type===`Parameter`&&(i.node.type===`ArrowFunctionExpression`||i.node.type===`FunctionExpression`)){let t=i.node.parent;if(t?.type===`CallExpression`&&t.arguments[0]===i.node&&i.node.params[0]===i.name&&(t.callee.type===`Identifier`||t.callee.type===`MemberExpression`)){let n=p(e,t.callee);if(n&&H(n))return`context`}if(t?.type===`CallExpression`&&t.callee.type===`MemberExpression`){let e=yield t.callee.object,n=N(t.callee);if(n===`handler`&&e===`queryOperation`&&t.arguments[0]===i.node&&i.node.params[1]===i.name)return`context`;if(i.node.params[0]!==i.name)return null;if((n===`execute`||n===`paginate`)&&t.arguments[1]===i.node&&(e===`stream`||e===`relationship`))return`bounded`;if(n===`then`&&t.arguments[0]===i.node&&(e===`bounded`||e===`page`))return e}let n=i.node.parent,r=n?.type===`Property`?n.parent:null,a=r?.type===`ObjectExpression`?r.parent:null,o=a?.type===`CallExpression`?p(e,a.callee):null;if(n?.type===`Property`&&(n.computed?M(n.key):I(n.key))===`operations`&&a?.type===`CallExpression`&&a.arguments[0]===r&&(yield a.callee)===`queryRegistry`&&r?.type===`ObjectExpression`&&i.node.params[0]?.type===`ObjectPattern`&&i.node.params[0].properties.some(e=>e.type===`Property`&&e.value===i.name&&(e.computed?M(e.key):I(e.key))===`query`)&&W(e,r))return`queryOperation`;if(n?.type===`Property`&&(n.computed?M(n.key):I(n.key))===`handler`&&a?.type===`CallExpression`&&a.arguments[0]===r&&i.node.params[1]===i.name&&(yield a.callee)===`queryOperation`||n?.type===`Property`&&(n.computed?M(n.key):I(n.key))===`handler`&&i.node.params[0]===i.name&&o&&(a?.type===`CallExpression`&&a.arguments[0]===r&&(a.callee.type===`Identifier`||a.callee.type===`MemberExpression`)&&H(o)||b(e,o.source)&&/^(?:auth|role|admin|system)(?:Query|Mutation)$/.test(o.name)))return`context`}let a=p(e,t);return a&&[`zod`,`zod/v4`,`convex/values`].includes(a.source)&&[`z`,`v`,`*`,`default`].includes(a.name)?`validator`:a?R(e,a):null}if(t.type===`MemberExpression`){let n=p(e,t);if(n){let t=R(e,n);if(t)return t}let r=yield t.object,i=N(t);return r===`context`&&i===`db`?`db`:r===`foundation`&&i===`Query`?`queryRegistry`:r===`reader`?`stream`:r===`page`&&i===`page`?`bounded`:r===`table`&&[`publicDto`,`dto`].includes(i??``)?`dtoSchema`:r===`validator`?`validator`:null}if(t.type!==`CallExpression`&&t.type!==`NewExpression`)return null;let n=yield t.callee;if(n===`engine`)return`reader`;if(n===`include`&&t.arguments[0]&&(yield t.arguments[0])===`stream`)return`stream`;let r=p(e,t.callee);if(r&&U(r))return`foundation`;if(r&&[`cvx-kit`,`cvx-kit/zod-table`,`cvx-kit/tenancy`].includes(r.source)&&[`zodTable`,`tenantTable`,`zodVariantTable`].includes(r.name))return`table`;if(r&&[`cvx-kit`,`cvx-kit/querying`].includes(r.source)&&r.name===`createQueryEngine`)return`engine`;if(r&&[`cvx-kit`,`cvx-kit/auth`].includes(r.source)&&r.name===`createInclude`)return`include`;if(r?.source===`convex-helpers/server/stream`&&r.name===`stream`&&t.arguments[0]&&(yield t.arguments[0])===`db`)return`db`;if(t.callee.type!==`MemberExpression`)return null;let i=yield t.callee.object,a=N(t.callee);if(i===`table`&&a===`toPublicDto`)return`dto`;if(i===`table`&&[`select`,`dto`].includes(a??``))return`dtoSchema`;if(i===`dtoSchema`&&[`parse`,`parseAsync`].includes(a??``))return`dto`;if(i===`db`&&a===`query`)return`stream`;if(i===`stream`&&a===`relation`)return`relationship`;if(i===`context`&&a===`include`&&t.arguments[0]&&(yield t.arguments[0])===`stream`)return`stream`;if(i===`stream`||i===`relationship`){if([`take`,`execute`].includes(a??``))return`bounded`;if(a===`paginate`)return`page`;if([`withIndex`,`withSearchIndex`,`filter`,`filterWith`,`map`,`flatMap`,`distinct`,`order`,`matching`,`when`,`otherwise`,`fullTableScan`,`where`,`with`].includes(a??``))return i}return i===`bounded`&&a===`map`?`bounded`:i===`validator`?`validator`:null}function H(e){return/_generated\/server(?:\.[cm]?[jt]s)?$/.test(e.source)&&g.includes(e.name)||e.source===`convex/server`&&g.some(t=>e.name===`${t}Generic`)}function U(e){return e.source===`cvx-kit`&&e.name===`createFoundation`||e.source===`cvx-kit/effect`&&e.name===`createEffectFoundation`||[`cvx-kit`,`cvx-kit/components/foundation`].includes(e.source)&&e.name===`Foundation`}function W(e,t){let n=t.properties.find(e=>e.type===`Property`&&(e.computed?M(e.key):I(e.key))===`context`);if(n?.type!==`Property`)return!1;let r=n.value;if(r.type!==`ArrowFunctionExpression`&&r.type!==`FunctionExpression`)return!1;let i=r.params[0];if(i?.type!==`Identifier`||P(e,i)?.references.some(e=>e.isWrite()&&!e.init))return!1;let a=r.body,o=a?.type===`BlockStatement`&&a.body.length===1&&a.body[0].type===`ReturnStatement`?a.body[0].argument:a;return o?.type===`Identifier`&&P(e,o)===P(e,i)}function G(e){return e.type===`Literal`&&String(e.value)===e.value?String(e.value):e.type===`TemplateLiteral`&&e.expressions.length===0?e.quasis[0].value.cooked:null}export{f as appFile,P as binding,j as componentRoot,d as consumerOptions,w as containsComponentReference,L as delegatingBody,I as exportName,F as exportedNames,k as hasCall,p as imported,S as isDbAccess,O as isDbWrite,C as isExternalCall,b as isFunctionsImport,D as isTableChain,h as localDestructured,m as localInitializer,E as memberPath,A as metadata,N as propertyName,v as readProvenance,T as rootMember,y as sourceVisitors,M as staticString,x as typeOnlySource};
|
|
1
|
+
import{conventionalComponentRoot as e,findComponentRoot as t}from"./components.mjs";import{createResolver as n,resolveImport as r}from"./architecture.mjs";import{z as i}from"zod";import{dirname as a,relative as o,resolve as s,sep as c}from"node:path";import{existsSync as l,readFileSync as u,realpathSync as d}from"node:fs";import{parseSync as f}from"oxc-parser";const p=i.object({convexDir:i.string().min(1).default(`convex`),componentDirs:i.array(i.string().min(1)).default([]),domainPublicFiles:i.record(i.string(),i.array(i.string().min(1))).default({})});function m(e,t=e.filename){let n=s(e.cwd,p.parse(e.options[0]??{}).convexDir),r=l(n)?d(n):n,i=o(r,l(t)?d(t):t).split(c).join(`/`);return i===`..`||i.startsWith(`../`)||i.startsWith(`/`)?null:i}function h(e,t,n=/* @__PURE__ */ new Set){if(n.has(t)||n.size>32)return null;if(n=new Set(n).add(t),t.type===`TSAsExpression`||t.type===`TSSatisfiesExpression`||t.type===`TSNonNullExpression`)return h(e,t.expression,n);if(t.type===`CallExpression`)return h(e,t.callee,n);if(t.type===`MemberExpression`){let r=h(e,t.object,n),i=I(t);return r&&i&&[`*`,`z`,`v`,`default`].includes(r.name)?{source:r.source,name:i}:null}if(t.type!==`Identifier`)return null;let r=g(e,t);if(r&&r.type!==`CallExpression`&&r.type!==`AwaitExpression`)return h(e,r,n);let i=_(e,t);if(i){let t=h(e,i.expression,n);return t&&[`*`,`z`,`v`,`default`].includes(t.name)?{source:t.source,name:i.name}:null}for(let n of L(e,t)?.defs??[]){if(n.type!==`ImportBinding`||n.parent?.type!==`ImportDeclaration`||n.parent.importKind===`type`)continue;let e=n.node;if(e.type!==`ImportSpecifier`||e.importKind!==`type`)return{source:n.parent.source.value,name:e.type===`ImportSpecifier`?z(e.imported)??``:e.type===`ImportDefaultSpecifier`?`default`:`*`}}return null}function g(e,t){let n=L(e,t);if(!n||n.references.some(e=>e.isWrite()&&!e.init))return null;let r=n.defs.length===1?n.defs[0]:null;return r?.type===`Variable`&&r.parent?.type===`VariableDeclaration`&&r.parent.kind===`const`&&r.node.type===`VariableDeclarator`&&r.node.id.type===`Identifier`?r.node.init:null}function _(e,t){let n=L(e,t);if(!n||n.references.some(e=>e.isWrite()&&!e.init))return null;let r=n.defs.length===1?n.defs[0]:null;if(r?.type!==`Variable`||r.parent?.type!==`VariableDeclaration`||r.parent.kind!==`const`||r.node.type!==`VariableDeclarator`||r.node.id.type!==`ObjectPattern`||!r.node.init)return null;for(let e of r.node.id.properties)if(e.type===`Property`&&e.value.type===`Identifier`&&e.value.name===n.name){let t=e.computed?F(e.key):z(e.key);if(t)return{expression:r.node.init,name:t}}return null}const v=[`query`,`internalQuery`,`mutation`,`internalMutation`],y=/* @__PURE__ */ new WeakMap;function b(e,t){let n=U(e).nodes;if(n.has(t))return n.get(t)??null;n.set(t,null);let r=[{node:t,evaluation:W(e,t)}],i=null;for(;r.length;){let t=r[r.length-1],a=t.evaluation.next(i);a.done?(i=a.value,n.set(t.node,i),r.pop()):n.has(a.value)?i=n.get(a.value)??null:(n.set(a.value,null),r.push({node:a.value,evaluation:W(e,a.value)}),i=null)}return i}function x(e,t){function n(e,n){let r=F(n);r&&t(e,r)}return{ImportDeclaration(e){n(e,e.source)},ExportNamedDeclaration(e){n(e,e.source)},ExportAllDeclaration(e){n(e,e.source)},ImportExpression(e){n(e,e.source)},TSImportType(e){n(e,e.source)},CallExpression(t){t.callee.type===`Identifier`&&t.callee.name===`require`&&!L(e,t.callee)?.defs.length&&n(t,t.arguments[0])}}}function S(e,t){let i=t.startsWith(`.`)?s(a(e.filename),t):r(n(),e.filename,t);if(!i)return!1;let l=P(e,e.filename);return(l?o(l,i).split(c).join(`/`):m(e,i))?.replace(/\.[cm]?[jt]s$/,``)===`functions`}function C(e){return e.type===`TSImportType`||e.type===`ImportDeclaration`&&(e.importKind===`type`||e.specifiers.length>0&&e.specifiers.every(e=>e.type===`ImportSpecifier`&&e.importKind===`type`))||(e.type===`ExportNamedDeclaration`||e.type===`ExportAllDeclaration`)&&e.exportKind===`type`}function w(e){return e.callee.type===`MemberExpression`&&e.callee.object.type===`MemberExpression`&&I(e.callee.object)===`db`}function T(e,t){let n=h(e,t.callee);return n&&/^(?:node:)?(?:https?|net|tls|fs)(?:\/|$)|^(?:undici|axios)(?:\/|$)/.test(n.source)?!0:t.callee.type===`Identifier`&&t.callee.name===`fetch`&&!L(e,t.callee)?.defs.length||t.callee.type===`MemberExpression`&&I(t.callee)===`fetch`&&t.callee.object.type===`Identifier`&&t.callee.object.name===`globalThis`&&!L(e,t.callee.object)?.defs.length}function E(e,t){if(t.type===`MemberExpression`){let n=h(e,t.object);return n?.name===`components`&&/_generated\/api/.test(n.source)?!0:E(e,t.object)}return t.type===`ObjectExpression`&&t.properties.some(t=>t.type===`Property`&&E(e,t.value))}function D(e){return e.type===`MemberExpression`?D(e.object):e}function O(e){return e.type===`Identifier`?[e.name]:e.type===`MemberExpression`?[...O(e.object),I(e)??``]:[]}function k(e){return e.type===`MemberExpression`?I(e)===`table`||k(e.object):e.type===`CallExpression`&&k(e.callee)}function A(e){return e.callee.type===`MemberExpression`&&[`insert`,`patch`,`replace`,`delete`].includes(I(e.callee)??``)&&e.callee.object.type===`MemberExpression`&&I(e.callee.object)===`db`}function j(e,t){return e.type===`CallExpression`?e.callee.type===`MemberExpression`&&I(e.callee)===t&&(t!==`query`||I(e.callee.object)===`db`)||j(e.callee,t):e.type===`MemberExpression`&&j(e.object,t)}function M(e,t){return{type:`problem`,docs:{description:e},schema:[],messages:t}}const N=/* @__PURE__ */ new WeakMap;function P(n,r){let i=N.get(n);if(i||(i=/* @__PURE__ */ new Map,N.set(n,i)),i.has(r))return i.get(r)??null;let a=s(n.cwd,p.parse(n.options[0]??{}).convexDir),o=l(a)?d(a):a,c=l(r)?d(r):s(r),u=p.parse(n.options[0]??{}).componentDirs.map(e=>s(o,e)),f=t(c,u)??e(c,o);return i.set(r,f),f}function F(e){return e?.type===`Literal`&&`value`in e&&String(e.value)===e.value?String(e.value):e?.type===`TemplateLiteral`&&e.expressions.length===0?e.quasis[0].value.cooked:null}function I(e){return e.type===`MemberExpression`?e.computed?F(e.property):e.property.name:null}function L(e,t){if(t.type!==`Identifier`)return null;let n=e.sourceCode.getScope(t);for(;n;){let e=n.set.get(t.name);if(e)return e;n=n.upper}return null}function R(e){let t=/* @__PURE__ */ new Set;for(let n of e.body)if(n.type===`ExportNamedDeclaration`&&!n.source)for(let e of n.specifiers)t.add(z(e.local)??``);else n.type===`ExportDefaultDeclaration`&&n.declaration.type===`Identifier`&&t.add(n.declaration.name);return t}function z(e){return e.type===`Identifier`?e.name:F(e)}function B(e){return e.type===`CallExpression`?!0:e.type===`AwaitExpression`?B(e.argument):e.type===`BlockStatement`&&e.body.length>0&&e.body.every(e=>e.type===`ReturnStatement`&&e.argument!==null&&B(e.argument)||e.type===`ExpressionStatement`&&B(e.expression))}function V(e,t){let n=U(e),i=r(n.resolver,e.filename,t.source),a=i&&m(e,i);if(!i||!a||!/^(?:domain\/.+\/schema\.ts|querying\.ts|foundation\.ts)$/.test(a)&&!(P(e,i)&&/(?:^|\/)(?:schema|table|foundation)\.ts$/.test(a))||!l(i))return null;let o=`${i}:${t.name}`;if(n.imports.has(o))return n.imports.get(o)??null;let s=H(e,i,t.name);return n.imports.set(o,s),s}function H(e,t,n){let r=U(e),i=r.files.get(t);if(i||(i=f(t,u(t,`utf8`)),r.files.set(t,i)),i.errors.length)return null;let a=/* @__PURE__ */ new Map,o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map,c=/* @__PURE__ */ new Map;for(let e of i.program.body){if(e.type===`ImportDeclaration`&&e.importKind!==`type`)for(let t of e.specifiers)t.type===`ImportSpecifier`&&t.importKind!==`type`&&a.set(t.local.name,{source:e.source.value,name:t.imported.type===`Identifier`?t.imported.name:``}),t.type===`ImportNamespaceSpecifier`&&a.set(t.local.name,{source:e.source.value,name:`*`});let t=e.type===`ExportNamedDeclaration`?e.declaration:e;if(t?.type===`VariableDeclaration`&&t.kind===`const`){for(let n of t.declarations)if(n.init){if(n.id.type===`ObjectPattern`)for(let t of n.id.properties){if(t.type!==`Property`||t.value.type!==`Identifier`)continue;let r=t.computed?J(t.key):t.key.type===`Identifier`?t.key.name:null;r&&(o.set(t.value.name,n.init),s.set(t.value.name,r),e.type===`ExportNamedDeclaration`&&c.set(t.value.name,t.value.name))}n.id.type===`Identifier`&&(o.set(n.id.name,n.init),e.type===`ExportNamedDeclaration`&&c.set(n.id.name,n.id.name))}}if(e.type===`ExportNamedDeclaration`&&!e.source&&e.exportKind!==`type`)for(let t of e.specifiers)t.exportKind!==`type`&&t.local.type===`Identifier`&&t.exported.type===`Identifier`&&c.set(t.exported.name,t.local.name)}let l=c.get(n);if(!l)return null;function d(e,t=/* @__PURE__ */ new Set){if(e.type===`Identifier`){if(t.has(e.name)||t.size>16)return null;let n=a.get(e.name);if(n)return n;let r=o.get(e.name);return r?d(r,new Set(t).add(e.name)):null}if(e.type===`MemberExpression`&&!e.computed&&e.property.type===`Identifier`){let n=d(e.object,t);if(n?.name===`*`)return{source:n.source,name:e.property.name}}return null}function p(e,t=/* @__PURE__ */ new Set){if(e.type===`TSAsExpression`||e.type===`TSSatisfiesExpression`||e.type===`ParenthesizedExpression`)return p(e.expression,t);if(e.type===`Identifier`){if(t.has(e.name)||t.size>16)return null;let n=o.get(e.name),r=n?p(n,new Set(t).add(e.name)):null;return s.has(e.name)?r===`foundation`&&s.get(e.name)===`Query`?`queryRegistry`:null:r}if(e.type===`MemberExpression`&&!e.computed&&e.property.type===`Identifier`)return p(e.object,t)===`foundation`&&e.property.name===`Query`?`queryRegistry`:null;if(e.type!==`CallExpression`&&e.type!==`NewExpression`)return null;let n=d(e.callee);return n&&K(n)?`foundation`:n&&[`cvx-kit`,`cvx-kit/zod-table`,`cvx-kit/tenancy`].includes(n.source)&&[`zodTable`,`tenantTable`,`zodVariantTable`].includes(n.name)?`table`:n&&[`cvx-kit`,`cvx-kit/querying`].includes(n.source)&&n.name===`createQueryEngine`?`engine`:null}let m=o.get(l),h=m?p(m):null;return s.has(l)?h===`foundation`&&s.get(l)===`Query`?`queryRegistry`:null:h}function U(e){let t=y.get(e);return t||(t={nodes:/* @__PURE__ */ new Map,files:/* @__PURE__ */ new Map,imports:/* @__PURE__ */ new Map,resolver:n()},y.set(e,t)),t}function*W(e,t){if(t.type===`AwaitExpression`)return yield t.argument;if(t.type===`TSAsExpression`||t.type===`TSSatisfiesExpression`||t.type===`TSNonNullExpression`)return yield t.expression;if(t.type===`Identifier`){if(L(e,t)?.references.some(e=>e.isWrite()&&!e.init))return null;let n=g(e,t);if(n)return yield n;let r=_(e,t);if(r){let e=yield r.expression;if(e===`context`&&r.name===`db`)return`db`;if(e===`page`&&r.name===`page`)return`bounded`;if(e===`table`&&r.name===`publicDto`)return`dtoSchema`;if(e===`foundation`&&r.name===`Query`)return`queryRegistry`}let i=L(e,t)?.defs[0];if(i?.type===`Parameter`&&(i.node.type===`ArrowFunctionExpression`||i.node.type===`FunctionExpression`)){let t=i.node.parent;if(t?.type===`CallExpression`&&t.arguments[0]===i.node&&i.node.params[0]===i.name&&(t.callee.type===`Identifier`||t.callee.type===`MemberExpression`)){let n=h(e,t.callee);if(n&&G(n))return`context`}if(t?.type===`CallExpression`&&t.callee.type===`MemberExpression`){let e=yield t.callee.object,n=I(t.callee);if(n===`handler`&&e===`queryOperation`&&t.arguments[0]===i.node&&i.node.params[1]===i.name)return`context`;if(i.node.params[0]!==i.name)return null;if((n===`execute`||n===`paginate`)&&t.arguments[1]===i.node&&(e===`stream`||e===`relationship`))return`bounded`;if(n===`then`&&t.arguments[0]===i.node&&(e===`bounded`||e===`page`))return e}let n=i.node.parent,r=n?.type===`Property`?n.parent:null,a=r?.type===`ObjectExpression`?r.parent:null,o=a?.type===`CallExpression`?h(e,a.callee):null;if(n?.type===`Property`&&(n.computed?F(n.key):z(n.key))===`operations`&&a?.type===`CallExpression`&&a.arguments[0]===r&&(yield a.callee)===`queryRegistry`&&r?.type===`ObjectExpression`&&i.node.params[0]?.type===`ObjectPattern`&&i.node.params[0].properties.some(e=>e.type===`Property`&&e.value===i.name&&(e.computed?F(e.key):z(e.key))===`query`)&&q(e,r))return`queryOperation`;if(n?.type===`Property`&&(n.computed?F(n.key):z(n.key))===`handler`&&a?.type===`CallExpression`&&a.arguments[0]===r&&i.node.params[1]===i.name&&(yield a.callee)===`queryOperation`||n?.type===`Property`&&(n.computed?F(n.key):z(n.key))===`handler`&&i.node.params[0]===i.name&&o&&(a?.type===`CallExpression`&&a.arguments[0]===r&&(a.callee.type===`Identifier`||a.callee.type===`MemberExpression`)&&G(o)||S(e,o.source)&&/^(?:auth|role|admin|system)(?:Query|Mutation)$/.test(o.name)))return`context`}let a=h(e,t);return a&&[`zod`,`zod/v4`,`convex/values`].includes(a.source)&&[`z`,`v`,`*`,`default`].includes(a.name)?`validator`:a?V(e,a):null}if(t.type===`MemberExpression`){let n=h(e,t);if(n){let t=V(e,n);if(t)return t}let r=yield t.object,i=I(t);return r===`context`&&i===`db`?`db`:r===`foundation`&&i===`Query`?`queryRegistry`:r===`reader`?`stream`:r===`page`&&i===`page`?`bounded`:r===`table`&&[`publicDto`,`dto`].includes(i??``)?`dtoSchema`:r===`validator`?`validator`:null}if(t.type!==`CallExpression`&&t.type!==`NewExpression`)return null;let n=yield t.callee;if(n===`engine`)return`reader`;if(n===`include`&&t.arguments[0]&&(yield t.arguments[0])===`stream`)return`stream`;let r=h(e,t.callee);if(r&&K(r))return`foundation`;if(r&&[`cvx-kit`,`cvx-kit/zod-table`,`cvx-kit/tenancy`].includes(r.source)&&[`zodTable`,`tenantTable`,`zodVariantTable`].includes(r.name))return`table`;if(r&&[`cvx-kit`,`cvx-kit/querying`].includes(r.source)&&r.name===`createQueryEngine`)return`engine`;if(r&&[`cvx-kit`,`cvx-kit/auth`].includes(r.source)&&r.name===`createInclude`)return`include`;if(r?.source===`convex-helpers/server/stream`&&r.name===`stream`&&t.arguments[0]&&(yield t.arguments[0])===`db`)return`db`;if(t.callee.type!==`MemberExpression`)return null;let i=yield t.callee.object,a=I(t.callee);if(i===`table`&&a===`toPublicDto`)return`dto`;if(i===`table`&&[`select`,`dto`].includes(a??``))return`dtoSchema`;if(i===`dtoSchema`&&[`parse`,`parseAsync`].includes(a??``))return`dto`;if(i===`db`&&a===`query`)return`stream`;if(i===`stream`&&a===`relation`)return`relationship`;if(i===`context`&&a===`include`&&t.arguments[0]&&(yield t.arguments[0])===`stream`)return`stream`;if(i===`stream`||i===`relationship`){if([`take`,`execute`].includes(a??``))return`bounded`;if(a===`paginate`)return`page`;if([`withIndex`,`withSearchIndex`,`filter`,`filterWith`,`map`,`flatMap`,`distinct`,`order`,`matching`,`when`,`otherwise`,`fullTableScan`,`where`,`with`].includes(a??``))return i}return i===`bounded`&&a===`map`?`bounded`:i===`validator`?`validator`:null}function G(e){return/_generated\/server(?:\.[cm]?[jt]s)?$/.test(e.source)&&v.includes(e.name)||e.source===`convex/server`&&v.some(t=>e.name===`${t}Generic`)}function K(e){return e.source===`cvx-kit`&&e.name===`createFoundation`||e.source===`cvx-kit/effect`&&e.name===`createEffectFoundation`||[`cvx-kit`,`cvx-kit/components/foundation`].includes(e.source)&&e.name===`Foundation`}function q(e,t){let n=t.properties.find(e=>e.type===`Property`&&(e.computed?F(e.key):z(e.key))===`context`);if(n?.type!==`Property`)return!1;let r=n.value;if(r.type!==`ArrowFunctionExpression`&&r.type!==`FunctionExpression`)return!1;let i=r.params[0];if(i?.type!==`Identifier`||L(e,i)?.references.some(e=>e.isWrite()&&!e.init))return!1;let a=r.body,o=a?.type===`BlockStatement`&&a.body.length===1&&a.body[0].type===`ReturnStatement`?a.body[0].argument:a;return o?.type===`Identifier`&&L(e,o)===L(e,i)}function J(e){return e.type===`Literal`&&String(e.value)===e.value?String(e.value):e.type===`TemplateLiteral`&&e.expressions.length===0?e.quasis[0].value.cooked:null}export{m as appFile,L as binding,P as componentRoot,p as consumerOptions,E as containsComponentReference,B as delegatingBody,z as exportName,R as exportedNames,j as hasCall,h as imported,w as isDbAccess,A as isDbWrite,T as isExternalCall,S as isFunctionsImport,k as isTableChain,_ as localDestructured,g as localInitializer,O as memberPath,M as metadata,I as propertyName,b as readProvenance,D as rootMember,x as sourceVisitors,F as staticString,C as typeOnlySource};
|
|
2
2
|
//# sourceMappingURL=ast.mjs.map
|
package/dist/oxlint/ast.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.mjs","names":["consumerOptions","z","appFile","context","requestedRoot","resolve","root","existsSync","realpathSync","file","relative","filename","sep","imported","active","node","owner","name","propertyName","initializer","localInitializer","member","localDestructured","def","binding","specifier","exportName","variable","reference","property","staticString","nativeReadBuilders","provenanceCaches","readProvenance","cache","provenanceCache","stack","evaluateReadProvenance","result","frame","step","sourceVisitors","visit","text","source","check","isFunctionsImport","target","dirname","resolveImport","createResolver","typeOnlySource","isDbAccess","isExternalCall","ref","containsComponentReference","rootMember","memberPath","isTableChain","isDbWrite","hasCall","metadata","componentRoot","match","scope","exportedNames","names","statement","program","delegatingBody","importedReadProvenance","key","physicalReadProvenance","parsed","parseSync","readFileSync","imports","declarations","members","exports","declaration","item","physicalString","local","factoryImport","importedFactory","init","evaluate","value","factory","foundationFactory","callbackCall","nativeReadBuilder","method","object","call","p","registryPreservesContext","importedValue","callee","callback","host","r","body","returned"],"sources":["../../src/oxlint/ast.ts"],"sourcesContent":["import { existsSync, readFileSync, realpathSync } from 'node:fs'\nimport { dirname, relative, resolve, sep } from 'node:path'\nimport type { Context, ESTree, RuleMeta, Scope, Visitor } from '@oxlint/plugins'\nimport { z } from 'zod'\nimport { parseSync, type Node } from 'oxc-parser'\nimport { createResolver, resolveImport } from './architecture'\n\nexport const consumerOptions = z.object({ convexDir: z.string().min(1).default('convex') })\n\nexport function appFile(context: Context, filename = context.filename) {\n\tconst requestedRoot = resolve(\n\t\tcontext.cwd,\n\t\tconsumerOptions.parse(context.options[0] ?? {}).convexDir,\n\t)\n\tconst root = existsSync(requestedRoot) ? realpathSync(requestedRoot) : requestedRoot\n\tconst file = relative(root, existsSync(filename) ? realpathSync(filename) : filename)\n\t\t.split(sep)\n\t\t.join('/')\n\treturn file === '..' || file.startsWith('../') || file.startsWith('/') ? null : file\n}\n\nexport function imported(\n\tcontext: Context,\n\tnode: ESTree.Node,\n\tactive = new Set<ESTree.Node>(),\n): { source: string; name: string } | null {\n\tif (active.has(node) || active.size > 32) return null\n\tactive = new Set(active).add(node)\n\tif (\n\t\tnode.type === 'TSAsExpression' ||\n\t\tnode.type === 'TSSatisfiesExpression' ||\n\t\tnode.type === 'TSNonNullExpression'\n\t)\n\t\treturn imported(context, node.expression, active)\n\tif (node.type === 'CallExpression') return imported(context, node.callee, active)\n\tif (node.type === 'MemberExpression') {\n\t\tconst owner = imported(context, node.object, active)\n\t\tconst name = propertyName(node)\n\t\treturn owner && name && ['*', 'z', 'v', 'default'].includes(owner.name)\n\t\t\t? { source: owner.source, name }\n\t\t\t: null\n\t}\n\tif (node.type !== 'Identifier') return null\n\tconst initializer = localInitializer(context, node)\n\tif (\n\t\tinitializer &&\n\t\tinitializer.type !== 'CallExpression' &&\n\t\tinitializer.type !== 'AwaitExpression'\n\t)\n\t\treturn imported(context, initializer, active)\n\tconst member = localDestructured(context, node)\n\tif (member) {\n\t\tconst owner = imported(context, member.expression, active)\n\t\treturn owner && ['*', 'z', 'v', 'default'].includes(owner.name)\n\t\t\t? { source: owner.source, name: member.name }\n\t\t\t: null\n\t}\n\tfor (const def of binding(context, node)?.defs ?? []) {\n\t\tif (\n\t\t\tdef.type !== 'ImportBinding' ||\n\t\t\tdef.parent?.type !== 'ImportDeclaration' ||\n\t\t\tdef.parent.importKind === 'type'\n\t\t)\n\t\t\tcontinue\n\t\tconst specifier = def.node\n\t\tif (specifier.type === 'ImportSpecifier' && specifier.importKind === 'type') continue\n\t\treturn {\n\t\t\tsource: def.parent.source.value,\n\t\t\tname:\n\t\t\t\tspecifier.type === 'ImportSpecifier'\n\t\t\t\t\t? (exportName(specifier.imported) ?? '')\n\t\t\t\t\t: specifier.type === 'ImportDefaultSpecifier'\n\t\t\t\t\t\t? 'default'\n\t\t\t\t\t\t: '*',\n\t\t}\n\t}\n\treturn null\n}\n\n/** Follow immutable bindings only; a same-named parameter never inherits outer provenance. */\nexport function localInitializer(context: Context, node: ESTree.Node): ESTree.Node | null {\n\tconst variable = binding(context, node)\n\tif (!variable || variable.references.some((reference) => reference.isWrite() && !reference.init))\n\t\treturn null\n\tconst def = variable.defs.length === 1 ? variable.defs[0] : null\n\treturn def?.type === 'Variable' &&\n\t\tdef.parent?.type === 'VariableDeclaration' &&\n\t\tdef.parent.kind === 'const' &&\n\t\tdef.node.type === 'VariableDeclarator' &&\n\t\tdef.node.id.type === 'Identifier'\n\t\t? def.node.init\n\t\t: null\n}\n\nexport function localDestructured(context: Context, node: ESTree.Node) {\n\tconst variable = binding(context, node)\n\tif (!variable || variable.references.some((reference) => reference.isWrite() && !reference.init))\n\t\treturn null\n\tconst def = variable.defs.length === 1 ? variable.defs[0] : null\n\tif (\n\t\tdef?.type !== 'Variable' ||\n\t\tdef.parent?.type !== 'VariableDeclaration' ||\n\t\tdef.parent.kind !== 'const' ||\n\t\tdef.node.type !== 'VariableDeclarator' ||\n\t\tdef.node.id.type !== 'ObjectPattern' ||\n\t\t!def.node.init\n\t)\n\t\treturn null\n\tfor (const property of def.node.id.properties) {\n\t\tif (\n\t\t\tproperty.type === 'Property' &&\n\t\t\tproperty.value.type === 'Identifier' &&\n\t\t\tproperty.value.name === variable.name\n\t\t) {\n\t\t\tconst name = property.computed ? staticString(property.key) : exportName(property.key)\n\t\t\tif (name) return { expression: def.node.init, name }\n\t\t}\n\t}\n\treturn null\n}\n\nexport type ReadProvenance =\n\t| 'table'\n\t| 'dtoSchema'\n\t| 'dto'\n\t| 'engine'\n\t| 'reader'\n\t| 'include'\n\t| 'context'\n\t| 'db'\n\t| 'stream'\n\t| 'relationship'\n\t| 'bounded'\n\t| 'page'\n\t| 'validator'\n\t| 'foundation'\n\t| 'queryRegistry'\n\t| 'queryOperation'\n\nconst nativeReadBuilders = ['query', 'internalQuery', 'mutation', 'internalMutation']\n\n// Weak keys keep caches local to a lint invocation; no file state survives a new context.\nconst provenanceCaches = new WeakMap<\n\tContext,\n\t{\n\t\tnodes: Map<ESTree.Node, ReadProvenance | null>\n\t\tfiles: Map<string, ReturnType<typeof parseSync>>\n\t\timports: Map<string, ReadProvenance | null>\n\t\tresolver: ReturnType<typeof createResolver>\n\t}\n>()\n/** Suspend dependencies on a work stack; null in-progress entries terminate alias cycles. */\nexport function readProvenance(context: Context, node: ESTree.Node): ReadProvenance | null {\n\tconst cache = provenanceCache(context).nodes\n\tif (cache.has(node)) return cache.get(node) ?? null\n\tcache.set(node, null)\n\tconst stack = [{ node, evaluation: evaluateReadProvenance(context, node) }]\n\tlet result: ReadProvenance | null = null\n\twhile (stack.length) {\n\t\tconst frame = stack[stack.length - 1]!\n\t\tconst step = frame.evaluation.next(result)\n\t\tif (step.done) {\n\t\t\tresult = step.value\n\t\t\tcache.set(frame.node, result)\n\t\t\tstack.pop()\n\t\t} else if (cache.has(step.value)) {\n\t\t\tresult = cache.get(step.value) ?? null\n\t\t} else {\n\t\t\tcache.set(step.value, null)\n\t\t\tstack.push({ node: step.value, evaluation: evaluateReadProvenance(context, step.value) })\n\t\t\tresult = null\n\t\t}\n\t}\n\treturn result\n}\nexport function sourceVisitors(\n\tcontext: Context,\n\tcheck: (node: ESTree.Node, source: string) => void,\n): Visitor {\n\tfunction visit(node: ESTree.Node, source: ESTree.Node | null | undefined) {\n\t\tconst text = staticString(source)\n\t\tif (text) check(node, text)\n\t}\n\treturn {\n\t\tImportDeclaration(node) {\n\t\t\tvisit(node, node.source)\n\t\t},\n\t\tExportNamedDeclaration(node) {\n\t\t\tvisit(node, node.source)\n\t\t},\n\t\tExportAllDeclaration(node) {\n\t\t\tvisit(node, node.source)\n\t\t},\n\t\tImportExpression(node) {\n\t\t\tvisit(node, node.source)\n\t\t},\n\t\tTSImportType(node) {\n\t\t\tvisit(node, node.source)\n\t\t},\n\t\tCallExpression(node) {\n\t\t\tif (\n\t\t\t\tnode.callee.type === 'Identifier' &&\n\t\t\t\tnode.callee.name === 'require' &&\n\t\t\t\t!binding(context, node.callee)?.defs.length\n\t\t\t)\n\t\t\t\tvisit(node, node.arguments[0])\n\t\t},\n\t}\n}\n\nexport function isFunctionsImport(context: Context, source: string) {\n\tconst target = source.startsWith('.')\n\t\t? resolve(dirname(context.filename), source)\n\t\t: resolveImport(createResolver(), context.filename, source)\n\treturn target !== null && appFile(context, target)?.replace(/\\.[cm]?[jt]s$/, '') === 'functions'\n}\n\nexport function typeOnlySource(node: ESTree.Node) {\n\treturn (\n\t\tnode.type === 'TSImportType' ||\n\t\t(node.type === 'ImportDeclaration' &&\n\t\t\t(node.importKind === 'type' ||\n\t\t\t\t(node.specifiers.length > 0 &&\n\t\t\t\t\tnode.specifiers.every(\n\t\t\t\t\t\t(specifier) => specifier.type === 'ImportSpecifier' && specifier.importKind === 'type',\n\t\t\t\t\t)))) ||\n\t\t((node.type === 'ExportNamedDeclaration' || node.type === 'ExportAllDeclaration') &&\n\t\t\tnode.exportKind === 'type')\n\t)\n}\n\nexport function isDbAccess(node: ESTree.CallExpression) {\n\treturn (\n\t\tnode.callee.type === 'MemberExpression' &&\n\t\tnode.callee.object.type === 'MemberExpression' &&\n\t\tpropertyName(node.callee.object) === 'db'\n\t)\n}\n\nexport function isExternalCall(context: Context, node: ESTree.CallExpression) {\n\tconst ref = imported(context, node.callee)\n\tif (ref && /^(?:node:)?(?:https?|net|tls|fs)(?:\\/|$)|^(?:undici|axios)(?:\\/|$)/.test(ref.source))\n\t\treturn true\n\treturn (\n\t\t(node.callee.type === 'Identifier' &&\n\t\t\tnode.callee.name === 'fetch' &&\n\t\t\t!binding(context, node.callee)?.defs.length) ||\n\t\t(node.callee.type === 'MemberExpression' &&\n\t\t\tpropertyName(node.callee) === 'fetch' &&\n\t\t\tnode.callee.object.type === 'Identifier' &&\n\t\t\tnode.callee.object.name === 'globalThis' &&\n\t\t\t!binding(context, node.callee.object)?.defs.length)\n\t)\n}\n\nexport function containsComponentReference(context: Context, node: ESTree.Node): boolean {\n\tif (node.type === 'MemberExpression') {\n\t\tconst owner = imported(context, node.object)\n\t\tif (owner?.name === 'components' && /_generated\\/api/.test(owner.source)) return true\n\t\treturn containsComponentReference(context, node.object)\n\t}\n\tif (node.type === 'ObjectExpression')\n\t\treturn node.properties.some(\n\t\t\t(property) =>\n\t\t\t\tproperty.type === 'Property' && containsComponentReference(context, property.value),\n\t\t)\n\treturn false\n}\n\nexport function rootMember(node: ESTree.Node): ESTree.Node {\n\treturn node.type === 'MemberExpression' ? rootMember(node.object) : node\n}\n\nexport function memberPath(node: ESTree.Node): string[] {\n\tif (node.type === 'Identifier') return [node.name]\n\tif (node.type === 'MemberExpression')\n\t\treturn [...memberPath(node.object), propertyName(node) ?? '']\n\treturn []\n}\n\nexport function isTableChain(node: ESTree.Node): boolean {\n\tif (node.type === 'MemberExpression')\n\t\treturn propertyName(node) === 'table' || isTableChain(node.object)\n\treturn node.type === 'CallExpression' && isTableChain(node.callee)\n}\n\nexport function isDbWrite(node: ESTree.CallExpression) {\n\treturn (\n\t\tnode.callee.type === 'MemberExpression' &&\n\t\t['insert', 'patch', 'replace', 'delete'].includes(propertyName(node.callee) ?? '') &&\n\t\tnode.callee.object.type === 'MemberExpression' &&\n\t\tpropertyName(node.callee.object) === 'db'\n\t)\n}\n\nexport function hasCall(node: ESTree.Node, name: string): boolean {\n\tif (node.type === 'CallExpression')\n\t\treturn (\n\t\t\t(node.callee.type === 'MemberExpression' &&\n\t\t\t\tpropertyName(node.callee) === name &&\n\t\t\t\t(name !== 'query' || propertyName(node.callee.object) === 'db')) ||\n\t\t\thasCall(node.callee, name)\n\t\t)\n\tif (node.type === 'MemberExpression') return hasCall(node.object, name)\n\treturn false\n}\n\nexport function metadata(description: string, messages: Record<string, string>): RuleMeta {\n\treturn { type: 'problem', docs: { description }, schema: [], messages }\n}\n\nexport function componentRoot(context: Context, filename: string) {\n\tconst requestedRoot = resolve(\n\t\tcontext.cwd,\n\t\tconsumerOptions.parse(context.options[0] ?? {}).convexDir,\n\t)\n\tconst root = existsSync(requestedRoot) ? realpathSync(requestedRoot) : requestedRoot\n\tconst file = relative(root, existsSync(filename) ? realpathSync(filename) : filename)\n\t\t.split(sep)\n\t\t.join('/')\n\tconst match = file.match(/^components\\/([^/]+)(?:\\/|$)/)\n\treturn match ? resolve(root, 'components', match[1]) : null\n}\n\nexport function staticString(node: ESTree.Node | null | undefined) {\n\tif (node?.type === 'Literal' && 'value' in node && String(node.value) === node.value)\n\t\treturn String(node.value)\n\tif (node?.type === 'TemplateLiteral' && node.expressions.length === 0)\n\t\treturn node.quasis[0].value.cooked\n\treturn null\n}\n\nexport function propertyName(node: ESTree.Node): string | null {\n\tif (node.type !== 'MemberExpression') return null\n\treturn node.computed ? staticString(node.property) : node.property.name\n}\n\nexport function binding(context: Context, node: ESTree.Node) {\n\tif (node.type !== 'Identifier') return null\n\tlet scope: Scope | null = context.sourceCode.getScope(node)\n\twhile (scope) {\n\t\tconst variable = scope.set.get(node.name)\n\t\tif (variable) return variable\n\t\tscope = scope.upper\n\t}\n\treturn null\n}\n\nexport function exportedNames(program: ESTree.Program) {\n\tconst names = new Set<string>()\n\tfor (const statement of program.body) {\n\t\tif (statement.type === 'ExportNamedDeclaration' && !statement.source) {\n\t\t\tfor (const specifier of statement.specifiers) names.add(exportName(specifier.local) ?? '')\n\t\t} else if (\n\t\t\tstatement.type === 'ExportDefaultDeclaration' &&\n\t\t\tstatement.declaration.type === 'Identifier'\n\t\t) {\n\t\t\tnames.add(statement.declaration.name)\n\t\t}\n\t}\n\treturn names\n}\n\nexport function exportName(node: ESTree.Node): string | null {\n\treturn node.type === 'Identifier' ? node.name : staticString(node)\n}\n\nexport function delegatingBody(node: ESTree.Node): boolean {\n\tif (node.type === 'CallExpression') return true\n\tif (node.type === 'AwaitExpression') return delegatingBody(node.argument)\n\tif (node.type === 'BlockStatement')\n\t\treturn (\n\t\t\tnode.body.length > 0 &&\n\t\t\tnode.body.every(\n\t\t\t\t(statement) =>\n\t\t\t\t\t(statement.type === 'ReturnStatement' &&\n\t\t\t\t\t\tstatement.argument !== null &&\n\t\t\t\t\t\tdelegatingBody(statement.argument)) ||\n\t\t\t\t\t(statement.type === 'ExpressionStatement' && delegatingBody(statement.expression)),\n\t\t\t)\n\t\t)\n\treturn false\n}\n\n/** Read only the owning schema/facade's top-level declaration, never arbitrary helper bodies. */\nfunction importedReadProvenance(\n\tcontext: Context,\n\tref: { source: string; name: string },\n): ReadProvenance | null {\n\tconst cache = provenanceCache(context)\n\tconst target = resolveImport(cache.resolver, context.filename, ref.source)\n\tconst file = target && appFile(context, target)\n\tif (\n\t\t!target ||\n\t\t!file ||\n\t\t!/^(?:domain\\/.+\\/schema\\.ts|querying\\.ts|foundation\\.ts)$/.test(file) ||\n\t\t!existsSync(target)\n\t)\n\t\treturn null\n\tconst key = `${target}:${ref.name}`\n\tif (cache.imports.has(key)) return cache.imports.get(key) ?? null\n\tconst result = physicalReadProvenance(context, target, ref.name)\n\tcache.imports.set(key, result)\n\treturn result\n}\nfunction physicalReadProvenance(\n\tcontext: Context,\n\ttarget: string,\n\tname: string,\n): ReadProvenance | null {\n\tconst cache = provenanceCache(context)\n\tlet parsed = cache.files.get(target)\n\tif (!parsed) {\n\t\tparsed = parseSync(target, readFileSync(target, 'utf8'))\n\t\tcache.files.set(target, parsed)\n\t}\n\tif (parsed.errors.length) return null\n\tconst imports = new Map<string, { source: string; name: string }>()\n\tconst declarations = new Map<string, Node>()\n\tconst members = new Map<string, string>()\n\tconst exports = new Map<string, string>()\n\tfor (const statement of parsed.program.body) {\n\t\tif (statement.type === 'ImportDeclaration' && statement.importKind !== 'type') {\n\t\t\tfor (const specifier of statement.specifiers) {\n\t\t\t\tif (specifier.type === 'ImportSpecifier' && specifier.importKind !== 'type')\n\t\t\t\t\timports.set(specifier.local.name, {\n\t\t\t\t\t\tsource: statement.source.value,\n\t\t\t\t\t\tname: specifier.imported.type === 'Identifier' ? specifier.imported.name : '',\n\t\t\t\t\t})\n\t\t\t\tif (specifier.type === 'ImportNamespaceSpecifier')\n\t\t\t\t\timports.set(specifier.local.name, { source: statement.source.value, name: '*' })\n\t\t\t}\n\t\t}\n\t\tconst declaration =\n\t\t\tstatement.type === 'ExportNamedDeclaration' ? statement.declaration : statement\n\t\tif (declaration?.type === 'VariableDeclaration' && declaration.kind === 'const') {\n\t\t\tfor (const item of declaration.declarations) {\n\t\t\t\tif (!item.init) continue\n\t\t\t\tif (item.id.type === 'ObjectPattern') {\n\t\t\t\t\tfor (const property of item.id.properties) {\n\t\t\t\t\t\tif (property.type !== 'Property' || property.value.type !== 'Identifier') continue\n\t\t\t\t\t\tconst member = property.computed\n\t\t\t\t\t\t\t? physicalString(property.key)\n\t\t\t\t\t\t\t: property.key.type === 'Identifier'\n\t\t\t\t\t\t\t\t? property.key.name\n\t\t\t\t\t\t\t\t: null\n\t\t\t\t\t\tif (!member) continue\n\t\t\t\t\t\tdeclarations.set(property.value.name, item.init)\n\t\t\t\t\t\tmembers.set(property.value.name, member)\n\t\t\t\t\t\tif (statement.type === 'ExportNamedDeclaration')\n\t\t\t\t\t\t\texports.set(property.value.name, property.value.name)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (item.id.type !== 'Identifier') continue\n\t\t\t\tdeclarations.set(item.id.name, item.init)\n\t\t\t\tif (statement.type === 'ExportNamedDeclaration') exports.set(item.id.name, item.id.name)\n\t\t\t}\n\t\t}\n\t\tif (\n\t\t\tstatement.type === 'ExportNamedDeclaration' &&\n\t\t\t!statement.source &&\n\t\t\tstatement.exportKind !== 'type'\n\t\t) {\n\t\t\tfor (const specifier of statement.specifiers)\n\t\t\t\tif (\n\t\t\t\t\tspecifier.exportKind !== 'type' &&\n\t\t\t\t\tspecifier.local.type === 'Identifier' &&\n\t\t\t\t\tspecifier.exported.type === 'Identifier'\n\t\t\t\t)\n\t\t\t\t\texports.set(specifier.exported.name, specifier.local.name)\n\t\t}\n\t}\n\tconst local = exports.get(name)\n\tif (!local) return null\n\tfunction factoryImport(\n\t\tnode: Node,\n\t\tactive = new Set<string>(),\n\t): { source: string; name: string } | null {\n\t\tif (node.type === 'Identifier') {\n\t\t\tif (active.has(node.name) || active.size > 16) return null\n\t\t\tconst importedFactory = imports.get(node.name)\n\t\t\tif (importedFactory) return importedFactory\n\t\t\tconst init = declarations.get(node.name)\n\t\t\treturn init ? factoryImport(init, new Set(active).add(node.name)) : null\n\t\t}\n\t\tif (node.type === 'MemberExpression' && !node.computed && node.property.type === 'Identifier') {\n\t\t\tconst owner = factoryImport(node.object, active)\n\t\t\tif (owner?.name === '*') return { source: owner.source, name: node.property.name }\n\t\t}\n\t\treturn null\n\t}\n\tfunction evaluate(node: Node, active = new Set<string>()): ReadProvenance | null {\n\t\tif (\n\t\t\tnode.type === 'TSAsExpression' ||\n\t\t\tnode.type === 'TSSatisfiesExpression' ||\n\t\t\tnode.type === 'ParenthesizedExpression'\n\t\t)\n\t\t\treturn evaluate(node.expression, active)\n\t\tif (node.type === 'Identifier') {\n\t\t\tif (active.has(node.name) || active.size > 16) return null\n\t\t\tconst init = declarations.get(node.name)\n\t\t\tconst value = init ? evaluate(init, new Set(active).add(node.name)) : null\n\t\t\treturn members.has(node.name)\n\t\t\t\t? value === 'foundation' && members.get(node.name) === 'Query'\n\t\t\t\t\t? 'queryRegistry'\n\t\t\t\t\t: null\n\t\t\t\t: value\n\t\t}\n\t\tif (node.type === 'MemberExpression' && !node.computed && node.property.type === 'Identifier')\n\t\t\treturn evaluate(node.object, active) === 'foundation' && node.property.name === 'Query'\n\t\t\t\t? 'queryRegistry'\n\t\t\t\t: null\n\t\tif (node.type !== 'CallExpression' && node.type !== 'NewExpression') return null\n\t\tconst factory = factoryImport(node.callee)\n\t\tif (factory && foundationFactory(factory)) return 'foundation'\n\t\tif (\n\t\t\tfactory &&\n\t\t\t['cvx-kit', 'cvx-kit/zod-table', 'cvx-kit/tenancy'].includes(factory.source) &&\n\t\t\t['zodTable', 'tenantTable', 'zodVariantTable'].includes(factory.name)\n\t\t)\n\t\t\treturn 'table'\n\t\tif (\n\t\t\tfactory &&\n\t\t\t['cvx-kit', 'cvx-kit/querying'].includes(factory.source) &&\n\t\t\tfactory.name === 'createQueryEngine'\n\t\t)\n\t\t\treturn 'engine'\n\t\treturn null\n\t}\n\tconst declaration = declarations.get(local)\n\tconst value = declaration ? evaluate(declaration) : null\n\treturn members.has(local)\n\t\t? value === 'foundation' && members.get(local) === 'Query'\n\t\t\t? 'queryRegistry'\n\t\t\t: null\n\t\t: value\n}\n\nfunction provenanceCache(context: Context) {\n\tlet cache = provenanceCaches.get(context)\n\tif (!cache) {\n\t\tcache = { nodes: new Map(), files: new Map(), imports: new Map(), resolver: createResolver() }\n\t\tprovenanceCaches.set(context, cache)\n\t}\n\treturn cache\n}\n\nfunction* evaluateReadProvenance(\n\tcontext: Context,\n\tnode: ESTree.Node,\n): Generator<ESTree.Node, ReadProvenance | null, ReadProvenance | null> {\n\tif (node.type === 'AwaitExpression') return yield node.argument\n\tif (\n\t\tnode.type === 'TSAsExpression' ||\n\t\tnode.type === 'TSSatisfiesExpression' ||\n\t\tnode.type === 'TSNonNullExpression'\n\t)\n\t\treturn yield node.expression\n\tif (node.type === 'Identifier') {\n\t\tconst variable = binding(context, node)\n\t\tif (variable?.references.some((reference) => reference.isWrite() && !reference.init))\n\t\t\treturn null\n\t\tconst initializer = localInitializer(context, node)\n\t\tif (initializer) return yield initializer\n\t\tconst member = localDestructured(context, node)\n\t\tif (member) {\n\t\t\tconst owner = yield member.expression\n\t\t\tif (owner === 'context' && member.name === 'db') return 'db'\n\t\t\tif (owner === 'page' && member.name === 'page') return 'bounded'\n\t\t\tif (owner === 'table' && member.name === 'publicDto') return 'dtoSchema'\n\t\t\tif (owner === 'foundation' && member.name === 'Query') return 'queryRegistry'\n\t\t}\n\t\tconst def = binding(context, node)?.defs[0]\n\t\tif (\n\t\t\tdef?.type === 'Parameter' &&\n\t\t\t(def.node.type === 'ArrowFunctionExpression' || def.node.type === 'FunctionExpression')\n\t\t) {\n\t\t\tconst callbackCall = def.node.parent\n\t\t\tif (\n\t\t\t\tcallbackCall?.type === 'CallExpression' &&\n\t\t\t\tcallbackCall.arguments[0] === def.node &&\n\t\t\t\tdef.node.params[0] === def.name &&\n\t\t\t\t(callbackCall.callee.type === 'Identifier' ||\n\t\t\t\t\tcallbackCall.callee.type === 'MemberExpression')\n\t\t\t) {\n\t\t\t\tconst ref = imported(context, callbackCall.callee)\n\t\t\t\tif (ref && nativeReadBuilder(ref)) return 'context'\n\t\t\t}\n\t\t\tif (\n\t\t\t\tcallbackCall?.type === 'CallExpression' &&\n\t\t\t\tcallbackCall.callee.type === 'MemberExpression'\n\t\t\t) {\n\t\t\t\tconst owner = yield callbackCall.callee.object\n\t\t\t\tconst method = propertyName(callbackCall.callee)\n\t\t\t\tif (\n\t\t\t\t\tmethod === 'handler' &&\n\t\t\t\t\towner === 'queryOperation' &&\n\t\t\t\t\tcallbackCall.arguments[0] === def.node &&\n\t\t\t\t\tdef.node.params[1] === def.name\n\t\t\t\t)\n\t\t\t\t\treturn 'context'\n\t\t\t\tif (def.node.params[0] !== def.name) return null\n\t\t\t\tif (\n\t\t\t\t\t(method === 'execute' || method === 'paginate') &&\n\t\t\t\t\tcallbackCall.arguments[1] === def.node &&\n\t\t\t\t\t(owner === 'stream' || owner === 'relationship')\n\t\t\t\t)\n\t\t\t\t\treturn 'bounded'\n\t\t\t\tif (\n\t\t\t\t\tmethod === 'then' &&\n\t\t\t\t\tcallbackCall.arguments[0] === def.node &&\n\t\t\t\t\t(owner === 'bounded' || owner === 'page')\n\t\t\t\t)\n\t\t\t\t\treturn owner\n\t\t\t}\n\t\t\tconst property = def.node.parent\n\t\t\tconst object = property?.type === 'Property' ? property.parent : null\n\t\t\tconst call = object?.type === 'ObjectExpression' ? object.parent : null\n\t\t\tconst ref = call?.type === 'CallExpression' ? imported(context, call.callee) : null\n\t\t\tif (\n\t\t\t\tproperty?.type === 'Property' &&\n\t\t\t\t(property.computed ? staticString(property.key) : exportName(property.key)) ===\n\t\t\t\t\t'operations' &&\n\t\t\t\tcall?.type === 'CallExpression' &&\n\t\t\t\tcall.arguments[0] === object &&\n\t\t\t\t(yield call.callee) === 'queryRegistry' &&\n\t\t\t\tobject?.type === 'ObjectExpression' &&\n\t\t\t\tdef.node.params[0]?.type === 'ObjectPattern' &&\n\t\t\t\tdef.node.params[0].properties.some(\n\t\t\t\t\t(p) =>\n\t\t\t\t\t\tp.type === 'Property' &&\n\t\t\t\t\t\tp.value === def.name &&\n\t\t\t\t\t\t(p.computed ? staticString(p.key) : exportName(p.key)) === 'query',\n\t\t\t\t) &&\n\t\t\t\tregistryPreservesContext(context, object)\n\t\t\t)\n\t\t\t\treturn 'queryOperation'\n\n\t\t\tif (\n\t\t\t\tproperty?.type === 'Property' &&\n\t\t\t\t(property.computed ? staticString(property.key) : exportName(property.key)) === 'handler' &&\n\t\t\t\tcall?.type === 'CallExpression' &&\n\t\t\t\tcall.arguments[0] === object &&\n\t\t\t\tdef.node.params[1] === def.name &&\n\t\t\t\t(yield call.callee) === 'queryOperation'\n\t\t\t)\n\t\t\t\treturn 'context'\n\n\t\t\tif (\n\t\t\t\tproperty?.type === 'Property' &&\n\t\t\t\t(property.computed ? staticString(property.key) : exportName(property.key)) === 'handler' &&\n\t\t\t\tdef.node.params[0] === def.name &&\n\t\t\t\tref &&\n\t\t\t\t((call?.type === 'CallExpression' &&\n\t\t\t\t\tcall.arguments[0] === object &&\n\t\t\t\t\t(call.callee.type === 'Identifier' || call.callee.type === 'MemberExpression') &&\n\t\t\t\t\tnativeReadBuilder(ref)) ||\n\t\t\t\t\t(isFunctionsImport(context, ref.source) &&\n\t\t\t\t\t\t/^(?:auth|role|admin|system)(?:Query|Mutation)$/.test(ref.name)))\n\t\t\t)\n\t\t\t\treturn 'context'\n\t\t}\n\t\tconst ref = imported(context, node)\n\t\tif (\n\t\t\tref &&\n\t\t\t['zod', 'zod/v4', 'convex/values'].includes(ref.source) &&\n\t\t\t['z', 'v', '*', 'default'].includes(ref.name)\n\t\t)\n\t\t\treturn 'validator'\n\t\tif (ref) return importedReadProvenance(context, ref)\n\t\treturn null\n\t}\n\tif (node.type === 'MemberExpression') {\n\t\tconst ref = imported(context, node)\n\t\tif (ref) {\n\t\t\tconst importedValue = importedReadProvenance(context, ref)\n\t\t\tif (importedValue) return importedValue\n\t\t}\n\t\tconst owner = yield node.object\n\t\tconst name = propertyName(node)\n\t\tif (owner === 'context' && name === 'db') return 'db'\n\t\tif (owner === 'foundation' && name === 'Query') return 'queryRegistry'\n\t\tif (owner === 'reader') return 'stream'\n\t\tif (owner === 'page' && name === 'page') return 'bounded'\n\t\tif (owner === 'table' && ['publicDto', 'dto'].includes(name ?? '')) return 'dtoSchema'\n\t\tif (owner === 'validator') return 'validator'\n\t\treturn null\n\t}\n\tif (node.type !== 'CallExpression' && node.type !== 'NewExpression') return null\n\tconst callee = yield node.callee\n\tif (callee === 'engine') return 'reader'\n\tif (callee === 'include' && node.arguments[0] && (yield node.arguments[0]) === 'stream')\n\t\treturn 'stream'\n\tconst ref = imported(context, node.callee)\n\tif (ref && foundationFactory(ref)) return 'foundation'\n\tif (\n\t\tref &&\n\t\t['cvx-kit', 'cvx-kit/zod-table', 'cvx-kit/tenancy'].includes(ref.source) &&\n\t\t['zodTable', 'tenantTable', 'zodVariantTable'].includes(ref.name)\n\t)\n\t\treturn 'table'\n\tif (\n\t\tref &&\n\t\t['cvx-kit', 'cvx-kit/querying'].includes(ref.source) &&\n\t\tref.name === 'createQueryEngine'\n\t)\n\t\treturn 'engine'\n\tif (ref && ['cvx-kit', 'cvx-kit/auth'].includes(ref.source) && ref.name === 'createInclude')\n\t\treturn 'include'\n\tif (\n\t\tref?.source === 'convex-helpers/server/stream' &&\n\t\tref.name === 'stream' &&\n\t\tnode.arguments[0] &&\n\t\t(yield node.arguments[0]) === 'db'\n\t)\n\t\treturn 'db'\n\tif (node.callee.type !== 'MemberExpression') return null\n\tconst owner = yield node.callee.object\n\tconst name = propertyName(node.callee)\n\tif (owner === 'table' && name === 'toPublicDto') return 'dto'\n\tif (owner === 'table' && ['select', 'dto'].includes(name ?? '')) return 'dtoSchema'\n\tif (owner === 'dtoSchema' && ['parse', 'parseAsync'].includes(name ?? '')) return 'dto'\n\tif (owner === 'db' && name === 'query') return 'stream'\n\tif (owner === 'stream' && name === 'relation') return 'relationship'\n\tif (\n\t\towner === 'context' &&\n\t\tname === 'include' &&\n\t\tnode.arguments[0] &&\n\t\t(yield node.arguments[0]) === 'stream'\n\t)\n\t\treturn 'stream'\n\tif (owner === 'stream' || owner === 'relationship') {\n\t\tif (['take', 'execute'].includes(name ?? '')) return 'bounded'\n\t\tif (name === 'paginate') return 'page'\n\t\tif (\n\t\t\t[\n\t\t\t\t'withIndex',\n\t\t\t\t'withSearchIndex',\n\t\t\t\t'filter',\n\t\t\t\t'filterWith',\n\t\t\t\t'map',\n\t\t\t\t'flatMap',\n\t\t\t\t'distinct',\n\t\t\t\t'order',\n\t\t\t\t'matching',\n\t\t\t\t'when',\n\t\t\t\t'otherwise',\n\t\t\t\t'fullTableScan',\n\t\t\t\t'where',\n\t\t\t\t'with',\n\t\t\t].includes(name ?? '')\n\t\t)\n\t\t\treturn owner\n\t}\n\tif (owner === 'bounded' && name === 'map') return 'bounded'\n\tif (owner === 'validator') return 'validator'\n\treturn null\n}\n\n/** Match native registration contracts by both their import source and exported name. */\nfunction nativeReadBuilder(ref: { source: string; name: string }) {\n\treturn (\n\t\t(/_generated\\/server(?:\\.[cm]?[jt]s)?$/.test(ref.source) &&\n\t\t\tnativeReadBuilders.includes(ref.name)) ||\n\t\t(ref.source === 'convex/server' &&\n\t\t\tnativeReadBuilders.some((name) => ref.name === `${name}Generic`))\n\t)\n}\n\nfunction foundationFactory(ref: { source: string; name: string }) {\n\treturn (\n\t\t(ref.source === 'cvx-kit' && ref.name === 'createFoundation') ||\n\t\t(ref.source === 'cvx-kit/effect' && ref.name === 'createEffectFoundation') ||\n\t\t(['cvx-kit', 'cvx-kit/components/foundation'].includes(ref.source) && ref.name === 'Foundation')\n\t)\n}\n\n/** The supported registry mapping passes the host through unchanged. */\nfunction registryPreservesContext(context: Context, object: ESTree.ObjectExpression) {\n\tconst property = object.properties.find(\n\t\t(p) =>\n\t\t\tp.type === 'Property' && (p.computed ? staticString(p.key) : exportName(p.key)) === 'context',\n\t)\n\tif (property?.type !== 'Property') return false\n\tconst callback = property.value\n\tif (callback.type !== 'ArrowFunctionExpression' && callback.type !== 'FunctionExpression')\n\t\treturn false\n\tconst host = callback.params[0]\n\tif (\n\t\thost?.type !== 'Identifier' ||\n\t\tbinding(context, host)?.references.some((r) => r.isWrite() && !r.init)\n\t)\n\t\treturn false\n\tconst body = callback.body\n\tconst returned =\n\t\tbody?.type === 'BlockStatement' &&\n\t\tbody.body.length === 1 &&\n\t\tbody.body[0].type === 'ReturnStatement'\n\t\t\t? body.body[0].argument\n\t\t\t: body\n\treturn returned?.type === 'Identifier' && binding(context, returned) === binding(context, host)\n}\n\nfunction physicalString(node: Node): string | null {\n\tif (node.type === 'Literal' && String(node.value) === node.value) return String(node.value)\n\tif (node.type === 'TemplateLiteral' && node.expressions.length === 0)\n\t\treturn node.quasis[0].value.cooked\n\treturn null\n}\n"],"mappings":"uRAOA,MAAaA,EAAkBC,EAAE,OAAO,CAAE,UAAWA,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,QAAQ,CAAE,CAAC,EAE1F,SAAgBC,EAAQ,EAAkB,EAAWC,EAAQ,SAAU,CACtE,IAAMC,EAAgBC,EACrBF,EAAQ,IACRH,EAAgB,MAAMG,EAAQ,QAAQ,IAAM,CAAC,CAAC,CAAC,CAAC,SACjD,EACMG,EAAOC,EAAWH,CAAa,EAAII,EAAaJ,CAAa,EAAIA,EACjEK,EAAOC,EAASJ,EAAMC,EAAWI,CAAQ,EAAIH,EAAaG,CAAQ,EAAIA,CAAQ,CAAC,CACnF,MAAMC,CAAG,CAAC,CACV,KAAK,GAAG,EACV,OAAOH,IAAS,MAAQA,EAAK,WAAW,KAAK,GAAKA,EAAK,WAAW,GAAG,EAAI,KAAOA,CACjF,CAEA,SAAgBI,EACf,EACA,EACA,kBAAS,IAAI,IAC6B,CAC1C,GAAIC,EAAO,IAAIC,CAAI,GAAKD,EAAO,KAAO,GAAI,OAAO,KAEjD,GADA,EAAS,IAAI,IAAIA,CAAM,CAAC,CAAC,IAAIC,CAAI,EAEhCA,EAAK,OAAS,kBACdA,EAAK,OAAS,yBACdA,EAAK,OAAS,sBAEd,OAAOF,EAASV,EAASY,EAAK,WAAYD,CAAM,EACjD,GAAIC,EAAK,OAAS,iBAAkB,OAAOF,EAASV,EAASY,EAAK,OAAQD,CAAM,EAChF,GAAIC,EAAK,OAAS,mBAAoB,CACrC,IAAMC,EAAQH,EAASV,EAASY,EAAK,OAAQD,CAAM,EAC7CG,EAAOC,EAAaH,CAAI,EAC9B,OAAOC,GAASC,GAAQ,CAAC,IAAK,IAAK,IAAK,SAAS,CAAC,CA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BACnBA,EAAK,KAAK,EAAE,CAAC,SACbA,EACJ,OAAOC,GAAU,OAAS,cAAgBhF,EAAQrB,EAASqG,CAAQ,IAAMhF,EAAQrB,EAASkG,CAAI,CAC/F,CAEA,SAASnB,EAAe,EAA2B,CAIlD,OAHInE,EAAK,OAAS,WAAa,OAAOA,EAAK,KAAK,IAAMA,EAAK,MAAc,OAAOA,EAAK,KAAK,EACtFA,EAAK,OAAS,mBAAqBA,EAAK,YAAY,SAAW,EAC3DA,EAAK,OAAO,EAAE,CAAC,MAAM,OACtB,IACR"}
|
|
1
|
+
{"version":3,"file":"ast.mjs","names":["consumerOptions","z","appFile","context","requestedRoot","resolve","root","existsSync","realpathSync","file","relative","filename","sep","imported","active","node","owner","name","propertyName","initializer","localInitializer","member","localDestructured","def","binding","specifier","exportName","variable","reference","property","staticString","nativeReadBuilders","provenanceCaches","readProvenance","cache","provenanceCache","stack","evaluateReadProvenance","result","frame","step","sourceVisitors","visit","text","source","check","isFunctionsImport","target","dirname","resolveImport","createResolver","componentRoot","typeOnlySource","isDbAccess","isExternalCall","ref","containsComponentReference","rootMember","memberPath","isTableChain","isDbWrite","hasCall","metadata","componentRoots","roots","path","findComponentRoot","conventionalComponentRoot","scope","exportedNames","names","statement","program","delegatingBody","importedReadProvenance","key","physicalReadProvenance","parsed","parseSync","readFileSync","imports","declarations","members","exports","declaration","item","physicalString","local","factoryImport","importedFactory","init","evaluate","value","factory","foundationFactory","callbackCall","nativeReadBuilder","method","object","call","p","registryPreservesContext","importedValue","callee","callback","host","r","body","returned"],"sources":["../../src/oxlint/ast.ts"],"sourcesContent":["import { existsSync, readFileSync, realpathSync } from 'node:fs'\nimport { dirname, relative, resolve, sep } from 'node:path'\nimport type { Context, ESTree, RuleMeta, Scope, Visitor } from '@oxlint/plugins'\nimport { z } from 'zod'\nimport { parseSync, type Node } from 'oxc-parser'\nimport { createResolver, resolveImport } from './architecture'\nimport { findComponentRoot, conventionalComponentRoot } from './components'\n\nexport const consumerOptions = z.object({\n\tconvexDir: z.string().min(1).default('convex'),\n\tcomponentDirs: z.array(z.string().min(1)).default([]),\n\tdomainPublicFiles: z.record(z.string(), z.array(z.string().min(1))).default({}),\n})\n\nexport function appFile(context: Context, filename = context.filename) {\n\tconst requestedRoot = resolve(\n\t\tcontext.cwd,\n\t\tconsumerOptions.parse(context.options[0] ?? {}).convexDir,\n\t)\n\tconst root = existsSync(requestedRoot) ? realpathSync(requestedRoot) : requestedRoot\n\tconst file = relative(root, existsSync(filename) ? realpathSync(filename) : filename)\n\t\t.split(sep)\n\t\t.join('/')\n\treturn file === '..' || file.startsWith('../') || file.startsWith('/') ? null : file\n}\n\nexport function imported(\n\tcontext: Context,\n\tnode: ESTree.Node,\n\tactive = new Set<ESTree.Node>(),\n): { source: string; name: string } | null {\n\tif (active.has(node) || active.size > 32) return null\n\tactive = new Set(active).add(node)\n\tif (\n\t\tnode.type === 'TSAsExpression' ||\n\t\tnode.type === 'TSSatisfiesExpression' ||\n\t\tnode.type === 'TSNonNullExpression'\n\t)\n\t\treturn imported(context, node.expression, active)\n\tif (node.type === 'CallExpression') return imported(context, node.callee, active)\n\tif (node.type === 'MemberExpression') {\n\t\tconst owner = imported(context, node.object, active)\n\t\tconst name = propertyName(node)\n\t\treturn owner && name && ['*', 'z', 'v', 'default'].includes(owner.name)\n\t\t\t? { source: owner.source, name }\n\t\t\t: null\n\t}\n\tif (node.type !== 'Identifier') return null\n\tconst initializer = localInitializer(context, node)\n\tif (\n\t\tinitializer &&\n\t\tinitializer.type !== 'CallExpression' &&\n\t\tinitializer.type !== 'AwaitExpression'\n\t)\n\t\treturn imported(context, initializer, active)\n\tconst member = localDestructured(context, node)\n\tif (member) {\n\t\tconst owner = imported(context, member.expression, active)\n\t\treturn owner && ['*', 'z', 'v', 'default'].includes(owner.name)\n\t\t\t? { source: owner.source, name: member.name }\n\t\t\t: null\n\t}\n\tfor (const def of binding(context, node)?.defs ?? []) {\n\t\tif (\n\t\t\tdef.type !== 'ImportBinding' ||\n\t\t\tdef.parent?.type !== 'ImportDeclaration' ||\n\t\t\tdef.parent.importKind === 'type'\n\t\t)\n\t\t\tcontinue\n\t\tconst specifier = def.node\n\t\tif (specifier.type === 'ImportSpecifier' && specifier.importKind === 'type') continue\n\t\treturn {\n\t\t\tsource: def.parent.source.value,\n\t\t\tname:\n\t\t\t\tspecifier.type === 'ImportSpecifier'\n\t\t\t\t\t? (exportName(specifier.imported) ?? '')\n\t\t\t\t\t: specifier.type === 'ImportDefaultSpecifier'\n\t\t\t\t\t\t? 'default'\n\t\t\t\t\t\t: '*',\n\t\t}\n\t}\n\treturn null\n}\n\n/** Follow immutable bindings only; a same-named parameter never inherits outer provenance. */\nexport function localInitializer(context: Context, node: ESTree.Node): ESTree.Node | null {\n\tconst variable = binding(context, node)\n\tif (!variable || variable.references.some((reference) => reference.isWrite() && !reference.init))\n\t\treturn null\n\tconst def = variable.defs.length === 1 ? variable.defs[0] : null\n\treturn def?.type === 'Variable' &&\n\t\tdef.parent?.type === 'VariableDeclaration' &&\n\t\tdef.parent.kind === 'const' &&\n\t\tdef.node.type === 'VariableDeclarator' &&\n\t\tdef.node.id.type === 'Identifier'\n\t\t? def.node.init\n\t\t: null\n}\n\nexport function localDestructured(context: Context, node: ESTree.Node) {\n\tconst variable = binding(context, node)\n\tif (!variable || variable.references.some((reference) => reference.isWrite() && !reference.init))\n\t\treturn null\n\tconst def = variable.defs.length === 1 ? variable.defs[0] : null\n\tif (\n\t\tdef?.type !== 'Variable' ||\n\t\tdef.parent?.type !== 'VariableDeclaration' ||\n\t\tdef.parent.kind !== 'const' ||\n\t\tdef.node.type !== 'VariableDeclarator' ||\n\t\tdef.node.id.type !== 'ObjectPattern' ||\n\t\t!def.node.init\n\t)\n\t\treturn null\n\tfor (const property of def.node.id.properties) {\n\t\tif (\n\t\t\tproperty.type === 'Property' &&\n\t\t\tproperty.value.type === 'Identifier' &&\n\t\t\tproperty.value.name === variable.name\n\t\t) {\n\t\t\tconst name = property.computed ? staticString(property.key) : exportName(property.key)\n\t\t\tif (name) return { expression: def.node.init, name }\n\t\t}\n\t}\n\treturn null\n}\n\nexport type ReadProvenance =\n\t| 'table'\n\t| 'dtoSchema'\n\t| 'dto'\n\t| 'engine'\n\t| 'reader'\n\t| 'include'\n\t| 'context'\n\t| 'db'\n\t| 'stream'\n\t| 'relationship'\n\t| 'bounded'\n\t| 'page'\n\t| 'validator'\n\t| 'foundation'\n\t| 'queryRegistry'\n\t| 'queryOperation'\n\nconst nativeReadBuilders = ['query', 'internalQuery', 'mutation', 'internalMutation']\n\n// Weak keys keep caches local to a lint invocation; no file state survives a new context.\nconst provenanceCaches = new WeakMap<\n\tContext,\n\t{\n\t\tnodes: Map<ESTree.Node, ReadProvenance | null>\n\t\tfiles: Map<string, ReturnType<typeof parseSync>>\n\t\timports: Map<string, ReadProvenance | null>\n\t\tresolver: ReturnType<typeof createResolver>\n\t}\n>()\n/** Suspend dependencies on a work stack; null in-progress entries terminate alias cycles. */\nexport function readProvenance(context: Context, node: ESTree.Node): ReadProvenance | null {\n\tconst cache = provenanceCache(context).nodes\n\tif (cache.has(node)) return cache.get(node) ?? null\n\tcache.set(node, null)\n\tconst stack = [{ node, evaluation: evaluateReadProvenance(context, node) }]\n\tlet result: ReadProvenance | null = null\n\twhile (stack.length) {\n\t\tconst frame = stack[stack.length - 1]!\n\t\tconst step = frame.evaluation.next(result)\n\t\tif (step.done) {\n\t\t\tresult = step.value\n\t\t\tcache.set(frame.node, result)\n\t\t\tstack.pop()\n\t\t} else if (cache.has(step.value)) {\n\t\t\tresult = cache.get(step.value) ?? null\n\t\t} else {\n\t\t\tcache.set(step.value, null)\n\t\t\tstack.push({ node: step.value, evaluation: evaluateReadProvenance(context, step.value) })\n\t\t\tresult = null\n\t\t}\n\t}\n\treturn result\n}\nexport function sourceVisitors(\n\tcontext: Context,\n\tcheck: (node: ESTree.Node, source: string) => void,\n): Visitor {\n\tfunction visit(node: ESTree.Node, source: ESTree.Node | null | undefined) {\n\t\tconst text = staticString(source)\n\t\tif (text) check(node, text)\n\t}\n\treturn {\n\t\tImportDeclaration(node) {\n\t\t\tvisit(node, node.source)\n\t\t},\n\t\tExportNamedDeclaration(node) {\n\t\t\tvisit(node, node.source)\n\t\t},\n\t\tExportAllDeclaration(node) {\n\t\t\tvisit(node, node.source)\n\t\t},\n\t\tImportExpression(node) {\n\t\t\tvisit(node, node.source)\n\t\t},\n\t\tTSImportType(node) {\n\t\t\tvisit(node, node.source)\n\t\t},\n\t\tCallExpression(node) {\n\t\t\tif (\n\t\t\t\tnode.callee.type === 'Identifier' &&\n\t\t\t\tnode.callee.name === 'require' &&\n\t\t\t\t!binding(context, node.callee)?.defs.length\n\t\t\t)\n\t\t\t\tvisit(node, node.arguments[0])\n\t\t},\n\t}\n}\n\nexport function isFunctionsImport(context: Context, source: string) {\n\tconst target = source.startsWith('.')\n\t\t? resolve(dirname(context.filename), source)\n\t\t: resolveImport(createResolver(), context.filename, source)\n\tif (!target) return false\n\tconst owner = componentRoot(context, context.filename)\n\treturn (\n\t\t(owner ? relative(owner, target).split(sep).join('/') : appFile(context, target))?.replace(\n\t\t\t/\\.[cm]?[jt]s$/,\n\t\t\t'',\n\t\t) === 'functions'\n\t)\n}\n\nexport function typeOnlySource(node: ESTree.Node) {\n\treturn (\n\t\tnode.type === 'TSImportType' ||\n\t\t(node.type === 'ImportDeclaration' &&\n\t\t\t(node.importKind === 'type' ||\n\t\t\t\t(node.specifiers.length > 0 &&\n\t\t\t\t\tnode.specifiers.every(\n\t\t\t\t\t\t(specifier) => specifier.type === 'ImportSpecifier' && specifier.importKind === 'type',\n\t\t\t\t\t)))) ||\n\t\t((node.type === 'ExportNamedDeclaration' || node.type === 'ExportAllDeclaration') &&\n\t\t\tnode.exportKind === 'type')\n\t)\n}\n\nexport function isDbAccess(node: ESTree.CallExpression) {\n\treturn (\n\t\tnode.callee.type === 'MemberExpression' &&\n\t\tnode.callee.object.type === 'MemberExpression' &&\n\t\tpropertyName(node.callee.object) === 'db'\n\t)\n}\n\nexport function isExternalCall(context: Context, node: ESTree.CallExpression) {\n\tconst ref = imported(context, node.callee)\n\tif (ref && /^(?:node:)?(?:https?|net|tls|fs)(?:\\/|$)|^(?:undici|axios)(?:\\/|$)/.test(ref.source))\n\t\treturn true\n\treturn (\n\t\t(node.callee.type === 'Identifier' &&\n\t\t\tnode.callee.name === 'fetch' &&\n\t\t\t!binding(context, node.callee)?.defs.length) ||\n\t\t(node.callee.type === 'MemberExpression' &&\n\t\t\tpropertyName(node.callee) === 'fetch' &&\n\t\t\tnode.callee.object.type === 'Identifier' &&\n\t\t\tnode.callee.object.name === 'globalThis' &&\n\t\t\t!binding(context, node.callee.object)?.defs.length)\n\t)\n}\n\nexport function containsComponentReference(context: Context, node: ESTree.Node): boolean {\n\tif (node.type === 'MemberExpression') {\n\t\tconst owner = imported(context, node.object)\n\t\tif (owner?.name === 'components' && /_generated\\/api/.test(owner.source)) return true\n\t\treturn containsComponentReference(context, node.object)\n\t}\n\tif (node.type === 'ObjectExpression')\n\t\treturn node.properties.some(\n\t\t\t(property) =>\n\t\t\t\tproperty.type === 'Property' && containsComponentReference(context, property.value),\n\t\t)\n\treturn false\n}\n\nexport function rootMember(node: ESTree.Node): ESTree.Node {\n\treturn node.type === 'MemberExpression' ? rootMember(node.object) : node\n}\n\nexport function memberPath(node: ESTree.Node): string[] {\n\tif (node.type === 'Identifier') return [node.name]\n\tif (node.type === 'MemberExpression')\n\t\treturn [...memberPath(node.object), propertyName(node) ?? '']\n\treturn []\n}\n\nexport function isTableChain(node: ESTree.Node): boolean {\n\tif (node.type === 'MemberExpression')\n\t\treturn propertyName(node) === 'table' || isTableChain(node.object)\n\treturn node.type === 'CallExpression' && isTableChain(node.callee)\n}\n\nexport function isDbWrite(node: ESTree.CallExpression) {\n\treturn (\n\t\tnode.callee.type === 'MemberExpression' &&\n\t\t['insert', 'patch', 'replace', 'delete'].includes(propertyName(node.callee) ?? '') &&\n\t\tnode.callee.object.type === 'MemberExpression' &&\n\t\tpropertyName(node.callee.object) === 'db'\n\t)\n}\n\nexport function hasCall(node: ESTree.Node, name: string): boolean {\n\tif (node.type === 'CallExpression')\n\t\treturn (\n\t\t\t(node.callee.type === 'MemberExpression' &&\n\t\t\t\tpropertyName(node.callee) === name &&\n\t\t\t\t(name !== 'query' || propertyName(node.callee.object) === 'db')) ||\n\t\t\thasCall(node.callee, name)\n\t\t)\n\tif (node.type === 'MemberExpression') return hasCall(node.object, name)\n\treturn false\n}\n\nexport function metadata(description: string, messages: Record<string, string>): RuleMeta {\n\treturn { type: 'problem', docs: { description }, schema: [], messages }\n}\n\nconst componentRoots = new WeakMap<Context, Map<string, string | null>>()\n\nexport function componentRoot(context: Context, filename: string) {\n\tlet cache = componentRoots.get(context)\n\tif (!cache) {\n\t\tcache = new Map()\n\t\tcomponentRoots.set(context, cache)\n\t}\n\tif (cache.has(filename)) return cache.get(filename) ?? null\n\tconst requestedRoot = resolve(\n\t\tcontext.cwd,\n\t\tconsumerOptions.parse(context.options[0] ?? {}).convexDir,\n\t)\n\tconst root = existsSync(requestedRoot) ? realpathSync(requestedRoot) : requestedRoot\n\tconst file = existsSync(filename) ? realpathSync(filename) : resolve(filename)\n\tconst roots = consumerOptions\n\t\t.parse(context.options[0] ?? {})\n\t\t.componentDirs.map((path) => resolve(root, path))\n\tconst owner = findComponentRoot(file, roots) ?? conventionalComponentRoot(file, root)\n\tcache.set(filename, owner)\n\treturn owner\n}\n\nexport function staticString(node: ESTree.Node | null | undefined) {\n\tif (node?.type === 'Literal' && 'value' in node && String(node.value) === node.value)\n\t\treturn String(node.value)\n\tif (node?.type === 'TemplateLiteral' && node.expressions.length === 0)\n\t\treturn node.quasis[0].value.cooked\n\treturn null\n}\n\nexport function propertyName(node: ESTree.Node): string | null {\n\tif (node.type !== 'MemberExpression') return null\n\treturn node.computed ? staticString(node.property) : node.property.name\n}\n\nexport function binding(context: Context, node: ESTree.Node) {\n\tif (node.type !== 'Identifier') return null\n\tlet scope: Scope | null = context.sourceCode.getScope(node)\n\twhile (scope) {\n\t\tconst variable = scope.set.get(node.name)\n\t\tif (variable) return variable\n\t\tscope = scope.upper\n\t}\n\treturn null\n}\n\nexport function exportedNames(program: ESTree.Program) {\n\tconst names = new Set<string>()\n\tfor (const statement of program.body) {\n\t\tif (statement.type === 'ExportNamedDeclaration' && !statement.source) {\n\t\t\tfor (const specifier of statement.specifiers) names.add(exportName(specifier.local) ?? '')\n\t\t} else if (\n\t\t\tstatement.type === 'ExportDefaultDeclaration' &&\n\t\t\tstatement.declaration.type === 'Identifier'\n\t\t) {\n\t\t\tnames.add(statement.declaration.name)\n\t\t}\n\t}\n\treturn names\n}\n\nexport function exportName(node: ESTree.Node): string | null {\n\treturn node.type === 'Identifier' ? node.name : staticString(node)\n}\n\nexport function delegatingBody(node: ESTree.Node): boolean {\n\tif (node.type === 'CallExpression') return true\n\tif (node.type === 'AwaitExpression') return delegatingBody(node.argument)\n\tif (node.type === 'BlockStatement')\n\t\treturn (\n\t\t\tnode.body.length > 0 &&\n\t\t\tnode.body.every(\n\t\t\t\t(statement) =>\n\t\t\t\t\t(statement.type === 'ReturnStatement' &&\n\t\t\t\t\t\tstatement.argument !== null &&\n\t\t\t\t\t\tdelegatingBody(statement.argument)) ||\n\t\t\t\t\t(statement.type === 'ExpressionStatement' && delegatingBody(statement.expression)),\n\t\t\t)\n\t\t)\n\treturn false\n}\n\n/** Read only the owning schema/facade's top-level declaration, never arbitrary helper bodies. */\nfunction importedReadProvenance(\n\tcontext: Context,\n\tref: { source: string; name: string },\n): ReadProvenance | null {\n\tconst cache = provenanceCache(context)\n\tconst target = resolveImport(cache.resolver, context.filename, ref.source)\n\tconst file = target && appFile(context, target)\n\tif (\n\t\t!target ||\n\t\t!file ||\n\t\t(!/^(?:domain\\/.+\\/schema\\.ts|querying\\.ts|foundation\\.ts)$/.test(file) &&\n\t\t\t!(componentRoot(context, target) && /(?:^|\\/)(?:schema|table|foundation)\\.ts$/.test(file))) ||\n\t\t!existsSync(target)\n\t)\n\t\treturn null\n\tconst key = `${target}:${ref.name}`\n\tif (cache.imports.has(key)) return cache.imports.get(key) ?? null\n\tconst result = physicalReadProvenance(context, target, ref.name)\n\tcache.imports.set(key, result)\n\treturn result\n}\nfunction physicalReadProvenance(\n\tcontext: Context,\n\ttarget: string,\n\tname: string,\n): ReadProvenance | null {\n\tconst cache = provenanceCache(context)\n\tlet parsed = cache.files.get(target)\n\tif (!parsed) {\n\t\tparsed = parseSync(target, readFileSync(target, 'utf8'))\n\t\tcache.files.set(target, parsed)\n\t}\n\tif (parsed.errors.length) return null\n\tconst imports = new Map<string, { source: string; name: string }>()\n\tconst declarations = new Map<string, Node>()\n\tconst members = new Map<string, string>()\n\tconst exports = new Map<string, string>()\n\tfor (const statement of parsed.program.body) {\n\t\tif (statement.type === 'ImportDeclaration' && statement.importKind !== 'type') {\n\t\t\tfor (const specifier of statement.specifiers) {\n\t\t\t\tif (specifier.type === 'ImportSpecifier' && specifier.importKind !== 'type')\n\t\t\t\t\timports.set(specifier.local.name, {\n\t\t\t\t\t\tsource: statement.source.value,\n\t\t\t\t\t\tname: specifier.imported.type === 'Identifier' ? specifier.imported.name : '',\n\t\t\t\t\t})\n\t\t\t\tif (specifier.type === 'ImportNamespaceSpecifier')\n\t\t\t\t\timports.set(specifier.local.name, { source: statement.source.value, name: '*' })\n\t\t\t}\n\t\t}\n\t\tconst declaration =\n\t\t\tstatement.type === 'ExportNamedDeclaration' ? statement.declaration : statement\n\t\tif (declaration?.type === 'VariableDeclaration' && declaration.kind === 'const') {\n\t\t\tfor (const item of declaration.declarations) {\n\t\t\t\tif (!item.init) continue\n\t\t\t\tif (item.id.type === 'ObjectPattern') {\n\t\t\t\t\tfor (const property of item.id.properties) {\n\t\t\t\t\t\tif (property.type !== 'Property' || property.value.type !== 'Identifier') continue\n\t\t\t\t\t\tconst member = property.computed\n\t\t\t\t\t\t\t? physicalString(property.key)\n\t\t\t\t\t\t\t: property.key.type === 'Identifier'\n\t\t\t\t\t\t\t\t? property.key.name\n\t\t\t\t\t\t\t\t: null\n\t\t\t\t\t\tif (!member) continue\n\t\t\t\t\t\tdeclarations.set(property.value.name, item.init)\n\t\t\t\t\t\tmembers.set(property.value.name, member)\n\t\t\t\t\t\tif (statement.type === 'ExportNamedDeclaration')\n\t\t\t\t\t\t\texports.set(property.value.name, property.value.name)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (item.id.type !== 'Identifier') continue\n\t\t\t\tdeclarations.set(item.id.name, item.init)\n\t\t\t\tif (statement.type === 'ExportNamedDeclaration') exports.set(item.id.name, item.id.name)\n\t\t\t}\n\t\t}\n\t\tif (\n\t\t\tstatement.type === 'ExportNamedDeclaration' &&\n\t\t\t!statement.source &&\n\t\t\tstatement.exportKind !== 'type'\n\t\t) {\n\t\t\tfor (const specifier of statement.specifiers)\n\t\t\t\tif (\n\t\t\t\t\tspecifier.exportKind !== 'type' &&\n\t\t\t\t\tspecifier.local.type === 'Identifier' &&\n\t\t\t\t\tspecifier.exported.type === 'Identifier'\n\t\t\t\t)\n\t\t\t\t\texports.set(specifier.exported.name, specifier.local.name)\n\t\t}\n\t}\n\tconst local = exports.get(name)\n\tif (!local) return null\n\tfunction factoryImport(\n\t\tnode: Node,\n\t\tactive = new Set<string>(),\n\t): { source: string; name: string } | null {\n\t\tif (node.type === 'Identifier') {\n\t\t\tif (active.has(node.name) || active.size > 16) return null\n\t\t\tconst importedFactory = imports.get(node.name)\n\t\t\tif (importedFactory) return importedFactory\n\t\t\tconst init = declarations.get(node.name)\n\t\t\treturn init ? factoryImport(init, new Set(active).add(node.name)) : null\n\t\t}\n\t\tif (node.type === 'MemberExpression' && !node.computed && node.property.type === 'Identifier') {\n\t\t\tconst owner = factoryImport(node.object, active)\n\t\t\tif (owner?.name === '*') return { source: owner.source, name: node.property.name }\n\t\t}\n\t\treturn null\n\t}\n\tfunction evaluate(node: Node, active = new Set<string>()): ReadProvenance | null {\n\t\tif (\n\t\t\tnode.type === 'TSAsExpression' ||\n\t\t\tnode.type === 'TSSatisfiesExpression' ||\n\t\t\tnode.type === 'ParenthesizedExpression'\n\t\t)\n\t\t\treturn evaluate(node.expression, active)\n\t\tif (node.type === 'Identifier') {\n\t\t\tif (active.has(node.name) || active.size > 16) return null\n\t\t\tconst init = declarations.get(node.name)\n\t\t\tconst value = init ? evaluate(init, new Set(active).add(node.name)) : null\n\t\t\treturn members.has(node.name)\n\t\t\t\t? value === 'foundation' && members.get(node.name) === 'Query'\n\t\t\t\t\t? 'queryRegistry'\n\t\t\t\t\t: null\n\t\t\t\t: value\n\t\t}\n\t\tif (node.type === 'MemberExpression' && !node.computed && node.property.type === 'Identifier')\n\t\t\treturn evaluate(node.object, active) === 'foundation' && node.property.name === 'Query'\n\t\t\t\t? 'queryRegistry'\n\t\t\t\t: null\n\t\tif (node.type !== 'CallExpression' && node.type !== 'NewExpression') return null\n\t\tconst factory = factoryImport(node.callee)\n\t\tif (factory && foundationFactory(factory)) return 'foundation'\n\t\tif (\n\t\t\tfactory &&\n\t\t\t['cvx-kit', 'cvx-kit/zod-table', 'cvx-kit/tenancy'].includes(factory.source) &&\n\t\t\t['zodTable', 'tenantTable', 'zodVariantTable'].includes(factory.name)\n\t\t)\n\t\t\treturn 'table'\n\t\tif (\n\t\t\tfactory &&\n\t\t\t['cvx-kit', 'cvx-kit/querying'].includes(factory.source) &&\n\t\t\tfactory.name === 'createQueryEngine'\n\t\t)\n\t\t\treturn 'engine'\n\t\treturn null\n\t}\n\tconst declaration = declarations.get(local)\n\tconst value = declaration ? evaluate(declaration) : null\n\treturn members.has(local)\n\t\t? value === 'foundation' && members.get(local) === 'Query'\n\t\t\t? 'queryRegistry'\n\t\t\t: null\n\t\t: value\n}\n\nfunction provenanceCache(context: Context) {\n\tlet cache = provenanceCaches.get(context)\n\tif (!cache) {\n\t\tcache = { nodes: new Map(), files: new Map(), imports: new Map(), resolver: createResolver() }\n\t\tprovenanceCaches.set(context, cache)\n\t}\n\treturn cache\n}\n\nfunction* evaluateReadProvenance(\n\tcontext: Context,\n\tnode: ESTree.Node,\n): Generator<ESTree.Node, ReadProvenance | null, ReadProvenance | null> {\n\tif (node.type === 'AwaitExpression') return yield node.argument\n\tif (\n\t\tnode.type === 'TSAsExpression' ||\n\t\tnode.type === 'TSSatisfiesExpression' ||\n\t\tnode.type === 'TSNonNullExpression'\n\t)\n\t\treturn yield node.expression\n\tif (node.type === 'Identifier') {\n\t\tconst variable = binding(context, node)\n\t\tif (variable?.references.some((reference) => reference.isWrite() && !reference.init))\n\t\t\treturn null\n\t\tconst initializer = localInitializer(context, node)\n\t\tif (initializer) return yield initializer\n\t\tconst member = localDestructured(context, node)\n\t\tif (member) {\n\t\t\tconst owner = yield member.expression\n\t\t\tif (owner === 'context' && member.name === 'db') return 'db'\n\t\t\tif (owner === 'page' && member.name === 'page') return 'bounded'\n\t\t\tif (owner === 'table' && member.name === 'publicDto') return 'dtoSchema'\n\t\t\tif (owner === 'foundation' && member.name === 'Query') return 'queryRegistry'\n\t\t}\n\t\tconst def = binding(context, node)?.defs[0]\n\t\tif (\n\t\t\tdef?.type === 'Parameter' &&\n\t\t\t(def.node.type === 'ArrowFunctionExpression' || def.node.type === 'FunctionExpression')\n\t\t) {\n\t\t\tconst callbackCall = def.node.parent\n\t\t\tif (\n\t\t\t\tcallbackCall?.type === 'CallExpression' &&\n\t\t\t\tcallbackCall.arguments[0] === def.node &&\n\t\t\t\tdef.node.params[0] === def.name &&\n\t\t\t\t(callbackCall.callee.type === 'Identifier' ||\n\t\t\t\t\tcallbackCall.callee.type === 'MemberExpression')\n\t\t\t) {\n\t\t\t\tconst ref = imported(context, callbackCall.callee)\n\t\t\t\tif (ref && nativeReadBuilder(ref)) return 'context'\n\t\t\t}\n\t\t\tif (\n\t\t\t\tcallbackCall?.type === 'CallExpression' &&\n\t\t\t\tcallbackCall.callee.type === 'MemberExpression'\n\t\t\t) {\n\t\t\t\tconst owner = yield callbackCall.callee.object\n\t\t\t\tconst method = propertyName(callbackCall.callee)\n\t\t\t\tif (\n\t\t\t\t\tmethod === 'handler' &&\n\t\t\t\t\towner === 'queryOperation' &&\n\t\t\t\t\tcallbackCall.arguments[0] === def.node &&\n\t\t\t\t\tdef.node.params[1] === def.name\n\t\t\t\t)\n\t\t\t\t\treturn 'context'\n\t\t\t\tif (def.node.params[0] !== def.name) return null\n\t\t\t\tif (\n\t\t\t\t\t(method === 'execute' || method === 'paginate') &&\n\t\t\t\t\tcallbackCall.arguments[1] === def.node &&\n\t\t\t\t\t(owner === 'stream' || owner === 'relationship')\n\t\t\t\t)\n\t\t\t\t\treturn 'bounded'\n\t\t\t\tif (\n\t\t\t\t\tmethod === 'then' &&\n\t\t\t\t\tcallbackCall.arguments[0] === def.node &&\n\t\t\t\t\t(owner === 'bounded' || owner === 'page')\n\t\t\t\t)\n\t\t\t\t\treturn owner\n\t\t\t}\n\t\t\tconst property = def.node.parent\n\t\t\tconst object = property?.type === 'Property' ? property.parent : null\n\t\t\tconst call = object?.type === 'ObjectExpression' ? object.parent : null\n\t\t\tconst ref = call?.type === 'CallExpression' ? imported(context, call.callee) : null\n\t\t\tif (\n\t\t\t\tproperty?.type === 'Property' &&\n\t\t\t\t(property.computed ? staticString(property.key) : exportName(property.key)) ===\n\t\t\t\t\t'operations' &&\n\t\t\t\tcall?.type === 'CallExpression' &&\n\t\t\t\tcall.arguments[0] === object &&\n\t\t\t\t(yield call.callee) === 'queryRegistry' &&\n\t\t\t\tobject?.type === 'ObjectExpression' &&\n\t\t\t\tdef.node.params[0]?.type === 'ObjectPattern' &&\n\t\t\t\tdef.node.params[0].properties.some(\n\t\t\t\t\t(p) =>\n\t\t\t\t\t\tp.type === 'Property' &&\n\t\t\t\t\t\tp.value === def.name &&\n\t\t\t\t\t\t(p.computed ? staticString(p.key) : exportName(p.key)) === 'query',\n\t\t\t\t) &&\n\t\t\t\tregistryPreservesContext(context, object)\n\t\t\t)\n\t\t\t\treturn 'queryOperation'\n\n\t\t\tif (\n\t\t\t\tproperty?.type === 'Property' &&\n\t\t\t\t(property.computed ? staticString(property.key) : exportName(property.key)) === 'handler' &&\n\t\t\t\tcall?.type === 'CallExpression' &&\n\t\t\t\tcall.arguments[0] === object &&\n\t\t\t\tdef.node.params[1] === def.name &&\n\t\t\t\t(yield call.callee) === 'queryOperation'\n\t\t\t)\n\t\t\t\treturn 'context'\n\n\t\t\tif (\n\t\t\t\tproperty?.type === 'Property' &&\n\t\t\t\t(property.computed ? staticString(property.key) : exportName(property.key)) === 'handler' &&\n\t\t\t\tdef.node.params[0] === def.name &&\n\t\t\t\tref &&\n\t\t\t\t((call?.type === 'CallExpression' &&\n\t\t\t\t\tcall.arguments[0] === object &&\n\t\t\t\t\t(call.callee.type === 'Identifier' || call.callee.type === 'MemberExpression') &&\n\t\t\t\t\tnativeReadBuilder(ref)) ||\n\t\t\t\t\t(isFunctionsImport(context, ref.source) &&\n\t\t\t\t\t\t/^(?:auth|role|admin|system)(?:Query|Mutation)$/.test(ref.name)))\n\t\t\t)\n\t\t\t\treturn 'context'\n\t\t}\n\t\tconst ref = imported(context, node)\n\t\tif (\n\t\t\tref &&\n\t\t\t['zod', 'zod/v4', 'convex/values'].includes(ref.source) &&\n\t\t\t['z', 'v', '*', 'default'].includes(ref.name)\n\t\t)\n\t\t\treturn 'validator'\n\t\tif (ref) return importedReadProvenance(context, ref)\n\t\treturn null\n\t}\n\tif (node.type === 'MemberExpression') {\n\t\tconst ref = imported(context, node)\n\t\tif (ref) {\n\t\t\tconst importedValue = importedReadProvenance(context, ref)\n\t\t\tif (importedValue) return importedValue\n\t\t}\n\t\tconst owner = yield node.object\n\t\tconst name = propertyName(node)\n\t\tif (owner === 'context' && name === 'db') return 'db'\n\t\tif (owner === 'foundation' && name === 'Query') return 'queryRegistry'\n\t\tif (owner === 'reader') return 'stream'\n\t\tif (owner === 'page' && name === 'page') return 'bounded'\n\t\tif (owner === 'table' && ['publicDto', 'dto'].includes(name ?? '')) return 'dtoSchema'\n\t\tif (owner === 'validator') return 'validator'\n\t\treturn null\n\t}\n\tif (node.type !== 'CallExpression' && node.type !== 'NewExpression') return null\n\tconst callee = yield node.callee\n\tif (callee === 'engine') return 'reader'\n\tif (callee === 'include' && node.arguments[0] && (yield node.arguments[0]) === 'stream')\n\t\treturn 'stream'\n\tconst ref = imported(context, node.callee)\n\tif (ref && foundationFactory(ref)) return 'foundation'\n\tif (\n\t\tref &&\n\t\t['cvx-kit', 'cvx-kit/zod-table', 'cvx-kit/tenancy'].includes(ref.source) &&\n\t\t['zodTable', 'tenantTable', 'zodVariantTable'].includes(ref.name)\n\t)\n\t\treturn 'table'\n\tif (\n\t\tref &&\n\t\t['cvx-kit', 'cvx-kit/querying'].includes(ref.source) &&\n\t\tref.name === 'createQueryEngine'\n\t)\n\t\treturn 'engine'\n\tif (ref && ['cvx-kit', 'cvx-kit/auth'].includes(ref.source) && ref.name === 'createInclude')\n\t\treturn 'include'\n\tif (\n\t\tref?.source === 'convex-helpers/server/stream' &&\n\t\tref.name === 'stream' &&\n\t\tnode.arguments[0] &&\n\t\t(yield node.arguments[0]) === 'db'\n\t)\n\t\treturn 'db'\n\tif (node.callee.type !== 'MemberExpression') return null\n\tconst owner = yield node.callee.object\n\tconst name = propertyName(node.callee)\n\tif (owner === 'table' && name === 'toPublicDto') return 'dto'\n\tif (owner === 'table' && ['select', 'dto'].includes(name ?? '')) return 'dtoSchema'\n\tif (owner === 'dtoSchema' && ['parse', 'parseAsync'].includes(name ?? '')) return 'dto'\n\tif (owner === 'db' && name === 'query') return 'stream'\n\tif (owner === 'stream' && name === 'relation') return 'relationship'\n\tif (\n\t\towner === 'context' &&\n\t\tname === 'include' &&\n\t\tnode.arguments[0] &&\n\t\t(yield node.arguments[0]) === 'stream'\n\t)\n\t\treturn 'stream'\n\tif (owner === 'stream' || owner === 'relationship') {\n\t\tif (['take', 'execute'].includes(name ?? '')) return 'bounded'\n\t\tif (name === 'paginate') return 'page'\n\t\tif (\n\t\t\t[\n\t\t\t\t'withIndex',\n\t\t\t\t'withSearchIndex',\n\t\t\t\t'filter',\n\t\t\t\t'filterWith',\n\t\t\t\t'map',\n\t\t\t\t'flatMap',\n\t\t\t\t'distinct',\n\t\t\t\t'order',\n\t\t\t\t'matching',\n\t\t\t\t'when',\n\t\t\t\t'otherwise',\n\t\t\t\t'fullTableScan',\n\t\t\t\t'where',\n\t\t\t\t'with',\n\t\t\t].includes(name ?? '')\n\t\t)\n\t\t\treturn owner\n\t}\n\tif (owner === 'bounded' && name === 'map') return 'bounded'\n\tif (owner === 'validator') return 'validator'\n\treturn null\n}\n\n/** Match native registration contracts by both their import source and exported name. */\nfunction nativeReadBuilder(ref: { source: string; name: string }) {\n\treturn (\n\t\t(/_generated\\/server(?:\\.[cm]?[jt]s)?$/.test(ref.source) &&\n\t\t\tnativeReadBuilders.includes(ref.name)) ||\n\t\t(ref.source === 'convex/server' &&\n\t\t\tnativeReadBuilders.some((name) => ref.name === `${name}Generic`))\n\t)\n}\n\nfunction foundationFactory(ref: { source: string; name: string }) {\n\treturn (\n\t\t(ref.source === 'cvx-kit' && ref.name === 'createFoundation') ||\n\t\t(ref.source === 'cvx-kit/effect' && ref.name === 'createEffectFoundation') ||\n\t\t(['cvx-kit', 'cvx-kit/components/foundation'].includes(ref.source) && ref.name === 'Foundation')\n\t)\n}\n\n/** The supported registry mapping passes the host through unchanged. */\nfunction registryPreservesContext(context: Context, object: ESTree.ObjectExpression) {\n\tconst property = object.properties.find(\n\t\t(p) =>\n\t\t\tp.type === 'Property' && (p.computed ? staticString(p.key) : exportName(p.key)) === 'context',\n\t)\n\tif (property?.type !== 'Property') return false\n\tconst callback = property.value\n\tif (callback.type !== 'ArrowFunctionExpression' && callback.type !== 'FunctionExpression')\n\t\treturn false\n\tconst host = callback.params[0]\n\tif (\n\t\thost?.type !== 'Identifier' ||\n\t\tbinding(context, host)?.references.some((r) => r.isWrite() && !r.init)\n\t)\n\t\treturn false\n\tconst body = callback.body\n\tconst returned =\n\t\tbody?.type === 'BlockStatement' &&\n\t\tbody.body.length === 1 &&\n\t\tbody.body[0].type === 'ReturnStatement'\n\t\t\t? body.body[0].argument\n\t\t\t: body\n\treturn returned?.type === 'Identifier' && binding(context, returned) === binding(context, host)\n}\n\nfunction physicalString(node: Node): string | null {\n\tif (node.type === 'Literal' && String(node.value) === node.value) return String(node.value)\n\tif (node.type === 'TemplateLiteral' && node.expressions.length === 0)\n\t\treturn node.quasis[0].value.cooked\n\treturn null\n}\n"],"mappings":"2WAQA,MAAaA,EAAkBC,EAAE,OAAO,CACvC,UAAWA,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,QAAQ,EAC7C,cAAeA,EAAE,MAAMA,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EACpD,kBAAmBA,EAAE,OAAOA,EAAE,OAAO,EAAGA,EAAE,MAAMA,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAC/E,CAAC,EAED,SAAgBC,EAAQ,EAAkB,EAAWC,EAAQ,SAAU,CACtE,IAAMC,EAAgBC,EACrBF,EAAQ,IACRH,EAAgB,MAAMG,EAAQ,QAAQ,IAAM,CAAC,CAAC,CAAC,CAAC,SACjD,EACMG,EAAOC,EAAWH,CAAa,EAAII,EAAaJ,CAAa,EAAIA,EACjEK,EAAOC,EAASJ,EAAMC,EAAWI,CAAQ,EAAIH,EAAaG,CAAQ,EAAIA,CAAQ,CAAC,CACnF,MAAMC,CAAG,CAAC,CACV,KAAK,GAAG,EACV,OAAOH,IAAS,MAAQA,EAAK,WAAW,KAAK,GAAKA,EAAK,WAAW,GAAG,EAAI,KAAOA,CACjF,CAEA,SAAgBI,EACf,EACA,EACA,kBAAS,IAAI,IAC6B,CAC1C,GAAIC,EAAO,IAAIC,CAAI,GAAKD,EAAO,KAAO,GAAI,OAAO,KAEjD,GADA,EAAS,IAAI,IAAIA,CAAM,CAAC,CAAC,IAAIC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,OACtB,IACR"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
//#region src/oxlint/components.d.ts
|
|
2
|
+
/** Locate standalone components as well as the conventional components/<name> layout. */
|
|
3
|
+
export declare function findComponentRoot(filename: string, roots?: readonly string[]): string | null;
|
|
4
|
+
export declare function conventionalComponentRoot(filename: string, root: string): string | null;
|
|
5
|
+
//#endregion
|
|
6
|
+
//# sourceMappingURL=components.d.mts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{dirname as e,relative as t,resolve as n,sep as r}from"node:path";import{existsSync as i,readFileSync as a}from"node:fs";import{parseSync as o}from"oxc-parser";function s(t,r=[]){let i=n(t);for(let t=e(i);;t=e(t)){if(r.includes(t)||l(t))return t;if(e(t)===t)return null}}function c(e,i){let a=t(i,e).split(r).join(`/`).match(/^components\/([^/]+)(?:\/|$)/);return a?n(i,`components`,a[1]):null}function l(e){let t=n(e,`convex.config.ts`);if(!i(t))return!1;let{program:r,errors:s}=o(t,a(t,`utf8`));if(s.length)return!1;let c=/* @__PURE__ */ new Set,l=/* @__PURE__ */ new Set;for(let e of r.body)if(e.type===`ImportDeclaration`&&e.source.value===`convex/server`)for(let t of e.specifiers)t.type===`ImportNamespaceSpecifier`&&l.add(t.local.name),t.type===`ImportSpecifier`&&(t.imported.type===`Identifier`?t.imported.name:t.imported.value)===`defineComponent`&&c.add(t.local.name);for(let e of r.body){let t=e.type===`ExportNamedDeclaration`?e.declaration:e,n=t?.type===`VariableDeclaration`?t.declarations.map(e=>e.init):e.type===`ExportDefaultDeclaration`?[e.declaration]:[];for(let e of n){if(e?.type!==`CallExpression`)continue;let t=e.callee;if(t.type===`Identifier`&&c.has(t.name)||t.type===`MemberExpression`&&!t.computed&&t.property.type===`Identifier`&&t.property.name===`defineComponent`&&t.object.type===`Identifier`&&l.has(t.object.name))return!0}}return!1}export{c as conventionalComponentRoot,s as findComponentRoot};
|
|
2
|
+
//# sourceMappingURL=components.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.mjs","names":["findComponentRoot","file","resolve","filename","directory","dirname","roots","definesComponent","conventionalComponentRoot","match","relative","root","sep","config","existsSync","parseSync","readFileSync","errors","names","namespaces","statement","program","specifier","declaration","expressions","item","expression","callee"],"sources":["../../src/oxlint/components.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs'\nimport { dirname, resolve, relative, sep } from 'node:path'\nimport { parseSync } from 'oxc-parser'\n\n/** Locate standalone components as well as the conventional components/<name> layout. */\nexport function findComponentRoot(filename: string, roots: readonly string[] = []) {\n\tconst file = resolve(filename)\n\tfor (let directory = dirname(file); ; directory = dirname(directory)) {\n\t\tif (roots.includes(directory) || definesComponent(directory)) return directory\n\t\tif (dirname(directory) === directory) return null\n\t}\n}\n\nexport function conventionalComponentRoot(filename: string, root: string) {\n\tconst match = relative(root, filename)\n\t\t.split(sep)\n\t\t.join('/')\n\t\t.match(/^components\\/([^/]+)(?:\\/|$)/)\n\treturn match ? resolve(root, 'components', match[1]) : null\n}\n\nfunction definesComponent(directory: string) {\n\tconst config = resolve(directory, 'convex.config.ts')\n\tif (!existsSync(config)) return false\n\tconst { program, errors } = parseSync(config, readFileSync(config, 'utf8'))\n\tif (errors.length) return false\n\tconst names = new Set<string>()\n\tconst namespaces = new Set<string>()\n\tfor (const statement of program.body) {\n\t\tif (statement.type !== 'ImportDeclaration' || statement.source.value !== 'convex/server')\n\t\t\tcontinue\n\t\tfor (const specifier of statement.specifiers) {\n\t\t\tif (specifier.type === 'ImportNamespaceSpecifier') namespaces.add(specifier.local.name)\n\t\t\tif (\n\t\t\t\tspecifier.type === 'ImportSpecifier' &&\n\t\t\t\t(specifier.imported.type === 'Identifier'\n\t\t\t\t\t? specifier.imported.name\n\t\t\t\t\t: specifier.imported.value) === 'defineComponent'\n\t\t\t)\n\t\t\t\tnames.add(specifier.local.name)\n\t\t}\n\t}\n\tfor (const statement of program.body) {\n\t\tconst declaration =\n\t\t\tstatement.type === 'ExportNamedDeclaration' ? statement.declaration : statement\n\t\tconst expressions =\n\t\t\tdeclaration?.type === 'VariableDeclaration'\n\t\t\t\t? declaration.declarations.map((item) => item.init)\n\t\t\t\t: statement.type === 'ExportDefaultDeclaration'\n\t\t\t\t\t? [statement.declaration]\n\t\t\t\t\t: []\n\t\tfor (const expression of expressions) {\n\t\t\tif (expression?.type !== 'CallExpression') continue\n\t\t\tconst callee = expression.callee\n\t\t\tif (callee.type === 'Identifier' && names.has(callee.name)) return true\n\t\t\tif (\n\t\t\t\tcallee.type === 'MemberExpression' &&\n\t\t\t\t!callee.computed &&\n\t\t\t\tcallee.property.type === 'Identifier' &&\n\t\t\t\tcallee.property.name === 'defineComponent' &&\n\t\t\t\tcallee.object.type === 'Identifier' &&\n\t\t\t\tnamespaces.has(callee.object.name)\n\t\t\t)\n\t\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n"],"mappings":"sKAKA,SAAgBA,EAAkB,EAAkB,EAA2B,CAAC,EAAG,CAClF,IAAMC,EAAOC,EAAQC,CAAQ,EAC7B,IAAK,IAAIC,EAAYC,EAAQJ,CAAI,GAAK,EAAYI,EAAQD,CAAS,EAAG,CACrE,GAAIE,EAAM,SAASF,CAAS,GAAKG,EAAiBH,CAAS,EAAG,OAAOA,EACrE,GAAIC,EAAQD,CAAS,IAAMA,EAAW,OAAO,IAC9C,CACD,CAEA,SAAgBI,EAA0B,EAAkB,EAAc,CACzE,IAAMC,EAAQC,EAASC,EAAMR,CAAQ,CAAC,CACpC,MAAMS,CAAG,CAAC,CACV,KAAK,GAAG,CAAC,CACT,MAAM,8BAA8B,EACtC,OAAOH,EAAQP,EAAQS,EAAM,aAAcF,EAAM,EAAE,EAAI,IACxD,CAEA,SAASF,EAAiB,EAAmB,CAC5C,IAAMM,EAASX,EAAQE,EAAW,kBAAkB,EACpD,GAAI,CAACU,EAAWD,CAAM,EAAG,MAAO,GAChC,GAAM,CAAE,UAAS,UAAWE,EAAUF,EAAQG,EAAaH,EAAQ,MAA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