cvx-kit 0.1.26 → 0.1.28
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/index.d.mts +2 -2
- package/dist/index.mjs +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/querying/schema-snapshot.d.mts +2 -0
- package/dist/querying/schema-snapshot.mjs +1 -1
- package/dist/querying/schema-snapshot.mjs.map +1 -1
- package/dist/querying/shared/page.d.mts +23 -0
- package/dist/querying/shared/page.mjs +2 -0
- package/dist/querying/shared/page.mjs.map +1 -0
- 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-table.d.mts +2 -5
- package/dist/zod-table.mjs +1 -1
- package/dist/zod-table.mjs.map +1 -1
- package/package.json +1 -1
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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CAAI,CAAC,EAAE,WAAW,KAAM,GAAMC,EAAE,QAAQ,GAAK,CAACA,EAAE,IAAI,EAErE,MAAO,GACR,IAAMC,EAAOH,EAAS,KAChBI,EACLD,GAAM,OAAS,kBACfA,EAAK,KAAK,SAAW,GACrBA,EAAK,KAAK,EAAE,CAAC,OAAS,kBACnBA,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,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AEA,SAASnB,EAAe,EAA2B,CAIlD,OAHIvE,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"}
|
|
@@ -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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spectArchitecture as n,resolveImport as r}from"./architecture.mjs";import{appFile as i,binding as a,componentRoot as o,consumerOptions as s,containsComponentReference as c,delegatingBody as l,exportedNames as u,imported as d,isDbAccess as f,isDbWrite as p,isExternalCall as m,isFunctionsImport as h,memberPath as g,metadata as _,propertyName as v,rootMember as y,sourceVisitors as b,typeOnlySource as x}from"./ast.mjs";import{basename as S,resolve as C}from"node:path";import{existsSync as w,realpathSync as T}from"node:fs";const E={"project-structure":{meta:_(`Validate the application tree, colocated tests, and module cycles.`,{structure:`{{file}}: {{message}}`}),create(t){let r=s.parse(t.options[0]??{}),i=C(t.cwd,r.convexDir);return(w(t.filename)?T(t.filename):C(t.filename))===e(i)?{Program(e){for(let i of n({cwd:t.cwd,convexDir:r.convexDir}))t.report({node:e,messageId:`structure`,data:{file:i.file,message:i.message}})}}:{}}},"root-wiring-only":{meta:_(`Keep root files limited to configuration, assembly, and component facades.`,{ownership:`Root files only wire configuration and components. Move behavior into domain/<module>/: {{reason}}.`}),create(e){let t=i(e);if(!t||t.includes(`/`))return{};let n=null,r=`business implementation`,a=!1,o=/^(?:convex\.config|auth\.config|vite\.config|vitest\.config|auth|schema|functions|triggers|foundation|http|crons)\.[cm]?[jt]s$/.test(t);function s(e){n??=e}return{Program(e){e.body.some(e=>e.type===`FunctionDeclaration`||e.type===`ExportNamedDeclaration`&&e.declaration?.type===`FunctionDeclaration`)&&s(e)},NewExpression(t){d(e,t.callee)&&t.arguments.some(t=>c(e,t))&&(a=!0)},CallExpression(n){d(e,n.callee)&&n.arguments.some(t=>c(e,t))&&(a=!0),(p(n)||m(e,n)||t===`schema.ts`&&d(e,n.callee)?.name!==`defineSchema`)&&s(n)},ArrowFunctionExpression(e){(!e.body||!l(e.body))&&s(e)},FunctionExpression(e){(!e.body||!l(e.body))&&s(e)},IfStatement:s,SwitchStatement:s,ConditionalExpression:s,ForStatement:s,ForOfStatement:s,WhileStatement:s,"Program:exit"(t){!o&&!a&&(n=t,r=`unknown root file; only declared component facades may add root source files`),n&&e.report({node:n,messageId:`ownership`,data:{reason:r}})}}}},"application-orchestration":{meta:_(`Reserve application/ for thin cross-domain coordination.`,{ownership:`application/ only coordinates two or more domains. Move schemas, providers, storage access, helpers, and business decisions into their owning domain.`}),create(e){if(!i(e)?.startsWith(`application/`))return{};let n=/* @__PURE__ */ new Set,a=t(),
|
|
1
|
+
import{architectureAnchor as e,createResolver as t,inspectArchitecture as n,resolveImport as r}from"./architecture.mjs";import{appFile as i,binding as a,componentRoot as o,consumerOptions as s,containsComponentReference as c,delegatingBody as l,exportedNames as u,imported as d,isDbAccess as f,isDbWrite as p,isExternalCall as m,isFunctionsImport as h,memberPath as g,metadata as _,propertyName as v,rootMember as y,sourceVisitors as b,typeOnlySource as x}from"./ast.mjs";import{basename as S,resolve as C}from"node:path";import{existsSync as w,realpathSync as T}from"node:fs";const E={"project-structure":{meta:_(`Validate the application tree, colocated tests, and module cycles.`,{structure:`{{file}}: {{message}}`}),create(t){let r=s.parse(t.options[0]??{}),i=C(t.cwd,r.convexDir);return(w(t.filename)?T(t.filename):C(t.filename))===e(i)?{Program(e){for(let i of n({cwd:t.cwd,convexDir:r.convexDir,componentDirs:r.componentDirs}))t.report({node:e,messageId:`structure`,data:{file:i.file,message:i.message}})}}:{}}},"root-wiring-only":{meta:_(`Keep root files limited to configuration, assembly, and component facades.`,{ownership:`Root files only wire configuration and components. Move behavior into domain/<module>/: {{reason}}.`}),create(e){let t=i(e);if(!t||t.includes(`/`))return{};let n=null,r=`business implementation`,a=!1,o=/^(?:convex\.config|auth\.config|vite\.config|vitest\.config|auth|schema|functions|triggers|foundation|http|crons)\.[cm]?[jt]s$/.test(t);function s(e){n??=e}return{Program(e){e.body.some(e=>e.type===`FunctionDeclaration`||e.type===`ExportNamedDeclaration`&&e.declaration?.type===`FunctionDeclaration`)&&s(e)},NewExpression(t){d(e,t.callee)&&t.arguments.some(t=>c(e,t))&&(a=!0)},CallExpression(n){d(e,n.callee)&&n.arguments.some(t=>c(e,t))&&(a=!0),(p(n)||m(e,n)||t===`schema.ts`&&d(e,n.callee)?.name!==`defineSchema`)&&s(n)},ArrowFunctionExpression(e){(!e.body||!l(e.body))&&s(e)},FunctionExpression(e){(!e.body||!l(e.body))&&s(e)},IfStatement:s,SwitchStatement:s,ConditionalExpression:s,ForStatement:s,ForOfStatement:s,WhileStatement:s,"Program:exit"(t){!o&&!a&&(n=t,r=`unknown root file; only declared component facades may add root source files`),n&&e.report({node:n,messageId:`ownership`,data:{reason:r}})}}}},"application-orchestration":{meta:_(`Reserve application/ for thin cross-domain coordination.`,{ownership:`application/ only coordinates two or more domains. Move schemas, providers, storage access, helpers, and business decisions into their owning domain.`}),create(e){if(!i(e)?.startsWith(`application/`))return{};let n=/* @__PURE__ */ new Set,a=t(),s=null;function c(e){s??=e}let l=b(e,(t,s)=>{if(x(t))return;let l=r(a,e.filename,s),u=l&&i(e,l),d=u?.match(/^domain\/([^/]+)\/(?:commands|queries|rules)(?:\.[cm]?[jt]s)?$/);d&&d[1]!==`shared`&&n.add(d[1]),u?.startsWith(`domain/`)&&!d&&!u.startsWith(`domain/shared/`)&&c(t),!u&&!o(e,e.filename)&&![`cvx-kit`,`cvx-kit/components/foundation`,`@convex-dev/workflow`,`convex/values`].includes(s)&&c(t)});return{...l,Program(e){let t=u(e);for(let n of e.body){n.type===`FunctionDeclaration`&&n.id&&!t.has(n.id.name)&&c(n);let e=n.type===`ExportNamedDeclaration`?n.declaration:n;if((e?.type===`TSTypeAliasDeclaration`||e?.type===`TSInterfaceDeclaration`)&&c(n),e?.type===`VariableDeclaration`)for(let r of e.declarations)r.init&&[`ObjectExpression`,`ArrayExpression`,`Literal`].includes(r.init.type)&&c(r),n.type===`VariableDeclaration`&&r.id.type===`Identifier`&&!t.has(r.id.name)&&[`ArrowFunctionExpression`,`FunctionExpression`].includes(r.init?.type??``)&&c(r)}},CallExpression(t){l.CallExpression?.(t),(f(t)||m(e,t))&&c(t);let n=d(e,t.callee);n&&[`zod`,`zod/v4`].includes(n.source)&&c(t)},MemberExpression(t){let r=g(t);if(r.length>=4&&r[1]===`domain`){let i=d(e,y(t));i?.name===`internal`&&/_generated\/api/.test(i.source)&&n.add(r[2])}},NewExpression:c,IfStatement:c,SwitchStatement:c,ConditionalExpression:c,"Program:exit"(t){(n.size<2||s)&&e.report({node:s??t,messageId:`ownership`})}}}},"internal-function-ownership":{meta:_(`Place internal handlers with their owner, never in root, api/, or shared/.`,{ownership:`Declare system/internal handlers in domain/<module>/, cross-domain application/, migrations/, or an isolated component.`}),create(e){let t=i(e)??``;return o(e,e.filename)||/^(?:domain\/(?!shared\/)[^/]+\/|application\/|migrations\/)/.test(t)?{}:{CallExpression(t){if(t.callee.type===`CallExpression`)return;let n=d(e,t.callee);n&&(h(e,n.source)&&/^system(Query|Mutation|Action)$/.test(n.name)||/(?:_generated\/server|convex\/server)/.test(n.source)&&/^internal(Query|Mutation|Action)(Generic)?$/.test(n.name))&&e.report({node:t,messageId:`ownership`})}}}},"domain-file-responsibilities":{meta:_(`Keep invariants pure, reads read-only, shapes declarative, and I/O action-side.`,{ownership:`Respect this domain file responsibility: pure rules, read-only queries, declarative schemas/tables/constants, and external I/O only in actions or integrations.`}),create(e){let n=i(e)??``,s=n===`domain/table.ts`;if(!s&&!/^domain\/[^/]+\//.test(n)&&!o(e,e.filename))return{};let c=S(n).replace(/\.[cm]?[jt]s$/,``),l=c===`rules`,u=c===`queries`,g=[`schema`,`table`,`contracts`,`constants`].includes(c),_=/(?:^|\/)(?:actions|integrations|providers)(?:\/|\.)/.test(n)||/(?:^|_)actions\./.test(n),y=t(),C=null;function w(e){C??=e}let T=b(e,(t,n)=>{if(x(t))return;let a=r(y,e.filename,n),c=a&&i(e,a);s&&n!==`cvx-kit/zod-table`&&!/^domain\/[^/]+\/table(?:\.[cm]?[jt]s)?$/.test(c??``)&&w(t),l&&c&&!/(?:^|\/)(?:rules|constants)(?:\.[cm]?[jt]s)?$/.test(c)&&w(t),(l||u||g)&&!c&&!o(e,e.filename)&&![`zod`,`zod/v4`,`convex/values`,`cvx-kit`,`cvx-kit/zod-table`,`cvx-kit/errors`,`cvx-kit/contracts`].includes(n)&&w(t),u&&c&&/(?:^|\/)(?:commands|actions|integrations|providers)(?:[./]|$)/.test(c)&&w(t)});return{...T,Program(e){if(s)for(let t of e.body){if(t.type===`ImportDeclaration`||t.type===`EmptyStatement`)continue;let e=t.type===`ExportNamedDeclaration`?t.declaration:t;(e?.type!==`VariableDeclaration`||e.declarations.some(e=>e.init?.type!==`CallExpression`))&&w(t)}},CallExpression(t){if(T.CallExpression?.(t),s){let n=d(e,t.callee);(n?.source!==`cvx-kit/zod-table`||n.name!==`createModule`)&&w(t)}let n=t.callee.type===`MemberExpression`?v(t.callee):null;(l||g)&&(f(t)||[`runQuery`,`runMutation`,`runAction`,`runAfter`,`runAt`].includes(n??``))&&w(t),u&&(p(t)||[`runMutation`,`runAction`,`runAfter`,`runAt`].includes(n??``))&&w(t);let r=d(e,t.callee);r&&h(e,r.source)&&(l||g||u&&/(?:Mutation|Action)$/.test(r.name))&&w(t),u&&t.callee.type===`MemberExpression`&&v(t.callee.object)===`storage`&&[`store`,`delete`,`generateUploadUrl`].includes(n??``)&&w(t),!_&&m(e,t)&&w(t),l&&t.callee.type===`MemberExpression`&&t.callee.object.type===`Identifier`&&!a(e,t.callee.object)?.defs.length&&(t.callee.object.name===`Date`&&n===`now`||t.callee.object.name===`Math`&&n===`random`)&&w(t)},Property(e){c===`contracts`&&[`handler`,`context`,`audit`,`prepare`,`middleware`,`guard`].includes(e.key.type===`Identifier`?e.key.name:String(e.key.type===`Literal`?e.key.value:``))&&w(e)},MemberExpression(e){l&&[`db`,`storage`,`scheduler`,`env`].includes(v(e)??``)&&w(e)},NewExpression(t){(l||u||g)&&(t.callee.type!==`Identifier`||a(e,t.callee)?.defs.length||![`Error`,`TypeError`,`RangeError`,`Set`,`Map`,`RegExp`].includes(t.callee.name))&&w(t)},"Program:exit"(){C&&e.report({node:C,messageId:`ownership`})}}}}};export{E as ownershipRules};
|
|
2
2
|
//# sourceMappingURL=ownership.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ownership.mjs","names":["ownershipRules","metadata","settings","consumerOptions","context","root","resolve","existsSync","realpathSync","architectureAnchor","issue","inspectArchitecture","file","appFile","reason","componentFacade","standard","flag","node","statement","imported","containsComponentReference","argument","isDbWrite","isExternalCall","delegatingBody","owners","resolver","createResolver","sources","sourceVisitors","typeOnlySource","target","resolveImport","source","path","match","publicNames","exportedNames","declaration","item","isDbAccess","ref","memberPath","rootMember","componentRoot","isFunctionsImport","assembly","role","basename","pure","read","declarative","actionSide","method","propertyName","constructor","binding"],"sources":["../../src/oxlint/ownership.ts"],"sourcesContent":["import { existsSync, realpathSync } from 'node:fs'\nimport { basename, resolve } from 'node:path'\nimport type { CreateRule, ESTree } from '@oxlint/plugins'\nimport {\n\tarchitectureAnchor,\n\tinspectArchitecture,\n\tcreateResolver,\n\tresolveImport,\n} from './architecture'\nimport {\n\tconsumerOptions,\n\tappFile,\n\timported,\n\tsourceVisitors,\n\tisFunctionsImport,\n\ttypeOnlySource,\n\tisDbAccess,\n\tisExternalCall,\n\tcontainsComponentReference,\n\trootMember,\n\tmemberPath,\n\tisDbWrite,\n\tmetadata,\n\tcomponentRoot,\n\tpropertyName,\n\tbinding,\n\texportedNames,\n\tdelegatingBody,\n} from './ast'\n\nexport const ownershipRules = {\n\t'project-structure': {\n\t\tmeta: metadata('Validate the application tree, colocated tests, and module cycles.', {\n\t\t\tstructure: '{{file}}: {{message}}',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tconst settings = consumerOptions.parse(context.options[0] ?? {})\n\t\t\tconst root = resolve(context.cwd, settings.convexDir)\n\t\t\tif (\n\t\t\t\t(existsSync(context.filename)\n\t\t\t\t\t? realpathSync(context.filename)\n\t\t\t\t\t: resolve(context.filename)) !== architectureAnchor(root)\n\t\t\t)\n\t\t\t\treturn {}\n\t\t\treturn {\n\t\t\t\tProgram(node) {\n\t\t\t\t\tfor (const issue of inspectArchitecture({\n\t\t\t\t\t\tcwd: context.cwd,\n\t\t\t\t\t\tconvexDir: settings.convexDir,\n\t\t\t\t\t}))\n\t\t\t\t\t\tcontext.report({\n\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\tmessageId: 'structure',\n\t\t\t\t\t\t\tdata: { file: issue.file, message: issue.message },\n\t\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'root-wiring-only': {\n\t\tmeta: metadata('Keep root files limited to configuration, assembly, and component facades.', {\n\t\t\townership:\n\t\t\t\t'Root files only wire configuration and components. Move behavior into domain/<module>/: {{reason}}.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tconst file = appFile(context)\n\t\t\tif (!file || file.includes('/')) return {}\n\t\t\tlet issue: ESTree.Node | null = null\n\t\t\tlet reason = 'business implementation'\n\t\t\tlet componentFacade = false\n\t\t\tconst standard =\n\t\t\t\t/^(?:convex\\.config|auth\\.config|vite\\.config|vitest\\.config|auth|schema|functions|triggers|foundation|http|crons)\\.[cm]?[jt]s$/.test(\n\t\t\t\t\tfile,\n\t\t\t\t)\n\t\t\tfunction flag(node: ESTree.Node) {\n\t\t\t\tissue ??= node\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tProgram(node) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.body.some(\n\t\t\t\t\t\t\t(statement) =>\n\t\t\t\t\t\t\t\tstatement.type === 'FunctionDeclaration' ||\n\t\t\t\t\t\t\t\t(statement.type === 'ExportNamedDeclaration' &&\n\t\t\t\t\t\t\t\t\tstatement.declaration?.type === 'FunctionDeclaration'),\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t},\n\t\t\t\tNewExpression(node) {\n\t\t\t\t\tif (\n\t\t\t\t\t\timported(context, node.callee) &&\n\t\t\t\t\t\tnode.arguments.some((argument) => containsComponentReference(context, argument))\n\t\t\t\t\t)\n\t\t\t\t\t\tcomponentFacade = true\n\t\t\t\t},\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tif (\n\t\t\t\t\t\timported(context, node.callee) &&\n\t\t\t\t\t\tnode.arguments.some((argument) => containsComponentReference(context, argument))\n\t\t\t\t\t)\n\t\t\t\t\t\tcomponentFacade = true\n\t\t\t\t\tif (\n\t\t\t\t\t\tisDbWrite(node) ||\n\t\t\t\t\t\tisExternalCall(context, node) ||\n\t\t\t\t\t\t(file === 'schema.ts' && !(imported(context, node.callee)?.name === 'defineSchema'))\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t},\n\t\t\t\tArrowFunctionExpression(node) {\n\t\t\t\t\tif (!node.body || !delegatingBody(node.body)) flag(node)\n\t\t\t\t},\n\t\t\t\tFunctionExpression(node) {\n\t\t\t\t\tif (!node.body || !delegatingBody(node.body)) flag(node)\n\t\t\t\t},\n\t\t\t\tIfStatement: flag,\n\t\t\t\tSwitchStatement: flag,\n\t\t\t\tConditionalExpression: flag,\n\t\t\t\tForStatement: flag,\n\t\t\t\tForOfStatement: flag,\n\t\t\t\tWhileStatement: flag,\n\t\t\t\t'Program:exit'(node) {\n\t\t\t\t\tif (!standard && !componentFacade) {\n\t\t\t\t\t\tissue = node\n\t\t\t\t\t\treason = 'unknown root file; only declared component facades may add root source files'\n\t\t\t\t\t}\n\t\t\t\t\tif (issue) context.report({ node: issue, messageId: 'ownership', data: { reason } })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'application-orchestration': {\n\t\tmeta: metadata('Reserve application/ for thin cross-domain coordination.', {\n\t\t\townership:\n\t\t\t\t'application/ only coordinates two or more domains. Move schemas, providers, storage access, helpers, and business decisions into their owning domain.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tif (!appFile(context)?.startsWith('application/')) return {}\n\t\t\tconst owners = new Set<string>()\n\t\t\tconst resolver = createResolver()\n\t\t\tlet issue: ESTree.Node | null = null\n\t\t\tfunction flag(node: ESTree.Node) {\n\t\t\t\tissue ??= node\n\t\t\t}\n\t\t\tconst sources = sourceVisitors(context, (node, source) => {\n\t\t\t\tif (typeOnlySource(node)) return\n\t\t\t\tconst target = resolveImport(resolver, context.filename, source)\n\t\t\t\tconst path = target && appFile(context, target)\n\t\t\t\tconst match = path?.match(/^domain\\/([^/]+)\\/(?:commands|queries|rules)(?:\\.[cm]?[jt]s)?$/)\n\t\t\t\tif (match && match[1] !== 'shared') owners.add(match[1])\n\t\t\t\tif (path?.startsWith('domain/') && !match && !path.startsWith('domain/shared/')) flag(node)\n\t\t\t\tif (\n\t\t\t\t\t!path &&\n\t\t\t\t\t![\n\t\t\t\t\t\t'cvx-kit',\n\t\t\t\t\t\t'cvx-kit/components/foundation',\n\t\t\t\t\t\t'@convex-dev/workflow',\n\t\t\t\t\t\t'convex/values',\n\t\t\t\t\t].includes(source)\n\t\t\t\t)\n\t\t\t\t\tflag(node)\n\t\t\t})\n\t\t\treturn {\n\t\t\t\t...sources,\n\t\t\t\tProgram(node) {\n\t\t\t\t\tconst publicNames = exportedNames(node)\n\t\t\t\t\tfor (const statement of node.body) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tstatement.type === 'FunctionDeclaration' &&\n\t\t\t\t\t\t\tstatement.id &&\n\t\t\t\t\t\t\t!publicNames.has(statement.id.name)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tflag(statement)\n\t\t\t\t\t\tconst declaration =\n\t\t\t\t\t\t\tstatement.type === 'ExportNamedDeclaration' ? statement.declaration : statement\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tdeclaration?.type === 'TSTypeAliasDeclaration' ||\n\t\t\t\t\t\t\tdeclaration?.type === 'TSInterfaceDeclaration'\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tflag(statement)\n\t\t\t\t\t\tif (declaration?.type === 'VariableDeclaration')\n\t\t\t\t\t\t\tfor (const item of declaration.declarations) {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\titem.init &&\n\t\t\t\t\t\t\t\t\t['ObjectExpression', 'ArrayExpression', 'Literal'].includes(item.init.type)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tflag(item)\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tstatement.type === 'VariableDeclaration' &&\n\t\t\t\t\t\t\t\t\titem.id.type === 'Identifier' &&\n\t\t\t\t\t\t\t\t\t!publicNames.has(item.id.name) &&\n\t\t\t\t\t\t\t\t\t['ArrowFunctionExpression', 'FunctionExpression'].includes(item.init?.type ?? '')\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tflag(item)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tsources.CallExpression?.(node)\n\t\t\t\t\tif (isDbAccess(node) || isExternalCall(context, node)) flag(node)\n\t\t\t\t\tconst ref = imported(context, node.callee)\n\t\t\t\t\tif (ref && ['zod', 'zod/v4'].includes(ref.source)) flag(node)\n\t\t\t\t},\n\t\t\t\tMemberExpression(node) {\n\t\t\t\t\tconst path = memberPath(node)\n\t\t\t\t\tif (path.length >= 4 && path[1] === 'domain') {\n\t\t\t\t\t\tconst ref = imported(context, rootMember(node))\n\t\t\t\t\t\tif (ref?.name === 'internal' && /_generated\\/api/.test(ref.source)) owners.add(path[2])\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tNewExpression: flag,\n\t\t\t\tIfStatement: flag,\n\t\t\t\tSwitchStatement: flag,\n\t\t\t\tConditionalExpression: flag,\n\t\t\t\t'Program:exit'(node) {\n\t\t\t\t\tif (owners.size < 2 || issue)\n\t\t\t\t\t\tcontext.report({ node: issue ?? node, messageId: 'ownership' })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'internal-function-ownership': {\n\t\tmeta: metadata('Place internal handlers with their owner, never in root, api/, or shared/.', {\n\t\t\townership:\n\t\t\t\t'Declare system/internal handlers in domain/<module>/, cross-domain application/, migrations/, or an isolated component.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tconst file = appFile(context) ?? ''\n\t\t\tif (\n\t\t\t\tcomponentRoot(context, context.filename) ||\n\t\t\t\t/^(?:domain\\/(?!shared\\/)[^/]+\\/|application\\/|migrations\\/)/.test(file)\n\t\t\t)\n\t\t\t\treturn {}\n\t\t\treturn {\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tif (node.callee.type === 'CallExpression') return\n\t\t\t\t\tconst ref = imported(context, node.callee)\n\t\t\t\t\tif (\n\t\t\t\t\t\tref &&\n\t\t\t\t\t\t((isFunctionsImport(context, ref.source) &&\n\t\t\t\t\t\t\t/^system(Query|Mutation|Action)$/.test(ref.name)) ||\n\t\t\t\t\t\t\t(/(?:_generated\\/server|convex\\/server)/.test(ref.source) &&\n\t\t\t\t\t\t\t\t/^internal(Query|Mutation|Action)(Generic)?$/.test(ref.name)))\n\t\t\t\t\t)\n\t\t\t\t\t\tcontext.report({ node, messageId: 'ownership' })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'domain-file-responsibilities': {\n\t\tmeta: metadata(\n\t\t\t'Keep invariants pure, reads read-only, shapes declarative, and I/O action-side.',\n\t\t\t{\n\t\t\t\townership:\n\t\t\t\t\t'Respect this domain file responsibility: pure rules, read-only queries, declarative schemas/tables/constants, and external I/O only in actions or integrations.',\n\t\t\t},\n\t\t),\n\t\tcreate(context) {\n\t\t\tconst file = appFile(context) ?? ''\n\t\t\tconst assembly = file === 'domain/table.ts'\n\t\t\tif (!assembly && !/^domain\\/[^/]+\\//.test(file)) return {}\n\t\t\tconst role = basename(file).replace(/\\.[cm]?[jt]s$/, '')\n\t\t\tconst pure = role === 'rules'\n\t\t\tconst read = role === 'queries'\n\t\t\tconst declarative = ['schema', 'table', 'contracts', 'constants'].includes(role)\n\t\t\tconst actionSide =\n\t\t\t\t/(?:^|\\/)(?:actions|integrations|providers)(?:\\/|\\.)/.test(file) ||\n\t\t\t\t/(?:^|_)actions\\./.test(file)\n\t\t\tconst resolver = createResolver()\n\t\t\tlet issue: ESTree.Node | null = null\n\t\t\tfunction flag(node: ESTree.Node) {\n\t\t\t\tissue ??= node\n\t\t\t}\n\t\t\tconst sources = sourceVisitors(context, (node, source) => {\n\t\t\t\tif (typeOnlySource(node)) return\n\t\t\t\tconst target = resolveImport(resolver, context.filename, source)\n\t\t\t\tconst path = target && appFile(context, target)\n\t\t\t\tif (\n\t\t\t\t\tassembly &&\n\t\t\t\t\tsource !== 'cvx-kit/zod-table' &&\n\t\t\t\t\t!/^domain\\/[^/]+\\/table(?:\\.[cm]?[jt]s)?$/.test(path ?? '')\n\t\t\t\t)\n\t\t\t\t\tflag(node)\n\t\t\t\tif (pure && path && !/(?:^|\\/)(?:rules|constants)(?:\\.[cm]?[jt]s)?$/.test(path)) flag(node)\n\t\t\t\tif (\n\t\t\t\t\t(pure || read || declarative) &&\n\t\t\t\t\t!path &&\n\t\t\t\t\t![\n\t\t\t\t\t\t'zod',\n\t\t\t\t\t\t'zod/v4',\n\t\t\t\t\t\t'convex/values',\n\t\t\t\t\t\t'cvx-kit',\n\t\t\t\t\t\t'cvx-kit/zod-table',\n\t\t\t\t\t\t'cvx-kit/errors',\n\t\t\t\t\t\t'cvx-kit/contracts',\n\t\t\t\t\t].includes(source)\n\t\t\t\t)\n\t\t\t\t\tflag(node)\n\t\t\t\tif (\n\t\t\t\t\tread &&\n\t\t\t\t\tpath &&\n\t\t\t\t\t/(?:^|\\/)(?:commands|actions|integrations|providers)(?:[./]|$)/.test(path)\n\t\t\t\t)\n\t\t\t\t\tflag(node)\n\t\t\t})\n\t\t\treturn {\n\t\t\t\t...sources,\n\t\t\t\tProgram(node) {\n\t\t\t\t\tif (!assembly) return\n\t\t\t\t\tfor (const statement of node.body) {\n\t\t\t\t\t\tif (statement.type === 'ImportDeclaration' || statement.type === 'EmptyStatement')\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\tconst declaration =\n\t\t\t\t\t\t\tstatement.type === 'ExportNamedDeclaration' ? statement.declaration : statement\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tdeclaration?.type !== 'VariableDeclaration' ||\n\t\t\t\t\t\t\tdeclaration.declarations.some((item) => item.init?.type !== 'CallExpression')\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tflag(statement)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tsources.CallExpression?.(node)\n\t\t\t\t\tif (assembly) {\n\t\t\t\t\t\tconst ref = imported(context, node.callee)\n\t\t\t\t\t\tif (ref?.source !== 'cvx-kit/zod-table' || ref.name !== 'createModule') flag(node)\n\t\t\t\t\t}\n\t\t\t\t\tconst method = node.callee.type === 'MemberExpression' ? propertyName(node.callee) : null\n\t\t\t\t\tif (\n\t\t\t\t\t\t(pure || declarative) &&\n\t\t\t\t\t\t(isDbAccess(node) ||\n\t\t\t\t\t\t\t['runQuery', 'runMutation', 'runAction', 'runAfter', 'runAt'].includes(method ?? ''))\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t\tif (\n\t\t\t\t\t\tread &&\n\t\t\t\t\t\t(isDbWrite(node) ||\n\t\t\t\t\t\t\t['runMutation', 'runAction', 'runAfter', 'runAt'].includes(method ?? ''))\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t\tconst constructor = imported(context, node.callee)\n\t\t\t\t\tif (\n\t\t\t\t\t\tconstructor &&\n\t\t\t\t\t\tisFunctionsImport(context, constructor.source) &&\n\t\t\t\t\t\t(pure || declarative || (read && /(?:Mutation|Action)$/.test(constructor.name)))\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t\tif (\n\t\t\t\t\t\tread &&\n\t\t\t\t\t\tnode.callee.type === 'MemberExpression' &&\n\t\t\t\t\t\tpropertyName(node.callee.object) === 'storage' &&\n\t\t\t\t\t\t['store', 'delete', 'generateUploadUrl'].includes(method ?? '')\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t\tif (!actionSide && isExternalCall(context, node)) flag(node)\n\t\t\t\t\tif (\n\t\t\t\t\t\tpure &&\n\t\t\t\t\t\tnode.callee.type === 'MemberExpression' &&\n\t\t\t\t\t\tnode.callee.object.type === 'Identifier' &&\n\t\t\t\t\t\t!binding(context, node.callee.object)?.defs.length &&\n\t\t\t\t\t\t((node.callee.object.name === 'Date' && method === 'now') ||\n\t\t\t\t\t\t\t(node.callee.object.name === 'Math' && method === 'random'))\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t},\n\t\t\t\tProperty(node) {\n\t\t\t\t\tif (\n\t\t\t\t\t\trole === 'contracts' &&\n\t\t\t\t\t\t['handler', 'context', 'audit', 'prepare', 'middleware', 'guard'].includes(\n\t\t\t\t\t\t\tnode.key.type === 'Identifier'\n\t\t\t\t\t\t\t\t? node.key.name\n\t\t\t\t\t\t\t\t: String(node.key.type === 'Literal' ? node.key.value : ''),\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t},\n\t\t\t\tMemberExpression(node) {\n\t\t\t\t\tif (pure && ['db', 'storage', 'scheduler', 'env'].includes(propertyName(node) ?? ''))\n\t\t\t\t\t\tflag(node)\n\t\t\t\t},\n\t\t\t\tNewExpression(node) {\n\t\t\t\t\tif (!(pure || read || declarative)) return\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.callee.type === 'Identifier' &&\n\t\t\t\t\t\t!binding(context, node.callee)?.defs.length &&\n\t\t\t\t\t\t['Error', 'TypeError', 'RangeError', 'Set', 'Map', 'RegExp'].includes(node.callee.name)\n\t\t\t\t\t)\n\t\t\t\t\t\treturn\n\t\t\t\t\tflag(node)\n\t\t\t\t},\n\t\t\t\t'Program:exit'() {\n\t\t\t\t\tif (issue) context.report({ node: issue, messageId: 'ownership' })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n} satisfies Record<string, Create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D,EAAKC,CAAI,CACX,EACA,iBAAiB,EAAM,CAClBgC,GAAQ,CAAC,KAAM,UAAW,YAAa,KAAK,CAAC,CAAC,SAASK,EAAarC,CAAI,GAAK,EAAE,GAClFD,EAAKC,CAAI,CACX,EACA,cAAc,EAAM,EACbgC,GAAQC,GAAQC,KAErBlC,EAAK,OAAO,OAAS,cACpBuC,EAAQrD,EAASc,EAAK,MAAM,CAAC,EAAE,KAAK,QACrC,EAAC,QAAS,YAAa,aAAc,MAAO,MAAO,QAAQ,CAAC,CAAC,SAASA,EAAK,OAAO,IAAI,IAGvFD,EAAKC,CAAI,CACV,EACA,gBAAiB,CACZR,GAAON,EAAQ,OAAO,CAAE,KAAMM,EAAO,UAAW,WAAY,CAAC,CAClE,CACD,CACD,CACD,CACD"}
|
|
1
|
+
{"version":3,"file":"ownership.mjs","names":["ownershipRules","metadata","settings","consumerOptions","context","root","resolve","existsSync","realpathSync","architectureAnchor","issue","inspectArchitecture","file","appFile","reason","componentFacade","standard","flag","node","statement","imported","containsComponentReference","argument","isDbWrite","isExternalCall","delegatingBody","owners","resolver","createResolver","sources","sourceVisitors","typeOnlySource","target","resolveImport","source","path","match","componentRoot","publicNames","exportedNames","declaration","item","isDbAccess","ref","memberPath","rootMember","isFunctionsImport","assembly","role","basename","pure","read","declarative","actionSide","method","propertyName","constructor","binding"],"sources":["../../src/oxlint/ownership.ts"],"sourcesContent":["import { existsSync, realpathSync } from 'node:fs'\nimport { basename, resolve } from 'node:path'\nimport type { CreateRule, ESTree } from '@oxlint/plugins'\nimport {\n\tarchitectureAnchor,\n\tinspectArchitecture,\n\tcreateResolver,\n\tresolveImport,\n} from './architecture'\nimport {\n\tconsumerOptions,\n\tappFile,\n\timported,\n\tsourceVisitors,\n\tisFunctionsImport,\n\ttypeOnlySource,\n\tisDbAccess,\n\tisExternalCall,\n\tcontainsComponentReference,\n\trootMember,\n\tmemberPath,\n\tisDbWrite,\n\tmetadata,\n\tcomponentRoot,\n\tpropertyName,\n\tbinding,\n\texportedNames,\n\tdelegatingBody,\n} from './ast'\n\nexport const ownershipRules = {\n\t'project-structure': {\n\t\tmeta: metadata('Validate the application tree, colocated tests, and module cycles.', {\n\t\t\tstructure: '{{file}}: {{message}}',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tconst settings = consumerOptions.parse(context.options[0] ?? {})\n\t\t\tconst root = resolve(context.cwd, settings.convexDir)\n\t\t\tif (\n\t\t\t\t(existsSync(context.filename)\n\t\t\t\t\t? realpathSync(context.filename)\n\t\t\t\t\t: resolve(context.filename)) !== architectureAnchor(root)\n\t\t\t)\n\t\t\t\treturn {}\n\t\t\treturn {\n\t\t\t\tProgram(node) {\n\t\t\t\t\tfor (const issue of inspectArchitecture({\n\t\t\t\t\t\tcwd: context.cwd,\n\t\t\t\t\t\tconvexDir: settings.convexDir,\n\t\t\t\t\t\tcomponentDirs: settings.componentDirs,\n\t\t\t\t\t}))\n\t\t\t\t\t\tcontext.report({\n\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\tmessageId: 'structure',\n\t\t\t\t\t\t\tdata: { file: issue.file, message: issue.message },\n\t\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'root-wiring-only': {\n\t\tmeta: metadata('Keep root files limited to configuration, assembly, and component facades.', {\n\t\t\townership:\n\t\t\t\t'Root files only wire configuration and components. Move behavior into domain/<module>/: {{reason}}.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tconst file = appFile(context)\n\t\t\tif (!file || file.includes('/')) return {}\n\t\t\tlet issue: ESTree.Node | null = null\n\t\t\tlet reason = 'business implementation'\n\t\t\tlet componentFacade = false\n\t\t\tconst standard =\n\t\t\t\t/^(?:convex\\.config|auth\\.config|vite\\.config|vitest\\.config|auth|schema|functions|triggers|foundation|http|crons)\\.[cm]?[jt]s$/.test(\n\t\t\t\t\tfile,\n\t\t\t\t)\n\t\t\tfunction flag(node: ESTree.Node) {\n\t\t\t\tissue ??= node\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tProgram(node) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.body.some(\n\t\t\t\t\t\t\t(statement) =>\n\t\t\t\t\t\t\t\tstatement.type === 'FunctionDeclaration' ||\n\t\t\t\t\t\t\t\t(statement.type === 'ExportNamedDeclaration' &&\n\t\t\t\t\t\t\t\t\tstatement.declaration?.type === 'FunctionDeclaration'),\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t},\n\t\t\t\tNewExpression(node) {\n\t\t\t\t\tif (\n\t\t\t\t\t\timported(context, node.callee) &&\n\t\t\t\t\t\tnode.arguments.some((argument) => containsComponentReference(context, argument))\n\t\t\t\t\t)\n\t\t\t\t\t\tcomponentFacade = true\n\t\t\t\t},\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tif (\n\t\t\t\t\t\timported(context, node.callee) &&\n\t\t\t\t\t\tnode.arguments.some((argument) => containsComponentReference(context, argument))\n\t\t\t\t\t)\n\t\t\t\t\t\tcomponentFacade = true\n\t\t\t\t\tif (\n\t\t\t\t\t\tisDbWrite(node) ||\n\t\t\t\t\t\tisExternalCall(context, node) ||\n\t\t\t\t\t\t(file === 'schema.ts' && !(imported(context, node.callee)?.name === 'defineSchema'))\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t},\n\t\t\t\tArrowFunctionExpression(node) {\n\t\t\t\t\tif (!node.body || !delegatingBody(node.body)) flag(node)\n\t\t\t\t},\n\t\t\t\tFunctionExpression(node) {\n\t\t\t\t\tif (!node.body || !delegatingBody(node.body)) flag(node)\n\t\t\t\t},\n\t\t\t\tIfStatement: flag,\n\t\t\t\tSwitchStatement: flag,\n\t\t\t\tConditionalExpression: flag,\n\t\t\t\tForStatement: flag,\n\t\t\t\tForOfStatement: flag,\n\t\t\t\tWhileStatement: flag,\n\t\t\t\t'Program:exit'(node) {\n\t\t\t\t\tif (!standard && !componentFacade) {\n\t\t\t\t\t\tissue = node\n\t\t\t\t\t\treason = 'unknown root file; only declared component facades may add root source files'\n\t\t\t\t\t}\n\t\t\t\t\tif (issue) context.report({ node: issue, messageId: 'ownership', data: { reason } })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'application-orchestration': {\n\t\tmeta: metadata('Reserve application/ for thin cross-domain coordination.', {\n\t\t\townership:\n\t\t\t\t'application/ only coordinates two or more domains. Move schemas, providers, storage access, helpers, and business decisions into their owning domain.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tif (!appFile(context)?.startsWith('application/')) return {}\n\t\t\tconst owners = new Set<string>()\n\t\t\tconst resolver = createResolver()\n\t\t\tlet issue: ESTree.Node | null = null\n\t\t\tfunction flag(node: ESTree.Node) {\n\t\t\t\tissue ??= node\n\t\t\t}\n\t\t\tconst sources = sourceVisitors(context, (node, source) => {\n\t\t\t\tif (typeOnlySource(node)) return\n\t\t\t\tconst target = resolveImport(resolver, context.filename, source)\n\t\t\t\tconst path = target && appFile(context, target)\n\t\t\t\tconst match = path?.match(/^domain\\/([^/]+)\\/(?:commands|queries|rules)(?:\\.[cm]?[jt]s)?$/)\n\t\t\t\tif (match && match[1] !== 'shared') owners.add(match[1])\n\t\t\t\tif (path?.startsWith('domain/') && !match && !path.startsWith('domain/shared/')) flag(node)\n\t\t\t\tif (\n\t\t\t\t\t!path &&\n\t\t\t\t\t!componentRoot(context, context.filename) &&\n\t\t\t\t\t![\n\t\t\t\t\t\t'cvx-kit',\n\t\t\t\t\t\t'cvx-kit/components/foundation',\n\t\t\t\t\t\t'@convex-dev/workflow',\n\t\t\t\t\t\t'convex/values',\n\t\t\t\t\t].includes(source)\n\t\t\t\t)\n\t\t\t\t\tflag(node)\n\t\t\t})\n\t\t\treturn {\n\t\t\t\t...sources,\n\t\t\t\tProgram(node) {\n\t\t\t\t\tconst publicNames = exportedNames(node)\n\t\t\t\t\tfor (const statement of node.body) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tstatement.type === 'FunctionDeclaration' &&\n\t\t\t\t\t\t\tstatement.id &&\n\t\t\t\t\t\t\t!publicNames.has(statement.id.name)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tflag(statement)\n\t\t\t\t\t\tconst declaration =\n\t\t\t\t\t\t\tstatement.type === 'ExportNamedDeclaration' ? statement.declaration : statement\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tdeclaration?.type === 'TSTypeAliasDeclaration' ||\n\t\t\t\t\t\t\tdeclaration?.type === 'TSInterfaceDeclaration'\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tflag(statement)\n\t\t\t\t\t\tif (declaration?.type === 'VariableDeclaration')\n\t\t\t\t\t\t\tfor (const item of declaration.declarations) {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\titem.init &&\n\t\t\t\t\t\t\t\t\t['ObjectExpression', 'ArrayExpression', 'Literal'].includes(item.init.type)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tflag(item)\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tstatement.type === 'VariableDeclaration' &&\n\t\t\t\t\t\t\t\t\titem.id.type === 'Identifier' &&\n\t\t\t\t\t\t\t\t\t!publicNames.has(item.id.name) &&\n\t\t\t\t\t\t\t\t\t['ArrowFunctionExpression', 'FunctionExpression'].includes(item.init?.type ?? '')\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tflag(item)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tsources.CallExpression?.(node)\n\t\t\t\t\tif (isDbAccess(node) || isExternalCall(context, node)) flag(node)\n\t\t\t\t\tconst ref = imported(context, node.callee)\n\t\t\t\t\tif (ref && ['zod', 'zod/v4'].includes(ref.source)) flag(node)\n\t\t\t\t},\n\t\t\t\tMemberExpression(node) {\n\t\t\t\t\tconst path = memberPath(node)\n\t\t\t\t\tif (path.length >= 4 && path[1] === 'domain') {\n\t\t\t\t\t\tconst ref = imported(context, rootMember(node))\n\t\t\t\t\t\tif (ref?.name === 'internal' && /_generated\\/api/.test(ref.source)) owners.add(path[2])\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tNewExpression: flag,\n\t\t\t\tIfStatement: flag,\n\t\t\t\tSwitchStatement: flag,\n\t\t\t\tConditionalExpression: flag,\n\t\t\t\t'Program:exit'(node) {\n\t\t\t\t\tif (owners.size < 2 || issue)\n\t\t\t\t\t\tcontext.report({ node: issue ?? node, messageId: 'ownership' })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'internal-function-ownership': {\n\t\tmeta: metadata('Place internal handlers with their owner, never in root, api/, or shared/.', {\n\t\t\townership:\n\t\t\t\t'Declare system/internal handlers in domain/<module>/, cross-domain application/, migrations/, or an isolated component.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tconst file = appFile(context) ?? ''\n\t\t\tif (\n\t\t\t\tcomponentRoot(context, context.filename) ||\n\t\t\t\t/^(?:domain\\/(?!shared\\/)[^/]+\\/|application\\/|migrations\\/)/.test(file)\n\t\t\t)\n\t\t\t\treturn {}\n\t\t\treturn {\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tif (node.callee.type === 'CallExpression') return\n\t\t\t\t\tconst ref = imported(context, node.callee)\n\t\t\t\t\tif (\n\t\t\t\t\t\tref &&\n\t\t\t\t\t\t((isFunctionsImport(context, ref.source) &&\n\t\t\t\t\t\t\t/^system(Query|Mutation|Action)$/.test(ref.name)) ||\n\t\t\t\t\t\t\t(/(?:_generated\\/server|convex\\/server)/.test(ref.source) &&\n\t\t\t\t\t\t\t\t/^internal(Query|Mutation|Action)(Generic)?$/.test(ref.name)))\n\t\t\t\t\t)\n\t\t\t\t\t\tcontext.report({ node, messageId: 'ownership' })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'domain-file-responsibilities': {\n\t\tmeta: metadata(\n\t\t\t'Keep invariants pure, reads read-only, shapes declarative, and I/O action-side.',\n\t\t\t{\n\t\t\t\townership:\n\t\t\t\t\t'Respect this domain file responsibility: pure rules, read-only queries, declarative schemas/tables/constants, and external I/O only in actions or integrations.',\n\t\t\t},\n\t\t),\n\t\tcreate(context) {\n\t\t\tconst file = appFile(context) ?? ''\n\t\t\tconst assembly = file === 'domain/table.ts'\n\t\t\tif (!assembly && !/^domain\\/[^/]+\\//.test(file) && !componentRoot(context, context.filename))\n\t\t\t\treturn {}\n\t\t\tconst role = basename(file).replace(/\\.[cm]?[jt]s$/, '')\n\t\t\tconst pure = role === 'rules'\n\t\t\tconst read = role === 'queries'\n\t\t\tconst declarative = ['schema', 'table', 'contracts', 'constants'].includes(role)\n\t\t\tconst actionSide =\n\t\t\t\t/(?:^|\\/)(?:actions|integrations|providers)(?:\\/|\\.)/.test(file) ||\n\t\t\t\t/(?:^|_)actions\\./.test(file)\n\t\t\tconst resolver = createResolver()\n\t\t\tlet issue: ESTree.Node | null = null\n\t\t\tfunction flag(node: ESTree.Node) {\n\t\t\t\tissue ??= node\n\t\t\t}\n\t\t\tconst sources = sourceVisitors(context, (node, source) => {\n\t\t\t\tif (typeOnlySource(node)) return\n\t\t\t\tconst target = resolveImport(resolver, context.filename, source)\n\t\t\t\tconst path = target && appFile(context, target)\n\t\t\t\tif (\n\t\t\t\t\tassembly &&\n\t\t\t\t\tsource !== 'cvx-kit/zod-table' &&\n\t\t\t\t\t!/^domain\\/[^/]+\\/table(?:\\.[cm]?[jt]s)?$/.test(path ?? '')\n\t\t\t\t)\n\t\t\t\t\tflag(node)\n\t\t\t\tif (pure && path && !/(?:^|\\/)(?:rules|constants)(?:\\.[cm]?[jt]s)?$/.test(path)) flag(node)\n\t\t\t\tif (\n\t\t\t\t\t(pure || read || declarative) &&\n\t\t\t\t\t!path &&\n\t\t\t\t\t!componentRoot(context, context.filename) &&\n\t\t\t\t\t![\n\t\t\t\t\t\t'zod',\n\t\t\t\t\t\t'zod/v4',\n\t\t\t\t\t\t'convex/values',\n\t\t\t\t\t\t'cvx-kit',\n\t\t\t\t\t\t'cvx-kit/zod-table',\n\t\t\t\t\t\t'cvx-kit/errors',\n\t\t\t\t\t\t'cvx-kit/contracts',\n\t\t\t\t\t].includes(source)\n\t\t\t\t)\n\t\t\t\t\tflag(node)\n\t\t\t\tif (\n\t\t\t\t\tread &&\n\t\t\t\t\tpath &&\n\t\t\t\t\t/(?:^|\\/)(?:commands|actions|integrations|providers)(?:[./]|$)/.test(path)\n\t\t\t\t)\n\t\t\t\t\tflag(node)\n\t\t\t})\n\t\t\treturn {\n\t\t\t\t...sources,\n\t\t\t\tProgram(node) {\n\t\t\t\t\tif (!assembly) return\n\t\t\t\t\tfor (const statement of node.body) {\n\t\t\t\t\t\tif (statement.type === 'ImportDeclaration' || statement.type === 'EmptyStatement')\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\tconst declaration =\n\t\t\t\t\t\t\tstatement.type === 'ExportNamedDeclaration' ? statement.declaration : statement\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tdeclaration?.type !== 'VariableDeclaration' ||\n\t\t\t\t\t\t\tdeclaration.declarations.some((item) => item.init?.type !== 'CallExpression')\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tflag(statement)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tsources.CallExpression?.(node)\n\t\t\t\t\tif (assembly) {\n\t\t\t\t\t\tconst ref = imported(context, node.callee)\n\t\t\t\t\t\tif (ref?.source !== 'cvx-kit/zod-table' || ref.name !== 'createModule') flag(node)\n\t\t\t\t\t}\n\t\t\t\t\tconst method = node.callee.type === 'MemberExpression' ? propertyName(node.callee) : null\n\t\t\t\t\tif (\n\t\t\t\t\t\t(pure || declarative) &&\n\t\t\t\t\t\t(isDbAccess(node) ||\n\t\t\t\t\t\t\t['runQuery', 'runMutation', 'runAction', 'runAfter', 'runAt'].includes(method ?? ''))\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t\tif (\n\t\t\t\t\t\tread &&\n\t\t\t\t\t\t(isDbWrite(node) ||\n\t\t\t\t\t\t\t['runMutation', 'runAction', 'runAfter', 'runAt'].includes(method ?? ''))\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t\tconst constructor = imported(context, node.callee)\n\t\t\t\t\tif (\n\t\t\t\t\t\tconstructor &&\n\t\t\t\t\t\tisFunctionsImport(context, constructor.source) &&\n\t\t\t\t\t\t(pure || declarative || (read && /(?:Mutation|Action)$/.test(constructor.name)))\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t\tif (\n\t\t\t\t\t\tread &&\n\t\t\t\t\t\tnode.callee.type === 'MemberExpression' &&\n\t\t\t\t\t\tpropertyName(node.callee.object) === 'storage' &&\n\t\t\t\t\t\t['store', 'delete', 'generateUploadUrl'].includes(method ?? '')\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t\tif (!actionSide && isExternalCall(context, node)) flag(node)\n\t\t\t\t\tif (\n\t\t\t\t\t\tpure &&\n\t\t\t\t\t\tnode.callee.type === 'MemberExpression' &&\n\t\t\t\t\t\tnode.callee.object.type === 'Identifier' &&\n\t\t\t\t\t\t!binding(context, node.callee.object)?.defs.length &&\n\t\t\t\t\t\t((node.callee.object.name === 'Date' && method === 'now') ||\n\t\t\t\t\t\t\t(node.callee.object.name === 'Math' && method === 'random'))\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t},\n\t\t\t\tProperty(node) {\n\t\t\t\t\tif (\n\t\t\t\t\t\trole === 'contracts' &&\n\t\t\t\t\t\t['handler', 'context', 'audit', 'prepare', 'middleware', 'guard'].includes(\n\t\t\t\t\t\t\tnode.key.type === 'Identifier'\n\t\t\t\t\t\t\t\t? node.key.name\n\t\t\t\t\t\t\t\t: String(node.key.type === 'Literal' ? node.key.value : ''),\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t},\n\t\t\t\tMemberExpression(node) {\n\t\t\t\t\tif (pure && ['db', 'storage', 'scheduler', 'env'].includes(propertyName(node) ?? ''))\n\t\t\t\t\t\tflag(node)\n\t\t\t\t},\n\t\t\t\tNewExpression(node) {\n\t\t\t\t\tif (!(pure || read || declarative)) return\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.callee.type === 'Identifier' &&\n\t\t\t\t\t\t!binding(context, node.callee)?.defs.length &&\n\t\t\t\t\t\t['Error', 'TypeError', 'RangeError', 'Set', 'Map', 'RegExp'].includes(node.callee.name)\n\t\t\t\t\t)\n\t\t\t\t\t\treturn\n\t\t\t\t\tflag(node)\n\t\t\t\t},\n\t\t\t\t'Program:exit'() {\n\t\t\t\t\tif (issue) context.report({ node: issue, messageId: 'ownership' })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n} satisfies Record<string, CreateRule>\n\nexport type OwnershipRuleName = keyof typeof ownershipRules\n"],"mappings":"ikBA8BA,MAAaA,EAAiB,CAC7B,oBAAqB,CACpB,KAAMC,EAAS,qEAAsE,CACpF,UAAW,uBACZ,CAAC,EACD,OAAO,EAAS,CACf,IAAMC,EAAWC,EAAgB,MAAMC,EAAQ,QAAQ,IAAM,CAAC,CAAC,EACzDC,EAAOC,EAAQF,EAAQ,IAAKF,EAAS,SAAS,EAOpD,OALEK,EAAWH,EAAQ,QAAQ,EACzBI,EAAaJ,EAAQ,QAAQ,EAC7BE,EAAQF,EAAQ,QAAQ,KAAOK,EAAmBJ,CAAI,EAGnD,CACN,QAAQ,EAAM,CACb,IAAK,IAAMK,KAASC,EAAoB,CACvC,IAAKP,EAAQ,IACb,UAAWF,EAAS,UACpB,cAAeA,EAAS,aACzB,CAAC,EACAE,EAAQ,OAAO,CACd,OACA,UAAW,YACX,KAAM,CAAE,KAAMM,EAAM,KAAM,QAASA,EAAM,OAAQ,CAClD,CAAC,CACH,CACD,EAdQ,CAAC,CAeV,CACD,EACA,mBAAoB,CACnB,KAAMT,E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@@
|
|
|
1
|
-
import{forceRegistry as e}from"./modules/contracts/lazy.mjs";import{createResolver as t,inspectArchitecture as n,narrowRootDeclaration as r,resolveImport as i}from"./oxlint/architecture.mjs";import{appFile as a,binding as o,componentRoot as s,exportName as c,exportedNames as l,imported as u,isDbWrite as d,isFunctionsImport as f,isTableChain as p,localInitializer as m,metadata as h,propertyName as g,readProvenance as _,sourceVisitors as v,staticString as y}from"./oxlint/ast.mjs";import{reservedDomainFiles as b}from"./oxlint/reserved-files.mjs";import{ownershipRules as x}from"./oxlint/ownership.mjs";import{basename as S,dirname as C,relative as w,sep as T}from"node:path";function E(t={}){for(let n of t.registries??[])e(n);return n(t)}const D=k({...x,"root-wiring-only":{...x[`root-wiring-only`],create(e){let t=a(e)??``;return[`relations.ts`,`querying.ts`].includes(t)?r(t,e.sourceCode.text)?{}:{Program(n){e.report({node:n,messageId:`ownership`,data:{reason:`${t} must export one kit factory declaration and contain only declarative configuration`}})}}:x[`root-wiring-only`].create(e)}},"reserved-domain-file-anatomy":b,"root-facade-ownership":{meta:h(`Configure shared kit infrastructure once in its root facade.`,{facade:`Configure {{name}} once in convex/{{file}}; import that facade elsewhere.`}),create(e){if(s(e,e.filename))return{};let t=/* @__PURE__ */ new Set;function n(n){let r=u(e,n.callee);if(!r)return;let i=null;[`cvx-kit`,`cvx-kit/querying`].includes(r.source)&&r.name===`createQueryEngine`&&(i=`querying.ts`),[`cvx-kit`,`cvx-kit/relations`].includes(r.source)&&r.name===`defineRelations`&&(i=`relations.ts`),[`cvx-kit`,`cvx-kit/auth`].includes(r.source)&&r.name===`createAuthFunctions`&&(i=`functions.ts`),[`cvx-kit`,`cvx-kit/triggers`].includes(r.source)&&r.name===`createTriggers`&&(i=`triggers.ts`),[`cvx-kit`,`cvx-kit/components/foundation`].includes(r.source)&&r.name===`Foundation`&&(i=`foundation.ts`),(r.source===`cvx-kit/effect`&&r.name===`createEffectFoundation`||r.source===`cvx-kit`&&r.name===`createFoundation`)&&(i=`foundation.ts`),i&&((a(e)!==i||t.has(r.name))&&e.report({node:n,messageId:`facade`,data:{name:r.name,file:i}}),t.add(r.name))}return{CallExpression:n,NewExpression:n}}},"no-raw-builders":{meta:h(`Build host functions through the auth-aware root constructors.`,{builder:`Import raw builders only in convex/functions.ts; use auth*/role*/admin* or system* elsewhere.`}),create(e){if(a(e)===`functions.ts`||s(e,e.filename))return{};let n=t();return{ImportDeclaration(t){if(t.importKind===`type`)return;let r=t.source.value,o=i(n,e.filename,r),s=o&&a(e,o)?.startsWith(`_generated/`)?a(e,o):r;if(/(?:^|\/)_generated\/server(?:\.[cm]?[jt]s)?$/.test(s)||s===`convex/server`)for(let n of t.specifiers){if(n.type===`ImportSpecifier`&&n.importKind===`type`)continue;let t=n.type===`ImportSpecifier`?c(n.imported):null;(t===null&&s!==`convex/server`||t&&/^(?:internal)?(?:Query|Mutation|Action)(?:Generic)?$|^(?:query|mutation|action)(?:Generic)?$/.test(t))&&e.report({node:n,messageId:`builder`})}},CallExpression(t){let n=u(e,t.callee);n?.source===`convex/server`&&/^(?:internal)?(?:Query|Mutation|Action)Generic$|^(?:query|mutation|action)Generic$/.test(n.name)&&t.callee.type===`MemberExpression`&&e.report({node:t,messageId:`builder`})}}}},"no-handwritten-references":{meta:h(`Use generated api/internal references.`,{reference:`Use generated api/internal references instead of makeFunctionReference.`}),create(e){return{CallExpression(t){let n=u(e,t.callee);n?.source===`convex/server`&&n.name===`makeFunctionReference`&&e.report({node:t,messageId:`reference`})}}}},"domain-import-boundaries":{meta:h(`Keep api, application, domain, and shared dependencies directed.`,{boundary:`Follow api → application/domain → shared; sibling modules expose only rules.ts and queries.ts.`}),create(e){let n=a(e),r=t();return v(e,(t,o)=>{if(!n)return;let s=i(r,e.filename,o);if(!s)return;let c=a(e,s)?.replace(/\.[cm]?[jt]s$/,``);if(!c){s.split(T).includes(`node_modules`)||e.report({node:t,messageId:`boundary`});return}let l=n.split(`/`),u=c.split(`/`),d=!1;l[0]===`domain`?(d=[`api`,`application`,`migrations`].includes(u[0]),u[0]===`domain`&&l[1]!==u[1]&&u[1]!==`shared`&&l[1]!==`table.ts`&&(d=l[1]===`shared`||![`rules`,`queries`,`contracts`].includes(u.slice(2).join(`/`)))):l[0]===`api`?d=[`api`,`migrations`].includes(u[0])||u[0]===`domain`&&u[1]!==`shared`&&u[1]!==(l.length>2?l[1]:S(n).replace(/\.[cm]?[jt]s$/,``)):l[0]===`application`?d=[`api`,`migrations`].includes(u[0]):[`relations.ts`,`querying.ts`].includes(n)&&u[0]===`domain`&&(d=!(n===`relations.ts`?[`schema`,`table`]:[`queries`,`contracts`]).includes(u.slice(2).join(`/`))&&(n!==`relations.ts`||c!==`domain/table`)),u[0]===`migrations`&&l[0]!==`migrations`&&(d=!0),[`api`,`domain`,`application`].includes(l[0])&&u.length>1&&![`api`,`domain`,`application`,`_generated`,`components`,`migrations`].includes(u[0])&&(d=!0),d&&e.report({node:t,messageId:`boundary`})})}},"public-functions-in-api":{meta:h(`Expose authenticated public functions only through api/.`,{public:`Declare public auth*/role*/admin* functions in convex/api/<module>.ts.`}),create(e){return a(e)?.startsWith(`api/`)?{}:{CallExpression(t){let n=u(e,t.callee);t.callee.type!==`CallExpression`&&n&&f(e,n.source)&&/^(auth|role|admin)(Query|Mutation|Action)$/.test(n.name)&&e.report({node:t,messageId:`public`})}}}},"thin-api-adapters":{meta:h(`Keep business decisions and writes in domain executors.`,{adapter:`Move business branches, private helpers, and database writes into the owning domain executor.`}),create(e){return a(e)?.startsWith(`api/`)?{IfStatement(t){e.report({node:t,messageId:`adapter`})},SwitchStatement(t){e.report({node:t,messageId:`adapter`})},ConditionalExpression(t){e.report({node:t,messageId:`adapter`})},Program(t){let n=l(t);for(let r of t.body)if(r.type===`FunctionDeclaration`&&r.id&&!n.has(r.id.name)&&e.report({node:r,messageId:`adapter`}),r.type===`VariableDeclaration`)for(let t of r.declarations)t.id.type===`Identifier`&&!n.has(t.id.name)&&[`ArrowFunctionExpression`,`FunctionExpression`].includes(t.init?.type??``)&&e.report({node:t,messageId:`adapter`})},CallExpression(t){d(t)&&e.report({node:t,messageId:`adapter`})}}:{}}},"no-inline-enums":{meta:h(`Keep vocabularies in named constants.ts tuples.`,{vocabulary:`Define a named readonly tuple in constants.ts and pass it to z.enum().`}),create(e){return{CallExpression(t){let n=u(e,t.callee),r=t.arguments[0];for(;r?.type===`TSAsExpression`||r?.type===`TSSatisfiesExpression`;)r=r.expression;n&&/^zod(?:\/v4)?$/.test(n.source)&&n.name===`enum`&&r?.type===`ArrayExpression`&&e.report({node:t,messageId:`vocabulary`})}}}},"no-unbounded-reads":{meta:h(`Bound collection reads through include or pagination.`,{bounded:`Use include(...).execute(limit) or bounded pagination; do not collect() or resolve() an unbounded query.`,order:`Apply eligibility filters in the indexed query before take(), execute(), or paginate(); filtering a bounded result can omit eligible rows. Do not move the predicate automatically.`}),create(e){return s(e,e.filename)?{}:{CallExpression(t){if(t.callee.type!==`MemberExpression`)return;let n=g(t.callee),r=_(e,t.callee.object);n===`filter`&&r===`bounded`&&e.report({node:t,messageId:`order`}),(n===`collect`&&(r===`stream`||r===`relationship`)||n===`resolve`&&r===`stream`)&&e.report({node:t,messageId:`bounded`})}}}},"no-manual-id-projection":{meta:h(`Use the table DTO boundary to project public IDs.`,{projection:`Use toPublicDto(row, true) to include _id; do not add IDs manually after a table DTO parse or projection.`}),create(e){return{ObjectExpression(t){if(t.properties.some(t=>t.type===`SpreadElement`&&_(e,t.argument)===`dto`))for(let n of t.properties)n.type===`Property`&&[`id`,`_id`].includes((n.computed?y(n.key):c(n.key))??``)&&e.report({node:n,messageId:`projection`})},AssignmentExpression(t){t.left.type===`MemberExpression`&&[`id`,`_id`].includes(g(t.left)??``)&&_(e,t.left.object)===`dto`&&e.report({node:t,messageId:`projection`})}}}},"no-copied-pagination":{meta:h(`Use native or table pagination schemas instead of copying their shape.`,{pagination:`Use the native paginationOptsValidator (or paginated(table.dto())) for native pagination, or table.paginationOpts(selection) for table queries; do not copy pagination fields.`}),create(e){return{CallExpression(t){let n=u(e,t.callee);if(!(n?.name===`object`&&[`zod`,`zod/v4`,`convex/values`].includes(n.source)))return;let r=t.arguments[0],i=r&&(m(e,r)??r);if(i?.type!==`ObjectExpression`)return;let a=new Set(i.properties.flatMap(e=>e.type===`Property`?[e.computed?y(e.key):c(e.key)]:[]));(a.has(`numItems`)&&a.has(`cursor`)||[`page`,`isDone`,`continueCursor`].every(e=>a.has(e)))&&e.report({node:t,messageId:`pagination`})}}}},"no-manual-timestamps":{meta:h(`Let timestamps triggers own createdAt and updatedAt.`,{timestamp:`Remove {{field}} from this write; register the timestamps trigger instead.`}),create(e){return s(e,e.filename)?{}:{CallExpression(t){if(!d(t))return;let n=t.arguments.at(-1);if(n?.type===`ObjectExpression`)for(let t of n.properties){if(t.type!==`Property`)continue;let n=t.computed?y(t.key):c(t.key);(n===`createdAt`||n===`updatedAt`)&&e.report({node:t,messageId:`timestamp`,data:{field:n}})}}}}},"component-boundaries":{meta:h(`Keep portable components isolated and consume their client facades.`,{boundary:`Components may import only their own files and npm dependencies; inject host policy through the client API.`,facade:`Import a component through its client.ts facade, not its private implementation.`}),create(e){let n=s(e,e.filename),r=t();return v(e,(t,o)=>{o.startsWith(`.`)||/^cvx-kit\/components\/[^/]+\//.test(o)&&!/^cvx-kit\/components\/[^/]+\/convex\.config(?:\.js)?$/.test(o)&&e.report({node:t,messageId:`facade`});let c=i(r,e.filename,o);c&&!c.split(T).includes(`node_modules`)&&(n&&(w(n,c).startsWith(`..${T}`)||c===C(n))?e.report({node:t,messageId:`boundary`}):!n&&s(e,c)&&!/^client(?:\.[cm]?[jt]s)?$/.test(S(c))&&!(a(e)===`convex.config.ts`&&/^convex\.config(?:\.[cm]?[jt]s)?$/.test(S(c)))&&e.report({node:t,messageId:`facade`}))})}},"no-component-env":{meta:h(`Pass environment configuration into portable components.`,{env:`Portable components must receive configuration through arguments; do not read process.env.`}),create(e){if(!s(e,e.filename))return{};function t(t){if(t.type!==`Identifier`)return!1;let n=o(e,t);return t.name===`process`&&!n?.defs.length||n?.defs.some(e=>e.type===`ImportBinding`&&e.parent?.type===`ImportDeclaration`&&[`node:process`,`process`].includes(e.parent.source.value)&&[`ImportDefaultSpecifier`,`ImportNamespaceSpecifier`].includes(e.node.type))}return{ImportDeclaration(t){if([`node:process`,`process`].includes(t.source.value))for(let n of t.specifiers)n.type===`ImportSpecifier`&&c(n.imported)===`env`&&e.report({node:n,messageId:`env`})},MemberExpression(n){if(g(n)!==`env`)return;let r=n.object,i=r.type===`MemberExpression`&&g(r)===`process`&&r.object.type===`Identifier`&&r.object.name===`globalThis`&&!o(e,r.object)?.defs.length;(t(r)||i)&&e.report({node:n,messageId:`env`})},VariableDeclarator(n){if(n.init&&t(n.init)&&n.id.type===`ObjectPattern`)for(let t of n.id.properties)t.type===`Property`&&(t.computed?y(t.key):c(t.key))===`env`&&e.report({node:t,messageId:`env`})}}}},"schema-file-boundaries":{meta:h(`Keep storage shapes and indexes in their documented owners.`,{schema:`{{builder}} belongs in {{file}}.`}),create(e){return{CallExpression(t){let n=u(e,t.callee),r=a(e);if(!r)return;let i=null;n?.source===`convex/server`&&(n.name===`defineSchema`&&r!==`schema.ts`&&!(s(e,e.filename)&&S(r)===`schema.ts`)&&(i=`the root schema.ts (or a component schema.ts)`),n.name===`defineTable`&&!(s(e,e.filename)&&[`schema.ts`,`table.ts`].includes(S(r)))&&(i=`a component schema.ts/table.ts; host tables use zodTable in domain/<module>/schema.ts`)),n&&[`cvx-kit`,`cvx-kit/zod-table`].includes(n.source)&&[`zodTable`,`tenantTable`,`zodVariantTable`].includes(n.name)&&!/^domain\/[^/]+\/schema\.ts$/.test(r)&&(i=`domain/<module>/schema.ts`),i&&e.report({node:t,messageId:`schema`,data:{builder:n?.name??`table`,file:i}}),t.callee.type===`MemberExpression`&&[`index`,`searchIndex`,`vectorIndex`].includes(g(t.callee)??``)&&p(t.callee.object)&&!s(e,e.filename)&&!/^domain\/[^/]+\/table\.ts$/.test(r)&&e.report({node:t,messageId:`schema`,data:{builder:`Table indexes`,file:`domain/<module>/table.ts`}})}}}},"no-internal-reexports":{meta:h(`Import from owning modules directly; consumer apps have no barrels.`,{reexport:`Import from the owning file directly; do not re-export imports inside convex/.`}),create(e){function t(t){if(t.source){e.report({node:t,messageId:`reexport`});return}for(let n of t.type===`ExportNamedDeclaration`?t.specifiers:[])o(e,n.local)?.defs.some(e=>e.type===`ImportBinding`)&&e.report({node:n,messageId:`reexport`})}return{ExportNamedDeclaration:t,ExportAllDeclaration:t,ExportDefaultDeclaration(t){t.declaration.type===`Identifier`&&o(e,t.declaration)?.defs.some(e=>e.type===`ImportBinding`)&&e.report({node:t,messageId:`reexport`})}}}},"public-api-first":{meta:h(`Place private helper implementations after the exported API.`,{order:`Move this private helper below the exported API so the file reads from public purpose to implementation.`}),create(e){return{Program(t){let n=l(t),r=t.body.findLastIndex(e=>e.type.startsWith(`Export`));for(let i of t.body.slice(0,r<0?0:r))i.type===`FunctionDeclaration`&&i.id&&!n.has(i.id.name)&&e.report({node:i,messageId:`order`})}}}},"named-private-helpers":{meta:h(`Use named declarations for top-level private helper functions.`,{helper:`Declare this private helper with function name(...) at the bottom of the file.`}),create(e){return{Program(t){let n=l(t);for(let r of t.body)if(r.type===`VariableDeclaration`)for(let t of r.declarations)t.id.type===`Identifier`&&!n.has(t.id.name)&&(t.init?.type===`ArrowFunctionExpression`||t.init?.type===`FunctionExpression`)&&e.report({node:t,messageId:`helper`})}}}}}),O={meta:{name:`cvx`},rules:D};function k(e){let t={...e},n=Object.keys(e);for(let r of n){let n=e[r];t[r]={meta:{...n.meta,schema:[{type:`object`,properties:{convexDir:{type:`string`,minLength:1}},additionalProperties:!1}]},create(e){let t=a(e);return!t||/(?:^|\/)(?:_generated|__tests__)(?:\/|$)/.test(t)||/\.(?:test|spec)\.[cm]?[jt]s$/.test(t)?{}:n.create(e)}}}return t}export{E as checkArchitecture,O as default,D as rules};
|
|
1
|
+
import{forceRegistry as e}from"./modules/contracts/lazy.mjs";import{createResolver as t,inspectArchitecture as n,narrowRootDeclaration as r,resolveImport as i}from"./oxlint/architecture.mjs";import{appFile as a,binding as o,componentRoot as s,consumerOptions as c,exportName as l,exportedNames as u,imported as d,isDbWrite as f,isFunctionsImport as p,isTableChain as m,localInitializer as h,metadata as g,propertyName as _,readProvenance as v,sourceVisitors as y,staticString as b}from"./oxlint/ast.mjs";import{reservedDomainFiles as x}from"./oxlint/reserved-files.mjs";import{ownershipRules as S}from"./oxlint/ownership.mjs";import{basename as C,dirname as w,relative as T,sep as E}from"node:path";function D(t={}){for(let n of t.registries??[])e(n);return n(t)}const O=A({...S,"root-wiring-only":{...S[`root-wiring-only`],create(e){let t=a(e)??``;return[`relations.ts`,`querying.ts`].includes(t)?r(t,e.sourceCode.text)?{}:{Program(n){e.report({node:n,messageId:`ownership`,data:{reason:`${t} must export one kit factory declaration and contain only declarative configuration`}})}}:S[`root-wiring-only`].create(e)}},"reserved-domain-file-anatomy":x,"root-facade-ownership":{meta:g(`Configure shared kit infrastructure once in its root facade.`,{facade:`Configure {{name}} once in convex/{{file}}; import that facade elsewhere.`}),create(e){let t=s(e,e.filename),n=/* @__PURE__ */ new Set;function r(r){let i=d(e,r.callee);if(!i)return;let o=null;[`cvx-kit`,`cvx-kit/querying`].includes(i.source)&&i.name===`createQueryEngine`&&(o=`querying.ts`),[`cvx-kit`,`cvx-kit/relations`].includes(i.source)&&i.name===`defineRelations`&&(o=`relations.ts`),[`cvx-kit`,`cvx-kit/auth`].includes(i.source)&&i.name===`createAuthFunctions`&&(o=`functions.ts`),[`cvx-kit`,`cvx-kit/triggers`].includes(i.source)&&i.name===`createTriggers`&&(o=`triggers.ts`),[`cvx-kit`,`cvx-kit/components/foundation`].includes(i.source)&&i.name===`Foundation`&&(o=`foundation.ts`),(i.source===`cvx-kit/effect`&&i.name===`createEffectFoundation`||i.source===`cvx-kit`&&i.name===`createFoundation`)&&(o=`foundation.ts`),o&&(((t?T(t,e.filename).split(E).join(`/`):a(e))!==o||n.has(i.name))&&e.report({node:r,messageId:`facade`,data:{name:i.name,file:o}}),n.add(i.name))}return{CallExpression:r,NewExpression:r}}},"no-raw-builders":{meta:g(`Build host functions through the auth-aware root constructors.`,{builder:`Import raw builders only in convex/functions.ts; use auth*/role*/admin* or system* elsewhere.`}),create(e){let n=s(e,e.filename);if((n?T(n,e.filename).split(E).join(`/`):a(e))===`functions.ts`)return{};let r=t();return{ImportDeclaration(t){if(t.importKind===`type`)return;let o=t.source.value,s=i(r,e.filename,o),c=s?n?T(n,s).split(E).join(`/`):a(e,s):null,u=c?.startsWith(`_generated/`)?c:o;if(/(?:^|\/)_generated\/server(?:\.[cm]?[jt]s)?$/.test(u)||u===`convex/server`)for(let n of t.specifiers){if(n.type===`ImportSpecifier`&&n.importKind===`type`)continue;let t=n.type===`ImportSpecifier`?l(n.imported):null;(t===null&&u!==`convex/server`||t&&/^(?:internal)?(?:Query|Mutation|Action)(?:Generic)?$|^(?:query|mutation|action)(?:Generic)?$/.test(t))&&e.report({node:n,messageId:`builder`})}},CallExpression(t){let n=d(e,t.callee);n?.source===`convex/server`&&/^(?:internal)?(?:Query|Mutation|Action)Generic$|^(?:query|mutation|action)Generic$/.test(n.name)&&t.callee.type===`MemberExpression`&&e.report({node:t,messageId:`builder`})}}}},"no-handwritten-references":{meta:g(`Use generated api/internal references.`,{reference:`Use generated api/internal references instead of makeFunctionReference.`}),create(e){return{CallExpression(t){let n=d(e,t.callee);n?.source===`convex/server`&&n.name===`makeFunctionReference`&&e.report({node:t,messageId:`reference`})}}}},"domain-import-boundaries":{meta:g(`Keep api, application, domain, and shared dependencies directed.`,{boundary:`Follow api → application/domain → shared; sibling modules expose only rules.ts and queries.ts.`}),create(e){let{domainPublicFiles:n}=c.parse(e.options[0]??{}),r=a(e);if(s(e,e.filename))return{};let o=t();return y(e,(t,s)=>{if(!r)return;let c=i(o,e.filename,s);if(!c)return;let l=a(e,c)?.replace(/\.[cm]?[jt]s$/,``);if(!l){c.split(E).includes(`node_modules`)||e.report({node:t,messageId:`boundary`});return}let u=r.split(`/`),d=l.split(`/`),f=!1;u[0]===`domain`?(f=[`api`,`application`,`migrations`].includes(d[0]),d[0]===`domain`&&u[1]!==d[1]&&d[1]!==`shared`&&u[1]!==`table.ts`&&(f=u[1]===`shared`||![`rules`,`queries`,`contracts`].includes(d.slice(2).join(`/`))&&!n[d[1]]?.includes(d.slice(2).join(`/`)))):u[0]===`api`?f=[`api`,`migrations`].includes(d[0])||d[0]===`domain`&&d[1]!==`shared`&&d[1]!==(u.length>2?u[1]:C(r).replace(/\.[cm]?[jt]s$/,``)):u[0]===`application`?f=[`api`,`migrations`].includes(d[0]):[`relations.ts`,`querying.ts`].includes(r)&&d[0]===`domain`&&(f=!(r===`relations.ts`?[`schema`,`table`]:[`queries`,`contracts`]).includes(d.slice(2).join(`/`))&&(r!==`relations.ts`||l!==`domain/table`)),d[0]===`migrations`&&u[0]!==`migrations`&&(f=!0),[`api`,`domain`,`application`].includes(u[0])&&d.length>1&&![`api`,`domain`,`application`,`_generated`,`components`,`migrations`].includes(d[0])&&(f=!0),f&&e.report({node:t,messageId:`boundary`})})}},"public-functions-in-api":{meta:g(`Expose authenticated public functions only through api/.`,{public:`Declare public auth*/role*/admin* functions in convex/api/<module>.ts.`}),create(e){return a(e)?.startsWith(`api/`)?{}:{CallExpression(t){let n=d(e,t.callee);t.callee.type!==`CallExpression`&&n&&p(e,n.source)&&/^(auth|role|admin)(Query|Mutation|Action)$/.test(n.name)&&e.report({node:t,messageId:`public`})}}}},"thin-api-adapters":{meta:g(`Keep business decisions and writes in domain executors.`,{adapter:`Move business branches, private helpers, and database writes into the owning domain executor.`}),create(e){return a(e)?.startsWith(`api/`)?{IfStatement(t){e.report({node:t,messageId:`adapter`})},SwitchStatement(t){e.report({node:t,messageId:`adapter`})},ConditionalExpression(t){e.report({node:t,messageId:`adapter`})},Program(t){let n=u(t);for(let r of t.body)if(r.type===`FunctionDeclaration`&&r.id&&!n.has(r.id.name)&&e.report({node:r,messageId:`adapter`}),r.type===`VariableDeclaration`)for(let t of r.declarations)t.id.type===`Identifier`&&!n.has(t.id.name)&&[`ArrowFunctionExpression`,`FunctionExpression`].includes(t.init?.type??``)&&e.report({node:t,messageId:`adapter`})},CallExpression(t){f(t)&&e.report({node:t,messageId:`adapter`})}}:{}}},"no-inline-enums":{meta:g(`Keep vocabularies in named constants.ts tuples.`,{vocabulary:`Define a named readonly tuple in constants.ts and pass it to z.enum().`}),create(e){return{CallExpression(t){let n=d(e,t.callee),r=t.arguments[0];for(;r?.type===`TSAsExpression`||r?.type===`TSSatisfiesExpression`;)r=r.expression;n&&/^zod(?:\/v4)?$/.test(n.source)&&n.name===`enum`&&r?.type===`ArrayExpression`&&e.report({node:t,messageId:`vocabulary`})}}}},"no-unbounded-reads":{meta:g(`Bound collection reads through include or pagination.`,{bounded:`Use include(...).execute(limit) or bounded pagination; do not collect() or resolve() an unbounded query.`,order:`Apply eligibility filters in the indexed query before take(), execute(), or paginate(); filtering a bounded result can omit eligible rows. Do not move the predicate automatically.`}),create(e){return{CallExpression(t){if(t.callee.type!==`MemberExpression`)return;let n=_(t.callee),r=v(e,t.callee.object);n===`filter`&&r===`bounded`&&e.report({node:t,messageId:`order`}),(n===`collect`&&(r===`stream`||r===`relationship`)||n===`resolve`&&r===`stream`)&&e.report({node:t,messageId:`bounded`})}}}},"no-manual-id-projection":{meta:g(`Use the table DTO boundary to project public IDs.`,{projection:`Use toPublicDto(row, true) to include _id; do not add IDs manually after a table DTO parse or projection.`}),create(e){return{ObjectExpression(t){if(t.properties.some(t=>t.type===`SpreadElement`&&v(e,t.argument)===`dto`))for(let n of t.properties)n.type===`Property`&&[`id`,`_id`].includes((n.computed?b(n.key):l(n.key))??``)&&e.report({node:n,messageId:`projection`})},AssignmentExpression(t){t.left.type===`MemberExpression`&&[`id`,`_id`].includes(_(t.left)??``)&&v(e,t.left.object)===`dto`&&e.report({node:t,messageId:`projection`})}}}},"no-copied-pagination":{meta:g(`Use native or table pagination schemas instead of copying their shape.`,{pagination:`Use the native paginationOptsValidator (or paginated(table.dto())) for native pagination, or table.paginationOpts(selection) for table queries; do not copy pagination fields.`}),create(e){return{CallExpression(t){let n=d(e,t.callee);if(!(n?.name===`object`&&[`zod`,`zod/v4`,`convex/values`].includes(n.source)))return;let r=t.arguments[0],i=r&&(h(e,r)??r);if(i?.type!==`ObjectExpression`)return;let a=new Set(i.properties.flatMap(e=>e.type===`Property`?[e.computed?b(e.key):l(e.key)]:[]));(a.has(`numItems`)&&a.has(`cursor`)||[`page`,`isDone`,`continueCursor`].every(e=>a.has(e)))&&e.report({node:t,messageId:`pagination`})}}}},"no-manual-timestamps":{meta:g(`Let timestamps triggers own createdAt and updatedAt.`,{timestamp:`Remove {{field}} from this write; register the timestamps trigger instead.`}),create(e){return{CallExpression(t){if(!f(t))return;let n=t.arguments.at(-1);if(n?.type===`ObjectExpression`)for(let t of n.properties){if(t.type!==`Property`)continue;let n=t.computed?b(t.key):l(t.key);(n===`createdAt`||n===`updatedAt`)&&e.report({node:t,messageId:`timestamp`,data:{field:n}})}}}}},"component-boundaries":{meta:g(`Keep portable components isolated and consume their client facades.`,{boundary:`Components may import only their own files and npm dependencies; inject host policy through the client API.`,facade:`Import a component through its client.ts facade, not its private implementation.`}),create(e){let n=s(e,e.filename),r=t(!1);return y(e,(t,o)=>{o.startsWith(`.`)||/^cvx-kit\/components\/[^/]+\//.test(o)&&!/^cvx-kit\/components\/[^/]+\/convex\.config(?:\.js)?$/.test(o)&&e.report({node:t,messageId:`facade`});let c=i(r,e.filename,o);c&&!c.split(E).includes(`node_modules`)&&(n&&(T(n,c).startsWith(`..${E}`)||c===w(n))?e.report({node:t,messageId:`boundary`}):!n&&s(e,c)&&!/^client(?:\.[cm]?[jt]s)?$/.test(C(c))&&!(a(e)===`convex.config.ts`&&/^convex\.config(?:\.[cm]?[jt]s)?$/.test(C(c)))&&e.report({node:t,messageId:`facade`}))})}},"no-component-env":{meta:g(`Pass environment configuration into portable components.`,{env:`Portable components must receive configuration through arguments; do not read process.env.`}),create(e){if(!s(e,e.filename))return{};function t(t){if(t.type!==`Identifier`)return!1;let n=o(e,t);return t.name===`process`&&!n?.defs.length||n?.defs.some(e=>e.type===`ImportBinding`&&e.parent?.type===`ImportDeclaration`&&[`node:process`,`process`].includes(e.parent.source.value)&&[`ImportDefaultSpecifier`,`ImportNamespaceSpecifier`].includes(e.node.type))}return{ImportDeclaration(t){if([`node:process`,`process`].includes(t.source.value))for(let n of t.specifiers)n.type===`ImportSpecifier`&&l(n.imported)===`env`&&e.report({node:n,messageId:`env`})},MemberExpression(n){if(_(n)!==`env`)return;let r=n.object,i=r.type===`MemberExpression`&&_(r)===`process`&&r.object.type===`Identifier`&&r.object.name===`globalThis`&&!o(e,r.object)?.defs.length;(t(r)||i)&&e.report({node:n,messageId:`env`})},VariableDeclarator(n){if(n.init&&t(n.init)&&n.id.type===`ObjectPattern`)for(let t of n.id.properties)t.type===`Property`&&(t.computed?b(t.key):l(t.key))===`env`&&e.report({node:t,messageId:`env`})}}}},"schema-file-boundaries":{meta:g(`Keep storage shapes and indexes in their documented owners.`,{schema:`{{builder}} belongs in {{file}}.`}),create(e){return{CallExpression(t){let n=d(e,t.callee),r=a(e);if(!r)return;let i=null;n?.source===`convex/server`&&(n.name===`defineSchema`&&r!==`schema.ts`&&!(s(e,e.filename)&&C(r)===`schema.ts`)&&(i=`the root schema.ts (or a component schema.ts)`),n.name===`defineTable`&&!(s(e,e.filename)&&[`schema.ts`,`table.ts`].includes(C(r)))&&(i=`a component schema.ts/table.ts; host tables use zodTable in domain/<module>/schema.ts`)),n&&[`cvx-kit`,`cvx-kit/zod-table`].includes(n.source)&&[`zodTable`,`tenantTable`,`zodVariantTable`].includes(n.name)&&!/^domain\/[^/]+\/schema\.ts$/.test(r)&&!(s(e,e.filename)&&[`schema.ts`,`table.ts`].includes(C(r)))&&(i=`domain/<module>/schema.ts or a component schema.ts/table.ts`),i&&e.report({node:t,messageId:`schema`,data:{builder:n?.name??`table`,file:i}}),t.callee.type===`MemberExpression`&&[`index`,`searchIndex`,`vectorIndex`].includes(_(t.callee)??``)&&m(t.callee.object)&&!(s(e,e.filename)?C(r)===`table.ts`:/^domain\/[^/]+\/table\.ts$/.test(r))&&e.report({node:t,messageId:`schema`,data:{builder:`Table indexes`,file:s(e,e.filename)?`a component table.ts`:`domain/<module>/table.ts`}})}}}},"no-internal-reexports":{meta:g(`Import from owning modules directly; consumer apps have no barrels.`,{reexport:`Import from the owning file directly; do not re-export imports inside convex/.`}),create(e){function t(t){if(t.source){e.report({node:t,messageId:`reexport`});return}for(let n of t.type===`ExportNamedDeclaration`?t.specifiers:[])o(e,n.local)?.defs.some(e=>e.type===`ImportBinding`)&&e.report({node:n,messageId:`reexport`})}return{ExportNamedDeclaration:t,ExportAllDeclaration:t,ExportDefaultDeclaration(t){t.declaration.type===`Identifier`&&o(e,t.declaration)?.defs.some(e=>e.type===`ImportBinding`)&&e.report({node:t,messageId:`reexport`})}}}},"public-api-first":{meta:g(`Place private helper implementations after the exported API.`,{order:`Move this private helper below the exported API so the file reads from public purpose to implementation.`}),create(e){return{Program(t){let n=u(t),r=t.body.findLastIndex(e=>e.type.startsWith(`Export`));for(let i of t.body.slice(0,r<0?0:r))i.type===`FunctionDeclaration`&&i.id&&!n.has(i.id.name)&&e.report({node:i,messageId:`order`})}}}},"named-private-helpers":{meta:g(`Use named declarations for top-level private helper functions.`,{helper:`Declare this private helper with function name(...) at the bottom of the file.`}),create(e){return{Program(t){let n=u(t);for(let r of t.body)if(r.type===`VariableDeclaration`)for(let t of r.declarations)t.id.type===`Identifier`&&!n.has(t.id.name)&&(t.init?.type===`ArrowFunctionExpression`||t.init?.type===`FunctionExpression`)&&e.report({node:t,messageId:`helper`})}}}}}),k={meta:{name:`cvx`},rules:O};function A(e){let t={...e},n=Object.keys(e);for(let r of n){let n={convexDir:{type:`string`,minLength:1},componentDirs:{type:`array`,items:{type:`string`,minLength:1}}},i=e[r];t[r]={meta:{...i.meta,schema:[{type:`object`,properties:r===`domain-import-boundaries`?{...n,domainPublicFiles:{type:`object`,additionalProperties:{type:`array`,items:{type:`string`,minLength:1}}}}:n,additionalProperties:!1}]},create(e){let t=a(e);return!t||/(?:^|\/)(?:_generated|__tests__)(?:\/|$)/.test(t)||/\.(?:test|spec)\.[cm]?[jt]s$/.test(t)?{}:i.create(e)}}}return t}export{D as checkArchitecture,k as default,O as rules};
|
|
2
2
|
//# sourceMappingURL=oxlint.mjs.map
|