{"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,CAA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