cvx-kit 0.1.32 → 0.1.33
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.
|
@@ -1,2 +1,2 @@
|
|
|
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);
|
|
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`||n?.source===`cvx-kit/zod-table`&&n.name===`namespaceIndex`||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","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,EAAS,6EAA8E,CAC5F,UACC,qGACF,CAAC,EACD,OAAO,EAAS,CACf,IAAMW,EAAOC,EAAQT,CAAO,EAC5B,GAAI,CAACQ,GAAQA,EAAK,SAAS,GAAG,EAAG,MAAO,CAAC,EACzC,IAAIF,EAA4B,KAC5BI,EAAS,0BACTC,EAAkB,GAChBC,EACL,iIAAiI,KAChIJ,CACD,EACD,SAASK,EAAK,EAAmB,CAChC,IAAUC,CACX,CACA,MAAO,CACN,QAAQ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,OAAS,cAC5B,CAACuC,EAAQrD,EAASc,EAAK,OAAO,MAAM,CAAC,EAAE,KAAK,SAC1CA,EAAK,OAAO,OAAO,OAAS,QAAUoC,IAAW,OACjDpC,EAAK,OAAO,OAAO,OAAS,QAAUoC,IAAW,WAEnDrC,EAAKC,CAAI,CACX,EACA,SAAS,EAAM,CAEb8B,IAAS,aACT,CAAC,UAAW,UAAW,QAAS,UAAW,aAAc,OAAO,CAAC,CAAC,SACjE9B,EAAK,IAAI,OAAS,aACfA,EAAK,IAAI,KACT,OAAOA,EAAK,IAAI,OAAS,UAAYA,EAAK,IAAI,MAAQ,EAAE,CAC5D,GAEAD,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\tconst assemblyCall =\n\t\t\t\t\t\t\t(ref?.source === 'cvx-kit/zod-table' && ref.name === 'createModule') ||\n\t\t\t\t\t\t\t(ref?.source === 'cvx-kit/zod-table' && ref.name === 'namespaceIndex')\n\t\t\t\t\t\tif (!assemblyCall) 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,EAA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AAK,IAAI,MAAQ,EAAE,CAC5D,GAEAD,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,2 +1,2 @@
|
|
|
1
|
-
import{createResolver as e,resolveImport as t}from"./architecture.mjs";import{appFile as n,exportName as r,metadata as i,propertyName as a}from"./ast.mjs";import{readFileSync as o}from"node:fs";import{parseSync as s}from"oxc-parser";const c={meta:i(`Require kit-backed declarations in reserved domain files.`,{anatomy:`{{file}} must export {{expected}} built with cvx-kit; imports or local lookalikes do not count.`}),create(e){let t=n(e)??``,r=t.match(/^domain\/(?:.+\/)?(commands|queries|contracts|schema|table)\.ts$/);if(!r)return{};let i=r[1];return{Program(n){let r=u(e,n,e.filename),a=l(n).map(e=>r(e)),o=i===`commands`?`one Command registry`:i===`queries`?`one Query registry`:i===`schema`?`zodTable shapes`:i===`contracts`?`declarative contracts`:t===`domain/table.ts`?`createModule assembly`:`a table topology map`,s=i===`commands`?`registry:Command`:i===`queries`?`registry:Query`:i===`schema`?`shape`:i===`contracts`?`contract`:t===`domain/table.ts`?`assembly`:`topology`,c=a.filter(e=>e===s).length;(i===`commands`||i===`queries`?c===1:c>0)||e.report({node:n,messageId:`anatomy`,data:{file:t,expected:o}})}}}};function l(e){let t=[],n=/* @__PURE__ */ new Map;for(let r of e.body){let e=r.type===`ExportNamedDeclaration`?r.declaration:r;if(e?.type===`VariableDeclaration`&&e.kind===`const`)for(let i of e.declarations)i.id.type===`Identifier`&&i.init&&(n.set(i.id.name,i.init),r.type===`ExportNamedDeclaration`&&t.push(i.init))}for(let i of e.body){if(i.type===`ExportNamedDeclaration`&&i.exportKind!==`type`&&!i.source)for(let e of i.specifiers){if(e.exportKind===`type`)continue;let i=n.get(r(e.local)??``);i&&t.push(i)}i.type===`ExportDefaultDeclaration`&&i.declaration.type!==`FunctionDeclaration`&&i.declaration.type!==`ClassDeclaration`&&i.declaration.type!==`TSInterfaceDeclaration`&&t.push(i.declaration)}return t}function u(i,c,l,d=/* @__PURE__ */ new Set){let f=/* @__PURE__ */ new Map,p=/* @__PURE__ */ new Map,m=e();for(let e of c.body){if(e.type===`ImportDeclaration`&&e.importKind!==`type`)for(let t of e.specifiers)(t.type!==`ImportSpecifier`||t.importKind!==`type`)&&f.set(t.local.name,{source:e.source.value,name:t.type===`ImportSpecifier`?r(t.imported)??``:t.type===`ImportNamespaceSpecifier`?`*`:`default`});let t=e.type===`ExportNamedDeclaration`?e.declaration:e;if(t?.type===`VariableDeclaration`&&t.kind===`const`){for(let e of t.declarations)if(e.init&&(e.id.type===`Identifier`&&p.set(e.id.name,{expression:e.init}),e.id.type===`ObjectPattern`))for(let t of e.id.properties)t.type===`Property`&&t.value.type===`Identifier`&&p.set(t.value.name,{expression:e.init,member:r(t.key)??``})}}function h(e,a){if([`cvx-kit`,`cvx-kit/effect`,`cvx-kit/components/foundation`,`cvx-kit/contracts`,`cvx-kit/zod-table`,`cvx-kit/errors`].includes(e))return a===`*`?`namespace:${e}`:e===`cvx-kit/effect`&&a===`createEffectFoundation`||e===`cvx-kit`&&a===`createFoundation`||[`cvx-kit`,`cvx-kit/components/foundation`].includes(e)&&a===`Foundation`?`foundationFactory`:[`cvx-kit`,`cvx-kit/zod-table`].includes(e)&&[`zodTable`,`zodVariantTable`].includes(a)?`shapeFactory`:[`cvx-kit`,`cvx-kit/zod-table`].includes(e)&&a===`createModule`?`assemblyFactory`:e===`cvx-kit/contracts`&&[`defineDomainContract`,`operationContract`].includes(a)||e===`cvx-kit/errors`&&a===`defineErrorContract`?`contractFactory`:null;if([`zod`,`zod/v4`,`convex/values`].includes(e))return`validator`;let c=t(m,l,e),f=c&&n(i,c);if(!c||!f||!/^(?:foundation\.ts|domain\/.+\/(?:schema|contracts)\.ts)$/.test(f)||d.has(c)||d.size>=6)return null;if(a===`*`)return`namespace:${e}`;let p=s(c,o(c,`utf8`));if(p.errors.length)return null;let h=p.program,g=u(i,h,c,new Set(d).add(c));for(let e of h.body)if(e.type===`ExportNamedDeclaration`&&e.exportKind!==`type`){if(e.declaration?.type===`VariableDeclaration`)for(let t of e.declaration.declarations){if(t.id.type===`Identifier`&&t.id.name===a)return g(t.id);if(t.id.type===`ObjectPattern`){for(let e of t.id.properties)if(e.type===`Property`&&e.value.type===`Identifier`&&e.value.name===a)return g(e.value)}}for(let t of e.specifiers)if(t.exportKind!==`type`&&r(t.exported)===a&&!e.source)return g(t.local)}return null}function g(e,t){return e===`foundation`&&[`Command`,`Query`].includes(t)?t:e?.startsWith(`namespace:`)?h(e.slice(10),t):e===`validator`||e===`contract`?`validator`:e===`shape`&&t===`table`?`table`:e===`table`&&[`index`,`searchIndex`,`vectorIndex`].includes(t)?`indexFactory`:null}function _(e,t=/* @__PURE__ */ new Set){if(e.type===`TSAsExpression`||e.type===`TSSatisfiesExpression`||e.type===`TSNonNullExpression`)return _(e.expression,t);if(e.type===`Identifier`){if(t.has(e.name))return null;let n=f.get(e.name);if(n)return h(n.source,n.name);let r=p.get(e.name);if(!r)return null;let i=_(r.expression,new Set(t).add(e.name));return r.member?g(i,r.member):i}if(e.type===`MemberExpression`)return g(_(e.object,t),a(e)??``);if(e.type===`CallExpression`||e.type===`NewExpression`){let n=_(e.callee,t);
|
|
1
|
+
import{createResolver as e,resolveImport as t}from"./architecture.mjs";import{appFile as n,exportName as r,metadata as i,propertyName as a}from"./ast.mjs";import{readFileSync as o}from"node:fs";import{parseSync as s}from"oxc-parser";const c={meta:i(`Require kit-backed declarations in reserved domain files.`,{anatomy:`{{file}} must export {{expected}} built with cvx-kit; imports or local lookalikes do not count.`}),create(e){let t=n(e)??``,r=t.match(/^domain\/(?:.+\/)?(commands|queries|contracts|schema|table)\.ts$/);if(!r)return{};let i=r[1];return{Program(n){let r=u(e,n,e.filename),a=l(n).map(e=>r(e)),o=i===`commands`?`one Command registry`:i===`queries`?`one Query registry`:i===`schema`?`zodTable shapes`:i===`contracts`?`declarative contracts`:t===`domain/table.ts`?`createModule assembly`:`a table topology map`,s=i===`commands`?`registry:Command`:i===`queries`?`registry:Query`:i===`schema`?`shape`:i===`contracts`?`contract`:t===`domain/table.ts`?`assembly`:`topology`,c=a.filter(e=>e===s).length;(i===`commands`||i===`queries`?c===1:c>0)||e.report({node:n,messageId:`anatomy`,data:{file:t,expected:o}})}}}};function l(e){let t=[],n=/* @__PURE__ */ new Map;for(let r of e.body){let e=r.type===`ExportNamedDeclaration`?r.declaration:r;if(e?.type===`VariableDeclaration`&&e.kind===`const`)for(let i of e.declarations)i.id.type===`Identifier`&&i.init&&(n.set(i.id.name,i.init),r.type===`ExportNamedDeclaration`&&t.push(i.init))}for(let i of e.body){if(i.type===`ExportNamedDeclaration`&&i.exportKind!==`type`&&!i.source)for(let e of i.specifiers){if(e.exportKind===`type`)continue;let i=n.get(r(e.local)??``);i&&t.push(i)}i.type===`ExportDefaultDeclaration`&&i.declaration.type!==`FunctionDeclaration`&&i.declaration.type!==`ClassDeclaration`&&i.declaration.type!==`TSInterfaceDeclaration`&&t.push(i.declaration)}return t}function u(i,c,l,d=/* @__PURE__ */ new Set){let f=/* @__PURE__ */ new Map,p=/* @__PURE__ */ new Map,m=e();for(let e of c.body){if(e.type===`ImportDeclaration`&&e.importKind!==`type`)for(let t of e.specifiers)(t.type!==`ImportSpecifier`||t.importKind!==`type`)&&f.set(t.local.name,{source:e.source.value,name:t.type===`ImportSpecifier`?r(t.imported)??``:t.type===`ImportNamespaceSpecifier`?`*`:`default`});let t=e.type===`ExportNamedDeclaration`?e.declaration:e;if(t?.type===`VariableDeclaration`&&t.kind===`const`){for(let e of t.declarations)if(e.init&&(e.id.type===`Identifier`&&p.set(e.id.name,{expression:e.init}),e.id.type===`ObjectPattern`))for(let t of e.id.properties)t.type===`Property`&&t.value.type===`Identifier`&&p.set(t.value.name,{expression:e.init,member:r(t.key)??``})}}function h(e,a){if([`cvx-kit`,`cvx-kit/effect`,`cvx-kit/components/foundation`,`cvx-kit/contracts`,`cvx-kit/zod-table`,`cvx-kit/errors`].includes(e))return a===`*`?`namespace:${e}`:e===`cvx-kit/effect`&&a===`createEffectFoundation`||e===`cvx-kit`&&a===`createFoundation`||[`cvx-kit`,`cvx-kit/components/foundation`].includes(e)&&a===`Foundation`?`foundationFactory`:[`cvx-kit`,`cvx-kit/zod-table`].includes(e)&&[`zodTable`,`zodVariantTable`].includes(a)?`shapeFactory`:[`cvx-kit`,`cvx-kit/zod-table`].includes(e)&&a===`createModule`?`assemblyFactory`:e===`cvx-kit/zod-table`&&a===`namespace`?`namespaceFactory`:e===`cvx-kit/contracts`&&[`defineDomainContract`,`operationContract`].includes(a)||e===`cvx-kit/errors`&&a===`defineErrorContract`?`contractFactory`:null;if([`zod`,`zod/v4`,`convex/values`].includes(e))return`validator`;let c=t(m,l,e),f=c&&n(i,c);if(!c||!f||!/^(?:foundation\.ts|domain\/.+\/(?:schema|contracts)\.ts)$/.test(f)||d.has(c)||d.size>=6)return null;if(a===`*`)return`namespace:${e}`;let p=s(c,o(c,`utf8`));if(p.errors.length)return null;let h=p.program,g=u(i,h,c,new Set(d).add(c));for(let e of h.body)if(e.type===`ExportNamedDeclaration`&&e.exportKind!==`type`){if(e.declaration?.type===`VariableDeclaration`)for(let t of e.declaration.declarations){if(t.id.type===`Identifier`&&t.id.name===a)return g(t.id);if(t.id.type===`ObjectPattern`){for(let e of t.id.properties)if(e.type===`Property`&&e.value.type===`Identifier`&&e.value.name===a)return g(e.value)}}for(let t of e.specifiers)if(t.exportKind!==`type`&&r(t.exported)===a&&!e.source)return g(t.local)}return null}function g(e,t){return e===`foundation`&&[`Command`,`Query`].includes(t)?t:e?.startsWith(`namespace:`)?h(e.slice(10),t):e===`validator`||e===`contract`?`validator`:e===`shape`&&t===`table`?`table`:e===`table`&&[`index`,`searchIndex`,`vectorIndex`].includes(t)?`indexFactory`:null}function _(e,t=/* @__PURE__ */ new Set){if(e.type===`TSAsExpression`||e.type===`TSSatisfiesExpression`||e.type===`TSNonNullExpression`)return _(e.expression,t);if(e.type===`Identifier`){if(t.has(e.name))return null;let n=f.get(e.name);if(n)return h(n.source,n.name);let r=p.get(e.name);if(!r)return null;let i=_(r.expression,new Set(t).add(e.name));return r.member?g(i,r.member):i}if(e.type===`MemberExpression`)return g(_(e.object,t),a(e)??``);if(e.type===`CallExpression`||e.type===`NewExpression`){let n=_(e.callee,t);if(n===`foundationFactory`)return`foundation`;if(n===`Command`||n===`Query`)return`registry:${n}`;if(n===`shapeFactory`)return`shape`;if(n===`assemblyFactory`)return`assembly`;if(n===`contractFactory`||n===`validator`)return`contract`;if(n===`indexFactory`)return`table`;if(n===`namespaceFactory`){let n=e.arguments[1];if(n?.type!==`ObjectExpression`)return null;let r=n.properties.map(e=>e.type===`Property`?_(e.value,t):null);return r.length&&r.every(e=>e===`table`||e===`topology`||e===`shape`)?`topology`:null}return null}if(e.type===`ObjectExpression`){let n=e.properties.map(e=>e.type===`Property`?_(e.value,t):null);if(n.length&&n.every(e=>e===`table`||e===`topology`))return`topology`;if(n.some(e=>e===`contract`||e===`validator`)&&n.every(e=>e===`contract`||e===`validator`||e===`data`))return`contract`;if(n.every(e=>e===`data`))return`data`}return e.type===`Literal`?`data`:null}return _}export{c as reservedDomainFiles};
|
|
2
2
|
//# sourceMappingURL=reserved-files.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reserved-files.mjs","names":["reservedDomainFiles","metadata","file","appFile","context","match","role","evaluate","provenance","program","values","publicExpressions","expression","expected","wanted","count","value","expressions","declarations","statement","declaration","item","specifier","exportName","imports","variables","resolver","createResolver","property","imported","source","name","target","resolveImport","filename","visited","parsed","parseSync","readFileSync","remote","evaluateRemote","member","owner","node","active","reference","variable","propertyName","callee"],"sources":["../../src/oxlint/reserved-files.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport type { Context, CreateRule, ESTree } from '@oxlint/plugins'\nimport { parseSync } from 'oxc-parser'\nimport { appFile, metadata, propertyName, exportName } from './ast'\nimport { createResolver, resolveImport } from './architecture'\n\n/** Reserved files prove their exported declaration's provenance, not an unused import. */\nexport const reservedDomainFiles: CreateRule = {\n\tmeta: metadata('Require kit-backed declarations in reserved domain files.', {\n\t\tanatomy:\n\t\t\t'{{file}} must export {{expected}} built with cvx-kit; imports or local lookalikes do not count.',\n\t}),\n\tcreate(context) {\n\t\tconst file = appFile(context) ?? ''\n\t\tconst match = file.match(/^domain\\/(?:.+\\/)?(commands|queries|contracts|schema|table)\\.ts$/)\n\t\tif (!match) return {}\n\t\tconst role = match[1]\n\t\treturn {\n\t\t\tProgram(program) {\n\t\t\t\tconst evaluate = provenance(context, program, context.filename)\n\t\t\t\tconst exports = publicExpressions(program)\n\t\t\t\tconst values = exports.map((expression) => evaluate(expression))\n\t\t\t\tconst expected =\n\t\t\t\t\trole === 'commands'\n\t\t\t\t\t\t? 'one Command registry'\n\t\t\t\t\t\t: role === 'queries'\n\t\t\t\t\t\t\t? 'one Query registry'\n\t\t\t\t\t\t\t: role === 'schema'\n\t\t\t\t\t\t\t\t? 'zodTable shapes'\n\t\t\t\t\t\t\t\t: role === 'contracts'\n\t\t\t\t\t\t\t\t\t? 'declarative contracts'\n\t\t\t\t\t\t\t\t\t: file === 'domain/table.ts'\n\t\t\t\t\t\t\t\t\t\t? 'createModule assembly'\n\t\t\t\t\t\t\t\t\t\t: 'a table topology map'\n\t\t\t\tconst wanted =\n\t\t\t\t\trole === 'commands'\n\t\t\t\t\t\t? 'registry:Command'\n\t\t\t\t\t\t: role === 'queries'\n\t\t\t\t\t\t\t? 'registry:Query'\n\t\t\t\t\t\t\t: role === 'schema'\n\t\t\t\t\t\t\t\t? 'shape'\n\t\t\t\t\t\t\t\t: role === 'contracts'\n\t\t\t\t\t\t\t\t\t? 'contract'\n\t\t\t\t\t\t\t\t\t: file === 'domain/table.ts'\n\t\t\t\t\t\t\t\t\t\t? 'assembly'\n\t\t\t\t\t\t\t\t\t\t: 'topology'\n\t\t\t\tconst count = values.filter((value) => value === wanted).length\n\t\t\t\tconst valid = role === 'commands' || role === 'queries' ? count === 1 : count > 0\n\t\t\t\tif (!valid)\n\t\t\t\t\tcontext.report({ node: program, messageId: 'anatomy', data: { file, expected } })\n\t\t\t},\n\t\t}\n\t},\n}\n\nfunction publicExpressions(program: ESTree.Program): ESTree.Expression[] {\n\tconst expressions: ESTree.Expression[] = []\n\tconst declarations = new Map<string, ESTree.Expression>()\n\tfor (const statement of program.body) {\n\t\tconst declaration =\n\t\t\tstatement.type === 'ExportNamedDeclaration' ? statement.declaration : statement\n\t\tif (declaration?.type === 'VariableDeclaration' && declaration.kind === 'const')\n\t\t\tfor (const item of declaration.declarations) {\n\t\t\t\tif (item.id.type === 'Identifier' && item.init) {\n\t\t\t\t\tdeclarations.set(item.id.name, item.init)\n\t\t\t\t\tif (statement.type === 'ExportNamedDeclaration') expressions.push(item.init)\n\t\t\t\t}\n\t\t\t}\n\t}\n\tfor (const statement of program.body) {\n\t\tif (\n\t\t\tstatement.type === 'ExportNamedDeclaration' &&\n\t\t\tstatement.exportKind !== 'type' &&\n\t\t\t!statement.source\n\t\t)\n\t\t\tfor (const specifier of statement.specifiers) {\n\t\t\t\tif (specifier.exportKind === 'type') continue\n\t\t\t\tconst expression = declarations.get(exportName(specifier.local) ?? '')\n\t\t\t\tif (expression) expressions.push(expression)\n\t\t\t}\n\t\tif (\n\t\t\tstatement.type === 'ExportDefaultDeclaration' &&\n\t\t\tstatement.declaration.type !== 'FunctionDeclaration' &&\n\t\t\tstatement.declaration.type !== 'ClassDeclaration' &&\n\t\t\tstatement.declaration.type !== 'TSInterfaceDeclaration'\n\t\t) {\n\t\t\texpressions.push(statement.declaration)\n\t\t}\n\t}\n\treturn expressions\n}\n\nfunction provenance(\n\tcontext: Context,\n\tprogram: ESTree.Program,\n\tfilename: string,\n\tvisited = new Set<string>(),\n) {\n\tconst imports = new Map<string, { source: string; name: string }>()\n\tconst variables = new Map<string, { expression: ESTree.Expression; member?: string }>()\n\tconst resolver = createResolver()\n\tfor (const statement of 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') continue\n\t\t\t\timports.set(specifier.local.name, {\n\t\t\t\t\tsource: statement.source.value,\n\t\t\t\t\tname:\n\t\t\t\t\t\tspecifier.type === 'ImportSpecifier'\n\t\t\t\t\t\t\t? (exportName(specifier.imported) ?? '')\n\t\t\t\t\t\t\t: specifier.type === 'ImportNamespaceSpecifier'\n\t\t\t\t\t\t\t\t? '*'\n\t\t\t\t\t\t\t\t: 'default',\n\t\t\t\t})\n\t\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 === 'Identifier') variables.set(item.id.name, { expression: item.init })\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')\n\t\t\t\t\t\t\tvariables.set(property.value.name, {\n\t\t\t\t\t\t\t\texpression: item.init,\n\t\t\t\t\t\t\t\tmember: exportName(property.key) ?? '',\n\t\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t}\n\t}\n\tfunction imported(source: string, name: string): string | null {\n\t\tif (\n\t\t\t[\n\t\t\t\t'cvx-kit',\n\t\t\t\t'cvx-kit/effect',\n\t\t\t\t'cvx-kit/components/foundation',\n\t\t\t\t'cvx-kit/contracts',\n\t\t\t\t'cvx-kit/zod-table',\n\t\t\t\t'cvx-kit/errors',\n\t\t\t].includes(source)\n\t\t) {\n\t\t\tif (name === '*') return `namespace:${source}`\n\t\t\tif (\n\t\t\t\t(source === 'cvx-kit/effect' && name === 'createEffectFoundation') ||\n\t\t\t\t(source === 'cvx-kit' && name === 'createFoundation') ||\n\t\t\t\t(['cvx-kit', 'cvx-kit/components/foundation'].includes(source) && name === 'Foundation')\n\t\t\t)\n\t\t\t\treturn 'foundationFactory'\n\t\t\tif (\n\t\t\t\t['cvx-kit', 'cvx-kit/zod-table'].includes(source) &&\n\t\t\t\t['zodTable', 'zodVariantTable'].includes(name)\n\t\t\t)\n\t\t\t\treturn 'shapeFactory'\n\t\t\tif (['cvx-kit', 'cvx-kit/zod-table'].includes(source) && name === 'createModule')\n\t\t\t\treturn 'assemblyFactory'\n\t\t\tif (\n\t\t\t\tsource === 'cvx-kit/contracts' &&\n\t\t\t\t['defineDomainContract', 'operationContract'].includes(name)\n\t\t\t)\n\t\t\t\treturn 'contractFactory'\n\t\t\tif (source === 'cvx-kit/errors' && name === 'defineErrorContract') return 'contractFactory'\n\t\t\treturn null\n\t\t}\n\t\tif (['zod', 'zod/v4', 'convex/values'].includes(source)) return 'validator'\n\t\tconst target = resolveImport(resolver, filename, source)\n\t\tconst file = target && appFile(context, target)\n\t\tif (\n\t\t\t!target ||\n\t\t\t!file ||\n\t\t\t!/^(?:foundation\\.ts|domain\\/.+\\/(?:schema|contracts)\\.ts)$/.test(file) ||\n\t\t\tvisited.has(target) ||\n\t\t\tvisited.size >= 6\n\t\t)\n\t\t\treturn null\n\t\tif (name === '*') return `namespace:${source}`\n\t\tconst parsed = parseSync(target, readFileSync(target, 'utf8'))\n\t\tif (parsed.errors.length) return null\n\t\t// SAFETY: oxc-parser and the rule API share these declaration fields; provenance never reads rule-API loc/tokens.\n\t\t// oxlint-disable-next-line anti-slop/no-chained-type-assertions\n\t\tconst remote = parsed.program as unknown as ESTree.Program\n\t\tconst nextVisited = new Set(visited).add(target)\n\t\tconst evaluateRemote = provenance(context, remote, target, nextVisited)\n\t\tfor (const statement of remote.body) {\n\t\t\tif (statement.type !== 'ExportNamedDeclaration' || statement.exportKind === 'type') continue\n\t\t\tif (statement.declaration?.type === 'VariableDeclaration')\n\t\t\t\tfor (const item of statement.declaration.declarations) {\n\t\t\t\t\tif (item.id.type === 'Identifier' && item.id.name === name) return evaluateRemote(item.id)\n\t\t\t\t\tif (item.id.type === 'ObjectPattern')\n\t\t\t\t\t\tfor (const property of item.id.properties)\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tproperty.type === 'Property' &&\n\t\t\t\t\t\t\t\tproperty.value.type === 'Identifier' &&\n\t\t\t\t\t\t\t\tproperty.value.name === name\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\treturn evaluateRemote(property.value)\n\t\t\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\texportName(specifier.exported) === name &&\n\t\t\t\t\t!statement.source\n\t\t\t\t)\n\t\t\t\t\treturn evaluateRemote(specifier.local)\n\t\t}\n\t\treturn null\n\t}\n\tfunction member(owner: string | null, name: string): string | null {\n\t\tif (owner === 'foundation' && ['Command', 'Query'].includes(name)) return name\n\t\tif (owner?.startsWith('namespace:')) return imported(owner.slice(10), name)\n\t\tif (owner === 'validator' || owner === 'contract') return 'validator'\n\t\tif (owner === 'shape' && name === 'table') return 'table'\n\t\tif (owner === 'table' && ['index', 'searchIndex', 'vectorIndex'].includes(name))\n\t\t\treturn 'indexFactory'\n\t\treturn null\n\t}\n\tfunction evaluate(node: ESTree.Node, active = new Set<string>()): string | null {\n\t\tif (\n\t\t\tnode.type === 'TSAsExpression' ||\n\t\t\tnode.type === 'TSSatisfiesExpression' ||\n\t\t\tnode.type === 'TSNonNullExpression'\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)) return null\n\t\t\tconst reference = imports.get(node.name)\n\t\t\tif (reference) return imported(reference.source, reference.name)\n\t\t\tconst variable = variables.get(node.name)\n\t\t\tif (!variable) return null\n\t\t\tconst value = evaluate(variable.expression, new Set(active).add(node.name))\n\t\t\treturn variable.member ? member(value, variable.member) : value\n\t\t}\n\t\tif (node.type === 'MemberExpression')\n\t\t\treturn member(evaluate(node.object, active), propertyName(node) ?? '')\n\t\tif (node.type === 'CallExpression' || node.type === 'NewExpression') {\n\t\t\tconst callee = evaluate(node.callee, active)\n\t\t\tif (callee === 'foundationFactory') return 'foundation'\n\t\t\tif (callee === 'Command' || callee === 'Query') return `registry:${callee}`\n\t\t\tif (callee === 'shapeFactory') return 'shape'\n\t\t\tif (callee === 'assemblyFactory') return 'assembly'\n\t\t\tif (callee === 'contractFactory' || callee === 'validator') return 'contract'\n\t\t\tif (callee === 'indexFactory') return 'table'\n\t\t\treturn null\n\t\t}\n\t\tif (node.type === 'ObjectExpression') {\n\t\t\tconst values = node.properties.map((property) =>\n\t\t\t\tproperty.type === 'Property' ? evaluate(property.value, active) : null,\n\t\t\t)\n\t\t\tif (values.length && values.every((value) => value === 'table' || value === 'topology'))\n\t\t\t\treturn 'topology'\n\t\t\tif (\n\t\t\t\tvalues.some((value) => value === 'contract' || value === 'validator') &&\n\t\t\t\tvalues.every((value) => value === 'contract' || value === 'validator' || value === 'data')\n\t\t\t)\n\t\t\t\treturn 'contract'\n\t\t\tif (values.every((value) => value === 'data')) return 'data'\n\t\t}\n\t\tif (node.type === 'Literal') return 'data'\n\t\treturn null\n\t}\n\treturn evaluate\n}\n"],"mappings":"yOAOA,MAAaA,EAAkC,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AU,OAAQA,EAAU,IAAI,EAC/D,IAAMC,EAAWrB,EAAU,IAAIkB,EAAK,IAAI,EACxC,GAAI,CAACG,EAAU,OAAO,KACtB,IAAM9B,EAAQT,EAASuC,EAAS,WAAY,IAAI,IAAIF,CAAM,CAAC,CAAC,IAAID,EAAK,IAAI,CAAC,EAC1E,OAAOG,EAAS,OAASL,EAAOzB,EAAO8B,EAAS,MAAM,EAAI9B,CAC3D,CACA,GAAI2B,EAAK,OAAS,mBACjB,OAAOF,EAAOlC,EAASoC,EAAK,OAAQC,CAAM,EAAGG,EAAaJ,CAAI,GAAK,EAAE,EACtE,GAAIA,EAAK,OAAS,kBAAoBA,EAAK,OAAS,gBAAiB,CACpE,IAAMK,EAASzC,EAASoC,EAAK,OAAQC,CAAM,EAO3C,OANII,IAAW,oBAA4B,aACvCA,IAAW,WAAaA,IAAW,QAAgB,YAAYA,IAC/DA,IAAW,eAAuB,QAClCA,IAAW,kBAA0B,WACrCA,IAAW,mBAAqBA,IAAW,YAAoB,WAC/DA,IAAW,eAAuB,QAC/B,IACR,CACA,GAAIL,EAAK,OAAS,mBAAoB,CACrC,IAAMjC,EAASiC,EAAK,WAAW,IAAK,GACnCf,EAAS,OAAS,WAAarB,EAASqB,EAAS,MAAOgB,CAAM,EAAI,IACnE,EACA,GAAIlC,EAAO,QAAUA,EAAO,MAAO,GAAUM,IAAU,SAAWA,IAAU,UAAU,EACrF,MAAO,WACR,GACCN,EAAO,KAAM,GAAUM,IAAU,YAAcA,IAAU,WAAW,GACpEN,EAAO,MAAO,GAAUM,IAAU,YAAcA,IAAU,aAAeA,IAAU,MAAM,EAEzF,MAAO,WACR,GAAIN,EAAO,MAAO,GAAUM,IAAU,MAAM,EAAG,MAAO,MACvD,CAEA,OADI2B,EAAK,OAAS,UAAkB,OAC7B,IACR,CACA,OAAOpC,CACR"}
|
|
1
|
+
{"version":3,"file":"reserved-files.mjs","names":["reservedDomainFiles","metadata","file","appFile","context","match","role","evaluate","provenance","program","values","publicExpressions","expression","expected","wanted","count","value","expressions","declarations","statement","declaration","item","specifier","exportName","imports","variables","resolver","createResolver","property","imported","source","name","target","resolveImport","filename","visited","parsed","parseSync","readFileSync","remote","evaluateRemote","member","owner","node","active","reference","variable","propertyName","callee","members"],"sources":["../../src/oxlint/reserved-files.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport type { Context, CreateRule, ESTree } from '@oxlint/plugins'\nimport { parseSync } from 'oxc-parser'\nimport { appFile, metadata, propertyName, exportName } from './ast'\nimport { createResolver, resolveImport } from './architecture'\n\n/** Reserved files prove their exported declaration's provenance, not an unused import. */\nexport const reservedDomainFiles: CreateRule = {\n\tmeta: metadata('Require kit-backed declarations in reserved domain files.', {\n\t\tanatomy:\n\t\t\t'{{file}} must export {{expected}} built with cvx-kit; imports or local lookalikes do not count.',\n\t}),\n\tcreate(context) {\n\t\tconst file = appFile(context) ?? ''\n\t\tconst match = file.match(/^domain\\/(?:.+\\/)?(commands|queries|contracts|schema|table)\\.ts$/)\n\t\tif (!match) return {}\n\t\tconst role = match[1]\n\t\treturn {\n\t\t\tProgram(program) {\n\t\t\t\tconst evaluate = provenance(context, program, context.filename)\n\t\t\t\tconst exports = publicExpressions(program)\n\t\t\t\tconst values = exports.map((expression) => evaluate(expression))\n\t\t\t\tconst expected =\n\t\t\t\t\trole === 'commands'\n\t\t\t\t\t\t? 'one Command registry'\n\t\t\t\t\t\t: role === 'queries'\n\t\t\t\t\t\t\t? 'one Query registry'\n\t\t\t\t\t\t\t: role === 'schema'\n\t\t\t\t\t\t\t\t? 'zodTable shapes'\n\t\t\t\t\t\t\t\t: role === 'contracts'\n\t\t\t\t\t\t\t\t\t? 'declarative contracts'\n\t\t\t\t\t\t\t\t\t: file === 'domain/table.ts'\n\t\t\t\t\t\t\t\t\t\t? 'createModule assembly'\n\t\t\t\t\t\t\t\t\t\t: 'a table topology map'\n\t\t\t\tconst wanted =\n\t\t\t\t\trole === 'commands'\n\t\t\t\t\t\t? 'registry:Command'\n\t\t\t\t\t\t: role === 'queries'\n\t\t\t\t\t\t\t? 'registry:Query'\n\t\t\t\t\t\t\t: role === 'schema'\n\t\t\t\t\t\t\t\t? 'shape'\n\t\t\t\t\t\t\t\t: role === 'contracts'\n\t\t\t\t\t\t\t\t\t? 'contract'\n\t\t\t\t\t\t\t\t\t: file === 'domain/table.ts'\n\t\t\t\t\t\t\t\t\t\t? 'assembly'\n\t\t\t\t\t\t\t\t\t\t: 'topology'\n\t\t\t\tconst count = values.filter((value) => value === wanted).length\n\t\t\t\tconst valid = role === 'commands' || role === 'queries' ? count === 1 : count > 0\n\t\t\t\tif (!valid)\n\t\t\t\t\tcontext.report({ node: program, messageId: 'anatomy', data: { file, expected } })\n\t\t\t},\n\t\t}\n\t},\n}\n\nfunction publicExpressions(program: ESTree.Program): ESTree.Expression[] {\n\tconst expressions: ESTree.Expression[] = []\n\tconst declarations = new Map<string, ESTree.Expression>()\n\tfor (const statement of program.body) {\n\t\tconst declaration =\n\t\t\tstatement.type === 'ExportNamedDeclaration' ? statement.declaration : statement\n\t\tif (declaration?.type === 'VariableDeclaration' && declaration.kind === 'const')\n\t\t\tfor (const item of declaration.declarations) {\n\t\t\t\tif (item.id.type === 'Identifier' && item.init) {\n\t\t\t\t\tdeclarations.set(item.id.name, item.init)\n\t\t\t\t\tif (statement.type === 'ExportNamedDeclaration') expressions.push(item.init)\n\t\t\t\t}\n\t\t\t}\n\t}\n\tfor (const statement of program.body) {\n\t\tif (\n\t\t\tstatement.type === 'ExportNamedDeclaration' &&\n\t\t\tstatement.exportKind !== 'type' &&\n\t\t\t!statement.source\n\t\t)\n\t\t\tfor (const specifier of statement.specifiers) {\n\t\t\t\tif (specifier.exportKind === 'type') continue\n\t\t\t\tconst expression = declarations.get(exportName(specifier.local) ?? '')\n\t\t\t\tif (expression) expressions.push(expression)\n\t\t\t}\n\t\tif (\n\t\t\tstatement.type === 'ExportDefaultDeclaration' &&\n\t\t\tstatement.declaration.type !== 'FunctionDeclaration' &&\n\t\t\tstatement.declaration.type !== 'ClassDeclaration' &&\n\t\t\tstatement.declaration.type !== 'TSInterfaceDeclaration'\n\t\t) {\n\t\t\texpressions.push(statement.declaration)\n\t\t}\n\t}\n\treturn expressions\n}\n\nfunction provenance(\n\tcontext: Context,\n\tprogram: ESTree.Program,\n\tfilename: string,\n\tvisited = new Set<string>(),\n) {\n\tconst imports = new Map<string, { source: string; name: string }>()\n\tconst variables = new Map<string, { expression: ESTree.Expression; member?: string }>()\n\tconst resolver = createResolver()\n\tfor (const statement of 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') continue\n\t\t\t\timports.set(specifier.local.name, {\n\t\t\t\t\tsource: statement.source.value,\n\t\t\t\t\tname:\n\t\t\t\t\t\tspecifier.type === 'ImportSpecifier'\n\t\t\t\t\t\t\t? (exportName(specifier.imported) ?? '')\n\t\t\t\t\t\t\t: specifier.type === 'ImportNamespaceSpecifier'\n\t\t\t\t\t\t\t\t? '*'\n\t\t\t\t\t\t\t\t: 'default',\n\t\t\t\t})\n\t\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 === 'Identifier') variables.set(item.id.name, { expression: item.init })\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')\n\t\t\t\t\t\t\tvariables.set(property.value.name, {\n\t\t\t\t\t\t\t\texpression: item.init,\n\t\t\t\t\t\t\t\tmember: exportName(property.key) ?? '',\n\t\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t}\n\t}\n\tfunction imported(source: string, name: string): string | null {\n\t\tif (\n\t\t\t[\n\t\t\t\t'cvx-kit',\n\t\t\t\t'cvx-kit/effect',\n\t\t\t\t'cvx-kit/components/foundation',\n\t\t\t\t'cvx-kit/contracts',\n\t\t\t\t'cvx-kit/zod-table',\n\t\t\t\t'cvx-kit/errors',\n\t\t\t].includes(source)\n\t\t) {\n\t\t\tif (name === '*') return `namespace:${source}`\n\t\t\tif (\n\t\t\t\t(source === 'cvx-kit/effect' && name === 'createEffectFoundation') ||\n\t\t\t\t(source === 'cvx-kit' && name === 'createFoundation') ||\n\t\t\t\t(['cvx-kit', 'cvx-kit/components/foundation'].includes(source) && name === 'Foundation')\n\t\t\t)\n\t\t\t\treturn 'foundationFactory'\n\t\t\tif (\n\t\t\t\t['cvx-kit', 'cvx-kit/zod-table'].includes(source) &&\n\t\t\t\t['zodTable', 'zodVariantTable'].includes(name)\n\t\t\t)\n\t\t\t\treturn 'shapeFactory'\n\t\t\tif (['cvx-kit', 'cvx-kit/zod-table'].includes(source) && name === 'createModule')\n\t\t\t\treturn 'assemblyFactory'\n\t\t\tif (source === 'cvx-kit/zod-table' && name === 'namespace') return 'namespaceFactory'\n\t\t\tif (\n\t\t\t\tsource === 'cvx-kit/contracts' &&\n\t\t\t\t['defineDomainContract', 'operationContract'].includes(name)\n\t\t\t)\n\t\t\t\treturn 'contractFactory'\n\t\t\tif (source === 'cvx-kit/errors' && name === 'defineErrorContract') return 'contractFactory'\n\t\t\treturn null\n\t\t}\n\t\tif (['zod', 'zod/v4', 'convex/values'].includes(source)) return 'validator'\n\t\tconst target = resolveImport(resolver, filename, source)\n\t\tconst file = target && appFile(context, target)\n\t\tif (\n\t\t\t!target ||\n\t\t\t!file ||\n\t\t\t!/^(?:foundation\\.ts|domain\\/.+\\/(?:schema|contracts)\\.ts)$/.test(file) ||\n\t\t\tvisited.has(target) ||\n\t\t\tvisited.size >= 6\n\t\t)\n\t\t\treturn null\n\t\tif (name === '*') return `namespace:${source}`\n\t\tconst parsed = parseSync(target, readFileSync(target, 'utf8'))\n\t\tif (parsed.errors.length) return null\n\t\t// SAFETY: oxc-parser and the rule API share these declaration fields; provenance never reads rule-API loc/tokens.\n\t\t// oxlint-disable-next-line anti-slop/no-chained-type-assertions\n\t\tconst remote = parsed.program as unknown as ESTree.Program\n\t\tconst nextVisited = new Set(visited).add(target)\n\t\tconst evaluateRemote = provenance(context, remote, target, nextVisited)\n\t\tfor (const statement of remote.body) {\n\t\t\tif (statement.type !== 'ExportNamedDeclaration' || statement.exportKind === 'type') continue\n\t\t\tif (statement.declaration?.type === 'VariableDeclaration')\n\t\t\t\tfor (const item of statement.declaration.declarations) {\n\t\t\t\t\tif (item.id.type === 'Identifier' && item.id.name === name) return evaluateRemote(item.id)\n\t\t\t\t\tif (item.id.type === 'ObjectPattern')\n\t\t\t\t\t\tfor (const property of item.id.properties)\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tproperty.type === 'Property' &&\n\t\t\t\t\t\t\t\tproperty.value.type === 'Identifier' &&\n\t\t\t\t\t\t\t\tproperty.value.name === name\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\treturn evaluateRemote(property.value)\n\t\t\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\texportName(specifier.exported) === name &&\n\t\t\t\t\t!statement.source\n\t\t\t\t)\n\t\t\t\t\treturn evaluateRemote(specifier.local)\n\t\t}\n\t\treturn null\n\t}\n\tfunction member(owner: string | null, name: string): string | null {\n\t\tif (owner === 'foundation' && ['Command', 'Query'].includes(name)) return name\n\t\tif (owner?.startsWith('namespace:')) return imported(owner.slice(10), name)\n\t\tif (owner === 'validator' || owner === 'contract') return 'validator'\n\t\tif (owner === 'shape' && name === 'table') return 'table'\n\t\tif (owner === 'table' && ['index', 'searchIndex', 'vectorIndex'].includes(name))\n\t\t\treturn 'indexFactory'\n\t\treturn null\n\t}\n\tfunction evaluate(node: ESTree.Node, active = new Set<string>()): string | null {\n\t\tif (\n\t\t\tnode.type === 'TSAsExpression' ||\n\t\t\tnode.type === 'TSSatisfiesExpression' ||\n\t\t\tnode.type === 'TSNonNullExpression'\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)) return null\n\t\t\tconst reference = imports.get(node.name)\n\t\t\tif (reference) return imported(reference.source, reference.name)\n\t\t\tconst variable = variables.get(node.name)\n\t\t\tif (!variable) return null\n\t\t\tconst value = evaluate(variable.expression, new Set(active).add(node.name))\n\t\t\treturn variable.member ? member(value, variable.member) : value\n\t\t}\n\t\tif (node.type === 'MemberExpression')\n\t\t\treturn member(evaluate(node.object, active), propertyName(node) ?? '')\n\t\tif (node.type === 'CallExpression' || node.type === 'NewExpression') {\n\t\t\tconst callee = evaluate(node.callee, active)\n\t\t\tif (callee === 'foundationFactory') return 'foundation'\n\t\t\tif (callee === 'Command' || callee === 'Query') return `registry:${callee}`\n\t\t\tif (callee === 'shapeFactory') return 'shape'\n\t\t\tif (callee === 'assemblyFactory') return 'assembly'\n\t\t\tif (callee === 'contractFactory' || callee === 'validator') return 'contract'\n\t\t\tif (callee === 'indexFactory') return 'table'\n\t\t\tif (callee === 'namespaceFactory') {\n\t\t\t\t// namespace(name, members) is a topology map when every member is a table\n\t\t\t\t// definition or a table boundary (namespace() unwraps boundaries itself).\n\t\t\t\tconst members = node.arguments[1]\n\t\t\t\tif (members?.type !== 'ObjectExpression') return null\n\t\t\t\tconst values = members.properties.map((property) =>\n\t\t\t\t\tproperty.type === 'Property' ? evaluate(property.value, active) : null,\n\t\t\t\t)\n\t\t\t\treturn values.length &&\n\t\t\t\t\tvalues.every((value) => value === 'table' || value === 'topology' || value === 'shape')\n\t\t\t\t\t? 'topology'\n\t\t\t\t\t: null\n\t\t\t}\n\t\t\treturn null\n\t\t}\n\t\tif (node.type === 'ObjectExpression') {\n\t\t\tconst values = node.properties.map((property) =>\n\t\t\t\tproperty.type === 'Property' ? evaluate(property.value, active) : null,\n\t\t\t)\n\t\t\tif (values.length && values.every((value) => value === 'table' || value === 'topology'))\n\t\t\t\treturn 'topology'\n\t\t\tif (\n\t\t\t\tvalues.some((value) => value === 'contract' || value === 'validator') &&\n\t\t\t\tvalues.every((value) => value === 'contract' || value === 'validator' || value === 'data')\n\t\t\t)\n\t\t\t\treturn 'contract'\n\t\t\tif (values.every((value) => value === 'data')) return 'data'\n\t\t}\n\t\tif (node.type === 'Literal') return 'data'\n\t\treturn null\n\t}\n\treturn evaluate\n}\n"],"mappings":"yOAOA,MAAaA,EAAkC,CAC9C,KAAMC,EAAS,4DAA6D,CAC3E,QACC,iGACF,CAAC,EACD,OAAO,EAAS,CACf,IAAMC,EAAOC,EAAQC,CAAO,GAAK,GAC3BC,EAAQH,EAAK,MAAM,kEAAkE,EAC3F,GAAI,CAACG,EAAO,MAAO,CAAC,EACpB,IAAMC,EAAOD,EAAM,GACnB,MAAO,CACN,QAAQ,EAAS,CAChB,IAAME,EAAWC,EAAWJ,EAASK,EAASL,EAAQ,QAAQ,EAExDM,EADUC,EAAkBF,CACb,CAAC,CAAC,IAAK,GAAeF,EAASK,CAAU,CAAC,EACzDC,EACLP,IAAS,WACN,uBACAA,IAAS,UACR,qBACAA,IAAS,SACR,kBACAA,IAAS,YACR,wBACAJ,IAAS,kBACR,wBACA,uBACFY,EACLR,IAAS,WACN,mBACAA,IAAS,UACR,iBACAA,IAAS,SACR,QACAA,IAAS,YACR,WACAJ,IAAS,kBACR,WACA,WACFa,EAAQL,EAAO,OAAQ,GAAUM,IAAUF,CAAM,CAAC,CAAC,QAC3CR,IAAS,YAAcA,IAAS,UAAYS,IAAU,EAAIA,EAAQ,IAE/EX,EAAQ,OAAO,CAAE,KAAMK,EAAS,UAAW,UAAW,KAAM,CAAE,OAAM,UAAS,CAAE,CAAC,CAClF,CACD,CACD,CACD,EAEA,SAASE,EAAkB,EAA8C,CACxE,IAAMM,EAAmC,CAAC,EACpCC,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jD,IAAMvC,EAASuC,EAAQ,WAAW,IAAK,GACtCrB,EAAS,OAAS,WAAarB,EAASqB,EAAS,MAAOgB,CAAM,EAAI,IACnE,EACA,OAAOlC,EAAO,QACbA,EAAO,MAAO,GAAUM,IAAU,SAAWA,IAAU,YAAcA,IAAU,OAAO,EACpF,WACA,IACJ,CACA,OAAO,IACR,CACA,GAAI2B,EAAK,OAAS,mBAAoB,CACrC,IAAMjC,EAASiC,EAAK,WAAW,IAAK,GACnCf,EAAS,OAAS,WAAarB,EAASqB,EAAS,MAAOgB,CAAM,EAAI,IACnE,EACA,GAAIlC,EAAO,QAAUA,EAAO,MAAO,GAAUM,IAAU,SAAWA,IAAU,UAAU,EACrF,MAAO,WACR,GACCN,EAAO,KAAM,GAAUM,IAAU,YAAcA,IAAU,WAAW,GACpEN,EAAO,MAAO,GAAUM,IAAU,YAAcA,IAAU,aAAeA,IAAU,MAAM,EAEzF,MAAO,WACR,GAAIN,EAAO,MAAO,GAAUM,IAAU,MAAM,EAAG,MAAO,MACvD,CAEA,OADI2B,EAAK,OAAS,UAAkB,OAC7B,IACR,CACA,OAAOpC,CACR"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cvx-kit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.33",
|
|
4
4
|
"description": "Reusable Convex application kit: foundation kernels, approvals component, zod table boundaries, WorkOS-backed auth function constructors, and audited command protocol.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"component",
|